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

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

Issue 2706033004: Don't throw when getting selection(Direction|Start|End) on input (Closed)
Patch Set: Created 3 years, 10 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 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, 2008, 2009, 2010, 2011 Apple Inc. All 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
6 * rights reserved. 6 * rights reserved.
7 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 7 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
8 * Copyright (C) 2007 Samuel Weinig (sam@webkit.org) 8 * Copyright (C) 2007 Samuel Weinig (sam@webkit.org)
9 * Copyright (C) 2010 Google Inc. All rights reserved. 9 * Copyright (C) 2010 Google Inc. All rights reserved.
10 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. 10 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved.
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 m_stateRestored = true; 542 m_stateRestored = true;
543 } 543 }
544 544
545 bool HTMLInputElement::canStartSelection() const { 545 bool HTMLInputElement::canStartSelection() const {
546 if (!isTextField()) 546 if (!isTextField())
547 return false; 547 return false;
548 return TextControlElement::canStartSelection(); 548 return TextControlElement::canStartSelection();
549 } 549 }
550 550
551 unsigned HTMLInputElement::selectionStartForBinding( 551 unsigned HTMLInputElement::selectionStartForBinding(
552 bool& isNull,
552 ExceptionState& exceptionState) const { 553 ExceptionState& exceptionState) const {
553 if (!m_inputType->supportsSelectionAPI()) { 554 if (!m_inputType->supportsSelectionAPI()) {
554 UseCounter::count(document(), UseCounter::InputSelectionGettersThrow); 555 isNull = true;
555 exceptionState.throwDOMException(InvalidStateError,
556 "The input element's type ('" +
557 m_inputType->formControlType() +
558 "') does not support selection.");
559 return 0; 556 return 0;
560 } 557 }
561 return TextControlElement::selectionStart(); 558 return TextControlElement::selectionStart();
562 } 559 }
563 560
564 unsigned HTMLInputElement::selectionEndForBinding( 561 unsigned HTMLInputElement::selectionEndForBinding(
562 bool& isNull,
565 ExceptionState& exceptionState) const { 563 ExceptionState& exceptionState) const {
566 if (!m_inputType->supportsSelectionAPI()) { 564 if (!m_inputType->supportsSelectionAPI()) {
567 UseCounter::count(document(), UseCounter::InputSelectionGettersThrow); 565 isNull = true;
568 exceptionState.throwDOMException(InvalidStateError,
569 "The input element's type ('" +
570 m_inputType->formControlType() +
571 "') does not support selection.");
572 return 0; 566 return 0;
573 } 567 }
574 return TextControlElement::selectionEnd(); 568 return TextControlElement::selectionEnd();
575 } 569 }
576 570
577 String HTMLInputElement::selectionDirectionForBinding( 571 String HTMLInputElement::selectionDirectionForBinding(
578 ExceptionState& exceptionState) const { 572 ExceptionState& exceptionState) const {
579 if (!m_inputType->supportsSelectionAPI()) { 573 if (!m_inputType->supportsSelectionAPI()) {
580 UseCounter::count(document(), UseCounter::InputSelectionGettersThrow);
581 exceptionState.throwDOMException(InvalidStateError,
582 "The input element's type ('" +
583 m_inputType->formControlType() +
584 "') does not support selection.");
585 return String(); 574 return String();
586 } 575 }
587 return TextControlElement::selectionDirection(); 576 return TextControlElement::selectionDirection();
588 } 577 }
589 578
590 void HTMLInputElement::setSelectionStartForBinding( 579 void HTMLInputElement::setSelectionStartForBinding(
591 unsigned start, 580 unsigned start,
592 ExceptionState& exceptionState) { 581 ExceptionState& exceptionState) {
593 if (!m_inputType->supportsSelectionAPI()) { 582 if (!m_inputType->supportsSelectionAPI()) {
594 exceptionState.throwDOMException(InvalidStateError, 583 exceptionState.throwDOMException(InvalidStateError,
(...skipping 1291 matching lines...) Expand 10 before | Expand all | Expand 10 after
1886 1875
1887 bool HTMLInputElement::hasFallbackContent() const { 1876 bool HTMLInputElement::hasFallbackContent() const {
1888 return m_inputTypeView->hasFallbackContent(); 1877 return m_inputTypeView->hasFallbackContent();
1889 } 1878 }
1890 1879
1891 void HTMLInputElement::setFilesFromPaths(const Vector<String>& paths) { 1880 void HTMLInputElement::setFilesFromPaths(const Vector<String>& paths) {
1892 return m_inputType->setFilesFromPaths(paths); 1881 return m_inputType->setFilesFromPaths(paths);
1893 } 1882 }
1894 1883
1895 } // namespace blink 1884 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698