Changeset 144577 in webkit


Ignore:
Timestamp:
Mar 3, 2013, 11:36:33 AM (12 years ago)
Author:
dino@apple.com
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.

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r144575 r144577  
     12013-03-03  Dean Jackson  <dino@apple.com>
     2
     3        Plug-ins that are appropriately large w.r.t page size should autostart
     4        https://bugs.webkit.org/show_bug.cgi?id=111242
     5
     6        Reviewed by Brady Eidson.
     7
     8        A "full-page" plug-in site should never snapshot. The trick is
     9        how to determine what is full-page. This change implements the
     10        following algorithm.
     11
     12        - The plug-in is in the main frame (not an iframe).
     13        - The plug-in is sized with width and height 100%.
     14        - The displayed area of the plug-in is more than 96% of the viewport area.
     15
     16        This is definitely not foolproof. For example, zombo.com has a slight
     17        border around its plug-in. As the window size gets smaller, the body margin
     18        takes up more than 5% of the width or height, and the plug-in doesn't pass
     19        the tests above.
     20
     21        * html/HTMLPlugInImageElement.cpp:
     22        (WebCore): New static constant: sizingFullPageThresholdPercentage
     23        (WebCore::HTMLPlugInImageElement::subframeLoaderWillCreatePlugIn): Implements
     24            the rules described above.
     25
    1262013-03-03  Ryosuke Niwa  <rniwa@webkit.org>
    227
  • trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp

    r144067 r144577  
    5858static const int sizingMediumWidthThreshold = 450;
    5959static const int sizingMediumHeightThreshold = 300;
     60static const float sizingFullPageAreaRatioThreshold = 0.96;
    6061
    6162// This delay should not exceed the snapshot delay in PluginView.cpp
     
    415416        return;
    416417
    417     if (document()->isPluginDocument() && document()->frame() == document()->page()->mainFrame()) {
     418    bool inMainFrame = document()->frame() == document()->page()->mainFrame();
     419
     420    if (document()->isPluginDocument() && inMainFrame) {
    418421        LOG(Plugins, "%p Plug-in document in main frame", this);
    419422        return;
     
    425428    }
    426429
    427     LayoutRect rect = toRenderEmbeddedObject(renderer())->contentBoxRect();
    428     int width = rect.width();
    429     int height = rect.height();
    430     if (width <= sizingTinyDimensionThreshold || height <= sizingTinyDimensionThreshold) {
    431         LOG(Plugins, "%p Plug-in is %dx%d, set to play", this, width, height);
     430    RenderBox* renderEmbeddedObject = toRenderBox(renderer());
     431    Length styleWidth = renderEmbeddedObject->style()->width();
     432    Length styleHeight = renderEmbeddedObject->style()->height();
     433    LayoutRect contentBoxRect = renderEmbeddedObject->contentBoxRect();
     434    int contentWidth = contentBoxRect.width();
     435    int contentHeight = contentBoxRect.height();
     436    int contentArea = contentWidth * contentHeight;
     437    IntSize visibleViewSize = document()->frame()->view()->visibleSize();
     438    int visibleArea = visibleViewSize.width() * visibleViewSize.height();
     439
     440    if (inMainFrame && styleWidth.isPercent() && (styleWidth.percent() == 100)
     441        && styleHeight.isPercent() && (styleHeight.percent() == 100)
     442        && (static_cast<float>(contentArea) / visibleArea > sizingFullPageAreaRatioThreshold)) {
     443        LOG(Plugins, "%p Plug-in is top level full page, set to play", this);
     444        return;
     445    }
     446
     447    if (contentWidth <= sizingTinyDimensionThreshold || contentHeight <= sizingTinyDimensionThreshold) {
     448        LOG(Plugins, "%p Plug-in is %dx%d, set to play", this, contentWidth, contentHeight);
    432449        return;
    433450    }
     
    447464    }
    448465
    449     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);
     466    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);
    450467    // We may have got to this point by restarting a snapshotted plug-in, in which case we don't want to
    451468    // reset the display state.
Note: See TracChangeset for help on using the changeset viewer.