[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

simon.fraser at apple.com simon.fraser at apple.com
Wed Dec 22 14:48:53 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 771538980653c35028b3dde0b3299114529f2cdb
Author: simon.fraser at apple.com <simon.fraser at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Oct 21 01:17:35 2010 +0000

    2010-10-20  Simon Fraser  <simon.fraser at apple.com>
    
            Reviewed by Dan Bernstein.
    
            Composited elements drawn twice when WebView is layer-backed
            https://bugs.webkit.org/show_bug.cgi?id=48024
            <rdar://problem/7916580>
    
            When drawing content in a layer-backed WebView, WebFrame's test
            for drawing to a bitmap succeeded, causing us to paint flattened
            compositing layers into the view. They would also be rendered
            by the normal compositing path, resulting in double rendering.
    
            Fix this by detecting when the WebHTMLView is being drawn into
            a layer, and avoiding flattening in that case.
    
            * WebView/WebFrame.mm:
            (-[WebFrame _showFlattenedCompositingLayers:]):
            (-[WebFrame _drawRect:contentsOnly:]):
            * WebView/WebHTMLView.mm:
            (-[WebHTMLView drawLayer:inContext:]):
            (-[WebHTMLView _web_isDrawingIntoLayer]):
            * WebView/WebHTMLViewInternal.h:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@70199 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/mac/ChangeLog b/WebKit/mac/ChangeLog
index 68eb0fd..8f1ea42 100644
--- a/WebKit/mac/ChangeLog
+++ b/WebKit/mac/ChangeLog
@@ -1,3 +1,27 @@
+2010-10-20  Simon Fraser  <simon.fraser at apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        Composited elements drawn twice when WebView is layer-backed
+        https://bugs.webkit.org/show_bug.cgi?id=48024
+        <rdar://problem/7916580>
+        
+        When drawing content in a layer-backed WebView, WebFrame's test
+        for drawing to a bitmap succeeded, causing us to paint flattened
+        compositing layers into the view. They would also be rendered
+        by the normal compositing path, resulting in double rendering.
+        
+        Fix this by detecting when the WebHTMLView is being drawn into
+        a layer, and avoiding flattening in that case.
+
+        * WebView/WebFrame.mm:
+        (-[WebFrame _showFlattenedCompositingLayers:]):
+        (-[WebFrame _drawRect:contentsOnly:]):
+        * WebView/WebHTMLView.mm:
+        (-[WebHTMLView drawLayer:inContext:]):
+        (-[WebHTMLView _web_isDrawingIntoLayer]):
+        * WebView/WebHTMLViewInternal.h:
+
 2010-10-20  Dumitru Daniliuc  <dumi at chromium.org>
 
         Reviewed by David Levin.
diff --git a/WebKit/mac/WebView/WebFrame.mm b/WebKit/mac/WebView/WebFrame.mm
index 4099e46..4f8c1ba 100644
--- a/WebKit/mac/WebView/WebFrame.mm
+++ b/WebKit/mac/WebView/WebFrame.mm
@@ -529,6 +529,26 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
     return [[[NSString alloc] initWithCharactersNoCopy:buf length:length freeWhenDone:YES] autorelease];
 }
 
+- (BOOL)_shouldFlattenCompositingLayers:(CGContextRef)context
+{
+    // -currentContextDrawingToScreen returns YES for bitmap contexts.
+    BOOL isPrinting = ![NSGraphicsContext currentContextDrawingToScreen];
+    if (isPrinting)
+        return YES;
+
+    if (!WKCGContextIsBitmapContext(context))
+        return NO;
+
+    // If we're drawing into a bitmap, we might be snapshotting, or drawing into a layer-backed view.
+    if ([getWebView(self) _usesDocumentViews]) {
+        id documentView = [_private->webFrameView documentView];
+        if ([documentView isKindOfClass:[WebHTMLView class]] && [(WebHTMLView *)documentView _web_isDrawingIntoLayer])
+            return NO;
+    }
+
+    return [getWebView(self) _includesFlattenedCompositingLayersWhenDrawingToBitmap];
+}
+
 - (void)_drawRect:(NSRect)rect contentsOnly:(BOOL)contentsOnly
 {
     ASSERT([[NSGraphicsContext currentContext] isFlipped]);
@@ -545,7 +565,7 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
         if (parentView)
             shouldFlatten = parentView->paintBehavior() & PaintBehaviorFlattenCompositingLayers;
     } else
-        shouldFlatten = WKCGContextIsBitmapContext(ctx) && [getWebView(self) _includesFlattenedCompositingLayersWhenDrawingToBitmap];
+        shouldFlatten = [self _shouldFlattenCompositingLayers:ctx];
 
     PaintBehavior oldBehavior = PaintBehaviorNormal;
     if (shouldFlatten) {
diff --git a/WebKit/mac/WebView/WebHTMLView.mm b/WebKit/mac/WebView/WebHTMLView.mm
index 55587c4..ec2473f 100644
--- a/WebKit/mac/WebView/WebHTMLView.mm
+++ b/WebKit/mac/WebView/WebHTMLView.mm
@@ -456,6 +456,7 @@ struct WebHTMLViewInterpretKeyEventsParameters {
     
 #if USE(ACCELERATED_COMPOSITING)
     NSView *layerHostingView;
+    BOOL drawingIntoLayer;
 #endif
 
     NSEvent *mouseDownEvent; // Kept after handling the event.
@@ -5636,6 +5637,25 @@ static CGPoint coreGraphicsScreenPointForAppKitScreenPoint(NSPoint point)
     [_private->layerHostingView setFrame:layerViewFrame];
 }
 #endif // defined(BUILDING_ON_LEOPARD)
+
+- (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx
+{
+    if (_private) {
+        ASSERT(!_private->drawingIntoLayer);
+        _private->drawingIntoLayer = YES;
+    }
+
+    [super drawLayer:layer inContext:ctx];
+
+    if (_private)
+        _private->drawingIntoLayer = NO;
+}
+
+- (BOOL)_web_isDrawingIntoLayer
+{
+    return _private->drawingIntoLayer;
+}
+
 #endif // USE(ACCELERATED_COMPOSITING)
 
 @end
diff --git a/WebKit/mac/WebView/WebHTMLViewInternal.h b/WebKit/mac/WebView/WebHTMLViewInternal.h
index 2d9e2a9..07a782a 100644
--- a/WebKit/mac/WebView/WebHTMLViewInternal.h
+++ b/WebKit/mac/WebView/WebHTMLViewInternal.h
@@ -66,6 +66,7 @@ namespace WebCore {
 #if USE(ACCELERATED_COMPOSITING)
 - (void)attachRootLayer:(CALayer*)layer;
 - (void)detachRootLayer;
+- (BOOL)_web_isDrawingIntoLayer;
 #endif
 
 #if USE(ACCELERATED_COMPOSITING) && defined(BUILDING_ON_LEOPARD)

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list