Title: [102619] trunk
Revision
102619
Author
[email protected]
Date
2011-12-12 14:00:31 -0800 (Mon, 12 Dec 2011)

Log Message

Page cache should support pages with plugins.
<rdar://problem/5190122> and https://bugs.webkit.org/show_bug.cgi?id=13634

Source/WebCore: 

Reviewed by Anders Carlsson.

By making plugin elements renderers go display:none when entering the page cache,
we destroy the plug-in in a cross platform way as well as handle invalidating script
objects created by that plugin.

By restoring the original style when leaving the page cache and forcing a style recalc
on the plugin element, the plugin is gracefully reinstantiated when the user goes back.

Test: plugins/netscape-plugin-page-cache-works.html

* dom/Document.cpp:
(WebCore::Document::documentDidBecomeActive): Copy this collection before iterating over
  it, as the callbacks might result in mutating the set.

* dom/Node.h:
(WebCore::Node::setHasCustomStyleForRenderer):
(WebCore::Node::clearHasCustomStyleForRenderer): Expose the ability to stop using a 
  custom renderer and go back to the default renderer.

* history/CachedFrame.cpp:
(WebCore::CachedFrame::CachedFrame): Move the document inactivation call to the same place
  we suspend active DOM objects. It is important this call be *after* the beforeunload event
  is dispatched, and was coincidental non of the elements that using Document activation
  had run in to this problem yet.

* history/PageCache.cpp:
(WebCore::logCanCacheFrameDecision):
(WebCore::PageCache::canCachePageContainingThisFrame): If the page contains plugins but
  the PageCacheSupportsPlugins setting is true, allow this page.

Kill and recreate the plugin by listening for Document activation callbacks and setting a custom
display:none render style:
* html/HTMLPlugInImageElement.cpp:
(WebCore::HTMLPlugInImageElement::HTMLPlugInImageElement):
(WebCore::HTMLPlugInImageElement::~HTMLPlugInImageElement): Unregister for document activation
  callbacks.
(WebCore::HTMLPlugInImageElement::createRenderer): Once a renderer (ie. plugin instance) is
  created, this element needs Document (in)activation callbacks.
(WebCore::HTMLPlugInImageElement::willMoveToNewOwnerDocument): Manage Document activation 
  callback registration.
(WebCore::HTMLPlugInImageElement::didMoveToNewOwnerDocument): Ditto.
(WebCore::HTMLPlugInImageElement::documentWillBecomeInactive): Clone the element's current style
  and set the clone's display value to None. Start using this custom style and force a style
  recall. This destroys the renderer and therefore the plugin instance.
(WebCore::HTMLPlugInImageElement::documentDidBecomeActive): Stop using the custom style and
  force a style recall to reinstantiate the plugin.
(WebCore::HTMLPlugInImageElement::customStyleForRenderer): Return the stand-in style that has
  display:none set.
* html/HTMLPlugInImageElement.h:

Add a setting that allows runtime configuration of whether or not the page cache supports plugins:
* page/Settings.cpp:
(WebCore::Settings::Settings):
* page/Settings.h:
(WebCore::Settings::setPageCacheSupportsPlugins):
(WebCore::Settings::pageCacheSupportsPlugins):

Source/WebKit/mac: 

Expose a WebKit preference for the page cache supporting plugins (on by default).

Reviewed by Anders Carlsson.

* WebView/WebPreferenceKeysPrivate.h:

* WebView/WebPreferences.mm:
(-[WebPreferences pageCacheSupportsPlugins]):
(-[WebPreferences setPageCacheSupportsPlugins:]):
* WebView/WebPreferencesPrivate.h:

* WebView/WebView.mm:
(-[WebView _preferencesChanged:]):

Source/WebKit2: 

Expose a WebKit2 preference for the page cache supporting plugins (on by default).

Reviewed by Anders Carlsson.

* Shared/WebPreferencesStore.h:

* UIProcess/API/C/WKPreferences.cpp:
(WKPreferencesSetPageCacheSupportsPlugins):
(WKPreferencesGetPageCacheSupportsPlugins):
* UIProcess/API/C/WKPreferencesPrivate.h:

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updatePreferences):

LayoutTests: 

Reviewed by Anders Carlsson.

* plugins/netscape-plugin-page-cache-works-expected.txt: Added.
* plugins/netscape-plugin-page-cache-works.html: Added.
* plugins/resources/go-back.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (102618 => 102619)


