Title: [148547] trunk/Source/WebCore
Revision
148547
Author
[email protected]
Date
2013-04-16 15:01:38 -0700 (Tue, 16 Apr 2013)

Log 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.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (148546 => 148547)


--- trunk/Source/WebCore/ChangeLog	2013-04-16 21:55:55 UTC (rev 148546)
+++ trunk/Source/WebCore/ChangeLog	2013-04-16 22:01:38 UTC (rev 148547)
@@ -1,3 +1,27 @@
+2013-04-16  Dean Jackson  <[email protected]>
+
+        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.
+
 2013-04-15  Sam Weinig  <[email protected]>
 
         Remove more #includes from Frame.h

Modified: trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp (148546 => 148547)


--- trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp	2013-04-16 21:55:55 UTC (rev 148546)
+++ trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp	2013-04-16 22:01:38 UTC (rev 148547)
@@ -538,9 +538,22 @@
     m_pendingClickEventFromSnapshot = nullptr;
 }
 
+static bool documentHadRecentUserGesture(Document* document)
+{
+    double lastKnownUserGestureTimestamp = document->lastHandledUserGestureTimestamp();
+
+    if (document->frame() != document->page()->mainFrame() && document->page()->mainFrame() && document->page()->mainFrame()->document())
+        lastKnownUserGestureTimestamp = std::max(lastKnownUserGestureTimestamp, document->page()->mainFrame()->document()->lastHandledUserGestureTimestamp());
+
+    if (currentTime() - lastKnownUserGestureTimestamp < autostartSoonAfterUserGestureThreshold)
+        return true;
+
+    return false;
+}
+
 void HTMLPlugInImageElement::checkSizeChangeForSnapshotting()
 {
-    if (!m_needsCheckForSizeChange || m_snapshotDecision != MaySnapshotWhenResized)
+    if (!m_needsCheckForSizeChange || m_snapshotDecision != MaySnapshotWhenResized || documentHadRecentUserGesture(document()))
         return;
 
     m_needsCheckForSizeChange = false;
@@ -609,10 +622,7 @@
         return;
     }
 
-    double lastKnownUserGestureTimestamp = document()->lastHandledUserGestureTimestamp();
-    if (!inMainFrame && document()->page()->mainFrame() && document()->page()->mainFrame()->document())
-        lastKnownUserGestureTimestamp = std::max(lastKnownUserGestureTimestamp, document()->page()->mainFrame()->document()->lastHandledUserGestureTimestamp());
-    if (currentTime() - lastKnownUserGestureTimestamp < autostartSoonAfterUserGestureThreshold) {
+    if (documentHadRecentUserGesture(document())) {
         LOG(Plugins, "%p Plug-in was created shortly after a user gesture, set to play", this);
         m_snapshotDecision = NeverSnapshot;
         return;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to