[SCM] WebKit Debian packaging branch, webkit-1.3, updated. upstream/1.3.7-4207-g178b198

darin at chromium.org darin at chromium.org
Mon Feb 21 00:38:11 UTC 2011


The following commit has been merged in the webkit-1.3 branch:
commit 9a23ba5d7ca29a66902cfec0adcbbdd28f7a671f
Author: darin at chromium.org <darin at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Feb 2 18:30:59 2011 +0000

    2011-02-01  Darin Fisher  <darin at chromium.org>
    
            Reviewed by Kenneth Russell.
    
            [chromium] Avoid #ifdefs in code that constructs a GraphicsContext by
            adding a helper class.
            https://bugs.webkit.org/show_bug.cgi?id=53575
    
            * WebKit.gyp:
            * src/WebFontImpl.cpp:
            (WebKit::WebFontImpl::drawText):
            * src/WebFrameImpl.cpp:
            (WebKit::WebFrameImpl::printPage):
            (WebKit::WebFrameImpl::paint):
            * src/WebPopupMenuImpl.cpp:
            (WebKit::WebPopupMenuImpl::paint):
            * src/WebScrollbarImpl.cpp:
            (WebKit::WebScrollbarImpl::paint):
            * src/painting: Added.
            * src/painting/GraphicsContextBuilder.h: Added.
            (WebKit::GraphicsContextBuilder::GraphicsContextBuilder):
            (WebKit::GraphicsContextBuilder::context):
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@77383 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/Source/WebKit/chromium/ChangeLog b/Source/WebKit/chromium/ChangeLog
index 13a68df..11a37b7 100644
--- a/Source/WebKit/chromium/ChangeLog
+++ b/Source/WebKit/chromium/ChangeLog
@@ -1,3 +1,26 @@
+2011-02-01  Darin Fisher  <darin at chromium.org>
+
+        Reviewed by Kenneth Russell.
+
+        [chromium] Avoid #ifdefs in code that constructs a GraphicsContext by
+        adding a helper class.
+        https://bugs.webkit.org/show_bug.cgi?id=53575
+
+        * WebKit.gyp:
+        * src/WebFontImpl.cpp:
+        (WebKit::WebFontImpl::drawText):
+        * src/WebFrameImpl.cpp:
+        (WebKit::WebFrameImpl::printPage):
+        (WebKit::WebFrameImpl::paint):
+        * src/WebPopupMenuImpl.cpp:
+        (WebKit::WebPopupMenuImpl::paint):
+        * src/WebScrollbarImpl.cpp:
+        (WebKit::WebScrollbarImpl::paint):
+        * src/painting: Added.
+        * src/painting/GraphicsContextBuilder.h: Added.
+        (WebKit::GraphicsContextBuilder::GraphicsContextBuilder):
+        (WebKit::GraphicsContextBuilder::context):
+
 2011-02-02  Hans Wennborg  <hans at chromium.org>
 
         Reviewed by Jeremy Orlow.
diff --git a/Source/WebKit/chromium/WebKit.gyp b/Source/WebKit/chromium/WebKit.gyp
index 57755b2..38ac7e7 100644
--- a/Source/WebKit/chromium/WebKit.gyp
+++ b/Source/WebKit/chromium/WebKit.gyp
@@ -384,6 +384,7 @@
                 'src/MediaPlayerPrivateChromium.cpp',
                 'src/NotificationPresenterImpl.h',
                 'src/NotificationPresenterImpl.cpp',
+                'src/painting/GraphicsContextBuilder.h',
                 'src/PlatformBridge.cpp',
                 'src/PlatformMessagePortChannel.cpp',
                 'src/PlatformMessagePortChannel.h',
diff --git a/Source/WebKit/chromium/src/WebFontImpl.cpp b/Source/WebKit/chromium/src/WebFontImpl.cpp
index cb37896..d3555f2 100644
--- a/Source/WebKit/chromium/src/WebFontImpl.cpp
+++ b/Source/WebKit/chromium/src/WebFontImpl.cpp
@@ -34,7 +34,7 @@
 #include "Font.h"
 #include "FontDescription.h"
 #include "GraphicsContext.h"
-#include "PlatformContextSkia.h"
+#include "painting/GraphicsContextBuilder.h"
 #include "TextRun.h"
 #include "WebFloatPoint.h"
 #include "WebFloatRect.h"
