From 0bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5 Mon Sep 17 00:00:00 2001 From: Ben Murdoch Date: Tue, 11 Aug 2009 17:01:47 +0100 Subject: Merge in WebKit r47029. --- WebCore/dom/Range.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'WebCore/dom/Range.cpp') diff --git a/WebCore/dom/Range.cpp b/WebCore/dom/Range.cpp index 8a3ca8f..edee305 100644 --- a/WebCore/dom/Range.cpp +++ b/WebCore/dom/Range.cpp @@ -90,13 +90,14 @@ PassRefPtr Range::create(PassRefPtr ownerDocument, PassRefPtr Range::create(PassRefPtr ownerDocument, const Position& start, const Position& end) { + // FIXME: we shouldn't be using deprecatedEditingOffset here return adoptRef(new Range(ownerDocument, start.node(), start.deprecatedEditingOffset(), end.node(), end.deprecatedEditingOffset())); } Range::~Range() { - if (m_start.container()) - m_ownerDocument->detachRange(this); + // Always detach (even if we've already detached) to fix https://bugs.webkit.org/show_bug.cgi?id=26044 + m_ownerDocument->detachRange(this); #ifndef NDEBUG rangeCounter.decrement(); @@ -294,7 +295,7 @@ bool Range::isPointInRange(Node* refNode, int offset, ExceptionCode& ec) && compareBoundaryPoints(refNode, offset, m_end.container(), m_end.offset()) <= 0; } -short Range::comparePoint(Node* refNode, int offset, ExceptionCode& ec) +short Range::comparePoint(Node* refNode, int offset, ExceptionCode& ec) const { // http://developer.mozilla.org/en/docs/DOM:range.comparePoint // This method returns -1, 0 or 1 depending on if the point described by the @@ -332,7 +333,7 @@ short Range::comparePoint(Node* refNode, int offset, ExceptionCode& ec) return 0; } -Range::CompareResults Range::compareNode(Node* refNode, ExceptionCode& ec) +Range::CompareResults Range::compareNode(Node* refNode, ExceptionCode& ec) const { // http://developer.mozilla.org/en/docs/DOM:range.compareNode // This method returns 0, 1, 2, or 3 based on if the node is before, after, @@ -379,7 +380,6 @@ Range::CompareResults Range::compareNode(Node* refNode, ExceptionCode& ec) } } - short Range::compareBoundaryPoints(CompareHow how, const Range* sourceRange, ExceptionCode& ec) const { if (!m_start.container()) { @@ -726,7 +726,7 @@ PassRefPtr Range::processContents(ActionType action, Exception for (; leftParent != commonRoot; leftParent = leftParent->parentNode()) { if (action == EXTRACT_CONTENTS || action == CLONE_CONTENTS) { RefPtr leftContentsParent = leftParent->cloneNode(false); - leftContentsParent->appendChild(leftContents,ec); + leftContentsParent->appendChild(leftContents, ec); leftContents = leftContentsParent; } @@ -734,11 +734,11 @@ PassRefPtr Range::processContents(ActionType action, Exception for (; n; n = next) { next = n->nextSibling(); if (action == EXTRACT_CONTENTS) - leftContents->appendChild(n,ec); // will remove n from leftParent + leftContents->appendChild(n, ec); // will remove n from leftParent else if (action == CLONE_CONTENTS) - leftContents->appendChild(n->cloneNode(true),ec); + leftContents->appendChild(n->cloneNode(true), ec); else - leftParent->removeChild(n,ec); + leftParent->removeChild(n, ec); } n = leftParent->nextSibling(); } @@ -796,7 +796,7 @@ PassRefPtr Range::processContents(ActionType action, Exception for (; rightParent != commonRoot; rightParent = rightParent->parentNode()) { if (action == EXTRACT_CONTENTS || action == CLONE_CONTENTS) { RefPtr rightContentsParent = rightParent->cloneNode(false); - rightContentsParent->appendChild(rightContents,ec); + rightContentsParent->appendChild(rightContents, ec); rightContents = rightContentsParent; } Node* prev; @@ -1070,6 +1070,7 @@ PassRefPtr Range::createContextualFragment(const String& marku void Range::detach(ExceptionCode& ec) { + // Check first to see if we've already detached: if (!m_start.container()) { ec = INVALID_STATE_ERR; return; -- cgit v1.1