Changeset 267074 in webkit


Ignore:
Timestamp:
Sep 14, 2020 10:17:24 PM (4 years ago)
Author:
rniwa@webkit.org
Message:

Element should not set an attribute inside its constructor
https://bugs.webkit.org/show_bug.cgi?id=216507

Reviewed by Wenson Hsieh.

Moved the code to add attributes from element constructors to respective ::create functions
since setting attributes could run code in parseAttribute some of which may try to store
"this" in Ref / RefPtr, which would not be safe before adoptRef is called.

No new tests since there should be no observable behavioral change.

  • dom/Element.cpp:

(WebCore::Element::setAttributeInternal): Added an assertion.

  • html/FileInputType.cpp:

(WebCore::UploadButtonElement::create):
(WebCore::UploadButtonElement::createForMultiple):
(WebCore::UploadButtonElement::createInternal): Extracted.
(WebCore::UploadButtonElement::UploadButtonElement):

  • html/HTMLKeygenElement.cpp:
  • html/shadow/DateTimeEditElement.cpp:

(WebCore::DateTimeEditElement::DateTimeEditElement):
(WebCore::DateTimeEditElement::create):

  • html/shadow/DateTimeFieldElements.cpp:

(WebCore::DateTimeDayFieldElement::DateTimeDayFieldElement):
(WebCore::DateTimeDayFieldElement::create):
(WebCore::DateTimeHourFieldElement::DateTimeHourFieldElement):
(WebCore::DateTimeHourFieldElement::create):
(WebCore::DateTimeMeridiemFieldElement::DateTimeMeridiemFieldElement):
(WebCore::DateTimeMeridiemFieldElement::create):
(WebCore::DateTimeMillisecondFieldElement::DateTimeMillisecondFieldElement):
(WebCore::DateTimeMillisecondFieldElement::create):
(WebCore::DateTimeMinuteFieldElement::DateTimeMinuteFieldElement):
(WebCore::DateTimeMinuteFieldElement::create):
(WebCore::DateTimeMonthFieldElement::DateTimeMonthFieldElement):
(WebCore::DateTimeMonthFieldElement::create):
(WebCore::DateTimeSecondFieldElement::DateTimeSecondFieldElement):
(WebCore::DateTimeSecondFieldElement::create):
(WebCore::DateTimeSymbolicMonthFieldElement::DateTimeSymbolicMonthFieldElement):
(WebCore::DateTimeSymbolicMonthFieldElement::create):
(WebCore::DateTimeYearFieldElement::DateTimeYearFieldElement):
(WebCore::DateTimeYearFieldElement::create):

  • html/shadow/DetailsMarkerControl.cpp:

(WebCore::DetailsMarkerControl::create):
(WebCore::DetailsMarkerControl::DetailsMarkerControl):

  • html/shadow/MediaControlTextTrackContainerElement.cpp:

(WebCore::MediaControlTextTrackContainerElement::create):
(WebCore::MediaControlTextTrackContainerElement::MediaControlTextTrackContainerElement):

  • html/shadow/SpinButtonElement.cpp:

(WebCore::SpinButtonElement::SpinButtonElement):
(WebCore::SpinButtonElement::create):

  • html/shadow/TextControlInnerElements.cpp:

(WebCore::TextControlPlaceholderElement::TextControlPlaceholderElement):
(WebCore::TextControlPlaceholderElement::create):
(WebCore::SearchFieldCancelButtonElement::SearchFieldCancelButtonElement):
(WebCore::SearchFieldCancelButtonElement::create):

  • html/shadow/YouTubeEmbedShadowElement.cpp:

(WebCore::YouTubeEmbedShadowElement::create):
(WebCore::YouTubeEmbedShadowElement::YouTubeEmbedShadowElement):

  • html/track/TextTrackCue.cpp:

(WebCore::TextTrackCueBox::create): Moved from .h.
(WebCore::TextTrackCueBox::TextTrackCueBox):
(WebCore::TextTrackCueBox::initilaize): Added.

  • html/track/TextTrackCue.h:

(WebCore::TextTrackCueBox::create): Moved to cpp.

  • html/track/TextTrackCueGeneric.cpp:

