Title: [191366] trunk/Source/WebKit2
- Revision
- 191366
- Author
- [email protected]
- Date
- 2015-10-20 18:10:32 -0700 (Tue, 20 Oct 2015)
Log Message
_WKThumbnailView should support a snapshot-only mode
https://bugs.webkit.org/show_bug.cgi?id=150106
Reviewed by Tim Horton.
Add a new property to _WKThumbnailView, exclusivelyUsesSnapshot, which causes _WKThumbnailView
to bypass both layer tree reparenting and event suppression on the associated WKView.
Add a new method, -requestSnapshot, which clients can use to force _WKThumbnailView to refresh
on demand.
* UIProcess/API/Cocoa/_WKThumbnailView.h:
* UIProcess/API/Cocoa/_WKThumbnailView.mm:
(-[_WKThumbnailView requestSnapshot]):
Extracted from -_requestSnapshotIfNeeded:.
(-[_WKThumbnailView _viewWasUnparented]):
(-[_WKThumbnailView _viewWasParented]):
(-[_WKThumbnailView _requestSnapshotIfNeeded]):
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (191365 => 191366)
--- trunk/Source/WebKit2/ChangeLog 2015-10-20 23:40:19 UTC (rev 191365)
+++ trunk/Source/WebKit2/ChangeLog 2015-10-21 01:10:32 UTC (rev 191366)
@@ -1,3 +1,24 @@
+2015-10-13 Conrad Shultz <[email protected]>
+
+ _WKThumbnailView should support a snapshot-only mode
+ https://bugs.webkit.org/show_bug.cgi?id=150106
+
+ Reviewed by Tim Horton.
+
+ Add a new property to _WKThumbnailView, exclusivelyUsesSnapshot, which causes _WKThumbnailView
+ to bypass both layer tree reparenting and event suppression on the associated WKView.
+
+ Add a new method, -requestSnapshot, which clients can use to force _WKThumbnailView to refresh
+ on demand.
+
+ * UIProcess/API/Cocoa/_WKThumbnailView.h:
+ * UIProcess/API/Cocoa/_WKThumbnailView.mm:
+ (-[_WKThumbnailView requestSnapshot]):
+ Extracted from -_requestSnapshotIfNeeded:.
+ (-[_WKThumbnailView _viewWasUnparented]):
+ (-[_WKThumbnailView _viewWasParented]):
+ (-[_WKThumbnailView _requestSnapshotIfNeeded]):
+
2015-10-20 Alexey Proskuryakov <[email protected]>
Build fix.
Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKThumbnailView.h (191365 => 191366)
--- trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKThumbnailView.h 2015-10-20 23:40:19 UTC (rev 191365)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKThumbnailView.h 2015-10-21 01:10:32 UTC (rev 191366)
@@ -39,10 +39,13 @@
- (instancetype)initWithFrame:(NSRect)frame fromWKView:(WKView *)wkView;
@property (nonatomic) CGFloat scale;
+@property (nonatomic) BOOL exclusivelyUsesSnapshot;
// This should be removed when all clients go away; it is always YES now.
@property (nonatomic) BOOL usesSnapshot;
+- (void)requestSnapshot;
+
@end
#endif // TARGET_OS_IPHONE
Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKThumbnailView.mm (191365 => 191366)
--- trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKThumbnailView.mm 2015-10-20 23:40:19 UTC (rev 191365)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKThumbnailView.mm 2015-10-21 01:10:32 UTC (rev 191366)
@@ -56,7 +56,8 @@
double _lastSnapshotScale;
}
-@synthesize _waitingForSnapshot = _waitingForSnapshot;
+@synthesize _waitingForSnapshot=_waitingForSnapshot;
+@synthesize exclusivelyUsesSnapshot=_exclusivelyUsesSnapshot;
- (instancetype)initWithFrame:(NSRect)frame fromWKView:(WKView *)wkView
{
@@ -77,15 +78,38 @@
return self;
}
+- (void)requestSnapshot
+{
+ if (_waitingForSnapshot) {
+ _snapshotWasDeferred = YES;
+ return;
+ }
+
+ _waitingForSnapshot = YES;
+
+ RetainPtr<_WKThumbnailView> thumbnailView = self;
+ IntRect snapshotRect(IntPoint(), _webPageProxy->viewSize() - IntSize(0, _webPageProxy->topContentInset()));
+ SnapshotOptions options = SnapshotOptionsInViewCoordinates;
+ IntSize bitmapSize = snapshotRect.size();
+ bitmapSize.scale(_scale * _webPageProxy->deviceScaleFactor());
+ _lastSnapshotScale = _scale;
+ _webPageProxy->takeSnapshot(snapshotRect, bitmapSize, options, [thumbnailView](const ShareableBitmap::Handle& imageHandle, WebKit::CallbackBase::Error) {
+ RefPtr<ShareableBitmap> bitmap = ShareableBitmap::create(imageHandle, SharedMemory::Protection::ReadOnly);
+ RetainPtr<CGImageRef> cgImage = bitmap ? bitmap->makeCGImage() : nullptr;
+ [thumbnailView _didTakeSnapshot:cgImage.get()];
+ });
+}
+
- (void)_viewWasUnparented
{
- [_wkView _setThumbnailView:nil];
- [_wkView _setIgnoresAllEvents:NO];
+ if (!_exclusivelyUsesSnapshot) {
+ [_wkView _setThumbnailView:nil];
+ [_wkView _setIgnoresAllEvents:NO];
+ _webPageProxy->setMayStartMediaWhenInWindow(_originalMayStartMediaWhenInWindow);
+ }
self.layer.contents = nil;
_lastSnapshotScale = NAN;
-
- _webPageProxy->setMayStartMediaWhenInWindow(_originalMayStartMediaWhenInWindow);
}
- (void)_viewWasParented
@@ -93,12 +117,15 @@
if ([_wkView _thumbnailView])
return;
- if (!_originalSourceViewIsInWindow)
+ if (!_exclusivelyUsesSnapshot && !_originalSourceViewIsInWindow)
_webPageProxy->setMayStartMediaWhenInWindow(false);
[self _requestSnapshotIfNeeded];
- [_wkView _setThumbnailView:self];
- [_wkView _setIgnoresAllEvents:YES];
+
+ if (!_exclusivelyUsesSnapshot) {
+ [_wkView _setThumbnailView:self];
+ [_wkView _setIgnoresAllEvents:YES];
+ }
}
- (void)_requestSnapshotIfNeeded
@@ -106,24 +133,7 @@
if (self.layer.contents && _lastSnapshotScale == _scale)
return;
- if (_waitingForSnapshot) {
- _snapshotWasDeferred = YES;
- return;
- }
-
- _waitingForSnapshot = YES;
-
- RetainPtr<_WKThumbnailView> thumbnailView = self;
- IntRect snapshotRect(IntPoint(), _webPageProxy->viewSize() - IntSize(0, _webPageProxy->topContentInset()));
- SnapshotOptions options = SnapshotOptionsInViewCoordinates;
- IntSize bitmapSize = snapshotRect.size();
- bitmapSize.scale(_scale * _webPageProxy->deviceScaleFactor());
- _lastSnapshotScale = _scale;
- _webPageProxy->takeSnapshot(snapshotRect, bitmapSize, options, [thumbnailView](const ShareableBitmap::Handle& imageHandle, WebKit::CallbackBase::Error) {
- RefPtr<ShareableBitmap> bitmap = ShareableBitmap::create(imageHandle, SharedMemory::Protection::ReadOnly);
- RetainPtr<CGImageRef> cgImage = bitmap ? bitmap->makeCGImage() : nullptr;
- [thumbnailView _didTakeSnapshot:cgImage.get()];
- });
+ [self requestSnapshot];
}
- (void)_didTakeSnapshot:(CGImageRef)image
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes