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

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

Issue 1121633004: Revert Range firstNode/pastLastNode() refactoring. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Revert back to previous versions of firstNode/pastLastNode + add test Created 5 years, 7 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/range-toString-non-anchor-no-crash-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 e777350724f99d3ecc62789be5dc047c97a7e8cc..e4438717e0f3f9d886cd9f5ed90bdad76482f7d7 100644
--- a/Source/core/dom/Range.cpp
+++ b/Source/core/dom/Range.cpp
@@ -1329,7 +1329,13 @@ void Range::checkExtractPrecondition(ExceptionState& exceptionState)
Node* Range::firstNode() const
{
- return startPosition().toOffsetInAnchor().nodeAsRangeFirstNode();
+ if (m_start.container()->offsetInCharacters())
+ return m_start.container();
+ if (Node* child = NodeTraversal::childAt(*m_start.container(), m_start.offset()))
+ return child;
+ if (!m_start.offset())
+ return m_start.container();
+ return NodeTraversal::nextSkippingChildren(*m_start.container());
}
ShadowRoot* Range::shadowRoot() const
@@ -1339,7 +1345,11 @@ ShadowRoot* Range::shadowRoot() const
Node* Range::pastLastNode() const
{
- return endPosition().toOffsetInAnchor().nodeAsRangePastLastNode();
+ if (m_end.container()->offsetInCharacters())
+ return NodeTraversal::nextSkippingChildren(*m_end.container());
+ if (Node* child = NodeTraversal::childAt(*m_end.container(), m_end.offset()))
+ return child;
+ return NodeTraversal::nextSkippingChildren(*m_end.container());
}
IntRect Range::boundingBox() const
« no previous file with comments | « LayoutTests/fast/dom/Range/range-toString-non-anchor-no-crash-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698