Bug 58676

Summary: Views should be made visible before painting in WM_PRINTCLIENT messages
Product: WebKit Reporter: Brian Weinstein <bweinstein>
Component: WebKit2Assignee: Brian Weinstein <bweinstein>
Status: RESOLVED FIXED    
Severity: Normal CC: aroben
Priority: P2 Keywords: InRadar, PlatformOnly
Version: 528+ (Nightly build)   
Hardware: PC   
OS: Windows 7   
Attachments:
Description Flags
[PATCH] Fix
aroben: review+
[PATCH] Fix v2 aroben: review+

Description Brian Weinstein 2011-04-15 11:17:40 PDT
If a view that is in the background (from a background tab) tries to paint to an HDC in response to a WM_PRINTCLIENT message, painting is suspended from the drawing area, so the paint will fail.

We should tell the view that it is temporarily visible, so it is allowed to paint.

<rdar://problem/9279211>
Comment 1 Brian Weinstein 2011-04-15 11:21:15 PDT
Created attachment 89817 [details]
[PATCH] Fix
Comment 2 Jeff Miller 2011-04-15 11:32:53 PDT
Comment on attachment 89817 [details]
[PATCH] Fix

View in context: https://bugs.webkit.org/attachment.cgi?id=89817&action=review

> Source/WebKit2/UIProcess/win/WebView.cpp:693
> +    bool isVisible = isViewVisible();

Maybe this should be wasVisible?
Comment 3 Brian Weinstein 2011-04-15 11:34:03 PDT
(In reply to comment #2)
> (From update of attachment 89817 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=89817&action=review
> 
> > Source/WebKit2/UIProcess/win/WebView.cpp:693
> > +    bool isVisible = isViewVisible();
> 
> Maybe this should be wasVisible?

Yeah, I was waffling on a name here. wasVisible is good. Thanks!
Comment 4 Adam Roben (:aroben) 2011-04-15 12:15:33 PDT
Comment on attachment 89817 [details]
[PATCH] Fix

View in context: https://bugs.webkit.org/attachment.cgi?id=89817&action=review

> Source/WebKit2/UIProcess/win/WebView.cpp:700
> +    if (!isVisible)
> +        setIsVisible(true);
> +
>      paint(hdc, winRect);
>  
> +    if (!isVisible)
> +        setIsVisible(false);

I think it's worth adding a comment explaining why we do this.

It's a little unfortunate that we don't have more fine-grained control of this. Today, the visible state of the view only affects whether painting happens. In the future it could affect more things which we don't want to touch here. Maybe a FIXME saying that it would be good to have a more-direct way of telling the web process to draw even if we're invisible would be enough here.

> Source/WebKit2/UIProcess/win/WebView.cpp:1482
> +void WebView::setIsVisible(bool isVisible)
> +{
> +    m_isVisible = isVisible;
> +    m_page->viewStateDidChange(WebPageProxy::ViewIsVisible);
> +}

Seems like onShowWindowEvent should call this function.
Comment 5 Brian Weinstein 2011-04-15 12:42:10 PDT
Created attachment 89831 [details]
[PATCH] Fix v2
Comment 6 Brian Weinstein 2011-04-15 12:47:31 PDT
Landed in r84019.