Title: [144577] trunk/Source/WebCore
Revision
144577
Author
[email protected]
Date
2013-03-03 11:36:33 -0800 (Sun, 03 Mar 2013)

Log Message

Plug-ins that are appropriately large w.r.t page size should autostart
https://bugs.webkit.org/show_bug.cgi?id=111242

Reviewed by Brady Eidson.

A "full-page" plug-in site should never snapshot. The trick is
how to determine what is full-page. This change implements the
following algorithm.

- The plug-in is in the main frame (not an iframe).
- The plug-in is sized with width and height 100%.
- The displayed area of the plug-in is more than 96% of the viewport area.

This is definitely not foolproof. For example, zombo.com has a slight
border around its plug-in. As the window size gets smaller, the body margin
takes up more than 5% of the width or height, and the plug-in doesn't pass
the tests above.

* html/HTMLPlugInImageElement.cpp:
(WebCore): New static constant: sizingFullPageThresholdPercentage
(WebCore::HTMLPlugInImageElement::subframeLoaderWillCreatePlugIn): Implements
    the rules described above.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (144576 => 144577)


--- trunk/Source/WebCore/ChangeLog	2013-03-03 18:27:44 UTC (rev 144576)
+++ trunk/Source/WebCore/ChangeLog	2013-03-03 19:36:33 UTC (rev 144577)
@@ -1,3 +1,28 @@
+2013-03-03  Dean Jackson  <[email protected]>
+
+        Plug-ins that are appropriately large w.r.t page size should autostart
+        https://bugs.webkit.org/show_bug.cgi?id=111242
+
+        Reviewed by Brady Eidson.
+
+        A "full-page" plug-in site should never snapshot. The trick is
+        how to determine what is full-page. This change implements the
+        following algorithm.
+
+        - The plug-in is in the main frame (not an iframe).
+        - The plug-in is sized with width and height 100%.
+        - The displayed area of the plug-in is more than 96% of the viewport area.
+
+        This is definitely not foolproof. For example, zombo.com has a slight
+        border around its plug-in. As the window size gets smaller, the body margin
+        takes up more than 5% of the width or height, and the plug-in doesn't pass
+        the tests above.
+
+        * html/HTMLPlugInImageElement.cpp:
+        (WebCore): New static constant: sizingFullPageThresholdPercentage
+        (WebCore::HTMLPlugInImageElement::subframeLoaderWillCreatePlugIn): Implements
+            the rules described above.
+
 2013-03-03  Ryosuke Niwa  <[email protected]>
 
         [Win] IDLParser.pm fails to parse OESTextureHalfFloat and causes a build failure

Modified: trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp (144576 => 144577)


--- trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp	2013-03-03 18:27:44 UTC (rev 144576)
+++ trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp	2013-03-03 19:36:33 UTC (rev 144577)
@@ -57,6 +57,7 @@
 static const int sizingSmallWidthThreshold = 250;
 static const int sizingMediumWidthThreshold = 450;
 static const int sizingMediumHeightThreshold = 300;
+static const float sizingFullPageAreaRatioThreshold = 0.96;
 
 // This delay should not exceed the snapshot delay in PluginView.cpp
 static const double simulatedMouseClickTimerDelay = .75;
@@ -414,7 +415,9 @@
         || !document()->page()->settings()->plugInSnapshottingEnabled())
         return;
 
-    if (document()->isPluginDocument() && document()->frame() == document()->page()->mainFrame()) {
+    bool inMainFrame = document()->frame() == document()->page()->mainFrame();
+
+    if (document()->isPluginDocument() && inMainFrame) {
         LOG(Plugins, "%p Plug-in document in main frame", this);
         return;
     }
@@ -424,14 +427,28 @@
         return;
     }
 
-    LayoutRect rect = toRenderEmbeddedObject(renderer())->contentBoxRect();
-    int width = rect.width();
-    int height = rect.height();
-    if (width <= sizingTinyDimensionThreshold || height <= sizingTinyDimensionThreshold) {
-        LOG(Plugins, "%p Plug-in is %dx%d, set to play", this, width, height);
+    RenderBox* renderEmbeddedObject = toRenderBox(renderer());
+    Length styleWidth = renderEmbeddedObject->style()->width();
+    Length styleHeight = renderEmbeddedObject->style()->height();
+    LayoutRect contentBoxRect = renderEmbeddedObject->contentBoxRect();
+    int contentWidth = contentBoxRect.width();
+    int contentHeight = contentBoxRect.height();
+    int contentArea = contentWidth * contentHeight;
+    IntSize visibleViewSize = document()->frame()->view()->visibleSize();
+    int visibleArea = visibleViewSize.width() * visibleViewSize.height();
+
+    if (inMainFrame && styleWidth.isPercent() && (styleWidth.percent() == 100)
+        && styleHeight.isPercent() && (styleHeight.percent() == 100)
+        && (static_cast<float>(contentArea) / visibleArea > sizingFullPageAreaRatioThreshold)) {
+        LOG(Plugins, "%p Plug-in is top level full page, set to play", this);
         return;
     }
 
+    if (contentWidth <= sizingTinyDimensionThreshold || contentHeight <= sizingTinyDimensionThreshold) {
+        LOG(Plugins, "%p Plug-in is %dx%d, set to play", this, contentWidth, contentHeight);
+        return;
+    }
+
     if (!document()->page() || !document()->page()->plugInClient()) {
         setDisplayState(WaitingForSnapshot);
         return;
@@ -446,7 +463,7 @@
         return;
     }
 
-    LOG(Plugins, "%p Plug-in hash %x is %dx%d, origin is not auto-start, set to wait for snapshot", this, m_plugInOriginHash, width, height);
+    LOG(Plugins, "%p Plug-in hash %x is %dx%d, origin is not auto-start, set to wait for snapshot", this, m_plugInOriginHash, contentWidth, contentHeight);
     // We may have got to this point by restarting a snapshotted plug-in, in which case we don't want to
     // reset the display state.
     if (displayState() != PlayingWithPendingMouseClick)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to