Changeset 147240 in webkit


Ignore:
Timestamp:
Mar 29, 2013 12:31:45 PM (11 years ago)
Author:
dino@apple.com
Message:

Snapshotted plugins must be able to restart on appropriate mouseup events
https://bugs.webkit.org/show_bug.cgi?id=113577

Reviewed by Tim Horton.

If the page content prevents the default behaviour of a mousedown event, then a snapshotted
plugin would never receive a click event, and thus be unable to restart. We have to also
look for a mouseup that happens with an associated mousedown, and trigger restart. This
won't call any page code - it's just behind the scenes.

  • rendering/RenderSnapshottedPlugIn.cpp:

(WebCore::RenderSnapshottedPlugIn::RenderSnapshottedPlugIn): Initialize new member variable.
(WebCore::RenderSnapshottedPlugIn::handleEvent): Track the state of mousedown and up pairs, and restart

if you see an appropriate mouseup.

  • rendering/RenderSnapshottedPlugIn.h: New member variable to track mouse state.
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r147238 r147240  
     12013-03-29  Dean Jackson  <dino@apple.com>
     2
     3        Snapshotted plugins must be able to restart on appropriate mouseup events
     4        https://bugs.webkit.org/show_bug.cgi?id=113577
     5
     6        Reviewed by Tim Horton.
     7
     8        If the page content prevents the default behaviour of a mousedown event, then a snapshotted
     9        plugin would never receive a click event, and thus be unable to restart. We have to also
     10        look for a mouseup that happens with an associated mousedown, and trigger restart. This
     11        won't call any page code - it's just behind the scenes.
     12
     13        * rendering/RenderSnapshottedPlugIn.cpp:
     14        (WebCore::RenderSnapshottedPlugIn::RenderSnapshottedPlugIn): Initialize new member variable.
     15        (WebCore::RenderSnapshottedPlugIn::handleEvent): Track the state of mousedown and up pairs, and restart
     16            if you see an appropriate mouseup.
     17        * rendering/RenderSnapshottedPlugIn.h: New member variable to track mouse state.
     18
    1192013-03-29  Simon Fraser  <simon.fraser@apple.com>
    220
  • trunk/Source/WebCore/rendering/RenderSnapshottedPlugIn.cpp

    r146679 r147240  
    4747    : RenderEmbeddedObject(element)
    4848    , m_snapshotResource(RenderImageResource::create())
     49    , m_isPotentialMouseActivation(false)
    4950{
    5051    m_snapshotResource->initialize(this);
     
    155156    MouseEvent* mouseEvent = static_cast<MouseEvent*>(event);
    156157
    157     if (event->type() == eventNames().clickEvent) {
    158         if (mouseEvent->button() != LeftButton)
    159             return;
     158    // If we're a snapshotted plugin, we want to make sure we activate on
     159    // clicks even if the page is preventing our default behaviour. Otherwise
     160    // we can never restart. One we do restart, then the page will happily
     161    // block the new plugin in the normal renderer. All this means we have to
     162    // be on the lookout for a mouseup event that comes after a mousedown
     163    // event. The code below is not completely foolproof, but the worst that
     164    // could happen is that a snapshotted plugin restarts.
    160165
     166    if (event->type() == eventNames().mouseoutEvent)
     167        m_isPotentialMouseActivation = false;
     168
     169    if (mouseEvent->button() != LeftButton)
     170        return;
     171
     172    if (event->type() == eventNames().clickEvent || (m_isPotentialMouseActivation && event->type() == eventNames().mouseupEvent)) {
     173        m_isPotentialMouseActivation = false;
    161174        plugInImageElement()->setDisplayState(HTMLPlugInElement::RestartingWithPendingMouseClick);
    162175        plugInImageElement()->userDidClickSnapshot(mouseEvent);
    163176        event->setDefaultHandled();
    164177    } else if (event->type() == eventNames().mousedownEvent) {
    165         if (mouseEvent->button() != LeftButton)
    166             return;
    167 
     178        m_isPotentialMouseActivation = true;
    168179        event->setDefaultHandled();
    169180    }
  • trunk/Source/WebCore/rendering/RenderSnapshottedPlugIn.h

    r145934 r147240  
    5959
    6060    OwnPtr<RenderImageResource> m_snapshotResource;
     61    bool m_isPotentialMouseActivation;
    6162};
    6263
Note: See TracChangeset for help on using the changeset viewer.