--- trunk/LayoutTests/ChangeLog	2011-12-12 21:56:31 UTC (rev 102618)
+++ trunk/LayoutTests/ChangeLog	2011-12-12 22:00:31 UTC (rev 102619)
@@ -1,3 +1,14 @@
+2011-12-12  Brady Eidson  <[email protected]>
+
+        Page cache should support pages with plugins.
+        <rdar://problem/5190122> and https://bugs.webkit.org/show_bug.cgi?id=13634
+
+        Reviewed by Anders Carlsson.
+
+        * plugins/netscape-plugin-page-cache-works-expected.txt: Added.
+        * plugins/netscape-plugin-page-cache-works.html: Added.
+        * plugins/resources/go-back.html: Added.
+
 2011-12-12  James Robinson  <[email protected]>
 
         Rename webkitCancelRequestAnimationFrame to webkitCancelAnimationFrame to match spec change

Added: trunk/LayoutTests/plugins/netscape-plugin-page-cache-works-expected.txt (0 => 102619)


--- trunk/LayoutTests/plugins/netscape-plugin-page-cache-works-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/plugins/netscape-plugin-page-cache-works-expected.txt	2011-12-12 22:00:31 UTC (rev 102619)
@@ -0,0 +1,22 @@
+This tests that pages with plugins behave properly with the page cache. This includes:
+-The plugin being destroyed upon navigation away from the page.
+-The plugin being recreated upon restoring the page from the page cache.
+-Plugin script objects accessed the first time the plugin was created are appropriately invalidated after the page has been restored from the page cache.
+
+Unfortunately there is no reliable way to get affirmative confirmation that the plugin was destroyed upon navigation away from the page. For now we'll assume recreation means it had successfully been destroyed.
+
+Initial load: Page loaded
+Initial load: Page shown
+Initial load: Plugin created
+Initial load: Accessing testObject.property
+Initial load: Accessed testObject.property without exception
+Initial load: Assigning to testObject.property
+Initial load: Assigned to testObject.property without exception
+Initial load: Page hidden
+Restored from page cache: Page shown
+Restored from page cache: Plugin created
+Restored from page cache: Accessing testObject.property
+Restored from page cache: While accessing testObject.property: ReferenceError: Trying to access object from destroyed plug-in.
+Restored from page cache: Assigning to testObject.property
+Restored from page cache: While assigning to testObject.property: ReferenceError: Trying to access object from destroyed plug-in.
+

Added: trunk/LayoutTests/plugins/netscape-plugin-page-cache-works.html (0 => 102619)


--- trunk/LayoutTests/plugins/netscape-plugin-page-cache-works.html	                        (rev 0)
+++ trunk/LayoutTests/plugins/netscape-plugin-page-cache-works.html	2011-12-12 22:00:31 UTC (rev 102619)
@@ -0,0 +1,83 @@
+<html>
+<script>
+if (window.layoutTestController) {
+    layoutTestController.dumpAsText();
+    layoutTestController.waitUntilDone();
+    layoutTestController.overridePreference("WebKitUsesPageCachePreferenceKey", 1);
+    layoutTestController.overridePreference("WebKitPageCacheSupportsPluginsPreferenceKey", 1);
+}
+
+var savedTestObject = null;
+var currentTestStage = null;
+var hasHidden = false;
+
+function runTest()
+{
+    var plugin = document.getElementById("testPlugin");
+    
+    if (!savedTestObject)
+        savedTestObject = plugin.testObject;
+
+    try {
+        log("Accessing testObject.property");
+        savedTestObject.property;
+        log("Accessed testObject.property without exception");
+    } catch (e) {
+        log("While accessing testObject.property: " + e);
+    }
+
+    try {
+        log("Assigning to testObject.property");
+        savedTestObject.property = 'hello';
+        log("Assigned to testObject.property without exception");
+    } catch (e) {
+        log("While assigning to testObject.property: " + e);
+    }
+    
+    if (!hasHidden)
+        setTimeout("window.location.href = ''", 0);
+    else {
+        if (window.layoutTestController)
+            layoutTestController.notifyDone();
+    }
+    
+}
+
+function loaded() {
+    currentTestStage = "Initial load";
+    log("Page loaded");
+}
+
+function hidden() {
+    log("Page hidden");
+    hasHidden = true;
+}
+
+function shown() {
+    if (hasHidden)
+        currentTestStage = "Restored from page cache"
+    log("Page shown");
+}
+
+function pluginCreated()
+{
+    log("Plugin created");
+    setTimeout("runTest()", 0);
+}
+
+function log(message)
+{
+   document.getElementById("logging").innerHTML += currentTestStage + ": " + message + "<br>";
+}
+</script>
+
+<body _onload_="loaded()" _onpagehide_="hidden();" _onpageshow_="shown();">
+This tests that pages with plugins behave properly with the page cache.  This includes:<br>
+-The plugin being destroyed upon navigation away from the page.<br>
+-The plugin being recreated upon restoring the page from the page cache.<br>
+-Plugin script objects accessed the first time the plugin was created are appropriately invalidated after the page has been restored from the page cache.<br><br>
+Unfortunately there is no reliable way to get affirmative confirmation that the plugin was destroyed upon navigation away from the page.  For now we'll assume recreation means it had successfully been destroyed.<br>
+<embed id="testPlugin" type="application/x-webkit-test-netscape" width="200" height="200" _onNew_="pluginCreated()"></embed><br>
+<div id="logging"></div>
+</body>
+</html>

