Title: [260977] trunk/Source/WebCore
Revision
260977
Author
ysuz...@apple.com
Date
2020-04-30 18:47:47 -0700 (Thu, 30 Apr 2020)

Log Message

Some HTML element critical paths include AtomString materialization
https://bugs.webkit.org/show_bug.cgi?id=211223

Reviewed by Saam Barati.

While measuring Speedometer2, I've noticed that every time we create some type of input element, we call AtomString multiple times while it is not necessary.
It turned out that this is because some places are using `AtomString("...", AtomString::ConstructFromLiteral)` instead of
`static NeverDestroyed<const AtomString> ...("...", AtomString::ConstructFromLiteral)`. Since HTML is in the main thread, we can just use `static NeverDestroyed<>`.
This patch fixes `AtomString()` calls by changing them to `NeverDestroyed<const AtomString>` if it is under WebCore/html directory.
And in this patch, we omit FTPDirectoryDocument, MediaDocument, and PluginDocument's fixes for now since their AtomString content has a bit different nature (some
pseudo CSS value ("-webkit-xxx") v.s. some particular CSS property value ("100%").

* html/ColorInputType.cpp:
(WebCore::ColorInputType::createShadowSubtree):
* html/FileInputType.cpp:
(WebCore::UploadButtonElement::UploadButtonElement):
* html/HTMLElement.cpp:
(WebCore::trueName):
(WebCore::falseName):
(WebCore::plaintextOnlyName):
(WebCore::HTMLElement::setContentEditable):
(WebCore::HTMLElement::setDraggable):
(WebCore::HTMLElement::setSpellcheck):
(WebCore::HTMLElement::setAutocorrect):
* html/HTMLTextFormControlElement.cpp:
(WebCore::HTMLTextFormControlElement::updateInnerTextElementEditability):
* html/RangeInputType.cpp:
(WebCore::RangeInputType::createShadowSubtree):
* html/SearchInputType.cpp:
(WebCore::updateResultButtonPseudoType):
* html/TextFieldInputType.cpp:
(WebCore::TextFieldInputType::createShadowSubtree):
(WebCore::TextFieldInputType::createDataListDropdownIndicator):
(WebCore::TextFieldInputType::createContainer):
(WebCore::TextFieldInputType::createAutoFillButton):
* html/ValidationMessage.cpp:
(WebCore::ValidationMessage::buildBubbleTree):
* html/shadow/DetailsMarkerControl.cpp:
(WebCore::DetailsMarkerControl::DetailsMarkerControl):
* html/shadow/MediaControlTextTrackContainerElement.cpp:
(WebCore::MediaControlTextTrackContainerElement::MediaControlTextTrackContainerElement):
* html/shadow/ProgressShadowElement.cpp:
(WebCore::ProgressInnerElement::create):
(WebCore::ProgressBarElement::create):
(WebCore::ProgressValueElement::create):
* html/shadow/ProgressShadowElement.h:
(WebCore::ProgressInnerElement::create): Deleted.
(WebCore::ProgressBarElement::create): Deleted.
(WebCore::ProgressValueElement::create): Deleted.
* html/shadow/SpinButtonElement.cpp:
(WebCore::SpinButtonElement::SpinButtonElement):
* html/shadow/TextControlInnerElements.cpp:
(WebCore::TextControlPlaceholderElement::TextControlPlaceholderElement):
(WebCore::SearchFieldCancelButtonElement::SearchFieldCancelButtonElement):
* html/shadow/YouTubeEmbedShadowElement.cpp:
(WebCore::YouTubeEmbedShadowElement::YouTubeEmbedShadowElement):
* html/shadow/mac/ImageControlsButtonElementMac.cpp:
(WebCore::ImageControlsButtonElementMac::tryCreate):
* html/shadow/mac/ImageControlsRootElementMac.cpp:
(WebCore::ImageControlsRootElement::tryCreate):
* html/track/TextTrackCue.cpp:
(WebCore::TextTrackCue::rebuildDisplayTree):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (260976 => 260977)


