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

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

Issue 2349653002: Added support of getClientRects() for SVG Elements. (Closed)
Patch Set: Align with review comments 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
« no previous file with comments | « third_party/WebKit/Source/core/dom/Element.h ('k') | no next file » | 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 a70da0b7f8cd17c79bc6ff87a8f3bde279ee877f..db5bb11eb01740dfeed5ad30be72edc0e40da1c0 100644
--- a/third_party/WebKit/Source/core/dom/Element.cpp
+++ b/third_party/WebKit/Source/core/dom/Element.cpp
@@ -1034,39 +1034,43 @@ 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()))
- return ClientRectList::create();
+ 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()));
+ return;
+ }
- // FIXME: Handle SVG elements.
// FIXME: Handle table/inline-table with a caption.
+ if (elementLayoutObject->isBoxModelObject() || elementLayoutObject->isBR())
+ elementLayoutObject->absoluteQuads(quads);
+}
+ClientRectList* Element::getClientRects()
+{
Vector<FloatQuad> quads;
- elementLayoutObject->absoluteQuads(quads);
+ clientQuads(quads);
+ if (quads.isEmpty())
+ return ClientRectList::create();
+
+ 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();
@@ -1074,6 +1078,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);
« no previous file with comments | « third_party/WebKit/Source/core/dom/Element.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698