Added: trunk/LayoutTests/plugins/resources/go-back.html (0 => 102619)


--- trunk/LayoutTests/plugins/resources/go-back.html	                        (rev 0)
+++ trunk/LayoutTests/plugins/resources/go-back.html	2011-12-12 22:00:31 UTC (rev 102619)
@@ -0,0 +1,14 @@
+<script>
+function loaded()
+{
+    setTimeout("history.go(-1)", 0);
+}
+</script>
+<body _onload_="loaded();">This page should go back to the previous page.</body>
+<script>
+if (history.length == 0) {
+    document.innerHTML += "<br> But it won't work because there is no back history!";
+    if (window.layoutTestController)
+        layoutTestController.notifyDone();
+}
+</script>

Modified: trunk/Source/WebCore/ChangeLog (102618 => 102619)


--- trunk/Source/WebCore/ChangeLog	2011-12-12 21:56:31 UTC (rev 102618)
+++ trunk/Source/WebCore/ChangeLog	2011-12-12 22:00:31 UTC (rev 102619)
@@ -1,3 +1,66 @@
+2011-12-12  Brady Eidson  <[email protected]>
+
+        Page cache should support pages with plugins.
+        <rdar://problem/5190122> and https://bugs.webkit.org/show_bug.cgi?id=13634
+
+        Reviewed by Anders Carlsson.
+
+        By making plugin elements renderers go display:none when entering the page cache,
+        we destroy the plug-in in a cross platform way as well as handle invalidating script
+        objects created by that plugin.
+
+        By restoring the original style when leaving the page cache and forcing a style recalc
+        on the plugin element, the plugin is gracefully reinstantiated when the user goes back.
+
+        Test: plugins/netscape-plugin-page-cache-works.html
+
+        * dom/Document.cpp:
+        (WebCore::Document::documentDidBecomeActive): Copy this collection before iterating over
+          it, as the callbacks might result in mutating the set.
+
+        * dom/Node.h:
+        (WebCore::Node::setHasCustomStyleForRenderer):
+        (WebCore::Node::clearHasCustomStyleForRenderer): Expose the ability to stop using a 
+          custom renderer and go back to the default renderer.
+
+        * history/CachedFrame.cpp:
+        (WebCore::CachedFrame::CachedFrame): Move the document inactivation call to the same place
+          we suspend active DOM objects. It is important this call be *after* the beforeunload event
+          is dispatched, and was coincidental non of the elements that using Document activation
+          had run in to this problem yet.
+
+        * history/PageCache.cpp:
+        (WebCore::logCanCacheFrameDecision):
+        (WebCore::PageCache::canCachePageContainingThisFrame): If the page contains plugins but
+          the PageCacheSupportsPlugins setting is true, allow this page.
+
+        Kill and recreate the plugin by listening for Document activation callbacks and setting a custom
+        display:none render style:
+        * html/HTMLPlugInImageElement.cpp:
+        (WebCore::HTMLPlugInImageElement::HTMLPlugInImageElement):
+        (WebCore::HTMLPlugInImageElement::~HTMLPlugInImageElement): Unregister for document activation
+          callbacks.
+        (WebCore::HTMLPlugInImageElement::createRenderer): Once a renderer (ie. plugin instance) is
+          created, this element needs Document (in)activation callbacks.
+        (WebCore::HTMLPlugInImageElement::willMoveToNewOwnerDocument): Manage Document activation 
+          callback registration.
+        (WebCore::HTMLPlugInImageElement::didMoveToNewOwnerDocument): Ditto.
+        (WebCore::HTMLPlugInImageElement::documentWillBecomeInactive): Clone the element's current style
+          and set the clone's display value to None. Start using this custom style and force a style
+          recall. This destroys the renderer and therefore the plugin instance.
+        (WebCore::HTMLPlugInImageElement::documentDidBecomeActive): Stop using the custom style and
+          force a style recall to reinstantiate the plugin.
+        (WebCore::HTMLPlugInImageElement::customStyleForRenderer): Return the stand-in style that has
+          display:none set.
+        * html/HTMLPlugInImageElement.h:
+
+        Add a setting that allows runtime configuration of whether or not the page cache supports plugins:
+        * page/Settings.cpp:
+        (WebCore::Settings::Settings):
+        * page/Settings.h:
+        (WebCore::Settings::setPageCacheSupportsPlugins):
+        (WebCore::Settings::pageCacheSupportsPlugins):
+
 2011-12-12  Ojan Vafai  <[email protected]>
 
         r102234 caused RuleData to use 33 bits in its bitmask

Modified: trunk/Source/WebCore/dom/Document.cpp (102618 => 102619)


