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

Unified Diff: Source/core/html/HTMLTextFormControlElement.cpp

Issue 1269263003: The start and end arguments should be unsigned long in setSelectionRange() function Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixing tests Created 5 years, 4 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/core/html/HTMLTextFormControlElement.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/HTMLTextFormControlElement.cpp
diff --git a/Source/core/html/HTMLTextFormControlElement.cpp b/Source/core/html/HTMLTextFormControlElement.cpp
index 1cfab17e841ced2e367b7ad2c8c31777f1636fdc..bcdd82a7d0d7d3dc4a4f6b27c5247945a490ef5b 100644
--- a/Source/core/html/HTMLTextFormControlElement.cpp
+++ b/Source/core/html/HTMLTextFormControlElement.cpp
@@ -266,7 +266,7 @@ void HTMLTextFormControlElement::setRangeText(const String& replacement, unsigne
setSelectionRange(newSelectionStart, newSelectionEnd, SelectionHasNoDirection);
}
-void HTMLTextFormControlElement::setSelectionRange(int start, int end, const String& directionString)
+void HTMLTextFormControlElement::setSelectionRange(unsigned start, unsigned end, const String& directionString)
{
TextFieldSelectionDirection direction = SelectionHasNoDirection;
if (directionString == "forward")
@@ -346,15 +346,15 @@ static int indexForPosition(HTMLElement* innerEditor, const Position& passedPosi
return index;
}
-void HTMLTextFormControlElement::setSelectionRange(int start, int end, TextFieldSelectionDirection direction, NeedToDispatchSelectEvent eventBehaviour, SelectionOption selectionOption)
+void HTMLTextFormControlElement::setSelectionRange(unsigned start, unsigned end, TextFieldSelectionDirection direction, NeedToDispatchSelectEvent eventBehaviour, SelectionOption selectionOption)
{
if (openShadowRoot() || !isTextFormControl() || !inDocument())
return;
const int editorValueLength = static_cast<int>(innerEditorValue().length());
philipj_slow 2015/08/12 13:20:03 Making this unsigned now would make more sense.
tanay.c 2015/08/14 05:39:11 Done.
ASSERT(editorValueLength >= 0);
- end = std::max(std::min(end, editorValueLength), 0);
- start = std::min(std::max(start, 0), end);
+ end = std::min<unsigned>(end, editorValueLength);
+ start = std::min<unsigned>(start, end);
cacheSelection(start, end, direction);
if (selectionOption == NotChangeSelection || (selectionOption == ChangeSelectionIfFocused && document().focusedElement() != this)) {
@@ -371,8 +371,8 @@ void HTMLTextFormControlElement::setSelectionRange(int start, int end, TextField
Position startPosition = positionForIndex(innerEditor, start);
Position endPosition = start == end ? startPosition : positionForIndex(innerEditor, end);
- ASSERT(start == indexForPosition(innerEditor, startPosition));
- ASSERT(end == indexForPosition(innerEditor, endPosition));
+ ASSERT(start == (unsigned)indexForPosition(innerEditor, startPosition));
philipj_slow 2015/08/12 13:20:03 So indexForPosition() still returns int. It looks
tanay.c 2015/08/14 05:39:11 It may not be possible to find a clean cut boundar
+ ASSERT(end == (unsigned)indexForPosition(innerEditor, endPosition));
// startPosition and endPosition can be null position for example when
// "-webkit-user-select: none" style attribute is specified.
« no previous file with comments | « Source/core/html/HTMLTextFormControlElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698