⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 280829 in webkit


Ignore:
Timestamp:
Aug 10, 2021, 2:19:23 AM (5 years ago)
Author:
Adrian Perez de Castro
Message:

Merge r273935 - "precustomized" state of custom elements can become HTMLUnknownElement
https://bugs.webkit.org/show_bug.cgi?id=221652

Reviewed by Darin Adler.

The bug was caused by createJSHTMLWrapper in JSHTMLElementWrapperFactory.cpp relying on
!isCustomElementUpgradeCandidate() to create HTMLUnknownElement as JS wrapper of the element.

This is problematic after r266269 since that change re-purposes CustomElementState::Failed
on a custom element as "precustomized" state instead of introducing another enum value in
CustomElementState as RareDataBitFields has no more bits available.

This patch fixes the problem by introducing a new NodeFlag::IsUnknownElement and using that
to check whether JSHTMLUnknownElement should be created for a given element or not. Note that
HTMLElement had a virtual function, isHTMLUnknownElement, to check this condition but invoking
a virtual function proved to incur too much runtime cost.

  • dom/Node.h:

(WebCore::Node::isUnknownElement const): Added.
(WebCore::Node::isHTMLUnknownElement const): Added.
(WebCore::Node::isSVGUnknownElement const): Added.
(WebCore::Node::isMathMLUnknownElement const): Added.
(WebCore::Node::NodeFlag): Added NodeFlag::IsUnknownElement.

  • dom/make_names.pl:

(printWrapperFactoryCppFile): Treat the element as HTMLUnknownElement only if isUnknownElement
returns true instead of isCustomElementUpgradeCandidate returning false.

  • html/HTMLElement.h:

(WebCore::HTMLElement::isHTMLUnknownElement const): Deleted.

  • html/HTMLUnknownElement.h:
  • mathml/MathMLElement.cpp:

(WebCore::MathMLElement::MathMLElement): Added ConstructionType as an argument.

  • mathml/MathMLElement.h:
  • mathml/MathMLUnknownElement.h:

(WebCore::MathMLUnknownElement::MathMLUnknownElement): Set NodeFlag::IsUnknownElement.

  • svg/SVGElement.cpp:

(WebCore::SVGElement::SVGElement): Added ConstructionType as an argument.

  • svg/SVGElement.h:
  • svg/SVGUnknownElement.h:

(WebCore::SVGUnknownElement::SVGUnknownElement): Set NodeFlag::IsUnknownElement.