--- trunk/Source/WebCore/ChangeLog	2020-05-01 01:13:03 UTC (rev 260976)
+++ trunk/Source/WebCore/ChangeLog	2020-05-01 01:47:47 UTC (rev 260977)
@@ -1,3 +1,68 @@
+2020-04-30  Yusuke Suzuki  <ysuz...@apple.com>
+
+        Some HTML element critical paths include AtomString materialization
+        https://bugs.webkit.org/show_bug.cgi?id=211223
+
+        Reviewed by Saam Barati.
+
+        While measuring Speedometer2, I've noticed that every time we create some type of input element, we call AtomString multiple times while it is not necessary.
+        It turned out that this is because some places are using `AtomString("...", AtomString::ConstructFromLiteral)` instead of
+        `static NeverDestroyed<const AtomString> ...("...", AtomString::ConstructFromLiteral)`. Since HTML is in the main thread, we can just use `static NeverDestroyed<>`.
+        This patch fixes `AtomString()` calls by changing them to `NeverDestroyed<const AtomString>` if it is under WebCore/html directory.
+        And in this patch, we omit FTPDirectoryDocument, MediaDocument, and PluginDocument's fixes for now since their AtomString content has a bit different nature (some
+        pseudo CSS value ("-webkit-xxx") v.s. some particular CSS property value ("100%").
+
+        * html/ColorInputType.cpp:
+        (WebCore::ColorInputType::createShadowSubtree):
+        * html/FileInputType.cpp:
+        (WebCore::UploadButtonElement::UploadButtonElement):
+        * html/HTMLElement.cpp:
+        (WebCore::trueName):
+        (WebCore::falseName):
+        (WebCore::plaintextOnlyName):
+        (WebCore::HTMLElement::setContentEditable):
+        (WebCore::HTMLElement::setDraggable):
+        (WebCore::HTMLElement::setSpellcheck):
+        (WebCore::HTMLElement::setAutocorrect):
+        * html/HTMLTextFormControlElement.cpp:
+        (WebCore::HTMLTextFormControlElement::updateInnerTextElementEditability):
+        * html/RangeInputType.cpp:
+        (WebCore::RangeInputType::createShadowSubtree):
+        * html/SearchInputType.cpp:
+        (WebCore::updateResultButtonPseudoType):
+        * html/TextFieldInputType.cpp:
+        (WebCore::TextFieldInputType::createShadowSubtree):
+        (WebCore::TextFieldInputType::createDataListDropdownIndicator):
+        (WebCore::TextFieldInputType::createContainer):
+        (WebCore::TextFieldInputType::createAutoFillButton):
+        * html/ValidationMessage.cpp:
+        (WebCore::ValidationMessage::buildBubbleTree):
+        * html/shadow/DetailsMarkerControl.cpp:
+        (WebCore::DetailsMarkerControl::DetailsMarkerControl):
+        * html/shadow/MediaControlTextTrackContainerElement.cpp:
+        (WebCore::MediaControlTextTrackContainerElement::MediaControlTextTrackContainerElement):
+        * html/shadow/ProgressShadowElement.cpp:
+        (WebCore::ProgressInnerElement::create):
+        (WebCore::ProgressBarElement::create):
+        (WebCore::ProgressValueElement::create):
+        * html/shadow/ProgressShadowElement.h:
+        (WebCore::ProgressInnerElement::create): Deleted.
+        (WebCore::ProgressBarElement::create): Deleted.
+        (WebCore::ProgressValueElement::create): Deleted.
+        * html/shadow/SpinButtonElement.cpp:
+        (WebCore::SpinButtonElement::SpinButtonElement):
+        * html/shadow/TextControlInnerElements.cpp:
+        (WebCore::TextControlPlaceholderElement::TextControlPlaceholderElement):
+        (WebCore::SearchFieldCancelButtonElement::SearchFieldCancelButtonElement):
+        * html/shadow/YouTubeEmbedShadowElement.cpp:
+        (WebCore::YouTubeEmbedShadowElement::YouTubeEmbedShadowElement):
+        * html/shadow/mac/ImageControlsButtonElementMac.cpp:
+        (WebCore::ImageControlsButtonElementMac::tryCreate):
+        * html/shadow/mac/ImageControlsRootElementMac.cpp:
+        (WebCore::ImageControlsRootElement::tryCreate):
+        * html/track/TextTrackCue.cpp:
+        (WebCore::TextTrackCue::rebuildDisplayTree):
+
 2020-04-30  Jiewen Tan  <jiewen_...@apple.com>
 
         [WebAuthn] Optimize LocalAuthenticator

Modified: trunk/Source/WebCore/html/ColorInputType.cpp (260976 => 260977)


--- trunk/Source/WebCore/html/ColorInputType.cpp	2020-05-01 01:13:03 UTC (rev 260976)
+++ trunk/Source/WebCore/html/ColorInputType.cpp	2020-05-01 01:47:47 UTC (rev 260977)
@@ -143,11 +143,15 @@
     ASSERT(element());
     ASSERT(element()->shadowRoot());
 
+    static NeverDestroyed<const AtomString> webkitColorSwatchName("-webkit-color-swatch", AtomString::ConstructFromLiteral);
+    static NeverDestroyed<const AtomString> webkitColorSwatchWrapperName("-webkit-color-swatch-wrapper", AtomString::ConstructFromLiteral);
+    ASSERT(isMainThread());
+
     Document& document = element()->document();
     auto wrapperElement = HTMLDivElement::create(document);
-    wrapperElement->setPseudo(AtomString("-webkit-color-swatch-wrapper", AtomString::ConstructFromLiteral));
+    wrapperElement->setPseudo(webkitColorSwatchWrapperName);
     auto colorSwatch = HTMLDivElement::create(document);
-    colorSwatch->setPseudo(AtomString("-webkit-color-swatch", AtomString::ConstructFromLiteral));
+    colorSwatch->setPseudo(webkitColorSwatchName);
     wrapperElement->appendChild(colorSwatch);
     element()->userAgentShadowRoot()->appendChild(wrapperElement);
 

Modified: trunk/Source/WebCore/html/FileInputType.cpp (260976 => 260977)


