Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(522)

Unified Diff: third_party/WebKit/Source/core/html/HTMLSelectElement.cpp

Issue 1959583002: Do not open SELECT popup if the SELECT element is not in the viewport. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: popup-menu-key-operations.html needs rebaseline Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/html/HTMLSelectElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLSelectElement.cpp b/third_party/WebKit/Source/core/html/HTMLSelectElement.cpp
index c1b513711c3747b6df2204199d5be67d57f4eaf1..391b5486f648de1f172eb69a84ebf8c90511dda4 100644
--- a/third_party/WebKit/Source/core/html/HTMLSelectElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLSelectElement.cpp
@@ -1876,9 +1876,12 @@ IntRect HTMLSelectElement::elementRectRelativeToViewport() const
{
if (!layoutObject())
return IntRect();
+ // Initialize with this frame rectangle relative to the viewport.
+ IntRect rect = document().view()->convertToRootFrame(document().view()->boundsRect());
// We don't use absoluteBoundingBoxRect() because it can return an IntRect
// larger the actual size by 1px.
- return document().view()->contentsToViewport(roundedIntRect(layoutObject()->absoluteBoundingBoxFloatRect()));
+ rect.intersect(document().view()->contentsToViewport(roundedIntRect(layoutObject()->absoluteBoundingBoxFloatRect())));
+ return rect;
}
LayoutUnit HTMLSelectElement::clientPaddingLeft() const
@@ -1951,6 +1954,8 @@ void HTMLSelectElement::showPopup()
return;
if (!layoutObject() || !layoutObject()->isMenuList())
return;
+ if (elementRectRelativeToViewport().isEmpty())
+ return;
if (!m_popup)
m_popup = document().frameHost()->chromeClient().openPopupMenu(*document().frame(), *this);

Powered by Google App Engine
This is Rietveld 408576698