Changeset 290414 in webkit
- Timestamp:
- Feb 23, 2022, 11:28:49 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 3 deleted
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r290412 r290414 1 2022-02-23 Commit Queue <commit-queue@webkit.org> 2 3 Unreviewed, reverting r290284. 4 https://bugs.webkit.org/show_bug.cgi?id=237131 5 6 It is preventing the fuzzer from finding other bugs 7 8 Reverted changeset: 9 10 "Make input element UA shadow tree creation lazy" 11 https://bugs.webkit.org/show_bug.cgi?id=236747 12 https://commits.webkit.org/r290284 13 1 14 2022-02-23 Tim Nguyen <ntim@apple.com> 2 15 -
trunk/Source/WebCore/ChangeLog
r290412 r290414 1 2022-02-23 Commit Queue <commit-queue@webkit.org> 2 3 Unreviewed, reverting r290284. 4 https://bugs.webkit.org/show_bug.cgi?id=237131 5 6 It is preventing the fuzzer from finding other bugs 7 8 Reverted changeset: 9 10 "Make input element UA shadow tree creation lazy" 11 https://bugs.webkit.org/show_bug.cgi?id=236747 12 https://commits.webkit.org/r290284 13 1 14 2022-02-23 Tim Nguyen <ntim@apple.com> 2 15 -
trunk/Source/WebCore/html/BaseDateAndTimeInputType.cpp
r290284 r290414 307 307 } 308 308 309 void BaseDateAndTimeInputType::createShadowSubtree ()309 void BaseDateAndTimeInputType::createShadowSubtreeAndUpdateInnerTextElementEditability(bool) 310 310 { 311 311 ASSERT(needsShadowSubtree()); … … 335 335 { 336 336 ASSERT(element()); 337 338 createShadowSubtreeIfNeeded();339 340 337 if (!m_dateTimeEditElement) { 341 338 auto node = element()->userAgentShadowRoot()->firstChild(); -
trunk/Source/WebCore/html/BaseDateAndTimeInputType.h
r290284 r290414 115 115 116 116 void handleDOMActivateEvent(Event&) override; 117 void createShadowSubtree () final;117 void createShadowSubtreeAndUpdateInnerTextElementEditability(bool) final; 118 118 void destroyShadowSubtree() final; 119 119 void updateInnerTextValue() final; -
trunk/Source/WebCore/html/ColorInputType.cpp
r290284 r290414 137 137 } 138 138 139 void ColorInputType::createShadowSubtree ()139 void ColorInputType::createShadowSubtreeAndUpdateInnerTextElementEditability(bool) 140 140 { 141 141 ASSERT(needsShadowSubtree()); -
trunk/Source/WebCore/html/ColorInputType.h
r290284 r290414 63 63 String fallbackValue() const final; 64 64 String sanitizeValue(const String&) const final; 65 void createShadowSubtree () final;65 void createShadowSubtreeAndUpdateInnerTextElementEditability(bool) final; 66 66 void setValue(const String&, bool valueChanged, TextFieldEventBehavior) final; 67 67 void attributeChanged(const QualifiedName&) final; -
trunk/Source/WebCore/html/FileInputType.cpp
r290284 r290414 263 263 } 264 264 265 void FileInputType::createShadowSubtree ()265 void FileInputType::createShadowSubtreeAndUpdateInnerTextElementEditability(bool) 266 266 { 267 267 ASSERT(needsShadowSubtree()); 268 268 ASSERT(element()); 269 269 ASSERT(element()->shadowRoot()); 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(); 270 element()->userAgentShadowRoot()->appendChild(ContainerNode::ChildChange::Source::Parser, element()->multiple() ? UploadButtonElement::createForMultiple(element()->document()): UploadButtonElement::create(element()->document())); 274 271 } 275 272 … … 277 274 { 278 275 ASSERT(element()); 276 ASSERT(element()->shadowRoot()); 279 277 280 278 auto root = element()->userAgentShadowRoot(); … … 290 288 if (name == multipleAttr) { 291 289 if (auto* element = this->element()) { 290 ASSERT(element->shadowRoot()); 292 291 if (auto root = element->userAgentShadowRoot()) { 293 292 if (RefPtr button = childrenOfType<UploadButtonElement>(*root).first()) -
trunk/Source/WebCore/html/FileInputType.h
r290284 r290414 78 78 79 79 Icon* icon() const final; 80 void createShadowSubtree () final;80 void createShadowSubtreeAndUpdateInnerTextElementEditability(bool) final; 81 81 void disabledStateChanged() final; 82 82 void attributeChanged(const QualifiedName&) final; -
trunk/Source/WebCore/html/HTMLInputElement.cpp
r290284 r290414 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 ,140 // 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 and 140 // its shadow subtree, 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 return adoptRef(*new HTMLInputElement(tagName, document, form, createdByParser)); 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; 151 158 } 152 159 … … 156 163 m_imageLoader = makeUnique<HTMLImageLoader>(*this); 157 164 return *m_imageLoader; 165 } 166 167 void HTMLInputElement::createShadowSubtreeAndUpdateInnerTextElementEditability() 168 { 169 Ref<InputType> protectedInputType(*m_inputType); 170 protectedInputType->createShadowSubtreeAndUpdateInnerTextElementEditability(isInnerTextElementEditable()); 158 171 } 159 172 … … 198 211 { 199 212 return m_inputType->innerTextElement(); 200 }201 202 RefPtr<TextControlInnerTextElement> HTMLInputElement::innerTextElementCreatingShadowSubtreeIfNeeded()203 {204 return m_inputType->innerTextElementCreatingShadowSubtreeIfNeeded();205 213 } 206 214 … … 573 581 574 582 m_inputType = WTFMove(newType); 575 m_inputType->createShadowSubtreeIfNeeded(); 583 if (m_inputType->needsShadowSubtree()) { 584 ensureUserAgentShadowRoot(); 585 createShadowSubtreeAndUpdateInnerTextElementEditability(); 586 } 576 587 577 588 updateWillValidateAndValidity(); … … 726 737 if (type.isNull()) { 727 738 m_inputType = InputType::createText(*this); 739 ASSERT(m_inputType->needsShadowSubtree()); 740 createUserAgentShadowRoot(); 741 createShadowSubtreeAndUpdateInnerTextElementEditability(); 728 742 updateWillValidateAndValidity(); 729 743 return; … … 732 746 m_hasType = true; 733 747 m_inputType = InputType::create(*this, type); 748 if (m_inputType->needsShadowSubtree()) { 749 createUserAgentShadowRoot(); 750 createShadowSubtreeAndUpdateInnerTextElementEditability(); 751 } 734 752 updateWillValidateAndValidity(); 735 753 registerForSuspensionCallbackIfNeeded(); … … 1582 1600 if (isInTreeScope() && !form()) 1583 1601 addToRadioButtonGroup(); 1584 if (isConnected()) 1585 m_inputType->createShadowSubtreeIfNeeded(); 1602 #if ENABLE(DATALIST_ELEMENT) 1603 if (isConnected() && m_hasNonEmptyList) 1604 dataListMayHaveChanged(); 1605 #endif 1586 1606 } 1587 1607 -
trunk/Source/WebCore/html/HTMLInputElement.h
r290284 r290414 138 138 139 139 RefPtr<TextControlInnerTextElement> innerTextElement() const final; 140 RefPtr<TextControlInnerTextElement> innerTextElementCreatingShadowSubtreeIfNeeded() final;141 140 RenderStyle createInnerTextStyle(const RenderStyle&) final; 142 141 … … 358 357 String resultForDialogSubmit() const final; 359 358 360 bool isInnerTextElementEditable() const final { return !hasAutoFillStrongPasswordButton() && HTMLTextFormControlElement::isInnerTextElementEditable(); }361 362 359 protected: 363 360 HTMLInputElement(const QualifiedName&, Document&, HTMLFormElement*, bool createdByParser); … … 374 371 void removedFromAncestor(RemovalType, ContainerNode&) final; 375 372 void didMoveToNewDocument(Document& oldDocument, Document& newDocument) final; 373 374 void createShadowSubtreeAndUpdateInnerTextElementEditability(); 376 375 377 376 int defaultTabIndex() const final; … … 385 384 386 385 bool isInteractiveContent() const final; 386 387 bool isInnerTextElementEditable() const final { return !hasAutoFillStrongPasswordButton() && HTMLTextFormControlElement::isInnerTextElementEditable(); } 387 388 388 389 bool canTriggerImplicitSubmission() const final { return isTextField(); } -
trunk/Source/WebCore/html/HTMLTextAreaElement.cpp
r290284 r290414 346 346 } 347 347 348 RefPtr<TextControlInnerTextElement> HTMLTextAreaElement::innerTextElementCreatingShadowSubtreeIfNeeded()349 {350 return innerTextElement();351 }352 353 348 void HTMLTextAreaElement::rendererWillBeDestroyed() 354 349 { -
trunk/Source/WebCore/html/HTMLTextAreaElement.h
r290284 r290414 58 58 59 59 WEBCORE_EXPORT RefPtr<TextControlInnerTextElement> innerTextElement() const final; 60 WEBCORE_EXPORT RefPtr<TextControlInnerTextElement> innerTextElementCreatingShadowSubtreeIfNeeded() final;61 60 RenderStyle createInnerTextStyle(const RenderStyle&) final; 62 61 void copyNonAttributePropertiesFromElement(const Element&) final; -
trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp
r290284 r290414 158 158 if (event.type() == eventNames().blurEvent || event.type() == eventNames().focusEvent) 159 159 return; 160 161 if (auto innerText = innerTextElement()) 162 innerText->defaultEventHandler(event); 160 innerTextElement()->defaultEventHandler(event); 163 161 } 164 162 … … 312 310 start = std::min(std::max(start, 0), end); 313 311 314 auto innerText = innerTextElement CreatingShadowSubtreeIfNeeded();312 auto innerText = innerTextElement(); 315 313 bool hasFocus = document().focusedElement() == this; 316 314 if (!hasFocus && innerText) { … … 372 370 VisiblePosition HTMLTextFormControlElement::visiblePositionForIndex(int index) const 373 371 { 374 ASSERT(innerTextElement());375 372 VisiblePosition position = positionForIndex(innerTextElement().get(), index); 376 373 ASSERT(indexForVisiblePosition(position) == index); … … 591 588 { 592 589 LayoutDisallowedScope layoutDisallowedScope(LayoutDisallowedScope::Reason::PerformanceOptimization); 593 auto innerText = innerTextElement CreatingShadowSubtreeIfNeeded();590 auto innerText = innerTextElement(); 594 591 if (!innerText) 595 592 return; -
trunk/Source/WebCore/html/HTMLTextFormControlElement.h
r290284 r290414 90 90 91 91 virtual RefPtr<TextControlInnerTextElement> innerTextElement() const = 0; 92 virtual RefPtr<TextControlInnerTextElement> innerTextElementCreatingShadowSubtreeIfNeeded() = 0;93 92 virtual RenderStyle createInnerTextStyle(const RenderStyle&) = 0; 94 93 -
trunk/Source/WebCore/html/InputType.cpp
r290284 r290414 562 562 } 563 563 564 void InputType::createShadowSubtree ()564 void InputType::createShadowSubtreeAndUpdateInnerTextElementEditability(bool) 565 565 { 566 566 } … … 1120 1120 } 1121 1121 1122 RefPtr<TextControlInnerTextElement> InputType::innerTextElementCreatingShadowSubtreeIfNeeded()1123 {1124 createShadowSubtreeIfNeeded();1125 return innerTextElement();1126 }1127 1128 1122 String InputType::resultForDialogSubmit() const 1129 1123 { … … 1132 1126 } 1133 1127 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 1144 1128 } // namespace WebCore -
trunk/Source/WebCore/html/InputType.h
r290284 r290414 207 207 bool isEnumeratable() const; 208 208 bool needsShadowSubtree() const { return !nonShadowRootTypes.contains(m_type); } 209 bool hasCreatedShadowSubtree() const { return m_hasCreatedShadowSubtree; }210 209 211 210 // Form value functions. … … 308 307 // Shadow tree handling. 309 308 310 void createShadowSubtreeIfNeeded(); 311 virtual void createShadowSubtree(); 309 virtual void createShadowSubtreeAndUpdateInnerTextElementEditability(bool); 312 310 virtual void destroyShadowSubtree(); 313 311 … … 326 324 virtual HTMLElement* dataListButtonElement() const { return nullptr; } 327 325 #endif 328 RefPtr<TextControlInnerTextElement> innerTextElementCreatingShadowSubtreeIfNeeded();329 326 330 327 // Miscellaneous functions. … … 417 414 418 415 const Type m_type; 419 bool m_hasCreatedShadowSubtree { false };420 416 // m_element is null if this InputType is no longer associated with an element (either the element died or changed input type). 421 417 WeakPtr<HTMLInputElement> m_element; -
trunk/Source/WebCore/html/RangeInputType.cpp
r290284 r290414 134 134 { 135 135 ASSERT(element()); 136 137 if (!hasCreatedShadowSubtree())138 return;139 140 136 if (element()->isDisabledFormControl()) 141 137 return; … … 156 152 void RangeInputType::handleTouchEvent(TouchEvent& event) 157 153 { 158 ASSERT(element());159 160 if (!hasCreatedShadowSubtree())161 return;162 163 154 #if PLATFORM(IOS_FAMILY) 164 155 typedSliderThumbElement().handleTouchEvent(event); 165 156 #elif ENABLE(TOUCH_SLIDER) 166 157 ASSERT(element()); 167 158 if (element()->isDisabledFormControl()) 168 159 return; … … 193 184 void RangeInputType::disabledStateChanged() 194 185 { 195 if (!hasCreatedShadowSubtree())196 return;197 186 typedSliderThumbElement().hostDisabledStateChanged(); 198 187 } … … 201 190 { 202 191 ASSERT(element()); 203 204 if (!hasCreatedShadowSubtree())205 return ShouldCallBaseEventHandler::Yes;206 207 192 if (element()->isDisabledFormControl()) 208 193 return ShouldCallBaseEventHandler::Yes; … … 257 242 } 258 243 259 void RangeInputType::createShadowSubtree ()244 void RangeInputType::createShadowSubtreeAndUpdateInnerTextElementEditability(bool) 260 245 { 261 246 ASSERT(needsShadowSubtree()); … … 275 260 { 276 261 ASSERT(element()); 277 278 if (!hasCreatedShadowSubtree())279 return nullptr;280 281 262 ASSERT(element()->userAgentShadowRoot()); 282 263 ASSERT(element()->userAgentShadowRoot()->firstChild()); // container … … 297 278 SliderThumbElement& RangeInputType::typedSliderThumbElement() const 298 279 { 299 ASSERT(hasCreatedShadowSubtree());300 280 ASSERT(sliderTrackElement()->firstChild()); // thumb 301 281 ASSERT(sliderTrackElement()->firstChild()->isHTMLElement()); … … 343 323 element->setValue(element->value()); 344 324 } 345 if (hasCreatedShadowSubtree()) 346 typedSliderThumbElement().setPositionFromValue(); 325 typedSliderThumbElement().setPositionFromValue(); 347 326 } 348 327 InputType::attributeChanged(name); … … 361 340 } 362 341 363 if (hasCreatedShadowSubtree()) 364 typedSliderThumbElement().setPositionFromValue(); 342 typedSliderThumbElement().setPositionFromValue(); 365 343 } 366 344 … … 391 369 m_tickMarkValuesDirty = true; 392 370 RefPtr<HTMLElement> sliderTrackElement = this->sliderTrackElement(); 393 if (sliderTrackElement && sliderTrackElement->renderer())371 if (sliderTrackElement->renderer()) 394 372 sliderTrackElement->renderer()->setNeedsLayout(); 395 373 } -
trunk/Source/WebCore/html/RangeInputType.h
r290284 r290414 53 53 ShouldCallBaseEventHandler handleKeydownEvent(KeyboardEvent&) final; 54 54 RenderPtr<RenderElement> createInputRenderer(RenderStyle&&) final; 55 void createShadowSubtree () final;55 void createShadowSubtreeAndUpdateInnerTextElementEditability(bool) 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
r290284 r290414 103 103 } 104 104 105 void SearchInputType::createShadowSubtree ()105 void SearchInputType::createShadowSubtreeAndUpdateInnerTextElementEditability(bool isInnerTextElementEditable) 106 106 { 107 107 ASSERT(needsShadowSubtree()); … … 109 109 ASSERT(!m_cancelButton); 110 110 111 TextFieldInputType::createShadowSubtree ();111 TextFieldInputType::createShadowSubtreeAndUpdateInnerTextElementEditability(isInnerTextElementEditable); 112 112 RefPtr<HTMLElement> container = containerElement(); 113 113 RefPtr<HTMLElement> textWrapper = innerBlockElement(); -
trunk/Source/WebCore/html/SearchInputType.h
r290284 r290414 52 52 const AtomString& formControlType() const final; 53 53 bool needsContainer() const final; 54 void createShadowSubtree () final;54 void createShadowSubtreeAndUpdateInnerTextElementEditability(bool) final; 55 55 void destroyShadowSubtree() final; 56 56 HTMLElement* resultsButtonElement() const final; -
trunk/Source/WebCore/html/TextFieldInputType.cpp
r290284 r290414 109 109 { 110 110 auto innerText = innerTextElement(); 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 } 111 ASSERT(innerText); 116 112 117 113 for (Text* text = TextNodeTraversal::firstWithin(*innerText); text; text = TextNodeTraversal::next(*text, innerText.get())) { … … 226 222 void TextFieldInputType::forwardEvent(Event& event) 227 223 { 228 ASSERT(element());229 230 224 if (m_innerSpinButton) { 231 225 m_innerSpinButton->forwardEvent(event); … … 238 232 if (isFocusEvent || isBlurEvent) 239 233 capsLockStateMayHaveChanged(); 240 if (event.isMouseEvent() || isFocusEvent || isBlurEvent) 234 if (event.isMouseEvent() || isFocusEvent || isBlurEvent) { 235 ASSERT(element()); 241 236 element()->forwardEvent(event); 237 } 242 238 } 243 239 … … 321 317 } 322 318 323 void TextFieldInputType::createShadowSubtree ()319 void TextFieldInputType::createShadowSubtreeAndUpdateInnerTextElementEditability(bool isInnerTextElementEditable) 324 320 { 325 321 ASSERT(needsShadowSubtree()); 326 322 ASSERT(element()); 327 323 ASSERT(element()->shadowRoot()); 328 ASSERT(!element()->shadowRoot()->hasChildNodes());329 324 330 325 ASSERT(!m_innerText); … … 337 332 bool shouldHaveSpinButton = this->shouldHaveSpinButton(); 338 333 bool shouldHaveCapsLockIndicator = this->shouldHaveCapsLockIndicator(); 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()); 334 bool createsContainer = shouldHaveSpinButton || shouldHaveCapsLockIndicator || needsContainer(); 335 336 m_innerText = TextControlInnerTextElement::create(document, isInnerTextElementEditable); 350 337 351 338 if (!createsContainer) { … … 372 359 m_container->appendChild(ContainerNode::ChildChange::Source::Parser, *m_capsLockIndicator); 373 360 } 374 375 361 updateAutoFillButton(); 376 377 #if ENABLE(DATALIST_ELEMENT)378 dataListMayHaveChanged();379 #endif380 362 } 381 363 … … 392 374 RefPtr<TextControlInnerTextElement> TextFieldInputType::innerTextElement() const 393 375 { 376 ASSERT(m_innerText); 394 377 return m_innerText; 395 378 } … … 443 426 void TextFieldInputType::disabledStateChanged() 444 427 { 445 if (!hasCreatedShadowSubtree())446 return;447 448 428 if (m_innerSpinButton) 449 429 m_innerSpinButton->releaseCapture(); … … 454 434 void TextFieldInputType::readOnlyStateChanged() 455 435 { 456 if (!hasCreatedShadowSubtree())457 return;458 459 436 if (m_innerSpinButton) 460 437 m_innerSpinButton->releaseCapture(); … … 640 617 void TextFieldInputType::updatePlaceholderText() 641 618 { 642 ASSERT(element());643 644 if (!hasCreatedShadowSubtree())645 return;646 647 619 if (!supportsPlaceholder()) 648 620 return; 649 621 ASSERT(element()); 650 622 String placeholderText = element()->placeholder(); 651 623 if (placeholderText.isEmpty()) { … … 845 817 void TextFieldInputType::updateAutoFillButton() 846 818 { 847 ASSERT(element());848 849 if (!hasCreatedShadowSubtree())850 return;851 852 819 capsLockStateMayHaveChanged(); 853 820 … … 856 823 createContainer(); 857 824 825 ASSERT(element()); 858 826 AutoFillButtonType autoFillButtonType = element()->autoFillButtonType(); 859 827 if (!m_autoFillButton) … … 879 847 void TextFieldInputType::dataListMayHaveChanged() 880 848 { 881 if (!hasCreatedShadowSubtree())882 return;883 884 849 m_cachedSuggestions = { }; 885 850 -
trunk/Source/WebCore/html/TextFieldInputType.h
r290284 r290414 71 71 72 72 virtual bool needsContainer() const; 73 void createShadowSubtree () override;73 void createShadowSubtreeAndUpdateInnerTextElementEditability(bool) override; 74 74 void destroyShadowSubtree() override; 75 75 void attributeChanged(const QualifiedName&) override;
Note:
See TracChangeset
for help on using the changeset viewer.