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

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

Issue 2349653002: Added support of getClientRects() for SVG Elements. (Closed)
Patch Set: nits Created 4 years, 3 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 62ff6eceed9ca21bfc1cc038ebfdfc2e01a53d53..8c1b3a73be810067d25a3aad01d740bace80de4f 100644
--- a/third_party/WebKit/Source/core/dom/Element.cpp
+++ b/third_party/WebKit/Source/core/dom/Element.cpp
@@ -1031,39 +1031,42 @@ IntRect Element::visibleBoundsInVisualViewport() const
return rect;
}
-ClientRectList* Element::getClientRects()
+void Element::clientQuads(Vector<FloatQuad>& quads)
{
document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this);
LayoutObject* elementLayoutObject = layoutObject();
- if (!elementLayoutObject || (!elementLayoutObject->isBoxModelObject() && !elementLayoutObject->isBR()))
+ if (!elementLayoutObject)
+ return;
+
+ if (isSVGElement() && !elementLayoutObject->isSVGRoot()) {
+ // Get the bounding rectangle from the SVG model.
+ if (toSVGElement(this)->isSVGGraphicsElement())
+ quads.append(elementLayoutObject->localToAbsoluteQuad(elementLayoutObject->objectBoundingBox()));
+ } else if (elementLayoutObject->isBoxModelObject() || elementLayoutObject->isBR()) {
+ elementLayoutObject->absoluteQuads(quads);
+ }
+}
+
+ClientRectList* Element::getClientRects()
+{
+ Vector<FloatQuad> quads;
+ clientQuads(quads);
+ if (quads.isEmpty())
return ClientRectList::create();
- // FIXME: Handle SVG elements.
// FIXME: Handle table/inline-table with a caption.
rwlbuis 2016/09/19 17:24:59 Don't we want to keep these FIXMEs?
Shanmuga Pandi 2016/09/20 05:43:10 I kept the FIXME for table/inline-table... And rem
- Vector<FloatQuad> quads;
- elementLayoutObject->absoluteQuads(quads);
+ LayoutObject* elementLayoutObject = layoutObject();
+ DCHECK(elementLayoutObject);
document().adjustFloatQuadsForScrollAndAbsoluteZoom(quads, *elementLayoutObject);
return ClientRectList::create(quads);
}
ClientRect* Element::getBoundingClientRect()
{
- document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this);
-
Vector<FloatQuad> quads;
- LayoutObject* elementLayoutObject = layoutObject();
- if (elementLayoutObject) {
- if (isSVGElement() && !elementLayoutObject->isSVGRoot()) {
- // Get the bounding rectangle from the SVG model.
- if (toSVGElement(this)->isSVGGraphicsElement())
- quads.append(elementLayoutObject->localToAbsoluteQuad(elementLayoutObject->objectBoundingBox()));
- } else if (elementLayoutObject->isBoxModelObject() || elementLayoutObject->isBR()) {
- elementLayoutObject->absoluteQuads(quads);
- }
- }
-
+ clientQuads(quads);
if (quads.isEmpty())
return ClientRect::create();
@@ -1071,6 +1074,7 @@ ClientRect* Element::getBoundingClientRect()
for (size_t i = 1; i < quads.size(); ++i)
result.unite(quads[i].boundingBox());
+ LayoutObject* elementLayoutObject = layoutObject();
DCHECK(elementLayoutObject);
document().adjustFloatRectForScrollAndAbsoluteZoom(result, *elementLayoutObject);
return ClientRect::create(result);

Powered by Google App Engine
This is Rietveld 408576698