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

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

Issue 14859003: Remove the compile time flag for DATALIST Element. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 7 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 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 #if ENABLE(INPUT_SPEECH) 81 #if ENABLE(INPUT_SPEECH)
82 #include "RuntimeEnabledFeatures.h" 82 #include "RuntimeEnabledFeatures.h"
83 #endif 83 #endif
84 84
85 using namespace std; 85 using namespace std;
86 86
87 namespace WebCore { 87 namespace WebCore {
88 88
89 using namespace HTMLNames; 89 using namespace HTMLNames;
90 90
91 #if ENABLE(DATALIST_ELEMENT)
92 class ListAttributeTargetObserver : IdTargetObserver { 91 class ListAttributeTargetObserver : IdTargetObserver {
93 WTF_MAKE_FAST_ALLOCATED; 92 WTF_MAKE_FAST_ALLOCATED;
94 public: 93 public:
95 static PassOwnPtr<ListAttributeTargetObserver> create(const AtomicString& id , HTMLInputElement*); 94 static PassOwnPtr<ListAttributeTargetObserver> create(const AtomicString& id , HTMLInputElement*);
96 virtual void idTargetChanged() OVERRIDE; 95 virtual void idTargetChanged() OVERRIDE;
97 96
98 private: 97 private:
99 ListAttributeTargetObserver(const AtomicString& id, HTMLInputElement*); 98 ListAttributeTargetObserver(const AtomicString& id, HTMLInputElement*);
100 99
101 HTMLInputElement* m_element; 100 HTMLInputElement* m_element;
102 }; 101 };
103 #endif
104 102
105 // FIXME: According to HTML4, the length attribute's value can be arbitrarily 103 // FIXME: According to HTML4, the length attribute's value can be arbitrarily
106 // large. However, due to https://bugs.webkit.org/show_bug.cgi?id=14536 things 104 // large. However, due to https://bugs.webkit.org/show_bug.cgi?id=14536 things
107 // get rather sluggish when a text field has a larger number of characters than 105 // get rather sluggish when a text field has a larger number of characters than
108 // this, even when just clicking in the text field. 106 // this, even when just clicking in the text field.
109 const int HTMLInputElement::maximumLength = 524288; 107 const int HTMLInputElement::maximumLength = 524288;
110 const int defaultSize = 20; 108 const int defaultSize = 20;
111 const int maxSavedResults = 256; 109 const int maxSavedResults = 256;
112 110
113 HTMLInputElement::HTMLInputElement(const QualifiedName& tagName, Document* docum ent, HTMLFormElement* form, bool createdByParser) 111 HTMLInputElement::HTMLInputElement(const QualifiedName& tagName, Document* docum ent, HTMLFormElement* form, bool createdByParser)
114 : HTMLTextFormControlElement(tagName, document, form) 112 : HTMLTextFormControlElement(tagName, document, form)
115 , m_size(defaultSize) 113 , m_size(defaultSize)
116 , m_maxLength(maximumLength) 114 , m_maxLength(maximumLength)
117 , m_maxResults(-1) 115 , m_maxResults(-1)
118 , m_isChecked(false) 116 , m_isChecked(false)
119 , m_reflectsCheckedAttribute(true) 117 , m_reflectsCheckedAttribute(true)
120 , m_isIndeterminate(false) 118 , m_isIndeterminate(false)
121 , m_hasType(false) 119 , m_hasType(false)
122 , m_isActivatedSubmit(false) 120 , m_isActivatedSubmit(false)
123 , m_autocomplete(Uninitialized) 121 , m_autocomplete(Uninitialized)
124 , m_isAutofilled(false) 122 , m_isAutofilled(false)
125 #if ENABLE(DATALIST_ELEMENT)
126 , m_hasNonEmptyList(false) 123 , m_hasNonEmptyList(false)
127 #endif
128 , m_stateRestored(false) 124 , m_stateRestored(false)
129 , m_parsingInProgress(createdByParser) 125 , m_parsingInProgress(createdByParser)
130 , m_valueAttributeWasUpdatedAfterParsing(false) 126 , m_valueAttributeWasUpdatedAfterParsing(false)
131 , m_wasModifiedByUser(false) 127 , m_wasModifiedByUser(false)
132 , m_canReceiveDroppedFiles(false) 128 , m_canReceiveDroppedFiles(false)
133 , m_hasTouchEventHandler(false) 129 , m_hasTouchEventHandler(false)
134 , m_inputType(InputType::createText(this)) 130 , m_inputType(InputType::createText(this))
135 { 131 {
136 ASSERT(hasTagName(inputTag) || hasTagName(isindexTag)); 132 ASSERT(hasTagName(inputTag) || hasTagName(isindexTag));
137 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI) 133 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 bool HTMLInputElement::getAllowedValueStep(Decimal* step) const 334 bool HTMLInputElement::getAllowedValueStep(Decimal* step) const
339 { 335 {
340 return m_inputType->getAllowedValueStep(step); 336 return m_inputType->getAllowedValueStep(step);
341 } 337 }
342 338
343 StepRange HTMLInputElement::createStepRange(AnyStepHandling anyStepHandling) con st 339 StepRange HTMLInputElement::createStepRange(AnyStepHandling anyStepHandling) con st
344 { 340 {
345 return m_inputType->createStepRange(anyStepHandling); 341 return m_inputType->createStepRange(anyStepHandling);
346 } 342 }
347 343
348 #if ENABLE(DATALIST_ELEMENT)
349 Decimal HTMLInputElement::findClosestTickMarkValue(const Decimal& value) 344 Decimal HTMLInputElement::findClosestTickMarkValue(const Decimal& value)
350 { 345 {
351 return m_inputType->findClosestTickMarkValue(value); 346 return m_inputType->findClosestTickMarkValue(value);
352 } 347 }
353 #endif
354 348
355 void HTMLInputElement::stepUp(int n, ExceptionCode& ec) 349 void HTMLInputElement::stepUp(int n, ExceptionCode& ec)
356 { 350 {
357 m_inputType->stepUp(n, ec); 351 m_inputType->stepUp(n, ec);
358 } 352 }
359 353
360 void HTMLInputElement::stepDown(int n, ExceptionCode& ec) 354 void HTMLInputElement::stepDown(int n, ExceptionCode& ec)
361 { 355 {
362 m_inputType->stepUp(-n, ec); 356 m_inputType->stepUp(-n, ec);
363 } 357 }
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 } else if (name == precisionAttr) { 691 } else if (name == precisionAttr) {
698 setNeedsValidityCheck(); 692 setNeedsValidityCheck();
699 UseCounter::count(document(), UseCounter::PrecisionAttribute); 693 UseCounter::count(document(), UseCounter::PrecisionAttribute);
700 } else if (name == disabledAttr) { 694 } else if (name == disabledAttr) {
701 HTMLTextFormControlElement::parseAttribute(name, value); 695 HTMLTextFormControlElement::parseAttribute(name, value);
702 m_inputType->disabledAttributeChanged(); 696 m_inputType->disabledAttributeChanged();
703 } else if (name == readonlyAttr) { 697 } else if (name == readonlyAttr) {
704 HTMLTextFormControlElement::parseAttribute(name, value); 698 HTMLTextFormControlElement::parseAttribute(name, value);
705 m_inputType->readonlyAttributeChanged(); 699 m_inputType->readonlyAttributeChanged();
706 } 700 }
707 #if ENABLE(DATALIST_ELEMENT)
708 else if (name == listAttr) { 701 else if (name == listAttr) {
709 m_hasNonEmptyList = !value.isEmpty(); 702 m_hasNonEmptyList = !value.isEmpty();
710 if (m_hasNonEmptyList) { 703 if (m_hasNonEmptyList) {
711 resetListAttributeTargetObserver(); 704 resetListAttributeTargetObserver();
712 listAttributeTargetChanged(); 705 listAttributeTargetChanged();
713 } 706 }
714 UseCounter::count(document(), UseCounter::ListAttribute); 707 UseCounter::count(document(), UseCounter::ListAttribute);
715 } 708 }
716 #endif
717 #if ENABLE(INPUT_SPEECH) 709 #if ENABLE(INPUT_SPEECH)
718 else if (name == webkitspeechAttr) { 710 else if (name == webkitspeechAttr) {
719 if (renderer()) { 711 if (renderer()) {
720 // This renderer and its children have quite different layouts and s tyles depending on 712 // This renderer and its children have quite different layouts and s tyles depending on
721 // whether the speech button is visible or not. So we reset the whol e thing and recreate 713 // whether the speech button is visible or not. So we reset the whol e thing and recreate
722 // to get the right styles and layout. 714 // to get the right styles and layout.
723 detach(); 715 detach();
724 m_inputType->destroyShadowSubtree(); 716 m_inputType->destroyShadowSubtree();
725 m_inputType->createShadowSubtree(); 717 m_inputType->createShadowSubtree();
726 if (!attached()) 718 if (!attached())
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after
1428 { 1420 {
1429 HTMLTextFormControlElement::didChangeForm(); 1421 HTMLTextFormControlElement::didChangeForm();
1430 addToRadioButtonGroup(); 1422 addToRadioButtonGroup();
1431 } 1423 }
1432 1424
1433 Node::InsertionNotificationRequest HTMLInputElement::insertedInto(ContainerNode* insertionPoint) 1425 Node::InsertionNotificationRequest HTMLInputElement::insertedInto(ContainerNode* insertionPoint)
1434 { 1426 {
1435 HTMLTextFormControlElement::insertedInto(insertionPoint); 1427 HTMLTextFormControlElement::insertedInto(insertionPoint);
1436 if (insertionPoint->inDocument() && !form()) 1428 if (insertionPoint->inDocument() && !form())
1437 addToRadioButtonGroup(); 1429 addToRadioButtonGroup();
1438 #if ENABLE(DATALIST_ELEMENT)
1439 resetListAttributeTargetObserver(); 1430 resetListAttributeTargetObserver();
1440 #endif
1441 return InsertionDone; 1431 return InsertionDone;
1442 } 1432 }
1443 1433
1444 void HTMLInputElement::removedFrom(ContainerNode* insertionPoint) 1434 void HTMLInputElement::removedFrom(ContainerNode* insertionPoint)
1445 { 1435 {
1446 if (insertionPoint->inDocument() && !form()) 1436 if (insertionPoint->inDocument() && !form())
1447 removeFromRadioButtonGroup(); 1437 removeFromRadioButtonGroup();
1448 HTMLTextFormControlElement::removedFrom(insertionPoint); 1438 HTMLTextFormControlElement::removedFrom(insertionPoint);
1449 ASSERT(!inDocument()); 1439 ASSERT(!inDocument());
1450 #if ENABLE(DATALIST_ELEMENT)
1451 resetListAttributeTargetObserver(); 1440 resetListAttributeTargetObserver();
1452 #endif
1453 } 1441 }
1454 1442
1455 void HTMLInputElement::didMoveToNewDocument(Document* oldDocument) 1443 void HTMLInputElement::didMoveToNewDocument(Document* oldDocument)
1456 { 1444 {
1457 if (hasImageLoader()) 1445 if (hasImageLoader())
1458 imageLoader()->elementDidMoveToNewDocument(); 1446 imageLoader()->elementDidMoveToNewDocument();
1459 1447
1460 if (oldDocument) { 1448 if (oldDocument) {
1461 if (isRadioButton()) 1449 if (isRadioButton())
1462 oldDocument->formController()->checkedRadioButtons().removeButton(th is); 1450 oldDocument->formController()->checkedRadioButtons().removeButton(th is);
(...skipping 29 matching lines...) Expand all
1492 1480
1493 #if ENABLE(INPUT_TYPE_COLOR) 1481 #if ENABLE(INPUT_TYPE_COLOR)
1494 void HTMLInputElement::selectColorInColorChooser(const Color& color) 1482 void HTMLInputElement::selectColorInColorChooser(const Color& color)
1495 { 1483 {
1496 if (!m_inputType->isColorControl()) 1484 if (!m_inputType->isColorControl())
1497 return; 1485 return;
1498 static_cast<ColorInputType*>(m_inputType.get())->didChooseColor(color); 1486 static_cast<ColorInputType*>(m_inputType.get())->didChooseColor(color);
1499 } 1487 }
1500 #endif 1488 #endif
1501 1489
1502 #if ENABLE(DATALIST_ELEMENT)
1503 HTMLElement* HTMLInputElement::list() const 1490 HTMLElement* HTMLInputElement::list() const
1504 { 1491 {
1505 return dataList(); 1492 return dataList();
1506 } 1493 }
1507 1494
1508 HTMLDataListElement* HTMLInputElement::dataList() const 1495 HTMLDataListElement* HTMLInputElement::dataList() const
1509 { 1496 {
1510 if (!m_hasNonEmptyList) 1497 if (!m_hasNonEmptyList)
1511 return 0; 1498 return 0;
1512 1499
(...skipping 14 matching lines...) Expand all
1527 if (inDocument()) 1514 if (inDocument())
1528 m_listAttributeTargetObserver = ListAttributeTargetObserver::create(fast GetAttribute(listAttr), this); 1515 m_listAttributeTargetObserver = ListAttributeTargetObserver::create(fast GetAttribute(listAttr), this);
1529 else 1516 else
1530 m_listAttributeTargetObserver = nullptr; 1517 m_listAttributeTargetObserver = nullptr;
1531 } 1518 }
1532 1519
1533 void HTMLInputElement::listAttributeTargetChanged() 1520 void HTMLInputElement::listAttributeTargetChanged()
1534 { 1521 {
1535 m_inputType->listAttributeTargetChanged(); 1522 m_inputType->listAttributeTargetChanged();
1536 } 1523 }
1537 #endif // ENABLE(DATALIST_ELEMENT)
1538 1524
1539 bool HTMLInputElement::isSteppable() const 1525 bool HTMLInputElement::isSteppable() const
1540 { 1526 {
1541 return m_inputType->isSteppable(); 1527 return m_inputType->isSteppable();
1542 } 1528 }
1543 1529
1544 #if ENABLE(INPUT_SPEECH) 1530 #if ENABLE(INPUT_SPEECH)
1545 1531
1546 bool HTMLInputElement::isSpeechEnabled() const 1532 bool HTMLInputElement::isSpeechEnabled() const
1547 { 1533 {
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
1795 void HTMLInputElement::setHeight(unsigned height) 1781 void HTMLInputElement::setHeight(unsigned height)
1796 { 1782 {
1797 setAttribute(heightAttr, String::number(height)); 1783 setAttribute(heightAttr, String::number(height));
1798 } 1784 }
1799 1785
1800 void HTMLInputElement::setWidth(unsigned width) 1786 void HTMLInputElement::setWidth(unsigned width)
1801 { 1787 {
1802 setAttribute(widthAttr, String::number(width)); 1788 setAttribute(widthAttr, String::number(width));
1803 } 1789 }
1804 1790
1805 #if ENABLE(DATALIST_ELEMENT)
1806 PassOwnPtr<ListAttributeTargetObserver> ListAttributeTargetObserver::create(cons t AtomicString& id, HTMLInputElement* element) 1791 PassOwnPtr<ListAttributeTargetObserver> ListAttributeTargetObserver::create(cons t AtomicString& id, HTMLInputElement* element)
1807 { 1792 {
1808 return adoptPtr(new ListAttributeTargetObserver(id, element)); 1793 return adoptPtr(new ListAttributeTargetObserver(id, element));
1809 } 1794 }
1810 1795
1811 ListAttributeTargetObserver::ListAttributeTargetObserver(const AtomicString& id, HTMLInputElement* element) 1796 ListAttributeTargetObserver::ListAttributeTargetObserver(const AtomicString& id, HTMLInputElement* element)
1812 : IdTargetObserver(element->treeScope()->idTargetObserverRegistry(), id) 1797 : IdTargetObserver(element->treeScope()->idTargetObserverRegistry(), id)
1813 , m_element(element) 1798 , m_element(element)
1814 { 1799 {
1815 } 1800 }
1816 1801
1817 void ListAttributeTargetObserver::idTargetChanged() 1802 void ListAttributeTargetObserver::idTargetChanged()
1818 { 1803 {
1819 m_element->listAttributeTargetChanged(); 1804 m_element->listAttributeTargetChanged();
1820 } 1805 }
1821 #endif
1822 1806
1823 void HTMLInputElement::setRangeText(const String& replacement, ExceptionCode& ec ) 1807 void HTMLInputElement::setRangeText(const String& replacement, ExceptionCode& ec )
1824 { 1808 {
1825 if (!m_inputType->supportsSelectionAPI()) { 1809 if (!m_inputType->supportsSelectionAPI()) {
1826 ec = INVALID_STATE_ERR; 1810 ec = INVALID_STATE_ERR;
1827 return; 1811 return;
1828 } 1812 }
1829 1813
1830 HTMLTextFormControlElement::setRangeText(replacement, ec); 1814 HTMLTextFormControlElement::setRangeText(replacement, ec);
1831 } 1815 }
(...skipping 29 matching lines...) Expand all
1861 parameters.step = stepRange.step().toDouble(); 1845 parameters.step = stepRange.step().toDouble();
1862 parameters.stepBase = stepRange.stepBase().toDouble(); 1846 parameters.stepBase = stepRange.stepBase().toDouble();
1863 } else { 1847 } else {
1864 parameters.step = 1.0; 1848 parameters.step = 1.0;
1865 parameters.stepBase = 0; 1849 parameters.stepBase = 0;
1866 } 1850 }
1867 1851
1868 parameters.anchorRectInRootView = document()->view()->contentsToRootView(pix elSnappedBoundingBox()); 1852 parameters.anchorRectInRootView = document()->view()->contentsToRootView(pix elSnappedBoundingBox());
1869 parameters.currentValue = value(); 1853 parameters.currentValue = value();
1870 parameters.isAnchorElementRTL = computedStyle()->direction() == RTL; 1854 parameters.isAnchorElementRTL = computedStyle()->direction() == RTL;
1871 #if ENABLE(DATALIST_ELEMENT)
1872 if (HTMLDataListElement* dataList = this->dataList()) { 1855 if (HTMLDataListElement* dataList = this->dataList()) {
1873 RefPtr<HTMLCollection> options = dataList->options(); 1856 RefPtr<HTMLCollection> options = dataList->options();
1874 for (unsigned i = 0; HTMLOptionElement* option = toHTMLOptionElement(opt ions->item(i)); ++i) { 1857 for (unsigned i = 0; HTMLOptionElement* option = toHTMLOptionElement(opt ions->item(i)); ++i) {
1875 if (!isValidValue(option->value())) 1858 if (!isValidValue(option->value()))
1876 continue; 1859 continue;
1877 parameters.suggestionValues.append(sanitizeValue(option->value())); 1860 parameters.suggestionValues.append(sanitizeValue(option->value()));
1878 parameters.localizedSuggestionValues.append(localizeValue(option->va lue())); 1861 parameters.localizedSuggestionValues.append(localizeValue(option->va lue()));
1879 parameters.suggestionLabels.append(option->value() == option->label( ) ? String() : option->label()); 1862 parameters.suggestionLabels.append(option->value() == option->label( ) ? String() : option->label());
1880 } 1863 }
1881 } 1864 }
1882 #endif
1883 return true; 1865 return true;
1884 } 1866 }
1885 1867
1886 void HTMLInputElement::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) con st 1868 void HTMLInputElement::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) con st
1887 { 1869 {
1888 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM); 1870 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM);
1889 HTMLTextFormControlElement::reportMemoryUsage(memoryObjectInfo); 1871 HTMLTextFormControlElement::reportMemoryUsage(memoryObjectInfo);
1890 info.addMember(m_name, "name"); 1872 info.addMember(m_name, "name");
1891 info.addMember(m_valueIfDirty, "valueIfDirty"); 1873 info.addMember(m_valueIfDirty, "valueIfDirty");
1892 info.addMember(m_suggestedValue, "suggestedValue"); 1874 info.addMember(m_suggestedValue, "suggestedValue");
1893 info.addMember(m_inputType, "inputType"); 1875 info.addMember(m_inputType, "inputType");
1894 #if ENABLE(DATALIST_ELEMENT)
1895 info.addMember(m_listAttributeTargetObserver, "listAttributeTargetObserver") ; 1876 info.addMember(m_listAttributeTargetObserver, "listAttributeTargetObserver") ;
1896 #endif
1897 } 1877 }
1898 1878
1899 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI) 1879 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
1900 PassRefPtr<RenderStyle> HTMLInputElement::customStyleForRenderer() 1880 PassRefPtr<RenderStyle> HTMLInputElement::customStyleForRenderer()
1901 { 1881 {
1902 return m_inputType->customStyleForRenderer(document()->styleResolver()->styl eForElement(this)); 1882 return m_inputType->customStyleForRenderer(document()->styleResolver()->styl eForElement(this));
1903 } 1883 }
1904 #endif 1884 #endif
1905 1885
1906 } // namespace 1886 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698