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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « LayoutTests/fast/dom/Range/getBoundingClientRect-caret-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * (C) 1999 Lars Knoll (knoll@kde.org) 2 * (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Gunnstein Lye (gunnstein@netcom.no) 3 * (C) 2000 Gunnstein Lye (gunnstein@netcom.no)
4 * (C) 2000 Frederik Holljen (frederik.holljen@hig.no) 4 * (C) 2000 Frederik Holljen (frederik.holljen@hig.no)
5 * (C) 2001 Peter Kelly (pmk@post.com) 5 * (C) 2001 Peter Kelly (pmk@post.com)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved.
7 * Copyright (C) 2011 Motorola Mobility. All rights reserved. 7 * Copyright (C) 2011 Motorola Mobility. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 1757 matching lines...) Expand 10 before | Expand all | Expand 10 after
1768 } 1768 }
1769 } 1769 }
1770 1770
1771 FloatRect Range::boundingRect() const 1771 FloatRect Range::boundingRect() const
1772 { 1772 {
1773 m_ownerDocument->updateLayoutIgnorePendingStylesheets(); 1773 m_ownerDocument->updateLayoutIgnorePendingStylesheets();
1774 1774
1775 Vector<FloatQuad> quads; 1775 Vector<FloatQuad> quads;
1776 getBorderAndTextQuads(quads); 1776 getBorderAndTextQuads(quads);
1777 1777
1778 if (quads.isEmpty())
1779 return FloatRect();
1780
1778 FloatRect result; 1781 FloatRect result;
1779 for (const FloatQuad& quad : quads) 1782 for (const FloatQuad& quad : quads) {
1780 result.unite(quad.boundingBox()); 1783 if (result.isEmpty()) {
1784 result = quad.boundingBox();
1785 continue;
1786 }
1787
1788 result.uniteEvenIfEmpty(quad.boundingBox());
1789 }
1781 1790
1782 return result; 1791 return result;
1783 } 1792 }
1784 1793
1785 DEFINE_TRACE(Range) 1794 DEFINE_TRACE(Range)
1786 { 1795 {
1787 visitor->trace(m_ownerDocument); 1796 visitor->trace(m_ownerDocument);
1788 visitor->trace(m_start); 1797 visitor->trace(m_start);
1789 visitor->trace(m_end); 1798 visitor->trace(m_end);
1790 } 1799 }
1791 1800
1792 } // namespace blink 1801 } // namespace blink
1793 1802
1794 #ifndef NDEBUG 1803 #ifndef NDEBUG
1795 1804
1796 void showTree(const blink::Range* range) 1805 void showTree(const blink::Range* range)
1797 { 1806 {
1798 if (range && range->boundaryPointsValid()) { 1807 if (range && range->boundaryPointsValid()) {
1799 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r ange->endContainer(), "E"); 1808 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r ange->endContainer(), "E");
1800 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset (), range->endOffset()); 1809 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset (), range->endOffset());
1801 } 1810 }
1802 } 1811 }
1803 1812
1804 #endif 1813 #endif
OLDNEW
« 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