--- trunk/Source/WebCore/html/FileInputType.cpp	2020-05-01 01:13:03 UTC (rev 260976)
+++ trunk/Source/WebCore/html/FileInputType.cpp	2020-05-01 01:47:47 UTC (rev 260977)
@@ -89,8 +89,11 @@
 UploadButtonElement::UploadButtonElement(Document& document)
     : HTMLInputElement(inputTag, document, 0, false)
 {
-    setType(AtomString("button", AtomString::ConstructFromLiteral));
-    setPseudo(AtomString("-webkit-file-upload-button", AtomString::ConstructFromLiteral));
+    static NeverDestroyed<const AtomString> buttonName("button", AtomString::ConstructFromLiteral);
+    static NeverDestroyed<const AtomString> webkitFileUploadButtonName("-webkit-file-upload-button", AtomString::ConstructFromLiteral);
+    ASSERT(isMainThread());
+    setType(buttonName);
+    setPseudo(webkitFileUploadButtonName);
 }
 
 FileInputType::FileInputType(HTMLInputElement& element)

Modified: trunk/Source/WebCore/html/HTMLElement.cpp (260976 => 260977)


--- trunk/Source/WebCore/html/HTMLElement.cpp	2020-05-01 01:13:03 UTC (rev 260976)
+++ trunk/Source/WebCore/html/HTMLElement.cpp	2020-05-01 01:47:47 UTC (rev 260977)
@@ -660,14 +660,35 @@
     return "inherit"_s;
 }
 
