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..e6c91e7e1e9da57f2f52fe616126c056ade0a3ed 100644 |
--- a/third_party/WebKit/Source/core/dom/Element.cpp |
+++ b/third_party/WebKit/Source/core/dom/Element.cpp |
@@ -1013,15 +1013,9 @@ bool Element::hasNonEmptyLayoutSize() const |
return false; |
} |
-IntRect Element::boundsInViewport() |
+bool Element::getBoundingQuads(Vector<FloatQuad>& quads) |
{ |
- document().updateLayoutIgnorePendingStylesheets(); |
- |
- FrameView* view = document().view(); |
- if (!view) |
- return IntRect(); |
- |
- Vector<FloatQuad> quads; |
+ assert(quads.isEmpty()); |
if (isSVGElement() && layoutObject()) { |
// Get the bounding rectangle from the SVG model. |
if (toSVGElement(this)->isSVGGraphicsElement()) |
@@ -1031,8 +1025,19 @@ IntRect Element::boundsInViewport() |
if (layoutBoxModelObject()) |
layoutBoxModelObject()->absoluteQuads(quads); |
} |
+ return !quads.isEmpty(); |
+} |
- if (quads.isEmpty()) |
+IntRect Element::boundsInViewport() |
+{ |
+ document().updateLayoutIgnorePendingStylesheets(); |
+ |
+ FrameView* view = document().view(); |
+ if (!view) |
+ return IntRect(); |
+ |
+ Vector<FloatQuad> quads; |
+ if (!getBoundingQuads(quads)) |
return IntRect(); |
IntRect result = quads[0].enclosingBoundingBox(); |
@@ -1042,6 +1047,25 @@ IntRect Element::boundsInViewport() |
return view->contentsToViewport(result); |
} |
+FloatRect Element::boundsInViewportFloat() |
bokan
2015/12/10 14:48:39
Perhaps we should just make boundsInViewport retur
huangs
2015/12/10 16:16:14
Replied in main comment.
|
+{ |
+ document().updateLayoutIgnorePendingStylesheets(); |
+ |
+ FrameView* view = document().view(); |
+ if (!view) |
+ return FloatRect(); |
+ |
+ Vector<FloatQuad> quads; |
+ if (!getBoundingQuads(quads)) |
+ return FloatRect(); |
+ |
+ FloatRect result = quads[0].boundingBox(); |
+ for (size_t i = 1; i < quads.size(); ++i) |
+ result.unite(quads[i].boundingBox()); |
+ |
+ return view->contentsToViewport(result); |
+} |
+ |
ClientRectList* Element::getClientRects() |
{ |
document().updateLayoutIgnorePendingStylesheets(); |