From 65f5cfc7cc842fa47ae669aa2be4476f345e2f76 Mon Sep 17 00:00:00 2001 From: "tkent@chromium.org" Date: Tue, 17 Apr 2012 03:42:46 +0000 Subject: [PATCH] [Chromium] Move popup location detection code from WebViewImpl to WebPagePopupImpl https://bugs.webkit.org/show_bug.cgi?id=84116 Reviewed by Kentaro Hara. This makes no behavior change. Just move some code. To fix Bug 84007, WebPagePopupImpl needs to know if the popup is above the target element or below the target element. * src/WebPagePopupImpl.cpp: (WebKit::WebPagePopupImpl::init): Move some code from WebViewImpl::openPagePopup(). * src/WebPagePopupImpl.h: (WebPagePopupImpl): Rename an argument name. * src/WebViewImpl.cpp: (WebKit::WebViewImpl::openPagePopup): Move some code to WebPagePopupImpl::init(). git-svn-id: http://svn.webkit.org/repository/webkit/trunk@114336 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Source/WebKit/chromium/ChangeLog | 18 ++++++++++++++++++ Source/WebKit/chromium/src/WebPagePopupImpl.cpp | 14 +++++++++++++- Source/WebKit/chromium/src/WebPagePopupImpl.h | 2 +- Source/WebKit/chromium/src/WebViewImpl.cpp | 9 +-------- 4 files changed, 33 insertions(+), 10 deletions(-) diff --git a/Source/WebKit/chromium/ChangeLog b/Source/WebKit/chromium/ChangeLog index d225a2b..b9bd589 100644 --- a/Source/WebKit/chromium/ChangeLog +++ b/Source/WebKit/chromium/ChangeLog @@ -1,3 +1,21 @@ +2012-04-16 Kent Tamura + + [Chromium] Move popup location detection code from WebViewImpl to WebPagePopupImpl + https://bugs.webkit.org/show_bug.cgi?id=84116 + + Reviewed by Kentaro Hara. + + This makes no behavior change. Just move some code. + To fix Bug 84007, WebPagePopupImpl needs to know if the popup is + above the target element or below the target element. + + * src/WebPagePopupImpl.cpp: + (WebKit::WebPagePopupImpl::init): Move some code from WebViewImpl::openPagePopup(). + * src/WebPagePopupImpl.h: + (WebPagePopupImpl): Rename an argument name. + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::openPagePopup): Move some code to WebPagePopupImpl::init(). + 2012-04-13 James Robinson [chromium] Expose WebVideoLayer to Platform API and port WebMediaPlayerClientImpl to using it diff --git a/Source/WebKit/chromium/src/WebPagePopupImpl.cpp b/Source/WebKit/chromium/src/WebPagePopupImpl.cpp index 0c2cc6d..7fb6f34 100644 --- a/Source/WebKit/chromium/src/WebPagePopupImpl.cpp +++ b/Source/WebKit/chromium/src/WebPagePopupImpl.cpp @@ -31,6 +31,7 @@ #include "config.h" #include "WebPagePopupImpl.h" +#include "Chrome.h" #include "EmptyClients.h" #include "FileChooser.h" #include "FocusController.h" @@ -44,9 +45,11 @@ #include "WebInputEvent.h" #include "WebInputEventConversion.h" #include "WebPagePopup.h" +#include "WebViewImpl.h" #include "WebWidgetClient.h" using namespace WebCore; +using namespace std; namespace WebKit { @@ -133,13 +136,22 @@ WebPagePopupImpl::~WebPagePopupImpl() ASSERT(!m_page); } -bool WebPagePopupImpl::init(WebViewImpl* webView, PagePopupClient* popupClient, const IntRect& boundsInScreen) +bool WebPagePopupImpl::init(WebViewImpl* webView, PagePopupClient* popupClient, const IntRect& originBoundsInRootView) { ASSERT(webView); ASSERT(popupClient); m_webView = webView; m_popupClient = popupClient; + WebSize rootViewSize = webView->size(); + IntSize popupSize = popupClient->contentSize(); + IntRect popupBoundsInRootView(IntPoint(max(0, originBoundsInRootView.x()), max(0, originBoundsInRootView.maxY())), popupSize); + if (popupBoundsInRootView.maxY() > rootViewSize.height) + popupBoundsInRootView.setY(max(0, originBoundsInRootView.y() - popupSize.height())); + if (popupBoundsInRootView.maxX() > rootViewSize.width) + popupBoundsInRootView.setX(max(0, rootViewSize.width - popupSize.width())); + IntRect boundsInScreen = webView->page()->chrome()->rootViewToScreen(popupBoundsInRootView); + m_widgetClient->setWindowRect(boundsInScreen); m_windowRectInScreen = boundsInScreen; if (!initPage()) diff --git a/Source/WebKit/chromium/src/WebPagePopupImpl.h b/Source/WebKit/chromium/src/WebPagePopupImpl.h index 25afcb4..3b776f1 100644 --- a/Source/WebKit/chromium/src/WebPagePopupImpl.h +++ b/Source/WebKit/chromium/src/WebPagePopupImpl.h @@ -56,7 +56,7 @@ class WebPagePopupImpl : public WebPagePopup, WTF_MAKE_FAST_ALLOCATED; public: - bool init(WebViewImpl*, WebCore::PagePopupClient*, const WebCore::IntRect& boundsInScreen); + bool init(WebViewImpl*, WebCore::PagePopupClient*, const WebCore::IntRect& originBoundsInRootView); bool handleKeyEvent(const WebCore::PlatformKeyboardEvent&); void closePopup(); WebWidgetClient* widgetClient() const { return m_widgetClient; } diff --git a/Source/WebKit/chromium/src/WebViewImpl.cpp b/Source/WebKit/chromium/src/WebViewImpl.cpp index c2bbadb..67b0b1c 100644 --- a/Source/WebKit/chromium/src/WebViewImpl.cpp +++ b/Source/WebKit/chromium/src/WebViewImpl.cpp @@ -1207,14 +1207,7 @@ PagePopup* WebViewImpl::openPagePopup(PagePopupClient* client, const IntRect& or WebWidget* popupWidget = m_client->createPopupMenu(WebPopupTypePage); ASSERT(popupWidget); m_pagePopup = static_cast(popupWidget); - WebSize rootViewSize = size(); - IntSize popupSize = client->contentSize(); - IntRect popupBoundsInRootView(IntPoint(max(0, originBoundsInRootView.x()), max(0, originBoundsInRootView.maxY())), popupSize); - if (popupBoundsInRootView.maxY() > rootViewSize.height) - popupBoundsInRootView.setY(max(0, originBoundsInRootView.y() - popupSize.height())); - if (popupBoundsInRootView.maxX() > rootViewSize.width) - popupBoundsInRootView.setX(max(0, rootViewSize.width - popupSize.width())); - if (!m_pagePopup->init(this, client, m_chromeClientImpl.rootViewToScreen(popupBoundsInRootView))) { + if (!m_pagePopup->init(this, client, originBoundsInRootView)) { m_pagePopup->closePopup(); m_pagePopup = 0; } -- 2.7.4