Cleanup in RenderThemeWin and GraphicsContextCairo/Win
authorhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 25 Sep 2006 07:39:01 +0000 (07:39 +0000)
committerhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 25 Sep 2006 07:39:01 +0000 (07:39 +0000)
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@16554 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/WebCore.vcproj/WebCore/WebCore.vcproj
WebCore/platform/cairo/GraphicsContextCairo.cpp
WebCore/platform/win/GraphicsContextWin.cpp [new file with mode: 0644]
WebCore/rendering/RenderThemeWin.cpp

index 5fca068297cccac17a5596b4a60138728caa17cb..fb77b93aef130ecc78bc4103321ce99cc5d67627 100644 (file)
@@ -1,3 +1,18 @@
+2006-09-25  Dave Hyatt  <hyat@apple.com>
+
+        Shunt the RenderTheme world transform adoption between
+        Cairo and Windows into getWindowsContext and move the method
+        out of GraphicsContextCairo and into GraphicsContextWin.
+
+        * ChangeLog:
+        * WebCore.vcproj/WebCore/WebCore.vcproj:
+        * platform/cairo/GraphicsContextCairo.cpp:
+        * platform/win/GraphicsContextWin.cpp: Added.
+        (WebCore::GraphicsContext::getWindowsContext):
+        (WebCore::GraphicsContext::releaseWindowsContext):
+        * rendering/RenderThemeWin.cpp:
+        (WebCore::prepareForDrawing):
+
 2006-09-24  Eric Seidel  <eric@eseidel.com>
 
         Reviewed by hyatt.
index 79f8cfcc2fc6d6da63aa2bba3be1f7b6fd2aa086..85f1d8eaa9022dd1511ef17dd734cd68beb98776 100644 (file)
                                        RelativePath="..\..\platform\win\GlyphMapWin.cpp"
                                        >
                                </File>
+                                <File
+                                        RelativePath="..\..\platform\win\GraphicsContextWin.cpp"
+                                </File>
                                <File
                                        RelativePath="..\..\platform\win\ImageWin.cpp"
                                        >
index a3bd55aafd7ab3d468c8730b17414c8df5729066..c282f6c104bcc341547fcf191c397c9574bfab3c 100644 (file)
@@ -452,14 +452,6 @@ void GraphicsContext::translate(float x, float y)
     cairo_translate(context, x, y);
 }
 
-HDC GraphicsContext::getWindowsContext()
-{
-    cairo_surface_t* surface = cairo_get_target(platformContext());
-    HDC hdc = cairo_win32_surface_get_dc(surface);    
-    SaveDC(hdc);
-    return hdc;
-}
-
 IntPoint GraphicsContext::origin()
 {
     cairo_matrix_t matrix;
@@ -468,14 +460,6 @@ IntPoint GraphicsContext::origin()
     return IntPoint(matrix.x0, matrix.y0);
 }
 
-void GraphicsContext::releaseWindowsContext()
-{
-    cairo_surface_t* surface = cairo_get_target(platformContext());
-    HDC hdc = cairo_win32_surface_get_dc(surface);
-    RestoreDC(hdc, -1);
-    cairo_surface_mark_dirty(surface);
-}
-
 } // namespace WebCore
 
 #endif // PLATFORM(CAIRO)
diff --git a/WebCore/platform/win/GraphicsContextWin.cpp b/WebCore/platform/win/GraphicsContextWin.cpp
new file mode 100644 (file)
index 0000000..c7229ad
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. 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. 
+ */
+
+#if PLATFORM(CAIRO)
+
+#include "config.h"
+#include "GraphicsContext.h"
+#include <cairo-win32.h>
+
+namespace WebCore
+{
+    
+HDC GraphicsContext::getWindowsContext()
+{
+    cairo_surface_t* surface = cairo_get_target(platformContext());
+    HDC hdc = cairo_win32_surface_get_dc(surface);    
+    SaveDC(hdc);
+
+    // FIXME: We need to make sure a clip is really set on the HDC.
+    // Call SetWorldTransform to honor the current Cairo transform.
+    SetGraphicsMode(hdc, GM_ADVANCED); // We need this call for themes to honor world transforms.
+    cairo_matrix_t mat;
+    cairo_get_matrix(platformContext(), &mat);
+    XFORM xform;
+    xform.eM11 = mat.xx;
+    xform.eM12 = mat.xy;
+    xform.eM21 = mat.yx;
+    xform.eM22 = mat.yy;
+    xform.eDx = mat.x0;
+    xform.eDy = mat.y0;
+    SetWorldTransform(hdc, &xform);
+
+    return hdc;
+}
+
+void GraphicsContext::releaseWindowsContext()
+{
+    cairo_surface_t* surface = cairo_get_target(platformContext());
+    HDC hdc = cairo_win32_surface_get_dc(surface);
+    RestoreDC(hdc, -1);
+    cairo_surface_mark_dirty(surface);
+}
+
+}
+
+#endif
index ee850d8bf5b0245d992cfd03aa3a58201e6434f0..f153955790f89c15685d2449d7b539018adc9fb0 100644 (file)
@@ -211,29 +211,12 @@ void RenderThemeWin::adjustButtonStyle(CSSStyleSelector*, RenderStyle* style, El
 {
 }
 
+// May need to add stuff to these later, so keep the graphics context retrieval/release in some helpers.
 static HDC prepareForDrawing(GraphicsContext* g)
 {
-    HDC hdc = g->getWindowsContext();
-    
-    // FIXME: We need to make sure a clip is really set on the HDC.  See what Mozilla does with
-    // UpdateSurfaceClip on its GraphicsContext. (Cairo may not have put its clip into native form yet.)
-
-    // Call SetWorldTransform to honor the current Cairo transform.
-    SetGraphicsMode(hdc, GM_ADVANCED); // We need this call for themes to honor world transforms.
-    cairo_matrix_t mat;
-    cairo_get_matrix(g->platformContext(), &mat);
-    XFORM xform;
-    xform.eM11 = mat.xx;
-    xform.eM12 = mat.xy;
-    xform.eM21 = mat.yx;
-    xform.eM22 = mat.yy;
-    xform.eDx = mat.x0;
-    xform.eDy = mat.y0;
-    SetWorldTransform(hdc, &xform);
-
-    return hdc;
+    return g->getWindowsContext();
 }
-
 static void doneDrawing(GraphicsContext* g)
 {
     g->releaseWindowsContext();