| OLD | NEW |
| 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 Loading... |
| 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 document().updateStyleAndLayoutIgnorePendingStylesheets(); | 192 setSelectionRange(0, std::numeric_limits<int>::max(), SelectionHasNoDirectio
n, eventBehaviour); |
| 193 setSelectionRange(0, std::numeric_limits<int>::max(), SelectionHasNoDirectio
n, eventBehaviour, isFocusable() ? ChangeSelectionAndFocus : NotChangeSelection)
; | 193 focus(); |
| 194 } | 194 } |
| 195 | 195 |
| 196 bool HTMLTextFormControlElement::shouldDispatchFormControlChangeEvent(String& ol
dValue, String& newValue) | 196 bool HTMLTextFormControlElement::shouldDispatchFormControlChangeEvent(String& ol
dValue, String& newValue) |
| 197 { | 197 { |
| 198 return !equalIgnoringNullity(oldValue, newValue); | 198 return !equalIgnoringNullity(oldValue, newValue); |
| 199 } | 199 } |
| 200 | 200 |
| 201 void HTMLTextFormControlElement::dispatchFormControlChangeEvent() | 201 void HTMLTextFormControlElement::dispatchFormControlChangeEvent() |
| 202 { | 202 { |
| 203 String newValue = value(); | 203 String newValue = value(); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 index += length; | 336 index += length; |
| 337 } else if (node->hasTagName(brTag)) { | 337 } else if (node->hasTagName(brTag)) { |
| 338 ++index; | 338 ++index; |
| 339 } | 339 } |
| 340 } | 340 } |
| 341 | 341 |
| 342 DCHECK_GE(index, 0); | 342 DCHECK_GE(index, 0); |
| 343 return index; | 343 return index; |
| 344 } | 344 } |
| 345 | 345 |
| 346 void HTMLTextFormControlElement::setSelectionRange(int start, int end, TextField
SelectionDirection direction, NeedToDispatchSelectEvent eventBehaviour, Selectio
nOption selectionOption) | 346 void HTMLTextFormControlElement::setSelectionRange(int start, int end, TextField
SelectionDirection direction, NeedToDispatchSelectEvent eventBehaviour) |
| 347 { | 347 { |
| 348 if (openShadowRoot() || !isTextFormControl()) | 348 if (openShadowRoot() || !isTextFormControl()) |
| 349 return; | 349 return; |
| 350 const int editorValueLength = static_cast<int>(innerEditorValue().length()); | 350 const int editorValueLength = static_cast<int>(innerEditorValue().length()); |
| 351 DCHECK_GE(editorValueLength, 0); | 351 DCHECK_GE(editorValueLength, 0); |
| 352 end = std::max(std::min(end, editorValueLength), 0); | 352 end = std::max(std::min(end, editorValueLength), 0); |
| 353 start = std::min(std::max(start, 0), end); | 353 start = std::min(std::max(start, 0), end); |
| 354 cacheSelection(start, end, direction); | 354 cacheSelection(start, end, direction); |
| 355 | 355 |
| 356 if (selectionOption == NotChangeSelection || (selectionOption == ChangeSelec
tionIfFocused && document().focusedElement() != this) || !isConnected()) { | 356 if (document().focusedElement() != this) { |
| 357 if (eventBehaviour == DispatchSelectEvent) | 357 if (eventBehaviour == DispatchSelectEvent) |
| 358 scheduleSelectEvent(); | 358 scheduleSelectEvent(); |
| 359 return; | 359 return; |
| 360 } | 360 } |
| 361 | 361 |
| 362 LocalFrame* frame = document().frame(); | 362 LocalFrame* frame = document().frame(); |
| 363 HTMLElement* innerEditor = innerEditorElement(); | 363 HTMLElement* innerEditor = innerEditorElement(); |
| 364 if (!frame || !innerEditor) | 364 if (!frame || !innerEditor) |
| 365 return; | 365 return; |
| 366 | 366 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 378 DCHECK_EQ(endPosition.anchorNode()->shadowHost(), this); | 378 DCHECK_EQ(endPosition.anchorNode()->shadowHost(), this); |
| 379 } | 379 } |
| 380 #endif // DCHECK_IS_ON() | 380 #endif // DCHECK_IS_ON() |
| 381 VisibleSelection newSelection; | 381 VisibleSelection newSelection; |
| 382 if (direction == SelectionHasBackwardDirection) | 382 if (direction == SelectionHasBackwardDirection) |
| 383 newSelection.setWithoutValidation(endPosition, startPosition); | 383 newSelection.setWithoutValidation(endPosition, startPosition); |
| 384 else | 384 else |
| 385 newSelection.setWithoutValidation(startPosition, endPosition); | 385 newSelection.setWithoutValidation(startPosition, endPosition); |
| 386 newSelection.setIsDirectional(direction != SelectionHasNoDirection); | 386 newSelection.setIsDirectional(direction != SelectionHasNoDirection); |
| 387 | 387 |
| 388 frame->selection().setSelection(newSelection, FrameSelection::DoNotAdjustInF
latTree | FrameSelection::CloseTyping | FrameSelection::ClearTypingStyle | (sele
ctionOption == ChangeSelectionAndFocus ? 0 : FrameSelection::DoNotSetFocus)); | 388 frame->selection().setSelection(newSelection, FrameSelection::DoNotAdjustInF
latTree | FrameSelection::CloseTyping | FrameSelection::ClearTypingStyle | Frame
Selection::DoNotSetFocus); |
| 389 if (eventBehaviour == DispatchSelectEvent) | 389 if (eventBehaviour == DispatchSelectEvent) |
| 390 scheduleSelectEvent(); | 390 scheduleSelectEvent(); |
| 391 } | 391 } |
| 392 | 392 |
| 393 VisiblePosition HTMLTextFormControlElement::visiblePositionForIndex(int index) c
onst | 393 VisiblePosition HTMLTextFormControlElement::visiblePositionForIndex(int index) c
onst |
| 394 { | 394 { |
| 395 if (index <= 0) | 395 if (index <= 0) |
| 396 return VisiblePosition::firstPositionInNode(innerEditorElement()); | 396 return VisiblePosition::firstPositionInNode(innerEditorElement()); |
| 397 Position start, end; | 397 Position start, end; |
| 398 bool selected = Range::selectNodeContents(innerEditorElement(), start, end); | 398 bool selected = Range::selectNodeContents(innerEditorElement(), start, end); |
| (...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1024 } | 1024 } |
| 1025 | 1025 |
| 1026 void HTMLTextFormControlElement::copyNonAttributePropertiesFromElement(const Ele
ment& source) | 1026 void HTMLTextFormControlElement::copyNonAttributePropertiesFromElement(const Ele
ment& source) |
| 1027 { | 1027 { |
| 1028 const HTMLTextFormControlElement& sourceElement = static_cast<const HTMLText
FormControlElement&>(source); | 1028 const HTMLTextFormControlElement& sourceElement = static_cast<const HTMLText
FormControlElement&>(source); |
| 1029 m_lastChangeWasUserEdit = sourceElement.m_lastChangeWasUserEdit; | 1029 m_lastChangeWasUserEdit = sourceElement.m_lastChangeWasUserEdit; |
| 1030 HTMLFormControlElement::copyNonAttributePropertiesFromElement(source); | 1030 HTMLFormControlElement::copyNonAttributePropertiesFromElement(source); |
| 1031 } | 1031 } |
| 1032 | 1032 |
| 1033 } // namespace blink | 1033 } // namespace blink |
| OLD | NEW |