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

Unified Diff: third_party/WebKit/Source/core/dom/Element.cpp

Issue 2215333002: Fix element visibility check for validation bubbles and SELECT popups. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename to visibleBoundsInVisualViewport(), etc. Created 4 years, 4 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/dom/Element.cpp
diff --git a/third_party/WebKit/Source/core/dom/Element.cpp b/third_party/WebKit/Source/core/dom/Element.cpp
index 289c6b575bf1889052fa382523fefad648e3fa5b..499b9ea597f8be63ab7ef5d200ddf4299afe2130 100644
--- a/third_party/WebKit/Source/core/dom/Element.cpp
+++ b/third_party/WebKit/Source/core/dom/Element.cpp
@@ -95,6 +95,7 @@
#include "core/frame/ScrollToOptions.h"
#include "core/frame/Settings.h"
#include "core/frame/UseCounter.h"
+#include "core/frame/VisualViewport.h"
#include "core/frame/csp/ContentSecurityPolicy.h"
#include "core/html/ClassList.h"
#include "core/html/HTMLCanvasElement.h"
@@ -1015,6 +1016,20 @@ IntRect Element::boundsInViewport() const
return view->contentsToViewport(result);
}
+IntRect Element::visibleBoundsInVisualViewport() const
+{
+ if (!layoutObject() || !document().page())
+ return IntRect();
+ // TODO(tkent): Can we check invisibility by scrollable non-frame elements?
+
+ IntSize viewportSize = document().page()->frameHost().visualViewport().size();
+ IntRect rect(0, 0, viewportSize.width(), viewportSize.height());
+ // We don't use absoluteBoundingBoxRect() because it can return an IntRect
+ // larger the actual size by 1px. crbug.com/470503
+ rect.intersect(document().view()->contentsToViewport(roundedIntRect(layoutObject()->absoluteBoundingBoxFloatRect())));
+ return rect;
+}
+
ClientRectList* Element::getClientRects()
{
document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this);
« no previous file with comments | « third_party/WebKit/Source/core/dom/Element.h ('k') | third_party/WebKit/Source/core/html/HTMLSelectElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698