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

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: 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 8fb4a4d37b6c25f79605301a33d289ddf59be2d9..762203b3589bf0d7178082fb3ccb35f771b7ccde 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::visibleBoundsInViewport() 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);

Powered by Google App Engine
This is Rietveld 408576698