Title: [290414] trunk
Revision
290414
Author
[email protected]
Date
2022-02-23 23:28:49 -0800 (Wed, 23 Feb 2022)

Log Message

Unreviewed, reverting r290284.
https://bugs.webkit.org/show_bug.cgi?id=237131

It is preventing the fuzzer from finding other bugs

Reverted changeset:

"Make input element UA shadow tree creation lazy"
https://bugs.webkit.org/show_bug.cgi?id=236747
https://commits.webkit.org/r290284

Modified Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (290413 => 290414)


--- trunk/LayoutTests/ChangeLog	2022-02-24 06:35:55 UTC (rev 290413)
+++ trunk/LayoutTests/ChangeLog	2022-02-24 07:28:49 UTC (rev 290414)
@@ -1,3 +1,16 @@
+2022-02-23  Commit Queue  <[email protected]>
+
+        Unreviewed, reverting r290284.
+        https://bugs.webkit.org/show_bug.cgi?id=237131
+
+        It is preventing the fuzzer from finding other bugs
+
+        Reverted changeset:
+
+        "Make input element UA shadow tree creation lazy"
+        https://bugs.webkit.org/show_bug.cgi?id=236747
+        https://commits.webkit.org/r290284
+
 2022-02-23  Tim Nguyen  <[email protected]>
 
         Use of showModalDialog should appear as a warning in WI console

Deleted: trunk/LayoutTests/fast/forms/lazy-shadow-tree-creation-expected.html (290413 => 290414)


--- trunk/LayoutTests/fast/forms/lazy-shadow-tree-creation-expected.html	2022-02-24 06:35:55 UTC (rev 290413)
+++ trunk/LayoutTests/fast/forms/lazy-shadow-tree-creation-expected.html	2022-02-24 07:28:49 UTC (rev 290414)
@@ -1,6 +0,0 @@
-<!DOCTYPE html>
-<body>
-<script src=""
-<script>
-run({ useParser: true });
-</script>

Deleted: trunk/LayoutTests/fast/forms/lazy-shadow-tree-creation.html (290413 => 290414)


--- trunk/LayoutTests/fast/forms/lazy-shadow-tree-creation.html	2022-02-24 06:35:55 UTC (rev 290413)
+++ trunk/LayoutTests/fast/forms/lazy-shadow-tree-creation.html	2022-02-24 07:28:49 UTC (rev 290414)
@@ -1,6 +0,0 @@
-<!DOCTYPE html>
-<body>
-<script src=""
-<script>
-run({ useParser: false });
-</script>

Deleted: trunk/LayoutTests/fast/forms/lazy-shadow-tree-creation.js (290413 => 290414)


--- trunk/LayoutTests/fast/forms/lazy-shadow-tree-creation.js	2022-02-24 06:35:55 UTC (rev 290413)
+++ trunk/LayoutTests/fast/forms/lazy-shadow-tree-creation.js	2022-02-24 07:28:49 UTC (rev 290414)
@@ -1,57 +0,0 @@
-const types = {
-    "color": { value: "#008000" },
-    "date": { value: "2022-01-01" },
-    "datetime-local": { value: "2022-01-01" },
-    "email": { value: "[email protected]" },
-    "file": { },
-    "month": { value: "2022-01" },
-    "number": { value: "123" },
-    "password": { },
-    "range": { value: "75" },
-    "search": { value: "abc" },
-    "telephone": { value: "+61300000000" },
-    "text": { value: "abc" },
-    "time": { value: "10:00" },
-    "url": { value: "https://example.com/" },
-    "week": { value: "2022-W1" },
-};
-
-function supportsType(typeName) {
-    let e = document.createElement("input");
-    e.type = typeName;
-    return e.type == typeName;
-}
-
-function makeAndAppendInput(options, typeName, attributes = { }) {
-    let span = document.createElement("span");
-    document.body.append(span);
-
-    if (options.useParser) {
-        let tag = `<input type="${typeName}"`;
-        for (let name in attributes)
-            tag += ` ${name}="${attributes[name]}"`;
-        tag += ">";
-        span.innerHTML = tag;
-    } else {
-        let input = document.createElement("input");
-        input.type = typeName;
-        for (let name in attributes)
-            input.setAttribute(name, attributes[name]);
-        span.append(input);
-    }
-}
-
-function run(options) {
-    for (let typeName in types) {
-        if (!supportsType(typeName))
-            continue;
-
-        let type = types[typeName];
-        makeAndAppendInput(options, typeName);
-
-        if (type.value)
-            makeAndAppendInput(options, typeName, { value: type.value });
-
-        makeAndAppendInput(options, typeName, { value: type.value, disabled: "disabled" });
-    }
-}

Modified: trunk/Source/WebCore/ChangeLog (290413 => 290414)


