Title: [114357] trunk/Source/WebKit/chromium
Revision
114357
Author
tk...@chromium.org
Date
2012-04-17 00:40:30 -0700 (Tue, 17 Apr 2012)

Log Message

[Chromium] Calendar Picker: Popup position is wrong when there are
no enough space below the target date field
https://bugs.webkit.org/show_bug.cgi?id=84007

Reviewed by Hajime Morita.

The popup was detached from the origin element because
calendarPicker.js resizes its window. To fix this bug, we move the
window position vertically when it is resized.

No new tests. This is not testable in WebKit.

* src/WebPagePopupImpl.cpp:
(WebKit::PagePopupChromeClient::setWindowRect):
If this request is just a resize and m_isPutAboveOrigin is true,
update the vertical position so that the popup attaches to the
origin rectangle.
(WebKit::WebPagePopupImpl::WebPagePopupImpl):
Initialize m_isPutAboveOrigin with false.
(WebKit::WebPagePopupImpl::init): Set m_isPutAboveOrigin true.
* src/WebPagePopupImpl.h:
(WebPagePopupImpl): Add m_isPutAboveOrigin.

Modified Paths

Diff

Modified: trunk/Source/WebKit/chromium/ChangeLog (114356 => 114357)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-04-17 07:30:46 UTC (rev 114356)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-04-17 07:40:30 UTC (rev 114357)
@@ -1,3 +1,28 @@
+2012-04-17  Kent Tamura  <tk...@chromium.org>
+
+        [Chromium] Calendar Picker: Popup position is wrong when there are
+        no enough space below the target date field
+        https://bugs.webkit.org/show_bug.cgi?id=84007
+
+        Reviewed by Hajime Morita.
+
+        The popup was detached from the origin element because
+        calendarPicker.js resizes its window. To fix this bug, we move the
+        window position vertically when it is resized.
+
+        No new tests. This is not testable in WebKit.
+
+        * src/WebPagePopupImpl.cpp:
+        (WebKit::PagePopupChromeClient::setWindowRect):
+        If this request is just a resize and m_isPutAboveOrigin is true,
+        update the vertical position so that the popup attaches to the
+        origin rectangle.
+        (WebKit::WebPagePopupImpl::WebPagePopupImpl):
+        Initialize m_isPutAboveOrigin with false.
+        (WebKit::WebPagePopupImpl::init): Set m_isPutAboveOrigin true.
+        * src/WebPagePopupImpl.h:
+        (WebPagePopupImpl): Add m_isPutAboveOrigin.
+
 2012-04-16  Kent Tamura  <tk...@chromium.org>
 
         Rename LocalizedNumberICU.h to ICULocale.h

Modified: trunk/Source/WebKit/chromium/src/WebPagePopupImpl.cpp (114356 => 114357)


--- trunk/Source/WebKit/chromium/src/WebPagePopupImpl.cpp	2012-04-17 07:30:46 UTC (rev 114356)
+++ trunk/Source/WebKit/chromium/src/WebPagePopupImpl.cpp	2012-04-17 07:40:30 UTC (rev 114357)
@@ -79,7 +79,11 @@
 
     virtual void setWindowRect(const FloatRect& rect) OVERRIDE
     {
-        m_popup->m_windowRectInScreen = IntRect(rect);
+        IntRect intRect(rect);
+        const WebRect currentRect = m_popup->m_windowRectInScreen;
+        if (intRect.x() == currentRect.x && intRect.y() == currentRect.y && m_popup->m_isPutAboveOrigin)
+            intRect.setY(currentRect.y + currentRect.height - intRect.height());
+        m_popup->m_windowRectInScreen = intRect;
         m_popup->widgetClient()->setWindowRect(m_popup->m_windowRectInScreen);
     }
 
@@ -127,6 +131,7 @@
 
 WebPagePopupImpl::WebPagePopupImpl(WebWidgetClient* client)
     : m_widgetClient(client)
+    , m_isPutAboveOrigin(false)
 {
     ASSERT(client);
 }
@@ -146,8 +151,10 @@
     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)
+    if (popupBoundsInRootView.maxY() > rootViewSize.height) {
         popupBoundsInRootView.setY(max(0, originBoundsInRootView.y() - popupSize.height()));
+        m_isPutAboveOrigin = true;
+    }
     if (popupBoundsInRootView.maxX() > rootViewSize.width)
         popupBoundsInRootView.setX(max(0, rootViewSize.width - popupSize.width()));
     IntRect boundsInScreen = webView->page()->chrome()->rootViewToScreen(popupBoundsInRootView);

Modified: trunk/Source/WebKit/chromium/src/WebPagePopupImpl.h (114356 => 114357)


--- trunk/Source/WebKit/chromium/src/WebPagePopupImpl.h	2012-04-17 07:30:46 UTC (rev 114356)
+++ trunk/Source/WebKit/chromium/src/WebPagePopupImpl.h	2012-04-17 07:40:30 UTC (rev 114357)
@@ -90,6 +90,7 @@
     OwnPtr<WebCore::Page> m_page;
     OwnPtr<PagePopupChromeClient> m_chromeClient;
     WebCore::PagePopupClient* m_popupClient;
+    bool m_isPutAboveOrigin;
 
     friend class WebPagePopup;
     friend class PagePopupChromeClient;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to