(WebCore::TextTrackCueGenericBoxElement::create): Now calls initialize().

  • html/track/VTTCue.cpp:

(WebCore::VTTCueBox::create): Moved from .h. Now calls initialize().

  • html/track/VTTCue.h:

(WebCore::VTTCueBox::create): Moved to cpp.

Location:
trunk/Source/WebCore
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r267073 r267074  
     12020-09-14  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Element should not set an attribute inside its constructor
     4        https://bugs.webkit.org/show_bug.cgi?id=216507
     5
     6        Reviewed by Wenson Hsieh.
     7
     8        Moved the code to add attributes from element constructors to respective ::create functions
     9        since setting attributes could run code in parseAttribute some of which may try to store
     10        "this" in Ref / RefPtr, which would not be safe before adoptRef is called.
     11
     12        No new tests since there should be no observable behavioral change.
     13
     14        * dom/Element.cpp:
     15        (WebCore::Element::setAttributeInternal): Added an assertion.
     16        * html/FileInputType.cpp:
     17        (WebCore::UploadButtonElement::create):
     18        (WebCore::UploadButtonElement::createForMultiple):
     19        (WebCore::UploadButtonElement::createInternal): Extracted.
     20        (WebCore::UploadButtonElement::UploadButtonElement):
     21        * html/HTMLKeygenElement.cpp:
     22        * html/shadow/DateTimeEditElement.cpp:
     23        (WebCore::DateTimeEditElement::DateTimeEditElement):
     24        (WebCore::DateTimeEditElement::create):
     25        * html/shadow/DateTimeFieldElements.cpp:
     26        (WebCore::DateTimeDayFieldElement::DateTimeDayFieldElement):
     27        (WebCore::DateTimeDayFieldElement::create):
     28        (WebCore::DateTimeHourFieldElement::DateTimeHourFieldElement):
     29        (WebCore::DateTimeHourFieldElement::create):
     30        (WebCore::DateTimeMeridiemFieldElement::DateTimeMeridiemFieldElement):
     31        (WebCore::DateTimeMeridiemFieldElement::create):
     32        (WebCore::DateTimeMillisecondFieldElement::DateTimeMillisecondFieldElement):
     33        (WebCore::DateTimeMillisecondFieldElement::create):
     34        (WebCore::DateTimeMinuteFieldElement::DateTimeMinuteFieldElement):
     35        (WebCore::DateTimeMinuteFieldElement::create):
     36        (WebCore::DateTimeMonthFieldElement::DateTimeMonthFieldElement):
     37        (WebCore::DateTimeMonthFieldElement::create):
     38        (WebCore::DateTimeSecondFieldElement::DateTimeSecondFieldElement):
     39        (WebCore::DateTimeSecondFieldElement::create):
     40        (WebCore::DateTimeSymbolicMonthFieldElement::DateTimeSymbolicMonthFieldElement):
     41        (WebCore::DateTimeSymbolicMonthFieldElement::create):
     42        (WebCore::DateTimeYearFieldElement::DateTimeYearFieldElement):
     43        (WebCore::DateTimeYearFieldElement::create):
     44        * html/shadow/DetailsMarkerControl.cpp:
     45        (WebCore::DetailsMarkerControl::create):
     46        (WebCore::DetailsMarkerControl::DetailsMarkerControl):
     47        * html/shadow/MediaControlTextTrackContainerElement.cpp:
     48        (WebCore::MediaControlTextTrackContainerElement::create):
     49        (WebCore::MediaControlTextTrackContainerElement::MediaControlTextTrackContainerElement):
     50        * html/shadow/SpinButtonElement.cpp:
     51        (WebCore::SpinButtonElement::SpinButtonElement):
     52        (WebCore::SpinButtonElement::create):
     53        * html/shadow/TextControlInnerElements.cpp:
     54        (WebCore::TextControlPlaceholderElement::TextControlPlaceholderElement):
     55        (WebCore::TextControlPlaceholderElement::create):
     56        (WebCore::SearchFieldCancelButtonElement::SearchFieldCancelButtonElement):
     57        (WebCore::SearchFieldCancelButtonElement::create):
     58        * html/shadow/YouTubeEmbedShadowElement.cpp:
     59        (WebCore::YouTubeEmbedShadowElement::create):
     60        (WebCore::YouTubeEmbedShadowElement::YouTubeEmbedShadowElement):
     61        * html/track/TextTrackCue.cpp:
     62        (WebCore::TextTrackCueBox::create): Moved from .h.
     63        (WebCore::TextTrackCueBox::TextTrackCueBox):
     64        (WebCore::TextTrackCueBox::initilaize): Added.
     65        * html/track/TextTrackCue.h:
     66        (WebCore::TextTrackCueBox::create): Moved to cpp.
     67        * html/track/TextTrackCueGeneric.cpp:
     68        (WebCore::TextTrackCueGenericBoxElement::create): Now calls initialize().
     69        * html/track/VTTCue.cpp:
     70        (WebCore::VTTCueBox::create): Moved from .h. Now calls initialize().
     71        * html/track/VTTCue.h:
     72        (WebCore::VTTCueBox::create): Moved to cpp.
     73
    1742020-09-14  Myles C. Maxfield  <mmaxfield@apple.com>
    275
  • trunk/Source/WebCore/dom/Element.cpp

    r266986 r267074  
    17351735inline void Element::setAttributeInternal(unsigned index, const QualifiedName& name, const AtomString& newValue, SynchronizationOfLazyAttribute inSynchronizationOfLazyAttribute)
    17361736{
     1737    ASSERT_WITH_MESSAGE(refCount() || parentNode(), "Attribute must not be set on an element before adoptRef");
     1738
    17371739    if (newValue.isNull()) {
    17381740        if (index != ElementData::attributeNotFound)
  • trunk/Source/WebCore/html/FileInputType.cpp

    r266168 r267074  
    7474
    7575private:
     76    static Ref<UploadButtonElement> createInternal(Document&, const String& value);
    7677    bool isUploadButton() const override { return true; }
    7778   
     
    8182Ref<UploadButtonElement> UploadButtonElement::create(Document& document)
    8283{
     84    return createInternal(document, fileButtonChooseFileLabel());
     85}
     86
     87Ref<UploadButtonElement> UploadButtonElement::createForMultiple(Document& document)
     88{
     89    return createInternal(document, fileButtonChooseMultipleFilesLabel());
     90}
     91
     92Ref<UploadButtonElement> UploadButtonElement::createInternal(Document& document, const String& value)
     93{
    8394    auto button = adoptRef(*new UploadButtonElement(document));
    84     button->setValue(fileButtonChooseFileLabel());
    85     return button;
    86 }
    87 
    88 Ref<UploadButtonElement> UploadButtonElement::createForMultiple(Document& document)
    89 {
    90     auto button = adoptRef(*new UploadButtonElement(document));
    91     button->setValue(fileButtonChooseMultipleFilesLabel());
     95    static MainThreadNeverDestroyed<const AtomString> buttonName("button", AtomString::ConstructFromLiteral);
     96    static MainThreadNeverDestroyed<const AtomString> webkitFileUploadButtonName("-webkit-file-upload-button", AtomString::ConstructFromLiteral);
     97    button->setType(buttonName);
     98    button->setPseudo(webkitFileUploadButtonName);
     99    button->setValue(value);
    92100    return button;
    93101}
     
    96104    : HTMLInputElement(inputTag, document, 0, false)
    97105{
    98     static MainThreadNeverDestroyed<const AtomString> buttonName("button", AtomString::ConstructFromLiteral);
    99     static MainThreadNeverDestroyed<const AtomString> webkitFileUploadButtonName("-webkit-file-upload-button", AtomString::ConstructFromLiteral);
    100     setType(buttonName);
    101     setPseudo(webkitFileUploadButtonName);
    102106}
    103107
  • trunk/Source/WebCore/html/HTMLKeygenElement.cpp

    r261013 r267074  
    5151    static Ref<KeygenSelectElement> create(Document& document)
    5252    {
    53         return adoptRef(*new KeygenSelectElement(document));
     53        auto element = adoptRef(*new KeygenSelectElement(document));
     54        static MainThreadNeverDestroyed<const AtomString> pseudoId("-webkit-keygen-select", AtomString::ConstructFromLiteral);
     55        element->setPseudo(pseudoId);
     56        return element;
    5457    }
    5558
     
    5861        : HTMLSelectElement(selectTag, document, 0)
    5962    {
    60         static MainThreadNeverDestroyed<const AtomString> pseudoId("-webkit-keygen-select", AtomString::ConstructFromLiteral);
    61         setPseudo(pseudoId);
    6263    }
    6364
  • trunk/Source/WebCore/html/shadow/DateTimeEditElement.cpp

    r266779 r267074  
    181181    , m_editControlOwner(makeWeakPtr(editControlOwner))
    182182{
    183     static MainThreadNeverDestroyed<const AtomString> dateTimeEditPseudoId("-webkit-datetime-edit", AtomString::ConstructFromLiteral);
    184     setPseudo(dateTimeEditPseudoId);
    185183}
    186184
     
    223221Ref<DateTimeEditElement> DateTimeEditElement::create(Document& document, EditControlOwner& editControlOwner)
    224222{
    225     return adoptRef(*new DateTimeEditElement(document, editControlOwner));
     223    auto element = adoptRef(*new DateTimeEditElement(document, editControlOwner));
     224    static MainThreadNeverDestroyed<const AtomString> dateTimeEditPseudoId("-webkit-datetime-edit", AtomString::ConstructFromLiteral);
     225    element->setPseudo(dateTimeEditPseudoId);
     226    return element;
    226227}
    227228
  • trunk/Source/WebCore/html/shadow/DateTimeFieldElements.cpp

    r266779 r267074  
    4141    : DateTimeNumericFieldElement(document, fieldOwner, Range(1, 31), "--"_s)
    4242{
     43}
     44
     45Ref<DateTimeDayFieldElement> DateTimeDayFieldElement::create(Document& document, FieldOwner& fieldOwner)
     46{
     47    auto element = adoptRef(*new DateTimeDayFieldElement(document, fieldOwner));
    4348    static MainThreadNeverDestroyed<const AtomString> dayPseudoId("-webkit-datetime-edit-day-field", AtomString::ConstructFromLiteral);
    44     initialize(dayPseudoId);
    45 }
    46 
    47 Ref<DateTimeDayFieldElement> DateTimeDayFieldElement::create(Document& document, FieldOwner& fieldOwner)
    48 {
    49     return adoptRef(*new DateTimeDayFieldElement(document, fieldOwner));
     49    element->initialize(dayPseudoId);
     50    return element;
    5051}
    5152
     
    6667    : DateTimeNumericFieldElement(document, fieldOwner, Range(minimum, maximum), "--"_s)
    6768{
     69}
     70
     71Ref<DateTimeHourFieldElement> DateTimeHourFieldElement::create(Document& document, FieldOwner& fieldOwner, int minimum, int maximum)
     72{
     73    auto element = adoptRef(*new DateTimeHourFieldElement(document, fieldOwner, minimum, maximum));
    6874    static MainThreadNeverDestroyed<const AtomString> hourPseudoId("-webkit-datetime-edit-hour-field", AtomString::ConstructFromLiteral);
    69     initialize(hourPseudoId);
    70 }
    71 
    72 Ref<DateTimeHourFieldElement> DateTimeHourFieldElement::create(Document& document, FieldOwner& fieldOwner, int minimum, int maximum)
    73 {
    74     return adoptRef(*new DateTimeHourFieldElement(document, fieldOwner, minimum, maximum));
     75    element->initialize(hourPseudoId);
     76    return element;
    7577}
    7678
     
    130132    : DateTimeSymbolicFieldElement(document, fieldOwner, labels)
    131133{
     134}
     135
     136Ref<DateTimeMeridiemFieldElement> DateTimeMeridiemFieldElement::create(Document& document, FieldOwner& fieldOwner, const Vector<String>& labels)
     137{
     138    auto element = adoptRef(*new DateTimeMeridiemFieldElement(document, fieldOwner, labels));
    132139    static MainThreadNeverDestroyed<const AtomString> meridiemPseudoId("-webkit-datetime-edit-meridiem-field", AtomString::ConstructFromLiteral);
    133     initialize(meridiemPseudoId);
    134 }
    135 
    136 Ref<DateTimeMeridiemFieldElement> DateTimeMeridiemFieldElement::create(Document& document, FieldOwner& fieldOwner, const Vector<String>& labels)
    137 {
    138     return adoptRef(*new DateTimeMeridiemFieldElement(document, fieldOwner, labels));
     140    element->initialize(meridiemPseudoId);
     141    return element;
    139142}
    140143
     
    155158    : DateTimeNumericFieldElement(document, fieldOwner, Range(0, 999), "--"_s)
    156159{
     160}
     161
     162Ref<DateTimeMillisecondFieldElement> DateTimeMillisecondFieldElement::create(Document& document, FieldOwner& fieldOwner)
     163{
     164    auto element = adoptRef(*new DateTimeMillisecondFieldElement(document, fieldOwner));
    157165    static MainThreadNeverDestroyed<const AtomString> millisecondPseudoId("-webkit-datetime-edit-millisecond-field", AtomString::ConstructFromLiteral);
    158     initialize(millisecondPseudoId);
    159 }
    160 
    161 Ref<DateTimeMillisecondFieldElement> DateTimeMillisecondFieldElement::create(Document& document, FieldOwner& fieldOwner)
    162 {
    163     return adoptRef(*new DateTimeMillisecondFieldElement(document, fieldOwner));
     166    element->initialize(millisecondPseudoId);
     167    return element;
    164168}
    165169
     
    180184    : DateTimeNumericFieldElement(document, fieldOwner, Range(0, 59), "--"_s)
    181185{
     186}
     187
     188Ref<DateTimeMinuteFieldElement> DateTimeMinuteFieldElement::create(Document& document, FieldOwner& fieldOwner)
     189{
     190    auto element = adoptRef(*new DateTimeMinuteFieldElement(document, fieldOwner));
    182191    static MainThreadNeverDestroyed<const AtomString> minutePseudoId("-webkit-datetime-edit-minute-field", AtomString::ConstructFromLiteral);
    183     initialize(minutePseudoId);
    184 }
    185 
    186 Ref<DateTimeMinuteFieldElement> DateTimeMinuteFieldElement::create(Document& document, FieldOwner& fieldOwner)
    187 {
    188     return adoptRef(*new DateTimeMinuteFieldElement(document, fieldOwner));
     192    element->initialize(minutePseudoId);
     193    return element;
    189194}
    190195
     
    205210    : DateTimeNumericFieldElement(document, fieldOwner, Range(1, 12), "--"_s)
    206211{
     212}
     213
     214Ref<DateTimeMonthFieldElement> DateTimeMonthFieldElement::create(Document& document, FieldOwner& fieldOwner)
     215{
     216    auto element = adoptRef(*new DateTimeMonthFieldElement(document, fieldOwner));
    207217    static MainThreadNeverDestroyed<const AtomString> monthPseudoId("-webkit-datetime-edit-month-field", AtomString::ConstructFromLiteral);
    208     initialize(monthPseudoId);
    209 }
    210 
    211 Ref<DateTimeMonthFieldElement> DateTimeMonthFieldElement::create(Document& document, FieldOwner& fieldOwner)
    212 {
    213     return adoptRef(*new DateTimeMonthFieldElement(document, fieldOwner));
     218    element->initialize(monthPseudoId);
     219    return element;
    214220}
    215221
     
    231237    : DateTimeNumericFieldElement(document, fieldOwner, Range(0, 59), "--"_s)
    232238{
     239}
     240
     241Ref<DateTimeSecondFieldElement> DateTimeSecondFieldElement::create(Document& document, FieldOwner& fieldOwner)
     242{
     243    auto element = adoptRef(*new DateTimeSecondFieldElement(document, fieldOwner));
    233244    static MainThreadNeverDestroyed<const AtomString> secondPseudoId("-webkit-datetime-edit-second-field", AtomString::ConstructFromLiteral);
    234     initialize(secondPseudoId);
    235 }
    236 
    237 Ref<DateTimeSecondFieldElement> DateTimeSecondFieldElement::create(Document& document, FieldOwner& fieldOwner)
    238 {
    239     return adoptRef(*new DateTimeSecondFieldElement(document, fieldOwner));
     245    element->initialize(secondPseudoId);
     246    return element;
    240247}
    241248
     
    256263    : DateTimeSymbolicFieldElement(document, fieldOwner, labels)
    257264{
     265}
     266
     267Ref<DateTimeSymbolicMonthFieldElement> DateTimeSymbolicMonthFieldElement::create(Document& document, FieldOwner& fieldOwner, const Vector<String>& labels)
     268{
     269    auto element = adoptRef(*new DateTimeSymbolicMonthFieldElement(document, fieldOwner, labels));
    258270    static MainThreadNeverDestroyed<const AtomString> monthPseudoId("-webkit-datetime-edit-month-field", AtomString::ConstructFromLiteral);
    259     initialize(monthPseudoId);
    260 }
    261 
    262 Ref<DateTimeSymbolicMonthFieldElement> DateTimeSymbolicMonthFieldElement::create(Document& document, FieldOwner& fieldOwner, const Vector<String>& labels)
    263 {
    264     return adoptRef(*new DateTimeSymbolicMonthFieldElement(document, fieldOwner, labels));
     271    element->initialize(monthPseudoId);
     272    return element;
    265273}
    266274
     
    281289    : DateTimeNumericFieldElement(document, fieldOwner, Range(DateComponents::minimumYear(), DateComponents::maximumYear()), "----"_s)
    282290{
     291}
     292
     293Ref<DateTimeYearFieldElement> DateTimeYearFieldElement::create(Document& document, FieldOwner& fieldOwner)
     294{
     295    auto element = adoptRef(*new DateTimeYearFieldElement(document, fieldOwner));
    283296    static MainThreadNeverDestroyed<const AtomString> yearPseudoId("-webkit-datetime-edit-year-field", AtomString::ConstructFromLiteral);
    284     initialize(yearPseudoId);
    285 }
    286 
    287 Ref<DateTimeYearFieldElement> DateTimeYearFieldElement::create(Document& document, FieldOwner& fieldOwner)
    288 {
    289     return adoptRef(*new DateTimeYearFieldElement(document, fieldOwner));
     297    element->initialize(yearPseudoId);
     298    return element;
    290299}
    291300
  • trunk/Source/WebCore/html/shadow/DetailsMarkerControl.cpp

    r261013 r267074  
    4444Ref<DetailsMarkerControl> DetailsMarkerControl::create(Document& document)
    4545{
    46     return adoptRef(*new DetailsMarkerControl(document));
     46    auto control = adoptRef(*new DetailsMarkerControl(document));
     47    static MainThreadNeverDestroyed<const AtomString> webkitDetailsMarkerName("-webkit-details-marker", AtomString::ConstructFromLiteral);
     48    control->setPseudo(webkitDetailsMarkerName);
     49    return control;
    4750}
    4851
     
    5053    : HTMLDivElement(HTMLNames::divTag, document)
    5154{
    52     static MainThreadNeverDestroyed<const AtomString> webkitDetailsMarkerName("-webkit-details-marker", AtomString::ConstructFromLiteral);
    53     setPseudo(webkitDetailsMarkerName);
    5455}
    5556
  • trunk/Source/WebCore/html/shadow/MediaControlTextTrackContainerElement.cpp

    r263544 r267074  
    6868{
    6969    auto element = adoptRef(*new MediaControlTextTrackContainerElement(document, mediaElement));
     70    static MainThreadNeverDestroyed<const AtomString> webkitMediaTextTrackContainerName("-webkit-media-text-track-container", AtomString::ConstructFromLiteral);
     71    element->setPseudo(webkitMediaTextTrackContainerName);
    7072    element->hide();
    7173    return element;
     
    7678    , m_mediaElement(makeWeakPtr(&element))
    7779{
    78     static MainThreadNeverDestroyed<const AtomString> webkitMediaTextTrackContainerName("-webkit-media-text-track-container", AtomString::ConstructFromLiteral);
    79     setPseudo(webkitMediaTextTrackContainerName);
    8080}
    8181
  • trunk/Source/WebCore/html/shadow/SpinButtonElement.cpp

    r261013 r267074  
    5656    , m_repeatingTimer(*this, &SpinButtonElement::repeatingTimerFired)
    5757{
     58    setHasCustomStyleResolveCallbacks();
     59}
     60
     61Ref<SpinButtonElement> SpinButtonElement::create(Document& document, SpinButtonOwner& spinButtonOwner)
     62{
     63    auto element = adoptRef(*new SpinButtonElement(document, spinButtonOwner));
    5864    static MainThreadNeverDestroyed<const AtomString> webkitInnerSpinButtonName("-webkit-inner-spin-button", AtomString::ConstructFromLiteral);
    59     setHasCustomStyleResolveCallbacks();
    60     setPseudo(webkitInnerSpinButtonName);
    61 }
    62 
    63 Ref<SpinButtonElement> SpinButtonElement::create(Document& document, SpinButtonOwner& spinButtonOwner)
    64 {
    65     return adoptRef(*new SpinButtonElement(document, spinButtonOwner));
     65    element->setPseudo(webkitInnerSpinButtonName);
     66    return element;
    6667}
    6768
  • trunk/Source/WebCore/html/shadow/TextControlInnerElements.cpp

    r261013 r267074  
    183183    : HTMLDivElement(divTag, document)
    184184{
     185    setHasCustomStyleResolveCallbacks();
     186}
     187
     188Ref<TextControlPlaceholderElement> TextControlPlaceholderElement::create(Document& document)
     189{
     190    auto element = adoptRef(*new TextControlPlaceholderElement(document));
    185191    static MainThreadNeverDestroyed<const AtomString> placeholderName("placeholder", AtomString::ConstructFromLiteral);
    186     setPseudo(placeholderName);
    187     setHasCustomStyleResolveCallbacks();
    188 }
    189 
    190 Ref<TextControlPlaceholderElement> TextControlPlaceholderElement::create(Document& document)
    191 {
    192     return adoptRef(*new TextControlPlaceholderElement(document));
     192    element->setPseudo(placeholderName);
     193    return element;
    193194}
    194195
     
    256257    : HTMLDivElement(divTag, document)
    257258{
     259    setHasCustomStyleResolveCallbacks();
     260}
     261
     262Ref<SearchFieldCancelButtonElement> SearchFieldCancelButtonElement::create(Document& document)
     263{
     264    auto element = adoptRef(*new SearchFieldCancelButtonElement(document));
    258265    static MainThreadNeverDestroyed<const AtomString> webkitSearchCancelButtonName("-webkit-search-cancel-button", AtomString::ConstructFromLiteral);
    259266    static MainThreadNeverDestroyed<const AtomString> buttonName("button", AtomString::ConstructFromLiteral);
    260 
    261     setHasCustomStyleResolveCallbacks();
    262 
    263     setPseudo(webkitSearchCancelButtonName);
     267    element->setPseudo(webkitSearchCancelButtonName);
    264268#if !PLATFORM(IOS_FAMILY)
    265     setAttributeWithoutSynchronization(aria_labelAttr, AXSearchFieldCancelButtonText());
     269    element->setAttributeWithoutSynchronization(aria_labelAttr, AXSearchFieldCancelButtonText());
    266270#endif
    267     setAttributeWithoutSynchronization(roleAttr, buttonName);
    268 }
    269 
    270 Ref<SearchFieldCancelButtonElement> SearchFieldCancelButtonElement::create(Document& document)
    271 {
    272     return adoptRef(*new SearchFieldCancelButtonElement(document));
     271    element->setAttributeWithoutSynchronization(roleAttr, buttonName);
     272    return element;
    273273}
    274274
  • trunk/Source/WebCore/html/shadow/YouTubeEmbedShadowElement.cpp

    r261013 r267074  
    3434WTF_MAKE_ISO_ALLOCATED_IMPL(YouTubeEmbedShadowElement);
    3535
    36 Ref<YouTubeEmbedShadowElement> YouTubeEmbedShadowElement::create(Document& doc)
     36Ref<YouTubeEmbedShadowElement> YouTubeEmbedShadowElement::create(Document& document)
    3737{
    38     return adoptRef(*new YouTubeEmbedShadowElement(doc));
     38    auto element = adoptRef(*new YouTubeEmbedShadowElement(document));
     39    static MainThreadNeverDestroyed<const AtomString> webkitPluginReplacementName("-webkit-plugin-replacement", AtomString::ConstructFromLiteral);
     40    element->setPseudo(webkitPluginReplacementName);
     41    return element;
    3942}
    4043
     
    4245    : HTMLDivElement(HTMLNames::divTag, document)
    4346{
    44     static MainThreadNeverDestroyed<const AtomString> webkitPluginReplacementName("-webkit-plugin-replacement", AtomString::ConstructFromLiteral);
    45     setPseudo(webkitPluginReplacementName);
    4647}
    4748
  • trunk/Source/WebCore/html/track/TextTrackCue.cpp

    r262695 r267074  
    9393}
    9494
     95Ref<TextTrackCueBox> TextTrackCueBox::create(Document& document, TextTrackCue& cue)
     96{
     97    auto box = adoptRef(*new TextTrackCueBox(document, cue));
     98    box->initialize();
     99    return box;
     100}
     101
    95102TextTrackCueBox::TextTrackCueBox(Document& document, TextTrackCue& cue)
    96103    : HTMLElement(HTMLNames::divTag, document)
     
    98105{
    99106    setHasCustomStyleResolveCallbacks();
     107}
     108
     109void TextTrackCueBox::initialize()
     110{
    100111    setPseudo(TextTrackCue::cueBoxShadowPseudoId());
    101112}
  • trunk/Source/WebCore/html/track/TextTrackCue.h

    r262695 r267074  
    4747    WTF_MAKE_ISO_ALLOCATED(TextTrackCueBox);
    4848public:
    49     static Ref<TextTrackCueBox> create(Document& document, TextTrackCue& cue)
    50     {
    51         return adoptRef(*new TextTrackCueBox(document, cue));
    52     }
     49    static Ref<TextTrackCueBox> create(Document&, TextTrackCue&);
    5350
    5451    TextTrackCue* getCue() const;
     
    5653
    5754protected:
     55    void initialize();
     56
    5857    TextTrackCueBox(Document&, TextTrackCue&);
    5958    ~TextTrackCueBox() { }
  • trunk/Source/WebCore/html/track/TextTrackCueGeneric.cpp

    r263788 r267074  
    5353    WTF_MAKE_ISO_ALLOCATED_INLINE(TextTrackCueGenericBoxElement);
    5454public:
    55     static Ref<TextTrackCueGenericBoxElement> create(Document& document, TextTrackCueGeneric& cue)
    56     {
    57         return adoptRef(*new TextTrackCueGenericBoxElement(document, cue));
    58     }
     55    static Ref<TextTrackCueGenericBoxElement> create(Document&, TextTrackCueGeneric&);
    5956   
    6057    void applyCSSProperties(const IntSize&) override;
     
    6360    TextTrackCueGenericBoxElement(Document&, VTTCue&);
    6461};
     62
     63Ref<TextTrackCueGenericBoxElement> TextTrackCueGenericBoxElement::create(Document& document, TextTrackCueGeneric& cue)
     64{
     65    auto box = adoptRef(*new TextTrackCueGenericBoxElement(document, cue));
     66    box->initialize();
     67    return box;
     68}
    6569
    6670TextTrackCueGenericBoxElement::TextTrackCueGenericBoxElement(Document& document, VTTCue& cue)
  • trunk/Source/WebCore/html/track/VTTCue.cpp

    r262695 r267074  
    125125
    126126// ----------------------------
     127
     128Ref<VTTCueBox> VTTCueBox::create(Document& document, VTTCue& cue)
     129{
     130    auto box = adoptRef(*new VTTCueBox(document, cue));
     131    box->initialize();
     132    return box;
     133}
    127134
    128135VTTCueBox::VTTCueBox(Document& document, VTTCue& cue)
  • trunk/Source/WebCore/html/track/VTTCue.h

    r262695 r267074  
    5353    WTF_MAKE_ISO_ALLOCATED(VTTCueBox);
    5454public:
    55     static Ref<VTTCueBox> create(Document& document, VTTCue& cue)
    56     {
    57         return adoptRef(*new VTTCueBox(document, cue));
    58     }
     55    static Ref<VTTCueBox> create(Document&, VTTCue&);
    5956
    6057    void applyCSSProperties(const IntSize&) override;
Note: See TracChangeset for help on using the changeset viewer.