[wx] Enable wxWebKit to run using the wxGC Cairo backend on platforms other than...
authorkevino@webkit.org <kevino@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 4 Sep 2011 16:49:10 +0000 (16:49 +0000)
committerkevino@webkit.org <kevino@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 4 Sep 2011 16:49:10 +0000 (16:49 +0000)
https://bugs.webkit.org/show_bug.cgi?id=67577

Reviewed by Kevin Ollivier.

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

19 files changed:
ChangeLog
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/GlyphBuffer.h
Source/WebCore/platform/graphics/wx/GraphicsContextWx.cpp
Source/WebCore/platform/graphics/wx/PathWx.cpp
Source/WebCore/platform/graphics/wx/TransformationMatrixWx.cpp
Source/WebCore/platform/image-decoders/wx/ImageDecoderWx.cpp
Source/WebCore/platform/wx/ContextMenuWx.cpp
Source/WebCore/platform/wx/RenderThemeWx.cpp
Source/WebCore/platform/wx/ScrollbarThemeWx.cpp
Source/WebCore/platform/wx/wxcode/gtk/non-kerned-drawing.cpp
Source/WebCore/platform/wx/wxcode/win/non-kerned-drawing.cpp
Source/WebCore/platform/wx/wxcode/win/scrollbar_render.cpp
Source/WebKit/wx/ChangeLog
Source/WebKit/wx/WebFrame.cpp
Source/WebKit/wx/WebView.cpp
Tools/ChangeLog
Tools/waf/build/settings.py
wscript

index 280d9a7..cec152c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2011-09-04  Robin Dunn  <robin@alldunn.com>
+
+        [wx] Enable wxWebKit to run using the wxGC Cairo backend on platforms other than GTK.
+        https://bugs.webkit.org/show_bug.cgi?id=67577
+
+        Reviewed by Kevin Ollivier.
+
+        * wscript:
+
 2011-08-30  Aaron Colwell  <acolwell@chromium.org>
 
         Add MediaSource API to HTMLMediaElement
index 947e437..b79c1ac 100644 (file)
@@ -1,3 +1,58 @@
+2011-09-04  Robin Dunn  <robin@alldunn.com>
+
+        [wx] Enable wxWebKit to run using the wxGC Cairo backend on platforms other than GTK.
+        https://bugs.webkit.org/show_bug.cgi?id=67577
+
+        Reviewed by Kevin Ollivier.
+
+        * platform/graphics/GlyphBuffer.h:
+        (WebCore::GlyphBuffer::glyphAt):
+        (WebCore::GlyphBuffer::add):
+        * platform/graphics/wx/GraphicsContextWx.cpp:
+        (WebCore::GraphicsContext::clipOut):
+        (WebCore::GraphicsContext::clipPath):
+        * platform/graphics/wx/PathWx.cpp:
+        (WebCore::Path::Path):
+        (WebCore::Path::clear):
+        * platform/graphics/wx/TransformationMatrixWx.cpp:
+        (WebCore::TransformationMatrix::operator wxGraphicsMatrix):
+        (WebCore::AffineTransform::operator wxGraphicsMatrix):
+        * platform/image-decoders/wx/ImageDecoderWx.cpp:
+        (WebCore::ImageFrame::asNewNativeImage):
+        * platform/wx/ContextMenuWx.cpp:
+        (ContextMenu::ContextMenu):
+        * platform/wx/LocalDC.h: Added.
+        (WebCore::LocalDC::LocalDC):
+        (WebCore::LocalDC::context):
+        (WebCore::LocalDC::~LocalDC):
+        * platform/wx/RenderThemeWx.cpp:
+        (WebCore::RenderThemeWx::paintButton):
+        (WebCore::RenderThemeWx::paintTextField):
+        (WebCore::RenderThemeWx::paintMenuList):
+        (WebCore::RenderThemeWx::paintMenuListButton):
+        * platform/wx/ScrollbarThemeWx.cpp:
+        (WebCore::ScrollbarThemeWx::paint):
+        * platform/wx/wxcode/cairo: Added.
+        * platform/wx/wxcode/cairo/non-kerned-drawing.cpp: Added.
+        (WebCore::pangoFontMap):
+        (WebCore::createPangoFontForFont):
+        (WebCore::createScaledFontForFont):
+        (WebCore::pango_font_get_glyph):
+        (WebCore::drawTextWithSpacing):
+        * platform/wx/wxcode/gdiplus: Added.
+        * platform/wx/wxcode/gdiplus/non-kerned-drawing.cpp: Added.
+        (dmin):
+        (dmax):
+        (DegToRad):
+        (RadToDeg):
+        (WebCore::drawTextWithSpacing):
+        * platform/wx/wxcode/gtk/non-kerned-drawing.cpp: Removed.
+        * platform/wx/wxcode/win/non-kerned-drawing.cpp: Removed.
+        * platform/wx/wxcode/win/scrollbar_render.cpp:
+        (GraphicsHDC::GraphicsHDC):
+        (GraphicsHDC::~GraphicsHDC):
+        (wxRenderer_DrawScrollbar):
+
 2011-09-03  Laszlo Gombos  <laszlo.1.gombos@nokia.com>
 
         REGRESSION (r86268): Fix for qt_networkAccessAllowed()
index 0158de3..3e611b5 100644 (file)
@@ -43,7 +43,7 @@
 #include <ApplicationServices/ApplicationServices.h>
 #endif
 
-#if USE(CAIRO) || (PLATFORM(WX) && defined(__WXGTK__))
+#if USE(CAIRO) || (PLATFORM(WX) && defined(wxUSE_CAIRO) && wxUSE_CAIRO)
 #include <cairo.h>
 #endif
 
