Title: [147693] trunk/Source/WebCore
Revision
147693
Author
[email protected]
Date
2013-04-04 18:25:05 -0700 (Thu, 04 Apr 2013)

Log Message

Don't dispatch delayed click if snapshotted plugin was triggered by a click on the label
https://bugs.webkit.org/show_bug.cgi?id=113982

Reviewed by Tim Horton.

We regressed the way clicks were sent on to restarted plugins when we moved to a
Shadow Root - we were always sending the click. We should only send the click
on if the user clicked on the main plugin content, and not send it when you
click directly on the label.

* html/HTMLPlugInImageElement.cpp:
(WebCore::HTMLPlugInImageElement::didAddUserAgentShadowRoot): Keep a reference to the container and label.
(WebCore::HTMLPlugInImageElement::partOfSnapshotLabel): New method that detects if a Node was part
    of the snapshot label.
(WebCore::HTMLPlugInImageElement::userDidClickSnapshot): Only record the event if you should forward it on.
* html/HTMLPlugInImageElement.h:
(HTMLPlugInImageElement): New parameter to userDidClickSnapshot and member variables for shadow content.
* rendering/RenderSnapshottedPlugIn.cpp:
(WebCore::RenderSnapshottedPlugIn::handleEvent): Ask the plugin if the clicked target was the snapshot label.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (147692 => 147693)


--- trunk/Source/WebCore/ChangeLog	2013-04-05 00:59:25 UTC (rev 147692)
+++ trunk/Source/WebCore/ChangeLog	2013-04-05 01:25:05 UTC (rev 147693)
@@ -1,3 +1,25 @@
+2013-04-04  Dean Jackson  <[email protected]>
+
+        Don't dispatch delayed click if snapshotted plugin was triggered by a click on the label
+        https://bugs.webkit.org/show_bug.cgi?id=113982
+
+        Reviewed by Tim Horton.
+
+        We regressed the way clicks were sent on to restarted plugins when we moved to a
+        Shadow Root - we were always sending the click. We should only send the click
+        on if the user clicked on the main plugin content, and not send it when you
+        click directly on the label.
+
+        * html/HTMLPlugInImageElement.cpp:
+        (WebCore::HTMLPlugInImageElement::didAddUserAgentShadowRoot): Keep a reference to the container and label.
+        (WebCore::HTMLPlugInImageElement::partOfSnapshotLabel): New method that detects if a Node was part
+            of the snapshot label.
+        (WebCore::HTMLPlugInImageElement::userDidClickSnapshot): Only record the event if you should forward it on.
+        * html/HTMLPlugInImageElement.h:
+        (HTMLPlugInImageElement): New parameter to userDidClickSnapshot and member variables for shadow content.
+        * rendering/RenderSnapshottedPlugIn.cpp:
+        (WebCore::RenderSnapshottedPlugIn::handleEvent): Ask the plugin if the clicked target was the snapshot label.
+
 2013-04-04  Christophe Dumez  <[email protected]>
 
         Unreviewed EFL build fix.

Modified: trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp (147692 => 147693)


--- trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp	2013-04-05 00:59:25 UTC (rev 147692)
+++ trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp	2013-04-05 01:25:05 UTC (rev 147693)
@@ -347,8 +347,8 @@
 {
     Document* doc = document();
 
-    RefPtr<Element> shadowContainer = HTMLDivElement::create(doc);
-    shadowContainer->setPseudo(AtomicString("-webkit-snapshotted-plugin-content", AtomicString::ConstructFromLiteral));
+    m_shadowContainer = HTMLDivElement::create(doc);
+    m_shadowContainer->setPseudo(AtomicString("-webkit-snapshotted-plugin-content", AtomicString::ConstructFromLiteral));
 
     RefPtr<Element> container = HTMLDivElement::create(doc);
     container->setAttribute(classAttr, AtomicString("snapshot-container", AtomicString::ConstructFromLiteral));
@@ -357,8 +357,8 @@
     overlay->setAttribute(classAttr, AtomicString("snapshot-overlay", AtomicString::ConstructFromLiteral));
     container->appendChild(overlay, ASSERT_NO_EXCEPTION);
 
-    RefPtr<Element> label = HTMLDivElement::create(doc);
-    label->setAttribute(classAttr, AtomicString("snapshot-label", AtomicString::ConstructFromLiteral));
+    m_snapshotLabel = HTMLDivElement::create(doc);
+    m_snapshotLabel->setAttribute(classAttr, AtomicString("snapshot-label", AtomicString::ConstructFromLiteral));
 
     String titleText = snapshottedPlugInLabelTitle();
     String subtitleText = snapshottedPlugInLabelSubtitle();
@@ -374,14 +374,14 @@
     RefPtr<Element> title = HTMLDivElement::create(doc);
     title->setAttribute(classAttr, AtomicString("snapshot-title", AtomicString::ConstructFromLiteral));
     title->appendChild(doc->createTextNode(titleText), ASSERT_NO_EXCEPTION);
-    label->appendChild(title, ASSERT_NO_EXCEPTION);
+    m_snapshotLabel->appendChild(title, ASSERT_NO_EXCEPTION);
 
     RefPtr<Element> subTitle = HTMLDivElement::create(doc);
     subTitle->setAttribute(classAttr, AtomicString("snapshot-subtitle", AtomicString::ConstructFromLiteral));
     subTitle->appendChild(doc->createTextNode(subtitleText), ASSERT_NO_EXCEPTION);
-    label->appendChild(subTitle, ASSERT_NO_EXCEPTION);
+    m_snapshotLabel->appendChild(subTitle, ASSERT_NO_EXCEPTION);
 
-    container->appendChild(label, ASSERT_NO_EXCEPTION);
+    container->appendChild(m_snapshotLabel, ASSERT_NO_EXCEPTION);
 
     // Make this into a button for accessibility clients.
     String combinedText = titleText;
@@ -391,10 +391,15 @@
     container->setAttribute(aria_labelAttr, combinedText);
     container->setAttribute(roleAttr, "button");
 
-    shadowContainer->appendChild(container, ASSERT_NO_EXCEPTION);
-    root->appendChild(shadowContainer, ASSERT_NO_EXCEPTION);
+    m_shadowContainer->appendChild(container, ASSERT_NO_EXCEPTION);
+    root->appendChild(m_shadowContainer, ASSERT_NO_EXCEPTION);
 }
 