+static const AtomString& trueName()
+{
+    static NeverDestroyed<const AtomString> trueValue("true", AtomString::ConstructFromLiteral);
+    ASSERT(isMainThread());
+    return trueValue.get();
+}
+
+static const AtomString& falseName()
+{
+    static NeverDestroyed<const AtomString> falseValue("false", AtomString::ConstructFromLiteral);
+    ASSERT(isMainThread());
+    return falseValue.get();
+}
+
+static const AtomString& plaintextOnlyName()
+{
+    static NeverDestroyed<const AtomString> plaintextOnlyValue("plaintext-only", AtomString::ConstructFromLiteral);
+    ASSERT(isMainThread());
+    return plaintextOnlyValue.get();
+}
+
 ExceptionOr<void> HTMLElement::setContentEditable(const String& enabled)
 {
     if (equalLettersIgnoringASCIICase(enabled, "true"))
-        setAttributeWithoutSynchronization(contenteditableAttr, AtomString("true", AtomString::ConstructFromLiteral));
+        setAttributeWithoutSynchronization(contenteditableAttr, trueName());
     else if (equalLettersIgnoringASCIICase(enabled, "false"))
-        setAttributeWithoutSynchronization(contenteditableAttr, AtomString("false", AtomString::ConstructFromLiteral));
+        setAttributeWithoutSynchronization(contenteditableAttr, falseName());
     else if (equalLettersIgnoringASCIICase(enabled, "plaintext-only"))
-        setAttributeWithoutSynchronization(contenteditableAttr, AtomString("plaintext-only", AtomString::ConstructFromLiteral));
+        setAttributeWithoutSynchronization(contenteditableAttr, plaintextOnlyName());
     else if (equalLettersIgnoringASCIICase(enabled, "inherit"))
         removeAttribute(contenteditableAttr);
     else
@@ -682,9 +703,7 @@
 
 void HTMLElement::setDraggable(bool value)
 {
-    setAttributeWithoutSynchronization(draggableAttr, value
-        ? AtomString("true", AtomString::ConstructFromLiteral)
-        : AtomString("false", AtomString::ConstructFromLiteral));
+    setAttributeWithoutSynchronization(draggableAttr, value ? trueName() : falseName());
 }
 
 bool HTMLElement::spellcheck() const
@@ -694,9 +713,7 @@
 
 void HTMLElement::setSpellcheck(bool enable)
 {
-    setAttributeWithoutSynchronization(spellcheckAttr, enable
-        ? AtomString("true", AtomString::ConstructFromLiteral)
-        : AtomString("false", AtomString::ConstructFromLiteral));
+    setAttributeWithoutSynchronization(spellcheckAttr, enable ? trueName() : falseName());
 }
 
 void HTMLElement::click()
@@ -1100,7 +1117,10 @@
 
 void HTMLElement::setAutocorrect(bool autocorrect)
 {
-    setAttributeWithoutSynchronization(autocorrectAttr, autocorrect ? AtomString("on", AtomString::ConstructFromLiteral) : AtomString("off", AtomString::ConstructFromLiteral));
+    static NeverDestroyed<const AtomString> onName("on", AtomString::ConstructFromLiteral);
+    static NeverDestroyed<const AtomString> offName("off", AtomString::ConstructFromLiteral);
+    ASSERT(isMainThread());
+    setAttributeWithoutSynchronization(autocorrectAttr, autocorrect ? onName.get() : offName.get());
 }
 
 #endif

Modified: trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp (260976 => 260977)


--- trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp	2020-05-01 01:13:03 UTC (rev 260976)
+++ trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp	2020-05-01 01:47:47 UTC (rev 260977)
@@ -535,7 +535,10 @@
 void HTMLTextFormControlElement::updateInnerTextElementEditability()
 {
     if (auto innerText = innerTextElement()) {
-        auto value = isInnerTextElementEditable() ? AtomString { "plaintext-only", AtomString::ConstructFromLiteral } : AtomString { "false", AtomString::ConstructFromLiteral };
+        static NeverDestroyed<const AtomString> plainTextOnlyName("plaintext-only", AtomString::ConstructFromLiteral);
+        static NeverDestroyed<const AtomString> falseName("false", AtomString::ConstructFromLiteral);
+        ASSERT(isMainThread());
+        const auto& value = isInnerTextElementEditable() ? plainTextOnlyName.get() : falseName.get();
         innerText->setAttributeWithoutSynchronization(contenteditableAttr, value);
     }
 }

Modified: trunk/Source/WebCore/html/RangeInputType.cpp (260976 => 260977)


--- trunk/Source/WebCore/html/RangeInputType.cpp	2020-05-01 01:13:03 UTC (rev 260976)
+++ trunk/Source/WebCore/html/RangeInputType.cpp	2020-05-01 01:47:47 UTC (rev 260977)
@@ -255,9 +255,11 @@
     ASSERT(element());
     ASSERT(element()->userAgentShadowRoot());
 
+    static NeverDestroyed<const AtomString> webkitSliderRunnableTrackName("-webkit-slider-runnable-track", AtomString::ConstructFromLiteral);
+    ASSERT(isMainThread());
     Document& document = element()->document();
     auto track = HTMLDivElement::create(document);
-    track->setPseudo(AtomString("-webkit-slider-runnable-track", AtomString::ConstructFromLiteral));
+    track->setPseudo(webkitSliderRunnableTrackName);
     track->appendChild(SliderThumbElement::create(document));
     auto container = SliderContainerElement::create(document);
     container->appendChild(track);

Modified: trunk/Source/WebCore/html/SearchInputType.cpp (260976 => 260977)


--- trunk/Source/WebCore/html/SearchInputType.cpp	2020-05-01 01:13:03 UTC (rev 260976)
+++ trunk/Source/WebCore/html/SearchInputType.cpp	2020-05-01 01:47:47 UTC (rev 260977)
@@ -64,12 +64,16 @@
 
 static void updateResultButtonPseudoType(SearchFieldResultsButtonElement& resultButton, int maxResults)
 {
+    static NeverDestroyed<const AtomString> webkitSearchDecorationName("-webkit-search-decoration", AtomString::ConstructFromLiteral);
+    static NeverDestroyed<const AtomString> webkitSearchResultsDecorationName("-webkit-search-results-decoration", AtomString::ConstructFromLiteral);
+    static NeverDestroyed<const AtomString> webkitSearchResultsButtonName("-webkit-search-results-button", AtomString::ConstructFromLiteral);
+    ASSERT(isMainThread());
     if (!maxResults)
-        resultButton.setPseudo(AtomString("-webkit-search-results-decoration", AtomString::ConstructFromLiteral));
+        resultButton.setPseudo(webkitSearchResultsDecorationName);
     else if (maxResults < 0)
-        resultButton.setPseudo(AtomString("-webkit-search-decoration", AtomString::ConstructFromLiteral));
+        resultButton.setPseudo(webkitSearchDecorationName);
     else
-        resultButton.setPseudo(AtomString("-webkit-search-results-button", AtomString::ConstructFromLiteral));
+        resultButton.setPseudo(webkitSearchResultsButtonName);
 }
 
 void SearchInputType::attributeChanged(const QualifiedName& name)

Modified: trunk/Source/WebCore/html/TextFieldInputType.cpp (260976 => 260977)


--- trunk/Source/WebCore/html/TextFieldInputType.cpp	2020-05-01 01:13:03 UTC (rev 260976)
+++ trunk/Source/WebCore/html/TextFieldInputType.cpp	2020-05-01 01:47:47 UTC (rev 260977)
@@ -348,8 +348,10 @@
     }
 
     if (shouldHaveCapsLockIndicator) {
+        static NeverDestroyed<const AtomString> webkitCapsLockIndicatorName("-webkit-caps-lock-indicator", AtomString::ConstructFromLiteral);
+        ASSERT(isMainThread());
         m_capsLockIndicator = HTMLDivElement::create(document);
-        m_capsLockIndicator->setPseudo(AtomString("-webkit-caps-lock-indicator", AtomString::ConstructFromLiteral));
+        m_capsLockIndicator->setPseudo(webkitCapsLockIndicatorName);
 
         bool shouldDrawCapsLockIndicator = this->shouldDrawCapsLockIndicator();
         m_capsLockIndicator->setInlineStyleProperty(CSSPropertyDisplay, shouldDrawCapsLockIndicator ? CSSValueBlock : CSSValueNone, true);
@@ -455,10 +457,12 @@
     if (!m_container)
         createContainer();
 
+    static NeverDestroyed<const AtomString> webkitListButtonName("-webkit-list-button", AtomString::ConstructFromLiteral);
+    ASSERT(isMainThread());
     ScriptDisallowedScope::EventAllowedScope allowedScope(*m_container);
     m_dataListDropdownIndicator = DataListButtonElement::create(element()->document(), *this);
     m_container->appendChild(*m_dataListDropdownIndicator);
-    m_dataListDropdownIndicator->setPseudo(AtomString("-webkit-list-button", AtomString::ConstructFromLiteral));
+    m_dataListDropdownIndicator->setPseudo(webkitListButtonName);
     m_dataListDropdownIndicator->setInlineStyleProperty(CSSPropertyDisplay, CSSValueNone, true);
 }
 
