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

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

Issue 100433008: Disable select api for input type number and email (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Updated as per code review Created 7 years 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 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 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 return HTMLTextFormControlElement::canStartSelection(); 514 return HTMLTextFormControlElement::canStartSelection();
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 (!m_inputType->supportsSelectionAPI()) {
525 exceptionState.throwDOMException(InvalidStateError, "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 (!m_inputType->supportsSelectionAPI()) {
534 exceptionState.throwDOMException(InvalidStateError, "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 (!m_inputType->supportsSelectionAPI()) {
543 exceptionState.throwDOMException(InvalidStateError, "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 (!m_inputType->supportsSelectionAPI()) {
552 exceptionState.throwDOMException(InvalidStateError, "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 (!m_inputType->supportsSelectionAPI()) {
561 exceptionState.throwDOMException(InvalidStateError, "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 (!m_inputType->supportsSelectionAPI()) {
570 exceptionState.throwDOMException(InvalidStateError, "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 (!m_inputType->supportsSelectionAPI()) {
579 exceptionState.throwDOMException(InvalidStateError, "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 (!m_inputType->supportsSelectionAPI()) {
588 exceptionState.throwDOMException(InvalidStateError, "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 }
(...skipping 1266 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « LayoutTests/fast/forms/selection-wrongtype-expected.txt ('k') | Source/core/html/forms/NumberInputType.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698