Changeset 271672 in webkit
- Timestamp:
- Jan 20, 2021 1:54:37 PM (18 months ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 47 edited
-
ChangeLog (modified) (1 diff)
-
html/BaseButtonInputType.h (modified) (1 diff)
-
html/BaseCheckableInputType.h (modified) (1 diff)
-
html/BaseClickableWithKeyInputType.h (modified) (1 diff)
-
html/BaseDateAndTimeInputType.cpp (modified) (2 diffs)
-
html/BaseDateAndTimeInputType.h (modified) (4 diffs)
-
html/BaseTextInputType.h (modified) (1 diff)
-
html/ButtonInputType.h (modified) (1 diff)
-
html/CheckboxInputType.h (modified) (1 diff)
-
html/ColorInputType.cpp (modified) (1 diff)
-
html/ColorInputType.h (modified) (2 diffs)
-
html/DateInputType.cpp (modified) (1 diff)
-
html/DateInputType.h (modified) (1 diff)
-
html/DateTimeLocalInputType.h (modified) (1 diff)
-
html/EmailInputType.h (modified) (1 diff)
-
html/FileInputType.cpp (modified) (2 diffs)
-
html/FileInputType.h (modified) (2 diffs)
-
html/HTMLInputElement.cpp (modified) (3 diffs)
-
html/HTMLTextAreaElement.cpp (modified) (1 diff)
-
html/HTMLTextFormControlElement.cpp (modified) (1 diff)
-
html/HiddenInputType.h (modified) (1 diff)
-
html/ImageInputType.cpp (modified) (1 diff)
-
html/ImageInputType.h (modified) (1 diff)
-
html/InputType.cpp (modified) (3 diffs)
-
html/InputType.h (modified) (7 diffs)
-
html/MonthInputType.h (modified) (1 diff)
-
html/NumberInputType.cpp (modified) (1 diff)
-
html/NumberInputType.h (modified) (2 diffs)
-
html/PasswordInputType.h (modified) (1 diff)
-
html/RadioInputType.h (modified) (1 diff)
-
html/RangeInputType.cpp (modified) (3 diffs)
-
html/RangeInputType.h (modified) (2 diffs)
-
html/ResetInputType.h (modified) (1 diff)
-
html/SearchInputType.cpp (modified) (2 diffs)
-
html/SearchInputType.h (modified) (2 diffs)
-
html/SubmitInputType.h (modified) (1 diff)
-
html/TelephoneInputType.h (modified) (1 diff)
-
html/TextFieldInputType.cpp (modified) (5 diffs)
-
html/TextFieldInputType.h (modified) (4 diffs)
-
html/TextInputType.h (modified) (1 diff)
-
html/TimeInputType.cpp (modified) (1 diff)
-
html/TimeInputType.h (modified) (1 diff)
-
html/URLInputType.h (modified) (1 diff)
-
html/WeekInputType.h (modified) (1 diff)
-
html/shadow/TextControlInnerElements.cpp (modified) (1 diff)
-
html/shadow/TextControlInnerElements.h (modified) (2 diffs)
-
style/StyleScope.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r271671 r271672 1 2021-01-20 Yusuke Suzuki <ysuzuki@apple.com> 2 3 Accelerate HTMLInputElement creation 4 https://bugs.webkit.org/show_bug.cgi?id=220758 5 6 Reviewed by Simon Fraser. 7 8 HTMLInputElement creation is too slow. 9 10 1. InputType is excessively using virtual dispatching, which is too slow for hot path. 11 2. HTMLInputElement creates internal elements as a shadow DOM and its creation is too generic. 12 3. We are setting inner text element's editability in a very generic way. This allocates ElementData for each elements while attributes are almost the same. 13 14 In this patch, 15 16 1. We add m_type field in InputType, and for the hot path, we attempt to devirtualize things due to performance problem. 17 2. We pass "parsing phase" information to shadow DOM creation to make them fast. 18 3. We initialize editibility when creating TextControlInnerTextElement. And we use parserSetAttributes to set shared ElementData. This is faster and less memory. 19 4. We also shrink sizeof(Style::Scope) to reduce size of allocation when using shadow DOM. 20 21 This change offers 1% progression in Speedometer2/jQuery. 22 23 * html/BaseButtonInputType.h: 24 (WebCore::BaseButtonInputType::BaseButtonInputType): 25 * html/BaseCheckableInputType.h: 26 (WebCore::BaseCheckableInputType::BaseCheckableInputType): 27 * html/BaseClickableWithKeyInputType.h: 28 (WebCore::BaseClickableWithKeyInputType::BaseClickableWithKeyInputType): 29 * html/BaseDateAndTimeInputType.cpp: 30 (WebCore::BaseDateAndTimeInputType::isSteppableSlow const): 31 (WebCore::BaseDateAndTimeInputType::createShadowSubtreeAndUpdateInnerTextElementEditability): 32 (WebCore::BaseDateAndTimeInputType::isSteppable const): Deleted. 33 (WebCore::BaseDateAndTimeInputType::createShadowSubtree): Deleted. 34 * html/BaseDateAndTimeInputType.h: 35 (WebCore::BaseDateAndTimeInputType::BaseDateAndTimeInputType): 36 * html/BaseTextInputType.h: 37 (WebCore::BaseTextInputType::BaseTextInputType): 38 * html/ButtonInputType.h: 39 * html/CheckboxInputType.h: 40 * html/ColorInputType.cpp: 41 (WebCore::ColorInputType::createShadowSubtreeAndUpdateInnerTextElementEditability): 42 (WebCore::ColorInputType::createShadowSubtree): Deleted. 43 * html/ColorInputType.h: 44 * html/DateInputType.cpp: 45 (WebCore::DateInputType::DateInputType): 46 * html/DateInputType.h: 47 * html/DateTimeLocalInputType.h: 48 * html/EmailInputType.h: 49 * html/FileInputType.cpp: 50 (WebCore::FileInputType::FileInputType): 51 (WebCore::FileInputType::createShadowSubtreeAndUpdateInnerTextElementEditability): 52 (WebCore::FileInputType::createShadowSubtree): Deleted. 53 * html/FileInputType.h: 54 * html/HTMLInputElement.cpp: 55 (WebCore::HTMLInputElement::didAddUserAgentShadowRoot): 56 (WebCore::HTMLInputElement::isValid const): 57 (WebCore::HTMLInputElement::updateType): 58 * html/HTMLTextAreaElement.cpp: 59 (WebCore::HTMLTextAreaElement::didAddUserAgentShadowRoot): 60 * html/HTMLTextFormControlElement.cpp: 61 (WebCore::HTMLTextFormControlElement::updateInnerTextElementEditability): 62 * html/HiddenInputType.h: 63 * html/ImageInputType.cpp: 64 (WebCore::ImageInputType::ImageInputType): 65 * html/ImageInputType.h: 66 * html/InputType.cpp: 67 (WebCore::InputType::isInvalid const): 68 (WebCore::InputType::createShadowSubtreeAndUpdateInnerTextElementEditability): 69 (WebCore::InputType::isSteppable const): 70 (WebCore::InputType::createShadowSubtree): Deleted. 71 * html/InputType.h: 72 (WebCore::InputType::InputType): 73 (WebCore::InputType::isSteppableSlow const): 74 (WebCore::isInvalidInputType): 75 * html/MonthInputType.h: 76 * html/NumberInputType.cpp: 77 (WebCore::NumberInputType::isSteppableSlow const): 78 (WebCore::NumberInputType::isSteppable const): Deleted. 79 * html/NumberInputType.h: 80 * html/PasswordInputType.h: 81 * html/RadioInputType.h: 82 * html/RangeInputType.cpp: 83 (WebCore::RangeInputType::RangeInputType): 84 (WebCore::RangeInputType::isSteppableSlow const): 85 (WebCore::RangeInputType::createShadowSubtreeAndUpdateInnerTextElementEditability): 86 (WebCore::RangeInputType::isSteppable const): Deleted. 87 (WebCore::RangeInputType::createShadowSubtree): Deleted. 88 * html/RangeInputType.h: 89 * html/ResetInputType.h: 90 * html/SearchInputType.cpp: 91 (WebCore::SearchInputType::SearchInputType): 92 (WebCore::SearchInputType::createShadowSubtreeAndUpdateInnerTextElementEditability): 93 (WebCore::SearchInputType::createShadowSubtree): Deleted. 94 * html/SearchInputType.h: 95 * html/SubmitInputType.h: 96 * html/TelephoneInputType.h: 97 * html/TextFieldInputType.cpp: 98 (WebCore::TextFieldInputType::TextFieldInputType): 99 (WebCore::TextFieldInputType::createShadowSubtreeAndUpdateInnerTextElementEditability): 100 (WebCore::TextFieldInputType::createShadowSubtree): Deleted. 101 * html/TextFieldInputType.h: 102 * html/TextInputType.h: 103 * html/TimeInputType.cpp: 104 (WebCore::TimeInputType::TimeInputType): 105 * html/TimeInputType.h: 106 * html/URLInputType.h: 107 * html/WeekInputType.h: 108 * html/shadow/TextControlInnerElements.cpp: 109 (WebCore::TextControlInnerTextElement::create): 110 (WebCore::TextControlInnerTextElement::updateInnerTextElementEditabilityImpl): 111 * html/shadow/TextControlInnerElements.h: 112 * style/StyleScope.h: 113 1 114 2021-01-20 Manuel Rego Casasnovas <rego@igalia.com> 2 115 -
trunk/Source/WebCore/html/BaseButtonInputType.h
r221914 r271672 38 38 class BaseButtonInputType : public BaseClickableWithKeyInputType { 39 39 protected: 40 explicit BaseButtonInputType( HTMLInputElement& element) : BaseClickableWithKeyInputType(element) { }40 explicit BaseButtonInputType(Type type, HTMLInputElement& element) : BaseClickableWithKeyInputType(type, element) { } 41 41 42 42 private: -
trunk/Source/WebCore/html/BaseCheckableInputType.h
r259687 r271672 38 38 class BaseCheckableInputType : public InputType { 39 39 protected: 40 explicit BaseCheckableInputType( HTMLInputElement& element) : InputType(element) { }40 explicit BaseCheckableInputType(Type type, HTMLInputElement& element) : InputType(type, element) { } 41 41 ShouldCallBaseEventHandler handleKeydownEvent(KeyboardEvent&) override; 42 42 void fireInputAndChangeEvents(); -
trunk/Source/WebCore/html/BaseClickableWithKeyInputType.h
r259687 r271672 44 44 45 45 protected: 46 explicit BaseClickableWithKeyInputType( HTMLInputElement& element) : InputType(element) { }46 explicit BaseClickableWithKeyInputType(Type type, HTMLInputElement& element) : InputType(type, element) { } 47 47 48 48 private: -
trunk/Source/WebCore/html/BaseDateAndTimeInputType.cpp
r269027 r271672 168 168 } 169 169 170 bool BaseDateAndTimeInputType::isSteppable () const170 bool BaseDateAndTimeInputType::isSteppableSlow() const 171 171 { 172 172 return true; … … 308 308 } 309 309 310 void BaseDateAndTimeInputType::createShadowSubtree ()310 void BaseDateAndTimeInputType::createShadowSubtreeAndUpdateInnerTextElementEditability(ContainerNode::ChildChange::Source, bool) 311 311 { 312 312 ASSERT(element()); -
trunk/Source/WebCore/html/BaseDateAndTimeInputType.h
r267003 r271672 59 59 }; 60 60 61 BaseDateAndTimeInputType( HTMLInputElement& element) : InputType(element) { }61 BaseDateAndTimeInputType(Type type, HTMLInputElement& element) : InputType(type, element) { } 62 62 ~BaseDateAndTimeInputType(); 63 63 … … 68 68 bool shouldHaveSecondField(const DateComponents&) const; 69 69 bool shouldHaveMillisecondField(const DateComponents&) const; 70 bool typeMismatchFor(const String&) const final; 71 bool typeMismatch() const final; 72 bool valueMissing(const String&) const final; 70 73 71 74 private: … … 97 100 double valueAsDouble() const final; 98 101 ExceptionOr<void> setValueAsDecimal(const Decimal&, TextFieldEventBehavior) const final; 99 bool typeMismatchFor(const String&) const final;100 bool typeMismatch() const final;101 bool valueMissing(const String&) const final;102 102 Decimal defaultValueForStepUp() const override; 103 bool isSteppable () const final;103 bool isSteppableSlow() const final; 104 104 String localizeValue(const String&) const final; 105 105 bool supportsReadOnly() const final; … … 109 109 110 110 void handleDOMActivateEvent(Event&) override; 111 void createShadowSubtree () final;111 void createShadowSubtreeAndUpdateInnerTextElementEditability(ContainerNode::ChildChange::Source, bool) final; 112 112 void destroyShadowSubtree() final; 113 113 void updateInnerTextValue() final; -
trunk/Source/WebCore/html/BaseTextInputType.h
r208179 r271672 39 39 class BaseTextInputType : public TextFieldInputType { 40 40 protected: 41 explicit BaseTextInputType( HTMLInputElement& element) : TextFieldInputType(element) { }41 explicit BaseTextInputType(Type type, HTMLInputElement& element) : TextFieldInputType(type, element) { } 42 42 43 private:44 43 bool isTextType() const override; 45 44 bool patternMismatch(const String&) const override; -
trunk/Source/WebCore/html/ButtonInputType.h
r246490 r271672 36 36 37 37 class ButtonInputType final : public BaseButtonInputType { 38 template<typename DowncastedType> friend bool isInvalidInputType(const InputType&, const String&); 38 39 public: 39 explicit ButtonInputType(HTMLInputElement& element) : BaseButtonInputType( element) { }40 explicit ButtonInputType(HTMLInputElement& element) : BaseButtonInputType(Type::Button, element) { } 40 41 41 42 private: -
trunk/Source/WebCore/html/CheckboxInputType.h
r246490 r271672 36 36 37 37 class CheckboxInputType final : public BaseCheckableInputType { 38 template<typename DowncastedType> friend bool isInvalidInputType(const InputType&, const String&); 38 39 public: 39 explicit CheckboxInputType(HTMLInputElement& element) : BaseCheckableInputType( element) { }40 explicit CheckboxInputType(HTMLInputElement& element) : BaseCheckableInputType(Type::Checkbox, element) { } 40 41 41 42 private: -
trunk/Source/WebCore/html/ColorInputType.cpp
r264565 r271672 140 140 } 141 141 142 void ColorInputType::createShadowSubtree ()142 void ColorInputType::createShadowSubtreeAndUpdateInnerTextElementEditability(ContainerNode::ChildChange::Source, bool) 143 143 { 144 144 ASSERT(element()); -
trunk/Source/WebCore/html/ColorInputType.h
r264280 r271672 41 41 42 42 class ColorInputType final : public BaseClickableWithKeyInputType, private ColorChooserClient { 43 template<typename DowncastedType> friend bool isInvalidInputType(const InputType&, const String&); 43 44 public: 44 explicit ColorInputType(HTMLInputElement& element) : BaseClickableWithKeyInputType( element) { }45 explicit ColorInputType(HTMLInputElement& element) : BaseClickableWithKeyInputType(Type::Color, element) { } 45 46 virtual ~ColorInputType(); 46 47 … … 58 59 String fallbackValue() const final; 59 60 String sanitizeValue(const String&) const final; 60 void createShadowSubtree () final;61 void createShadowSubtreeAndUpdateInnerTextElementEditability(ContainerNode::ChildChange::Source, bool) final; 61 62 void setValue(const String&, bool valueChanged, TextFieldEventBehavior) final; 62 63 void handleDOMActivateEvent(Event&) final; -
trunk/Source/WebCore/html/DateInputType.cpp
r267003 r271672 51 51 52 52 DateInputType::DateInputType(HTMLInputElement& element) 53 : BaseDateAndTimeInputType( element)53 : BaseDateAndTimeInputType(Type::Date, element) 54 54 { 55 55 } -
trunk/Source/WebCore/html/DateInputType.h
r267003 r271672 38 38 39 39 class DateInputType final : public BaseDateAndTimeInputType { 40 template<typename DowncastedType> friend bool isInvalidInputType(const InputType&, const String&); 40 41 public: 41 42 explicit DateInputType(HTMLInputElement&); -
trunk/Source/WebCore/html/DateTimeLocalInputType.h
r267003 r271672 38 38 39 39 class DateTimeLocalInputType final : public BaseDateAndTimeInputType { 40 template<typename DowncastedType> friend bool isInvalidInputType(const InputType&, const String&); 40 41 public: 41 42 explicit DateTimeLocalInputType(HTMLInputElement& element) 42 : BaseDateAndTimeInputType( element)43 : BaseDateAndTimeInputType(Type::DateTimeLocal, element) 43 44 { 44 45 } -
trunk/Source/WebCore/html/EmailInputType.h
r246490 r271672 36 36 37 37 class EmailInputType final : public BaseTextInputType { 38 template<typename DowncastedType> friend bool isInvalidInputType(const InputType&, const String&); 38 39 public: 39 explicit EmailInputType(HTMLInputElement& element) : BaseTextInputType( element) { }40 explicit EmailInputType(HTMLInputElement& element) : BaseTextInputType(Type::Email, element) { } 40 41 41 42 private: -
trunk/Source/WebCore/html/FileInputType.cpp
r270784 r271672 107 107 108 108 FileInputType::FileInputType(HTMLInputElement& element) 109 : BaseClickableWithKeyInputType( element)109 : BaseClickableWithKeyInputType(Type::File, element) 110 110 , m_fileList(FileList::create()) 111 111 { … … 279 279 } 280 280 281 void FileInputType::createShadowSubtree ()281 void FileInputType::createShadowSubtreeAndUpdateInnerTextElementEditability(ContainerNode::ChildChange::Source, bool) 282 282 { 283 283 ASSERT(element()); -
trunk/Source/WebCore/html/FileInputType.h
r265422 r271672 46 46 47 47 class FileInputType final : public BaseClickableWithKeyInputType, private FileChooserClient, private FileIconLoaderClient, public CanMakeWeakPtr<FileInputType> { 48 template<typename DowncastedType> friend bool isInvalidInputType(const InputType&, const String&); 48 49 public: 49 50 explicit FileInputType(HTMLInputElement&); … … 78 79 Icon* icon() const final; 79 80 bool isFileUpload() const final; 80 void createShadowSubtree () final;81 void createShadowSubtreeAndUpdateInnerTextElementEditability(ContainerNode::ChildChange::Source, bool) final; 81 82 void disabledStateChanged() final; 82 83 void attributeChanged(const QualifiedName&) final; -
trunk/Source/WebCore/html/HTMLInputElement.cpp
r269587 r271672 159 159 { 160 160 Ref<InputType> protectedInputType(*m_inputType); 161 protectedInputType->createShadowSubtree(); 162 updateInnerTextElementEditability(); 161 protectedInputType->createShadowSubtreeAndUpdateInnerTextElementEditability(m_parsingInProgress ? ChildChange::Source::Parser : ChildChange::Source::API, isInnerTextElementEditable()); 163 162 } 164 163 … … 391 390 392 391 String value = this->value(); 393 bool someError = m_inputType->typeMismatch() || m_inputType->stepMismatch(value) || m_inputType->rangeUnderflow(value) || m_inputType->rangeOverflow(value) 394 || tooShort(value, CheckDirtyFlag) || tooLong(value, CheckDirtyFlag) || m_inputType->patternMismatch(value) || m_inputType->valueMissing(value) 395 || m_inputType->hasBadInput() || customError(); 392 bool someError = m_inputType->isInvalid(value) || tooShort(value, CheckDirtyFlag) || tooLong(value, CheckDirtyFlag) || customError(); 396 393 return !someError; 397 394 } … … 565 562 566 563 m_inputType = WTFMove(newType); 567 m_inputType->createShadowSubtree(); 568 updateInnerTextElementEditability(); 564 m_inputType->createShadowSubtreeAndUpdateInnerTextElementEditability(m_parsingInProgress ? ChildChange::Source::Parser : ChildChange::Source::API, isInnerTextElementEditable()); 569 565 570 566 setNeedsWillValidateCheck(); -
trunk/Source/WebCore/html/HTMLTextAreaElement.cpp
r269587 r271672 111 111 void HTMLTextAreaElement::didAddUserAgentShadowRoot(ShadowRoot& root) 112 112 { 113 root.appendChild(TextControlInnerTextElement::create(document())); 114 updateInnerTextElementEditability(); 113 root.appendChild(TextControlInnerTextElement::create(document(), isInnerTextElementEditable())); 115 114 } 116 115 -
trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp
r270983 r271672 541 541 void HTMLTextFormControlElement::updateInnerTextElementEditability() 542 542 { 543 if (auto innerText = innerTextElement()) { 544 static MainThreadNeverDestroyed<const AtomString> plainTextOnlyName("plaintext-only", AtomString::ConstructFromLiteral); 545 static MainThreadNeverDestroyed<const AtomString> falseName("false", AtomString::ConstructFromLiteral); 546 const auto& value = isInnerTextElementEditable() ? plainTextOnlyName.get() : falseName.get(); 547 innerText->setAttributeWithoutSynchronization(contenteditableAttr, value); 548 } 543 if (auto innerText = innerTextElement()) 544 innerText->updateInnerTextElementEditability(isInnerTextElementEditable()); 549 545 } 550 546 -
trunk/Source/WebCore/html/HiddenInputType.h
r259687 r271672 36 36 37 37 class HiddenInputType final : public InputType { 38 template<typename DowncastedType> friend bool isInvalidInputType(const InputType&, const String&); 38 39 public: 39 explicit HiddenInputType(HTMLInputElement& element) : InputType( element) { }40 explicit HiddenInputType(HTMLInputElement& element) : InputType(Type::Hidden, element) { } 40 41 41 42 private: -
trunk/Source/WebCore/html/ImageInputType.cpp
r246490 r271672 41 41 42 42 ImageInputType::ImageInputType(HTMLInputElement& element) 43 : BaseButtonInputType( element)43 : BaseButtonInputType(Type::Image, element) 44 44 { 45 45 } -
trunk/Source/WebCore/html/ImageInputType.h
r246490 r271672 39 39 40 40 class ImageInputType final : public BaseButtonInputType { 41 template<typename DowncastedType> friend bool isInvalidInputType(const InputType&, const String&); 41 42 public: 42 43 explicit ImageInputType(HTMLInputElement&); -
trunk/Source/WebCore/html/InputType.cpp
r271446 r271672 302 302 } 303 303 304 bool InputType::isInvalid(const String& value) const 305 { 306 switch (m_type) { 307 case Type::Button: 308 return isInvalidInputType<ButtonInputType>(*this, value); 309 case Type::Checkbox: 310 return isInvalidInputType<CheckboxInputType>(*this, value); 311 case Type::Color: 312 #if ENABLE(INPUT_TYPE_COLOR) 313 return isInvalidInputType<ColorInputType>(*this, value); 314 #else 315 return false; 316 #endif 317 case Type::Date: 318 #if ENABLE(INPUT_TYPE_DATE) 319 return isInvalidInputType<DateInputType>(*this, value); 320 #else 321 return false; 322 #endif 323 case Type::DateTimeLocal: 324 #if ENABLE(INPUT_TYPE_DATETIMELOCAL) 325 return isInvalidInputType<DateTimeLocalInputType>(*this, value); 326 #else 327 return false; 328 #endif 329 case Type::Email: 330 return isInvalidInputType<EmailInputType>(*this, value); 331 case Type::File: 332 return isInvalidInputType<FileInputType>(*this, value); 333 case Type::Hidden: 334 return isInvalidInputType<HiddenInputType>(*this, value); 335 case Type::Image: 336 return isInvalidInputType<ImageInputType>(*this, value); 337 case Type::Month: 338 #if ENABLE(INPUT_TYPE_MONTH) 339 return isInvalidInputType<MonthInputType>(*this, value); 340 #else 341 return false; 342 #endif 343 case Type::Number: 344 return isInvalidInputType<NumberInputType>(*this, value); 345 case Type::Password: 346 return isInvalidInputType<PasswordInputType>(*this, value); 347 case Type::Radio: 348 return isInvalidInputType<RadioInputType>(*this, value); 349 case Type::Range: 350 return isInvalidInputType<RangeInputType>(*this, value); 351 case Type::Reset: 352 return isInvalidInputType<ResetInputType>(*this, value); 353 case Type::Search: 354 return isInvalidInputType<SearchInputType>(*this, value); 355 case Type::Submit: 356 return isInvalidInputType<SubmitInputType>(*this, value); 357 case Type::Telephone: 358 return isInvalidInputType<TelephoneInputType>(*this, value); 359 case Type::Time: 360 #if ENABLE(INPUT_TYPE_TIME) 361 return isInvalidInputType<TimeInputType>(*this, value); 362 #else 363 return false; 364 #endif 365 case Type::URL: 366 return isInvalidInputType<URLInputType>(*this, value); 367 case Type::Week: 368 #if ENABLE(INPUT_TYPE_WEEK) 369 return isInvalidInputType<WeekInputType>(*this, value); 370 #else 371 return false; 372 #endif 373 case Type::Text: 374 return isInvalidInputType<TextInputType>(*this, value); 375 } 376 ASSERT_NOT_REACHED(); 377 return false; 378 } 379 304 380 Decimal InputType::defaultValueForStepUp() const 305 381 { … … 493 569 } 494 570 495 void InputType::createShadowSubtree ()571 void InputType::createShadowSubtreeAndUpdateInnerTextElementEditability(ContainerNode::ChildChange::Source, bool) 496 572 { 497 573 } … … 856 932 } 857 933 934 // Do not use virtual function for performance reason. 858 935 bool InputType::isSteppable() const 859 936 { 860 return false; 937 switch (m_type) { 938 case Type::Date: 939 case Type::DateTimeLocal: 940 case Type::Month: 941 case Type::Time: 942 case Type::Week: 943 case Type::Number: 944 case Type::Range: 945 ASSERT(isSteppableSlow()); 946 return true; 947 default: 948 ASSERT(!isSteppableSlow()); 949 return false; 950 } 861 951 } 862 952 -
trunk/Source/WebCore/html/InputType.h
r266114 r271672 71 71 class InputType : public RefCounted<InputType> { 72 72 WTF_MAKE_FAST_ALLOCATED; 73 74 73 public: 74 enum class Type : uint8_t { 75 Button, 76 Checkbox, 77 Color, 78 Date, 79 DateTimeLocal, 80 Email, 81 File, 82 Hidden, 83 Image, 84 Month, 85 Number, 86 Password, 87 Radio, 88 Range, 89 Reset, 90 Search, 91 Submit, 92 Telephone, 93 Time, 94 URL, 95 Week, 96 Text, 97 }; 98 75 99 static Ref<InputType> create(HTMLInputElement&, const AtomString&); 76 100 static Ref<InputType> createText(HTMLInputElement&); … … 218 242 // Shadow tree handling. 219 243 220 virtual void createShadowSubtree ();244 virtual void createShadowSubtreeAndUpdateInnerTextElementEditability(ContainerNode::ChildChange::Source, bool); 221 245 virtual void destroyShadowSubtree(); 222 246 … … 255 279 virtual bool isEnumeratable(); 256 280 virtual bool isCheckable(); 257 virtual bool isSteppable() const;258 281 virtual bool shouldRespectHeightAndWidthAttributes(); 259 282 virtual bool supportsPlaceholder() const; … … 276 299 virtual Vector<Color> suggestedColors() const; 277 300 301 bool isSteppable() const; 302 278 303 // Parses the specified string for the type, and return 279 304 // the Decimal value for the parsing result if the parsing … … 292 317 virtual unsigned width() const; 293 318 319 bool isInvalid(const String&) const; 320 294 321 void dispatchSimulatedClickIfActive(KeyboardEvent&) const; 295 322 … … 308 335 309 336 protected: 310 explicit InputType(HTMLInputElement& element) 311 : m_element(makeWeakPtr(element)) { } 337 explicit InputType(Type type, HTMLInputElement& element) 338 : m_type(type) 339 , m_element(makeWeakPtr(element)) { } 312 340 HTMLInputElement* element() const { return m_element.get(); } 313 341 Chrome* chrome() const; 314 342 Decimal parseToNumberOrNaN(const String&) const; 343 virtual bool isSteppableSlow() const { return false; } 315 344 316 345 private: … … 318 347 ExceptionOr<void> applyStep(int count, AnyStepHandling, TextFieldEventBehavior); 319 348 349 const Type m_type; 320 350 // m_element is null if this InputType is no longer associated with an element (either the element died or changed input type). 321 351 WeakPtr<HTMLInputElement> m_element; 322 352 }; 353 354 template<typename DowncastedType> 355 ALWAYS_INLINE bool isInvalidInputType(const InputType& baseInputType, const String& value) 356 { 357 auto& inputType = static_cast<const DowncastedType&>(baseInputType); 358 return inputType.typeMismatch() || inputType.stepMismatch(value) || inputType.rangeUnderflow(value) || inputType.rangeOverflow(value) || inputType.patternMismatch(value) || inputType.valueMissing(value) || inputType.hasBadInput(); 359 } 323 360 324 361 } // namespace WebCore -
trunk/Source/WebCore/html/MonthInputType.h
r267003 r271672 38 38 39 39 class MonthInputType final : public BaseDateAndTimeInputType { 40 template<typename DowncastedType> friend bool isInvalidInputType(const InputType&, const String&); 40 41 public: 41 42 explicit MonthInputType(HTMLInputElement& element) 42 : BaseDateAndTimeInputType( element)43 : BaseDateAndTimeInputType(Type::Month, element) 43 44 { 44 45 } -
trunk/Source/WebCore/html/NumberInputType.cpp
r264600 r271672 211 211 } 212 212 213 bool NumberInputType::isSteppable () const213 bool NumberInputType::isSteppableSlow() const 214 214 { 215 215 return true; -
trunk/Source/WebCore/html/NumberInputType.h
r246490 r271672 37 37 38 38 class NumberInputType final : public TextFieldInputType { 39 template<typename DowncastedType> friend bool isInvalidInputType(const InputType&, const String&); 39 40 public: 40 explicit NumberInputType(HTMLInputElement& element) : TextFieldInputType( element) { }41 explicit NumberInputType(HTMLInputElement& element) : TextFieldInputType(Type::Number, element) { } 41 42 42 43 private: … … 50 51 bool sizeShouldIncludeDecoration(int defaultSize, int& preferredSize) const final; 51 52 float decorationWidth() const final; 52 bool isSteppable () const final;53 bool isSteppableSlow() const final; 53 54 StepRange createStepRange(AnyStepHandling) const final; 54 55 ShouldCallBaseEventHandler handleKeydownEvent(KeyboardEvent&) final; -
trunk/Source/WebCore/html/PasswordInputType.h
r246490 r271672 36 36 37 37 class PasswordInputType final : public BaseTextInputType { 38 template<typename DowncastedType> friend bool isInvalidInputType(const InputType&, const String&); 38 39 public: 39 explicit PasswordInputType(HTMLInputElement& element) : BaseTextInputType( element) { }40 explicit PasswordInputType(HTMLInputElement& element) : BaseTextInputType(Type::Password, element) { } 40 41 41 42 private: -
trunk/Source/WebCore/html/RadioInputType.h
r246490 r271672 37 37 38 38 class RadioInputType final : public BaseCheckableInputType { 39 template<typename DowncastedType> friend bool isInvalidInputType(const InputType&, const String&); 39 40 public: 40 explicit RadioInputType(HTMLInputElement& element) : BaseCheckableInputType( element) { }41 explicit RadioInputType(HTMLInputElement& element) : BaseCheckableInputType(Type::Radio, element) { } 41 42 42 43 private: -
trunk/Source/WebCore/html/RangeInputType.cpp
r264600 r271672 81 81 82 82 RangeInputType::RangeInputType(HTMLInputElement& element) 83 : InputType( element)83 : InputType(Type::Range, element) 84 84 { 85 85 } … … 134 134 } 135 135 136 bool RangeInputType::isSteppable () const136 bool RangeInputType::isSteppableSlow() const 137 137 { 138 138 return true; … … 253 253 } 254 254 255 void RangeInputType::createShadowSubtree ()255 void RangeInputType::createShadowSubtreeAndUpdateInnerTextElementEditability(ContainerNode::ChildChange::Source, bool) 256 256 { 257 257 ASSERT(element()); -
trunk/Source/WebCore/html/RangeInputType.h
r259687 r271672 39 39 40 40 class RangeInputType final : public InputType { 41 template<typename DowncastedType> friend bool isInvalidInputType(const InputType&, const String&); 41 42 public: 42 43 explicit RangeInputType(HTMLInputElement&); … … 50 51 bool supportsRequired() const final; 51 52 StepRange createStepRange(AnyStepHandling) const final; 52 bool isSteppable () const final;53 bool isSteppableSlow() const final; 53 54 void handleMouseDownEvent(MouseEvent&) final; 54 55 ShouldCallBaseEventHandler handleKeydownEvent(KeyboardEvent&) final; 55 56 RenderPtr<RenderElement> createInputRenderer(RenderStyle&&) final; 56 void createShadowSubtree () final;57 void createShadowSubtreeAndUpdateInnerTextElementEditability(ContainerNode::ChildChange::Source, bool) final; 57 58 Decimal parseToNumber(const String&, const Decimal&) const final; 58 59 String serialize(const Decimal&) const final; -
trunk/Source/WebCore/html/ResetInputType.h
r246490 r271672 36 36 37 37 class ResetInputType final : public BaseButtonInputType { 38 template<typename DowncastedType> friend bool isInvalidInputType(const InputType&, const String&); 38 39 public: 39 explicit ResetInputType(HTMLInputElement& element) : BaseButtonInputType( element) { }40 explicit ResetInputType(HTMLInputElement& element) : BaseButtonInputType(Type::Reset, element) { } 40 41 41 42 private: -
trunk/Source/WebCore/html/SearchInputType.cpp
r261013 r271672 46 46 47 47 SearchInputType::SearchInputType(HTMLInputElement& element) 48 : BaseTextInputType( element)48 : BaseTextInputType(Type::Search, element) 49 49 , m_searchEventTimer(*this, &SearchInputType::searchEventTimerFired) 50 50 { … … 108 108 } 109 109 110 void SearchInputType::createShadowSubtree ()110 void SearchInputType::createShadowSubtreeAndUpdateInnerTextElementEditability(ContainerNode::ChildChange::Source source, bool isInnerTextElementEditable) 111 111 { 112 112 ASSERT(!m_resultsButton); 113 113 ASSERT(!m_cancelButton); 114 114 115 TextFieldInputType::createShadowSubtree ();115 TextFieldInputType::createShadowSubtreeAndUpdateInnerTextElementEditability(source, isInnerTextElementEditable); 116 116 RefPtr<HTMLElement> container = containerElement(); 117 117 RefPtr<HTMLElement> textWrapper = innerBlockElement(); -
trunk/Source/WebCore/html/SearchInputType.h
r246490 r271672 40 40 41 41 class SearchInputType final : public BaseTextInputType { 42 template<typename DowncastedType> friend bool isInvalidInputType(const InputType&, const String&); 42 43 public: 43 44 explicit SearchInputType(HTMLInputElement&); … … 52 53 bool isSearchField() const final; 53 54 bool needsContainer() const final; 54 void createShadowSubtree () final;55 void createShadowSubtreeAndUpdateInnerTextElementEditability(ContainerNode::ChildChange::Source, bool) final; 55 56 void destroyShadowSubtree() final; 56 57 HTMLElement* resultsButtonElement() const final; -
trunk/Source/WebCore/html/SubmitInputType.h
r246490 r271672 36 36 37 37 class SubmitInputType final : public BaseButtonInputType { 38 template<typename DowncastedType> friend bool isInvalidInputType(const InputType&, const String&); 38 39 public: 39 explicit SubmitInputType(HTMLInputElement& element) : BaseButtonInputType( element) { }40 explicit SubmitInputType(HTMLInputElement& element) : BaseButtonInputType(Type::Submit, element) { } 40 41 41 42 private: -
trunk/Source/WebCore/html/TelephoneInputType.h
r246490 r271672 36 36 37 37 class TelephoneInputType final : public BaseTextInputType { 38 template<typename DowncastedType> friend bool isInvalidInputType(const InputType&, const String&); 38 39 public: 39 explicit TelephoneInputType(HTMLInputElement& element) : BaseTextInputType( element) { }40 explicit TelephoneInputType(HTMLInputElement& element) : BaseTextInputType(Type::Telephone, element) { } 40 41 41 42 private: -
trunk/Source/WebCore/html/TextFieldInputType.cpp
r271559 r271672 72 72 using namespace HTMLNames; 73 73 74 TextFieldInputType::TextFieldInputType( HTMLInputElement& element)75 : InputType( element)74 TextFieldInputType::TextFieldInputType(Type type, HTMLInputElement& element) 75 : InputType(type, element) 76 76 { 77 77 } … … 319 319 } 320 320 321 void TextFieldInputType::createShadowSubtree ()321 void TextFieldInputType::createShadowSubtreeAndUpdateInnerTextElementEditability(ContainerNode::ChildChange::Source source, bool isInnerTextElementEditable) 322 322 { 323 323 ASSERT(element()); … … 335 335 bool createsContainer = shouldHaveSpinButton || shouldHaveCapsLockIndicator || needsContainer(); 336 336 337 m_innerText = TextControlInnerTextElement::create(document );337 m_innerText = TextControlInnerTextElement::create(document, isInnerTextElementEditable); 338 338 339 339 if (!createsContainer) { 340 element()->userAgentShadowRoot()->appendChild(*m_innerText); 340 if (source == ContainerNode::ChildChange::Source::Parser) 341 element()->userAgentShadowRoot()->parserAppendChild(*m_innerText); 342 else 343 element()->userAgentShadowRoot()->appendChild(*m_innerText); 341 344 updatePlaceholderText(); 342 345 return; … … 348 351 if (shouldHaveSpinButton) { 349 352 m_innerSpinButton = SpinButtonElement::create(document, *this); 350 m_container->appendChild(*m_innerSpinButton); 353 if (source == ContainerNode::ChildChange::Source::Parser) 354 m_container->parserAppendChild(*m_innerSpinButton); 355 else 356 m_container->appendChild(*m_innerSpinButton); 351 357 } 352 358 … … 359 365 m_capsLockIndicator->setInlineStyleProperty(CSSPropertyDisplay, shouldDrawCapsLockIndicator ? CSSValueBlock : CSSValueNone, true); 360 366 361 m_container->appendChild(*m_capsLockIndicator); 367 if (source == ContainerNode::ChildChange::Source::Parser) 368 m_container->parserAppendChild(*m_capsLockIndicator); 369 else 370 m_container->appendChild(*m_capsLockIndicator); 362 371 } 363 372 updateAutoFillButton(); -
trunk/Source/WebCore/html/TextFieldInputType.h
r259402 r271672 52 52 { 53 53 protected: 54 explicit TextFieldInputType( HTMLInputElement&);54 explicit TextFieldInputType(Type, HTMLInputElement&); 55 55 virtual ~TextFieldInputType(); 56 56 ShouldCallBaseEventHandler handleKeydownEvent(KeyboardEvent&) override; … … 71 71 72 72 virtual bool needsContainer() const; 73 void createShadowSubtree () override;73 void createShadowSubtreeAndUpdateInnerTextElementEditability(ContainerNode::ChildChange::Source, bool) override; 74 74 void destroyShadowSubtree() override; 75 75 void attributeChanged(const QualifiedName&) override; … … 82 82 void updateInnerTextValue() final; 83 83 String sanitizeValue(const String&) const override; 84 bool valueMissing(const String&) const final; 84 85 85 86 virtual String convertFromVisibleValue(const String&) const; … … 91 92 bool isTextField() const final; 92 93 bool isEmptyValue() const final; 93 bool valueMissing(const String&) const final;94 94 void handleBeforeTextInsertedEvent(BeforeTextInsertedEvent&) final; 95 95 void forwardEvent(Event&) final; -
trunk/Source/WebCore/html/TextInputType.h
r246490 r271672 36 36 37 37 class TextInputType final : public BaseTextInputType { 38 template<typename DowncastedType> friend bool isInvalidInputType(const InputType&, const String&); 38 39 public: 39 explicit TextInputType(HTMLInputElement& element) : BaseTextInputType( element) { }40 explicit TextInputType(HTMLInputElement& element) : BaseTextInputType(Type::Text, element) { } 40 41 41 42 private: -
trunk/Source/WebCore/html/TimeInputType.cpp
r267003 r271672 54 54 55 55 TimeInputType::TimeInputType(HTMLInputElement& element) 56 : BaseDateAndTimeInputType( element)56 : BaseDateAndTimeInputType(Type::Time, element) 57 57 { 58 58 } -
trunk/Source/WebCore/html/TimeInputType.h
r267003 r271672 38 38 39 39 class TimeInputType final : public BaseDateAndTimeInputType { 40 template<typename DowncastedType> friend bool isInvalidInputType(const InputType&, const String&); 40 41 public: 41 42 explicit TimeInputType(HTMLInputElement&); -
trunk/Source/WebCore/html/URLInputType.h
r246490 r271672 36 36 37 37 class URLInputType final : public BaseTextInputType { 38 template<typename DowncastedType> friend bool isInvalidInputType(const InputType&, const String&); 38 39 public: 39 explicit URLInputType(HTMLInputElement& element) : BaseTextInputType( element) { }40 explicit URLInputType(HTMLInputElement& element) : BaseTextInputType(Type::URL, element) { } 40 41 41 42 private: -
trunk/Source/WebCore/html/WeekInputType.h
r267003 r271672 38 38 39 39 class WeekInputType final : public BaseDateAndTimeInputType { 40 template<typename DowncastedType> friend bool isInvalidInputType(const InputType&, const String&); 40 41 public: 41 42 explicit WeekInputType(HTMLInputElement& element) 42 : BaseDateAndTimeInputType( element)43 : BaseDateAndTimeInputType(Type::Week, element) 43 44 { 44 45 } -
trunk/Source/WebCore/html/shadow/TextControlInnerElements.cpp
r267074 r271672 139 139 } 140 140 141 Ref<TextControlInnerTextElement> TextControlInnerTextElement::create(Document& document) 142 { 143 return adoptRef(*new TextControlInnerTextElement(document)); 141 Ref<TextControlInnerTextElement> TextControlInnerTextElement::create(Document& document, bool isEditable) 142 { 143 auto result = adoptRef(*new TextControlInnerTextElement(document)); 144 constexpr bool initialization = true; 145 result->updateInnerTextElementEditabilityImpl(isEditable, initialization); 146 return result; 147 } 148 149 void TextControlInnerTextElement::updateInnerTextElementEditabilityImpl(bool isEditable, bool initialization) 150 { 151 static MainThreadNeverDestroyed<const AtomString> plainTextOnlyName("plaintext-only", AtomString::ConstructFromLiteral); 152 static MainThreadNeverDestroyed<const AtomString> falseName("false", AtomString::ConstructFromLiteral); 153 const auto& value = isEditable ? plainTextOnlyName.get() : falseName.get(); 154 if (initialization) { 155 Vector<Attribute> attributes { Attribute(contenteditableAttr, value) }; 156 parserSetAttributes(attributes); 157 } else 158 setAttributeWithoutSynchronization(contenteditableAttr, value); 144 159 } 145 160 -
trunk/Source/WebCore/html/shadow/TextControlInnerElements.h
r260415 r271672 59 59 WTF_MAKE_ISO_ALLOCATED(TextControlInnerTextElement); 60 60 public: 61 static Ref<TextControlInnerTextElement> create(Document& );61 static Ref<TextControlInnerTextElement> create(Document&, bool isEditable); 62 62 63 63 void defaultEventHandler(Event&) override; … … 65 65 RenderTextControlInnerBlock* renderer() const; 66 66 67 inline void updateInnerTextElementEditability(bool isEditable) 68 { 69 constexpr bool initialization = false; 70 updateInnerTextElementEditabilityImpl(isEditable, initialization); 71 } 72 67 73 private: 74 void updateInnerTextElementEditabilityImpl(bool isEditable, bool initialization); 75 68 76 TextControlInnerTextElement(Document&); 69 77 RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) override; -
trunk/Source/WebCore/style/StyleScope.h
r253949 r271672 136 136 void didRemovePendingStylesheet(); 137 137 138 enum class UpdateType { ActiveSet, ContentsOrInterpretation };138 enum class UpdateType : uint8_t { ActiveSet, ContentsOrInterpretation }; 139 139 void updateActiveStyleSheets(UpdateType); 140 140 void scheduleUpdate(UpdateType); … … 184 184 HashSet<const Element*> m_elementsInBodyWithPendingSheets; 185 185 186 187 ListHashSet<Node*> m_styleSheetCandidateNodes; 188 189 String m_preferredStylesheetSetName; 190 186 191 Optional<UpdateType> m_pendingUpdate; 192 187 193 bool m_hasDescendantWithPendingUpdate { false }; 188 189 ListHashSet<Node*> m_styleSheetCandidateNodes;190 191 String m_preferredStylesheetSetName;192 193 194 bool m_usesStyleBasedEditability { false }; 194 195 bool m_isUpdatingStyleResolver { false };
Note: See TracChangeset
for help on using the changeset viewer.