@@ -778,11 +782,14 @@
     ASSERT(!m_container);
     ASSERT(element());
 
+    static NeverDestroyed<const AtomString> webkitTextfieldDecorationContainerName("-webkit-textfield-decoration-container", AtomString::ConstructFromLiteral);
+    ASSERT(isMainThread());
+
     ScriptDisallowedScope::EventAllowedScope allowedScope(*element()->userAgentShadowRoot());
 
     m_container = TextControlInnerContainer::create(element()->document());
     element()->userAgentShadowRoot()->appendChild(*m_container);
-    m_container->setPseudo(AtomString("-webkit-textfield-decoration-container", AtomString::ConstructFromLiteral));
+    m_container->setPseudo(webkitTextfieldDecorationContainerName);
 
     m_innerBlock = TextControlInnerElement::create(element()->document());
     m_container->appendChild(*m_innerBlock);
@@ -796,10 +803,12 @@
     if (autoFillButtonType == AutoFillButtonType::None)
         return;
 
+    static NeverDestroyed<const AtomString> buttonName("button", AtomString::ConstructFromLiteral);
+    ASSERT(isMainThread());
     ASSERT(element());
     m_autoFillButton = AutoFillButtonElement::create(element()->document(), *this);
     m_autoFillButton->setPseudo(autoFillButtonTypeToAutoFillButtonPseudoClassName(autoFillButtonType));
-    m_autoFillButton->setAttributeWithoutSynchronization(roleAttr, AtomString("button", AtomString::ConstructFromLiteral));
+    m_autoFillButton->setAttributeWithoutSynchronization(roleAttr, buttonName);
     m_autoFillButton->setAttributeWithoutSynchronization(aria_labelAttr, autoFillButtonTypeToAccessibilityLabel(autoFillButtonType));
     m_autoFillButton->setTextContent(autoFillButtonTypeToAutoFillButtonText(autoFillButtonType));
     m_container->appendChild(*m_autoFillButton);

Modified: trunk/Source/WebCore/html/ValidationMessage.cpp (260976 => 260977)


--- trunk/Source/WebCore/html/ValidationMessage.cpp	2020-05-01 01:13:03 UTC (rev 260976)
+++ trunk/Source/WebCore/html/ValidationMessage.cpp	2020-05-01 01:47:47 UTC (rev 260977)
@@ -181,9 +181,19 @@
 
     ShadowRoot& shadowRoot = m_element->ensureUserAgentShadowRoot();
 
+    static NeverDestroyed<const AtomString> webkitValidationBubbleName("-webkit-validation-bubble", AtomString::ConstructFromLiteral);
+    static NeverDestroyed<const AtomString> webkitValidationBubbleArrowClipperName("-webkit-validation-bubble-arrow-clipper", AtomString::ConstructFromLiteral);
+    static NeverDestroyed<const AtomString> webkitValidationBubbleArrowName("-webkit-validation-bubble-arrow", AtomString::ConstructFromLiteral);
+    static NeverDestroyed<const AtomString> webkitValidationBubbleMessageName("-webkit-validation-bubble-message", AtomString::ConstructFromLiteral);
+    static NeverDestroyed<const AtomString> webkitValidationBubbleIconName("-webkit-validation-bubble-icon", AtomString::ConstructFromLiteral);
+    static NeverDestroyed<const AtomString> webkitValidationBubbleTextBlockName("-webkit-validation-bubble-text-block", AtomString::ConstructFromLiteral);
+    static NeverDestroyed<const AtomString> webkitValidationBubbleHeadingName("-webkit-validation-bubble-heading", AtomString::ConstructFromLiteral);
+    static NeverDestroyed<const AtomString> webkitValidationBubbleBodyName("-webkit-validation-bubble-body", AtomString::ConstructFromLiteral);
+    ASSERT(isMainThread());
+
     Document& document = m_element->document();
     m_bubble = HTMLDivElement::create(document);
-    m_bubble->setPseudo(AtomString("-webkit-validation-bubble", AtomString::ConstructFromLiteral));
+    m_bubble->setPseudo(webkitValidationBubbleName);
     // Need to force position:absolute because RenderMenuList doesn't assume it
     // contains non-absolute or non-fixed renderers as children.
     m_bubble->setInlineStyleProperty(CSSPropertyPosition, CSSValueAbsolute);
@@ -199,24 +209,24 @@
     adjustBubblePosition(m_element->renderer()->absoluteBoundingBoxRect(), m_bubble.get());
 
     auto clipper = HTMLDivElement::create(document);
-    clipper->setPseudo(AtomString("-webkit-validation-bubble-arrow-clipper", AtomString::ConstructFromLiteral));
+    clipper->setPseudo(webkitValidationBubbleArrowClipperName);
     auto bubbleArrow = HTMLDivElement::create(document);
-    bubbleArrow->setPseudo(AtomString("-webkit-validation-bubble-arrow", AtomString::ConstructFromLiteral));
+    bubbleArrow->setPseudo(webkitValidationBubbleArrowName);
     clipper->appendChild(bubbleArrow);
     m_bubble->appendChild(clipper);
 
     auto message = HTMLDivElement::create(document);
