2006-03-04 Eric Seidel <eseidel@apple.com>
authoreseidel <eseidel@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 5 Mar 2006 09:42:13 +0000 (09:42 +0000)
committereseidel <eseidel@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 5 Mar 2006 09:42:13 +0000 (09:42 +0000)
        Reviewed by hyatt.

        Take advantage of new GraphicsContext constructor to implement double buffering to avoid tearing.
        Disable background erase to avoid tearing.
        Fix potential memory smasher from extra long urls.

        * Spinneret/Spinneret/Spinneret.cpp:
        (MyRegisterClass):
        * Spinneret/Spinneret/Spinneret.vcproj:
        * Spinneret/Spinneret/WebFrame.cpp:
        (WebKit::WebFrame::loadFilePath):
        (WebKit::WebFrame::paint):
        * Spinneret/Spinneret/WebView.cpp:
        (WebKit::registerWebViewWithInstance):

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

WebKitTools/ChangeLog
WebKitTools/Spinneret/Spinneret/Spinneret.cpp
WebKitTools/Spinneret/Spinneret/Spinneret.vcproj
WebKitTools/Spinneret/Spinneret/WebFrame.cpp
WebKitTools/Spinneret/Spinneret/WebView.cpp

index 75418a7eeedb627a7bb0e2692ac8a394a1c2d072..3512c2e6a068a727ba1121aee8edeb24dc5d5ea1 100644 (file)
@@ -1,3 +1,20 @@
+2006-03-04  Eric Seidel  <eseidel@apple.com>
+
+        Reviewed by hyatt.
+
+        Take advantage of new GraphicsContext constructor to implement double buffering to avoid tearing.
+        Disable background erase to avoid tearing.
+        Fix potential memory smasher from extra long urls. 
+
+        * Spinneret/Spinneret/Spinneret.cpp:
+        (MyRegisterClass):
+        * Spinneret/Spinneret/Spinneret.vcproj:
+        * Spinneret/Spinneret/WebFrame.cpp:
+        (WebKit::WebFrame::loadFilePath):
+        (WebKit::WebFrame::paint):
+        * Spinneret/Spinneret/WebView.cpp:
+        (WebKit::registerWebViewWithInstance):
+
 2006-03-04  Eric Seidel  <eseidel@apple.com>
 
         Reviewed by ggaren.
index 8da35897634815a9b682eae97a8bfbb1268773a2..ca62a11c0390d3c0043f3bd42c3f09674ba0df0f 100755 (executable)
@@ -129,7 +129,7 @@ ATOM MyRegisterClass(HINSTANCE hInstance)
     wcex.hInstance        = hInstance;
     wcex.hIcon            = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_SPINNERET));
     wcex.hCursor        = LoadCursor(NULL, IDC_ARROW);
-    wcex.hbrBackground    = (HBRUSH)(COLOR_WINDOW+1);
+    wcex.hbrBackground    = 0;
     wcex.lpszMenuName    = MAKEINTRESOURCE(IDC_SPINNERET);
     wcex.lpszClassName    = szWindowClass;
     wcex.hIconSm        = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
index a23ff1fbefbd98e11823021c7dec325aa928f95e..7ac2509249eaf854bc83bda53b303c253cc238ce 100755 (executable)
@@ -40,7 +40,7 @@
                        <Tool\r
                                Name="VCCLCompilerTool"\r
                                Optimization="0"\r