--- trunk/Source/WebCore/dom/Document.cpp	2011-12-12 21:56:31 UTC (rev 102618)
+++ trunk/Source/WebCore/dom/Document.cpp	2011-12-12 22:00:31 UTC (rev 102619)
@@ -3940,8 +3940,10 @@
 
 void Document::documentDidBecomeActive() 
 {
-    HashSet<Element*>::iterator end = m_documentActivationCallbackElements.end();
-    for (HashSet<Element*>::iterator i = m_documentActivationCallbackElements.begin(); i != end; ++i)
+    Vector<Element*> elements;
+    copyToVector(m_documentActivationCallbackElements, elements);
+    Vector<Element*>::iterator end = elements.end();
+    for (Vector<Element*>::iterator i = elements.begin(); i != end; ++i)
         (*i)->documentDidBecomeActive();
 
 #if USE(ACCELERATED_COMPOSITING)

Modified: trunk/Source/WebCore/dom/Node.h (102618 => 102619)


--- trunk/Source/WebCore/dom/Node.h	2011-12-12 21:56:31 UTC (rev 102618)
+++ trunk/Source/WebCore/dom/Node.h	2011-12-12 22:00:31 UTC (rev 102619)
@@ -691,7 +691,8 @@
     void setHasCustomWillOrDidRecalcStyle() { setFlag(true, HasCustomWillOrDidRecalcStyleFlag); }
     
     bool hasCustomStyleForRenderer() const { return getFlag(HasCustomStyleForRendererFlag); }
-    void setHasCustomStyleForRenderer() { setFlag(true, HasCustomStyleForRendererFlag); } 
+    void setHasCustomStyleForRenderer() { setFlag(true, HasCustomStyleForRendererFlag); }
+    void clearHasCustomStyleForRenderer() { clearFlag(HasCustomStyleForRendererFlag); }
 
 private:
     // Do not use this method to change the document of a node until after the node has been

Modified: trunk/Source/WebCore/history/CachedFrame.cpp (102618 => 102619)


--- trunk/Source/WebCore/history/CachedFrame.cpp	2011-12-12 21:56:31 UTC (rev 102618)
+++ trunk/Source/WebCore/history/CachedFrame.cpp	2011-12-12 22:00:31 UTC (rev 102619)
@@ -156,7 +156,6 @@
     // Custom scrollbar renderers will get reattached when the document comes out of the page cache
     m_view->detachCustomScrollbars();
 
-    m_document->documentWillBecomeInactive();
     frame->clearTimers();
     m_document->setInPageCache(true);
     frame->loader()->stopLoading(UnloadEventPolicyUnloadAndPageHide);
@@ -170,6 +169,7 @@
     // Suspending must also happen after we've recursed over child frames, in case
     // those create more objects.
     // FIXME: It's still possible to have objects created after suspending in some cases, see http://webkit.org/b/53733 for more details.
+    m_document->documentWillBecomeInactive();
     m_document->suspendScriptedAnimationControllerCallbacks();
     m_document->suspendActiveDOMObjects(ActiveDOMObject::DocumentWillBecomeInactive);
     m_cachedFrameScriptData = adoptPtr(new ScriptCachedFrameData(frame));

Modified: trunk/Source/WebCore/history/PageCache.cpp (102618 => 102619)


--- trunk/Source/WebCore/history/PageCache.cpp	2011-12-12 21:56:31 UTC (rev 102618)
+++ trunk/Source/WebCore/history/PageCache.cpp	2011-12-12 22:00:31 UTC (rev 102619)
@@ -107,7 +107,7 @@
             PCLOG("   -Main document has an error");
             cannotCache = true;
         }
