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

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: Add <datalist> display:none rule in RenderTheme::extraDefaultStyleSheet depending on the runtime fl… 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 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 UseCounter::count(document(), UseCounter::PatternAttribute); 687 UseCounter::count(document(), UseCounter::PatternAttribute);
694 } else if (name == precisionAttr) { 688 } else if (name == precisionAttr) {
695 setNeedsValidityCheck(); 689 setNeedsValidityCheck();
696 UseCounter::count(document(), UseCounter::PrecisionAttribute); 690 UseCounter::count(document(), UseCounter::PrecisionAttribute);
697 } else if (name == disabledAttr) { 691 } else if (name == disabledAttr) {
698 HTMLTextFormControlElement::parseAttribute(name, value); 692 HTMLTextFormControlElement::parseAttribute(name, value);
699 m_inputType->disabledAttributeChanged(); 693 m_inputType->disabledAttributeChanged();
700 } else if (name == readonlyAttr) { 694 } else if (name == readonlyAttr) {
701 HTMLTextFormControlElement::parseAttribute(name, value); 695 HTMLTextFormControlElement::parseAttribute(name, value);
702 m_inputType->readonlyAttributeChanged(); 696 m_inputType->readonlyAttributeChanged();
703 } 697 }
tkent 2013/05/20 21:32:11 should be "} else if (..."
704 #if ENABLE(DATALIST_ELEMENT)
705 else if (name == listAttr) { 698 else if (name == listAttr) {
706 m_hasNonEmptyList = !value.isEmpty(); 699 m_hasNonEmptyList = !value.isEmpty();
707 if (m_hasNonEmptyList) { 700 if (m_hasNonEmptyList) {
708 resetListAttributeTargetObserver(); 701 resetListAttributeTargetObserver();
709 listAttributeTargetChanged(); 702 listAttributeTargetChanged();
710 } 703 }
711 UseCounter::count(document(), UseCounter::ListAttribute); 704 UseCounter::count(document(), UseCounter::ListAttribute);
712 } 705 }
713 #endif
714 #if ENABLE(INPUT_SPEECH) 706 #if ENABLE(INPUT_SPEECH)
715 else if (name == webkitspeechAttr) { 707 else if (name == webkitspeechAttr) {
716 if (renderer()) { 708 if (renderer()) {
717 // This renderer and its children have quite different layouts and s tyles depending on 709 // This renderer and its children have quite different layouts and s tyles depending on
718 // whether the speech button is visible or not. So we reset the whol e thing and recreate 710 // whether the speech button is visible or not. So we reset the whol e thing and recreate
719 // to get the right styles and layout. 711 // to get the right styles and layout.
720 detach(); 712 detach();
721 m_inputType->destroyShadowSubtree(); 713 m_inputType->destroyShadowSubtree();
722 m_inputType->createShadowSubtree(); 714 m_inputType->createShadowSubtree();
723 if (!attached()) 715 if (!attached())
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after
1418 { 1410 {
1419 HTMLTextFormControlElement::didChangeForm(); 1411 HTMLTextFormControlElement::didChangeForm();
1420 addToRadioButtonGroup(); 1412 addToRadioButtonGroup();
1421 } 1413 }
1422 1414
1423 Node::InsertionNotificationRequest HTMLInputElement::insertedInto(ContainerNode* insertionPoint) 1415 Node::InsertionNotificationRequest HTMLInputElement::insertedInto(ContainerNode* insertionPoint)
1424 { 1416 {
1425 HTMLTextFormControlElement::insertedInto(insertionPoint); 1417 HTMLTextFormControlElement::insertedInto(insertionPoint);
1426 if (insertionPoint->inDocument() && !form()) 1418 if (insertionPoint->inDocument() && !form())
1427 addToRadioButtonGroup(); 1419 addToRadioButtonGroup();
1428 #if ENABLE(DATALIST_ELEMENT)
1429 resetListAttributeTargetObserver(); 1420 resetListAttributeTargetObserver();
1430 #endif
1431 return InsertionDone; 1421 return InsertionDone;
1432 } 1422 }
1433 1423
1434 void HTMLInputElement::removedFrom(ContainerNode* insertionPoint) 1424 void HTMLInputElement::removedFrom(ContainerNode* insertionPoint)
1435 { 1425 {
1436 if (insertionPoint->inDocument() && !form()) 1426 if (insertionPoint->inDocument() && !form())
1437 removeFromRadioButtonGroup(); 1427 removeFromRadioButtonGroup();
1438 HTMLTextFormControlElement::removedFrom(insertionPoint); 1428 HTMLTextFormControlElement::removedFrom(insertionPoint);
1439 ASSERT(!inDocument()); 1429 ASSERT(!inDocument());
1440 #if ENABLE(DATALIST_ELEMENT)
1441 resetListAttributeTargetObserver(); 1430 resetListAttributeTargetObserver();
1442 #endif
1443 } 1431 }
1444 1432
1445 void HTMLInputElement::didMoveToNewDocument(Document* oldDocument) 1433 void HTMLInputElement::didMoveToNewDocument(Document* oldDocument)
1446 { 1434 {
1447 if (hasImageLoader()) 1435 if (hasImageLoader())
1448 imageLoader()->elementDidMoveToNewDocument(); 1436 imageLoader()->elementDidMoveToNewDocument();
1449 1437
1450 if (oldDocument) { 1438 if (oldDocument) {
1451 if (isRadioButton()) 1439 if (isRadioButton())
1452 oldDocument->formController()->checkedRadioButtons().removeButton(th is); 1440 oldDocument->formController()->checkedRadioButtons().removeButton(th is);
(...skipping 29 matching lines...) Expand all
1482 1470
1483 #if ENABLE(INPUT_TYPE_COLOR) 1471 #if ENABLE(INPUT_TYPE_COLOR)
1484 void HTMLInputElement::selectColorInColorChooser(const Color& color) 1472 void HTMLInputElement::selectColorInColorChooser(const Color& color)
1485 { 1473 {
1486 if (!m_inputType->isColorControl()) 1474 if (!m_inputType->isColorControl())
1487 return; 1475 return;
1488 static_cast<ColorInputType*>(m_inputType.get())->didChooseColor(color); 1476 static_cast<ColorInputType*>(m_inputType.get())->didChooseColor(color);
1489 } 1477 }
1490 #endif 1478 #endif
1491 1479
1492 #if ENABLE(DATALIST_ELEMENT)
1493 HTMLElement* HTMLInputElement::list() const 1480 HTMLElement* HTMLInputElement::list() const
1494 { 1481 {
1495 return dataList(); 1482 return dataList();
1496 } 1483 }
1497 1484
1498 HTMLDataListElement* HTMLInputElement::dataList() const 1485 HTMLDataListElement* HTMLInputElement::dataList() const
1499 { 1486 {
1500 if (!m_hasNonEmptyList) 1487 if (!m_hasNonEmptyList)
1501 return 0; 1488 return 0;
1502 1489
(...skipping 14 matching lines...) Expand all
1517 if (inDocument()) 1504 if (inDocument())
1518 m_listAttributeTargetObserver = ListAttributeTargetObserver::create(fast GetAttribute(listAttr), this); 1505 m_listAttributeTargetObserver = ListAttributeTargetObserver::create(fast GetAttribute(listAttr), this);
1519 else 1506 else
1520 m_listAttributeTargetObserver = nullptr; 1507 m_listAttributeTargetObserver = nullptr;
1521 } 1508 }
1522 1509
1523 void HTMLInputElement::listAttributeTargetChanged() 1510 void HTMLInputElement::listAttributeTargetChanged()
1524 { 1511 {
1525 m_inputType->listAttributeTargetChanged(); 1512 m_inputType->listAttributeTargetChanged();
1526 } 1513 }
1527 #endif // ENABLE(DATALIST_ELEMENT)
1528 1514
1529 bool HTMLInputElement::isSteppable() const 1515 bool HTMLInputElement::isSteppable() const
1530 { 1516 {
1531 return m_inputType->isSteppable(); 1517 return m_inputType->isSteppable();
1532 } 1518 }
1533 1519
1534 #if ENABLE(INPUT_SPEECH) 1520 #if ENABLE(INPUT_SPEECH)
1535 1521
1536 bool HTMLInputElement::isSpeechEnabled() const 1522 bool HTMLInputElement::isSpeechEnabled() const
1537 { 1523 {
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
1780 void HTMLInputElement::setHeight(unsigned height) 1766 void HTMLInputElement::setHeight(unsigned height)
1781 { 1767 {
1782 setAttribute(heightAttr, String::number(height)); 1768 setAttribute(heightAttr, String::number(height));
1783 } 1769 }
1784 1770
1785 void HTMLInputElement::setWidth(unsigned width) 1771 void HTMLInputElement::setWidth(unsigned width)
1786 { 1772 {
1787 setAttribute(widthAttr, String::number(width)); 1773 setAttribute(widthAttr, String::number(width));
1788 } 1774 }
1789 1775
1790 #if ENABLE(DATALIST_ELEMENT)
1791 PassOwnPtr<ListAttributeTargetObserver> ListAttributeTargetObserver::create(cons t AtomicString& id, HTMLInputElement* element) 1776 PassOwnPtr<ListAttributeTargetObserver> ListAttributeTargetObserver::create(cons t AtomicString& id, HTMLInputElement* element)
1792 { 1777 {
1793 return adoptPtr(new ListAttributeTargetObserver(id, element)); 1778 return adoptPtr(new ListAttributeTargetObserver(id, element));
1794 } 1779 }
1795 1780
1796 ListAttributeTargetObserver::ListAttributeTargetObserver(const AtomicString& id, HTMLInputElement* element) 1781 ListAttributeTargetObserver::ListAttributeTargetObserver(const AtomicString& id, HTMLInputElement* element)
1797 : IdTargetObserver(element->treeScope()->idTargetObserverRegistry(), id) 1782 : IdTargetObserver(element->treeScope()->idTargetObserverRegistry(), id)
1798 , m_element(element) 1783 , m_element(element)
1799 { 1784 {
1800 } 1785 }
1801 1786
1802 void ListAttributeTargetObserver::idTargetChanged() 1787 void ListAttributeTargetObserver::idTargetChanged()
1803 { 1788 {
1804 m_element->listAttributeTargetChanged(); 1789 m_element->listAttributeTargetChanged();
1805 } 1790 }
1806 #endif
1807 1791
1808 void HTMLInputElement::setRangeText(const String& replacement, ExceptionCode& ec ) 1792 void HTMLInputElement::setRangeText(const String& replacement, ExceptionCode& ec )
1809 { 1793 {
1810 if (!m_inputType->supportsSelectionAPI()) { 1794 if (!m_inputType->supportsSelectionAPI()) {
1811 ec = INVALID_STATE_ERR; 1795 ec = INVALID_STATE_ERR;
1812 return; 1796 return;
1813 } 1797 }
1814 1798
1815 HTMLTextFormControlElement::setRangeText(replacement, ec); 1799 HTMLTextFormControlElement::setRangeText(replacement, ec);
1816 } 1800 }
(...skipping 29 matching lines...) Expand all
1846 parameters.step = stepRange.step().toDouble(); 1830 parameters.step = stepRange.step().toDouble();
1847 parameters.stepBase = stepRange.stepBase().toDouble(); 1831 parameters.stepBase = stepRange.stepBase().toDouble();
1848 } else { 1832 } else {
1849 parameters.step = 1.0; 1833 parameters.step = 1.0;
1850 parameters.stepBase = 0; 1834 parameters.stepBase = 0;
1851 } 1835 }
1852 1836
1853 parameters.anchorRectInRootView = document()->view()->contentsToRootView(pix elSnappedBoundingBox()); 1837 parameters.anchorRectInRootView = document()->view()->contentsToRootView(pix elSnappedBoundingBox());
1854 parameters.currentValue = value(); 1838 parameters.currentValue = value();
1855 parameters.isAnchorElementRTL = computedStyle()->direction() == RTL; 1839 parameters.isAnchorElementRTL = computedStyle()->direction() == RTL;
1856 #if ENABLE(DATALIST_ELEMENT)
1857 if (HTMLDataListElement* dataList = this->dataList()) { 1840 if (HTMLDataListElement* dataList = this->dataList()) {
1858 RefPtr<HTMLCollection> options = dataList->options(); 1841 RefPtr<HTMLCollection> options = dataList->options();
1859 for (unsigned i = 0; HTMLOptionElement* option = toHTMLOptionElement(opt ions->item(i)); ++i) { 1842 for (unsigned i = 0; HTMLOptionElement* option = toHTMLOptionElement(opt ions->item(i)); ++i) {
1860 if (!isValidValue(option->value())) 1843 if (!isValidValue(option->value()))
1861 continue; 1844 continue;
1862 parameters.suggestionValues.append(sanitizeValue(option->value())); 1845 parameters.suggestionValues.append(sanitizeValue(option->value()));
1863 parameters.localizedSuggestionValues.append(localizeValue(option->va lue())); 1846 parameters.localizedSuggestionValues.append(localizeValue(option->va lue()));
1864 parameters.suggestionLabels.append(option->value() == option->label( ) ? String() : option->label()); 1847 parameters.suggestionLabels.append(option->value() == option->label( ) ? String() : option->label());
1865 } 1848 }
1866 } 1849 }
1867 #endif
1868 return true; 1850 return true;
1869 } 1851 }
1870 1852
1871 void HTMLInputElement::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) con st 1853 void HTMLInputElement::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) con st
1872 { 1854 {
1873 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM); 1855 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM);
1874 HTMLTextFormControlElement::reportMemoryUsage(memoryObjectInfo); 1856 HTMLTextFormControlElement::reportMemoryUsage(memoryObjectInfo);
1875 info.addMember(m_name, "name"); 1857 info.addMember(m_name, "name");
1876 info.addMember(m_valueIfDirty, "valueIfDirty"); 1858 info.addMember(m_valueIfDirty, "valueIfDirty");
1877 info.addMember(m_suggestedValue, "suggestedValue"); 1859 info.addMember(m_suggestedValue, "suggestedValue");
1878 info.addMember(m_inputType, "inputType"); 1860 info.addMember(m_inputType, "inputType");
1879 #if ENABLE(DATALIST_ELEMENT)
1880 info.addMember(m_listAttributeTargetObserver, "listAttributeTargetObserver") ; 1861 info.addMember(m_listAttributeTargetObserver, "listAttributeTargetObserver") ;
1881 #endif
1882 } 1862 }
1883 1863
1884 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI) 1864 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
1885 PassRefPtr<RenderStyle> HTMLInputElement::customStyleForRenderer() 1865 PassRefPtr<RenderStyle> HTMLInputElement::customStyleForRenderer()
1886 { 1866 {
1887 return m_inputType->customStyleForRenderer(document()->styleResolver()->styl eForElement(this)); 1867 return m_inputType->customStyleForRenderer(document()->styleResolver()->styl eForElement(this));
1888 } 1868 }
1889 #endif 1869 #endif
1890 1870
1891 } // namespace 1871 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698