-    message->setPseudo(AtomString("-webkit-validation-bubble-message", AtomString::ConstructFromLiteral));
+    message->setPseudo(webkitValidationBubbleMessageName);
     auto icon = HTMLDivElement::create(document);
-    icon->setPseudo(AtomString("-webkit-validation-bubble-icon", AtomString::ConstructFromLiteral));
+    icon->setPseudo(webkitValidationBubbleIconName);
     message->appendChild(icon);
     auto textBlock = HTMLDivElement::create(document);
-    textBlock->setPseudo(AtomString("-webkit-validation-bubble-text-block", AtomString::ConstructFromLiteral));
+    textBlock->setPseudo(webkitValidationBubbleTextBlockName);
     m_messageHeading = HTMLDivElement::create(document);
-    m_messageHeading->setPseudo(AtomString("-webkit-validation-bubble-heading", AtomString::ConstructFromLiteral));
+    m_messageHeading->setPseudo(webkitValidationBubbleHeadingName);
     textBlock->appendChild(*m_messageHeading);
     m_messageBody = HTMLDivElement::create(document);
-    m_messageBody->setPseudo(AtomString("-webkit-validation-bubble-body", AtomString::ConstructFromLiteral));
+    m_messageBody->setPseudo(webkitValidationBubbleBodyName);
     textBlock->appendChild(*m_messageBody);
     message->appendChild(textBlock);
     m_bubble->appendChild(message);

Modified: trunk/Source/WebCore/html/shadow/DetailsMarkerControl.cpp (260976 => 260977)


--- trunk/Source/WebCore/html/shadow/DetailsMarkerControl.cpp	2020-05-01 01:13:03 UTC (rev 260976)
+++ trunk/Source/WebCore/html/shadow/DetailsMarkerControl.cpp	2020-05-01 01:47:47 UTC (rev 260977)
@@ -49,7 +49,9 @@
 DetailsMarkerControl::DetailsMarkerControl(Document& document)
     : HTMLDivElement(HTMLNames::divTag, document)
 {
-    setPseudo(AtomString("-webkit-details-marker", AtomString::ConstructFromLiteral));
+    static NeverDestroyed<const AtomString> webkitDetailsMarkerName("-webkit-details-marker", AtomString::ConstructFromLiteral);
+    ASSERT(isMainThread());
+    setPseudo(webkitDetailsMarkerName);
 }
 
 RenderPtr<RenderElement> DetailsMarkerControl::createElementRenderer(RenderStyle&& style, const RenderTreePosition&)

Modified: trunk/Source/WebCore/html/shadow/MediaControlTextTrackContainerElement.cpp (260976 => 260977)


--- trunk/Source/WebCore/html/shadow/MediaControlTextTrackContainerElement.cpp	2020-05-01 01:13:03 UTC (rev 260976)
+++ trunk/Source/WebCore/html/shadow/MediaControlTextTrackContainerElement.cpp	2020-05-01 01:47:47 UTC (rev 260977)
@@ -77,7 +77,9 @@
     : HTMLDivElement(divTag, document)
     , m_mediaElement(makeWeakPtr(&element))
 {
-    setPseudo(AtomString("-webkit-media-text-track-container", AtomString::ConstructFromLiteral));
+    static NeverDestroyed<const AtomString> webkitMediaTextTrackContainerName("-webkit-media-text-track-container", AtomString::ConstructFromLiteral);
+    ASSERT(isMainThread());
+    setPseudo(webkitMediaTextTrackContainerName);
 }
 
 RenderPtr<RenderElement> MediaControlTextTrackContainerElement::createElementRenderer(RenderStyle&& style, const RenderTreePosition&)

Modified: trunk/Source/WebCore/html/shadow/ProgressShadowElement.cpp (260976 => 260977)


--- trunk/Source/WebCore/html/shadow/ProgressShadowElement.cpp	2020-05-01 01:13:03 UTC (rev 260976)
+++ trunk/Source/WebCore/html/shadow/ProgressShadowElement.cpp	2020-05-01 01:47:47 UTC (rev 260977)
@@ -89,4 +89,31 @@
     setInlineStyleProperty(CSSPropertyWidth, width, CSSUnitType::CSS_PERCENTAGE);
 }
 
+Ref<ProgressInnerElement> ProgressInnerElement::create(Document& document)
+{
+    static NeverDestroyed<const AtomString> webkitProgressInnerElementName("-webkit-progress-inner-element", AtomString::ConstructFromLiteral);
+    ASSERT(isMainThread());
+    Ref<ProgressInnerElement> result = adoptRef(*new ProgressInnerElement(document));
+    result->setPseudo(webkitProgressInnerElementName);
+    return result;
 }
+
+Ref<ProgressBarElement> ProgressBarElement::create(Document& document)
+{
+    static NeverDestroyed<const AtomString> webkitProgressBarName("-webkit-progress-bar", AtomString::ConstructFromLiteral);
+    ASSERT(isMainThread());
+    Ref<ProgressBarElement> result = adoptRef(*new ProgressBarElement(document));
+    result->setPseudo(webkitProgressBarName);
+    return result;
+}
+
+Ref<ProgressValueElement> ProgressValueElement::create(Document& document)
+{
+    static NeverDestroyed<const AtomString> webkitProgressValueName("-webkit-progress-value", AtomString::ConstructFromLiteral);
+    ASSERT(isMainThread());
+    Ref<ProgressValueElement> result = adoptRef(*new ProgressValueElement(document));
+    result->setPseudo(webkitProgressValueName);
+    return result;
+}
+
+}