-                               AdditionalIncludeDirectories="&quot;$(SolutionDir)\..\..\WebCore&quot;;&quot;$(SolutionDir)\..\..\WebCore\loader&quot;;&quot;$(SolutionDir)\..\..\WebCore\khtml\dom&quot;;&quot;$(SolutionDir)\..\..\WebCore\khtml\ecma&quot;;&quot;$(SolutionDir)\..\..\WebCore\khtml\html&quot;;&quot;$(SolutionDir)\..\..\WebCore\khtml&quot;;&quot;$(SolutionDir)\..\..\WebCore\css&quot;;&quot;$(SolutionDir)\..\..\WebCore\khtml\misc&quot;;&quot;$(SolutionDir)\..\..\WebCore\platform&quot;;&quot;$(SolutionDir)\..\..\WebCore\bridge\win&quot;;&quot;$(SolutionDir)\..\..\WebCore\page&quot;;&quot;$(SolutionDir)\..\..\WebCore\bridge&quot;;&quot;$(SolutionDir)\..\..\WebCore\platform\win&quot;;&quot;$(SolutionDir)\..\..\WebCore\rendering&quot;;&quot;$(SolutionDir)\..\..\WebCore\editing&quot;;&quot;$(SolutionDir)\..\..\WebCore\dom&quot;;&quot;$(SolutionDir)\..\..\WebCore\xml&quot;;&quot;$(SolutionDir)\..\..\WebCore\kwq&quot;;&quot;$(SolutionDir)\..\..\iconv&quot;;&quot;$(SolutionDir)\..\..\libxml2&quot;;&quot;$(SolutionDir)\..\..\icu\include&quot;;&quot;$(SolutionDir)\..\..\JavaScriptCore&quot;;&quot;$(SolutionDir)\..\..\JavaScriptCore\os-win32&quot;;&quot;$(SolutionDir)\..\..\JavaScriptCore\kxmlcore&quot;;&quot;$(SolutionDir)\..\..\WebCore\ForwardingHeaders&quot;"\r
+                               AdditionalIncludeDirectories="&quot;$(SolutionDir)\..\..\WebCore&quot;;&quot;$(SolutionDir)\..\..\WebCore\loader&quot;;&quot;$(SolutionDir)\..\..\WebCore\khtml\dom&quot;;&quot;$(SolutionDir)\..\..\WebCore\khtml\ecma&quot;;&quot;$(SolutionDir)\..\..\WebCore\khtml\html&quot;;&quot;$(SolutionDir)\..\..\WebCore\khtml&quot;;&quot;$(SolutionDir)\..\..\WebCore\css&quot;;&quot;$(SolutionDir)\..\..\WebCore\khtml\misc&quot;;&quot;$(SolutionDir)\..\..\WebCore\platform&quot;;&quot;$(SolutionDir)\..\..\WebCore\bridge\win&quot;;&quot;$(SolutionDir)\..\..\WebCore\page&quot;;&quot;$(SolutionDir)\..\..\WebCore\bridge&quot;;&quot;$(SolutionDir)\..\..\WebCore\platform\cairo\cairo\src&quot;;&quot;$(SolutionDir)\..\..\WebCore\platform\win&quot;;&quot;$(SolutionDir)\..\..\WebCore\rendering&quot;;&quot;$(SolutionDir)\..\..\WebCore\editing&quot;;&quot;$(SolutionDir)\..\..\WebCore\dom&quot;;&quot;$(SolutionDir)\..\..\WebCore\xml&quot;;&quot;$(SolutionDir)\..\..\WebCore\kwq&quot;;&quot;$(SolutionDir)\..\..\iconv&quot;;&quot;$(SolutionDir)\..\..\libxml2&quot;;&quot;$(SolutionDir)\..\..\icu\include&quot;;&quot;$(SolutionDir)\..\..\JavaScriptCore&quot;;&quot;$(SolutionDir)\..\..\JavaScriptCore\os-win32&quot;;&quot;$(SolutionDir)\..\..\JavaScriptCore\kxmlcore&quot;;&quot;$(SolutionDir)\..\..\WebCore\ForwardingHeaders&quot;"\r
                                PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"\r
                                MinimalRebuild="true"\r
                                BasicRuntimeChecks="3"\r
                        />\r
                        <Tool\r
                                Name="VCCLCompilerTool"\r
-                               AdditionalIncludeDirectories="&quot;$(SolutionDir)\..\..\WebCore&quot;;&quot;$(SolutionDir)\..\..\WebCore\loader&quot;;&quot;$(SolutionDir)\..\..\WebCore\khtml\dom&quot;;&quot;$(SolutionDir)\..\..\WebCore\khtml\ecma&quot;;&quot;$(SolutionDir)\..\..\WebCore\khtml\html&quot;;&quot;$(SolutionDir)\..\..\WebCore\khtml&quot;;&quot;$(SolutionDir)\..\..\WebCore\css&quot;;&quot;$(SolutionDir)\..\..\WebCore\khtml\misc&quot;;&quot;$(SolutionDir)\..\..\WebCore\platform&quot;;&quot;$(SolutionDir)\..\..\WebCore\bridge\win&quot;;&quot;$(SolutionDir)\..\..\WebCore\page&quot;;&quot;$(SolutionDir)\..\..\WebCore\bridge&quot;;&quot;$(SolutionDir)\..\..\WebCore\platform\win&quot;;&quot;$(SolutionDir)\..\..\WebCore\rendering&quot;;&quot;$(SolutionDir)\..\..\WebCore\editing&quot;;&quot;$(SolutionDir)\..\..\WebCore\dom&quot;;&quot;$(SolutionDir)\..\..\WebCore\xml&quot;;&quot;$(SolutionDir)\..\..\WebCore\kwq&quot;;&quot;$(SolutionDir)\..\..\iconv&quot;;&quot;$(SolutionDir)\..\..\libxml2&quot;;&quot;$(SolutionDir)\..\..\icu\include&quot;;&quot;$(SolutionDir)\..\..\JavaScriptCore&quot;;&quot;$(SolutionDir)\..\..\JavaScriptCore\os-win32&quot;;&quot;$(SolutionDir)\..\..\JavaScriptCore\kxmlcore&quot;;&quot;$(SolutionDir)\..\..\WebCore\ForwardingHeaders&quot;"\r
+                               AdditionalIncludeDirectories="&quot;$(SolutionDir)\..\..\WebCore&quot;;&quot;$(SolutionDir)\..\..\WebCore\loader&quot;;&quot;$(SolutionDir)\..\..\WebCore\khtml\dom&quot;;&quot;$(SolutionDir)\..\..\WebCore\khtml\ecma&quot;;&quot;$(SolutionDir)\..\..\WebCore\khtml\html&quot;;&quot;$(SolutionDir)\..\..\WebCore\khtml&quot;;&quot;$(SolutionDir)\..\..\WebCore\css&quot;;&quot;$(SolutionDir)\..\..\WebCore\khtml\misc&quot;;&quot;$(SolutionDir)\..\..\WebCore\platform&quot;;&quot;$(SolutionDir)\..\..\WebCore\bridge\win&quot;;&quot;$(SolutionDir)\..\..\WebCore\page&quot;;&quot;$(SolutionDir)\..\..\WebCore\bridge&quot;;&quot;$(SolutionDir)\..\..\WebCore\platform\cairo\cairo\src&quot;;&quot;$(SolutionDir)\..\..\WebCore\platform\win&quot;;&quot;$(SolutionDir)\..\..\WebCore\rendering&quot;;&quot;$(SolutionDir)\..\..\WebCore\editing&quot;;&quot;$(SolutionDir)\..\..\WebCore\dom&quot;;&quot;$(SolutionDir)\..\..\WebCore\xml&quot;;&quot;$(SolutionDir)\..\..\WebCore\kwq&quot;;&quot;$(SolutionDir)\..\..\iconv&quot;;&quot;$(SolutionDir)\..\..\libxml2&quot;;&quot;$(SolutionDir)\..\..\icu\include&quot;;&quot;$(SolutionDir)\..\..\JavaScriptCore&quot;;&quot;$(SolutionDir)\..\..\JavaScriptCore\os-win32&quot;;&quot;$(SolutionDir)\..\..\JavaScriptCore\kxmlcore&quot;;&quot;$(SolutionDir)\..\..\WebCore\ForwardingHeaders&quot;"\r
                                PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"\r
                                RuntimeLibrary="2"\r
                                UsePrecompiledHeader="2"\r
