| Index: Source/WebCore/dom/Range.cpp
|
| diff --git a/Source/WebCore/dom/Range.cpp b/Source/WebCore/dom/Range.cpp
|
| index 423d43f26113c601e527b7521ecf2927fb6e095f..ee3272f7624f39392bb31e978434480cc20a6cf7 100644
|
| --- a/Source/WebCore/dom/Range.cpp
|
| +++ b/Source/WebCore/dom/Range.cpp
|
| @@ -1534,6 +1534,36 @@ bool Range::containedByReadOnly() const
|
| return false;
|
| }
|
|
|
| +bool Range::getLocationAndLength(unsigned& location, unsigned& length)
|
| +{
|
| + location = notFound;
|
| + length = 0;
|
| +
|
| + if (!startContainer())
|
| + return false;
|
| +
|
| + Element* selectionRoot = ownerDocument()->frame()->selection()->rootEditableElement();
|
| + Element* scope = selectionRoot ? selectionRoot : ownerDocument()->documentElement();
|
| +
|
| + // Mouse events may cause TSM to attempt to create an NSRange for a portion of the view
|
| + // that is not inside the current editable region. These checks ensure we don't produce
|
| + // potentially invalid data when responding to such requests.
|
| + if (startContainer() != scope && !startContainer()->isDescendantOf(scope))
|
| + return false;
|
| + if (endContainer() != scope && !endContainer()->isDescendantOf(scope))
|
| + return false;
|
| +
|
| + RefPtr<Range> testRange = Range::create(scope->document(), scope, 0, startContainer(), startOffset());
|
| + ASSERT(testRange->startContainer() == scope);
|
| + location = TextIterator::rangeLength(testRange.get());
|
| +
|
| + ExceptionCode ec;
|
| + testRange->setEnd(endContainer(), endOffset(), ec);
|
| + ASSERT(testRange->startContainer() == scope);
|
| + length = TextIterator::rangeLength(testRange.get()) - location;
|
| + return true;
|
| +}
|
| +
|
| Node* Range::firstNode() const
|
| {
|
| if (!m_start.container())
|
|
|