@@ -94,15 +94,9 @@ void WebFontImpl::drawText(WebCanvas* canvas, const WebTextRun& run, const WebFl
     // FIXME hook canvasIsOpaque up to the platform-specific indicators for
     // whether subpixel AA can be used for this draw. On Windows, this is
     // PlatformContextSkia::setDrawingToImageBuffer.
-#if WEBKIT_USING_CG
-    GraphicsContext gc(canvas);
-#elif WEBKIT_USING_SKIA
-    PlatformContextSkia context(canvas);
-    // PlatformGraphicsContext is actually a pointer to PlatformContextSkia.
-    GraphicsContext gc(reinterpret_cast<PlatformGraphicsContext*>(&context));
-#else
-    notImplemented();
-#endif
+
+    GraphicsContextBuilder builder(canvas);
+    GraphicsContext& gc = builder.context();
 
     gc.save();
     gc.setFillColor(color, ColorSpaceDeviceRGB);
diff --git a/Source/WebKit/chromium/src/WebFrameImpl.cpp b/Source/WebKit/chromium/src/WebFrameImpl.cpp
index 91c6543..1bade38 100644
--- a/Source/WebKit/chromium/src/WebFrameImpl.cpp
+++ b/Source/WebKit/chromium/src/WebFrameImpl.cpp
@@ -90,7 +90,6 @@
 #include "FrameLoader.h"
 #include "FrameTree.h"
 #include "FrameView.h"
-#include "GraphicsContext.h"
 #include "HTMLCollection.h"
 #include "HTMLFormElement.h"
 #include "HTMLFrameOwnerElement.h"
@@ -101,9 +100,9 @@
 #include "HistoryItem.h"
 #include "InspectorController.h"
 #include "Page.h"
+#include "painting/GraphicsContextBuilder.h"
 #include "Performance.h"
 #include "PlatformBridge.h"
-#include "PlatformContextSkia.h"
 #include "PluginDocument.h"
 #include "PrintContext.h"
 #include "RenderFrame.h"
@@ -155,10 +154,6 @@
 #include <algorithm>
 #include <wtf/CurrentTime.h>
 
-#if OS(DARWIN)
-#include "LocalCurrentGraphicsContext.h"
-#endif
-
 #if OS(LINUX) || OS(FREEBSD)
 #include <gdk/gdk.h>
 #endif
@@ -1351,15 +1346,7 @@ float WebFrameImpl::printPage(int page, WebCanvas* canvas)
         return 0;
     }
 
-#if OS(WINDOWS) || OS(LINUX) || OS(FREEBSD) || OS(SOLARIS)
-    PlatformContextSkia context(canvas);
-    GraphicsContext spool(&context);
-#elif OS(DARWIN)
-    GraphicsContext spool(canvas);
-    LocalCurrentGraphicsContext localContext(&spool);
-#endif
-
-    return m_printContext->spoolPage(spool, page);
+    return m_printContext->spoolPage(GraphicsContextBuilder(canvas).context(), page);
 }
 
 void WebFrameImpl::printEnd()
@@ -1934,18 +1921,7 @@ void WebFrameImpl::paint(WebCanvas* canvas, const WebRect& rect)
 {
     if (rect.isEmpty())
         return;
-#if WEBKIT_USING_CG
-    GraphicsContext gc(canvas);
-    LocalCurrentGraphicsContext localContext(&gc);
-#elif WEBKIT_USING_SKIA
-    PlatformContextSkia context(canvas);
-
-    // PlatformGraphicsContext is actually a pointer to PlatformContextSkia
-    GraphicsContext gc(reinterpret_cast<PlatformGraphicsContext*>(&context));
-#else
-    notImplemented();
-#endif
-    paintWithContext(gc, rect);
+    paintWithContext(GraphicsContextBuilder(canvas).context(), rect);
 }
 
 void WebFrameImpl::createFrameView()
diff --git a/Source/WebKit/chromium/src/WebPopupMenuImpl.cpp b/Source/WebKit/chromium/src/WebPopupMenuImpl.cpp
index 4b8f0f6..b4d4246 100644
--- a/Source/WebKit/chromium/src/WebPopupMenuImpl.cpp
+++ b/Source/WebKit/chromium/src/WebPopupMenuImpl.cpp
@@ -35,7 +35,7 @@
 #include "FramelessScrollView.h"
 #include "FrameView.h"
 #include "IntRect.h"
-#include "PlatformContextSkia.h"
+#include "painting/GraphicsContextBuilder.h"
 #include "PlatformKeyboardEvent.h"
 #include "PlatformMouseEvent.h"
 #include "PlatformWheelEvent.h"