--- trunk/Source/WebCore/ChangeLog	2022-02-24 06:35:55 UTC (rev 290413)
+++ trunk/Source/WebCore/ChangeLog	2022-02-24 07:28:49 UTC (rev 290414)
@@ -1,3 +1,16 @@
+2022-02-23  Commit Queue  <[email protected]>
+
+        Unreviewed, reverting r290284.
+        https://bugs.webkit.org/show_bug.cgi?id=237131
+
+        It is preventing the fuzzer from finding other bugs
+
+        Reverted changeset:
+
+        "Make input element UA shadow tree creation lazy"
+        https://bugs.webkit.org/show_bug.cgi?id=236747
+        https://commits.webkit.org/r290284
+
 2022-02-23  Tim Nguyen  <[email protected]>
 
         Use of showModalDialog should appear as a warning in WI console

Modified: trunk/Source/WebCore/html/BaseDateAndTimeInputType.cpp (290413 => 290414)


--- trunk/Source/WebCore/html/BaseDateAndTimeInputType.cpp	2022-02-24 06:35:55 UTC (rev 290413)
+++ trunk/Source/WebCore/html/BaseDateAndTimeInputType.cpp	2022-02-24 07:28:49 UTC (rev 290414)
@@ -306,7 +306,7 @@
     }
 }
 
