[webkit-dev] Proposed Windows Drawing Change (WebNodeHighlight) Logic

Brent Fulgham bfulgham at gmail.com
Sun Jun 26 16:12:29 PDT 2011


While investigating a separate issue, I noticed that I was hitting an assertion in the Cairo drawing layer because it was attempting to use an invalid HBITMAP created in the WebNodeHighlight::update method.  The underlying issue was that the CreateDIBSection function was failing, because it was being requested to create a section of zero height.

I think the following change would be safe for the CoreGraphics and Cairo ports, but wanted to see if anyone knew of a reason why it would be bad to exit early in the case of a zero height (or zero width) paint region.

$ svn diff
Index: win/WebNodeHighlight.cpp
===================================================================
--- win/WebNodeHighlight.cpp    (revision 89759)
+++ win/WebNodeHighlight.cpp    (working copy)
@@ -145,10 +145,14 @@
     size.cx = webViewRect.right - webViewRect.left;
     size.cy = webViewRect.bottom - webViewRect.top;

+    if (!size.cx || !size.cy)
+        return;
+
     BitmapInfo bitmapInfo = BitmapInfo::createBottomUp(IntSize(size));

     void* pixels = 0;
     OwnPtr<HBITMAP> hbmp = adoptPtr(::CreateDIBSection(hdc, &bitmapInfo, DIB_RG
B_COLORS, &pixels, 0, 0));
+    ASSERT_WITH_MESSAGE(hbmp.get(), "::CreateDIBSection failed with error %lu",
 ::GetLastError());

     ::SelectObject(hdc, hbmp.get());

Thanks,

-Brent



More information about the webkit-dev mailing list