Changeset 162710 in webkit
- Timestamp:
- Jan 24, 2014 10:56:23 AM (10 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 2 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r162709 r162710 1 2014-01-24 Tim Horton <timothy_horton@apple.com> 2 3 WebKit2 View Gestures (Swipe): Add a simple cache of view snapshots 4 https://bugs.webkit.org/show_bug.cgi?id=127438 5 6 Reviewed by Sam Weinig. 7 8 Add a cache of bitmap snapshots of the WKView, taken via OS X's window server 9 snapshotting mechanism. For now, we store all snapshots; refinements to the 10 caching strategy (or really having one at all) will come in future patches. 11 12 Snapshots are stored in a side map, with a UUID that allows references 13 to be stored inside WebBackForwardListItem (and serialized along with 14 the back-forward list when it is copied). 15 16 * Shared/WebBackForwardListItem.h: 17 (WebKit::WebBackForwardListItem::setSnapshotUUID): 18 (WebKit::WebBackForwardListItem::snapshotUUID): 19 * UIProcess/cf/WebBackForwardListCF.cpp: 20 (WebKit::WebBackForwardList::createCFDictionaryRepresentation): 21 (WebKit::extractBackForwardListEntriesFromArray): 22 Store and serialize a UUID along with each back-forward list item which 23 identifies that item's view snapshot in the ViewSnapshotStore. 24 25 * UIProcess/cf/WebPageProxyCF.cpp: 26 Bump the session state data version, as we changed the WebBackForwardList format. 27 28 * UIProcess/API/Cocoa/WKViewPrivate.h: 29 * UIProcess/API/mac/PageClientImpl.h: 30 * UIProcess/API/mac/PageClientImpl.mm: 31 (WebKit::PageClientImpl::takeViewSnapshot): 32 33 * UIProcess/API/mac/WKView.mm: 34 (-[WKView _takeViewSnapshot]): 35 Add _takeViewSnapshot IPI, which is used by ViewSnapshotStore via the PageClient 36 to take a snapshot of the view. 37 38 (-[WKView saveBackForwardSnapshotForCurrentItem]): 39 Add saveBackForwardSnapshotForCurrentItem SPI, which clients could potentially 40 use when they know they're about to manipulate the view hierarchy in such a way 41 that they want the current back-forward item's snapshot to be up to date. 42 43 * UIProcess/API/mac/WKViewInternal.h: 44 * UIProcess/PageClient.h: 45 * UIProcess/WebPageProxy.cpp: 46 (WebKit::WebPageProxy::WebPageProxy): 47 (WebKit::WebPageProxy::recordNavigationSnapshot): 48 (WebKit::WebPageProxy::goForward): 49 (WebKit::WebPageProxy::goBack): 50 (WebKit::WebPageProxy::goToBackForwardItem): 51 (WebKit::WebPageProxy::didStartProvisionalLoadForFrame): 52 Update the current back-forward item's snapshot immediately before navigating. 53 54 * UIProcess/WebPageProxy.h: 55 (WebKit::WebPageProxy::shouldRecordNavigationSnapshots): 56 (WebKit::WebPageProxy::setShouldRecordNavigationSnapshots): 57 Expose the ability to enable taking view snapshots on every navigation. 58 This is off by default, so we won't be taking any snapshots yet. 59 60 * UIProcess/mac/ViewSnapshotStore.h: Added. 61 (WebKit::ViewSnapshotStore::disableSnapshotting): 62 (WebKit::ViewSnapshotStore::enableSnapshotting): 63 * UIProcess/mac/ViewSnapshotStore.mm: Added. 64 (WebKit::ViewSnapshotStore::ViewSnapshotStore): 65 (WebKit::ViewSnapshotStore::~ViewSnapshotStore): 66 (WebKit::ViewSnapshotStore::shared): 67 (WebKit::ViewSnapshotStore::recordSnapshot): 68 (WebKit::ViewSnapshotStore::snapshotAndRenderTreeSize): 69 * UIProcess/mac/WebPageProxyMac.mm: 70 (WebKit::WebPageProxy::takeViewSnapshot): 71 * WebKit2.xcodeproj/project.pbxproj: 72 1 73 2014-01-24 Brady Eidson <beidson@apple.com> 2 74 -
trunk/Source/WebKit2/Shared/WebBackForwardListItem.h
r161148 r162710 61 61 const Vector<uint8_t>& backForwardData() const { return m_backForwardData; } 62 62 63 void setSnapshotUUID(const String& uuid) { m_snapshotUUID = uuid; } 64 const String& snapshotUUID() const { return m_snapshotUUID; } 65 63 66 void encode(IPC::ArgumentEncoder&) const; 64 67 static PassRefPtr<WebBackForwardListItem> decode(IPC::ArgumentDecoder&); … … 74 77 uint64_t m_itemID; 75 78 Vector<uint8_t> m_backForwardData; 79 String m_snapshotUUID; 76 80 }; 77 81 -
trunk/Source/WebKit2/UIProcess/API/Cocoa/WKViewPrivate.h
r162590 r162710 90 90 - (void)setMagnification:(double)magnification centeredAtPoint:(NSPoint)point; 91 91 92 - (void)saveBackForwardSnapshotForCurrentItem; 93 92 94 #endif 93 95 -
trunk/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h
r162158 r162710 114 114 virtual void updateAcceleratedCompositingMode(const LayerTreeContext&); 115 115 116 virtual RetainPtr<CGImageRef> takeViewSnapshot() override; 117 116 118 virtual void accessibilityWebProcessTokenReceived(const IPC::DataReference&); 117 119 -
trunk/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm
r161357 r162710 435 435 } 436 436 437 RetainPtr<CGImageRef> PageClientImpl::takeViewSnapshot() 438 { 439 return [m_wkView _takeViewSnapshot]; 440 } 441 437 442 void PageClientImpl::pluginFocusOrWindowFocusChanged(uint64_t pluginComplexTextInputIdentifier, bool pluginHasFocusAndWindowHasFocus) 438 443 { -
trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm
r162657 r162710 51 51 #import "TiledCoreAnimationDrawingAreaProxy.h" 52 52 #import "ViewGestureController.h" 53 #import "ViewSnapshotStore.h" 53 54 #import "WKAPICast.h" 54 55 #import "WKFullScreenWindowController.h" … … 58 59 #import "WKViewInternal.h" 59 60 #import "WKViewPrivate.h" 61 #import "WebBackForwardList.h" 60 62 #import "WebContext.h" 61 63 #import "WebEventFactory.h" … … 113 115 - (void)_maskRoundedBottomCorners:(NSRect)clipRect; 114 116 @end 117 118 #if defined(__has_include) && __has_include(<CoreGraphics/CoreGraphicsPrivate.h>) 119 #import <CoreGraphics/CoreGraphicsPrivate.h> 120 #endif 121 122 extern "C" { 123 typedef uint32_t CGSConnectionID; 124 typedef uint32_t CGSWindowID; 125 CGSConnectionID CGSMainConnectionID(void); 126 CGError CGSGetScreenRectForWindow(CGSConnectionID cid, CGSWindowID wid, CGRect *rect); 127 }; 115 128 116 129 using namespace WebKit; … … 2498 2511 } 2499 2512 2513 - (RetainPtr<CGImageRef>)_takeViewSnapshot 2514 { 2515 NSWindow *window = self.window; 2516 2517 if (![window windowNumber]) 2518 return nullptr; 2519 2520 RetainPtr<CGImageRef> windowSnapshotImage = adoptCF(CGWindowListCreateImage(CGRectNull, kCGWindowListOptionIncludingWindow, [window windowNumber], kCGWindowImageBoundsIgnoreFraming | kCGWindowImageShouldBeOpaque)); 2521 2522 NSRect windowCaptureRect = [self convertRect:self.bounds toView:nil]; 2523 NSRect windowCaptureScreenRect = [window convertRectToScreen:windowCaptureRect]; 2524 CGRect windowScreenRect; 2525 CGSGetScreenRectForWindow(CGSMainConnectionID(), (CGSWindowID)[window windowNumber], &windowScreenRect); 2526 2527 NSRect croppedImageRect = windowCaptureRect; 2528 croppedImageRect.origin.y = windowScreenRect.size.height - windowCaptureScreenRect.size.height - NSMinY(windowCaptureRect); 2529 2530 return adoptCF(CGImageCreateWithImageInRect(windowSnapshotImage.get(), NSRectToCGRect([window convertRectToBacking:croppedImageRect]))); 2531 } 2532 2500 2533 - (void)_setAccessibilityWebProcessToken:(NSData *)data 2501 2534 { … … 2814 2847 @implementation WKView (Private) 2815 2848 2849 - (void)saveBackForwardSnapshotForCurrentItem 2850 { 2851 _data->_page->recordNavigationSnapshot(); 2852 } 2853 2816 2854 - (void)_registerDraggedTypes 2817 2855 { -
trunk/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h
r161148 r162710 71 71 - (void)_setAcceleratedCompositingModeRootLayer:(CALayer *)rootLayer; 72 72 73 - (RetainPtr<CGImageRef>)_takeViewSnapshot; 74 73 75 - (void)_setAccessibilityWebProcessToken:(NSData *)data; 74 76 -
trunk/Source/WebKit2/UIProcess/PageClient.h
r162103 r162710 173 173 virtual void makeFirstResponder() = 0; 174 174 virtual void setAcceleratedCompositingRootLayer(CALayer *) = 0; 175 virtual RetainPtr<CGImageRef> takeViewSnapshot() = 0; 175 176 #endif 176 177 -
trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp
r162689 r162710 125 125 #endif 126 126 127 #if PLATFORM(MAC) 128 #include "ViewSnapshotStore.h" 129 #endif 130 127 131 // This controls what strategy we use for mouse wheel coalescing. 128 132 #define MERGE_WHEEL_EVENTS 1 … … 310 314 , m_backgroundExtendsBeyondPage(false) 311 315 , m_mainFrameInViewSourceMode(false) 316 , m_shouldRecordNavigationSnapshots(false) 312 317 , m_pageCount(0) 313 318 , m_renderTreeSize(0) … … 751 756 } 752 757 758 void WebPageProxy::recordNavigationSnapshot() 759 { 760 if (!m_shouldRecordNavigationSnapshots) 761 return; 762 763 #if PLATFORM(MAC) 764 ViewSnapshotStore::shared().recordSnapshot(*this); 765 #endif 766 } 767 753 768 void WebPageProxy::goForward() 754 769 { … … 760 775 return; 761 776 777 recordNavigationSnapshot(); 778 762 779 auto transaction = m_pageLoadState.transaction(); 763 780 … … 787 804 return; 788 805 806 recordNavigationSnapshot(); 807 789 808 auto transaction = m_pageLoadState.transaction(); 790 809 … … 811 830 return; 812 831 } 832 833 recordNavigationSnapshot(); 813 834 814 835 auto transaction = m_pageLoadState.transaction(); … … 2108 2129 MESSAGE_CHECK_URL(url); 2109 2130 2110 if (frame->isMainFrame()) 2131 if (frame->isMainFrame()) { 2132 recordNavigationSnapshot(); 2111 2133 m_pageLoadState.didStartProvisionalLoad(transaction, url, unreachableURL); 2134 } 2112 2135 2113 2136 frame->setUnreachableURL(unreachableURL); … … 4360 4383 #endif 4361 4384 4385 RetainPtr<CGImageRef> WebPageProxy::takeViewSnapshot() 4386 { 4387 return m_pageClient.takeViewSnapshot(); 4388 } 4389 4362 4390 #endif // PLATFORM(MAC) 4363 4391 -
trunk/Source/WebKit2/UIProcess/WebPageProxy.h
r162670 r162710 859 859 void setScrollPinningBehavior(WebCore::ScrollPinningBehavior); 860 860 WebCore::ScrollPinningBehavior scrollPinningBehavior() { return m_scrollPinningBehavior; } 861 861 862 bool shouldRecordNavigationSnapshots() const { return m_shouldRecordNavigationSnapshots; } 863 void setShouldRecordNavigationSnapshots(bool shouldRecordSnapshots) { m_shouldRecordNavigationSnapshots = shouldRecordSnapshots; } 864 void recordNavigationSnapshot(); 865 866 #if PLATFORM(MAC) 867 RetainPtr<CGImageRef> takeViewSnapshot(); 868 #endif 869 862 870 private: 863 871 WebPageProxy(PageClient&, WebProcessProxy&, WebPageGroup&, API::Session&, uint64_t pageID); … … 1360 1368 1361 1369 bool m_mainFrameInViewSourceMode; 1362 1370 1371 bool m_shouldRecordNavigationSnapshots; 1372 1363 1373 unsigned m_pageCount; 1364 1374 -
trunk/Source/WebKit2/UIProcess/cf/WebBackForwardListCF.cpp
r161148 r162710 1 1 /* 2 * Copyright (C) 2010, 2011, 2012 Apple Inc. All rights reserved.2 * Copyright (C) 2010, 2011, 2012, 2014 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 59 59 static CFStringRef sessionHistoryEntryOriginalURLKey = CFSTR("SessionHistoryEntryOriginalURL"); 60 60 static CFStringRef sessionHistoryEntryDataKey = CFSTR("SessionHistoryEntryData"); 61 static CFStringRef sessionHistoryEntrySnapshotUUIDKey = CFSTR("SessionHistoryEntrySnapshotUUID"); 61 62 62 63 static bool extractBackForwardListEntriesFromArray(CFArrayRef, BackForwardListItemVector&); … … 105 106 RetainPtr<CFStringRef> title = m_entries[i]->title().createCFString(); 106 107 RetainPtr<CFStringRef> originalURL = m_entries[i]->originalURL().createCFString(); 108 RetainPtr<CFStringRef> uuid = m_entries[i]->snapshotUUID().createCFString(); 107 109 108 110 // FIXME: This uses the IPC data encoding format, which means that whenever we change the IPC encoding we need to bump the CurrentSessionStateDataVersion 109 111 // constant in WebPageProxyCF.cpp. The IPC data format is meant to be an implementation detail, and not something that should be written to disk. 110 112 RetainPtr<CFDataRef> entryData = adoptCF(CFDataCreate(kCFAllocatorDefault, m_entries[i]->backForwardData().data(), m_entries[i]->backForwardData().size())); 111 112 const void* keys[ 4] = { sessionHistoryEntryURLKey, sessionHistoryEntryTitleKey, sessionHistoryEntryOriginalURLKey, sessionHistoryEntryDataKey };113 const void* values[ 4] = { url.get(), title.get(), originalURL.get(), entryData.get() };114 115 RetainPtr<CFDictionaryRef> entryDictionary = adoptCF(CFDictionaryCreate(0, keys, values, 4, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));113 114 const void* keys[5] = { sessionHistoryEntryURLKey, sessionHistoryEntryTitleKey, sessionHistoryEntryOriginalURLKey, sessionHistoryEntryDataKey, sessionHistoryEntrySnapshotUUIDKey }; 115 const void* values[5] = { url.get(), title.get(), originalURL.get(), entryData.get(), uuid.get() }; 116 117 RetainPtr<CFDictionaryRef> entryDictionary = adoptCF(CFDictionaryCreate(0, keys, values, 5, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); 116 118 CFArrayAppendValue(entries.get(), entryDictionary.get()); 117 119 } … … 310 312 } 311 313 314 CFStringRef snapshotUUID = (CFStringRef)CFDictionaryGetValue(entryDictionary, sessionHistoryEntrySnapshotUUIDKey); 315 if (!snapshotUUID || CFGetTypeID(snapshotUUID) != CFStringGetTypeID()) { 316 LOG(SessionState, "WebBackForwardList entry at index %i does not have a valid snapshot UUID", (int)i); 317 return false; 318 } 319 312 320 CFDataRef backForwardData = (CFDataRef)CFDictionaryGetValue(entryDictionary, sessionHistoryEntryDataKey); 313 321 if (!backForwardData || CFGetTypeID(backForwardData) != CFDataGetTypeID()) { … … 315 323 return false; 316 324 } 317 318 entries.append(WebBackForwardListItem::create(originalURL, entryURL, entryTitle, CFDataGetBytePtr(backForwardData), CFDataGetLength(backForwardData), generateWebBackForwardItemID())); 325 326 auto item = WebBackForwardListItem::create(originalURL, entryURL, entryTitle, CFDataGetBytePtr(backForwardData), CFDataGetLength(backForwardData), generateWebBackForwardItemID()); 327 item->setSnapshotUUID(snapshotUUID); 328 entries.append(item); 319 329 } 320 330 -
trunk/Source/WebKit2/UIProcess/cf/WebPageProxyCF.cpp
r161045 r162710 45 45 static CFStringRef provisionalURLKey = CFSTR("ProvisionalURL"); 46 46 47 static const UInt32 CurrentSessionStateDataVersion = 2;47 static const UInt32 CurrentSessionStateDataVersion = 3; 48 48 49 49 PassRefPtr<API::Data> WebPageProxy::sessionStateData(WebPageProxySessionStateFilterCallback filter, void* context) const -
trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
r162678 r162710 417 417 2D47B56C1810714E003A3AEE /* RemoteLayerBackingStore.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D47B56A1810714E003A3AEE /* RemoteLayerBackingStore.mm */; }; 418 418 2D47B56D1810714E003A3AEE /* RemoteLayerBackingStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D47B56B1810714E003A3AEE /* RemoteLayerBackingStore.h */; }; 419 2D6CD119189058A500E5A4A0 /* ViewSnapshotStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D6CD117189058A500E5A4A0 /* ViewSnapshotStore.h */; }; 420 2D6CD11A189058A500E5A4A0 /* ViewSnapshotStore.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D6CD118189058A500E5A4A0 /* ViewSnapshotStore.mm */; }; 419 421 2D819B9E18627EE9001F03D1 /* ViewGestureGeometryCollector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2D819B99186275B3001F03D1 /* ViewGestureGeometryCollector.cpp */; }; 420 422 2D819BA11862800E001F03D1 /* ViewGestureGeometryCollectorMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2D819B9F1862800E001F03D1 /* ViewGestureGeometryCollectorMessageReceiver.cpp */; }; … … 2071 2073 2D47B56A1810714E003A3AEE /* RemoteLayerBackingStore.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RemoteLayerBackingStore.mm; sourceTree = "<group>"; }; 2072 2074 2D47B56B1810714E003A3AEE /* RemoteLayerBackingStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteLayerBackingStore.h; sourceTree = "<group>"; }; 2075 2D6CD117189058A500E5A4A0 /* ViewSnapshotStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewSnapshotStore.h; sourceTree = "<group>"; }; 2076 2D6CD118189058A500E5A4A0 /* ViewSnapshotStore.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ViewSnapshotStore.mm; sourceTree = "<group>"; }; 2073 2077 2D819B99186275B3001F03D1 /* ViewGestureGeometryCollector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ViewGestureGeometryCollector.cpp; sourceTree = "<group>"; }; 2074 2078 2D819B9A186275B3001F03D1 /* ViewGestureGeometryCollector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewGestureGeometryCollector.h; sourceTree = "<group>"; }; … … 5694 5698 2D125C5D1857EA05003BA3CB /* ViewGestureController.mm */, 5695 5699 2D1B5D5A18586599006C6596 /* ViewGestureController.messages.in */, 5700 2D6CD117189058A500E5A4A0 /* ViewSnapshotStore.h */, 5701 2D6CD118189058A500E5A4A0 /* ViewSnapshotStore.mm */, 5696 5702 728E86EF1795188C0087879E /* WebColorPickerMac.h */, 5697 5703 728E86F01795188C0087879E /* WebColorPickerMac.mm */, … … 6668 6674 BC1DFE8F12B31CA8005DF730 /* WKOpenPanelResultListener.h in Headers */, 6669 6675 BCD597D7112B56DC00EC8C23 /* WKPage.h in Headers */, 6676 2D6CD119189058A500E5A4A0 /* ViewSnapshotStore.h in Headers */, 6670 6677 BC7B633712A45ABA00D174A4 /* WKPageGroup.h in Headers */, 6671 6678 BC2D021912AC426C00E732A3 /* WKPageLoadTypes.h in Headers */, … … 7498 7505 5167EEA1170377BF007681CA /* DiskCacheMonitor.mm in Sources */, 7499 7506 2DA9448F1884E3B500ED86DB /* WKGeolocationProviderIOS.mm in Sources */, 7507 2D6CD11A189058A500E5A4A0 /* ViewSnapshotStore.mm in Sources */, 7500 7508 518E8F0716B2093700E91429 /* Download.cpp in Sources */, 7501 7509 2D47B56C1810714E003A3AEE /* RemoteLayerBackingStore.mm in Sources */,
Note: See TracChangeset
for help on using the changeset viewer.