-void BaseDateAndTimeInputType::createShadowSubtree()
+void BaseDateAndTimeInputType::createShadowSubtreeAndUpdateInnerTextElementEditability(bool)
 {
     ASSERT(needsShadowSubtree());
     ASSERT(element());
@@ -334,9 +334,6 @@
 void BaseDateAndTimeInputType::updateInnerTextValue()
 {
     ASSERT(element());
-
-    createShadowSubtreeIfNeeded();
-
     if (!m_dateTimeEditElement) {
         auto node = element()->userAgentShadowRoot()->firstChild();
         if (!is<HTMLElement>(node))

Modified: trunk/Source/WebCore/html/BaseDateAndTimeInputType.h (290413 => 290414)


--- trunk/Source/WebCore/html/BaseDateAndTimeInputType.h	2022-02-24 06:35:55 UTC (rev 290413)
+++ trunk/Source/WebCore/html/BaseDateAndTimeInputType.h	2022-02-24 07:28:49 UTC (rev 290414)
@@ -114,7 +114,7 @@
     bool isMouseFocusable() const final;
 
     void handleDOMActivateEvent(Event&) override;
-    void createShadowSubtree() final;
+    void createShadowSubtreeAndUpdateInnerTextElementEditability(bool) final;
     void destroyShadowSubtree() final;
     void updateInnerTextValue() final;
     bool hasCustomFocusLogic() const final;

Modified: trunk/Source/WebCore/html/ColorInputType.cpp (290413 => 290414)


--- trunk/Source/WebCore/html/ColorInputType.cpp	2022-02-24 06:35:55 UTC (rev 290413)
+++ trunk/Source/WebCore/html/ColorInputType.cpp	2022-02-24 07:28:49 UTC (rev 290414)
@@ -136,7 +136,7 @@
     return parseSimpleColorValue(element()->value()).value();
 }
 
-void ColorInputType::createShadowSubtree()
+void ColorInputType::createShadowSubtreeAndUpdateInnerTextElementEditability(bool)
 {
     ASSERT(needsShadowSubtree());
     ASSERT(element());

Modified: trunk/Source/WebCore/html/ColorInputType.h (290413 => 290414)


--- trunk/Source/WebCore/html/ColorInputType.h	2022-02-24 06:35:55 UTC (rev 290413)
+++ trunk/Source/WebCore/html/ColorInputType.h	2022-02-24 07:28:49 UTC (rev 290414)
@@ -62,7 +62,7 @@
     bool supportsRequired() const final;
     String fallbackValue() const final;
     String sanitizeValue(const String&) const final;
-    void createShadowSubtree() final;
+    void createShadowSubtreeAndUpdateInnerTextElementEditability(bool) final;
     void setValue(const String&, bool valueChanged, TextFieldEventBehavior) final;
     void attributeChanged(const QualifiedName&) final;
     void handleDOMActivateEvent(Event&) final;

Modified: trunk/Source/WebCore/html/FileInputType.cpp (290413 => 290414)


--- trunk/Source/WebCore/html/FileInputType.cpp	2022-02-24 06:35:55 UTC (rev 290413)
+++ trunk/Source/WebCore/html/FileInputType.cpp	2022-02-24 07:28:49 UTC (rev 290414)
@@ -262,20 +262,18 @@
     element()->invalidateStyleForSubtree();
 }
 
-void FileInputType::createShadowSubtree()
+void FileInputType::createShadowSubtreeAndUpdateInnerTextElementEditability(bool)
 {
     ASSERT(needsShadowSubtree());
     ASSERT(element());
     ASSERT(element()->shadowRoot());
-
-    auto button = element()->multiple() ? UploadButtonElement::createForMultiple(element()->document()) : UploadButtonElement::create(element()->document());
-    element()->userAgentShadowRoot()->appendChild(ContainerNode::ChildChange::Source::Parser, button);
-    disabledStateChanged();
+    element()->userAgentShadowRoot()->appendChild(ContainerNode::ChildChange::Source::Parser, element()->multiple() ? UploadButtonElement::createForMultiple(element()->document()): UploadButtonElement::create(element()->document()));
 }
 
 void FileInputType::disabledStateChanged()
 {
     ASSERT(element());
+    ASSERT(element()->shadowRoot());
 
     auto root = element()->userAgentShadowRoot();
     if (!root)
@@ -289,6 +287,7 @@
 {
     if (name == multipleAttr) {
         if (auto* element = this->element()) {
+            ASSERT(element->shadowRoot());
             if (auto root = element->userAgentShadowRoot()) {
                 if (RefPtr button = childrenOfType<UploadButtonElement>(*root).first())
                     button->setValue(element->multiple() ? fileButtonChooseMultipleFilesLabel() : fileButtonChooseFileLabel());

Modified: trunk/Source/WebCore/html/FileInputType.h (290413 => 290414)


--- trunk/Source/WebCore/html/FileInputType.h	2022-02-24 06:35:55 UTC (rev 290413)
+++ trunk/Source/WebCore/html/FileInputType.h	2022-02-24 07:28:49 UTC (rev 290414)
@@ -77,7 +77,7 @@
 #endif
 
     Icon* icon() const final;
-    void createShadowSubtree() final;
+    void createShadowSubtreeAndUpdateInnerTextElementEditability(bool) final;
     void disabledStateChanged() final;
     void attributeChanged(const QualifiedName&) final;
     String defaultToolTip() const final;

Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (290413 => 290414)


--- trunk/Source/WebCore/html/HTMLInputElement.cpp	2022-02-24 06:35:55 UTC (rev 290413)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp	2022-02-24 07:28:49 UTC (rev 290414)
@@ -136,8 +136,8 @@
 #endif
     , m_isSpellcheckDisabledExceptTextReplacement(false)
 {
-    // m_inputType is lazily created when constructed by the parser to avoid constructing unnecessarily a text inputType,
-    // just to destroy them when the |type| attribute gets set by the parser to something else than 'text'.
+    // m_inputType is lazily created when constructed by the parser to avoid constructing unnecessarily a text inputType and
+    // its shadow subtree, just to destroy them when the |type| attribute gets set by the parser to something else than 'text'.
     if (!createdByParser)
         m_inputType = InputType::createText(*this);
 
@@ -147,7 +147,14 @@
 
 Ref<HTMLInputElement> HTMLInputElement::create(const QualifiedName& tagName, Document& document, HTMLFormElement* form, bool createdByParser)
 {
-    return adoptRef(*new HTMLInputElement(tagName, document, form, createdByParser));
+    bool shouldCreateShadowRootLazily = createdByParser;
+    Ref<HTMLInputElement> inputElement = adoptRef(*new HTMLInputElement(tagName, document, form, createdByParser));
+    if (!shouldCreateShadowRootLazily) {
+        ASSERT(inputElement->m_inputType->needsShadowSubtree());
+        inputElement->createUserAgentShadowRoot();
+        inputElement->createShadowSubtreeAndUpdateInnerTextElementEditability();
+    }
+    return inputElement;
 }
 
 HTMLImageLoader& HTMLInputElement::ensureImageLoader()
@@ -157,6 +164,12 @@
     return *m_imageLoader;
 }
 
+void HTMLInputElement::createShadowSubtreeAndUpdateInnerTextElementEditability()
+{
+    Ref<InputType> protectedInputType(*m_inputType);
+    protectedInputType->createShadowSubtreeAndUpdateInnerTextElementEditability(isInnerTextElementEditable());
+}
+
 HTMLInputElement::~HTMLInputElement()
 {
     if (needsSuspensionCallback())
@@ -199,11 +212,6 @@
     return m_inputType->innerTextElement();
 }
 
-RefPtr<TextControlInnerTextElement> HTMLInputElement::innerTextElementCreatingShadowSubtreeIfNeeded()
-{
-    return m_inputType->innerTextElementCreatingShadowSubtreeIfNeeded();
-}
-
 HTMLElement* HTMLInputElement::innerBlockElement() const
 {
     return m_inputType->innerBlockElement();
@@ -572,7 +580,10 @@
     m_inputType->detachFromElement();
 
     m_inputType = WTFMove(newType);
-    m_inputType->createShadowSubtreeIfNeeded();
+    if (m_inputType->needsShadowSubtree()) {
+        ensureUserAgentShadowRoot();
+        createShadowSubtreeAndUpdateInnerTextElementEditability();
+    }
 
     updateWillValidateAndValidity();
 
@@ -725,6 +736,9 @@
     const AtomString& type = attributeWithoutSynchronization(typeAttr);
     if (type.isNull()) {
         m_inputType = InputType::createText(*this);
+        ASSERT(m_inputType->needsShadowSubtree());
+        createUserAgentShadowRoot();
+        createShadowSubtreeAndUpdateInnerTextElementEditability();
         updateWillValidateAndValidity();
         return;
     }
@@ -731,6 +745,10 @@
 
     m_hasType = true;
     m_inputType = InputType::create(*this, type);
+    if (m_inputType->needsShadowSubtree()) {
+        createUserAgentShadowRoot();
+        createShadowSubtreeAndUpdateInnerTextElementEditability();
+    }
     updateWillValidateAndValidity();
     registerForSuspensionCallbackIfNeeded();
     runPostTypeUpdateTasks();
@@ -1581,8 +1599,10 @@
     HTMLTextFormControlElement::didFinishInsertingNode();
     if (isInTreeScope() && !form())
         addToRadioButtonGroup();
-    if (isConnected())
-        m_inputType->createShadowSubtreeIfNeeded();
+#if ENABLE(DATALIST_ELEMENT)
+    if (isConnected() && m_hasNonEmptyList)
+        dataListMayHaveChanged();
+#endif
 }
 
 void HTMLInputElement::removedFromAncestor(RemovalType removalType, ContainerNode& oldParentOfRemovedTree)

Modified: trunk/Source/WebCore/html/HTMLInputElement.h (290413 => 290414)


--- trunk/Source/WebCore/html/HTMLInputElement.h	2022-02-24 06:35:55 UTC (rev 290413)
+++ trunk/Source/WebCore/html/HTMLInputElement.h	2022-02-24 07:28:49 UTC (rev 290414)
@@ -137,7 +137,6 @@
     HTMLElement* containerElement() const;
     
     RefPtr<TextControlInnerTextElement> innerTextElement() const final;
-    RefPtr<TextControlInnerTextElement> innerTextElementCreatingShadowSubtreeIfNeeded() final;
     RenderStyle createInnerTextStyle(const RenderStyle&) final;
 
     HTMLElement* innerBlockElement() const;
@@ -357,8 +356,6 @@
 
     String resultForDialogSubmit() const final;
 
-    bool isInnerTextElementEditable() const final { return !hasAutoFillStrongPasswordButton() && HTMLTextFormControlElement::isInnerTextElementEditable(); }
-
 protected:
     HTMLInputElement(const QualifiedName&, Document&, HTMLFormElement*, bool createdByParser);
 
@@ -374,6 +371,8 @@
     void removedFromAncestor(RemovalType, ContainerNode&) final;
     void didMoveToNewDocument(Document& oldDocument, Document& newDocument) final;
 
+    void createShadowSubtreeAndUpdateInnerTextElementEditability();
+
     int defaultTabIndex() const final;
     bool hasCustomFocusLogic() const final;
     bool isKeyboardFocusable(KeyboardEvent*) const final;
@@ -385,6 +384,8 @@
 
     bool isInteractiveContent() const final;
 
+    bool isInnerTextElementEditable() const final { return !hasAutoFillStrongPasswordButton() && HTMLTextFormControlElement::isInnerTextElementEditable(); }
+
     bool canTriggerImplicitSubmission() const final { return isTextField(); }
 
     const AtomString& formControlType() const final;

Modified: trunk/Source/WebCore/html/HTMLTextAreaElement.cpp (290413 => 290414)


--- trunk/Source/WebCore/html/HTMLTextAreaElement.cpp	2022-02-24 06:35:55 UTC (rev 290413)
+++ trunk/Source/WebCore/html/HTMLTextAreaElement.cpp	2022-02-24 07:28:49 UTC (rev 290414)
@@ -345,11 +345,6 @@
     return childrenOfType<TextControlInnerTextElement>(*root).first();
 }
 
-RefPtr<TextControlInnerTextElement> HTMLTextAreaElement::innerTextElementCreatingShadowSubtreeIfNeeded()
-{
-    return innerTextElement();
-}
-
 void HTMLTextAreaElement::rendererWillBeDestroyed()
 {
     updateValue();

Modified: trunk/Source/WebCore/html/HTMLTextAreaElement.h (290413 => 290414)


--- trunk/Source/WebCore/html/HTMLTextAreaElement.h	2022-02-24 06:35:55 UTC (rev 290413)
+++ trunk/Source/WebCore/html/HTMLTextAreaElement.h	2022-02-24 07:28:49 UTC (rev 290414)
@@ -57,7 +57,6 @@
     bool isValidValue(const String&) const;
     
     WEBCORE_EXPORT RefPtr<TextControlInnerTextElement> innerTextElement() const final;
-    WEBCORE_EXPORT RefPtr<TextControlInnerTextElement> innerTextElementCreatingShadowSubtreeIfNeeded() final;
     RenderStyle createInnerTextStyle(const RenderStyle&) final;
     void copyNonAttributePropertiesFromElement(const Element&) final;
 

Modified: trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp (290413 => 290414)


--- trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp	2022-02-24 06:35:55 UTC (rev 290413)
+++ trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp	2022-02-24 07:28:49 UTC (rev 290414)
@@ -157,9 +157,7 @@
 {
     if (event.type() == eventNames().blurEvent || event.type() == eventNames().focusEvent)
         return;
-
-    if (auto innerText = innerTextElement())
-        innerText->defaultEventHandler(event);
+    innerTextElement()->defaultEventHandler(event);
 }
 
 static bool isNotLineBreak(UChar ch) { return ch != newlineCharacter && ch != carriageReturn; }
@@ -311,7 +309,7 @@
     end = std::max(end, 0);
     start = std::min(std::max(start, 0), end);
 
-    auto innerText = innerTextElementCreatingShadowSubtreeIfNeeded();
+    auto innerText = innerTextElement();
     bool hasFocus = document().focusedElement() == this;
     if (!hasFocus && innerText) {
         if (!isConnected()) {
@@ -371,7 +369,6 @@
 
 VisiblePosition HTMLTextFormControlElement::visiblePositionForIndex(int index) const
 {
-    ASSERT(innerTextElement());
     VisiblePosition position = positionForIndex(innerTextElement().get(), index);
     ASSERT(indexForVisiblePosition(position) == index);
     return position;
@@ -590,7 +587,7 @@
 void HTMLTextFormControlElement::setInnerTextValue(const String& value)
 {
     LayoutDisallowedScope layoutDisallowedScope(LayoutDisallowedScope::Reason::PerformanceOptimization);
-    auto innerText = innerTextElementCreatingShadowSubtreeIfNeeded();
+    auto innerText = innerTextElement();
     if (!innerText)
         return;
 

Modified: trunk/Source/WebCore/html/HTMLTextFormControlElement.h (290413 => 290414)


--- trunk/Source/WebCore/html/HTMLTextFormControlElement.h	2022-02-24 06:35:55 UTC (rev 290413)
+++ trunk/Source/WebCore/html/HTMLTextFormControlElement.h	2022-02-24 07:28:49 UTC (rev 290414)
@@ -89,7 +89,6 @@
     virtual String value() const = 0;
 
     virtual RefPtr<TextControlInnerTextElement> innerTextElement() const = 0;
-    virtual RefPtr<TextControlInnerTextElement> innerTextElementCreatingShadowSubtreeIfNeeded() = 0;
     virtual RenderStyle createInnerTextStyle(const RenderStyle&) = 0;
 
     void selectionChanged(bool shouldFireSelectEvent);

Modified: trunk/Source/WebCore/html/InputType.cpp (290413 => 290414)


--- trunk/Source/WebCore/html/InputType.cpp	2022-02-24 06:35:55 UTC (rev 290413)
+++ trunk/Source/WebCore/html/InputType.cpp	2022-02-24 07:28:49 UTC (rev 290414)
@@ -561,7 +561,7 @@
     element()->defaultBlur();
 }
 
-void InputType::createShadowSubtree()
+void InputType::createShadowSubtreeAndUpdateInnerTextElementEditability(bool)
 {
 }
 
@@ -1119,12 +1119,6 @@
     return nullptr;
 }
 
-RefPtr<TextControlInnerTextElement> InputType::innerTextElementCreatingShadowSubtreeIfNeeded()
-{
-    createShadowSubtreeIfNeeded();
-    return innerTextElement();
-}
-
 String InputType::resultForDialogSubmit() const
 {
     ASSERT(element());
@@ -1131,14 +1125,4 @@
     return element()->value();
 }
 
-void InputType::createShadowSubtreeIfNeeded()
-{
-    if (m_hasCreatedShadowSubtree || !needsShadowSubtree())
-        return;
-    Ref protectedThis { *this };
-    element()->ensureUserAgentShadowRoot();
-    m_hasCreatedShadowSubtree = true;
-    createShadowSubtree();
-}
-
 } // namespace WebCore

Modified: trunk/Source/WebCore/html/InputType.h (290413 => 290414)


--- trunk/Source/WebCore/html/InputType.h	2022-02-24 06:35:55 UTC (rev 290413)
+++ trunk/Source/WebCore/html/InputType.h	2022-02-24 07:28:49 UTC (rev 290414)
@@ -206,7 +206,6 @@
     bool supportLabels() const;
     bool isEnumeratable() const;
     bool needsShadowSubtree() const { return !nonShadowRootTypes.contains(m_type); }
-    bool hasCreatedShadowSubtree() const { return m_hasCreatedShadowSubtree; }
 
     // Form value functions.
 
@@ -307,8 +306,7 @@
 
     // Shadow tree handling.
 
-    void createShadowSubtreeIfNeeded();
-    virtual void createShadowSubtree();
+    virtual void createShadowSubtreeAndUpdateInnerTextElementEditability(bool);
     virtual void destroyShadowSubtree();
 
     virtual HTMLElement* containerElement() const { return nullptr; }
@@ -325,7 +323,6 @@
 #if ENABLE(DATALIST_ELEMENT)
     virtual HTMLElement* dataListButtonElement() const { return nullptr; }
 #endif
-    RefPtr<TextControlInnerTextElement> innerTextElementCreatingShadowSubtreeIfNeeded();
 
     // Miscellaneous functions.
 
@@ -416,7 +413,6 @@
     ExceptionOr<void> applyStep(int count, AnyStepHandling, TextFieldEventBehavior);
 
     const Type m_type;
-    bool m_hasCreatedShadowSubtree { false };
     // m_element is null if this InputType is no longer associated with an element (either the element died or changed input type).
     WeakPtr<HTMLInputElement> m_element;
 };

Modified: trunk/Source/WebCore/html/RangeInputType.cpp (290413 => 290414)


--- trunk/Source/WebCore/html/RangeInputType.cpp	2022-02-24 06:35:55 UTC (rev 290413)
+++ trunk/Source/WebCore/html/RangeInputType.cpp	2022-02-24 07:28:49 UTC (rev 290414)
@@ -133,10 +133,6 @@
 void RangeInputType::handleMouseDownEvent(MouseEvent& event)
 {
     ASSERT(element());
-
-    if (!hasCreatedShadowSubtree())
-        return;
-
     if (element()->isDisabledFormControl())
         return;
 
@@ -155,15 +151,10 @@
 #if ENABLE(TOUCH_EVENTS)
 void RangeInputType::handleTouchEvent(TouchEvent& event)
 {
-    ASSERT(element());
-
-    if (!hasCreatedShadowSubtree())
-        return;
-
 #if PLATFORM(IOS_FAMILY)
     typedSliderThumbElement().handleTouchEvent(event);
 #elif ENABLE(TOUCH_SLIDER)
-
+    ASSERT(element());
     if (element()->isDisabledFormControl())
         return;
 
@@ -192,8 +183,6 @@
 
 void RangeInputType::disabledStateChanged()
 {
-    if (!hasCreatedShadowSubtree())
-        return;
     typedSliderThumbElement().hostDisabledStateChanged();
 }
 
@@ -200,10 +189,6 @@
 auto RangeInputType::handleKeydownEvent(KeyboardEvent& event) -> ShouldCallBaseEventHandler
 {
     ASSERT(element());
-
-    if (!hasCreatedShadowSubtree())
-        return ShouldCallBaseEventHandler::Yes;
-
     if (element()->isDisabledFormControl())
         return ShouldCallBaseEventHandler::Yes;
 
@@ -256,7 +241,7 @@
     return ShouldCallBaseEventHandler::Yes;
 }
 
-void RangeInputType::createShadowSubtree()
+void RangeInputType::createShadowSubtreeAndUpdateInnerTextElementEditability(bool)
 {
     ASSERT(needsShadowSubtree());
     ASSERT(element());
@@ -274,10 +259,6 @@
 HTMLElement* RangeInputType::sliderTrackElement() const
 {
     ASSERT(element());
-
-    if (!hasCreatedShadowSubtree())
-        return nullptr;
-
     ASSERT(element()->userAgentShadowRoot());
     ASSERT(element()->userAgentShadowRoot()->firstChild()); // container
     ASSERT(element()->userAgentShadowRoot()->firstChild()->isHTMLElement());
@@ -296,7 +277,6 @@
 
 SliderThumbElement& RangeInputType::typedSliderThumbElement() const
 {
-    ASSERT(hasCreatedShadowSubtree());
     ASSERT(sliderTrackElement()->firstChild()); // thumb
     ASSERT(sliderTrackElement()->firstChild()->isHTMLElement());
 
@@ -342,8 +322,7 @@
             if (element->hasDirtyValue())
                 element->setValue(element->value());
         }
-        if (hasCreatedShadowSubtree())
-            typedSliderThumbElement().setPositionFromValue();
+        typedSliderThumbElement().setPositionFromValue();
     }
     InputType::attributeChanged(name);
 }
@@ -360,8 +339,7 @@
         element()->setTextAsOfLastFormControlChangeEvent(value);
     }
 
-    if (hasCreatedShadowSubtree())
-        typedSliderThumbElement().setPositionFromValue();
+    typedSliderThumbElement().setPositionFromValue();
 }
 
 String RangeInputType::fallbackValue() const
@@ -390,7 +368,7 @@
 {
     m_tickMarkValuesDirty = true;
     RefPtr<HTMLElement> sliderTrackElement = this->sliderTrackElement();
-    if (sliderTrackElement && sliderTrackElement->renderer())
+    if (sliderTrackElement->renderer())
         sliderTrackElement->renderer()->setNeedsLayout();
 }
 

Modified: trunk/Source/WebCore/html/RangeInputType.h (290413 => 290414)


--- trunk/Source/WebCore/html/RangeInputType.h	2022-02-24 06:35:55 UTC (rev 290413)
+++ trunk/Source/WebCore/html/RangeInputType.h	2022-02-24 07:28:49 UTC (rev 290414)
@@ -52,7 +52,7 @@
     void handleMouseDownEvent(MouseEvent&) final;
     ShouldCallBaseEventHandler handleKeydownEvent(KeyboardEvent&) final;
     RenderPtr<RenderElement> createInputRenderer(RenderStyle&&) final;
-    void createShadowSubtree() final;
+    void createShadowSubtreeAndUpdateInnerTextElementEditability(bool) final;
     Decimal parseToNumber(const String&, const Decimal&) const final;
     String serialize(const Decimal&) const final;
     bool accessKeyAction(bool sendMouseEvents) final;

Modified: trunk/Source/WebCore/html/SearchInputType.cpp (290413 => 290414)


--- trunk/Source/WebCore/html/SearchInputType.cpp	2022-02-24 06:35:55 UTC (rev 290413)
+++ trunk/Source/WebCore/html/SearchInputType.cpp	2022-02-24 07:28:49 UTC (rev 290414)
@@ -102,13 +102,13 @@
     return true;
 }
 
-void SearchInputType::createShadowSubtree()
+void SearchInputType::createShadowSubtreeAndUpdateInnerTextElementEditability(bool isInnerTextElementEditable)
 {
     ASSERT(needsShadowSubtree());
     ASSERT(!m_resultsButton);
     ASSERT(!m_cancelButton);
 
-    TextFieldInputType::createShadowSubtree();
+    TextFieldInputType::createShadowSubtreeAndUpdateInnerTextElementEditability(isInnerTextElementEditable);
     RefPtr<HTMLElement> container = containerElement();
     RefPtr<HTMLElement> textWrapper = innerBlockElement();
     ASSERT(container);

Modified: trunk/Source/WebCore/html/SearchInputType.h (290413 => 290414)


--- trunk/Source/WebCore/html/SearchInputType.h	2022-02-24 06:35:55 UTC (rev 290413)
+++ trunk/Source/WebCore/html/SearchInputType.h	2022-02-24 07:28:49 UTC (rev 290414)
@@ -51,7 +51,7 @@
     RenderPtr<RenderElement> createInputRenderer(RenderStyle&&) final;
     const AtomString& formControlType() const final;
     bool needsContainer() const final;
-    void createShadowSubtree() final;
+    void createShadowSubtreeAndUpdateInnerTextElementEditability(bool) final;
     void destroyShadowSubtree() final;
     HTMLElement* resultsButtonElement() const final;
     HTMLElement* cancelButtonElement() const final;

Modified: trunk/Source/WebCore/html/TextFieldInputType.cpp (290413 => 290414)


--- trunk/Source/WebCore/html/TextFieldInputType.cpp	2022-02-24 06:35:55 UTC (rev 290413)
+++ trunk/Source/WebCore/html/TextFieldInputType.cpp	2022-02-24 07:28:49 UTC (rev 290414)
@@ -108,11 +108,7 @@
 bool TextFieldInputType::isEmptyValue() const
 {
     auto innerText = innerTextElement();
-    if (!innerText) {
-        // Since we always create the shadow subtree if a value is set, we know
-        // that the value is empty.
-        return true;
-    }
+    ASSERT(innerText);
 
     for (Text* text = TextNodeTraversal::firstWithin(*innerText); text; text = TextNodeTraversal::next(*text, innerText.get())) {
         if (text->length())
@@ -225,8 +221,6 @@
 
 void TextFieldInputType::forwardEvent(Event& event)
 {
-    ASSERT(element());
-
     if (m_innerSpinButton) {
         m_innerSpinButton->forwardEvent(event);
         if (event.defaultHandled())
@@ -237,8 +231,10 @@
     bool isBlurEvent = event.type() == eventNames().blurEvent;
     if (isFocusEvent || isBlurEvent)
         capsLockStateMayHaveChanged();
-    if (event.isMouseEvent() || isFocusEvent || isBlurEvent)
+    if (event.isMouseEvent() || isFocusEvent || isBlurEvent) {
+        ASSERT(element());
         element()->forwardEvent(event);
+    }
 }
 
 void TextFieldInputType::elementDidBlur()
@@ -320,12 +316,11 @@
     return RenderTheme::singleton().shouldHaveCapsLockIndicator(*element());
 }
 
-void TextFieldInputType::createShadowSubtree()
+void TextFieldInputType::createShadowSubtreeAndUpdateInnerTextElementEditability(bool isInnerTextElementEditable)
 {
     ASSERT(needsShadowSubtree());
     ASSERT(element());
     ASSERT(element()->shadowRoot());
-    ASSERT(!element()->shadowRoot()->hasChildNodes());
 
     ASSERT(!m_innerText);
     ASSERT(!m_innerBlock);
@@ -336,17 +331,9 @@
     Document& document = element()->document();
     bool shouldHaveSpinButton = this->shouldHaveSpinButton();
     bool shouldHaveCapsLockIndicator = this->shouldHaveCapsLockIndicator();
-    bool shouldDrawAutoFillButton = this->shouldDrawAutoFillButton();
-#if ENABLE(DATALIST_ELEMENT)
-    bool hasDataList = element()->list();
-#endif
-    bool createsContainer = shouldHaveSpinButton || shouldHaveCapsLockIndicator || shouldDrawAutoFillButton
-#if ENABLE(DATALIST_ELEMENT)
-        || hasDataList
-#endif
-        || needsContainer();
+    bool createsContainer = shouldHaveSpinButton || shouldHaveCapsLockIndicator || needsContainer();
 
-    m_innerText = TextControlInnerTextElement::create(document, element()->isInnerTextElementEditable());
+    m_innerText = TextControlInnerTextElement::create(document, isInnerTextElementEditable);
 
     if (!createsContainer) {
         element()->userAgentShadowRoot()->appendChild(ContainerNode::ChildChange::Source::Parser, *m_innerText);
@@ -371,12 +358,7 @@
 
         m_container->appendChild(ContainerNode::ChildChange::Source::Parser, *m_capsLockIndicator);
     }
-
     updateAutoFillButton();
-
-#if ENABLE(DATALIST_ELEMENT)
-    dataListMayHaveChanged();
-#endif
 }
 
 HTMLElement* TextFieldInputType::containerElement() const
@@ -391,6 +373,7 @@
 
 RefPtr<TextControlInnerTextElement> TextFieldInputType::innerTextElement() const
 {
+    ASSERT(m_innerText);
     return m_innerText;
 }
 
@@ -442,9 +425,6 @@
 
 void TextFieldInputType::disabledStateChanged()
 {
-    if (!hasCreatedShadowSubtree())
-        return;
-
     if (m_innerSpinButton)
         m_innerSpinButton->releaseCapture();
     capsLockStateMayHaveChanged();
@@ -453,9 +433,6 @@
 
 void TextFieldInputType::readOnlyStateChanged()
 {
-    if (!hasCreatedShadowSubtree())
-        return;
-
     if (m_innerSpinButton)
         m_innerSpinButton->releaseCapture();
     capsLockStateMayHaveChanged();
@@ -639,14 +616,9 @@
 
 void TextFieldInputType::updatePlaceholderText()
 {
-    ASSERT(element());
-
-    if (!hasCreatedShadowSubtree())
-        return;
-
     if (!supportsPlaceholder())
         return;
-
+    ASSERT(element());
     String placeholderText = element()->placeholder();
     if (placeholderText.isEmpty()) {
         if (m_placeholder) {
@@ -844,11 +816,6 @@
 
 void TextFieldInputType::updateAutoFillButton()
 {
-    ASSERT(element());
-
-    if (!hasCreatedShadowSubtree())
-        return;
-
     capsLockStateMayHaveChanged();
 
     if (shouldDrawAutoFillButton()) {
@@ -855,6 +822,7 @@
         if (!m_container)
             createContainer();
 
+        ASSERT(element());
         AutoFillButtonType autoFillButtonType = element()->autoFillButtonType();
         if (!m_autoFillButton)
             createAutoFillButton(autoFillButtonType);
@@ -878,9 +846,6 @@
 
 void TextFieldInputType::dataListMayHaveChanged()
 {
-    if (!hasCreatedShadowSubtree())
-        return;
-
     m_cachedSuggestions = { };
 
     if (!m_dataListDropdownIndicator)

Modified: trunk/Source/WebCore/html/TextFieldInputType.h (290413 => 290414)


--- trunk/Source/WebCore/html/TextFieldInputType.h	2022-02-24 06:35:55 UTC (rev 290413)
+++ trunk/Source/WebCore/html/TextFieldInputType.h	2022-02-24 07:28:49 UTC (rev 290414)
@@ -70,7 +70,7 @@
 #endif
 
     virtual bool needsContainer() const;
-    void createShadowSubtree() override;
+    void createShadowSubtreeAndUpdateInnerTextElementEditability(bool) override;
     void destroyShadowSubtree() override;
     void attributeChanged(const QualifiedName&) override;
     void disabledStateChanged() final;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to