-        if (frame->loader()->subframeLoader()->containsPlugins()) {
+        if (frame->loader()->subframeLoader()->containsPlugins() && !frame->page()->settings()->pageCacheSupportsPlugins()) {
             PCLOG("   -Frame contains plugins");
             cannotCache = true;
         }
@@ -255,12 +255,7 @@
         && frame->loader()->documentLoader()->mainDocumentError().isNull()
         // Do not cache error pages (these can be recognized as pages with substitute data or unreachable URLs).
         && !(frame->loader()->documentLoader()->substituteData().isValid() && !frame->loader()->documentLoader()->substituteData().failingURL().isEmpty())
-        // FIXME: If we ever change this so that frames with plug-ins will be cached,
-        // we need to make sure that we don't cache frames that have outstanding NPObjects
-        // (objects created by the plug-in). Since there is no way to pause/resume a Netscape plug-in,
-        // they would need to be destroyed and then recreated, and there is no way that we can recreate
-        // the right NPObjects. See <rdar://problem/5197041> for more information.
-        && !frame->loader()->subframeLoader()->containsPlugins()
+        && (!frame->loader()->subframeLoader()->containsPlugins() || frame->page()->settings()->pageCacheSupportsPlugins())
         && !frame->document()->url().protocolIs("https")
         && (!frame->domWindow() || !frame->domWindow()->hasEventListeners(eventNames().unloadEvent))
 #if ENABLE(SQL_DATABASE)

Modified: trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp (102618 => 102619)


--- trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp	2011-12-12 21:56:31 UTC (rev 102618)
+++ trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp	2011-12-12 22:00:31 UTC (rev 102619)
@@ -27,6 +27,7 @@
 #include "HTMLImageLoader.h"
 #include "HTMLNames.h"
 #include "Image.h"
+#include "NodeRenderStyle.h"
 #include "Page.h"
 #include "RenderEmbeddedObject.h"
 #include "RenderImage.h"
@@ -42,10 +43,17 @@
     // the same codepath in this class.
     , m_needsWidgetUpdate(!createdByParser)
     , m_shouldPreferPlugInsForImages(preferPlugInsForImagesOption == ShouldPreferPlugInsForImages)
+    , m_needsDocumentActivationCallbacks(false)
 {
     setHasCustomWillOrDidRecalcStyle();
 }
 
+HTMLPlugInImageElement::~HTMLPlugInImageElement()
+{
+    if (m_needsDocumentActivationCallbacks)
+        document()->unregisterForDocumentActivationCallbacks(this);
+}
+
 RenderEmbeddedObject* HTMLPlugInImageElement::renderEmbeddedObject() const
 {
     // HTMLObjectElement and HTMLEmbedElement may return arbitrary renderers
@@ -115,6 +123,13 @@
 
 RenderObject* HTMLPlugInImageElement::createRenderer(RenderArena* arena, RenderStyle* style)
 {
+    // Once a PlugIn Element creates its renderer, it needs to be told when the Document goes
+    // inactive or reactivates so it can clear the renderer before going into the page cache.
+    if (!m_needsDocumentActivationCallbacks) {
+        m_needsDocumentActivationCallbacks = true;
+        document()->registerForDocumentActivationCallbacks(this);
+    }
+    
     // Fallback content breaks the DOM->Renderer class relationship of this
     // class and all superclasses because createObject won't necessarily
     // return a RenderEmbeddedObject, RenderPart or even RenderWidget.
@@ -189,11 +204,58 @@
 
 void HTMLPlugInImageElement::willMoveToNewOwnerDocument()
 {
+    if (m_needsDocumentActivationCallbacks)
+        document()->unregisterForDocumentActivationCallbacks(this);
+
     if (m_imageLoader)
         m_imageLoader->elementWillMoveToNewOwnerDocument();
+
     HTMLPlugInElement::willMoveToNewOwnerDocument();
 }
 
+void HTMLPlugInImageElement::didMoveToNewOwnerDocument()
+{
+    if (m_needsDocumentActivationCallbacks)
+        document()->registerForDocumentActivationCallbacks(this);   
+    
+    HTMLPlugInElement::didMoveToNewOwnerDocument();
+}
+
+void HTMLPlugInImageElement::documentWillBecomeInactive()
+{
+    if (RenderStyle* rs = renderStyle()) {
+        m_customStyleForPageCache = RenderStyle::clone(rs);
+        m_customStyleForPageCache->setDisplay(NONE);
+    }
+
+    setHasCustomStyleForRenderer();
+
+    if (m_customStyleForPageCache)
+        recalcStyle(Force);
+        
+    HTMLPlugInElement::documentWillBecomeInactive();
+}
+
+void HTMLPlugInImageElement::documentDidBecomeActive()
+{
+    clearHasCustomStyleForRenderer();
+
+    if (m_customStyleForPageCache) {
+        m_customStyleForPageCache = 0;
+        recalcStyle(Force);
+    }
+    
+    HTMLPlugInElement::documentDidBecomeActive();
+}
+
+PassRefPtr<RenderStyle> HTMLPlugInImageElement::customStyleForRenderer()
+{
+    if (!m_customStyleForPageCache)
+        return renderStyle();
+
+    return m_customStyleForPageCache;
+}
+
 void HTMLPlugInImageElement::updateWidgetCallback(Node* n, unsigned)
 {
     static_cast<HTMLPlugInImageElement*>(n)->updateWidgetIfNecessary();

Modified: trunk/Source/WebCore/html/HTMLPlugInImageElement.h (102618 => 102619)


--- trunk/Source/WebCore/html/HTMLPlugInImageElement.h	2011-12-12 21:56:31 UTC (rev 102618)
+++ trunk/Source/WebCore/html/HTMLPlugInImageElement.h	2011-12-12 22:00:31 UTC (rev 102619)
@@ -22,6 +22,8 @@
 #define HTMLPlugInImageElement_h
 
 #include "HTMLPlugInElement.h"
+
+#include "RenderStyle.h"
 #include <wtf/OwnPtr.h>
 
 namespace WebCore {
@@ -42,6 +44,8 @@
 // Base class for HTMLObjectElement and HTMLEmbedElement
 class HTMLPlugInImageElement : public HTMLPlugInElement {
 public:
+    virtual ~HTMLPlugInImageElement() OVERRIDE;
+
     RenderEmbeddedObject* renderEmbeddedObject() const;
 
     virtual void updateWidget(PluginCreationOption) = 0;
@@ -69,8 +73,14 @@
     bool allowedToLoadFrameURL(const String& url);
     bool wouldLoadAsNetscapePlugin(const String& url, const String& serviceType);
 
-    virtual void willMoveToNewOwnerDocument();
+    virtual void willMoveToNewOwnerDocument() OVERRIDE;
+    virtual void didMoveToNewOwnerDocument() OVERRIDE;
+    
+    virtual void documentWillBecomeInactive() OVERRIDE;
+    virtual void documentDidBecomeActive() OVERRIDE;
 
+    virtual PassRefPtr<RenderStyle> customStyleForRenderer() OVERRIDE;
+
 private:
     virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
     virtual bool willRecalcStyle(StyleChange);
@@ -82,6 +92,8 @@
     
     bool m_needsWidgetUpdate;
     bool m_shouldPreferPlugInsForImages;
+    bool m_needsDocumentActivationCallbacks;
+    RefPtr<RenderStyle> m_customStyleForPageCache;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/page/Settings.cpp (102618 => 102619)


--- trunk/Source/WebCore/page/Settings.cpp	2011-12-12 21:56:31 UTC (rev 102618)
+++ trunk/Source/WebCore/page/Settings.cpp	2011-12-12 22:00:31 UTC (rev 102619)
@@ -153,6 +153,7 @@
     , m_isDOMPasteAllowed(false)
     , m_shrinksStandaloneImagesToFit(true)
     , m_usesPageCache(false)
+    , m_pageCacheSupportsPlugins(false)
     , m_showsURLsInToolTips(false)
     , m_showsToolTipOverTruncatedText(false)
     , m_forceFTPDirectoryListings(false)

Modified: trunk/Source/WebCore/page/Settings.h (102618 => 102619)


--- trunk/Source/WebCore/page/Settings.h	2011-12-12 21:56:31 UTC (rev 102618)
+++ trunk/Source/WebCore/page/Settings.h	2011-12-12 22:00:31 UTC (rev 102619)
@@ -229,6 +229,9 @@
 
         void setUsesPageCache(bool);
         bool usesPageCache() const { return m_usesPageCache; }
+        
+        void setPageCacheSupportsPlugins(bool pageCacheSupportsPlugins) { m_pageCacheSupportsPlugins = pageCacheSupportsPlugins; }
+        bool pageCacheSupportsPlugins() const { return m_pageCacheSupportsPlugins; }
 
         void setShrinksStandaloneImagesToFit(bool);
         bool shrinksStandaloneImagesToFit() const { return m_shrinksStandaloneImagesToFit; }
@@ -561,7 +564,8 @@
         bool m_needsLeopardMailQuirks : 1;
         bool m_isDOMPasteAllowed : 1;
         bool m_shrinksStandaloneImagesToFit : 1;
-        bool m_usesPageCache: 1;
+        bool m_usesPageCache : 1;
+        bool m_pageCacheSupportsPlugins : 1;
         bool m_showsURLsInToolTips : 1;
         bool m_showsToolTipOverTruncatedText : 1;
         bool m_forceFTPDirectoryListings : 1;

Modified: trunk/Source/WebKit/mac/ChangeLog (102618 => 102619)


--- trunk/Source/WebKit/mac/ChangeLog	2011-12-12 21:56:31 UTC (rev 102618)
+++ trunk/Source/WebKit/mac/ChangeLog	2011-12-12 22:00:31 UTC (rev 102619)
@@ -1,3 +1,22 @@
+2011-12-12  Brady Eidson  <[email protected]>
+
+        Page cache should support pages with plugins.
+        <rdar://problem/5190122> and https://bugs.webkit.org/show_bug.cgi?id=13634
+
+        Expose a WebKit preference for the page cache supporting plugins (on by default).
+
+        Reviewed by Anders Carlsson.
+
+        * WebView/WebPreferenceKeysPrivate.h:
+
+        * WebView/WebPreferences.mm:
+        (-[WebPreferences pageCacheSupportsPlugins]):
+        (-[WebPreferences setPageCacheSupportsPlugins:]):
+        * WebView/WebPreferencesPrivate.h:
+
+        * WebView/WebView.mm:
+        (-[WebView _preferencesChanged:]):
+
 2011-12-12  Dan Bernstein  <[email protected]>
 
         <rdar://problem/10328474> Text highlight changes to gray selection color when menu extra is shown

Modified: trunk/Source/WebKit/mac/WebView/WebPreferenceKeysPrivate.h (102618 => 102619)


--- trunk/Source/WebKit/mac/WebView/WebPreferenceKeysPrivate.h	2011-12-12 21:56:31 UTC (rev 102618)
+++ trunk/Source/WebKit/mac/WebView/WebPreferenceKeysPrivate.h	2011-12-12 22:00:31 UTC (rev 102619)
@@ -75,6 +75,7 @@
 #define WebAutomaticSpellingCorrectionEnabled @"WebAutomaticSpellingCorrectionEnabled"
 #define WebKitDOMPasteAllowedPreferenceKey @"WebKitDOMPasteAllowedPreferenceKey"
 #define WebKitUsesPageCachePreferenceKey @"WebKitUsesPageCachePreferenceKey"
+#define WebKitPageCacheSupportsPluginsPreferenceKey @"WebKitPageCacheSupportsPluginsPreferenceKey"
 #define WebKitFTPDirectoryTemplatePath @"WebKitFTPDirectoryTemplatePath"
 #define WebKitForceFTPDirectoryListings @"WebKitForceFTPDirectoryListings"
 #define WebKitDeveloperExtrasEnabledPreferenceKey @"WebKitDeveloperExtrasEnabledPreferenceKey"

Modified: trunk/Source/WebKit/mac/WebView/WebPreferences.mm (102618 => 102619)


--- trunk/Source/WebKit/mac/WebView/WebPreferences.mm	2011-12-12 21:56:31 UTC (rev 102618)
+++ trunk/Source/WebKit/mac/WebView/WebPreferences.mm	2011-12-12 22:00:31 UTC (rev 102619)
@@ -1557,6 +1557,17 @@
     [self _setStringValue: family forKey: WebKitPictographFontPreferenceKey];
 }
 
+- (BOOL)pageCacheSupportsPlugins
+{
+    return [self _boolValueForKey:WebKitPageCacheSupportsPluginsPreferenceKey];
+}
+
+- (void)setPageCacheSupportsPlugins:(BOOL)flag
+{
+    [self _setBoolValue:flag forKey:WebKitPageCacheSupportsPluginsPreferenceKey];
+
+}
+
 - (void)setSuppressIncrementalRendering:(BOOL)flag
 {
     [self _setBoolValue:flag forKey:WebKitSuppressIncrementalRenderingKey];

Modified: trunk/Source/WebKit/mac/WebView/WebPreferencesPrivate.h (102618 => 102619)


--- trunk/Source/WebKit/mac/WebView/WebPreferencesPrivate.h	2011-12-12 21:56:31 UTC (rev 102618)
+++ trunk/Source/WebKit/mac/WebView/WebPreferencesPrivate.h	2011-12-12 22:00:31 UTC (rev 102619)
@@ -219,6 +219,9 @@
 - (NSString *)pictographFontFamily;
 - (void)setPictographFontFamily:(NSString *)family;
 
+- (BOOL)pageCacheSupportsPlugins;
+- (void)setPageCacheSupportsPlugins:(BOOL)flag;
+
 // This is a global setting.
 - (BOOL)mockScrollbarsEnabled;
 - (void)setMockScrollbarsEnabled:(BOOL)flag;

Modified: trunk/Source/WebKit/mac/WebView/WebView.mm (102618 => 102619)


--- trunk/Source/WebKit/mac/WebView/WebView.mm	2011-12-12 21:56:31 UTC (rev 102618)
+++ trunk/Source/WebKit/mac/WebView/WebView.mm	2011-12-12 22:00:31 UTC (rev 102619)
@@ -1429,6 +1429,7 @@
     settings->setTextDirectionSubmenuInclusionBehavior(core([preferences textDirectionSubmenuInclusionBehavior]));
     settings->setDOMPasteAllowed([preferences isDOMPasteAllowed]);
     settings->setUsesPageCache([self usesPageCache]);
+    settings->setPageCacheSupportsPlugins([preferences pageCacheSupportsPlugins]);
     settings->setShowsURLsInToolTips([preferences showsURLsInToolTips]);
     settings->setShowsToolTipOverTruncatedText([preferences showsToolTipOverTruncatedText]);
     settings->setDeveloperExtrasEnabled([preferences developerExtrasEnabled]);

Modified: trunk/Source/WebKit2/ChangeLog (102618 => 102619)


--- trunk/Source/WebKit2/ChangeLog	2011-12-12 21:56:31 UTC (rev 102618)
+++ trunk/Source/WebKit2/ChangeLog	2011-12-12 22:00:31 UTC (rev 102619)
@@ -1,3 +1,22 @@
+2011-12-12  Brady Eidson  <[email protected]>
+
+        Page cache should support pages with plugins.
+        <rdar://problem/5190122> and https://bugs.webkit.org/show_bug.cgi?id=13634
+
+        Expose a WebKit2 preference for the page cache supporting plugins (on by default).
+
+        Reviewed by Anders Carlsson.
+
+        * Shared/WebPreferencesStore.h:
+
+        * UIProcess/API/C/WKPreferences.cpp:
+        (WKPreferencesSetPageCacheSupportsPlugins):
+        (WKPreferencesGetPageCacheSupportsPlugins):
+        * UIProcess/API/C/WKPreferencesPrivate.h:
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::updatePreferences):
+
 2011-12-12  Sam Weinig  <[email protected]>
 
         Add WKConnection objective-c wrapper around WKConnectionRef

Modified: trunk/Source/WebKit2/Shared/WebPreferencesStore.h (102618 => 102619)


--- trunk/Source/WebKit2/Shared/WebPreferencesStore.h	2011-12-12 21:56:31 UTC (rev 102618)
+++ trunk/Source/WebKit2/Shared/WebPreferencesStore.h	2011-12-12 22:00:31 UTC (rev 102619)
@@ -77,6 +77,7 @@
     macro(WebArchiveDebugModeEnabled, webArchiveDebugModeEnabled, Bool, bool, false) \
     macro(LocalFileContentSniffingEnabled, localFileContentSniffingEnabled, Bool, bool, false) \
     macro(UsesPageCache, usesPageCache, Bool, bool, true) \
+    macro(PageCacheSupportsPlugins, pageCacheSupportsPlugins, Bool, bool, true) \
     macro(AuthorAndUserStylesEnabled, authorAndUserStylesEnabled, Bool, bool, true) \
     macro(PaginateDuringLayoutEnabled, paginateDuringLayoutEnabled, Bool, bool, false) \
     macro(DOMPasteAllowed, domPasteAllowed, Bool, bool, false) \

Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp (102618 => 102619)


--- trunk/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp	2011-12-12 21:56:31 UTC (rev 102618)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp	2011-12-12 22:00:31 UTC (rev 102619)
@@ -492,6 +492,16 @@
     return toImpl(preferencesRef)->usesPageCache();
 }
 
+void WKPreferencesSetPageCacheSupportsPlugins(WKPreferencesRef preferencesRef, bool pageCacheSupportsPlugins)
+{
+    toImpl(preferencesRef)->setPageCacheSupportsPlugins(pageCacheSupportsPlugins);
+}
+
+bool WKPreferencesGetPageCacheSupportsPlugins(WKPreferencesRef preferencesRef)
+{
+    return toImpl(preferencesRef)->pageCacheSupportsPlugins();
+}
+
 void WKPreferencesSetPaginateDuringLayoutEnabled(WKPreferencesRef preferencesRef, bool enabled)
 {
     toImpl(preferencesRef)->setPaginateDuringLayoutEnabled(enabled);

Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h (102618 => 102619)


--- trunk/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h	2011-12-12 21:56:31 UTC (rev 102618)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h	2011-12-12 22:00:31 UTC (rev 102619)
@@ -108,6 +108,10 @@
 WK_EXPORT void WKPreferencesSetPageCacheEnabled(WKPreferencesRef preferences, bool enabled);
 WK_EXPORT bool WKPreferencesGetPageCacheEnabled(WKPreferencesRef preferences);
 
+// Defaults to true.
+WK_EXPORT void WKPreferencesSetPageCacheSupportsPlugins(WKPreferencesRef preferences, bool pageCacheSupportsPlugins);
+WK_EXPORT bool WKPreferencesGetPageCacheSupportsPlugins(WKPreferencesRef preferences);
+
 // Defaults to false.
 WK_EXPORT void WKPreferencesSetPaginateDuringLayoutEnabled(WKPreferencesRef preferences, bool enabled);
 WK_EXPORT bool WKPreferencesGetPaginateDuringLayoutEnabled(WKPreferencesRef preferences);

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (102618 => 102619)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2011-12-12 21:56:31 UTC (rev 102618)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2011-12-12 22:00:31 UTC (rev 102619)
@@ -1792,6 +1792,7 @@
 #endif
     settings->setLocalFileContentSniffingEnabled(store.getBoolValueForKey(WebPreferencesKey::localFileContentSniffingEnabledKey()));
     settings->setUsesPageCache(store.getBoolValueForKey(WebPreferencesKey::usesPageCacheKey()));
+    settings->setPageCacheSupportsPlugins(store.getBoolValueForKey(WebPreferencesKey::pageCacheSupportsPluginsKey()));
     settings->setAuthorAndUserStylesEnabled(store.getBoolValueForKey(WebPreferencesKey::authorAndUserStylesEnabledKey()));
     settings->setPaginateDuringLayoutEnabled(store.getBoolValueForKey(WebPreferencesKey::paginateDuringLayoutEnabledKey()));
     settings->setDOMPasteAllowed(store.getBoolValueForKey(WebPreferencesKey::domPasteAllowedKey()));
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to