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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 String newValue = value(); | 201 String newValue = value(); |
202 if (shouldDispatchFormControlChangeEvent(m_textAsOfLastFormControlChangeEven
t, newValue)) { | 202 if (shouldDispatchFormControlChangeEvent(m_textAsOfLastFormControlChangeEven
t, newValue)) { |
203 setTextAsOfLastFormControlChangeEvent(newValue); | 203 setTextAsOfLastFormControlChangeEvent(newValue); |
204 dispatchChangeEvent(); | 204 dispatchChangeEvent(); |
205 } | 205 } |
206 setChangedSinceLastFormControlChangeEvent(false); | 206 setChangedSinceLastFormControlChangeEvent(false); |
207 } | 207 } |
208 | 208 |
209 void HTMLTextFormControlElement::setRangeText(const String& replacement, Excepti
onState& exceptionState) | 209 void HTMLTextFormControlElement::setRangeText(const String& replacement, Excepti
onState& exceptionState) |
210 { | 210 { |
211 setRangeText(replacement, selectionStart(), selectionEnd(), String(), except
ionState); | 211 setRangeText(replacement, selectionStart(), selectionEnd(), "preserve", exce
ptionState); |
212 } | 212 } |
213 | 213 |
214 void HTMLTextFormControlElement::setRangeText(const String& replacement, unsigne
d start, unsigned end, const String& selectionMode, ExceptionState& exceptionSta
te) | 214 void HTMLTextFormControlElement::setRangeText(const String& replacement, unsigne
d start, unsigned end, const String& selectionMode, ExceptionState& exceptionSta
te) |
215 { | 215 { |
216 if (start > end) { | 216 if (start > end) { |
217 exceptionState.throwDOMException(IndexSizeError, "The provided start val
ue (" + String::number(start) + ") is larger than the provided end value (" + St
ring::number(end) + ")."); | 217 exceptionState.throwDOMException(IndexSizeError, "The provided start val
ue (" + String::number(start) + ") is larger than the provided end value (" + St
ring::number(end) + ")."); |
218 return; | 218 return; |
219 } | 219 } |
220 if (hasOpenShadowRoot()) | 220 if (hasOpenShadowRoot()) |
221 return; | 221 return; |
(...skipping 13 matching lines...) Expand all Loading... |
235 text.insert(replacement, start); | 235 text.insert(replacement, start); |
236 | 236 |
237 setInnerEditorValue(text); | 237 setInnerEditorValue(text); |
238 | 238 |
239 // FIXME: What should happen to the value (as in value()) if there's no layo
utObject? | 239 // FIXME: What should happen to the value (as in value()) if there's no layo
utObject? |
240 if (!layoutObject()) | 240 if (!layoutObject()) |
241 return; | 241 return; |
242 | 242 |
243 subtreeHasChanged(); | 243 subtreeHasChanged(); |
244 | 244 |
245 if (equalIgnoringCase(selectionMode, "select")) { | 245 if (selectionMode == "select") { |
246 newSelectionStart = start; | 246 newSelectionStart = start; |
247 newSelectionEnd = start + replacementLength; | 247 newSelectionEnd = start + replacementLength; |
248 } else if (equalIgnoringCase(selectionMode, "start")) { | 248 } else if (selectionMode == "start") { |
249 newSelectionStart = newSelectionEnd = start; | 249 newSelectionStart = newSelectionEnd = start; |
250 } else if (equalIgnoringCase(selectionMode, "end")) { | 250 } else if (selectionMode == "end") { |
251 newSelectionStart = newSelectionEnd = start + replacementLength; | 251 newSelectionStart = newSelectionEnd = start + replacementLength; |
252 } else { | 252 } else { |
253 // Default is "preserve". | 253 ASSERT(selectionMode == "preserve"); |
254 long delta = replacementLength - (end - start); | 254 long delta = replacementLength - (end - start); |
255 | 255 |
256 if (newSelectionStart > end) | 256 if (newSelectionStart > end) |
257 newSelectionStart += delta; | 257 newSelectionStart += delta; |
258 else if (newSelectionStart > start) | 258 else if (newSelectionStart > start) |
259 newSelectionStart = start; | 259 newSelectionStart = start; |
260 | 260 |
261 if (newSelectionEnd > end) | 261 if (newSelectionEnd > end) |
262 newSelectionEnd += delta; | 262 newSelectionEnd += delta; |
263 else if (newSelectionEnd > start) | 263 else if (newSelectionEnd > start) |
(...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1009 } | 1009 } |
1010 | 1010 |
1011 void HTMLTextFormControlElement::copyNonAttributePropertiesFromElement(const Ele
ment& source) | 1011 void HTMLTextFormControlElement::copyNonAttributePropertiesFromElement(const Ele
ment& source) |
1012 { | 1012 { |
1013 const HTMLTextFormControlElement& sourceElement = static_cast<const HTMLText
FormControlElement&>(source); | 1013 const HTMLTextFormControlElement& sourceElement = static_cast<const HTMLText
FormControlElement&>(source); |
1014 m_lastChangeWasUserEdit = sourceElement.m_lastChangeWasUserEdit; | 1014 m_lastChangeWasUserEdit = sourceElement.m_lastChangeWasUserEdit; |
1015 HTMLFormControlElement::copyNonAttributePropertiesFromElement(source); | 1015 HTMLFormControlElement::copyNonAttributePropertiesFromElement(source); |
1016 } | 1016 } |
1017 | 1017 |
1018 } // namespace blink | 1018 } // namespace blink |
OLD | NEW |