Commit e7cb470a authored by akling@apple.com's avatar akling@apple.com

REGRESSION(r145869): Right-click on SWF contents displays the context menu at the wrong place.

<http://webkit.org/b/113836>
<rdar://problem/13587624>

Reviewed by Anders "Wesley Crusher" Carlsson.

Mac plugins expect flipped-Y screen coordinates, while DOM APIs speak in unflipped coordinates,
and we were mixing them up in the window frame caching optimization.

Solve this by having the UIProcess send both flipped and unflipped window frames to the WebProcess.
The flipped frame is passed on to plugins, and the unflipped frame is used for window.screenX/Y etc.

* UIProcess/API/mac/WKView.mm:
(-[WKView _updateWindowAndViewFrames]):

    No need to retrieve the window frame here as WebPageProxy::windowAndViewFramesChanged() will
    always override it anyway.

* UIProcess/mac/WebPageProxyMac.mm:
(WebKit::WebPageProxy::windowAndViewFramesChanged):
* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::windowRect):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::windowAndViewFramesChanged):
* WebProcess/WebPage/WebPage.h:
(WebKit::WebPage::windowFrameInUnflippedScreenCoordinates):
* WebProcess/WebPage/WebPage.messages.in:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@148278 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 6de6a8bd
2013-04-12 Andreas Kling <akling@apple.com>
REGRESSION(r145869): Right-click on SWF contents displays the context menu at the wrong place.
<http://webkit.org/b/113836>
<rdar://problem/13587624>
Reviewed by Anders "Wesley Crusher" Carlsson.
Mac plugins expect flipped-Y screen coordinates, while DOM APIs speak in unflipped coordinates,
and we were mixing them up in the window frame caching optimization.
Solve this by having the UIProcess send both flipped and unflipped window frames to the WebProcess.
The flipped frame is passed on to plugins, and the unflipped frame is used for window.screenX/Y etc.
* UIProcess/API/mac/WKView.mm:
(-[WKView _updateWindowAndViewFrames]):
No need to retrieve the window frame here as WebPageProxy::windowAndViewFramesChanged() will
always override it anyway.
* UIProcess/mac/WebPageProxyMac.mm:
(WebKit::WebPageProxy::windowAndViewFramesChanged):
* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::windowRect):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::windowAndViewFramesChanged):
* WebProcess/WebPage/WebPage.h:
(WebKit::WebPage::windowFrameInUnflippedScreenCoordinates):
* WebProcess/WebPage/WebPage.messages.in:
2013-04-12 Mikhail Pozdnyakov <mikhail.pozdnyakov@intel.com>
[WK2][EFL] WebView: Add callbacks to the WKViewClient to handle page viewport update
......@@ -396,14 +396,10 @@ struct WKViewInterpretKeyEventsParameters {
- (void)_updateWindowAndViewFrames
{
NSWindow *window = [self window];
ASSERT(window);
NSRect windowFrameInScreenCoordinates = [window frame];
NSRect viewFrameInWindowCoordinates = [self convertRect:[self frame] toView:nil];
NSPoint accessibilityPosition = [[self accessibilityAttributeValue:NSAccessibilityPositionAttribute] pointValue];
_data->_page->windowAndViewFramesChanged(windowFrameInScreenCoordinates, viewFrameInWindowCoordinates, accessibilityPosition);
_data->_page->windowAndViewFramesChanged(viewFrameInWindowCoordinates, accessibilityPosition);
if (_data->_expandsToFitContentViaAutoLayout)
_data->_page->viewExposedRectChanged([self visibleRect]);
}
......
......@@ -382,7 +382,7 @@ public:
#if PLATFORM(MAC)
void updateWindowIsVisible(bool windowIsVisible);
void windowAndViewFramesChanged(const WebCore::FloatRect& windowFrameInScreenCoordinates, const WebCore::FloatRect& viewFrameInWindowCoordinates, const WebCore::FloatPoint& accessibilityViewCoordinates);
void windowAndViewFramesChanged(const WebCore::FloatRect& viewFrameInWindowCoordinates, const WebCore::FloatPoint& accessibilityViewCoordinates);
void viewExposedRectChanged(const WebCore::FloatRect& exposedRect);
void setMainFrameIsScrollable(bool);
......
......@@ -138,16 +138,16 @@ void WebPageProxy::updateWindowIsVisible(bool windowIsVisible)
process()->send(Messages::WebPage::SetWindowIsVisible(windowIsVisible), m_pageID);
}
void WebPageProxy::windowAndViewFramesChanged(const FloatRect& windowFrameInScreenCoordinates, const FloatRect& viewFrameInWindowCoordinates, const FloatPoint& accessibilityViewCoordinates)
void WebPageProxy::windowAndViewFramesChanged(const FloatRect& viewFrameInWindowCoordinates, const FloatPoint& accessibilityViewCoordinates)
{
if (!isValid())
return;
// In case the UI client overrides getWindowFrame(), we call it here to make sure we send the appropriate window frame.
FloatRect adjustedWindowFrameInScreenCoordinates;
getWindowFrame(adjustedWindowFrameInScreenCoordinates);
FloatRect windowFrameInScreenCoordinates = m_uiClient.windowFrame(this);
FloatRect windowFrameInUnflippedScreenCoordinates = m_pageClient->convertToUserSpace(windowFrameInScreenCoordinates);
process()->send(Messages::WebPage::WindowAndViewFramesChanged(adjustedWindowFrameInScreenCoordinates, viewFrameInWindowCoordinates, accessibilityViewCoordinates), m_pageID);
process()->send(Messages::WebPage::WindowAndViewFramesChanged(windowFrameInScreenCoordinates, windowFrameInUnflippedScreenCoordinates, viewFrameInWindowCoordinates, accessibilityViewCoordinates), m_pageID);
}
void WebPageProxy::viewExposedRectChanged(const FloatRect& exposedRect)
......
......@@ -114,7 +114,7 @@ FloatRect WebChromeClient::windowRect()
{
#if PLATFORM(MAC)
if (m_page->hasCachedWindowFrame())
return m_page->windowFrameInScreenCoordinates();
return m_page->windowFrameInUnflippedScreenCoordinates();
#endif
FloatRect newWindowFrame;
......
......@@ -2969,9 +2969,10 @@ void WebPage::setWindowIsVisible(bool windowIsVisible)
(*it)->setWindowIsVisible(windowIsVisible);
}
void WebPage::windowAndViewFramesChanged(const FloatRect& windowFrameInScreenCoordinates, const FloatRect& viewFrameInWindowCoordinates, const FloatPoint& accessibilityViewCoordinates)
void WebPage::windowAndViewFramesChanged(const FloatRect& windowFrameInScreenCoordinates, const FloatRect& windowFrameInUnflippedScreenCoordinates, const FloatRect& viewFrameInWindowCoordinates, const FloatPoint& accessibilityViewCoordinates)
{
m_windowFrameInScreenCoordinates = windowFrameInScreenCoordinates;
m_windowFrameInUnflippedScreenCoordinates = windowFrameInUnflippedScreenCoordinates;
m_viewFrameInWindowCoordinates = viewFrameInWindowCoordinates;
m_accessibilityPosition = accessibilityViewCoordinates;
......@@ -2979,7 +2980,7 @@ void WebPage::windowAndViewFramesChanged(const FloatRect& windowFrameInScreenCoo
for (HashSet<PluginView*>::const_iterator it = m_pluginViews.begin(), end = m_pluginViews.end(); it != end; ++it)
(*it)->windowAndViewFramesChanged(enclosingIntRect(windowFrameInScreenCoordinates), enclosingIntRect(viewFrameInWindowCoordinates));
m_hasCachedWindowFrame = !m_windowFrameInScreenCoordinates.isEmpty();
m_hasCachedWindowFrame = !m_windowFrameInUnflippedScreenCoordinates.isEmpty();
}
#endif
......
......@@ -361,6 +361,7 @@ public:
bool windowIsVisible() const { return m_windowIsVisible; }
void updatePluginsActiveAndFocusedState();
const WebCore::FloatRect& windowFrameInScreenCoordinates() const { return m_windowFrameInScreenCoordinates; }
const WebCore::FloatRect& windowFrameInUnflippedScreenCoordinates() const { return m_windowFrameInUnflippedScreenCoordinates; }
const WebCore::FloatRect& viewFrameInWindowCoordinates() const { return m_viewFrameInWindowCoordinates; }
bool hasCachedWindowFrame() const { return m_hasCachedWindowFrame; }
......@@ -757,7 +758,7 @@ private:
void performDictionaryLookupForRange(DictionaryPopupInfo::Type, WebCore::Frame*, WebCore::Range*, NSDictionary *options);
void setWindowIsVisible(bool windowIsVisible);
void windowAndViewFramesChanged(const WebCore::FloatRect& windowFrameInScreenCoordinates, const WebCore::FloatRect& viewFrameInWindowCoordinates, const WebCore::FloatPoint& accessibilityViewCoordinates);
void windowAndViewFramesChanged(const WebCore::FloatRect& windowFrameInScreenCoordinates, const WebCore::FloatRect& windowFrameInUnflippedScreenCoordinates, const WebCore::FloatRect& viewFrameInWindowCoordinates, const WebCore::FloatPoint& accessibilityViewCoordinates);
RetainPtr<PDFDocument> pdfDocumentForPrintingFrame(WebCore::Frame*);
void computePagesForPrintingPDFDocument(uint64_t frameID, const PrintInfo&, Vector<WebCore::IntRect>& resultPageRects);
......@@ -885,6 +886,9 @@ private:
// The frame of the containing window in screen coordinates.
WebCore::FloatRect m_windowFrameInScreenCoordinates;
// The frame of the containing window in unflipped screen coordinates.
WebCore::FloatRect m_windowFrameInUnflippedScreenCoordinates;
// The frame of the view in window coordinates.
WebCore::FloatRect m_viewFrameInWindowCoordinates;
......
......@@ -260,7 +260,7 @@ messages -> WebPage LegacyReceiver {
SendComplexTextInputToPlugin(uint64_t pluginComplexTextInputIdentifier, String textInput)
SetWindowIsVisible(bool windowIsVisible)
WindowAndViewFramesChanged(WebCore::FloatRect windowFrameInScreenCoordinates, WebCore::FloatRect viewFrameInWindowCoordinates, WebCore::FloatPoint accessibilityViewCoordinates)
WindowAndViewFramesChanged(WebCore::FloatRect windowFrameInScreenCoordinates, WebCore::FloatRect windowFrameInUnflippedScreenCoordinates, WebCore::FloatRect viewFrameInWindowCoordinates, WebCore::FloatPoint accessibilityViewCoordinates)
ViewExposedRectChanged(WebCore::FloatRect exposedRect)
SetMainFrameIsScrollable(bool isScrollable)
RegisterUIProcessAccessibilityTokens(CoreIPC::DataReference elemenToken, CoreIPC::DataReference windowToken)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment