Changeset 147693 in webkit


Ignore:
Timestamp:
Apr 4, 2013 6:25:05 PM (11 years ago)
Author:
dino@apple.com
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.

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r147692 r147693  
     12013-04-04  Dean Jackson  <dino@apple.com>
     2
     3        Don't dispatch delayed click if snapshotted plugin was triggered by a click on the label
     4        https://bugs.webkit.org/show_bug.cgi?id=113982
     5
     6        Reviewed by Tim Horton.
     7
     8        We regressed the way clicks were sent on to restarted plugins when we moved to a
     9        Shadow Root - we were always sending the click. We should only send the click
     10        on if the user clicked on the main plugin content, and not send it when you
     11        click directly on the label.
     12
     13        * html/HTMLPlugInImageElement.cpp:
     14        (WebCore::HTMLPlugInImageElement::didAddUserAgentShadowRoot): Keep a reference to the container and label.
     15        (WebCore::HTMLPlugInImageElement::partOfSnapshotLabel): New method that detects if a Node was part
     16            of the snapshot label.
     17        (WebCore::HTMLPlugInImageElement::userDidClickSnapshot): Only record the event if you should forward it on.
     18        * html/HTMLPlugInImageElement.h:
     19        (HTMLPlugInImageElement): New parameter to userDidClickSnapshot and member variables for shadow content.
     20        * rendering/RenderSnapshottedPlugIn.cpp:
     21        (WebCore::RenderSnapshottedPlugIn::handleEvent): Ask the plugin if the clicked target was the snapshot label.
     22
    1232013-04-04  Christophe Dumez  <ch.dumez@sisa.samsung.com>
    224
  • trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp

    r147659 r147693  
    348348    Document* doc = document();
    349349
    350     RefPtr<Element> shadowContainer = HTMLDivElement::create(doc);
    351     shadowContainer->setPseudo(AtomicString("-webkit-snapshotted-plugin-content", AtomicString::ConstructFromLiteral));
     350    m_shadowContainer = HTMLDivElement::create(doc);
     351    m_shadowContainer->setPseudo(AtomicString("-webkit-snapshotted-plugin-content", AtomicString::ConstructFromLiteral));
    352352
    353353    RefPtr<Element> container = HTMLDivElement::create(doc);
     
    358358    container->appendChild(overlay, ASSERT_NO_EXCEPTION);
    359359
    360     RefPtr<Element> label = HTMLDivElement::create(doc);
    361     label->setAttribute(classAttr, AtomicString("snapshot-label", AtomicString::ConstructFromLiteral));
     360    m_snapshotLabel = HTMLDivElement::create(doc);
     361    m_snapshotLabel->setAttribute(classAttr, AtomicString("snapshot-label", AtomicString::ConstructFromLiteral));
    362362
    363363    String titleText = snapshottedPlugInLabelTitle();
     
    375375    title->setAttribute(classAttr, AtomicString("snapshot-title", AtomicString::ConstructFromLiteral));
    376376    title->appendChild(doc->createTextNode(titleText), ASSERT_NO_EXCEPTION);
    377     label->appendChild(title, ASSERT_NO_EXCEPTION);
     377    m_snapshotLabel->appendChild(title, ASSERT_NO_EXCEPTION);
    378378
    379379    RefPtr<Element> subTitle = HTMLDivElement::create(doc);
    380380    subTitle->setAttribute(classAttr, AtomicString("snapshot-subtitle", AtomicString::ConstructFromLiteral));
    381381    subTitle->appendChild(doc->createTextNode(subtitleText), ASSERT_NO_EXCEPTION);
    382     label->appendChild(subTitle, ASSERT_NO_EXCEPTION);
    383 
    384     container->appendChild(label, ASSERT_NO_EXCEPTION);
     382    m_snapshotLabel->appendChild(subTitle, ASSERT_NO_EXCEPTION);
     383
     384    container->appendChild(m_snapshotLabel, ASSERT_NO_EXCEPTION);
    385385
    386386    // Make this into a button for accessibility clients.
     
    392392    container->setAttribute(roleAttr, "button");
    393393
    394     shadowContainer->appendChild(container, ASSERT_NO_EXCEPTION);
    395     root->appendChild(shadowContainer, ASSERT_NO_EXCEPTION);
     394    m_shadowContainer->appendChild(container, ASSERT_NO_EXCEPTION);
     395    root->appendChild(m_shadowContainer, ASSERT_NO_EXCEPTION);
     396}
     397
     398bool HTMLPlugInImageElement::partOfSnapshotLabel(Node* node)
     399{
     400    return node && (node == m_snapshotLabel.get() || node->isDescendantOf(m_snapshotLabel.get()));
    396401}
    397402
     
    464469}
    465470
    466 void HTMLPlugInImageElement::userDidClickSnapshot(PassRefPtr<MouseEvent> event)
    467 {
    468     m_pendingClickEventFromSnapshot = event;
     471void HTMLPlugInImageElement::userDidClickSnapshot(PassRefPtr<MouseEvent> event, bool forwardEvent)
     472{
     473    if (forwardEvent)
     474        m_pendingClickEventFromSnapshot = event;
     475
    469476    String plugInOrigin = m_loadedUrl.host();
    470477    if (document()->page() && !SchemeRegistry::shouldTreatURLSchemeAsLocal(document()->page()->mainFrame()->document()->baseURL().protocol()) && document()->page()->settings()->autostartOriginPlugInSnapshottingEnabled())
  • trunk/Source/WebCore/html/HTMLPlugInImageElement.h

    r147591 r147693  
    7575    void setNeedsWidgetUpdate(bool needsWidgetUpdate) { m_needsWidgetUpdate = needsWidgetUpdate; }
    7676
    77     void userDidClickSnapshot(PassRefPtr<MouseEvent>);
     77    void userDidClickSnapshot(PassRefPtr<MouseEvent>, bool forwardEvent);
    7878    void updateSnapshotInfo();
    7979    Image* snapshotImage() const { return m_snapshotImage.get(); }
     
    8484
    8585    void setIsPrimarySnapshottedPlugIn(bool);
     86    bool partOfSnapshotLabel(Node*);
    8687
    8788protected:
     
    143144    Timer<HTMLPlugInImageElement> m_removeSnapshotTimer;
    144145    RefPtr<Image> m_snapshotImage;
     146    RefPtr<Element> m_shadowContainer;
     147    RefPtr<Element> m_snapshotLabel;
    145148    bool m_createdDuringUserGesture;
    146149    bool m_restartedPlugin;
  • trunk/Source/WebCore/rendering/RenderSnapshottedPlugIn.cpp

    r147240 r147693  
    172172    if (event->type() == eventNames().clickEvent || (m_isPotentialMouseActivation && event->type() == eventNames().mouseupEvent)) {
    173173        m_isPotentialMouseActivation = false;
    174         plugInImageElement()->setDisplayState(HTMLPlugInElement::RestartingWithPendingMouseClick);
    175         plugInImageElement()->userDidClickSnapshot(mouseEvent);
     174        bool clickWasOnLabel = plugInImageElement()->partOfSnapshotLabel(event->target()->toNode());
     175        plugInImageElement()->setDisplayState(clickWasOnLabel ? HTMLPlugInElement::Restarting : HTMLPlugInElement::RestartingWithPendingMouseClick);
     176        plugInImageElement()->userDidClickSnapshot(mouseEvent, !clickWasOnLabel);
    176177        event->setDefaultHandled();
    177178    } else if (event->type() == eventNames().mousedownEvent) {
Note: See TracChangeset for help on using the changeset viewer.