Title: [167662] trunk/Source/WebKit2
Revision
167662
Author
timothy_hor...@apple.com
Date
2014-04-22 08:51:33 -0700 (Tue, 22 Apr 2014)

Log Message

WKThumbnailView doesn't quite work with topContentInset
https://bugs.webkit.org/show_bug.cgi?id=131976
<rdar://problem/16642127>

Reviewed by Darin Adler.

* UIProcess/API/Cocoa/_WKThumbnailView.mm:
(-[_WKThumbnailView initWithFrame:fromWKView:]):
_WKThumbnailView always needs a layer.
We don't want to use snapshots by default, this was debugging accidentally landed in the last change.

(-[_WKThumbnailView _requestSnapshotIfNeeded]):
Don't request a new snapshot if the scale is the same as the existing one.
Reduce the height of the snapshot by the topContentInset.
Having the origin at (0, 0) is still correct, as the inset content is in negative Y space,
and (0, 0) is the true origin of the content.

(-[_WKThumbnailView setScale:]):
When not snapshotting, we've decided that WKThumbnailView should apply the scale to the WKView layer tree,
instead of depending on clients to do so.

(-[_WKThumbnailView setUsesSnapshot:]):
We *do* need to apply thumbnail scale in the web process even when snapshotting,
because we use the live layer tree temporarily while waiting for the asynchronous
snapshot to return. This was a misstep in the last thumbnail view patch.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (167661 => 167662)


--- trunk/Source/WebKit2/ChangeLog	2014-04-22 15:39:26 UTC (rev 167661)
+++ trunk/Source/WebKit2/ChangeLog	2014-04-22 15:51:33 UTC (rev 167662)
@@ -1,3 +1,31 @@
+2014-04-22  Tim Horton  <timothy_hor...@apple.com>
+
+        WKThumbnailView doesn't quite work with topContentInset
+        https://bugs.webkit.org/show_bug.cgi?id=131976
+        <rdar://problem/16642127>
+
+        Reviewed by Darin Adler.
+
+        * UIProcess/API/Cocoa/_WKThumbnailView.mm:
+        (-[_WKThumbnailView initWithFrame:fromWKView:]):
+        _WKThumbnailView always needs a layer.
+        We don't want to use snapshots by default, this was debugging accidentally landed in the last change.
+
+        (-[_WKThumbnailView _requestSnapshotIfNeeded]):
+        Don't request a new snapshot if the scale is the same as the existing one.
+        Reduce the height of the snapshot by the topContentInset.
+        Having the origin at (0, 0) is still correct, as the inset content is in negative Y space,
+        and (0, 0) is the true origin of the content.
+
+        (-[_WKThumbnailView setScale:]):
+        When not snapshotting, we've decided that WKThumbnailView should apply the scale to the WKView layer tree,
+        instead of depending on clients to do so.
+
+        (-[_WKThumbnailView setUsesSnapshot:]):
+        We *do* need to apply thumbnail scale in the web process even when snapshotting,
+        because we use the live layer tree temporarily while waiting for the asynchronous
+        snapshot to return. This was a misstep in the last thumbnail view patch.
+
 2014-04-22  Shivakumar JM  <shiva...@samsung.com>
 
         [WebKit2] Cleanup the build from unused parameter in WebProcess Module 

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKThumbnailView.mm (167661 => 167662)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKThumbnailView.mm	2014-04-22 15:39:26 UTC (rev 167661)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKThumbnailView.mm	2014-04-22 15:51:33 UTC (rev 167662)
@@ -55,6 +55,7 @@
     BOOL _shouldApplyThumbnailScale;
 
     BOOL _snapshotWasDeferred;
+    double _lastSnapshotScale;
 }
 
 @synthesize _waitingForSnapshot = _waitingForSnapshot;
@@ -64,17 +65,18 @@
     if (!(self = [super initWithFrame:frame]))
         return nil;
 
+    self.wantsLayer = YES;
+
     _wkView = wkView;
     _webPageProxy = toImpl([_wkView pageRef]);
     _scale = 1;
+    _lastSnapshotScale = NAN;
 
     _originalMayStartMediaWhenInWindow = _webPageProxy->mayStartMediaWhenInWindow();
     _originalSourceViewIsInWindow = !![_wkView window];
 
     _shouldApplyThumbnailScale = !_originalSourceViewIsInWindow;
 
-    self.usesSnapshot = YES;
-
     return self;
 }
 
@@ -86,6 +88,7 @@
     [_wkView _setThumbnailView:nil];
 
     self.layer.contents = nil;
+    _lastSnapshotScale = NAN;
 
     _webPageProxy->setMayStartMediaWhenInWindow(_originalMayStartMediaWhenInWindow);
 }
@@ -110,6 +113,9 @@
     if (!_usesSnapshot)
         return;
 
+    if (self.layer.contents && _lastSnapshotScale == _scale)
+        return;
+
     if (_waitingForSnapshot) {
         _snapshotWasDeferred = YES;
         return;
@@ -118,10 +124,11 @@
     _waitingForSnapshot = YES;
 
     RetainPtr<_WKThumbnailView> thumbnailView = self;
-    IntRect snapshotRect(IntPoint(), _webPageProxy->viewSize());
+    IntRect snapshotRect(IntPoint(), _webPageProxy->viewSize() - IntSize(0, _webPageProxy->topContentInset()));
     SnapshotOptions options = SnapshotOptionsRespectDrawingAreaTransform | SnapshotOptionsInViewCoordinates;
     IntSize bitmapSize = snapshotRect.size();
     bitmapSize.scale(_scale * _webPageProxy->deviceScaleFactor());
+    _lastSnapshotScale = _scale;
     _webPageProxy->takeSnapshot(snapshotRect, bitmapSize, options, [thumbnailView](bool, const ShareableBitmap::Handle& imageHandle) {
         RefPtr<ShareableBitmap> bitmap = ShareableBitmap::create(imageHandle, SharedMemory::ReadOnly);
         RetainPtr<CGImageRef> cgImage = bitmap->makeCGImage();
@@ -163,6 +170,8 @@
 
     if (_usesSnapshot)
         [self _requestSnapshotIfNeeded];
+
+    self.layer.sublayerTransform = CATransform3DMakeScale(_scale, _scale, 1);
 }
 
 - (void)setUsesSnapshot:(BOOL)usesSnapshot
@@ -171,7 +180,6 @@
         return;
 
     _usesSnapshot = usesSnapshot;
-    _shouldApplyThumbnailScale = _usesSnapshot ? false : !_originalSourceViewIsInWindow;
 
     if (!self.window)
         return;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to