@@ -51,7 +51,7 @@ namespace WebCore {
 
 class SimpleFontData;
 
-#if USE(CAIRO)
+#if USE(CAIRO) || (PLATFORM(WX) && defined(wxUSE_CAIRO) && wxUSE_CAIRO)
 // FIXME: Why does Cairo use such a huge struct instead of just an offset into an array?
 typedef cairo_glyph_t GlyphBufferGlyph;
 #elif OS(WINCE)
@@ -117,7 +117,7 @@ public:
 
     Glyph glyphAt(int index) const
     {
-#if USE(CAIRO)
+#if USE(CAIRO) || (PLATFORM(WX) && defined(wxUSE_CAIRO) && wxUSE_CAIRO)
         return m_glyphs[index].index;
 #else
         return m_glyphs[index];
@@ -149,7 +149,7 @@ public:
     {
         m_fontData.append(font);
 
-#if USE(CAIRO)
+#if USE(CAIRO) || (PLATFORM(WX) && defined(wxUSE_CAIRO) && wxUSE_CAIRO)
         cairo_glyph_t cairoGlyph;
         cairoGlyph.index = glyph;
         m_glyphs.append(cairoGlyph);
@@ -180,7 +180,7 @@ public:
     void add(Glyph glyph, const SimpleFontData* font, GlyphBufferAdvance advance)
     {
         m_fontData.append(font);
-#if USE(CAIRO)
+#if USE(CAIRO) || (PLATFORM(WX) && defined(wxUSE_CAIRO) && wxUSE_CAIRO)
         cairo_glyph_t cairoGlyph;
         cairoGlyph.index = glyph;
         m_glyphs.append(cairoGlyph);
index f032537..b822bcf 100644 (file)
 #include <wx/dcgraph.h>
 #include <wx/graphics.h>
 
+#if wxUSE_CAIRO
+#include <cairo.h>
+#endif
+
 #if __WXMAC__
 #include <Carbon/Carbon.h>
 #elif __WXMSW__
@@ -354,7 +358,18 @@ void GraphicsContext::clipOut(const IntRect& rect)
 #if USE(WXGC)
     wxGraphicsContext* gc = m_data->context->GetGraphicsContext();
 
-#ifdef __WXMAC__
+#if wxUSE_CAIRO
+    double x1, y1, x2, y2;
+    cairo_t* cr = (cairo_t*)gc->GetNativeContext();
+    cairo_clip_extents(cr, &x1, &y1, &x2, &y2);
+    cairo_rectangle(cr, x1, y1, x2 - x1, y2 - y1);
+    cairo_rectangle(cr, rect.x(), rect.y(), rect.width(), rect.height());
+    cairo_fill_rule_t savedFillRule = cairo_get_fill_rule(cr);
+    cairo_set_fill_rule(cr, CAIRO_FILL_RULE_EVEN_ODD);
+    cairo_clip(cr);
+    cairo_set_fill_rule(cr, savedFillRule);
+
+#elif __WXMAC__
     CGContextRef context = (CGContextRef)gc->GetNativeContext();
 
     CGRect rects[2] = { CGContextGetClipBoundingBox(context), CGRectMake(rect.x(), rect.y(), rect.width(), rect.height()) };
@@ -362,9 +377,8 @@ void GraphicsContext::clipOut(const IntRect& rect)
     CGContextAddRects(context, rects, 2);
     CGContextEOClip(context);
     return;
-#endif
 
-#ifdef __WXMSW__
+#elif __WXMSW__
     Gdiplus::Graphics* g = (Gdiplus::Graphics*)gc->GetNativeContext();
     Gdiplus::Region excludeRegion(Gdiplus::Rect(rect.x(), rect.y(), rect.width(), rect.height()));
     g->ExcludeClip(&excludeRegion);
@@ -386,7 +400,16 @@ void GraphicsContext::clipPath(const Path& path, WindRule clipRule)
     
     wxGraphicsContext* gc = m_data->context->GetGraphicsContext();
 
-#if __WXMAC__
+#if wxUSE_CAIRO
+    cairo_t* cr = (cairo_t*)gc->GetNativeContext();
+    cairo_path_t* nativePath = (cairo_path_t*)path.platformPath()->GetNativePath();
+
+    cairo_new_path(cr);
+    cairo_append_path(cr, nativePath);
+
+    cairo_set_fill_rule(cr, clipRule == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING);
+    cairo_clip(cr);
+#elif __WXMAC__
     CGContextRef context = (CGContextRef)gc->GetNativeContext();   
     CGPathRef nativePath = (CGPathRef)path.platformPath()->GetNativePath(); 
     
index a95cc1c..2b010f6 100644 (file)
@@ -57,7 +57,12 @@ Path::Path()
     // renderer an app is using right now with wx API, so we will just handle
     // the common case.
 #if USE(WXGC)
-    wxGraphicsRenderer* renderer = wxGraphicsRenderer::GetDefaultRenderer(); 
+    wxGraphicsRenderer* renderer = 0;
+#if wxUSE_CAIRO
+    renderer = wxGraphicsRenderer::GetCairoRenderer();
+#else
+    renderer = wxGraphicsRenderer::GetDefaultRenderer();
+#endif
     if (renderer) {
         wxGraphicsPath path = renderer->CreatePath();
         m_path = new wxGraphicsPath(path);
@@ -128,8 +133,12 @@ void Path::clear()
     if (m_path)
         delete m_path;
 
-#if USE(WXGC)   
-    wxGraphicsRenderer* renderer = wxGraphicsRenderer::GetDefaultRenderer(); 
+#if USE(WXGC)
+#if wxUSE_CAIRO
+    wxGraphicsRenderer* renderer = wxGraphicsRenderer::GetCairoRenderer();
+#else
+    wxGraphicsRenderer* renderer = wxGraphicsRenderer::GetDefaultRenderer();
+#endif
     if (renderer) {
         wxGraphicsPath path = renderer->CreatePath();
         m_path = new wxGraphicsPath(path);
index 1937986..e87c7ed 100644 (file)
@@ -40,7 +40,12 @@ namespace WebCore {
 #if USE(WXGC)
 TransformationMatrix::operator wxGraphicsMatrix() const
 {
-    wxGraphicsRenderer* renderer = wxGraphicsRenderer::GetDefaultRenderer();
+    wxGraphicsRenderer* renderer = 0;
+#if wxUSE_CAIRO
+    renderer = wxGraphicsRenderer::GetCairoRenderer();
+#else
+    renderer = wxGraphicsRenderer::GetDefaultRenderer();
+#endif
     ASSERT(renderer);
     
     wxGraphicsMatrix matrix = renderer->CreateMatrix(a(), b(), c(), d(), e(), f());
@@ -49,7 +54,12 @@ TransformationMatrix::operator wxGraphicsMatrix() const
 
 AffineTransform::operator wxGraphicsMatrix() const
 {
-    wxGraphicsRenderer* renderer = wxGraphicsRenderer::GetDefaultRenderer();
+    wxGraphicsRenderer* renderer = 0;
+#if wxUSE_CAIRO
+    renderer = wxGraphicsRenderer::GetCairoRenderer();
+#else
+    renderer = wxGraphicsRenderer::GetDefaultRenderer();
+#endif
     ASSERT(renderer);
     
     wxGraphicsMatrix matrix = renderer->CreateMatrix(a(), b(), c(), d(), e(), f());
index a9614c3..0e0479e 100644 (file)
@@ -84,7 +84,14 @@ NativeImagePtr ImageFrame::asNewNativeImage() const
     ASSERT(bmp->IsOk());
 
 #if USE(WXGC)
-    wxGraphicsBitmap* bitmap = new wxGraphicsBitmap(wxGraphicsRenderer::GetDefaultRenderer()->CreateBitmap(*bmp));
+    wxGraphicsRenderer* renderer = 0;
+#if wxUSE_CAIRO
+    renderer = wxGraphicsRenderer::GetCairoRenderer();
+#else
+    renderer = wxGraphicsRenderer::GetDefaultRenderer();
+#endif
+    ASSERT(renderer);
+    wxGraphicsBitmap* bitmap = new wxGraphicsBitmap(renderer->CreateBitmap(*bmp));
     delete bmp;
     return bitmap;
 #else
index a1bab37..73329a9 100644 (file)
@@ -44,7 +44,7 @@ ContextMenuItem* ContextMenu::itemWithId(int id)
 
 ContextMenu::ContextMenu()
 {
-    m_platformDescription = new wxMenu(0);
+    m_platformDescription = new wxMenu((long)0);
 }
 
 ContextMenu::~ContextMenu()
index 5a23458..faf2f7c 100644 (file)
@@ -30,6 +30,7 @@
 #include "FrameView.h"
 #include "GraphicsContext.h"
 #include "HostWindow.h"
+#include "LocalDC.h"
 #include "NotImplemented.h"
 #include "PaintInfo.h"
 #include "RenderView.h"
 
 namespace WebCore {
 
-IntRect getAdjustedRect(wxDC* dc, const IntRect& r)
-{
-    IntRect rect = r;
-// On Mac, wxGraphicsContext and wxDC share the same native implementation,
-// and so transformations are available.
-// On Win and Linux, however, this is not true and transforms are lost,
-// so we need to restore them here.
-#if !wxCHECK_VERSION(2, 9, 2) && USE(WXGC) && !defined(__WXMAC__)
-    LOG_ERROR("Rect is (%d, %d)\n", rect.x(), rect.y());
-    double xtrans = 0;
-    double ytrans = 0;
-    
-    wxGCDC* gcdc = static_cast<wxGCDC*>(dc);
-    wxGraphicsContext* gc = gcdc->GetGraphicsContext();
-    gc->GetTransform().TransformPoint(&xtrans, &ytrans);
-    rect.setX(r.x() + (int)xtrans);
-    rect.setY(r.y() + (int)ytrans);
-    LOG_ERROR("Transform is (%f, %f), (%d, %d)\n", xtrans, ytrans, rect.x(), rect.y());
-#endif
-
-    return rect;
-}
-
 class RenderThemeWx : public RenderTheme {
 private:
     RenderThemeWx() : RenderTheme() { }
@@ -288,9 +266,11 @@ bool RenderThemeWx::paintButton(RenderObject* o, const PaintInfo& i, const IntRe
 {
     wxWindow* window = nativeWindowForRenderObject(o);
     wxDC* dc = static_cast<wxDC*>(i.context->platformContext());
+    LocalDC localDC(dc, r);
+
     int flags = 0;
     
-    IntRect rect = getAdjustedRect(dc, r);
+    IntRect rect = r;
 
     if (!isEnabled(o))
         flags |= wxCONTROL_DISABLED;
@@ -303,22 +283,22 @@ bool RenderThemeWx::paintButton(RenderObject* o, const PaintInfo& i, const IntRe
         flags |= wxCONTROL_PRESSED;
     
     if (part == PushButtonPart || part == ButtonPart)
-        wxRendererNative::Get().DrawPushButton(window, *dc, rect, flags);
+        wxRendererNative::Get().DrawPushButton(window, *localDC.context(), rect, flags);
     else if(part == RadioPart) {
         if (isChecked(o))
             flags |= wxCONTROL_CHECKED;
 #if wxCHECK_VERSION(2,9,1)
-        wxRendererNative::Get().DrawRadioBitmap(window, *dc, rect, flags);
+        wxRendererNative::Get().DrawRadioBitmap(window, *localDC.context(), rect, flags);
 #elif wxCHECK_VERSION(2,9,0)
-        wxRendererNative::Get().DrawRadioButton(window, *dc, rect, flags);
+        wxRendererNative::Get().DrawRadioButton(window, *localDC.context(), rect, flags);
 #else
-        wxRenderer_DrawRadioButton(window, *dc, rect, flags);
+        wxRenderer_DrawRadioButton(window, *localDC.context(), rect, flags);
 #endif
     }
     else if(part == CheckboxPart) {
         if (isChecked(o))
             flags |= wxCONTROL_CHECKED;
-        wxRendererNative::Get().DrawCheckBox(window, *dc, rect, flags);
+        wxRendererNative::Get().DrawCheckBox(window, *localDC.context(), rect, flags);
     }
     return false;
 }
@@ -332,18 +312,19 @@ bool RenderThemeWx::paintTextField(RenderObject* o, const PaintInfo& i, const In
 {
     wxWindow* window = nativeWindowForRenderObject(o);
     wxDC* dc = static_cast<wxDC*>(i.context->platformContext());
+    LocalDC localDC(dc, r);
     int flags = 0;
     
-    IntRect rect = getAdjustedRect(dc, r);
+    IntRect rect = r;
 
     ControlPart part = o->style()->appearance();
     if (supportsFocus(part) && isFocused(o))
         flags |= wxCONTROL_FOCUSED;
 
 #if wxCHECK_VERSION(2,9,0)
-    wxRendererNative::Get().DrawTextCtrl(window, *dc, rect, flags);
+    wxRendererNative::Get().DrawTextCtrl(window, *localDC.context(), rect, flags);
 #else
-    wxRenderer_DrawTextCtrl(window, *dc, r, 0);
+    wxRenderer_DrawTextCtrl(window, *localDC.context(), r, 0);
 #endif
 
     return false;
@@ -369,8 +350,9 @@ bool RenderThemeWx::paintMenuList(RenderObject* o, const PaintInfo& i, const Int
 {
     wxWindow* window = nativeWindowForRenderObject(o);
     wxDC* dc = static_cast<wxDC*>(i.context->platformContext());
-    IntRect rect = getAdjustedRect(dc, r);
+
+    LocalDC localDC(dc, r);
+    IntRect rect = r;
 
     int flags = 0;      
     if (!isEnabled(o))
@@ -383,9 +365,9 @@ bool RenderThemeWx::paintMenuList(RenderObject* o, const PaintInfo& i, const Int
         flags |= wxCONTROL_PRESSED;
 
 #if wxCHECK_VERSION(2,9,0)
-    wxRendererNative::Get().DrawChoice(window, *dc, rect, flags);
+    wxRendererNative::Get().DrawChoice(window, *localDC.context(), rect, flags);
 #else
-    wxRenderer_DrawChoice(window, *dc, rect, flags);
+    wxRenderer_DrawChoice(window, *localDC.context(), rect, flags);
 #endif
 
     return false;
@@ -400,8 +382,8 @@ bool RenderThemeWx::paintMenuListButton(RenderObject* o, const PaintInfo& i, con
 {
     wxWindow* window = nativeWindowForRenderObject(o);
     wxDC* dc = static_cast<wxDC*>(i.context->platformContext());
-
-    IntRect rect = getAdjustedRect(dc, r);
+    LocalDC localDC(dc, r);
+    IntRect rect = r;
 
     int flags = 0;      
     if (!isEnabled(o))
@@ -413,7 +395,7 @@ bool RenderThemeWx::paintMenuListButton(RenderObject* o, const PaintInfo& i, con
     if (isPressed(o))
         flags |= wxCONTROL_PRESSED;
 
-    wxRendererNative::Get().DrawComboBoxDropButton(window, *dc, rect, flags);
+    wxRendererNative::Get().DrawComboBoxDropButton(window, *localDC.context(), rect, flags);
             
     return false;
 }
index 957f958..a3db5ed 100644 (file)
 #include "config.h"
 #include "ScrollbarThemeWx.h"
 
+// see http://trac.wxwidgets.org/ticket/11482
+// we need to include this before LocalDC as it includes wx headers
+#ifdef __WXMSW__
+#   include "wx/msw/winundef.h"
+#endif
+
 #include "HostWindow.h"
+#include "LocalDC.h"
 #include "NotImplemented.h"
 #include "PlatformMouseEvent.h"
 #include "ScrollableArea.h"
@@ -193,18 +200,17 @@ bool ScrollbarThemeWx::paint(Scrollbar* scrollbar, GraphicsContext* context, con
     
     wxDC* dc = static_cast<wxDC*>(context->platformContext());
     
-    context->save();
     ScrollView* root = scrollbar->root();
     ASSERT(root);
     if (!root)
         return false;
     
-    wxWindow* webview = root->hostWindow()->platformPageClient(); 
+    wxWindow* webview = root->hostWindow()->platformPageClient();
+    LocalDC localDC(dc, scrollbar->frameRect());
     
-    wxRenderer_DrawScrollbar(webview, *dc, scrollbar->frameRect(), orientation, scrollbar->currentPos(), static_cast<wxScrollbarPart>(scrollbar->pressedPart()),    
+    wxRenderer_DrawScrollbar(webview, *localDC.context(), scrollbar->frameRect(), orientation, scrollbar->currentPos(), static_cast<wxScrollbarPart>(scrollbar->pressedPart()),    
                      static_cast<wxScrollbarPart>(scrollbar->hoveredPart()), scrollbar->maximum(), scrollbar->pageStep(), flags);
 
-    context->restore();
     return true;
 }
 
index bf745e0..e69de29 100644 (file)
@@ -1,245 +0,0 @@
-/*
- * Copyright (C) 2007 Kevin Watters, Kevin Ollivier.  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.
- */
-
-#include "config.h"
-#include "GlyphBuffer.h"
-#include "GraphicsContext.h"
-#include "SimpleFontData.h"
-
-#include <wx/dc.h>
-#include <wx/dcgraph.h>
-#include <wx/defs.h>
-#include <wx/dcclient.h>
-#include <wx/gdicmn.h>
-#include <vector>
-
-#if USE(WXGC)
-#include <cairo.h>
-#include <assert.h>
-
-#include <pango/pango.h>
-#include <pango/pangocairo.h>
-
-// Use cairo-ft if a recent enough Pango version isn't available
-#if !PANGO_VERSION_CHECK(1,18,0)
-#include <cairo-ft.h>
-#include <pango/pangofc-fontmap.h>
-#endif
-
-#endif
-
-#include <gtk/gtk.h>
-
-namespace WebCore {
-
-#if USE(WXGC)
-static PangoFontMap* g_fontMap;
-
-PangoFontMap* pangoFontMap()
-{
-    if (!g_fontMap)
-        g_fontMap = pango_cairo_font_map_get_default();
-
-    return g_fontMap;
-}
-
-PangoFont* createPangoFontForFont(const wxFont* wxfont)
-{
-    ASSERT(wxfont && wxfont->Ok());
-
-    const char* face = wxfont->GetFaceName().mb_str(wxConvUTF8);
-    char const* families[] = {
-        face,
-        0
-    };
-
-    switch (wxfont->GetFamily()) {
-    case wxFONTFAMILY_ROMAN:
-        families[1] = "serif";
-        break;
-    case wxFONTFAMILY_SWISS:
-        families[1] = "sans";
-        break;
-    case wxFONTFAMILY_MODERN:
-        families[1] = "monospace";
-        break;
-    default:
-        families[1] = "sans";
-    }
-    
-    PangoFontDescription* description = pango_font_description_new();
-    pango_font_description_set_absolute_size(description, wxfont->GetPointSize() * PANGO_SCALE);
-    PangoFont* pangoFont = 0;
-    PangoContext* pangoContext = 0;
-
-    switch (wxfont->GetWeight()) {
-    case wxFONTWEIGHT_LIGHT:
-        pango_font_description_set_weight(description, PANGO_WEIGHT_LIGHT);
-        break;
-    case wxFONTWEIGHT_NORMAL:
-        pango_font_description_set_weight(description, PANGO_WEIGHT_NORMAL);
-        break;
-    case wxFONTWEIGHT_BOLD:
-        pango_font_description_set_weight(description, PANGO_WEIGHT_BOLD);
-        break;
-    }
-
-    switch (wxfont->GetStyle()) {
-    case wxFONTSTYLE_NORMAL:
-        pango_font_description_set_style(description, PANGO_STYLE_NORMAL);
-        break;
-    case wxFONTSTYLE_ITALIC:
-        pango_font_description_set_style(description, PANGO_STYLE_ITALIC);
-        break;
-    case wxFONTSTYLE_SLANT:
-        pango_font_description_set_style(description, PANGO_STYLE_OBLIQUE);
-        break;
-    }
-
-    PangoFontMap* fontMap = pangoFontMap();
-
-    pangoContext = pango_cairo_font_map_create_context(PANGO_CAIRO_FONT_MAP(fontMap));
-    for (unsigned i = 0; !pangoFont && i < G_N_ELEMENTS(families); i++) {
-        pango_font_description_set_family(description, families[i]);
-        pango_context_set_font_description(pangoContext, description);
-        pangoFont = pango_font_map_load_font(fontMap, pangoContext, description);
-    }
-    pango_font_description_free(description);
-
-    return pangoFont;
-}
-
-cairo_scaled_font_t* createScaledFontForFont(const wxFont* wxfont)
-{
-    ASSERT(wxfont && wxfont->Ok());
-
-    cairo_scaled_font_t* scaledFont = NULL;
-    PangoFont* pangoFont = createPangoFontForFont(wxfont);
-    
-#if PANGO_VERSION_CHECK(1,18,0)
-    if (pangoFont)
-        scaledFont = cairo_scaled_font_reference(pango_cairo_font_get_scaled_font(PANGO_CAIRO_FONT(pangoFont)));
-#endif
-
-    return scaledFont;
-}
-
-PangoGlyph pango_font_get_glyph(PangoFont* font, PangoContext* context, gunichar wc)
-{
-    PangoGlyph result = 0;
-    gchar buffer[7];
-
-    gint  length = g_unichar_to_utf8(wc, buffer);
-    g_return_val_if_fail(length, 0);
-
-    GList* items = pango_itemize(context, buffer, 0, length, NULL, NULL);
-
-    if (g_list_length(items) == 1) {
-        PangoItem* item = static_cast<PangoItem*>(items->data);
-        PangoFont* tmpFont = item->analysis.font;
-        item->analysis.font = font;
-
-        PangoGlyphString* glyphs = pango_glyph_string_new();
-        pango_shape(buffer, length, &item->analysis, glyphs);
-
-        item->analysis.font = tmpFont;
-
-        if (glyphs->num_glyphs == 1)
-            result = glyphs->glyphs[0].glyph;
-        else
-            g_warning("didn't get 1 glyph but %d", glyphs->num_glyphs);
-
-        pango_glyph_string_free(glyphs);
-    }
-
-    g_list_foreach(items, (GFunc)pango_item_free, NULL);
-    g_list_free(items);
-
-    return result;
-}
-#endif // USE(WXGC)
-
-
-void drawTextWithSpacing(GraphicsContext* graphicsContext, const SimpleFontData* font, const wxColour& color, const GlyphBuffer& glyphBuffer, int from, int numGlyphs, const FloatPoint& point)
-{
-#if USE(WXGC)
-    wxGCDC* dc = static_cast<wxGCDC*>(graphicsContext->platformContext());
-    wxGraphicsContext* gc = dc->GetGraphicsContext();
-    gc->PushState();
-    cairo_t* cr = (cairo_t*)gc->GetNativeContext();
-
-    wxFont* wxfont = font->getWxFont();
-    PangoFont* pangoFont = createPangoFontForFont(wxfont);
-    PangoFontMap* fontMap = pangoFontMap();
-    PangoContext* pangoContext = pango_cairo_font_map_create_context(PANGO_CAIRO_FONT_MAP(fontMap));
-    cairo_scaled_font_t* scaled_font = createScaledFontForFont(wxfont); 
-    ASSERT(scaled_font);
-
-    cairo_glyph_t* glyphs = NULL;
-    glyphs = static_cast<cairo_glyph_t*>(malloc(sizeof(cairo_glyph_t) * numGlyphs));
-
-    float offset = point.x();
-
-    for (int i = 0; i < numGlyphs; i++) {
-        glyphs[i].index = pango_font_get_glyph(pangoFont, pangoContext, glyphBuffer.glyphAt(from + i));
-        glyphs[i].x = offset;
-        glyphs[i].y = point.y();
-        offset += glyphBuffer.advanceAt(from + i);
-    }
-
-    cairo_set_source_rgba(cr, color.Red()/255.0, color.Green()/255.0, color.Blue()/255.0, color.Alpha()/255.0);
-    cairo_set_scaled_font(cr, scaled_font);
-    
-    cairo_show_glyphs(cr, glyphs, numGlyphs);
-
-    cairo_scaled_font_destroy(scaled_font);
-    gc->PopState();
-#else
-    wxDC* dc = graphicsContext->platformContext();
-
-    wxFont* wxfont = font->getWxFont();
-    if (wxfont && wxfont->IsOk())
-        dc->SetFont(*wxfont);
-    dc->SetTextForeground(color);
-
-    // convert glyphs to wxString
-    GlyphBufferGlyph* glyphs = const_cast<GlyphBufferGlyph*>(glyphBuffer.glyphs(from));
-    int offset = point.x();
-    wxString text = wxEmptyString;
-    for (unsigned i = 0; i < numGlyphs; i++) {
-        text = text.Append((wxChar)glyphs[i]);
-        offset += glyphBuffer.advanceAt(from + i);
-    }
-    
-    // the y point is actually the bottom point of the text, turn it into the top
-    float height = font->ascent() - font->descent();
-    wxCoord ypoint = (wxCoord) (point.y() - height);
-     
-    dc->DrawText(text, (wxCoord)point.x(), ypoint);
-#endif
-}
-
-}
index 0719871..e69de29 100644 (file)
@@ -1,153 +0,0 @@
-/*
- * Copyright (C) 2007 Kevin Watters, Kevin Ollivier.  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.
- */
-
-#include "config.h"
-
-#include "AffineTransform.h"
-#include "GlyphBuffer.h"
-#include "GraphicsContext.h"
-#include "SimpleFontData.h"
-
-#include <wx/defs.h>
-#include <wx/dcclient.h>
-#include <wx/dcgraph.h>
-#include <wx/gdicmn.h>
-#include <vector>
-
-using namespace std;
-
-//-----------------------------------------------------------------------------
-// constants
-//-----------------------------------------------------------------------------
-
-const double RAD2DEG = 180.0 / M_PI;
-
-//-----------------------------------------------------------------------------
-// Local functions
-//-----------------------------------------------------------------------------
-
-static inline double dmin(double a, double b) { return a < b ? a : b; }
-static inline double dmax(double a, double b) { return a > b ? a : b; }
-
-static inline double DegToRad(double deg) { return (deg * M_PI) / 180.0; }
-static inline double RadToDeg(double deg) { return (deg * 180.0) / M_PI; }
-
-#include "wx/msw/private.h"
-
-// TODO remove this dependency (gdiplus needs the macros)
-
-#ifndef max
-#define max(a,b)            (((a) > (b)) ? (a) : (b))
-#endif
-
-#ifndef min
-#define min(a,b)            (((a) < (b)) ? (a) : (b))
-#endif
-
-#include "gdiplus.h"
-
-namespace WebCore {
-
-void drawTextWithSpacing(GraphicsContext* graphicsContext, const SimpleFontData* font, const wxColour& color, const GlyphBuffer& glyphBuffer, int from, int numGlyphs, const FloatPoint& point)
-{
-#if USE(WXGC)
-    wxGCDC* dc = static_cast<wxGCDC*>(graphicsContext->platformContext());
-#else
-    wxDC* dc = graphicsContext->platformContext();
-#endif
-
-    // get the native HDC handle to draw using native APIs
-    HDC hdc = 0;
-    float y = point.y() - font->fontMetrics().ascent();
-    float x = point.x();
-
-
-#if USE(WXGC)
-    // when going from GdiPlus -> Gdi, any GdiPlus transformations are lost
-    // so we need to alter the coordinates to reflect their transformed point.
-    double xtrans = 0;
-    double ytrans = 0;
-    
-    wxGraphicsContext* gc = dc->GetGraphicsContext();
-    gc->GetTransform().TransformPoint(&xtrans, &ytrans);
-    Gdiplus::Graphics* g;
-    if (gc) {
-        g = (Gdiplus::Graphics*)gc->GetNativeContext();
-        hdc = g->GetHDC();
-    }
-    x += (int)xtrans;
-    y += (int)ytrans;
-#else
-    hdc = static_cast<HDC>(dc->GetHDC());
-#endif
-
-    // if the context has been scaled, we must manually re-apply that scale
-    // to the HDC.
-    FloatSize scale = graphicsContext->currentScale();
-    if (scale != FloatSize(1.0, 1.0)) {
-        SetGraphicsMode(hdc, GM_ADVANCED);
-        XFORM xForm;
-        xForm.eM11 = scale.width();
-        xForm.eM12 = 0.0;
-        xForm.eM21 = 0.0;
-        xForm.eM22 = scale.height();
-        xForm.eDx = 0.0;
-        xForm.eDy = 0.0;
-        SetWorldTransform(hdc, &xForm);
-    }
-    // ExtTextOut wants the offsets as an array of ints, so extract them
-    // from the glyph buffer
-    const GlyphBufferGlyph*   glyphs   = glyphBuffer.glyphs(from);
-    const GlyphBufferAdvance* advances = glyphBuffer.advances(from);
-
-    int* spacing = new int[numGlyphs - from];
-    for (unsigned i = 0; i < numGlyphs; ++i)
-        spacing[i] = advances[i].width();
-
-    wxFont* wxfont = font->getWxFont();
-    if (wxfont && wxfont->IsOk())
-        ::SelectObject(hdc, GetHfontOf(*wxfont));
-
-    if (color.Ok())
-        ::SetTextColor(hdc, color.GetPixel());
-
-    // do not draw background behind characters
-    ::SetBkMode(hdc, TRANSPARENT);
-
-    // draw text with optional character widths array
-    wxString string = wxString((wxChar*)(&glyphs[from]), numGlyphs);
-    ::ExtTextOut(hdc, x, y,  ETO_GLYPH_INDEX, 0, reinterpret_cast<const WCHAR*>(glyphs), numGlyphs, spacing);
-
-    ::SetBkMode(hdc, TRANSPARENT);
-
-    #if USE(WXGC)
-        g->ReleaseHDC(hdc);
-    #endif
-
-    delete [] spacing;
-}
-
-}
index 890db00..afa808e 100644 (file)
@@ -77,7 +77,7 @@ class GraphicsHDC
 public:
     GraphicsHDC(wxDC* dc)
     {
-#if wxUSE_GRAPHICS_CONTEXT
+#if wxUSE_GRAPHICS_CONTEXT && (!defined(wxUSE_CAIRO) || !wxUSE_CAIRO)
         m_graphics = NULL;
         wxGCDC* gcdc = wxDynamicCast(dc, wxGCDC);
         if (gcdc) {
@@ -91,7 +91,7 @@ public:
 
     ~GraphicsHDC()
     {
-#if wxUSE_GRAPHICS_CONTEXT
+#if wxUSE_GRAPHICS_CONTEXT  && (!defined(wxUSE_CAIRO) || !wxUSE_CAIRO)
         if (m_graphics)
             m_graphics->ReleaseHDC(m_hdc);
 #endif
@@ -101,7 +101,7 @@ public:
 
 private:
     HDC         m_hdc;
-#if wxUSE_GRAPHICS_CONTEXT
+#if wxUSE_GRAPHICS_CONTEXT  && (!defined(wxUSE_CAIRO) || !wxUSE_CAIRO)
     Graphics*   m_graphics;
 #endif
 };
@@ -135,7 +135,7 @@ void wxRenderer_DrawScrollbar(wxWindow* window, wxDC& dc,
     int xpState = TS_NORMAL;
     wxRect transRect = rect;
 
-#if USE(WXGC)
+#if USE(WXGC) && !defined(wxUSE_CAIRO) || !wxUSE_CAIRO
     // when going from GdiPlus -> Gdi, any GdiPlus transformations are lost
     // so we need to alter the coordinates to reflect their transformed point.
     double xtrans = 0;
@@ -147,6 +147,8 @@ void wxRenderer_DrawScrollbar(wxWindow* window, wxDC& dc,
 
     transRect.x += (int)xtrans;
     transRect.y += (int)ytrans;
+#else
+
 #endif
 
     RECT r;
@@ -208,6 +210,8 @@ void wxRenderer_DrawScrollbar(wxWindow* window, wxDC& dc,
         else
             part = SP_GRIPPERVERT;
         
+
+
         engine->DrawThemeBackground(hTheme, GraphicsHDC(&dc), part, xpState, &buttonRect, 0);
     }
 }
index 536037f..15c9092 100644 (file)
@@ -1,3 +1,18 @@
+2011-09-04  Robin Dunn  <robin@alldunn.com>
+
+        [wx] Enable wxWebKit to run using the wxGC Cairo backend on platforms other than GTK.
+        https://bugs.webkit.org/show_bug.cgi?id=67577
+
+        Reviewed by Kevin Ollivier.
+
+        * WebFrame.cpp:
+        (wxWebFramePrintout::InitializeWithPageSize):
+        (wxWebFramePrintout::OnBeginPrinting):
+        (wxWebFramePrintout::OnPrintPage):
+        (wxWebFrame::Print):
+        * WebView.cpp:
+        (wxWebView::OnPaint):
+
 2011-08-30  Kaustubh Atrawalkar  <kaustubh@motorola.com>
 
         The unused ScrollView* argument can and should be removed from
index 8c62142..3accef9 100644 (file)
@@ -106,21 +106,22 @@ public:
     void SetFirstPage(int page) { m_fromPage = page; }
     void SetLastPage(int page) { m_toPage = page; }
 
-    void InitializeWithPageSize(wxRect pageRect)
+    void InitializeWithPageSize(wxRect pageRect, bool isMM = true)
     {
-        double mmToPixelsX = (double)wxGetDisplaySize().GetWidth() /
-                                (double)wxGetDisplaySizeMM().GetWidth();
-        double mmToPixelsY = (double)wxGetDisplaySize().GetHeight() /
-                                (double)wxGetDisplaySizeMM().GetHeight();
-        // convert mm to pixels
-        pageRect.x = pageRect.x * mmToPixelsX;
-        pageRect.y = pageRect.y * mmToPixelsY;
-        pageRect.width = pageRect.width * mmToPixelsX;
-        pageRect.height = pageRect.height * mmToPixelsY;
-        
+        if (isMM) {
+            double mmToPixelsX = (double)wxGetDisplaySize().GetWidth() /
+                                    (double)wxGetDisplaySizeMM().GetWidth();
+            double mmToPixelsY = (double)wxGetDisplaySize().GetHeight() /
+                                    (double)wxGetDisplaySizeMM().GetHeight();
+            // convert mm to pixels
+            pageRect.x = pageRect.x * mmToPixelsX;
+            pageRect.y = pageRect.y * mmToPixelsY;
+            pageRect.width = pageRect.width * mmToPixelsX;
+            pageRect.height = pageRect.height * mmToPixelsY;
+        }
         m_pageWidth = pageRect.width;
         m_printContext.begin(m_pageWidth);
-        
+
         float pageHeight = pageRect.height;
         m_printContext.computePageRects(WebCore::FloatRect(pageRect), /* headerHeight */ 0, /* footerHeight */ 0, /* userScaleFactor */ 1.0, pageHeight);
     }
@@ -129,11 +130,12 @@ public:
     {
         wxPrinterDC* pdc = dynamic_cast<wxPrinterDC*>(GetDC());
         pdc->SetMapMode(wxMM_POINTS);
-        int pageWidth = 0;
-        int pageHeight = 0;
-        GetPageSizeMM(&pageWidth, &pageHeight);
-        
-        InitializeWithPageSize(wxRect(0, 0, pageWidth, pageHeight));
+        int pixelsW = 0;
+        int pixelsH = 0;
+        pdc->GetSize(&pixelsW, &pixelsH);
+        pixelsW = pdc->DeviceToLogicalXRel(pixelsW);
+        pixelsH = pdc->DeviceToLogicalYRel(pixelsH);
+        InitializeWithPageSize(wxRect(0, 0, pixelsW, pixelsH - 40), false);
     }
     
     void GetPageInfo(int *minPage, int *maxPage, int *pageFrom, int *pageTo)
@@ -156,8 +158,15 @@ public:
     bool OnPrintPage(int pageNum)
     {
         wxPrinterDC* pdc = dynamic_cast<wxPrinterDC*>(GetDC());
-        
-        wxGCDC gcdc(*pdc);
+#if wxCHECK_VERSION(2, 9, 2) && defined(wxUSE_CAIRO) && wxUSE_CAIRO
+        wxGraphicsRenderer* renderer = wxGraphicsRenderer::GetCairoRenderer();
+        if (!renderer)
+            renderer = wxGraphicsRenderer::GetDefaultRenderer();
+        wxGraphicsContext* context = renderer->CreateContext(*pdc);
+        wxGCDC gcdc(context);
+#else
+        wxGCDC gcdc(pdc);
+#endif
         if (!gcdc.IsOk())
             return false;
 
@@ -592,8 +601,14 @@ void wxWebFrame::Print(bool showDialog)
     wxPrintDialogData printdata;
     printdata.GetPrintData().SetPrintMode(wxPRINT_MODE_PRINTER);
     printdata.GetPrintData().SetNoCopies(1);
+#if wxCHECK_VERSION(2, 9, 2)
     printdata.GetPrintData().ConvertFromNative();
-    
+#else
+    // due to wx bugs, we cannot get the actual native default paper type before showing the dialog until 2.9.2, 
+    // so pick a common default instead.
+    printdata.GetPrintData().SetPaperId(wxPAPER_LETTER);
+#endif
+
     wxPageSetupDialogData pageSetup(printdata.GetPrintData());
 
     wxRect paperSize = pageSetup.GetPaperSize();
@@ -613,9 +628,9 @@ void wxWebFrame::Print(bool showDialog)
     if (showDialog) {
         wxPrintDialog dialog(0, &printdata);
         if (dialog.ShowModal() == wxID_OK) {
-            wxPrintDialogData updatedPrintdata = dialog.GetPrintDialogData();            
-            printout->SetFirstPage(updatedPrintdata.GetFromPage());
-            printout->SetLastPage(updatedPrintdata.GetToPage());
+            printdata = dialog.GetPrintDialogData();            
+            printout->SetFirstPage(printdata.GetFromPage());
+            printout->SetLastPage(printdata.GetToPage());
         } else
             return;
     }
index 6aad229..2699ec9 100644 (file)
@@ -685,8 +685,16 @@ void wxWebView::OnPaint(wxPaintEvent& event)
 
     if (IsShown() && frame->document()) {
 #if USE(WXGC)
+#if wxCHECK_VERSION(2, 9, 2) && defined(wxUSE_CAIRO) && wxUSE_CAIRO
+        wxGraphicsRenderer* renderer = wxGraphicsRenderer::GetCairoRenderer();
+        if (!renderer)
+            renderer = wxGraphicsRenderer::GetDefaultRenderer();
+        wxGraphicsContext* context = renderer->CreateContext(dc);
+        wxGCDC gcdc(context);
+#else
         wxGCDC gcdc(dc);
 #endif
+#endif
 
         if (dc.IsOk()) {
             wxRect paintRect = GetUpdateRegion().GetBox();
index 51ef92a..107c8c8 100644 (file)
@@ -1,3 +1,12 @@
+2011-09-04  Robin Dunn  <robin@alldunn.com>
+
+        [wx] Enable wxWebKit to run using the wxGC Cairo backend on platforms other than GTK.
+        https://bugs.webkit.org/show_bug.cgi?id=67577
+
+        Reviewed by Kevin Ollivier.
+
+        * waf/build/settings.py:
+
 2011-09-03  Kevin Ollivier  <kevino@theolliviers.com>
 
         [wx] Unreviewed build fix. Add wtf/dtoa directory to build.
index e7946eb..def9706 100644 (file)
@@ -29,6 +29,7 @@ import platform
 import re
 import sys
 
+import Logs
 import Options
 
 from build_utils import *
@@ -225,6 +226,7 @@ def common_set_options(opt):
     opt.add_option('--msvc-version', action='store', default='', help="MSVC version to use to build. Use 8 for 2005, 9 for 2008")
     opt.add_option('--mac_universal_binary', action='store_true', default=False, help='Build Mac as universal (i386, x86_64, ppc) binary.')
     opt.add_option('--mac_archs', action='store', default='', help='Comma separated list of architectures (i386, x86_64, ppc) to build on Mac.')
+    opt.add_option('--cairo', action='store_true', default=sys.platform.startswith('linux'), help='Use cairo for drawing (experimental for Win/Mac')
 
 def common_configure(conf):
     """
@@ -262,6 +264,11 @@ def common_configure(conf):
 
     libprefix = ''
 
+    if Options.options.cairo and build_port == 'wx':
+        if building_on_win32 and not "CAIRO_ROOT" in os.environ:
+            Log.error("To build with Cairo on Windows, you must set the CAIRO_ROOT environment variable.")
+            sys.exit(1)
+
     if building_on_win32:
         libprefix = 'lib'
 
@@ -314,6 +321,10 @@ def common_configure(conf):
             conf.env['CPPPATH_WX'] = wxincludes
             conf.env['LIB_WX'] = wxlibs
             conf.env['LIBPATH_WX'] = wxlibpaths
+            if Options.options.cairo and 'CAIRO_ROOT' in os.environ:
+                conf.env.append_value('CPPPATH_WX', [os.path.join(os.environ['CAIRO_ROOT'], 'include', 'cairo')])
+                conf.env.append_value('LIBPATH_WX', [os.path.join(os.environ['CAIRO_ROOT'], 'lib')])
+                conf.env.append_value('LIB_WX', ['cairo'])
         else:
             conf.check_cfg(path=get_path_to_wxconfig(), args='--cxxflags --libs', package='', uselib_store='WX', mandatory=True)
 
diff --git a/wscript b/wscript
index 98168d6..1855ca8 100644 (file)
--- a/wscript
+++ b/wscript
@@ -170,6 +170,10 @@ def build(bld):
                    'Source/WebCore/plugins/win/PluginPackageWin.cpp',
                    'Source/WebCore/plugins/win/PluginViewWin.cpp',
             ]
+            if Options.options.cairo:
+                webcore_dirs.append('Source/WebCore/platform/wx/wxcode/cairo')
+            else:
+                webcore_dirs.append('Source/WebCore/platform/wx/wxcode/gdiplus')
         elif sys.platform.startswith('darwin'):
             webcore_dirs.append('Source/WebCore/plugins/mac')
             webcore_dirs.append('Source/WebCore/platform/wx/wxcode/mac/carbon')
@@ -197,6 +201,7 @@ def build(bld):
                    'Source/WebCore/plugins/PluginPackageNone.cpp'
             ]
             webcore_dirs.append('Source/WebCore/platform/wx/wxcode/gtk')
+            webcore_dirs.append('Source/WebCore/platform/wx/wxcode/cairo')
         
 
     import TaskGen
@@ -350,7 +355,12 @@ def build(bld):
         
             for dep in windows_deps:
                 bld.install_files(webcore.install_path, [os.path.join(msvclibs_dir, dep)])
-
+            
+            if "CAIRO_ROOT" in os.environ and Options.options.cairo:
+                cairo_bin_dir = os.path.join(os.environ["CAIRO_ROOT"], "bin") 
+                for dep in glob.glob(os.path.join(cairo_bin_dir, "*.dll")):
+                    bld.install_files(webcore.install_path, [os.path.join(cairo_bin_dir, dep)])
+                    
     webcore.find_sources_in_dirs(full_dirs, excludes = excludes, exts=['.c', '.cpp'])
 
     bld.add_group()