Changeset 290284 in webkit
- Timestamp:
- Feb 21, 2022 7:36:52 PM (5 months ago)
- Location:
- trunk
- Files:
-
- 3 added
- 22 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/fast/forms/lazy-shadow-tree-creation-expected.html (added)
-
LayoutTests/fast/forms/lazy-shadow-tree-creation.html (added)
-
LayoutTests/fast/forms/lazy-shadow-tree-creation.js (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/html/BaseDateAndTimeInputType.cpp (modified) (2 diffs)
-
Source/WebCore/html/BaseDateAndTimeInputType.h (modified) (1 diff)
-
Source/WebCore/html/ColorInputType.cpp (modified) (1 diff)
-
Source/WebCore/html/ColorInputType.h (modified) (1 diff)
-
Source/WebCore/html/FileInputType.cpp (modified) (3 diffs)
-
Source/WebCore/html/FileInputType.h (modified) (1 diff)
-
Source/WebCore/html/HTMLInputElement.cpp (modified) (8 diffs)
-
Source/WebCore/html/HTMLInputElement.h (modified) (4 diffs)
-
Source/WebCore/html/HTMLTextAreaElement.cpp (modified) (1 diff)
-
Source/WebCore/html/HTMLTextAreaElement.h (modified) (1 diff)
-
Source/WebCore/html/HTMLTextFormControlElement.cpp (modified) (4 diffs)
-
Source/WebCore/html/HTMLTextFormControlElement.h (modified) (1 diff)
-
Source/WebCore/html/InputType.cpp (modified) (3 diffs)
-
Source/WebCore/html/InputType.h (modified) (4 diffs)
-
Source/WebCore/html/RangeInputType.cpp (modified) (10 diffs)
-
Source/WebCore/html/RangeInputType.h (modified) (1 diff)
-
Source/WebCore/html/SearchInputType.cpp (modified) (2 diffs)
-
Source/WebCore/html/SearchInputType.h (modified) (1 diff)
-
Source/WebCore/html/TextFieldInputType.cpp (modified) (13 diffs)
-
Source/WebCore/html/TextFieldInputType.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r290281 r290284 1 2022-02-21 Cameron McCormack <heycam@apple.com> 2 3 Make input element UA shadow tree creation lazy 4 https://bugs.webkit.org/show_bug.cgi?id=236747 5 6 Reviewed by Aditya Keerthi. 7 8 * fast/forms/lazy-shadow-tree-creation-expected.html: Added. 9 * fast/forms/lazy-shadow-tree-creation.html: Added. 10 * fast/forms/lazy-shadow-tree-creation.js: Added. 11 (supportsType): 12 (makeAndAppendInput): 13 1 14 2022-02-21 Jon Lee <jonlee@apple.com> 2 15 -
trunk/Source/WebCore/ChangeLog
r290278 r290284 1 2022-02-21 Cameron McCormack <heycam@apple.com> 2 3 Make input element UA shadow tree creation lazy 4 https://bugs.webkit.org/show_bug.cgi?id=236747 5 6 Reviewed by Aditya Keerthi. 7 8 We currently delay InputType creation for parser inserted elements until 9 just after the attributes have been set, so that we don't wastefully 10 create an InputType and the UA shadow tree creation if a non-text 11 type="" was specified on the tag. We don't do anything similar for 12 script inserted input elements. We could make the InputType creation 13 lazy, but most of the wasted time is due to the shadow tree creation. 14 15 This patch makes InputType shadow tree creation lazy by delaying it 16 until one of the following happens: 17 18 1. the element is inserted into the document 19 2. the type="" or value="" attributes are changed before the element 20 is inserted into the document 21 3. any DOM methods that need access to the innerTextElement() are 22 called on the element before the element is inserted into the 23 document 24 25 Not all places where we call innerTextElement() on the 26 HTMLInputElement are safe to lazily create the shadow trees, so we 27 have two accessors: 28 29 - innerTextElement() returns the inner text element if it's been 30 created already 31 - innerTextElementCreatingShadowSubtreeIfNeeded will perform the lazy 32 shadow tree construction if it hasn't already been done 33 34 Since the existing 35 createShadowSubtreeAndUpdateInnerTextElementEditability function has 36 more responsibility than just creating the subtree and ensuring the 37 editability is set appropriately, it's renamed to a more manageable 38 createShadowSubtree. 39 40 This change is a 0.5% progression on Speedometer 2. 41 42 Test: fast/forms/lazy-shadow-tree-creation.html 43 44 * html/BaseDateAndTimeInputType.h: 45 * html/BaseDateAndTimeInputType.cpp: 46 (WebCore::BaseDateAndTimeInputType::createShadowSubtree): 47 (WebCore::BaseDateAndTimeInputType::createShadowSubtreeAndUpdateInnerTextElementEditability): 48 * html/ColorInputType.h: 49 * html/ColorInputType.cpp: 50 (WebCore::ColorInputType::createShadowSubtree): 51 (WebCore::ColorInputType::createShadowSubtreeAndUpdateInnerTextElementEditability): 52 * html/FileInputType.h: 53 * html/FileInputType.cpp: 54 (WebCore::FileInputType::createShadowSubtree): 55 (WebCore::FileInputType::createShadowSubtreeAndUpdateInnerTextElementEditability): 56 * html/InputType.cpp: 57 (WebCore::InputType::createShadowSubtree): 58 (WebCore::InputType::createShadowSubtreeAndUpdateInnerTextElementEditability): 59 * html/RangeInputType.h: 60 * html/RangeInputType.cpp: 61 (WebCore::RangeInputType::createShadowSubtree): 62 (WebCore::RangeInputType::createShadowSubtreeAndUpdateInnerTextElementEditability): 63 * html/SearchInputType.h: 64 * html/SearchInputType.cpp: 65 (WebCore::SearchInputType::createShadowSubtree): 66 (WebCore::SearchInputType::createShadowSubtreeAndUpdateInnerTextElementEditability): 67 Renamed createShadowSubtreeAndUpdateInnerTextElementEditability to 68 createShadowSubtree and remove the "isInnerTextElementEditable" 69 argument, since we can ask the element() for its value if needed. 70 createShadowSubtree is now also responsible for creating the shadow 71 root. 72 73 * html/TextFieldInputType.h: 74 * html/TextFieldInputType.cpp: 75 (WebCore::TextFieldInputType::createShadowSubtree): 76 (WebCore::TextFieldInputType::createShadowSubtreeAndUpdateInnerTextElementEditability): 77 Renamed. Ensure all shadow tree state is up to date now that it can be 78 created later. 79 80 * html/InputType.h: 81 * html/InputType.cpp: 82 (WebCore::InputType::createShadowSubtree): 83 (WebCore::InputType::hasCreatedShadowSubtree const): 84 New functions to create the shadow subtree if it hasn't been done 85 already, and to query whether it's been done. 86 87 * html/HTMLInputElement.h: 88 * html/HTMLInputElement.cpp: 89 (WebCore::HTMLInputElement::innerTextElementCreatingShadowSubtreeIfNeeded): 90 * html/HTMLTextAreaElement.h: 91 * html/HTMLTextAreaElement.cpp: 92 (WebCore::HTMLTextAreaElement::innerTextElementCreatingShadowSubtreeIfNeeded): 93 * html/HTMLTextFormControlElement.h: 94 * html/InputType.h: 95 * html/InputType.cpp: 96 (WebCore::InputType::innerTextElementCreatingShadowSubtreeIfNeeded): 97 New functions to first create the shadow subtree before returning 98 innerTextElement(). HTMLTextAreaElement never lazily creates its 99 shadow subtree and so just returns innerTextElement(). 100 101 * html/HTMLInputElement.h: 102 * html/HTMLInputElement.cpp: 103 (WebCore::HTMLInputElement::createShadowSubtreeAndUpdateInnerTextElementEditability): 104 Deleted. Just call through to m_inputType->createShadowTree() 105 directly. 106 107 (WebCore::HTMLInputElement::HTMLInputElement): 108 (WebCore::HTMLInputElement::create): 109 (WebCore::HTMLInputElement::initializeInputType): 110 (WebCore::HTMLInputElement::updateType): 111 Don't immediately create the shadow tree. 112 113 (WebCore::HTMLInputElement::didFinishInsertingNode): 114 Create the shadow subtree now that the element's been inserted. No 115 need to call dataListMayHaveChanged since 116 TextFieldInputType::createShadowSubtree will now do this. 117 118 * html/BaseDateAndTimeInputType.cpp: 119 (WebCore::BaseDateAndTimeInputType::updateInnerTextValue): 120 Ensure the shadow subtree is created since we need to poke at it. 121 122 * html/HTMLTextFormControlElement.cpp: 123 (WebCore::HTMLTextFormControlElement::forwardEvent): 124 Don't forward the event if the shadow tree hasn't been created yet. 125 126 (WebCore::HTMLTextFormControlElement::setSelectionRange): 127 Ensure the shadow tree has been created. This is needed if the 128 selection APIs are called on the input element before it's inserted 129 into the document. 130 131 (WebCore::HTMLTextFormControlElement::visiblePositionForIndex const): 132 Assert that the shadow tree has been created, since editing 133 functionality should only be needed if the element's been inserted 134 into the document. 135 136 (WebCore::HTMLTextFormControlElement::setInnerTextValue): 137 Ensure the shadow tree has been created. 138 139 * html/RangeInputType.cpp: 140 (WebCore::RangeInputType::handleMouseDownEvent): 141 (WebCore::RangeInputType::handleTouchEvent): 142 (WebCore::RangeInputType::handleKeydownEvent): 143 Ensure the shadow tree has been created in case the event will change 144 the value. 145 146 (WebCore::RangeInputType::sliderTrackElement const): 147 Only return the element if it's been created. 148 149 (WebCore::RangeInputType::typedSliderThumbElement const): 150 Assert that the element has been created. 151 152 (WebCore::RangeInputType::dataListMayHaveChanged): 153 Only try to re-layout if the shadow tree has been created. 154 155 * html/TextFieldInputType.cpp: 156 (WebCore::TextFieldInputType::isEmptyValue const): 157 Avoid creating the shadow subtree. 158 159 (WebCore::TextFieldInputType::forwardEvent): 160 Move the element assertion up to be consistent with other functions. 161 162 (WebCore::TextFieldInputType::innerTextElement const): 163 Don't assert, since this now can legitimately return null. 164 165 * html/FileInputType.cpp: 166 (WebCore::FileInputType::disabledStateChanged): 167 (WebCore::FileInputType::attributeChanged): 168 * html/RangeInputType.cpp: 169 (WebCore::RangeInputType::disabledStateChanged): 170 (WebCore::RangeInputType::attributeChanged): 171 (WebCore::RangeInputType::setValue): 172 * html/TextFieldInputType.cpp: 173 (WebCore::TextFieldInputType::disabledStateChanged): 174 (WebCore::TextFieldInputType::readOnlyStateChanged): 175 (WebCore::TextFieldInputType::updatePlaceholderText): 176 (WebCore::TextFieldInputType::updateAutoFillButton): 177 (WebCore::TextFieldInputType::dataListMayHaveChanged): 178 Don't update the shadow tree contents if it hasn't been created yet. 179 createShadowTree is responsible for ensuring it creates the shadow 180 tree contents reflecting the current state. 181 1 182 2022-02-21 Wenson Hsieh <wenson_hsieh@apple.com> 2 183 -
trunk/Source/WebCore/html/BaseDateAndTimeInputType.cpp
r290086 r290284 307 307 } 308 308 309 void BaseDateAndTimeInputType::createShadowSubtree AndUpdateInnerTextElementEditability(bool)309 void BaseDateAndTimeInputType::createShadowSubtree() 310 310 { 311 311 ASSERT(needsShadowSubtree()); … … 335 335 { 336 336 ASSERT(element()); 337 338 createShadowSubtreeIfNeeded(); 339 337 340 if (!m_dateTimeEditElement) { 338 341 auto node = element()->userAgentShadowRoot()->firstChild(); -
trunk/Source/WebCore/html/BaseDateAndTimeInputType.h
r290086 r290284 115 115 116 116 void handleDOMActivateEvent(Event&) override; 117 void createShadowSubtree AndUpdateInnerTextElementEditability(bool) final;117 void createShadowSubtree() final; 118 118 void destroyShadowSubtree() final; 119 119 void updateInnerTextValue() final; -
trunk/Source/WebCore/html/ColorInputType.cpp
r290086 r290284 137 137 } 138 138 139 void ColorInputType::createShadowSubtree AndUpdateInnerTextElementEditability(bool)139 void ColorInputType::createShadowSubtree() 140 140 { 141 141 ASSERT(needsShadowSubtree()); -
trunk/Source/WebCore/html/ColorInputType.h
r290086 r290284 63 63 String fallbackValue() const final; 64 64 String sanitizeValue(const String&) const final; 65 void createShadowSubtree AndUpdateInnerTextElementEditability(bool) final;65 void createShadowSubtree() final; 66 66 void setValue(const String&, bool valueChanged, TextFieldEventBehavior) final; 67 67 void attributeChanged(const QualifiedName&) final; -
trunk/Source/WebCore/html/FileInputType.cpp
r290086 r290284 263 263 } 264 264 265 void FileInputType::createShadowSubtree AndUpdateInnerTextElementEditability(bool)265 void FileInputType::createShadowSubtree() 266 266 { 267 267 ASSERT(needsShadowSubtree()); 268 268 ASSERT(element()); 269 269 ASSERT(element()->shadowRoot()); 270 element()->userAgentShadowRoot()->appendChild(ContainerNode::ChildChange::Source::Parser, element()->multiple() ? UploadButtonElement::createForMultiple(element()->document()): UploadButtonElement::create(element()->document())); 270 271 auto button = element()->multiple() ? UploadButtonElement::createForMultiple(element()->document()) : UploadButtonElement::create(element()->document()); 272 element()->userAgentShadowRoot()->appendChild(ContainerNode::ChildChange::Source::Parser, button); 273 disabledStateChanged(); 271 274 } 272 275 … … 274 277 { 275 278 ASSERT(element()); 276 ASSERT(element()->shadowRoot());277 279 278 280 auto root = element()->userAgentShadowRoot(); … … 288 290 if (name == multipleAttr) { 289 291 if (auto* element = this->element()) { 290 ASSERT(element->shadowRoot());291 292 if (auto root = element->userAgentShadowRoot()) { 292 293 if (RefPtr button = childrenOfType<UploadButtonElement>(*root).first()) -
trunk/Source/WebCore/html/FileInputType.h
r290086 r290284 78 78 79 79 Icon* icon() const final; 80 void createShadowSubtree AndUpdateInnerTextElementEditability(bool) final;80 void createShadowSubtree() final; 81 81 void disabledStateChanged() final; 82 82 void attributeChanged(const QualifiedName&) final; -
trunk/Source/WebCore/html/HTMLInputElement.cpp
r290086 r290284 137 137 , m_isSpellcheckDisabledExceptTextReplacement(false) 138 138 { 139 // m_inputType is lazily created when constructed by the parser to avoid constructing unnecessarily a text inputType and140 // its shadow subtree,just to destroy them when the |type| attribute gets set by the parser to something else than 'text'.139 // m_inputType is lazily created when constructed by the parser to avoid constructing unnecessarily a text inputType, 140 // just to destroy them when the |type| attribute gets set by the parser to something else than 'text'. 141 141 if (!createdByParser) 142 142 m_inputType = InputType::createText(*this); … … 148 148 Ref<HTMLInputElement> HTMLInputElement::create(const QualifiedName& tagName, Document& document, HTMLFormElement* form, bool createdByParser) 149 149 { 150 bool shouldCreateShadowRootLazily = createdByParser; 151 Ref<HTMLInputElement> inputElement = adoptRef(*new HTMLInputElement(tagName, document, form, createdByParser)); 152 if (!shouldCreateShadowRootLazily) { 153 ASSERT(inputElement->m_inputType->needsShadowSubtree()); 154 inputElement->createUserAgentShadowRoot(); 155 inputElement->createShadowSubtreeAndUpdateInnerTextElementEditability(); 156 } 157 return inputElement; 150 return adoptRef(*new HTMLInputElement(tagName, document, form, createdByParser)); 158 151 } 159 152 … … 163 156 m_imageLoader = makeUnique<HTMLImageLoader>(*this); 164 157 return *m_imageLoader; 165 }166 167 void HTMLInputElement::createShadowSubtreeAndUpdateInnerTextElementEditability()168 {169 Ref<InputType> protectedInputType(*m_inputType);170 protectedInputType->createShadowSubtreeAndUpdateInnerTextElementEditability(isInnerTextElementEditable());171 158 } 172 159 … … 211 198 { 212 199 return m_inputType->innerTextElement(); 200 } 201 202 RefPtr<TextControlInnerTextElement> HTMLInputElement::innerTextElementCreatingShadowSubtreeIfNeeded() 203 { 204 return m_inputType->innerTextElementCreatingShadowSubtreeIfNeeded(); 213 205 } 214 206 … … 581 573 582 574 m_inputType = WTFMove(newType); 583 if (m_inputType->needsShadowSubtree()) { 584 ensureUserAgentShadowRoot(); 585 createShadowSubtreeAndUpdateInnerTextElementEditability(); 586 } 575 m_inputType->createShadowSubtreeIfNeeded(); 587 576 588 577 updateWillValidateAndValidity(); … … 737 726 if (type.isNull()) { 738 727 m_inputType = InputType::createText(*this); 739 ASSERT(m_inputType->needsShadowSubtree());740 createUserAgentShadowRoot();741 createShadowSubtreeAndUpdateInnerTextElementEditability();742 728 updateWillValidateAndValidity(); 743 729 return; … … 746 732 m_hasType = true; 747 733 m_inputType = InputType::create(*this, type); 748 if (m_inputType->needsShadowSubtree()) {749 createUserAgentShadowRoot();750 createShadowSubtreeAndUpdateInnerTextElementEditability();751 }752 734 updateWillValidateAndValidity(); 753 735 registerForSuspensionCallbackIfNeeded(); … … 1600 1582 if (isInTreeScope() && !form()) 1601 1583 addToRadioButtonGroup(); 1602 #if ENABLE(DATALIST_ELEMENT) 1603 if (isConnected() && m_hasNonEmptyList) 1604 dataListMayHaveChanged(); 1605 #endif 1584 if (isConnected()) 1585 m_inputType->createShadowSubtreeIfNeeded(); 1606 1586 } 1607 1587 -
trunk/Source/WebCore/html/HTMLInputElement.h
r289813 r290284 138 138 139 139 RefPtr<TextControlInnerTextElement> innerTextElement() const final; 140 RefPtr<TextControlInnerTextElement> innerTextElementCreatingShadowSubtreeIfNeeded() final; 140 141 RenderStyle createInnerTextStyle(const RenderStyle&) final; 141 142 … … 357 358 String resultForDialogSubmit() const final; 358 359 360 bool isInnerTextElementEditable() const final { return !hasAutoFillStrongPasswordButton() && HTMLTextFormControlElement::isInnerTextElementEditable(); } 361 359 362 protected: 360 363 HTMLInputElement(const QualifiedName&, Document&, HTMLFormElement*, bool createdByParser); … … 371 374 void removedFromAncestor(RemovalType, ContainerNode&) final; 372 375 void didMoveToNewDocument(Document& oldDocument, Document& newDocument) final; 373 374 void createShadowSubtreeAndUpdateInnerTextElementEditability();375 376 376 377 int defaultTabIndex() const final; … … 384 385 385 386 bool isInteractiveContent() const final; 386 387 bool isInnerTextElementEditable() const final { return !hasAutoFillStrongPasswordButton() && HTMLTextFormControlElement::isInnerTextElementEditable(); }388 387 389 388 bool canTriggerImplicitSubmission() const final { return isTextField(); } -
trunk/Source/WebCore/html/HTMLTextAreaElement.cpp
r288005 r290284 346 346 } 347 347 348 RefPtr<TextControlInnerTextElement> HTMLTextAreaElement::innerTextElementCreatingShadowSubtreeIfNeeded() 349 { 350 return innerTextElement(); 351 } 352 348 353 void HTMLTextAreaElement::rendererWillBeDestroyed() 349 354 { -
trunk/Source/WebCore/html/HTMLTextAreaElement.h
r286447 r290284 58 58 59 59 WEBCORE_EXPORT RefPtr<TextControlInnerTextElement> innerTextElement() const final; 60 WEBCORE_EXPORT RefPtr<TextControlInnerTextElement> innerTextElementCreatingShadowSubtreeIfNeeded() final; 60 61 RenderStyle createInnerTextStyle(const RenderStyle&) final; 61 62 void copyNonAttributePropertiesFromElement(const Element&) final; -
trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp
r289246 r290284 158 158 if (event.type() == eventNames().blurEvent || event.type() == eventNames().focusEvent) 159 159 return; 160 innerTextElement()->defaultEventHandler(event); 160 161 if (auto innerText = innerTextElement()) 162 innerText->defaultEventHandler(event); 161 163 } 162 164 … … 310 312 start = std::min(std::max(start, 0), end); 311 313 312 auto innerText = innerTextElement ();314 auto innerText = innerTextElementCreatingShadowSubtreeIfNeeded(); 313 315 bool hasFocus = document().focusedElement() == this; 314 316 if (!hasFocus && innerText) { … … 370 372 VisiblePosition HTMLTextFormControlElement::visiblePositionForIndex(int index) const 371 373 { 374 ASSERT(innerTextElement()); 372 375 VisiblePosition position = positionForIndex(innerTextElement().get(), index); 373 376 ASSERT(indexForVisiblePosition(position) == index); … … 588 591 { 589 592 LayoutDisallowedScope layoutDisallowedScope(LayoutDisallowedScope::Reason::PerformanceOptimization); 590 auto innerText = innerTextElement ();593 auto innerText = innerTextElementCreatingShadowSubtreeIfNeeded(); 591 594 if (!innerText) 592 595 return; -
trunk/Source/WebCore/html/HTMLTextFormControlElement.h
r289246 r290284 90 90 91 91 virtual RefPtr<TextControlInnerTextElement> innerTextElement() const = 0; 92 virtual RefPtr<TextControlInnerTextElement> innerTextElementCreatingShadowSubtreeIfNeeded() = 0; 92 93 virtual RenderStyle createInnerTextStyle(const RenderStyle&) = 0; 93 94 -
trunk/Source/WebCore/html/InputType.cpp
r290086 r290284 562 562 } 563 563 564 void InputType::createShadowSubtree AndUpdateInnerTextElementEditability(bool)564 void InputType::createShadowSubtree() 565 565 { 566 566 } … … 1120 1120 } 1121 1121 1122 RefPtr<TextControlInnerTextElement> InputType::innerTextElementCreatingShadowSubtreeIfNeeded() 1123 { 1124 createShadowSubtreeIfNeeded(); 1125 return innerTextElement(); 1126 } 1127 1122 1128 String InputType::resultForDialogSubmit() const 1123 1129 { … … 1126 1132 } 1127 1133 1134 void InputType::createShadowSubtreeIfNeeded() 1135 { 1136 if (m_hasCreatedShadowSubtree || !needsShadowSubtree()) 1137 return; 1138 Ref protectedThis { *this }; 1139 element()->ensureUserAgentShadowRoot(); 1140 m_hasCreatedShadowSubtree = true; 1141 createShadowSubtree(); 1142 } 1143 1128 1144 } // namespace WebCore -
trunk/Source/WebCore/html/InputType.h
r290086 r290284 207 207 bool isEnumeratable() const; 208 208 bool needsShadowSubtree() const { return !nonShadowRootTypes.contains(m_type); } 209 bool hasCreatedShadowSubtree() const { return m_hasCreatedShadowSubtree; } 209 210 210 211 // Form value functions. … … 307 308 // Shadow tree handling. 308 309 309 virtual void createShadowSubtreeAndUpdateInnerTextElementEditability(bool); 310 void createShadowSubtreeIfNeeded(); 311 virtual void createShadowSubtree(); 310 312 virtual void destroyShadowSubtree(); 311 313 … … 324 326 virtual HTMLElement* dataListButtonElement() const { return nullptr; } 325 327 #endif 328 RefPtr<TextControlInnerTextElement> innerTextElementCreatingShadowSubtreeIfNeeded(); 326 329 327 330 // Miscellaneous functions. … … 414 417 415 418 const Type m_type; 419 bool m_hasCreatedShadowSubtree { false }; 416 420 // m_element is null if this InputType is no longer associated with an element (either the element died or changed input type). 417 421 WeakPtr<HTMLInputElement> m_element; -
trunk/Source/WebCore/html/RangeInputType.cpp
r290086 r290284 134 134 { 135 135 ASSERT(element()); 136 137 if (!hasCreatedShadowSubtree()) 138 return; 139 136 140 if (element()->isDisabledFormControl()) 137 141 return; … … 152 156 void RangeInputType::handleTouchEvent(TouchEvent& event) 153 157 { 158 ASSERT(element()); 159 160 if (!hasCreatedShadowSubtree()) 161 return; 162 154 163 #if PLATFORM(IOS_FAMILY) 155 164 typedSliderThumbElement().handleTouchEvent(event); 156 165 #elif ENABLE(TOUCH_SLIDER) 157 ASSERT(element()); 166 158 167 if (element()->isDisabledFormControl()) 159 168 return; … … 184 193 void RangeInputType::disabledStateChanged() 185 194 { 195 if (!hasCreatedShadowSubtree()) 196 return; 186 197 typedSliderThumbElement().hostDisabledStateChanged(); 187 198 } … … 190 201 { 191 202 ASSERT(element()); 203 204 if (!hasCreatedShadowSubtree()) 205 return ShouldCallBaseEventHandler::Yes; 206 192 207 if (element()->isDisabledFormControl()) 193 208 return ShouldCallBaseEventHandler::Yes; … … 242 257 } 243 258 244 void RangeInputType::createShadowSubtree AndUpdateInnerTextElementEditability(bool)259 void RangeInputType::createShadowSubtree() 245 260 { 246 261 ASSERT(needsShadowSubtree()); … … 260 275 { 261 276 ASSERT(element()); 277 278 if (!hasCreatedShadowSubtree()) 279 return nullptr; 280 262 281 ASSERT(element()->userAgentShadowRoot()); 263 282 ASSERT(element()->userAgentShadowRoot()->firstChild()); // container … … 278 297 SliderThumbElement& RangeInputType::typedSliderThumbElement() const 279 298 { 299 ASSERT(hasCreatedShadowSubtree()); 280 300 ASSERT(sliderTrackElement()->firstChild()); // thumb 281 301 ASSERT(sliderTrackElement()->firstChild()->isHTMLElement()); … … 323 343 element->setValue(element->value()); 324 344 } 325 typedSliderThumbElement().setPositionFromValue(); 345 if (hasCreatedShadowSubtree()) 346 typedSliderThumbElement().setPositionFromValue(); 326 347 } 327 348 InputType::attributeChanged(name); … … 340 361 } 341 362 342 typedSliderThumbElement().setPositionFromValue(); 363 if (hasCreatedShadowSubtree()) 364 typedSliderThumbElement().setPositionFromValue(); 343 365 } 344 366 … … 369 391 m_tickMarkValuesDirty = true; 370 392 RefPtr<HTMLElement> sliderTrackElement = this->sliderTrackElement(); 371 if (sliderTrackElement ->renderer())393 if (sliderTrackElement && sliderTrackElement->renderer()) 372 394 sliderTrackElement->renderer()->setNeedsLayout(); 373 395 } -
trunk/Source/WebCore/html/RangeInputType.h
r290086 r290284 53 53 ShouldCallBaseEventHandler handleKeydownEvent(KeyboardEvent&) final; 54 54 RenderPtr<RenderElement> createInputRenderer(RenderStyle&&) final; 55 void createShadowSubtree AndUpdateInnerTextElementEditability(bool) final;55 void createShadowSubtree() final; 56 56 Decimal parseToNumber(const String&, const Decimal&) const final; 57 57 String serialize(const Decimal&) const final; -
trunk/Source/WebCore/html/SearchInputType.cpp
r290086 r290284 103 103 } 104 104 105 void SearchInputType::createShadowSubtree AndUpdateInnerTextElementEditability(bool isInnerTextElementEditable)105 void SearchInputType::createShadowSubtree() 106 106 { 107 107 ASSERT(needsShadowSubtree()); … … 109 109 ASSERT(!m_cancelButton); 110 110 111 TextFieldInputType::createShadowSubtree AndUpdateInnerTextElementEditability(isInnerTextElementEditable);111 TextFieldInputType::createShadowSubtree(); 112 112 RefPtr<HTMLElement> container = containerElement(); 113 113 RefPtr<HTMLElement> textWrapper = innerBlockElement(); -
trunk/Source/WebCore/html/SearchInputType.h
r290086 r290284 52 52 const AtomString& formControlType() const final; 53 53 bool needsContainer() const final; 54 void createShadowSubtree AndUpdateInnerTextElementEditability(bool) final;54 void createShadowSubtree() final; 55 55 void destroyShadowSubtree() final; 56 56 HTMLElement* resultsButtonElement() const final; -
trunk/Source/WebCore/html/TextFieldInputType.cpp
r290086 r290284 109 109 { 110 110 auto innerText = innerTextElement(); 111 ASSERT(innerText); 111 if (!innerText) { 112 // Since we always create the shadow subtree if a value is set, we know 113 // that the value is empty. 114 return true; 115 } 112 116 113 117 for (Text* text = TextNodeTraversal::firstWithin(*innerText); text; text = TextNodeTraversal::next(*text, innerText.get())) { … … 222 226 void TextFieldInputType::forwardEvent(Event& event) 223 227 { 228 ASSERT(element()); 229 224 230 if (m_innerSpinButton) { 225 231 m_innerSpinButton->forwardEvent(event); … … 232 238 if (isFocusEvent || isBlurEvent) 233 239 capsLockStateMayHaveChanged(); 234 if (event.isMouseEvent() || isFocusEvent || isBlurEvent) { 235 ASSERT(element()); 240 if (event.isMouseEvent() || isFocusEvent || isBlurEvent) 236 241 element()->forwardEvent(event); 237 }238 242 } 239 243 … … 317 321 } 318 322 319 void TextFieldInputType::createShadowSubtree AndUpdateInnerTextElementEditability(bool isInnerTextElementEditable)323 void TextFieldInputType::createShadowSubtree() 320 324 { 321 325 ASSERT(needsShadowSubtree()); 322 326 ASSERT(element()); 323 327 ASSERT(element()->shadowRoot()); 328 ASSERT(!element()->shadowRoot()->hasChildNodes()); 324 329 325 330 ASSERT(!m_innerText); … … 332 337 bool shouldHaveSpinButton = this->shouldHaveSpinButton(); 333 338 bool shouldHaveCapsLockIndicator = this->shouldHaveCapsLockIndicator(); 334 bool createsContainer = shouldHaveSpinButton || shouldHaveCapsLockIndicator || needsContainer(); 335 336 m_innerText = TextControlInnerTextElement::create(document, isInnerTextElementEditable); 339 bool shouldDrawAutoFillButton = this->shouldDrawAutoFillButton(); 340 #if ENABLE(DATALIST_ELEMENT) 341 bool hasDataList = element()->list(); 342 #endif 343 bool createsContainer = shouldHaveSpinButton || shouldHaveCapsLockIndicator || shouldDrawAutoFillButton 344 #if ENABLE(DATALIST_ELEMENT) 345 || hasDataList 346 #endif 347 || needsContainer(); 348 349 m_innerText = TextControlInnerTextElement::create(document, element()->isInnerTextElementEditable()); 337 350 338 351 if (!createsContainer) { … … 359 372 m_container->appendChild(ContainerNode::ChildChange::Source::Parser, *m_capsLockIndicator); 360 373 } 374 361 375 updateAutoFillButton(); 376 377 #if ENABLE(DATALIST_ELEMENT) 378 dataListMayHaveChanged(); 379 #endif 362 380 } 363 381 … … 374 392 RefPtr<TextControlInnerTextElement> TextFieldInputType::innerTextElement() const 375 393 { 376 ASSERT(m_innerText);377 394 return m_innerText; 378 395 } … … 426 443 void TextFieldInputType::disabledStateChanged() 427 444 { 445 if (!hasCreatedShadowSubtree()) 446 return; 447 428 448 if (m_innerSpinButton) 429 449 m_innerSpinButton->releaseCapture(); … … 434 454 void TextFieldInputType::readOnlyStateChanged() 435 455 { 456 if (!hasCreatedShadowSubtree()) 457 return; 458 436 459 if (m_innerSpinButton) 437 460 m_innerSpinButton->releaseCapture(); … … 617 640 void TextFieldInputType::updatePlaceholderText() 618 641 { 642 ASSERT(element()); 643 644 if (!hasCreatedShadowSubtree()) 645 return; 646 619 647 if (!supportsPlaceholder()) 620 648 return; 621 ASSERT(element()); 649 622 650 String placeholderText = element()->placeholder(); 623 651 if (placeholderText.isEmpty()) { … … 817 845 void TextFieldInputType::updateAutoFillButton() 818 846 { 847 ASSERT(element()); 848 849 if (!hasCreatedShadowSubtree()) 850 return; 851 819 852 capsLockStateMayHaveChanged(); 820 853 … … 823 856 createContainer(); 824 857 825 ASSERT(element());826 858 AutoFillButtonType autoFillButtonType = element()->autoFillButtonType(); 827 859 if (!m_autoFillButton) … … 847 879 void TextFieldInputType::dataListMayHaveChanged() 848 880 { 881 if (!hasCreatedShadowSubtree()) 882 return; 883 849 884 m_cachedSuggestions = { }; 850 885 -
trunk/Source/WebCore/html/TextFieldInputType.h
r290086 r290284 71 71 72 72 virtual bool needsContainer() const; 73 void createShadowSubtree AndUpdateInnerTextElementEditability(bool) override;73 void createShadowSubtree() override; 74 74 void destroyShadowSubtree() override; 75 75 void attributeChanged(const QualifiedName&) override;
Note: See TracChangeset
for help on using the changeset viewer.