Location:
releases/WebKitGTK/webkit-2.32/Source/WebCore
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • releases/WebKitGTK/webkit-2.32/Source/WebCore/ChangeLog

    r280828 r280829  
     12021-03-04  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        "precustomized" state of custom elements can become HTMLUnknownElement
     4        https://bugs.webkit.org/show_bug.cgi?id=221652
     5
     6        Reviewed by Darin Adler.
     7
     8        The bug was caused by createJSHTMLWrapper in JSHTMLElementWrapperFactory.cpp relying on
     9        !isCustomElementUpgradeCandidate() to create HTMLUnknownElement as JS wrapper of the element.
     10
     11        This is problematic after r266269 since that change re-purposes CustomElementState::Failed
     12        on a custom element as "precustomized" state instead of introducing another enum value in
     13        CustomElementState as RareDataBitFields has no more bits available.
     14
     15        This patch fixes the problem by introducing a new NodeFlag::IsUnknownElement and using that
     16        to check whether JSHTMLUnknownElement should be created for a given element or not. Note that
     17        HTMLElement had a virtual function, isHTMLUnknownElement, to check this condition but invoking
     18        a virtual function proved to incur too much runtime cost.
     19
     20        * dom/Node.h:
     21        (WebCore::Node::isUnknownElement const): Added.
     22        (WebCore::Node::isHTMLUnknownElement const): Added.
     23        (WebCore::Node::isSVGUnknownElement const): Added.
     24        (WebCore::Node::isMathMLUnknownElement const): Added.
     25        (WebCore::Node::NodeFlag): Added NodeFlag::IsUnknownElement.
     26        * dom/make_names.pl:
     27        (printWrapperFactoryCppFile): Treat the element as HTMLUnknownElement only if isUnknownElement
     28        returns true instead of isCustomElementUpgradeCandidate returning false.
     29        * html/HTMLElement.h:
     30        (WebCore::HTMLElement::isHTMLUnknownElement const): Deleted.
     31        * html/HTMLUnknownElement.h:
     32        * mathml/MathMLElement.cpp:
     33        (WebCore::MathMLElement::MathMLElement): Added ConstructionType as an argument.
     34        * mathml/MathMLElement.h:
     35        * mathml/MathMLUnknownElement.h:
     36        (WebCore::MathMLUnknownElement::MathMLUnknownElement): Set NodeFlag::IsUnknownElement.
     37        * svg/SVGElement.cpp:
     38        (WebCore::SVGElement::SVGElement): Added ConstructionType as an argument.
     39        * svg/SVGElement.h:
     40        * svg/SVGUnknownElement.h:
     41        (WebCore::SVGUnknownElement::SVGUnknownElement): Set NodeFlag::IsUnknownElement.
     42
    1432021-03-01  Chris Dumez  <cdumez@apple.com>
    244
  • releases/WebKitGTK/webkit-2.32/Source/WebCore/dom/Node.h

    r273479 r280829  
    194194    bool isMathMLElement() const { return hasNodeFlag(NodeFlag::IsMathMLElement); }
    195195
     196    bool isUnknownElement() const { return hasNodeFlag(NodeFlag::IsUnknownElement); }
     197    bool isHTMLUnknownElement() const { return isHTMLElement() && isUnknownElement(); }
     198    bool isSVGUnknownElement() const { return isSVGElement() && isUnknownElement(); }
     199    bool isMathMLUnknownElement() const { return isMathMLElement() && isUnknownElement(); }
     200
    196201    bool isPseudoElement() const { return pseudoId() != PseudoId::None; }
    197202    bool isBeforePseudoElement() const { return pseudoId() == PseudoId::Before; }
     
    536541        IsConnected = 1 << 10,
    537542        IsInShadowTree = 1 << 11,
    538         HasEventTargetData = 1 << 12,
    539         // UnusedFlag = 1 << 13,
     543        IsUnknownElement = 1 << 12,
     544        HasEventTargetData = 1 << 13,
    540545
    541546        // These bits are used by derived classes, pulled up here so they can
  • releases/WebKitGTK/webkit-2.32/Source/WebCore/dom/make_names.pl

    r267588 r280829  
    12781278    if ($parameters{customElementInterfaceName}) {
    12791279        print F <<END
    1280     if (element->isCustomElementUpgradeCandidate())
     1280    if (!element->isUnknownElement())
    12811281        return createWrapper<$parameters{customElementInterfaceName}>(globalObject, WTFMove(element));
     1282END
     1283;
     1284    }
     1285
     1286    if ("$parameters{namespace}Element" eq $parameters{fallbackJSInterfaceName}) {
     1287        print F <<END
     1288    ASSERT(element->is$parameters{fallbackJSInterfaceName}());
    12821289END
    12831290;
  • releases/WebKitGTK/webkit-2.32/Source/WebCore/html/HTMLElement.h

    r272503 r280829  
    8787    TextDirection directionalityIfhasDirAutoAttribute(bool& isAuto) const;
    8888
    89     virtual bool isHTMLUnknownElement() const { return false; }
    9089    virtual bool isTextControlInnerTextElement() const { return false; }
    9190
  • releases/WebKitGTK/webkit-2.32/Source/WebCore/html/HTMLUnknownElement.h

    r229694 r280829  
    4444private:
    4545    HTMLUnknownElement(const QualifiedName& tagName, Document& document)
    46         : HTMLElement(tagName, document, CreateHTMLElement)
     46        : HTMLElement(tagName, document, CreateHTMLElement | NodeFlag::IsUnknownElement)
    4747    {
    4848    }
    49 
    50     bool isHTMLUnknownElement() const final { return true; }
    5149};
    5250
  • releases/WebKitGTK/webkit-2.32/Source/WebCore/mathml/MathMLElement.cpp

    r271124 r280829  
    5151using namespace MathMLNames;
    5252
    53 MathMLElement::MathMLElement(const QualifiedName& tagName, Document& document)
    54     : StyledElement(tagName, document, CreateMathMLElement)
     53MathMLElement::MathMLElement(const QualifiedName& tagName, Document& document, ConstructionType constructionType)
     54    : StyledElement(tagName, document, constructionType)
    5555{
    5656}
  • releases/WebKitGTK/webkit-2.32/Source/WebCore/mathml/MathMLElement.h

    r267578 r280829  
    9191
    9292protected:
    93     MathMLElement(const QualifiedName& tagName, Document&);
     93    MathMLElement(const QualifiedName& tagName, Document&, ConstructionType = CreateMathMLElement);
    9494
    9595    void parseAttribute(const QualifiedName&, const AtomString&) override;
  • releases/WebKitGTK/webkit-2.32/Source/WebCore/mathml/MathMLUnknownElement.h

    r232064 r280829  
    4242private:
    4343    MathMLUnknownElement(const QualifiedName& tagName, Document& document)
    44         : MathMLElement(tagName, document)
     44        : MathMLElement(tagName, document, CreateMathMLElement | NodeFlag::IsUnknownElement)
    4545    {
    4646    }
  • releases/WebKitGTK/webkit-2.32/Source/WebCore/svg/SVGElement.cpp

    r271806 r280829  
    156156}
    157157
    158 SVGElement::SVGElement(const QualifiedName& tagName, Document& document)
    159     : StyledElement(tagName, document, CreateSVGElement)
     158SVGElement::SVGElement(const QualifiedName& tagName, Document& document, ConstructionType constructionType)
     159    : StyledElement(tagName, document, constructionType)
    160160    , m_propertyAnimatorFactory(makeUnique<SVGPropertyAnimatorFactory>())
    161161{
  • releases/WebKitGTK/webkit-2.32/Source/WebCore/svg/SVGElement.h

    r271806 r280829  
    148148
    149149protected:
    150     SVGElement(const QualifiedName&, Document&);
     150    SVGElement(const QualifiedName&, Document&, ConstructionType = CreateSVGElement);
    151151    virtual ~SVGElement();
    152152
  • releases/WebKitGTK/webkit-2.32/Source/WebCore/svg/SVGUnknownElement.h

    r229694 r280829  
    4646private:
    4747    SVGUnknownElement(const QualifiedName& tagName, Document& document)
    48         : SVGElement(tagName, document)
     48        : SVGElement(tagName, document, CreateSVGElement | NodeFlag::IsUnknownElement)
    4949    {
    5050    }
Note: See TracChangeset for help on using the changeset viewer.