Chromium Code Reviews| 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..f2c08bf49ed7d0e119a683b7c5ad83ad986052d4 100644 |
| --- a/third_party/WebKit/Source/core/dom/Element.cpp |
| +++ b/third_party/WebKit/Source/core/dom/Element.cpp |
| @@ -1034,39 +1034,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()) { |
|
fs
2016/09/29 12:04:21
Nit: While we're shuffling code, we could consider
Shanmuga Pandi
2016/09/29 13:14:13
Done.
|
| + 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. |
|
fs
2016/09/29 12:04:21
Nit: I guess this comment might be better suited f
Shanmuga Pandi
2016/09/29 13:14:12
Done.
|
| - 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(); |
| @@ -1074,6 +1077,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); |