Title: [104727] trunk/Source/WebKit2
Revision
104727
Author
[email protected]
Date
2012-01-11 11:38:24 -0800 (Wed, 11 Jan 2012)

Log Message

Webpages flash white when switching between windows
https://bugs.webkit.org/show_bug.cgi?id=76080
<rdar://problem/9893565>

Reviewed by Dan Bernstein.

Introduce a _windowHasValidBackingStore boolean and only paint the background (white or clear)
if it's false.

* UIProcess/API/mac/WKView.mm:
(-[WKView setFrameSize:]):
Set _windowHasValidBackingStore to false if the new size is different from the old size.

(-[WKView viewDidMoveToWindow]):
Set _windowHasValidBackingStore to false.

(-[WKView _windowDidMiniaturize:]):
Set _windowHasValidBackingStore to false.

(-[WKView _windowDidChangeBackingProperties:]):
Set _windowHasValidBackingStore to false.

(-[WKView drawRect:]):
Only call drawPageBackground if _windowHasValidBackingStore is false. Set it to true after painting.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (104726 => 104727)


--- trunk/Source/WebKit2/ChangeLog	2012-01-11 19:37:25 UTC (rev 104726)
+++ trunk/Source/WebKit2/ChangeLog	2012-01-11 19:38:24 UTC (rev 104727)
@@ -1,5 +1,32 @@
 2012-01-11  Anders Carlsson  <[email protected]>
 
+        Webpages flash white when switching between windows
+        https://bugs.webkit.org/show_bug.cgi?id=76080
+        <rdar://problem/9893565>
+
+        Reviewed by Dan Bernstein.
+
+        Introduce a _windowHasValidBackingStore boolean and only paint the background (white or clear)
+        if it's false.
+
+        * UIProcess/API/mac/WKView.mm:
+        (-[WKView setFrameSize:]):
+        Set _windowHasValidBackingStore to false if the new size is different from the old size.
+
+        (-[WKView viewDidMoveToWindow]):
+        Set _windowHasValidBackingStore to false.
+
+        (-[WKView _windowDidMiniaturize:]):
+        Set _windowHasValidBackingStore to false.
+
+        (-[WKView _windowDidChangeBackingProperties:]):
+        Set _windowHasValidBackingStore to false.
+
+        (-[WKView drawRect:]):
+        Only call drawPageBackground if _windowHasValidBackingStore is false. Set it to true after painting.
+
+2012-01-11  Anders Carlsson  <[email protected]>
+
         Fix the Mac GCC build.
 
         Work around the fact that GCC doesn't work very well with Blocks and C++ objets.

Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm (104726 => 104727)


--- trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm	2012-01-11 19:37:25 UTC (rev 104726)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm	2012-01-11 19:38:24 UTC (rev 104727)
@@ -187,7 +187,14 @@
     NSRect _windowBottomCornerIntersectionRect;
     
     unsigned _frameSizeUpdatesDisabledCount;
+
+    // Whether the containing window of the WKView has a valid backing store.
+    // The window server invalidates the backing store whenever the window is resized or minimized.
+    // We use this flag to determine when we need to paint the background (white or clear)
+    // when the web process is unresponsive or takes too long to paint.
+    BOOL _windowHasValidBackingStore;
 }
+
 @end
 
 @implementation WKViewData
@@ -324,6 +331,9 @@
 
 - (void)setFrameSize:(NSSize)size
 {
+    if (!NSEqualSizes(size, [self frame].size))
+        _data->_windowHasValidBackingStore = NO;
+
     [super setFrameSize:size];
     
     if (![self frameSizeUpdatesDisabled])
@@ -1818,6 +1828,7 @@
     // update the active state first and then make it visible. If the view is about to be hidden, we hide it first and then
     // update the active state.
     if ([self window]) {
+        _data->_windowHasValidBackingStore = NO;
         _data->_page->viewStateDidChange(WebPageProxy::ViewWindowIsActive);
         _data->_page->viewStateDidChange(WebPageProxy::ViewIsVisible | WebPageProxy::ViewIsInWindow);
         [self _updateWindowVisibility];
@@ -1883,6 +1894,8 @@
 
 - (void)_windowDidMiniaturize:(NSNotification *)notification
 {
+    _data->_windowHasValidBackingStore = NO;
+
     [self _updateWindowVisibility];
 }
 
@@ -1919,6 +1932,7 @@
     if (oldBackingScaleFactor == newBackingScaleFactor) 
         return; 
 
+    _data->_windowHasValidBackingStore = NO;
     _data->_page->setIntrinsicDeviceScaleFactor(newBackingScaleFactor);
 }
 
@@ -1963,9 +1977,15 @@
             IntRect rect = enclosingIntRect(rectsBeingDrawn[i]);
             drawingArea->paint(context, rect, unpaintedRegion);
 
-            Vector<IntRect> unpaintedRects = unpaintedRegion.rects();
-            for (size_t i = 0; i < unpaintedRects.size(); ++i)
-                drawPageBackground(context, _data->_page.get(), unpaintedRects[i]);
+            // If the window doesn't have a valid backing store, we need to fill the parts of the page that we
+            // didn't paint with the background color (white or clear), to avoid garbage in those areas.
+            if (!_data->_windowHasValidBackingStore) {
+                Vector<IntRect> unpaintedRects = unpaintedRegion.rects();
+                for (size_t i = 0; i < unpaintedRects.size(); ++i)
+                    drawPageBackground(context, _data->_page.get(), unpaintedRects[i]);
+
+                _data->_windowHasValidBackingStore = YES;
+            }
         }
     } else 
         drawPageBackground(context, _data->_page.get(), enclosingIntRect(rect));
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to