Changeset 102619 in webkit
- Timestamp:
- Dec 12, 2011 2:00:31 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r102612 r102619 1 2011-12-12 Brady Eidson <beidson@apple.com> 2 3 Page cache should support pages with plugins. 4 <rdar://problem/5190122> and https://bugs.webkit.org/show_bug.cgi?id=13634 5 6 Reviewed by Anders Carlsson. 7 8 * plugins/netscape-plugin-page-cache-works-expected.txt: Added. 9 * plugins/netscape-plugin-page-cache-works.html: Added. 10 * plugins/resources/go-back.html: Added. 11 1 12 2011-12-12 James Robinson <jamesr@chromium.org> 2 13 -
trunk/Source/WebCore/ChangeLog
r102613 r102619 1 2011-12-12 Brady Eidson <beidson@apple.com> 2 3 Page cache should support pages with plugins. 4 <rdar://problem/5190122> and https://bugs.webkit.org/show_bug.cgi?id=13634 5 6 Reviewed by Anders Carlsson. 7 8 By making plugin elements renderers go display:none when entering the page cache, 9 we destroy the plug-in in a cross platform way as well as handle invalidating script 10 objects created by that plugin. 11 12 By restoring the original style when leaving the page cache and forcing a style recalc 13 on the plugin element, the plugin is gracefully reinstantiated when the user goes back. 14 15 Test: plugins/netscape-plugin-page-cache-works.html 16 17 * dom/Document.cpp: 18 (WebCore::Document::documentDidBecomeActive): Copy this collection before iterating over 19 it, as the callbacks might result in mutating the set. 20 21 * dom/Node.h: 22 (WebCore::Node::setHasCustomStyleForRenderer): 23 (WebCore::Node::clearHasCustomStyleForRenderer): Expose the ability to stop using a 24 custom renderer and go back to the default renderer. 25 26 * history/CachedFrame.cpp: 27 (WebCore::CachedFrame::CachedFrame): Move the document inactivation call to the same place 28 we suspend active DOM objects. It is important this call be *after* the beforeunload event 29 is dispatched, and was coincidental non of the elements that using Document activation 30 had run in to this problem yet. 31 32 * history/PageCache.cpp: 33 (WebCore::logCanCacheFrameDecision): 34 (WebCore::PageCache::canCachePageContainingThisFrame): If the page contains plugins but 35 the PageCacheSupportsPlugins setting is true, allow this page. 36 37 Kill and recreate the plugin by listening for Document activation callbacks and setting a custom 38 display:none render style: 39 * html/HTMLPlugInImageElement.cpp: 40 (WebCore::HTMLPlugInImageElement::HTMLPlugInImageElement): 41 (WebCore::HTMLPlugInImageElement::~HTMLPlugInImageElement): Unregister for document activation 42 callbacks. 43 (WebCore::HTMLPlugInImageElement::createRenderer): Once a renderer (ie. plugin instance) is 44 created, this element needs Document (in)activation callbacks. 45 (WebCore::HTMLPlugInImageElement::willMoveToNewOwnerDocument): Manage Document activation 46 callback registration. 47 (WebCore::HTMLPlugInImageElement::didMoveToNewOwnerDocument): Ditto. 48 (WebCore::HTMLPlugInImageElement::documentWillBecomeInactive): Clone the element's current style 49 and set the clone's display value to None. Start using this custom style and force a style 50 recall. This destroys the renderer and therefore the plugin instance. 51 (WebCore::HTMLPlugInImageElement::documentDidBecomeActive): Stop using the custom style and 52 force a style recall to reinstantiate the plugin. 53 (WebCore::HTMLPlugInImageElement::customStyleForRenderer): Return the stand-in style that has 54 display:none set. 55 * html/HTMLPlugInImageElement.h: 56 57 Add a setting that allows runtime configuration of whether or not the page cache supports plugins: 58 * page/Settings.cpp: 59 (WebCore::Settings::Settings): 60 * page/Settings.h: 61 (WebCore::Settings::setPageCacheSupportsPlugins): 62 (WebCore::Settings::pageCacheSupportsPlugins): 63 1 64 2011-12-12 Ojan Vafai <ojan@chromium.org> 2 65 -
trunk/Source/WebCore/dom/Document.cpp
r102612 r102619 3941 3941 void Document::documentDidBecomeActive() 3942 3942 { 3943 HashSet<Element*>::iterator end = m_documentActivationCallbackElements.end(); 3944 for (HashSet<Element*>::iterator i = m_documentActivationCallbackElements.begin(); i != end; ++i) 3943 Vector<Element*> elements; 3944 copyToVector(m_documentActivationCallbackElements, elements); 3945 Vector<Element*>::iterator end = elements.end(); 3946 for (Vector<Element*>::iterator i = elements.begin(); i != end; ++i) 3945 3947 (*i)->documentDidBecomeActive(); 3946 3948 -
trunk/Source/WebCore/dom/Node.h
r102431 r102619 692 692 693 693 bool hasCustomStyleForRenderer() const { return getFlag(HasCustomStyleForRendererFlag); } 694 void setHasCustomStyleForRenderer() { setFlag(true, HasCustomStyleForRendererFlag); } 694 void setHasCustomStyleForRenderer() { setFlag(true, HasCustomStyleForRendererFlag); } 695 void clearHasCustomStyleForRenderer() { clearFlag(HasCustomStyleForRendererFlag); } 695 696 696 697 private: -
trunk/Source/WebCore/history/CachedFrame.cpp
r95901 r102619 157 157 m_view->detachCustomScrollbars(); 158 158 159 m_document->documentWillBecomeInactive();160 159 frame->clearTimers(); 161 160 m_document->setInPageCache(true); … … 171 170 // those create more objects. 172 171 // FIXME: It's still possible to have objects created after suspending in some cases, see http://webkit.org/b/53733 for more details. 172 m_document->documentWillBecomeInactive(); 173 173 m_document->suspendScriptedAnimationControllerCallbacks(); 174 174 m_document->suspendActiveDOMObjects(ActiveDOMObject::DocumentWillBecomeInactive); -
trunk/Source/WebCore/history/PageCache.cpp
r99239 r102619 108 108 cannotCache = true; 109 109 } 110 if (frame->loader()->subframeLoader()->containsPlugins() ) {110 if (frame->loader()->subframeLoader()->containsPlugins() && !frame->page()->settings()->pageCacheSupportsPlugins()) { 111 111 PCLOG(" -Frame contains plugins"); 112 112 cannotCache = true; … … 256 256 // Do not cache error pages (these can be recognized as pages with substitute data or unreachable URLs). 257 257 && !(frame->loader()->documentLoader()->substituteData().isValid() && !frame->loader()->documentLoader()->substituteData().failingURL().isEmpty()) 258 // FIXME: If we ever change this so that frames with plug-ins will be cached, 259 // we need to make sure that we don't cache frames that have outstanding NPObjects 260 // (objects created by the plug-in). Since there is no way to pause/resume a Netscape plug-in, 261 // they would need to be destroyed and then recreated, and there is no way that we can recreate 262 // the right NPObjects. See <rdar://problem/5197041> for more information. 263 && !frame->loader()->subframeLoader()->containsPlugins() 258 && (!frame->loader()->subframeLoader()->containsPlugins() || frame->page()->settings()->pageCacheSupportsPlugins()) 264 259 && !frame->document()->url().protocolIs("https") 265 260 && (!frame->domWindow() || !frame->domWindow()->hasEventListeners(eventNames().unloadEvent)) -
trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp
r96826 r102619 28 28 #include "HTMLNames.h" 29 29 #include "Image.h" 30 #include "NodeRenderStyle.h" 30 31 #include "Page.h" 31 32 #include "RenderEmbeddedObject.h" … … 43 44 , m_needsWidgetUpdate(!createdByParser) 44 45 , m_shouldPreferPlugInsForImages(preferPlugInsForImagesOption == ShouldPreferPlugInsForImages) 46 , m_needsDocumentActivationCallbacks(false) 45 47 { 46 48 setHasCustomWillOrDidRecalcStyle(); 49 } 50 51 HTMLPlugInImageElement::~HTMLPlugInImageElement() 52 { 53 if (m_needsDocumentActivationCallbacks) 54 document()->unregisterForDocumentActivationCallbacks(this); 47 55 } 48 56 … … 116 124 RenderObject* HTMLPlugInImageElement::createRenderer(RenderArena* arena, RenderStyle* style) 117 125 { 126 // Once a PlugIn Element creates its renderer, it needs to be told when the Document goes 127 // inactive or reactivates so it can clear the renderer before going into the page cache. 128 if (!m_needsDocumentActivationCallbacks) { 129 m_needsDocumentActivationCallbacks = true; 130 document()->registerForDocumentActivationCallbacks(this); 131 } 132 118 133 // Fallback content breaks the DOM->Renderer class relationship of this 119 134 // class and all superclasses because createObject won't necessarily … … 190 205 void HTMLPlugInImageElement::willMoveToNewOwnerDocument() 191 206 { 207 if (m_needsDocumentActivationCallbacks) 208 document()->unregisterForDocumentActivationCallbacks(this); 209 192 210 if (m_imageLoader) 193 211 m_imageLoader->elementWillMoveToNewOwnerDocument(); 212 194 213 HTMLPlugInElement::willMoveToNewOwnerDocument(); 195 214 } 196 215 216 void HTMLPlugInImageElement::didMoveToNewOwnerDocument() 217 { 218 if (m_needsDocumentActivationCallbacks) 219 document()->registerForDocumentActivationCallbacks(this); 220 221 HTMLPlugInElement::didMoveToNewOwnerDocument(); 222 } 223 224 void HTMLPlugInImageElement::documentWillBecomeInactive() 225 { 226 if (RenderStyle* rs = renderStyle()) { 227 m_customStyleForPageCache = RenderStyle::clone(rs); 228 m_customStyleForPageCache->setDisplay(NONE); 229 } 230 231 setHasCustomStyleForRenderer(); 232 233 if (m_customStyleForPageCache) 234 recalcStyle(Force); 235 236 HTMLPlugInElement::documentWillBecomeInactive(); 237 } 238 239 void HTMLPlugInImageElement::documentDidBecomeActive() 240 { 241 clearHasCustomStyleForRenderer(); 242 243 if (m_customStyleForPageCache) { 244 m_customStyleForPageCache = 0; 245 recalcStyle(Force); 246 } 247 248 HTMLPlugInElement::documentDidBecomeActive(); 249 } 250 251 PassRefPtr<RenderStyle> HTMLPlugInImageElement::customStyleForRenderer() 252 { 253 if (!m_customStyleForPageCache) 254 return renderStyle(); 255 256 return m_customStyleForPageCache; 257 } 258 197 259 void HTMLPlugInImageElement::updateWidgetCallback(Node* n, unsigned) 198 260 { -
trunk/Source/WebCore/html/HTMLPlugInImageElement.h
r95901 r102619 23 23 24 24 #include "HTMLPlugInElement.h" 25 26 #include "RenderStyle.h" 25 27 #include <wtf/OwnPtr.h> 26 28 … … 43 45 class HTMLPlugInImageElement : public HTMLPlugInElement { 44 46 public: 47 virtual ~HTMLPlugInImageElement() OVERRIDE; 48 45 49 RenderEmbeddedObject* renderEmbeddedObject() const; 46 50 … … 70 74 bool wouldLoadAsNetscapePlugin(const String& url, const String& serviceType); 71 75 72 virtual void willMoveToNewOwnerDocument(); 76 virtual void willMoveToNewOwnerDocument() OVERRIDE; 77 virtual void didMoveToNewOwnerDocument() OVERRIDE; 78 79 virtual void documentWillBecomeInactive() OVERRIDE; 80 virtual void documentDidBecomeActive() OVERRIDE; 81 82 virtual PassRefPtr<RenderStyle> customStyleForRenderer() OVERRIDE; 73 83 74 84 private: … … 83 93 bool m_needsWidgetUpdate; 84 94 bool m_shouldPreferPlugInsForImages; 95 bool m_needsDocumentActivationCallbacks; 96 RefPtr<RenderStyle> m_customStyleForPageCache; 85 97 }; 86 98 -
trunk/Source/WebCore/page/Settings.cpp
r102539 r102619 154 154 , m_shrinksStandaloneImagesToFit(true) 155 155 , m_usesPageCache(false) 156 , m_pageCacheSupportsPlugins(false) 156 157 , m_showsURLsInToolTips(false) 157 158 , m_showsToolTipOverTruncatedText(false) -
trunk/Source/WebCore/page/Settings.h
r102400 r102619 230 230 void setUsesPageCache(bool); 231 231 bool usesPageCache() const { return m_usesPageCache; } 232 233 void setPageCacheSupportsPlugins(bool pageCacheSupportsPlugins) { m_pageCacheSupportsPlugins = pageCacheSupportsPlugins; } 234 bool pageCacheSupportsPlugins() const { return m_pageCacheSupportsPlugins; } 232 235 233 236 void setShrinksStandaloneImagesToFit(bool); … … 562 565 bool m_isDOMPasteAllowed : 1; 563 566 bool m_shrinksStandaloneImagesToFit : 1; 564 bool m_usesPageCache: 1; 567 bool m_usesPageCache : 1; 568 bool m_pageCacheSupportsPlugins : 1; 565 569 bool m_showsURLsInToolTips : 1; 566 570 bool m_showsToolTipOverTruncatedText : 1; -
trunk/Source/WebKit/mac/ChangeLog
r102605 r102619 1 2011-12-12 Brady Eidson <beidson@apple.com> 2 3 Page cache should support pages with plugins. 4 <rdar://problem/5190122> and https://bugs.webkit.org/show_bug.cgi?id=13634 5 6 Expose a WebKit preference for the page cache supporting plugins (on by default). 7 8 Reviewed by Anders Carlsson. 9 10 * WebView/WebPreferenceKeysPrivate.h: 11 12 * WebView/WebPreferences.mm: 13 (-[WebPreferences pageCacheSupportsPlugins]): 14 (-[WebPreferences setPageCacheSupportsPlugins:]): 15 * WebView/WebPreferencesPrivate.h: 16 17 * WebView/WebView.mm: 18 (-[WebView _preferencesChanged:]): 19 1 20 2011-12-12 Dan Bernstein <mitz@apple.com> 2 21 -
trunk/Source/WebKit/mac/WebView/WebPreferenceKeysPrivate.h
r101977 r102619 76 76 #define WebKitDOMPasteAllowedPreferenceKey @"WebKitDOMPasteAllowedPreferenceKey" 77 77 #define WebKitUsesPageCachePreferenceKey @"WebKitUsesPageCachePreferenceKey" 78 #define WebKitPageCacheSupportsPluginsPreferenceKey @"WebKitPageCacheSupportsPluginsPreferenceKey" 78 79 #define WebKitFTPDirectoryTemplatePath @"WebKitFTPDirectoryTemplatePath" 79 80 #define WebKitForceFTPDirectoryListings @"WebKitForceFTPDirectoryListings" -
trunk/Source/WebKit/mac/WebView/WebPreferences.mm
r101977 r102619 1558 1558 } 1559 1559 1560 - (BOOL)pageCacheSupportsPlugins 1561 { 1562 return [self _boolValueForKey:WebKitPageCacheSupportsPluginsPreferenceKey]; 1563 } 1564 1565 - (void)setPageCacheSupportsPlugins:(BOOL)flag 1566 { 1567 [self _setBoolValue:flag forKey:WebKitPageCacheSupportsPluginsPreferenceKey]; 1568 1569 } 1570 1560 1571 - (void)setSuppressIncrementalRendering:(BOOL)flag 1561 1572 { -
trunk/Source/WebKit/mac/WebView/WebPreferencesPrivate.h
r101977 r102619 220 220 - (void)setPictographFontFamily:(NSString *)family; 221 221 222 - (BOOL)pageCacheSupportsPlugins; 223 - (void)setPageCacheSupportsPlugins:(BOOL)flag; 224 222 225 // This is a global setting. 223 226 - (BOOL)mockScrollbarsEnabled; -
trunk/Source/WebKit/mac/WebView/WebView.mm
r102605 r102619 1430 1430 settings->setDOMPasteAllowed([preferences isDOMPasteAllowed]); 1431 1431 settings->setUsesPageCache([self usesPageCache]); 1432 settings->setPageCacheSupportsPlugins([preferences pageCacheSupportsPlugins]); 1432 1433 settings->setShowsURLsInToolTips([preferences showsURLsInToolTips]); 1433 1434 settings->setShowsToolTipOverTruncatedText([preferences showsToolTipOverTruncatedText]); -
trunk/Source/WebKit2/ChangeLog
r102616 r102619 1 2011-12-12 Brady Eidson <beidson@apple.com> 2 3 Page cache should support pages with plugins. 4 <rdar://problem/5190122> and https://bugs.webkit.org/show_bug.cgi?id=13634 5 6 Expose a WebKit2 preference for the page cache supporting plugins (on by default). 7 8 Reviewed by Anders Carlsson. 9 10 * Shared/WebPreferencesStore.h: 11 12 * UIProcess/API/C/WKPreferences.cpp: 13 (WKPreferencesSetPageCacheSupportsPlugins): 14 (WKPreferencesGetPageCacheSupportsPlugins): 15 * UIProcess/API/C/WKPreferencesPrivate.h: 16 17 * WebProcess/WebPage/WebPage.cpp: 18 (WebKit::WebPage::updatePreferences): 19 1 20 2011-12-12 Sam Weinig <sam@webkit.org> 2 21 -
trunk/Source/WebKit2/Shared/WebPreferencesStore.h
r101977 r102619 78 78 macro(LocalFileContentSniffingEnabled, localFileContentSniffingEnabled, Bool, bool, false) \ 79 79 macro(UsesPageCache, usesPageCache, Bool, bool, true) \ 80 macro(PageCacheSupportsPlugins, pageCacheSupportsPlugins, Bool, bool, true) \ 80 81 macro(AuthorAndUserStylesEnabled, authorAndUserStylesEnabled, Bool, bool, true) \ 81 82 macro(PaginateDuringLayoutEnabled, paginateDuringLayoutEnabled, Bool, bool, false) \ -
trunk/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp
r101977 r102619 493 493 } 494 494 495 void WKPreferencesSetPageCacheSupportsPlugins(WKPreferencesRef preferencesRef, bool pageCacheSupportsPlugins) 496 { 497 toImpl(preferencesRef)->setPageCacheSupportsPlugins(pageCacheSupportsPlugins); 498 } 499 500 bool WKPreferencesGetPageCacheSupportsPlugins(WKPreferencesRef preferencesRef) 501 { 502 return toImpl(preferencesRef)->pageCacheSupportsPlugins(); 503 } 504 495 505 void WKPreferencesSetPaginateDuringLayoutEnabled(WKPreferencesRef preferencesRef, bool enabled) 496 506 { -
trunk/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h
r96619 r102619 109 109 WK_EXPORT bool WKPreferencesGetPageCacheEnabled(WKPreferencesRef preferences); 110 110 111 // Defaults to true. 112 WK_EXPORT void WKPreferencesSetPageCacheSupportsPlugins(WKPreferencesRef preferences, bool pageCacheSupportsPlugins); 113 WK_EXPORT bool WKPreferencesGetPageCacheSupportsPlugins(WKPreferencesRef preferences); 114 111 115 // Defaults to false. 112 116 WK_EXPORT void WKPreferencesSetPaginateDuringLayoutEnabled(WKPreferencesRef preferences, bool enabled); -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
r102352 r102619 1793 1793 settings->setLocalFileContentSniffingEnabled(store.getBoolValueForKey(WebPreferencesKey::localFileContentSniffingEnabledKey())); 1794 1794 settings->setUsesPageCache(store.getBoolValueForKey(WebPreferencesKey::usesPageCacheKey())); 1795 settings->setPageCacheSupportsPlugins(store.getBoolValueForKey(WebPreferencesKey::pageCacheSupportsPluginsKey())); 1795 1796 settings->setAuthorAndUserStylesEnabled(store.getBoolValueForKey(WebPreferencesKey::authorAndUserStylesEnabledKey())); 1796 1797 settings->setPaginateDuringLayoutEnabled(store.getBoolValueForKey(WebPreferencesKey::paginateDuringLayoutEnabledKey()));
Note: See TracChangeset
for help on using the changeset viewer.