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

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

Issue 1516723003: [Element / Autofill] Add boundsInViewportFloat() to fix <input> popup misalignment. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refator to use boundsInViewportFloat() eventually, but keep boundsInViewportInt(). Created 5 years 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
« no previous file with comments | « third_party/WebKit/Source/core/dom/Element.h ('k') | third_party/WebKit/Source/core/frame/FrameView.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 61151db94f3a35cfa29ca5a83bcc15397100f908..a15a0015f8be1014e4177743bc800f3a8887ba67 100644
--- a/third_party/WebKit/Source/core/dom/Element.cpp
+++ b/third_party/WebKit/Source/core/dom/Element.cpp
@@ -1013,13 +1013,33 @@ bool Element::hasNonEmptyLayoutSize() const
return false;
}
-IntRect Element::boundsInViewport()
+bool Element::getBoundingQuads(Vector<FloatQuad>& quads)
+{
+ assert(quads.isEmpty());
+ if (isSVGElement() && layoutObject()) {
+ // Get the bounding rectangle from the SVG model.
+ if (toSVGElement(this)->isSVGGraphicsElement())
+ quads.append(layoutObject()->localToAbsoluteQuad(layoutObject()->objectBoundingBox()));
+ } else {
+ // Get the bounding rectangle from the box model.
+ if (layoutBoxModelObject())
+ layoutBoxModelObject()->absoluteQuads(quads);
+ }
+ return !quads.isEmpty();
+}
+
+IntRect Element::boundsInViewportInt()
+{
+ return enclosingIntRect(boundsInViewportFloat());
+}
+
+FloatRect Element::boundsInViewportFloat()
{
document().updateLayoutIgnorePendingStylesheets();
FrameView* view = document().view();
if (!view)
- return IntRect();
+ return FloatRect();
Vector<FloatQuad> quads;
if (isSVGElement() && layoutObject()) {
@@ -1031,13 +1051,12 @@ IntRect Element::boundsInViewport()
if (layoutBoxModelObject())
layoutBoxModelObject()->absoluteQuads(quads);
}
-
if (quads.isEmpty())
- return IntRect();
+ return FloatRect();
- IntRect result = quads[0].enclosingBoundingBox();
+ FloatRect result = quads[0].boundingBox();
for (size_t i = 1; i < quads.size(); ++i)
- result.unite(quads[i].enclosingBoundingBox());
+ result.unite(quads[i].boundingBox());
return view->contentsToViewport(result);
}
« no previous file with comments | « third_party/WebKit/Source/core/dom/Element.h ('k') | third_party/WebKit/Source/core/frame/FrameView.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698