Changeset 148547 in webkit


Ignore:
Timestamp:
Apr 16, 2013 3:01:38 PM (11 years ago)
Author:
dino@apple.com
Message:

PlugIns that resize in user gestures should be immune to snapshotting
https://bugs.webkit.org/show_bug.cgi?id=114697
<rdar://problem/13666258>

Reviewed by Tim Horton.

Now that we snapshot plugins if they resize above the snapshotting threshold,
we need to make sure that we don't do it in response to a user gesture
such as a click.

Due to the complexities of real-world content and the way they often do
things using timeout, I copied the code from the generic user gesture
timeout, which gives a 5 second grace period after clicks.

  • html/HTMLPlugInImageElement.cpp:

(WebCore::documentHadRecentUserGesture): New static function to share the code for

checking the time since the last click (or whatever).

(WebCore::HTMLPlugInImageElement::checkSizeChangeForSnapshotting): Make sure

to test for a user gesture.

(WebCore::HTMLPlugInImageElement::subframeLoaderWillCreatePlugIn): Move the

code into the new function.

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r148545 r148547  
     12013-04-16  Dean Jackson  <dino@apple.com>
     2
     3        PlugIns that resize in user gestures should be immune to snapshotting
     4        https://bugs.webkit.org/show_bug.cgi?id=114697
     5        <rdar://problem/13666258>
     6
     7        Reviewed by Tim Horton.
     8
     9        Now that we snapshot plugins if they resize above the snapshotting threshold,
     10        we need to make sure that we don't do it in response to a user gesture
     11        such as a click.
     12
     13        Due to the complexities of real-world content and the way they often do
     14        things using timeout, I copied the code from the generic user gesture
     15        timeout, which gives a 5 second grace period after clicks.
     16
     17        * html/HTMLPlugInImageElement.cpp:
     18        (WebCore::documentHadRecentUserGesture): New static function to share the code for
     19            checking the time since the last click (or whatever).
     20        (WebCore::HTMLPlugInImageElement::checkSizeChangeForSnapshotting): Make sure
     21            to test for a user gesture.
     22        (WebCore::HTMLPlugInImageElement::subframeLoaderWillCreatePlugIn): Move the
     23            code into the new function.
     24
    1252013-04-15  Sam Weinig  <sam@webkit.org>
    226
  • trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp

    r148487 r148547  
    539539}
    540540
     541static bool documentHadRecentUserGesture(Document* document)
     542{
     543    double lastKnownUserGestureTimestamp = document->lastHandledUserGestureTimestamp();
     544
     545    if (document->frame() != document->page()->mainFrame() && document->page()->mainFrame() && document->page()->mainFrame()->document())
     546        lastKnownUserGestureTimestamp = std::max(lastKnownUserGestureTimestamp, document->page()->mainFrame()->document()->lastHandledUserGestureTimestamp());
     547
     548    if (currentTime() - lastKnownUserGestureTimestamp < autostartSoonAfterUserGestureThreshold)
     549        return true;
     550
     551    return false;
     552}
     553
    541554void HTMLPlugInImageElement::checkSizeChangeForSnapshotting()
    542555{
    543     if (!m_needsCheckForSizeChange || m_snapshotDecision != MaySnapshotWhenResized)
     556    if (!m_needsCheckForSizeChange || m_snapshotDecision != MaySnapshotWhenResized || documentHadRecentUserGesture(document()))
    544557        return;
    545558
     
    610623    }
    611624
    612     double lastKnownUserGestureTimestamp = document()->lastHandledUserGestureTimestamp();
    613     if (!inMainFrame && document()->page()->mainFrame() && document()->page()->mainFrame()->document())
    614         lastKnownUserGestureTimestamp = std::max(lastKnownUserGestureTimestamp, document()->page()->mainFrame()->document()->lastHandledUserGestureTimestamp());
    615     if (currentTime() - lastKnownUserGestureTimestamp < autostartSoonAfterUserGestureThreshold) {
     625    if (documentHadRecentUserGesture(document())) {
    616626        LOG(Plugins, "%p Plug-in was created shortly after a user gesture, set to play", this);
    617627        m_snapshotDecision = NeverSnapshot;
Note: See TracChangeset for help on using the changeset viewer.