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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLTextFormControlElement.cpp

Issue 1417363002: Revert of Use FrameSelection::selectedText where possible. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 setSelectionRange(std::min(end, selectionStart()), end, selectionDirection() ); 182 setSelectionRange(std::min(end, selectionStart()), end, selectionDirection() );
183 } 183 }
184 184
185 void HTMLTextFormControlElement::setSelectionDirection(const String& direction) 185 void HTMLTextFormControlElement::setSelectionDirection(const String& direction)
186 { 186 {
187 setSelectionRange(selectionStart(), selectionEnd(), direction); 187 setSelectionRange(selectionStart(), selectionEnd(), direction);
188 } 188 }
189 189
190 void HTMLTextFormControlElement::select(NeedToDispatchSelectEvent eventBehaviour ) 190 void HTMLTextFormControlElement::select(NeedToDispatchSelectEvent eventBehaviour )
191 { 191 {
192 // We have to update layout here to use isFocusable().
193 document().updateLayoutIgnorePendingStylesheets(); 192 document().updateLayoutIgnorePendingStylesheets();
194 setSelectionRange(0, std::numeric_limits<int>::max(), SelectionHasNoDirectio n, eventBehaviour, isFocusable() ? ChangeSelectionAndFocus : NotChangeSelection) ; 193 setSelectionRange(0, std::numeric_limits<int>::max(), SelectionHasNoDirectio n, eventBehaviour, isFocusable() ? ChangeSelectionAndFocus : NotChangeSelection) ;
195 } 194 }
196 195
197 bool HTMLTextFormControlElement::shouldDispatchFormControlChangeEvent(String& ol dValue, String& newValue) 196 bool HTMLTextFormControlElement::shouldDispatchFormControlChangeEvent(String& ol dValue, String& newValue)
198 { 197 {
199 return !equalIgnoringNullity(oldValue, newValue); 198 return !equalIgnoringNullity(oldValue, newValue);
200 } 199 }
201 200
202 void HTMLTextFormControlElement::dispatchFormControlChangeEvent() 201 void HTMLTextFormControlElement::dispatchFormControlChangeEvent()
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 347
349 ASSERT(index >= 0); 348 ASSERT(index >= 0);
350 return index; 349 return index;
351 } 350 }
352 351
353 void HTMLTextFormControlElement::setSelectionRange(int start, int end, TextField SelectionDirection direction, NeedToDispatchSelectEvent eventBehaviour, Selectio nOption selectionOption) 352 void HTMLTextFormControlElement::setSelectionRange(int start, int end, TextField SelectionDirection direction, NeedToDispatchSelectEvent eventBehaviour, Selectio nOption selectionOption)
354 { 353 {
355 if (openShadowRoot() || !isTextFormControl() || !inDocument()) 354 if (openShadowRoot() || !isTextFormControl() || !inDocument())
356 return; 355 return;
357 356
358 // We need to update layout here so that we have proper types for both dom t ree and composed tree selection.
359 // See https://codereview.chromium.org/1377963004/
360 document().updateLayoutIgnorePendingStylesheets();
361
362 const int editorValueLength = static_cast<int>(innerEditorValue().length()); 357 const int editorValueLength = static_cast<int>(innerEditorValue().length());
363 ASSERT(editorValueLength >= 0); 358 ASSERT(editorValueLength >= 0);
364 end = std::max(std::min(end, editorValueLength), 0); 359 end = std::max(std::min(end, editorValueLength), 0);
365 start = std::min(std::max(start, 0), end); 360 start = std::min(std::max(start, 0), end);
366 cacheSelection(start, end, direction); 361 cacheSelection(start, end, direction);
367 362
368 if (selectionOption == NotChangeSelection || (selectionOption == ChangeSelec tionIfFocused && document().focusedElement() != this)) { 363 if (selectionOption == NotChangeSelection || (selectionOption == ChangeSelec tionIfFocused && document().focusedElement() != this)) {
369 if (eventBehaviour == DispatchSelectEvent) 364 if (eventBehaviour == DispatchSelectEvent)
370 scheduleSelectEvent(); 365 scheduleSelectEvent();
371 return; 366 return;
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
1020 } 1015 }
1021 1016
1022 void HTMLTextFormControlElement::copyNonAttributePropertiesFromElement(const Ele ment& source) 1017 void HTMLTextFormControlElement::copyNonAttributePropertiesFromElement(const Ele ment& source)
1023 { 1018 {
1024 const HTMLTextFormControlElement& sourceElement = static_cast<const HTMLText FormControlElement&>(source); 1019 const HTMLTextFormControlElement& sourceElement = static_cast<const HTMLText FormControlElement&>(source);
1025 m_lastChangeWasUserEdit = sourceElement.m_lastChangeWasUserEdit; 1020 m_lastChangeWasUserEdit = sourceElement.m_lastChangeWasUserEdit;
1026 HTMLFormControlElement::copyNonAttributePropertiesFromElement(source); 1021 HTMLFormControlElement::copyNonAttributePropertiesFromElement(source);
1027 } 1022 }
1028 1023
1029 } // namespace blink 1024 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698