Modified: trunk/Source/WebCore/html/shadow/ProgressShadowElement.h (260976 => 260977)


--- trunk/Source/WebCore/html/shadow/ProgressShadowElement.h	2020-05-01 01:13:03 UTC (rev 260976)
+++ trunk/Source/WebCore/html/shadow/ProgressShadowElement.h	2020-05-01 01:47:47 UTC (rev 260977)
@@ -65,13 +65,6 @@
 };
 static_assert(sizeof(ProgressInnerElement) == sizeof(ProgressShadowElement));
 
-inline Ref<ProgressInnerElement> ProgressInnerElement::create(Document& document)
-{
-    Ref<ProgressInnerElement> result = adoptRef(*new ProgressInnerElement(document));
-    result->setPseudo(AtomString("-webkit-progress-inner-element", AtomString::ConstructFromLiteral));
-    return result;
-}
-
 class ProgressBarElement final : public ProgressShadowElement {
 public:
     static Ref<ProgressBarElement> create(Document&);
@@ -81,13 +74,6 @@
 };
 static_assert(sizeof(ProgressBarElement) == sizeof(ProgressShadowElement));
 
-inline Ref<ProgressBarElement> ProgressBarElement::create(Document& document)
-{
-    Ref<ProgressBarElement> result = adoptRef(*new ProgressBarElement(document));
-    result->setPseudo(AtomString("-webkit-progress-bar", AtomString::ConstructFromLiteral));
-    return result;
-}
-
 class ProgressValueElement final : public ProgressShadowElement {
 public:
     static Ref<ProgressValueElement> create(Document&);
@@ -98,11 +84,4 @@
 };
 static_assert(sizeof(ProgressValueElement) == sizeof(ProgressShadowElement));
 
-inline Ref<ProgressValueElement> ProgressValueElement::create(Document& document)
-{
-    Ref<ProgressValueElement> result = adoptRef(*new ProgressValueElement(document));
-    result->setPseudo(AtomString("-webkit-progress-value", AtomString::ConstructFromLiteral));
-    return result;
-}
-
 } // namespace WebCore

Modified: trunk/Source/WebCore/html/shadow/SpinButtonElement.cpp (260976 => 260977)


--- trunk/Source/WebCore/html/shadow/SpinButtonElement.cpp	2020-05-01 01:13:03 UTC (rev 260976)
+++ trunk/Source/WebCore/html/shadow/SpinButtonElement.cpp	2020-05-01 01:47:47 UTC (rev 260977)
@@ -55,8 +55,10 @@
     , m_pressStartingState(Indeterminate)
     , m_repeatingTimer(*this, &SpinButtonElement::repeatingTimerFired)
 {
+    static NeverDestroyed<const AtomString> webkitInnerSpinButtonName("-webkit-inner-spin-button", AtomString::ConstructFromLiteral);
+    ASSERT(isMainThread());
     setHasCustomStyleResolveCallbacks();
-    setPseudo(AtomString("-webkit-inner-spin-button", AtomString::ConstructFromLiteral));
+    setPseudo(webkitInnerSpinButtonName);
 }
 
 Ref<SpinButtonElement> SpinButtonElement::create(Document& document, SpinButtonOwner& spinButtonOwner)

Modified: trunk/Source/WebCore/html/shadow/TextControlInnerElements.cpp (260976 => 260977)


--- trunk/Source/WebCore/html/shadow/TextControlInnerElements.cpp	2020-05-01 01:13:03 UTC (rev 260976)
+++ trunk/Source/WebCore/html/shadow/TextControlInnerElements.cpp	2020-05-01 01:47:47 UTC (rev 260977)
@@ -182,7 +182,9 @@
 inline TextControlPlaceholderElement::TextControlPlaceholderElement(Document& document)
     : HTMLDivElement(divTag, document)
 {
-    setPseudo(AtomString("placeholder", AtomString::ConstructFromLiteral));
+    static NeverDestroyed<const AtomString> placeholderName("placeholder", AtomString::ConstructFromLiteral);
+    ASSERT(isMainThread());
+    setPseudo(placeholderName);
     setHasCustomStyleResolveCallbacks();
 }
 
@@ -254,13 +256,17 @@
 inline SearchFieldCancelButtonElement::SearchFieldCancelButtonElement(Document& document)
     : HTMLDivElement(divTag, document)
 {
+    static NeverDestroyed<const AtomString> webkitSearchCancelButtonName("-webkit-search-cancel-button", AtomString::ConstructFromLiteral);
+    static NeverDestroyed<const AtomString> buttonName("button", AtomString::ConstructFromLiteral);
+    ASSERT(isMainThread());
+
     setHasCustomStyleResolveCallbacks();
 
-    setPseudo(AtomString("-webkit-search-cancel-button", AtomString::ConstructFromLiteral));
+    setPseudo(webkitSearchCancelButtonName);
 #if !PLATFORM(IOS_FAMILY)
     setAttributeWithoutSynchronization(aria_labelAttr, AXSearchFieldCancelButtonText());
 #endif
-    setAttributeWithoutSynchronization(roleAttr, AtomString("button", AtomString::ConstructFromLiteral));
+    setAttributeWithoutSynchronization(roleAttr, buttonName);
 }
 
 Ref<SearchFieldCancelButtonElement> SearchFieldCancelButtonElement::create(Document& document)