@@ -164,18 +164,8 @@ void WebPopupMenuImpl::paint(WebCanvas* canvas, const WebRect& rect)
     if (!m_widget)
         return;
 
-    if (!rect.isEmpty()) {
-#if WEBKIT_USING_CG
-        GraphicsContext gc(canvas);
-#elif WEBKIT_USING_SKIA
-        PlatformContextSkia context(canvas);
-        // PlatformGraphicsContext is actually a pointer to PlatformContextSkia.
-        GraphicsContext gc(reinterpret_cast<PlatformGraphicsContext*>(&context));
-#else
-        notImplemented();
-#endif
-        m_widget->paint(&gc, rect);
-    }
+    if (!rect.isEmpty())
+        m_widget->paint(&GraphicsContextBuilder(canvas).context(), rect);
 }
 
 void WebPopupMenuImpl::themeChanged()
diff --git a/Source/WebKit/chromium/src/WebScrollbarImpl.cpp b/Source/WebKit/chromium/src/WebScrollbarImpl.cpp
index 128a1be..57ea92e 100644
--- a/Source/WebKit/chromium/src/WebScrollbarImpl.cpp
+++ b/Source/WebKit/chromium/src/WebScrollbarImpl.cpp
@@ -33,7 +33,7 @@
 
 #include "GraphicsContext.h"
 #include "KeyboardCodes.h"
-#include "PlatformContextSkia.h"
+#include "painting/GraphicsContextBuilder.h"
 #include "Scrollbar.h"
 #include "ScrollbarTheme.h"
 #include "ScrollTypes.h"
@@ -119,18 +119,7 @@ void WebScrollbarImpl::scroll(ScrollDirection direction, ScrollGranularity granu
 
 void WebScrollbarImpl::paint(WebCanvas* canvas, const WebRect& rect)
 {
-#if WEBKIT_USING_CG
-    GraphicsContext gc(canvas);
-#elif WEBKIT_USING_SKIA
-    PlatformContextSkia context(canvas);
-
-    // PlatformGraphicsContext is actually a pointer to PlatformContextSkia
-    GraphicsContext gc(reinterpret_cast<PlatformGraphicsContext*>(&context));
-#else
-    notImplemented();
-#endif
-
-    m_scrollbar->paint(&gc, rect);
+    m_scrollbar->paint(&GraphicsContextBuilder(canvas).context(), rect);
 }
 
 bool WebScrollbarImpl::handleInputEvent(const WebInputEvent& event)
diff --git a/Source/WebKit/chromium/src/painting/GraphicsContextBuilder.h b/Source/WebKit/chromium/src/painting/GraphicsContextBuilder.h
new file mode 100644
index 0000000..5ffae8e
--- /dev/null
+++ b/Source/WebKit/chromium/src/painting/GraphicsContextBuilder.h
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2011 Google 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:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * 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.
+ *     * Neither the name of Google Inc. 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 THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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.
+ */
+
+#ifndef GraphicsContextBuilder_h
+#define GraphicsContextBuilder_h
+
+#include "GraphicsContext.h"
+
+#if WEBKIT_USING_CG
+#include "LocalCurrentGraphicsContext.h"
+#elif WEBKIT_USING_SKIA
+#include "PlatformContextSkia.h"
+#endif
+
+namespace WebKit {
+
+#if WEBKIT_USING_CG
+
+class GraphicsContextBuilder {
+public:
+    GraphicsContextBuilder(WebCanvas* canvas)
+        : m_graphicsContext(canvas)
+        , m_localContext(&m_graphicsContext) 
+    {
+    }
+
+    WebCore::GraphicsContext& context() { return m_graphicsContext; }
+
+private:
+    WebCore::GraphicsContext m_graphicsContext;
+    WebCore::LocalCurrentGraphicsContext m_localContext;
+};
+
+#elif WEBKIT_USING_SKIA
+
+class GraphicsContextBuilder {
+public:
+    GraphicsContextBuilder(WebCanvas* canvas)
+        : m_platformContext(canvas)
+        , m_graphicsContext(&m_platformContext)
+    {
+    }
+
+    WebCore::GraphicsContext& context() { return m_graphicsContext; }
+
+private:
+    WebCore::PlatformContextSkia m_platformContext;
+    WebCore::GraphicsContext m_graphicsContext;
+};
+
+#else
+#error "Need to define GraphicsContextBuilder!"
+#endif
+
+} // namespace WebKit
+
+#endif

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list