Reviewed by Darin.
authorthatcher <thatcher@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Oct 2006 22:27:44 +0000 (22:27 +0000)
committerthatcher <thatcher@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Oct 2006 22:27:44 +0000 (22:27 +0000)
        Move the undef try/catch to WebKitPrfix.h and include algorithm so we get
        exception_defines.h and so the undef of try/catch works.

        Break off the BGRA to ARGB code into WebGraphicsExtras.c, this lets
        WebBaseNetscapePluginView.m safely compile as ObjC++ and not cause the Accelerate
        framework to complain about C++ exceptions being disabled.

        * Misc/WebGraphicsExtras.c: Added.
        (WebConvertBGRAToARGB):
        * Misc/WebGraphicsExtras.h: Added.
        * Plugins/WebBaseNetscapePluginView.m:
        (-[WebBaseNetscapePluginView _aglOffscreenImageForDrawingInRect:]):
        * WebKit.xcodeproj/project.pbxproj:
        * WebKitPrefix.h:
        * WebView/WebView.m:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@17228 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKit/ChangeLog
WebKit/Misc/WebGraphicsExtras.c [new file with mode: 0644]
WebKit/Misc/WebGraphicsExtras.h [new file with mode: 0644]
WebKit/Plugins/WebBaseNetscapePluginView.m
WebKit/WebKit.xcodeproj/project.pbxproj
WebKit/WebKitPrefix.h
WebKit/WebView/WebView.m

index d9a7085..bd2d6dc 100644 (file)
@@ -1,3 +1,23 @@
+2006-10-23  Timothy Hatcher  <timothy@apple.com>
+
+        Reviewed by Darin.
+
+        Move the undef try/catch to WebKitPrfix.h and include algorithm so we get
+        exception_defines.h and so the undef of try/catch works.
+
+        Break off the BGRA to ARGB code into WebGraphicsExtras.c, this lets
+        WebBaseNetscapePluginView.m safely compile as ObjC++ and not cause the Accelerate
+        framework to complain about C++ exceptions being disabled.
+
+        * Misc/WebGraphicsExtras.c: Added.
+        (WebConvertBGRAToARGB):
+        * Misc/WebGraphicsExtras.h: Added.
+        * Plugins/WebBaseNetscapePluginView.m:
+        (-[WebBaseNetscapePluginView _aglOffscreenImageForDrawingInRect:]):
+        * WebKit.xcodeproj/project.pbxproj:
+        * WebKitPrefix.h:
+        * WebView/WebView.m:
+
 2006-10-22  Sam Weinig  <sam.weinig@gmail.com>
 
         Reviewed by Tim H.
diff --git a/WebKit/Misc/WebGraphicsExtras.c b/WebKit/Misc/WebGraphicsExtras.c
new file mode 100644 (file)
index 0000000..1917901
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer. 
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution. 
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "WebGraphicsExtras.h"
+
+#import <Accelerate/Accelerate.h>
+#import <JavaScriptCore/Assertions.h>
+
+unsigned WebConvertBGRAToARGB(unsigned char *offscreenBuffer, int rowBytes, int x, int y, int width, int height)
+{
+    void *swizzleImageBase = offscreenBuffer + y * rowBytes + x * 4;
+    vImage_Buffer vImage = { swizzleImageBase, height, width, rowBytes };
+    uint8_t vImagePermuteMap[4] = { 3, 2, 1, 0 }; // Where { 0, 1, 2, 3 } would leave the channels unchanged; this map converts BGRA to ARGB
+    vImage_Error vImageError = vImagePermuteChannels_ARGB8888(&vImage, &vImage, vImagePermuteMap, 0);
+    if (vImageError) {
+        LOG_ERROR("Could not convert BGRA image to ARGB: %d", vImageError);
+        return FALSE;
+    }
+    return TRUE;
+}
diff --git a/WebKit/Misc/WebGraphicsExtras.h b/WebKit/Misc/WebGraphicsExtras.h
new file mode 100644 (file)
index 0000000..9232303
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer. 
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution. 
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+unsigned WebConvertBGRAToARGB(unsigned char *offscreenBuffer, int rowBytes, int x, int y, int width, int height);
+
+#ifdef __cplusplus
+}
+#endif
index 0736fae..12546b6 100644 (file)
@@ -33,6 +33,7 @@
 #import "WebFrameBridge.h"
 #import "WebFrameInternal.h" 
 #import "WebFrameView.h"