Modified: trunk/Source/WebCore/html/shadow/YouTubeEmbedShadowElement.cpp (260976 => 260977)


--- trunk/Source/WebCore/html/shadow/YouTubeEmbedShadowElement.cpp	2020-05-01 01:13:03 UTC (rev 260976)
+++ trunk/Source/WebCore/html/shadow/YouTubeEmbedShadowElement.cpp	2020-05-01 01:47:47 UTC (rev 260977)
@@ -41,7 +41,9 @@
 YouTubeEmbedShadowElement::YouTubeEmbedShadowElement(Document& document)
     : HTMLDivElement(HTMLNames::divTag, document)
 {
-    setPseudo(AtomString("-webkit-plugin-replacement", AtomString::ConstructFromLiteral));
+    static NeverDestroyed<const AtomString> webkitPluginReplacementName("-webkit-plugin-replacement", AtomString::ConstructFromLiteral);
+    ASSERT(isMainThread());
+    setPseudo(webkitPluginReplacementName);
 }
 
 RenderPtr<RenderElement> YouTubeEmbedShadowElement::createElementRenderer(RenderStyle&& style, const RenderTreePosition&)

Modified: trunk/Source/WebCore/html/shadow/mac/ImageControlsButtonElementMac.cpp (260976 => 260977)


--- trunk/Source/WebCore/html/shadow/mac/ImageControlsButtonElementMac.cpp	2020-05-01 01:13:03 UTC (rev 260976)
+++ trunk/Source/WebCore/html/shadow/mac/ImageControlsButtonElementMac.cpp	2020-05-01 01:47:47 UTC (rev 260977)
@@ -94,8 +94,11 @@
     if (!document.page())
         return nullptr;
 
+    static NeverDestroyed<const AtomString> xWebkitImageControlsButtonName("x-webkit-image-controls-button", AtomString::ConstructFromLiteral);
+    ASSERT(isMainThread());
+
     auto button = adoptRef(*new ImageControlsButtonElementMac(document));
-    button->setAttributeWithoutSynchronization(HTMLNames::classAttr, AtomString("x-webkit-image-controls-button", AtomString::ConstructFromLiteral));
+    button->setAttributeWithoutSynchronization(HTMLNames::classAttr, xWebkitImageControlsButtonName);
 
     IntSize positionOffset = RenderTheme::singleton().imageControlsButtonPositionOffset();
     button->setInlineStyleProperty(CSSPropertyTop, positionOffset.height(), CSSUnitType::CSS_PX);

Modified: trunk/Source/WebCore/html/shadow/mac/ImageControlsRootElementMac.cpp (260976 => 260977)


--- trunk/Source/WebCore/html/shadow/mac/ImageControlsRootElementMac.cpp	2020-05-01 01:13:03 UTC (rev 260976)
+++ trunk/Source/WebCore/html/shadow/mac/ImageControlsRootElementMac.cpp	2020-05-01 01:47:47 UTC (rev 260977)
@@ -86,8 +86,11 @@
     if (!document.page())
         return nullptr;
 
+    static NeverDestroyed<const AtomString> xWebkitImageControlsName("x-webkit-image-controls", AtomString::ConstructFromLiteral);
+    ASSERT(isMainThread());
+
     Ref<ImageControlsRootElementMac> controls = adoptRef(*new ImageControlsRootElementMac(document));
-    controls->setAttributeWithoutSynchronization(HTMLNames::classAttr, AtomString("x-webkit-image-controls", AtomString::ConstructFromLiteral));
+    controls->setAttributeWithoutSynchronization(HTMLNames::classAttr, xWebkitImageControlsName);
 
     if (RefPtr<ImageControlsButtonElementMac> button = ImageControlsButtonElementMac::tryCreate(document))
         controls->appendChild(*button);

Modified: trunk/Source/WebCore/html/track/TextTrackCue.cpp (260976 => 260977)


--- trunk/Source/WebCore/html/track/TextTrackCue.cpp	2020-05-01 01:13:03 UTC (rev 260976)
+++ trunk/Source/WebCore/html/track/TextTrackCue.cpp	2020-05-01 01:47:47 UTC (rev 260977)
@@ -488,8 +488,10 @@
     ScriptDisallowedScope::EventAllowedScope allowedScopeForReferenceTree(*m_cueNode);
 
     if (!m_displayTree) {
+        static NeverDestroyed<const AtomString> webkitGenericCueRootName("-webkit-generic-cue-root", AtomString::ConstructFromLiteral);
+        ASSERT(isMainThread());
         m_displayTree = TextTrackCueBox::create(ownerDocument(), *this);
-        m_displayTree->setPseudo(AtomString("-webkit-generic-cue-root", AtomString::ConstructFromLiteral));
+        m_displayTree->setPseudo(webkitGenericCueRootName);
     }
 
     m_displayTree->removeChildren();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to