Changeset 86615 in webkit


Ignore:
Timestamp:
May 16, 2011 3:32:18 PM (13 years ago)
Author:
cmarrin@apple.com
Message:

2011-05-16 Chris Marrin <cmarrin@apple.com>

Reviewed by Darin Adler.

Plug-in hit testing is broken after zooming
https://bugs.webkit.org/show_bug.cgi?id=60916

Construct a WebMouseEvent to send to plugin, adjusting values to take pageScaleFactor
into account. Also adjusted bounds sent to viewGeometryDidChange to take pageScaleFactor
into account. Both are needed or the plugin will think the mouse positions are outside
its bounds.

  • Shared/WebEvent.h:
  • Shared/WebMouseEvent.cpp:Add ctor to clone a WebMouseEvent and add a scaleFactor to values (WebKit::WebMouseEvent::WebMouseEvent):
  • WebProcess/Plugins/PluginView.cpp: (WebKit::PluginView::handleEvent):Adjust mouse coords to take pageScaleFactor into account (WebKit::PluginView::viewGeometryDidChange):Adjust bounds to take pageScaleFactor into account
Location:
trunk/Source/WebKit2
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r86612 r86615  
     12011-05-16  Chris Marrin  <cmarrin@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        Plug-in hit testing is broken after zooming
     6        https://bugs.webkit.org/show_bug.cgi?id=60916
     7
     8        Construct a WebMouseEvent to send to plugin, adjusting values to take pageScaleFactor
     9        into account. Also adjusted bounds sent to viewGeometryDidChange to take pageScaleFactor
     10        into account. Both are needed or the plugin will think the mouse positions are outside
     11        its bounds.
     12
     13        * Shared/WebEvent.h:
     14        * Shared/WebMouseEvent.cpp:Add ctor to clone a WebMouseEvent and add a scaleFactor to values
     15        (WebKit::WebMouseEvent::WebMouseEvent):
     16        * WebProcess/Plugins/PluginView.cpp:
     17        (WebKit::PluginView::handleEvent):Adjust mouse coords to take pageScaleFactor into account
     18        (WebKit::PluginView::viewGeometryDidChange):Adjust bounds to take pageScaleFactor into account
     19
    1202011-05-16  Martin Robinson  <mrobinson@igalia.com>
    221
  • trunk/Source/WebKit2/Shared/WebEvent.h

    r82896 r86615  
    125125    WebMouseEvent(Type, Button, const WebCore::IntPoint& position, const WebCore::IntPoint& globalPosition, float deltaX, float deltaY, float deltaZ, int clickCount, Modifiers, double timestamp, bool didActivateWebView);
    126126#endif
     127   
     128    WebMouseEvent(const WebMouseEvent&, float pageScaleFactor);
    127129
    128130    Button button() const { return static_cast<Button>(m_button); }
  • trunk/Source/WebKit2/Shared/WebMouseEvent.cpp

    r82733 r86615  
    7979#endif
    8080
     81WebMouseEvent::WebMouseEvent(const WebMouseEvent& event, float pageScaleFactor)
     82    : WebEvent(event.type(), event.modifiers(), event.timestamp())
     83    , m_button(event.button())
     84    , m_position(WebCore::IntPoint(event.position().x() / pageScaleFactor, event.position().y() / pageScaleFactor))
     85    , m_globalPosition(m_position + (event.globalPosition() - event.position()))
     86    , m_deltaX(event.deltaX())
     87    , m_deltaY(event.deltaY())
     88    , m_deltaZ(event.deltaZ())
     89    , m_clickCount(event.clickCount())
     90#if PLATFORM(WIN)
     91    , m_didActivateWebView(false)
     92#endif
     93{
     94}
     95
    8196void WebMouseEvent::encode(CoreIPC::ArgumentEncoder* encoder) const
    8297{
  • trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp

    r86577 r86615  
    3939#include <WebCore/CredentialStorage.h>
    4040#include <WebCore/DocumentLoader.h>
    41 #include <WebCore/Event.h>
     41#include <WebCore/MouseEvent.h>
    4242#include <WebCore/FocusController.h>
    4343#include <WebCore/Frame.h>
     
    576576        if (currentEvent->type() == WebEvent::MouseDown)
    577577            focusPluginElement();
    578 
    579         didHandleEvent = m_plugin->handleMouseEvent(static_cast<const WebMouseEvent&>(*currentEvent));
     578       
     579        // Adjust mouse coordinates to account for pageScaleFactor
     580        float scaleFactor = frame()->pageScaleFactor();
     581        WebMouseEvent eventWithScaledCoordinates(*(static_cast<const WebMouseEvent*>(currentEvent)), scaleFactor);
     582        didHandleEvent = m_plugin->handleMouseEvent(eventWithScaledCoordinates);
    580583    } else if (event->type() == eventNames().mousewheelEvent && currentEvent->type() == WebEvent::Wheel) {
    581584        // We have a wheel event.
     
    641644    // Get the frame rect in window coordinates.
    642645    IntRect frameRectInWindowCoordinates = parent()->contentsToWindow(frameRect());
     646   
     647    // Adjust bounds to account for pageScaleFactor
     648    float scaleFactor = frame()->pageScaleFactor();
     649    frameRectInWindowCoordinates.setX(frameRectInWindowCoordinates.x() / scaleFactor);
     650    frameRectInWindowCoordinates.setY(frameRectInWindowCoordinates.y() / scaleFactor);
    643651    frameRectInWindowCoordinates.setSize(m_boundsSize);
    644652    m_plugin->geometryDidChange(frameRectInWindowCoordinates, clipRectInWindowCoordinates());
Note: See TracChangeset for help on using the changeset viewer.