+#import "WebGraphicsExtras.h"
 #import "WebKitLogging.h"
 #import "WebKitNSStringExtras.h"
 #import "WebNSDataExtras.h"
@@ -46,7 +47,6 @@
 #import "WebNullPluginView.h"
 #import "WebPreferences.h"
 #import "WebViewInternal.h"
-#import <Accelerate/Accelerate.h>
 #import <Carbon/Carbon.h>
 #import <JavaScriptCore/Assertions.h>
 #import <JavaScriptCore/npruntime_impl.h>
@@ -2756,10 +2756,12 @@ static OSStatus TSMEventHandler(EventHandlerCallRef inHandlerRef, EventRef inEve
     GLsizei width, height;
     if (![self _getAGLOffscreenBuffer:&offscreenBuffer width:&width height:&height])
         return nil;
-        
+
+    unsigned char *plane = (unsigned char *)offscreenBuffer;
+
 #if defined(__i386__) || defined(__x86_64__)
-    // Make sure drawingInRect is inside the offscreen buffer because we're about to directly modify the bits inside drawingInRect
-    drawingInRect = NSIntersectionRect(drawingInRect, NSMakeRect(0, 0, width, height));
+    // Make rect inside the offscreen buffer because we're about to directly modify the bits inside drawingInRect
+    NSRect rect = NSIntegralRect(NSIntersectionRect(drawingInRect, NSMakeRect(0, 0, width, height)));
 
     // The offscreen buffer, being an OpenGL framebuffer, is in BGRA format on x86.  We need to swap the blue and red channels before
     // wrapping the buffer in an NSBitmapImageRep, which only supports RGBA and ARGB.
@@ -2769,24 +2771,12 @@ static OSStatus TSMEventHandler(EventHandlerCallRef inHandlerRef, EventRef inEve
     // If only a small region of the plug-in is being redrawn, then it would be a waste to convert the entire image from BGRA to ARGB.
     // Since we know what region of the image will ultimately be drawn to screen (drawingInRect), we restrict the channel swapping to
     // just that region within the offscreen buffer.
-    GLsizei rowBytes = width * 4;
-    GLvoid *swizzleImageBase = (unsigned char *)offscreenBuffer + (int)(NSMinY(drawingInRect) * rowBytes) + (int)(NSMinX(drawingInRect) * 4);
-    vImage_Buffer vImage = {
-        data: swizzleImageBase,
-        height: static_cast<vImagePixelCount>(NSHeight(drawingInRect)),
-        width: static_cast<vImagePixelCount>(NSWidth(drawingInRect)),
-        rowBytes: rowBytes
-    };
-    uint8_t vImagePermuteMap[4] = { 3, 2, 1, 0 }; // Where { 0, 1, 2, 3 } would leave the channels unchanged; this map converts BGRA to ARGB
-    vImage_Error vImageError = vImagePermuteChannels_ARGB8888(&vImage, &vImage, vImagePermuteMap, 0);
-    if (vImageError) {
-        LOG_ERROR("Could not convert BGRA image to ARGB: %d", vImageError);
+    if (!WebConvertBGRAToARGB(plane, width * 4, (int)rect.origin.x, (int)rect.origin.y, (int)rect.size.width, (int)rect.size.height))
         return nil;
-    }
 #endif /* defined(__i386__) || defined(__x86_64__) */
     
     NSBitmapImageRep *aglBitmap = [[NSBitmapImageRep alloc]
-        initWithBitmapDataPlanes:(unsigned char **)&offscreenBuffer
+        initWithBitmapDataPlanes:&plane
                       pixelsWide:width
                       pixelsHigh:height
                    bitsPerSample:8
index 4757fce..cca2ab2 100644 (file)
@@ -25,6 +25,8 @@
                1C68F671095B5FC100C2984E /* WebNodeHighlightView.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C68F665095B5FC100C2984E /* WebNodeHighlightView.h */; };
                1C68F672095B5FC100C2984E /* WebNodeHighlightView.m in Sources */ = {isa = PBXBuildFile; fileRef = 1C68F666095B5FC100C2984E /* WebNodeHighlightView.m */; };
                1C8CB07A0AE9830C00B1F6E9 /* WebEditingDelegatePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C8CB0790AE9830C00B1F6E9 /* WebEditingDelegatePrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               1CA57D620AED6A470009BDD0 /* WebGraphicsExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CA57D600AED6A470009BDD0 /* WebGraphicsExtras.h */; };
+               1CA57D630AED6A470009BDD0 /* WebGraphicsExtras.c in Sources */ = {isa = PBXBuildFile; fileRef = 1CA57D610AED6A470009BDD0 /* WebGraphicsExtras.c */; };
                220398770922D816009C3FFC /* WebBaseNetscapePluginViewInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 2203984A0922D765009C3FFC /* WebBaseNetscapePluginViewInternal.h */; settings = {ATTRIBUTES = (); }; };
                224100F3091818D900D2D266 /* WebPluginsPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 224100F2091818D900D2D266 /* WebPluginsPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
                224100F90918190100D2D266 /* WebPluginsPrivate.m in Sources */ = {isa = PBXBuildFile; fileRef = 224100F80918190100D2D266 /* WebPluginsPrivate.m */; };
                1C68F666095B5FC100C2984E /* WebNodeHighlightView.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = WebNodeHighlightView.m; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                1C6CB03E0AA6391D00D23BFD /* MigrateHeaders.make */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = MigrateHeaders.make; sourceTree = "<group>"; };
                1C8CB0790AE9830C00B1F6E9 /* WebEditingDelegatePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebEditingDelegatePrivate.h; sourceTree = "<group>"; };
+               1CA57D600AED6A470009BDD0 /* WebGraphicsExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebGraphicsExtras.h; sourceTree = "<group>"; };
+               1CA57D610AED6A470009BDD0 /* WebGraphicsExtras.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = WebGraphicsExtras.c; sourceTree = "<group>"; };
                2203984A0922D765009C3FFC /* WebBaseNetscapePluginViewInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebBaseNetscapePluginViewInternal.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                224100F2091818D900D2D266 /* WebPluginsPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebPluginsPrivate.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                224100F80918190100D2D266 /* WebPluginsPrivate.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = WebPluginsPrivate.m; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                254DC334016E1D3F0ECA149E /* Misc */ = {
                        isa = PBXGroup;
                        children = (
+                               6578F5DE045F817400000128 /* WebDownload.h */,
+                               6578F5DF045F817400000128 /* WebDownload.m */,
                                ABDDF20C08EB0DDC001E1241 /* WebDownloadInternal.h */,
+                               DD89681E09AA87240097E7F0 /* WebElementDictionary.h */,
+                               DD89681F09AA87240097E7F0 /* WebElementDictionary.m */,
+                               1CA57D600AED6A470009BDD0 /* WebGraphicsExtras.h */,
+                               1CA57D610AED6A470009BDD0 /* WebGraphicsExtras.c */,
                                F528E3E9031E91AD01CA2ACA /* WebIconDatabase.h */,
                                F528E3EA031E91AD01CA2ACA /* WebIconDatabase.m */,
-                               F528E3EB031E91AD01CA2ACA /* WebIconDatabasePrivate.h */,
                                51B2A0FF0ADB15D0002A9BEE /* WebIconDatabaseDelegate.h */,
+                               F528E3EB031E91AD01CA2ACA /* WebIconDatabasePrivate.h */,
                                2568C72C0174912D0ECA149E /* WebKit.h */,
                                F5927D4E02D26C5E01CA2DBB /* WebKitErrors.h */,
                                83730F9803FB1E660004736E /* WebKitErrors.m */,
                                BEE18F9A0472B73200CA289C /* WebLocalizableStrings.m */,
                                ED6BE2E5088C32B50044DEDC /* WebNSAttributedStringExtras.h */,
                                ED6BE2E6088C32B50044DEDC /* WebNSAttributedStringExtras.m */,
-                               9345DDB20365FFD0008635CE /* WebNSControlExtras.h */,
-                               9345DDB30365FFD0008635CE /* WebNSControlExtras.m */,
                                65EEDE51084FFB920002DB25 /* WebNSCalendarDateExtras.h */,
                                65EEDE52084FFB920002DB25 /* WebNSCalendarDateExtras.m */,
+                               9345DDB20365FFD0008635CE /* WebNSControlExtras.h */,
+                               9345DDB30365FFD0008635CE /* WebNSControlExtras.m */,
                                BECD14290565830A005BB09C /* WebNSDataExtras.h */,
-                               ED7F6D8A0980683500C235ED /* WebNSDataExtrasPrivate.h */,
                                BECD142A0565830A005BB09C /* WebNSDataExtras.m */,
+                               ED7F6D8A0980683500C235ED /* WebNSDataExtrasPrivate.h */,
                                65488D9F084FBCCB00831AD0 /* WebNSDictionaryExtras.h */,
                                65488DA0084FBCCB00831AD0 /* WebNSDictionaryExtras.m */,
                                BE887BFF056D3A6E009BB3E7 /* WebNSEventExtras.h */,
                                EDD1A5C705C83987008E3150 /* WebNSPrintOperationExtras.m */,
                                BE6DC39904C62C4E004D0EF6 /* WebNSURLExtras.h */,
                                BE6DC39A04C62C4E004D0EF6 /* WebNSURLExtras.m */,
-                               65E0F88308500917007E5CB9 /* WebNSURLRequestExtras.m */,
                                65E0F88208500917007E5CB9 /* WebNSURLRequestExtras.h */,
+                               65E0F88308500917007E5CB9 /* WebNSURLRequestExtras.m */,
                                65E0F9E408500F23007E5CB9 /* WebNSUserDefaultsExtras.h */,
                                65E0F9E508500F23007E5CB9 /* WebNSUserDefaultsExtras.m */,
                                F508946902B71D59018A9CD4 /* WebNSViewExtras.h */,
                                F560BEBD030DAF4401C1A526 /* WebSearchableTextView.m */,
                                F59668C802AD2923018635CA /* WebStringTruncator.h */,
                                F59668C902AD2923018635CA /* WebStringTruncator.m */,
-                               6578F5DE045F817400000128 /* WebDownload.h */,
-                               6578F5DF045F817400000128 /* WebDownload.m */,
-                               DD89681E09AA87240097E7F0 /* WebElementDictionary.h */,
-                               DD89681F09AA87240097E7F0 /* WebElementDictionary.m */,
                                DD7CDEE60A23BA9E00069928 /* WebTypesInternal.h */,
                        );
                        path = Misc;
                                51B2A1000ADB15D0002A9BEE /* WebIconDatabaseDelegate.h in Headers */,
                                1C8CB07A0AE9830C00B1F6E9 /* WebEditingDelegatePrivate.h in Headers */,
                                4BF99F900AE050BC00815C2B /* WebEditorClient.h in Headers */,
+                               1CA57D620AED6A470009BDD0 /* WebGraphicsExtras.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                65FFB7FD0AD0B7D30048CD05 /* WebDocumentLoaderMac.m in Sources */,
                                658BA6FD0ADB39DE00AEB387 /* WebPolicyDeciderMac.m in Sources */,
                                4BF99F910AE050BC00815C2B /* WebEditorClient.mm in Sources */,
+                               1CA57D630AED6A470009BDD0 /* WebGraphicsExtras.c in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index d051647..9bbfe54 100644 (file)
@@ -48,6 +48,7 @@
 
 #ifdef __cplusplus
 
+#include <algorithm> // needed for exception_defines.h
 #include <cstddef>
 #include <new>
 
@@ -64,3 +65,7 @@
 #endif
 
 #include <JavaScriptCore/Platform.h>
+
+/* Work around bug with C++ library that screws up Objective-C++ when exception support is disabled. */
+#undef try
+#undef catch
index 6a840e3..9f2bb05 100644 (file)
 
 #import <WebCore/WebCoreTextRenderer.h>
 
-/* Work around bug with C++ library that screws up Objective-C++ when exception support is disabled. */
-#undef try
-#undef catch
-
 #if defined(__ppc__) || defined(__ppc64__)
 #define PROCESSOR "PPC"
 #elif defined(__i386__) || defined(__x86_64__)