index 4ea47b7b3e1ce093c4e3f15ad3d6f0518ede5795..1c9818fcb41f288fdd63b137162326e56b99a0c5 100755 (executable)
@@ -34,6 +34,8 @@
 #include "GraphicsContext.h"
 #include "Page.h"
 #include "render_frames.h"
+#include "cairo.h"
+#include "cairo-win32.h"
 
 #include <io.h>
 #include <fcntl.h>
@@ -68,7 +70,7 @@ void WebFrame::loadFilePath(char* path)
 {
     char URL[2048];
     strcpy(URL, "file://localhost/");
-    strcat(URL, path);
+    strncat(URL, path, 2020);
 
     d->frame->didOpenURL(URL);
     d->frame->begin(URL);
@@ -99,9 +101,28 @@ void WebFrame::loadHTMLString(char *html, char *baseURL)
 void WebFrame::paint()
 {
     PAINTSTRUCT ps;
-    HDC hdc = BeginPaint(d->webView->windowHandle(), &ps);
-    GraphicsContext context(ps.hdc);
-    d->frame->paint(&context, ps.rcPaint);
+    HDC hdc = BeginPaint(d->webView->windowHandle(), &ps);   
+    cairo_surface_t* finalSurface = cairo_win32_surface_create(hdc);
+    cairo_surface_t* surface = cairo_surface_create_similar(finalSurface,
+                                                            CAIRO_CONTENT_COLOR_ALPHA,
+                                                            ps.rcPaint.right, ps.rcPaint.bottom);
+
+    cairo_t* context = cairo_create(surface);
+    GraphicsContext gc(context);
+    
+    d->frame->paint(&gc, ps.rcPaint);
+
+    cairo_destroy(context);
+    context = cairo_create(finalSurface);
+    cairo_set_operator(context, CAIRO_OPERATOR_SOURCE);
+    cairo_set_source_surface(context, surface, 0, 0);
+    cairo_rectangle(context, 0, 0, ps.rcPaint.right, ps.rcPaint.bottom);
+    cairo_fill(context);
+    cairo_destroy(context);
+
+    cairo_surface_destroy(surface);
+    cairo_surface_destroy(finalSurface);
+
     EndPaint(d->webView->windowHandle(), &ps);
 }
 
index a472e1755ad9860151622578925b5163f9e6cdd9..0553a8981364499cf2adc5e740892553815e39e5 100755 (executable)
@@ -64,14 +64,14 @@ static ATOM registerWebViewWithInstance(HINSTANCE hInstance)
 
     wcex.cbSize = sizeof(WNDCLASSEX);
 
-    wcex.style          = CS_HREDRAW | CS_VREDRAW; // CS_DBLCLKS?
+    wcex.style          = CS_DBLCLKS;
     wcex.lpfnWndProc    = WebViewWndProc;
     wcex.cbClsExtra     = 0;
     wcex.cbWndExtra     = 4; // 4 bytes for the WebView pointer
     wcex.hInstance      = hInstance;
     wcex.hIcon          = 0;
     wcex.hCursor        = LoadCursor(0, IDC_ARROW);
-    wcex.hbrBackground  = (HBRUSH)(COLOR_WINDOW+1);
+    wcex.hbrBackground  = 0;
     wcex.lpszMenuName   = 0;
     wcex.lpszClassName  = kWebViewWindowClassName;
     wcex.hIconSm        = 0;