| 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, 2008, 2009, 2010, 2011 Apple Inc. All r
ights reserved. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ights reserved. |
| 6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) | 6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) |
| 7 * Copyright (C) 2007 Samuel Weinig (sam@webkit.org) | 7 * Copyright (C) 2007 Samuel Weinig (sam@webkit.org) |
| 8 * Copyright (C) 2010 Google Inc. All rights reserved. | 8 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 9 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 9 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
| 10 * Copyright (C) 2012 Samsung Electronics. All rights reserved. | 10 * Copyright (C) 2012 Samsung Electronics. All rights reserved. |
| (...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 } | 515 } |
| 516 | 516 |
| 517 bool HTMLInputElement::canHaveSelection() const | 517 bool HTMLInputElement::canHaveSelection() const |
| 518 { | 518 { |
| 519 return isTextField(); | 519 return isTextField(); |
| 520 } | 520 } |
| 521 | 521 |
| 522 int HTMLInputElement::selectionStartForBinding(ExceptionState& exceptionState) c
onst | 522 int HTMLInputElement::selectionStartForBinding(ExceptionState& exceptionState) c
onst |
| 523 { | 523 { |
| 524 if (!canHaveSelection()) { | 524 if (!canHaveSelection()) { |
| 525 exceptionState.throwDOMException(InvalidStateError, ExceptionMessages::f
ailedToGet("selectionStart", "HTMLInputElement", "The input element's type ('" +
m_inputType->formControlType() + "') does not support selection.")); | 525 exceptionState.throwDOMException(InvalidStateError, "The input element's
type ('" + m_inputType->formControlType() + "') does not support selection."); |
| 526 return 0; | 526 return 0; |
| 527 } | 527 } |
| 528 return HTMLTextFormControlElement::selectionStart(); | 528 return HTMLTextFormControlElement::selectionStart(); |
| 529 } | 529 } |
| 530 | 530 |
| 531 int HTMLInputElement::selectionEndForBinding(ExceptionState& exceptionState) con
st | 531 int HTMLInputElement::selectionEndForBinding(ExceptionState& exceptionState) con
st |
| 532 { | 532 { |
| 533 if (!canHaveSelection()) { | 533 if (!canHaveSelection()) { |
| 534 exceptionState.throwDOMException(InvalidStateError, ExceptionMessages::f
ailedToGet("selectionEnd", "HTMLInputElement", "The input element's type ('" + m
_inputType->formControlType() + "') does not support selection.")); | 534 exceptionState.throwDOMException(InvalidStateError, "The input element'
s type ('" + m_inputType->formControlType() + "') does not support selection."); |
| 535 return 0; | 535 return 0; |
| 536 } | 536 } |
| 537 return HTMLTextFormControlElement::selectionEnd(); | 537 return HTMLTextFormControlElement::selectionEnd(); |
| 538 } | 538 } |
| 539 | 539 |
| 540 String HTMLInputElement::selectionDirectionForBinding(ExceptionState& exceptionS
tate) const | 540 String HTMLInputElement::selectionDirectionForBinding(ExceptionState& exceptionS
tate) const |
| 541 { | 541 { |
| 542 if (!canHaveSelection()) { | 542 if (!canHaveSelection()) { |
| 543 exceptionState.throwDOMException(InvalidStateError, ExceptionMessages::f
ailedToGet("selectionDirection", "HTMLInputElement", "The input element's type (
'" + m_inputType->formControlType() + "') does not support selection.")); | 543 exceptionState.throwDOMException(InvalidStateError, "The input element's
type ('" + m_inputType->formControlType() + "') does not support selection."); |
| 544 return String(); | 544 return String(); |
| 545 } | 545 } |
| 546 return HTMLTextFormControlElement::selectionDirection(); | 546 return HTMLTextFormControlElement::selectionDirection(); |
| 547 } | 547 } |
| 548 | 548 |
| 549 void HTMLInputElement::setSelectionStartForBinding(int start, ExceptionState& ex
ceptionState) | 549 void HTMLInputElement::setSelectionStartForBinding(int start, ExceptionState& ex
ceptionState) |
| 550 { | 550 { |
| 551 if (!canHaveSelection()) { | 551 if (!canHaveSelection()) { |
| 552 exceptionState.throwDOMException(InvalidStateError, ExceptionMessages::f
ailedToSet("selectionStart", "HTMLInputElement", "The input element's type ('" +
m_inputType->formControlType() + "') does not support selection.")); | 552 exceptionState.throwDOMException(InvalidStateError, "The input element's
type ('" + m_inputType->formControlType() + "') does not support selection."); |
| 553 return; | 553 return; |
| 554 } | 554 } |
| 555 HTMLTextFormControlElement::setSelectionStart(start); | 555 HTMLTextFormControlElement::setSelectionStart(start); |
| 556 } | 556 } |
| 557 | 557 |
| 558 void HTMLInputElement::setSelectionEndForBinding(int end, ExceptionState& except
ionState) | 558 void HTMLInputElement::setSelectionEndForBinding(int end, ExceptionState& except
ionState) |
| 559 { | 559 { |
| 560 if (!canHaveSelection()) { | 560 if (!canHaveSelection()) { |
| 561 exceptionState.throwDOMException(InvalidStateError, ExceptionMessages::f
ailedToSet("selectionEnd", "HTMLInputElement", "The input element's type ('" + m
_inputType->formControlType() + "') does not support selection.")); | 561 exceptionState.throwDOMException(InvalidStateError, "The input element's
type ('" + m_inputType->formControlType() + "') does not support selection."); |
| 562 return; | 562 return; |
| 563 } | 563 } |
| 564 HTMLTextFormControlElement::setSelectionEnd(end); | 564 HTMLTextFormControlElement::setSelectionEnd(end); |
| 565 } | 565 } |
| 566 | 566 |
| 567 void HTMLInputElement::setSelectionDirectionForBinding(const String& direction,
ExceptionState& exceptionState) | 567 void HTMLInputElement::setSelectionDirectionForBinding(const String& direction,
ExceptionState& exceptionState) |
| 568 { | 568 { |
| 569 if (!canHaveSelection()) { | 569 if (!canHaveSelection()) { |
| 570 exceptionState.throwDOMException(InvalidStateError, ExceptionMessages::f
ailedToSet("selectionDirection", "HTMLInputElement", "The input element's type (
'" + m_inputType->formControlType() + "') does not support selection.")); | 570 exceptionState.throwDOMException(InvalidStateError, "The input element's
type ('" + m_inputType->formControlType() + "') does not support selection."); |
| 571 return; | 571 return; |
| 572 } | 572 } |
| 573 HTMLTextFormControlElement::setSelectionDirection(direction); | 573 HTMLTextFormControlElement::setSelectionDirection(direction); |
| 574 } | 574 } |
| 575 | 575 |
| 576 void HTMLInputElement::setSelectionRangeForBinding(int start, int end, Exception
State& exceptionState) | 576 void HTMLInputElement::setSelectionRangeForBinding(int start, int end, Exception
State& exceptionState) |
| 577 { | 577 { |
| 578 if (!canHaveSelection()) { | 578 if (!canHaveSelection()) { |
| 579 exceptionState.throwDOMException(InvalidStateError, ExceptionMessages::f
ailedToSet("selectionRange", "HTMLInputElement", "The input element's type ('" +
m_inputType->formControlType() + "') does not support selection.")); | 579 exceptionState.throwDOMException(InvalidStateError, "The input element's
type ('" + m_inputType->formControlType() + "') does not support selection."); |
| 580 return; | 580 return; |
| 581 } | 581 } |
| 582 HTMLTextFormControlElement::setSelectionRange(start, end); | 582 HTMLTextFormControlElement::setSelectionRange(start, end); |
| 583 } | 583 } |
| 584 | 584 |
| 585 void HTMLInputElement::setSelectionRangeForBinding(int start, int end, const Str
ing& direction, ExceptionState& exceptionState) | 585 void HTMLInputElement::setSelectionRangeForBinding(int start, int end, const Str
ing& direction, ExceptionState& exceptionState) |
| 586 { | 586 { |
| 587 if (!canHaveSelection()) { | 587 if (!canHaveSelection()) { |
| 588 exceptionState.throwDOMException(InvalidStateError, ExceptionMessages::f
ailedToSet("selectionRange", "HTMLInputElement", "The input element's type ('" +
m_inputType->formControlType() + "') does not support selection.")); | 588 exceptionState.throwDOMException(InvalidStateError, "The input element's
type ('" + m_inputType->formControlType() + "') does not support selection."); |
| 589 return; | 589 return; |
| 590 } | 590 } |
| 591 HTMLTextFormControlElement::setSelectionRange(start, end, direction); | 591 HTMLTextFormControlElement::setSelectionRange(start, end, direction); |
| 592 } | 592 } |
| 593 | 593 |
| 594 void HTMLInputElement::accessKeyAction(bool sendMouseEvents) | 594 void HTMLInputElement::accessKeyAction(bool sendMouseEvents) |
| 595 { | 595 { |
| 596 m_inputType->accessKeyAction(sendMouseEvents); | 596 m_inputType->accessKeyAction(sendMouseEvents); |
| 597 } | 597 } |
| 598 | 598 |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 991 setSelectionRange(max, max); | 991 setSelectionRange(max, max); |
| 992 else | 992 else |
| 993 cacheSelectionInResponseToSetValue(max); | 993 cacheSelectionInResponseToSetValue(max); |
| 994 | 994 |
| 995 dispatchInputEvent(); | 995 dispatchInputEvent(); |
| 996 } | 996 } |
| 997 | 997 |
| 998 void HTMLInputElement::setValue(const String& value, ExceptionState& exceptionSt
ate, TextFieldEventBehavior eventBehavior) | 998 void HTMLInputElement::setValue(const String& value, ExceptionState& exceptionSt
ate, TextFieldEventBehavior eventBehavior) |
| 999 { | 999 { |
| 1000 if (isFileUpload() && !value.isEmpty()) { | 1000 if (isFileUpload() && !value.isEmpty()) { |
| 1001 exceptionState.throwDOMException(InvalidStateError, ExceptionMessages::f
ailedToSet("value", "HTMLInputElement", "This input element accepts a filename,
which may only be programatically set to the empty string.")); | 1001 exceptionState.throwDOMException(InvalidStateError, "This input element
accepts a filename, which may only be programatically set to the empty string.")
; |
| 1002 return; | 1002 return; |
| 1003 } | 1003 } |
| 1004 setValue(value, eventBehavior); | 1004 setValue(value, eventBehavior); |
| 1005 } | 1005 } |
| 1006 | 1006 |
| 1007 void HTMLInputElement::setValue(const String& value, TextFieldEventBehavior even
tBehavior) | 1007 void HTMLInputElement::setValue(const String& value, TextFieldEventBehavior even
tBehavior) |
| 1008 { | 1008 { |
| 1009 if (!m_inputType->canSetValue(value)) | 1009 if (!m_inputType->canSetValue(value)) |
| 1010 return; | 1010 return; |
| 1011 | 1011 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1046 } | 1046 } |
| 1047 | 1047 |
| 1048 double HTMLInputElement::valueAsNumber() const | 1048 double HTMLInputElement::valueAsNumber() const |
| 1049 { | 1049 { |
| 1050 return m_inputType->valueAsDouble(); | 1050 return m_inputType->valueAsDouble(); |
| 1051 } | 1051 } |
| 1052 | 1052 |
| 1053 void HTMLInputElement::setValueAsNumber(double newValue, ExceptionState& excepti
onState, TextFieldEventBehavior eventBehavior) | 1053 void HTMLInputElement::setValueAsNumber(double newValue, ExceptionState& excepti
onState, TextFieldEventBehavior eventBehavior) |
| 1054 { | 1054 { |
| 1055 if (!std::isfinite(newValue)) { | 1055 if (!std::isfinite(newValue)) { |
| 1056 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::f
ailedToSet("valueAsNumber", "HTMLInputElement", ExceptionMessages::notAFiniteNum
ber(newValue))); | 1056 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::n
otAFiniteNumber(newValue)); |
| 1057 return; | 1057 return; |
| 1058 } | 1058 } |
| 1059 m_inputType->setValueAsDouble(newValue, eventBehavior, exceptionState); | 1059 m_inputType->setValueAsDouble(newValue, eventBehavior, exceptionState); |
| 1060 } | 1060 } |
| 1061 | 1061 |
| 1062 void HTMLInputElement::setValueFromRenderer(const String& value) | 1062 void HTMLInputElement::setValueFromRenderer(const String& value) |
| 1063 { | 1063 { |
| 1064 // File upload controls will never use this. | 1064 // File upload controls will never use this. |
| 1065 ASSERT(!isFileUpload()); | 1065 ASSERT(!isFileUpload()); |
| 1066 | 1066 |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1280 } | 1280 } |
| 1281 | 1281 |
| 1282 int HTMLInputElement::maxLength() const | 1282 int HTMLInputElement::maxLength() const |
| 1283 { | 1283 { |
| 1284 return m_maxLength; | 1284 return m_maxLength; |
| 1285 } | 1285 } |
| 1286 | 1286 |
| 1287 void HTMLInputElement::setMaxLength(int maxLength, ExceptionState& exceptionStat
e) | 1287 void HTMLInputElement::setMaxLength(int maxLength, ExceptionState& exceptionStat
e) |
| 1288 { | 1288 { |
| 1289 if (maxLength < 0) | 1289 if (maxLength < 0) |
| 1290 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::fail
edToSet("maxLength", "HTMLInputElement", "The value provided (" + String::number
(maxLength) + ") is negative.")); | 1290 exceptionState.throwDOMException(IndexSizeError, "The value provided ("
+ String::number(maxLength) + ") is negative."); |
| 1291 else | 1291 else |
| 1292 setIntegralAttribute(maxlengthAttr, maxLength); | 1292 setIntegralAttribute(maxlengthAttr, maxLength); |
| 1293 } | 1293 } |
| 1294 | 1294 |
| 1295 bool HTMLInputElement::multiple() const | 1295 bool HTMLInputElement::multiple() const |
| 1296 { | 1296 { |
| 1297 return fastHasAttribute(multipleAttr); | 1297 return fastHasAttribute(multipleAttr); |
| 1298 } | 1298 } |
| 1299 | 1299 |
| 1300 void HTMLInputElement::setSize(unsigned size) | 1300 void HTMLInputElement::setSize(unsigned size) |
| 1301 { | 1301 { |
| 1302 setUnsignedIntegralAttribute(sizeAttr, size); | 1302 setUnsignedIntegralAttribute(sizeAttr, size); |
| 1303 } | 1303 } |
| 1304 | 1304 |
| 1305 void HTMLInputElement::setSize(unsigned size, ExceptionState& exceptionState) | 1305 void HTMLInputElement::setSize(unsigned size, ExceptionState& exceptionState) |
| 1306 { | 1306 { |
| 1307 if (!size) | 1307 if (!size) |
| 1308 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::fail
edToSet("size", "HTMLInputElement", "The value provided is 0, which is an invali
d size.")); | 1308 exceptionState.throwDOMException(IndexSizeError, "The value provided is
0, which is an invalid size."); |
| 1309 else | 1309 else |
| 1310 setSize(size); | 1310 setSize(size); |
| 1311 } | 1311 } |
| 1312 | 1312 |
| 1313 KURL HTMLInputElement::src() const | 1313 KURL HTMLInputElement::src() const |
| 1314 { | 1314 { |
| 1315 return document().completeURL(fastGetAttribute(srcAttr)); | 1315 return document().completeURL(fastGetAttribute(srcAttr)); |
| 1316 } | 1316 } |
| 1317 | 1317 |
| 1318 FileList* HTMLInputElement::files() | 1318 FileList* HTMLInputElement::files() |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1781 } | 1781 } |
| 1782 | 1782 |
| 1783 void ListAttributeTargetObserver::idTargetChanged() | 1783 void ListAttributeTargetObserver::idTargetChanged() |
| 1784 { | 1784 { |
| 1785 m_element->listAttributeTargetChanged(); | 1785 m_element->listAttributeTargetChanged(); |
| 1786 } | 1786 } |
| 1787 | 1787 |
| 1788 void HTMLInputElement::setRangeText(const String& replacement, ExceptionState& e
xceptionState) | 1788 void HTMLInputElement::setRangeText(const String& replacement, ExceptionState& e
xceptionState) |
| 1789 { | 1789 { |
| 1790 if (!m_inputType->supportsSelectionAPI()) { | 1790 if (!m_inputType->supportsSelectionAPI()) { |
| 1791 exceptionState.throwDOMException(InvalidStateError, ExceptionMessages::f
ailedToExecute("setRangeText", "HTMLInputElement", "The input element's type ('"
+ m_inputType->formControlType() + "') does not support selection.")); | 1791 exceptionState.throwDOMException(InvalidStateError, "The input element's
type ('" + m_inputType->formControlType() + "') does not support selection."); |
| 1792 return; | 1792 return; |
| 1793 } | 1793 } |
| 1794 | 1794 |
| 1795 HTMLTextFormControlElement::setRangeText(replacement, exceptionState); | 1795 HTMLTextFormControlElement::setRangeText(replacement, exceptionState); |
| 1796 } | 1796 } |
| 1797 | 1797 |
| 1798 void HTMLInputElement::setRangeText(const String& replacement, unsigned start, u
nsigned end, const String& selectionMode, ExceptionState& exceptionState) | 1798 void HTMLInputElement::setRangeText(const String& replacement, unsigned start, u
nsigned end, const String& selectionMode, ExceptionState& exceptionState) |
| 1799 { | 1799 { |
| 1800 if (!m_inputType->supportsSelectionAPI()) { | 1800 if (!m_inputType->supportsSelectionAPI()) { |
| 1801 exceptionState.throwDOMException(InvalidStateError, ExceptionMessages::f
ailedToExecute("setRangeText", "HTMLInputElement", "The input element's type ('"
+ m_inputType->formControlType() + "') does not support selection.")); | 1801 exceptionState.throwDOMException(InvalidStateError, "The input element's
type ('" + m_inputType->formControlType() + "') does not support selection."); |
| 1802 return; | 1802 return; |
| 1803 } | 1803 } |
| 1804 | 1804 |
| 1805 HTMLTextFormControlElement::setRangeText(replacement, start, end, selectionM
ode, exceptionState); | 1805 HTMLTextFormControlElement::setRangeText(replacement, start, end, selectionM
ode, exceptionState); |
| 1806 } | 1806 } |
| 1807 | 1807 |
| 1808 bool HTMLInputElement::setupDateTimeChooserParameters(DateTimeChooserParameters&
parameters) | 1808 bool HTMLInputElement::setupDateTimeChooserParameters(DateTimeChooserParameters&
parameters) |
| 1809 { | 1809 { |
| 1810 if (!document().view()) | 1810 if (!document().view()) |
| 1811 return false; | 1811 return false; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1864 } | 1864 } |
| 1865 | 1865 |
| 1866 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI) | 1866 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI) |
| 1867 PassRefPtr<RenderStyle> HTMLInputElement::customStyleForRenderer() | 1867 PassRefPtr<RenderStyle> HTMLInputElement::customStyleForRenderer() |
| 1868 { | 1868 { |
| 1869 return m_inputTypeView->customStyleForRenderer(originalStyleForRenderer()); | 1869 return m_inputTypeView->customStyleForRenderer(originalStyleForRenderer()); |
| 1870 } | 1870 } |
| 1871 #endif | 1871 #endif |
| 1872 | 1872 |
| 1873 } // namespace | 1873 } // namespace |
| OLD | NEW |