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

Unified Diff: Source/core/dom/Range.cpp

Issue 998263002: range.getBoundingClientRect() returns incorrect value for collapsed ranges (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 9 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 | « LayoutTests/fast/dom/Range/getBoundingClientRect-caret-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/Range.cpp
diff --git a/Source/core/dom/Range.cpp b/Source/core/dom/Range.cpp
index a27e461926f28db32139dffb77454fcbbe4abe0f..449aa66d63792d1272a6c3902ad4e7ad79c00a41 100644
--- a/Source/core/dom/Range.cpp
+++ b/Source/core/dom/Range.cpp
@@ -1775,9 +1775,18 @@ FloatRect Range::boundingRect() const
Vector<FloatQuad> quads;
getBorderAndTextQuads(quads);
+ if (quads.isEmpty())
+ return FloatRect();
+
FloatRect result;
- for (const FloatQuad& quad : quads)
- result.unite(quad.boundingBox());
+ for (const FloatQuad& quad : quads) {
+ if (result.isEmpty()) {
+ result = quad.boundingBox();
+ continue;
+ }
+
+ result.uniteEvenIfEmpty(quad.boundingBox());
+ }
return result;
}
« no previous file with comments | « LayoutTests/fast/dom/Range/getBoundingClientRect-caret-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698