[Chromium] Move popup location detection code from WebViewImpl to WebPagePopupImpl
authortkent@chromium.org <tkent@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 Apr 2012 03:42:46 +0000 (03:42 +0000)
committertkent@chromium.org <tkent@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 Apr 2012 03:42:46 +0000 (03:42 +0000)
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: https://svn.webkit.org/repository/webkit/trunk@114336 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/src/WebPagePopupImpl.cpp
Source/WebKit/chromium/src/WebPagePopupImpl.h
Source/WebKit/chromium/src/WebViewImpl.cpp

index d225a2b..b9bd589 100644 (file)
@@ -1,3 +1,21 @@
+2012-04-16  Kent Tamura  <tkent@chromium.org>
+
+        [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  <jamesr@chromium.org>
 
         [chromium] Expose WebVideoLayer to Platform API and port WebMediaPlayerClientImpl to using it
index 0c2cc6d..7fb6f34 100644 (file)
@@ -31,6 +31,7 @@
 #include "config.h"
 #include "WebPagePopupImpl.h"
 
+#include "Chrome.h"
 #include "EmptyClients.h"
 #include "FileChooser.h"
 #include "FocusController.h"
 #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())
index 25afcb4..3b776f1 100644 (file)
@@ -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; }
index c2bbadb..67b0b1c 100644 (file)
@@ -1207,14 +1207,7 @@ PagePopup* WebViewImpl::openPagePopup(PagePopupClient* client, const IntRect& or
     WebWidget* popupWidget = m_client->createPopupMenu(WebPopupTypePage);
     ASSERT(popupWidget);
     m_pagePopup = static_cast<WebPagePopupImpl*>(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;
     }