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

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

Issue 2750833002: TextControlElement::selection() should return SelectionInDOMTree. (Closed)
Patch Set: Y Created 3 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 | « third_party/WebKit/Source/core/html/TextControlElement.h ('k') | 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 36a1878ddcf5e579f9967e30bf62b5da92a2dcec..fe6bc4dd67228a527780da6a31fe2220fc264e85 100644
--- a/third_party/WebKit/Source/core/html/TextControlElement.cpp
+++ b/third_party/WebKit/Source/core/html/TextControlElement.cpp
@@ -608,9 +608,9 @@ static inline void setContainerAndOffsetForRange(Node* node,
}
}
-Range* TextControlElement::selection() const {
+SelectionInDOMTree TextControlElement::selection() const {
if (!layoutObject() || !isTextControl())
- return nullptr;
+ return SelectionInDOMTree();
int start = m_cachedSelectionStart;
int end = m_cachedSelectionEnd;
@@ -618,10 +618,14 @@ Range* TextControlElement::selection() const {
DCHECK_LE(start, end);
HTMLElement* innerText = innerEditorElement();
if (!innerText)
- return nullptr;
+ return SelectionInDOMTree();
- if (!innerText->hasChildren())
- return Range::create(document(), innerText, 0, innerText, 0);
+ if (!innerText->hasChildren()) {
+ return SelectionInDOMTree::Builder()
+ .collapse(Position(innerText, 0))
+ .setIsDirectional(selectionDirection() != "none")
+ .build();
+ }
int offset = 0;
Node* startNode = 0;
@@ -643,9 +647,12 @@ Range* TextControlElement::selection() const {
}
if (!startNode || !endNode)
- return nullptr;
+ return SelectionInDOMTree();
- return Range::create(document(), startNode, start, endNode, end);
+ return SelectionInDOMTree::Builder()
+ .setBaseAndExtent(Position(startNode, start), Position(endNode, end))
+ .setIsDirectional(selectionDirection() != "none")
+ .build();
}
const AtomicString& TextControlElement::autocapitalize() const {
« no previous file with comments | « third_party/WebKit/Source/core/html/TextControlElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698