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

Simon Fraser simon.fraser at apple.com
Sun Jun 26 22:55:27 PDT 2011


This should go into a bug.

Simon

On Jun 26, 2011, at 4:12 PM, Brent Fulgham wrote:

> 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
> 
> _______________________________________________
> webkit-dev mailing list
> webkit-dev at lists.webkit.org
> http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev



More information about the webkit-dev mailing list