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

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

Issue 6532004: DO NOT SUBMIT (Closed) Base URL: git://git.webkit.org/WebKit.git@master
Patch Set: Address feedback Created 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/WebCore/dom/Range.h ('k') | Source/WebCore/page/Frame.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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())
« no previous file with comments | « Source/WebCore/dom/Range.h ('k') | Source/WebCore/page/Frame.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698