+bool HTMLPlugInImageElement::partOfSnapshotLabel(Node* node)
+{
+    return node && (node == m_snapshotLabel.get() || node->isDescendantOf(m_snapshotLabel.get()));
+}
+
 void HTMLPlugInImageElement::swapRendererTimerFired(Timer<HTMLPlugInImageElement>*)
 {
     ASSERT(displayState() == DisplayingSnapshot);
@@ -463,9 +468,11 @@
     }
 }
 
-void HTMLPlugInImageElement::userDidClickSnapshot(PassRefPtr<MouseEvent> event)
+void HTMLPlugInImageElement::userDidClickSnapshot(PassRefPtr<MouseEvent> event, bool forwardEvent)
 {
-    m_pendingClickEventFromSnapshot = event;
+    if (forwardEvent)
+        m_pendingClickEventFromSnapshot = event;
+
     String plugInOrigin = m_loadedUrl.host();
     if (document()->page() && !SchemeRegistry::shouldTreatURLSchemeAsLocal(document()->page()->mainFrame()->document()->baseURL().protocol()) && document()->page()->settings()->autostartOriginPlugInSnapshottingEnabled())
         document()->page()->plugInClient()->didStartFromOrigin(document()->page()->mainFrame()->document()->baseURL().host(), plugInOrigin, loadedMimeType());

Modified: trunk/Source/WebCore/html/HTMLPlugInImageElement.h (147692 => 147693)


--- trunk/Source/WebCore/html/HTMLPlugInImageElement.h	2013-04-05 00:59:25 UTC (rev 147692)
+++ trunk/Source/WebCore/html/HTMLPlugInImageElement.h	2013-04-05 01:25:05 UTC (rev 147693)
@@ -74,7 +74,7 @@
     bool needsWidgetUpdate() const { return m_needsWidgetUpdate; }
     void setNeedsWidgetUpdate(bool needsWidgetUpdate) { m_needsWidgetUpdate = needsWidgetUpdate; }
 
-    void userDidClickSnapshot(PassRefPtr<MouseEvent>);
+    void userDidClickSnapshot(PassRefPtr<MouseEvent>, bool forwardEvent);
     void updateSnapshotInfo();
     Image* snapshotImage() const { return m_snapshotImage.get(); }
 
@@ -83,6 +83,7 @@
     void subframeLoaderDidCreatePlugIn(const Widget*);
 
     void setIsPrimarySnapshottedPlugIn(bool);
+    bool partOfSnapshotLabel(Node*);
 
 protected:
     HTMLPlugInImageElement(const QualifiedName& tagName, Document*, bool createdByParser, PreferPlugInsForImagesOption);
@@ -142,6 +143,8 @@
     Timer<HTMLPlugInImageElement> m_swapRendererTimer;
     Timer<HTMLPlugInImageElement> m_removeSnapshotTimer;
     RefPtr<Image> m_snapshotImage;
+    RefPtr<Element> m_shadowContainer;
+    RefPtr<Element> m_snapshotLabel;
     bool m_createdDuringUserGesture;
     bool m_restartedPlugin;
 };

Modified: trunk/Source/WebCore/rendering/RenderSnapshottedPlugIn.cpp (147692 => 147693)


--- trunk/Source/WebCore/rendering/RenderSnapshottedPlugIn.cpp	2013-04-05 00:59:25 UTC (rev 147692)
+++ trunk/Source/WebCore/rendering/RenderSnapshottedPlugIn.cpp	2013-04-05 01:25:05 UTC (rev 147693)
@@ -171,8 +171,9 @@
 
     if (event->type() == eventNames().clickEvent || (m_isPotentialMouseActivation && event->type() == eventNames().mouseupEvent)) {
         m_isPotentialMouseActivation = false;
-        plugInImageElement()->setDisplayState(HTMLPlugInElement::RestartingWithPendingMouseClick);
-        plugInImageElement()->userDidClickSnapshot(mouseEvent);
+        bool clickWasOnLabel = plugInImageElement()->partOfSnapshotLabel(event->target()->toNode());
+        plugInImageElement()->setDisplayState(clickWasOnLabel ? HTMLPlugInElement::Restarting : HTMLPlugInElement::RestartingWithPendingMouseClick);
+        plugInImageElement()->userDidClickSnapshot(mouseEvent, !clickWasOnLabel);
         event->setDefaultHandled();
     } else if (event->type() == eventNames().mousedownEvent) {
         m_isPotentialMouseActivation = true;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to