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

Unified Diff: third_party/WebKit/Source/core/html/TextControlElement.cpp

Issue 2727923002: Make TextControlElement::indexForVisiblePosition() not to use temporary Range (Closed)
Patch Set: 2017-03-02T16:16:45 Created 3 years, 10 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/html/TextControlElement.cpp
diff --git a/third_party/WebKit/Source/core/html/TextControlElement.cpp b/third_party/WebKit/Source/core/html/TextControlElement.cpp
index 0eebaaf7ec366b27396898a4b35485e085ad5e2c..71f9b7796e538155913811dbe66603e9239174dd 100644
--- a/third_party/WebKit/Source/core/html/TextControlElement.cpp
+++ b/third_party/WebKit/Source/core/html/TextControlElement.cpp
@@ -459,18 +459,16 @@ VisiblePosition TextControlElement::visiblePositionForIndex(int index) const {
return createVisiblePosition(it.endPosition(), TextAffinity::Upstream);
}
+// TODO(yosin): We should move |TextControlElement::indexForVisiblePosition()|
+// to "AXLayoutObject.cpp" since this funciton is used only there.
int TextControlElement::indexForVisiblePosition(
const VisiblePosition& pos) const {
Position indexPosition = pos.deepEquivalent().parentAnchoredEquivalent();
if (enclosingTextControl(indexPosition) != this)
return 0;
- DCHECK(indexPosition.document());
- Range* range = Range::create(*indexPosition.document());
- range->setStart(innerEditorElement(), 0, ASSERT_NO_EXCEPTION);
- range->setEnd(indexPosition.computeContainerNode(),
- indexPosition.offsetInContainerNode(), ASSERT_NO_EXCEPTION);
- return TextIterator::rangeLength(range->startPosition(),
- range->endPosition());
+ DCHECK(indexPosition.isConnected()) << indexPosition;
+ return TextIterator::rangeLength(Position(innerEditorElement(), 0),
+ indexPosition);
}
unsigned TextControlElement::selectionStart() const {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698