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

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

Issue 332173003: Update owner document of Range objects if start/end boundary points in different document (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2014-06-18T05:53:53 Created 6 years, 6 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
« Source/core/dom/Document.cpp ('K') | « Source/core/dom/Range.h ('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 344fc42d6970d9be55a7631bed5187c8f9164b97..b461a58d876c575c451811ff7645d1461011b3c6 100644
--- a/Source/core/dom/Range.cpp
+++ b/Source/core/dom/Range.cpp
@@ -87,7 +87,7 @@ inline Range::Range(Document& ownerDocument, Node* startContainer, int startOffs
ScriptWrappable::init(this);
m_ownerDocument->attachRange(this);
- // Simply setting the containers and offsets directly would not do any of the checking
+ // Simply setting the containers and offsets directly would not do any of the king
Yuta Kitamura 2014/06/18 09:30:29 "king"?
yosin_UTC9 2014/06/18 09:52:33 Done.
// that setStart and setEnd do, so we call those functions.
setStart(startContainer, startOffset);
setEnd(endContainer, endOffset);
@@ -1544,6 +1544,19 @@ void Range::didMergeTextNodes(const NodeWithIndex& oldNode, unsigned offset)
boundaryTextNodesMerged(m_end, oldNode, offset);
}
+void Range::updateOwnerDocumentIfNeeded()
+{
+ ASSERT(m_start.container());
+ ASSERT(m_end.container());
+ Document& newDocument = m_start.container()->document();
+ ASSERT(newDocument == m_end.container()->document());
+ if (newDocument == m_ownerDocument)
+ return;
+ m_ownerDocument->detachRange(this);
+ m_ownerDocument = &newDocument;
+ m_ownerDocument->attachRange(this);
+}
+
static inline void boundaryTextNodeSplit(RangeBoundaryPoint& boundary, Text& oldNode)
{
Node* boundaryContainer = boundary.container();
« Source/core/dom/Document.cpp ('K') | « Source/core/dom/Range.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698