Changeset 165544 in webkit


Ignore:
Timestamp:
Mar 13, 2014 10:45:38 AM (10 years ago)
Author:
Darin Adler
Message:

Optimize hasTagName when called on an HTMLElement
https://bugs.webkit.org/show_bug.cgi?id=130090

Reviewed by Antti Koivisto.

Added new hasTagName functions that have the efficiency of hasLocalName.
but are safe.

Now we can always use hasTagName, and we'll get a compile time error if
we try to use an SVG tag name with an HTML element. All call sites that
use the more specific tag name types are more efficient, and call sites
that have a specific pointer type will get even more efficient checking
that is exactly what we used to get by calling hasLocalName.

  • accessibility/AccessibilityObject.cpp:

(WebCore::AccessibilityObject::hasTagName): Cast explicitly to Element
since Node::hasTagName no longer works on a general QualifiedName.

  • accessibility/AccessibilityRenderObject.cpp:

(WebCore::AccessibilityRenderObject::isDescendantOfElementType): Use
more specific type, RenderElement, so we can call hasTagName on Element
instead of Node; eliminates an unnecessary branch.

  • dom/DocumentStyleSheetCollection.cpp:

(WebCore::DocumentStyleSheetCollection::collectActiveStyleSheets): Use
new for loop and full words for variable names. Also use nullptr instead
of 0. Call toHTMLElement and toSVGElement in code that checks hasTagName
since it's already checking isHTMLElement and isSVGElement.

  • dom/Element.cpp:

(WebCore::attrNodeListMap): Use NeverDestroyed and put the vectors into
the map rather than putting pointers to a vector into the map.
(WebCore::attrNodeListForElement): Take a reference rather than a pointer,
and update for the change above.
(WebCore::ensureAttrNodeListForElement): Ditto.
(WebCore::removeAttrNodeListForElement): Ditto.
(WebCore::findAttrNodeInList): Ditto.
(WebCore::Element::isFocusable): Use ancestorsOfType<HTMLCanvasElement>
to fine the canvas rather than a hand-written loop.
(WebCore::Element::attrNodeList): Update for above changes.
(WebCore::Element::setAttributeNode): Ditto.
(WebCore::Element::attrIfExists): Ditto.
(WebCore::Element::ensureAttr): Ditto.
(WebCore::Element::detachAttrNodeFromElementWithValue): Ditto.
(WebCore::Element::detachAllAttrNodesFromElement): Ditto.

  • dom/Element.h: Removed the overload of hasLocalName that takes a

QualifiedName and ignores the non-local-name parts of it. Callers should
use hasTagName instead, now that it's optimized appropriately. Added
overloads of hasTagName for all the specific qualified name types. It's
more efficient to use the Node versions of these functions rather than
using QualifiedName::matches to do the check. Removed the hasTagName and
hasLocalName functions from the Node class; the only convenience functions
needed in Node are the specific checks for tags from HTML, MathML, and SVG,
not the general purpose ones.

  • dom/Node.h: Removed hasLocalName and replaced the single hasTagName

that takes a QualifiedName with three faster ones that take HTML, MathML,
and SVG qualified names instead. Also updated to use nullptr instead of 0.

  • dom/PositionIterator.cpp: Added now-needed include.
  • dom/Text.cpp: Ditto.
  • dom/make_names.pl:

(printHeaderHead): Renamed an argument for clarity and added a definitions
argument, which is where we insert the classes derived from QualifiedName.
(printCppHead): Renamed an argument for clarity.
(printTypeHelpers): Use hasTagName rather than hasLocalName, since the
former is now optimized to be the same as what the latter was.
(printNamesHeaderFile): Define a class derived from QualifiedName that can
be used at compile time to avoid having to check the namespace.
(printNamesCppFile): Use the new more-specific type as needed.

  • editing/ApplyStyleCommand.cpp:

(WebCore::isLegacyAppleStyleSpan): Use hasTagName instead of hasLocalName,
and references instead of pointers.
(WebCore::ApplyStyleCommand::ApplyStyleCommand): Removed uneeded explicit
construction of a smart pointer.
(WebCore::ApplyStyleCommand::shouldApplyInlineStyleToRun): Updated to use
the enclosingElementWithTag function by its new name.

  • editing/Editor.cpp:

(WebCore::Editor::selectionUnorderedListState): Updated to use the
enclosingElementWithTag function by its new name.
(WebCore::Editor::selectionOrderedListState): Ditto.

  • editing/InsertListCommand.cpp:

(WebCore::InsertListCommand::doApply): Use a more-specific type for the list tag.
(WebCore::InsertListCommand::doApplyForSingleParagraph): Ditto.

  • editing/InsertListCommand.h: Ditto.
  • editing/MarkupAccumulator.cpp:

(WebCore::MarkupAccumulator::serializeNodesWithNamespaces): Added an explicit
cast to Element in the loop that is already guarded by an isElementNode check.
Also use a modern C++ for loop.

  • editing/ReplaceSelectionCommand.cpp:

(WebCore::ReplaceSelectionCommand::makeInsertedContentRoundTrippableWithHTMLTreeBuilder):
Updated to use the enclosingElementWithTag function by its new name.
(WebCore::ReplaceSelectionCommand::removeUnrenderedTextNodesAtEnds): Ditto.
(WebCore::ReplaceSelectionCommand::positionAtEndOfInsertedContent): Ditto.

  • editing/TypingCommand.cpp: Added now-needed includes.
  • editing/VisibleUnits.cpp: Ditto.
  • editing/htmlediting.cpp:

(WebCore::enclosingElementWithTag): Changed to return an Element instead of a Node,
since nodes other than elements do not have tags.

  • editing/htmlediting.h: Ditto.
  • editing/mac/EditorMac.mm:

(WebCore::Editor::adjustedSelectionRange): Updated to use the enclosingElementWithTag
function by its new name.

  • editing/markup.cpp:

(WebCore::StyledMarkupAccumulator::appendText): Ditto.
(WebCore::StyledMarkupAccumulator::traverseNodesForSerialization): Ditto.
(WebCore::highestAncestorToWrapMarkup): Ditto.
(WebCore::createMarkupInternal): Ditto.
(WebCore::createContextualFragment): Ditto. Use hasTagName instead of hasLocalName,
since the former is now optimized to be the same as the latter was before.

  • html/HTMLCollection.cpp:

(WebCore::isMatchingElement): Use hasTagName instead of hasLocalName,
since the former is now optimized to be the same as the latter was before.
(WebCore::nameShouldBeVisibleInDocumentAll): Ditto.

  • html/HTMLElement.cpp:

(WebCore::HTMLElement::ieForbidsInsertHTML): Ditto.
(WebCore::unicodeBidiAttributeForDirAuto): Ditto.
(WebCore::HTMLElement::parseBorderWidthAttribute): Ditto.
(WebCore::HTMLElement::setInnerHTML): Ditto.
(WebCore::shouldProhibitSetInnerOuterText): Ditto. Added this to share code between
setInnerText and setOuterText.
(WebCore::HTMLElement::setInnerText): Ditto.
(WebCore::HTMLElement::setOuterText): Ditto.
(WebCore::HTMLElement::rendererIsNeeded): Ditto.
(WebCore::HTMLElement::createElementRenderer): Ditto.

  • html/HTMLElement.h: Added hasTagName, which hides the one inherited from Element

and takes the more-specific HTMLQualifiedName type. This means we don't need to check
the namespace at runtime because it's known at compile time. Also put the
implementation of Node::hasTagName for HTMLQualifiedName into this header.

  • html/HTMLObjectElement.cpp:

(WebCore::isRecognizedTagName): Updated for change in return type of
HTMLNames::getHTMLTags.

  • html/HTMLSelectElement.cpp:

(WebCore::HTMLSelectElement::add): Use hasTagName inastead of hasLocalName.
(WebCore::HTMLSelectElement::value): Use isHTMLOptionElement instead of hasTagName.
Also use a new style for loop and emptyString() instead of "".
(WebCore::HTMLSelectElement::setValue): Ditto.
(WebCore::HTMLSelectElement::setLength): Ditto.
(WebCore::HTMLSelectElement::searchOptionsForValue): Ditto.
(WebCore::HTMLSelectElement::restoreFormControlState): Ditto.

  • html/HTMLTableColElement.cpp:

(WebCore::HTMLTableColElement::additionalPresentationAttributeStyle): Use hasTagName
instead of hasLocalName.

  • html/HTMLTableRowsCollection.cpp:

(WebCore::isInSection): Updated to use hasTagName and take a reference.
(WebCore::HTMLTableRowsCollection::rowAfter): Pass a reference.

  • html/parser/HTMLConstructionSite.cpp: Added now-needed include.
  • html/parser/HTMLTreeBuilder.cpp:

(WebCore::createCaseMap): Updated to return a map rather than filling one in, and to
be flxible about the type of the table being used.
(WebCore::adjustSVGTagNameCase): Updated to use NeverDestroyed.
(WebCore::adjustAttributes): Added new helper so we can share more code. Updated
template argument names for clarity.
(WebCore::adjustSVGAttributes): Marked this inline, since it just turns around and
calls a single non-inline function.
(WebCore::adjustMathMLAttributes): Ditto.
(WebCore::addNamesWithPrefix): Changed to take argument by reference instead of pointer.
(WebCore::createForeignAttributesMap): Added. Factors out the map creation from the
function below.
(WebCore::adjustForeignAttributes): Updated for above changes.
(WebCore::HTMLTreeBuilder::processStartTagForInBody): Updated to pass reference.
(WebCore::HTMLTreeBuilder::processTokenInForeignContent): Ditto.

  • inspector/InspectorStyleSheet.cpp: Added now-needed include.
  • mathml/MathMLElement.h: Added hasTagName, which hides the one inherited from Element

and takes the more-specific MathMLQualifiedName type. This means we don't need to check
the namespace at runtime because it's known at compile time. Also put the
implementation of Node::hasTagName for MathMLQualifiedName into this header.

  • mathml/MathMLInlineContainerElement.cpp:

(WebCore::MathMLInlineContainerElement::createElementRenderer): Use hasTagName.

  • mathml/MathMLSelectElement.cpp:

(WebCore::MathMLSelectElement::attributeChanged): Use hasTagName.
(WebCore::MathMLSelectElement::getSelectedActionChildAndIndex): Ditto.
(WebCore::MathMLSelectElement::getSelectedActionChild): Ditto.
(WebCore::MathMLSelectElement::getSelectedSemanticsChild): Ditto.
(WebCore::MathMLSelectElement::updateSelectedChild): Ditto.

  • mathml/MathMLTextElement.cpp:

(WebCore::MathMLTextElement::createElementRenderer): Ditto.
(WebCore::MathMLTextElement::childShouldCreateRenderer): Ditto.

  • platform/mac/HTMLConverter.mm: Added now-needed include.
  • rendering/RenderBlockFlow.cpp: Ditto.
  • rendering/RenderBoxModelObject.cpp:

(WebCore::RenderBoxModelObject::paintFillLayerExtended): Use hasTagName.

  • rendering/RenderElement.cpp:

(WebCore::RenderElement::rendererForRootBackground): Ditto.

  • rendering/RenderLayerBacking.cpp:

(WebCore::RenderLayerBacking::isSimpleContainerCompositingLayer): Ditto.

  • rendering/RenderReplaced.cpp: Added now-needed include.
  • rendering/mathml/RenderMathMLScripts.cpp:

(WebCore::RenderMathMLScripts::RenderMathMLScripts): Use hasTagName.

  • rendering/mathml/RenderMathMLUnderOver.cpp:

(WebCore::RenderMathMLUnderOver::RenderMathMLUnderOver): Ditto.

  • svg/SVGElement.h: Added hasTagName, which hides the one inherited from Element

and takes the more-specific SVGQualifiedName type. This means we don't need to check
the namespace at runtime because it's known at compile time. Also put the
implementation of Node::hasTagName for SVGQualifiedName into this header.

  • svg/SVGFontFaceSrcElement.cpp:

(WebCore::SVGFontFaceSrcElement::childrenChanged): Use isSVGFontFaceElement instead
of calling hasTagName.

  • svg/SVGUseElement.cpp:

(WebCore::isDirectReference): Changed to take a reference and a more specific type.
(WebCore::SVGUseElement::toClipPath): Added a type cast.
(WebCore::SVGUseElement::rendererClipChild): Use more specific types so we don't
need a type cast.

  • xml/parser/XMLDocumentParser.cpp:

(WebCore::XMLDocumentParser::parseDocumentFragment): Added explicit calls to this
unusual call site that has a good reason to use hasLocalName instead of hasTagName.

Location:
trunk/Source/WebCore
Files:
50 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r165543 r165544  
     12014-03-13  Darin Adler  <darin@apple.com>
     2
     3        Optimize hasTagName when called on an HTMLElement
     4        https://bugs.webkit.org/show_bug.cgi?id=130090
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Added new hasTagName functions that have the efficiency of hasLocalName.
     9        but are safe.
     10
     11        Now we can always use hasTagName, and we'll get a compile time error if
     12        we try to use an SVG tag name with an HTML element. All call sites that
     13        use the more specific tag name types are more efficient, and call sites
     14        that have a specific pointer type will get even more efficient checking
     15        that is exactly what we used to get by calling hasLocalName.
     16
     17        * accessibility/AccessibilityObject.cpp:
     18        (WebCore::AccessibilityObject::hasTagName): Cast explicitly to Element
     19        since Node::hasTagName no longer works on a general QualifiedName.
     20        * accessibility/AccessibilityRenderObject.cpp:
     21        (WebCore::AccessibilityRenderObject::isDescendantOfElementType): Use
     22        more specific type, RenderElement, so we can call hasTagName on Element
     23        instead of Node; eliminates an unnecessary branch.
     24
     25        * dom/DocumentStyleSheetCollection.cpp:
     26        (WebCore::DocumentStyleSheetCollection::collectActiveStyleSheets): Use
     27        new for loop and full words for variable names. Also use nullptr instead
     28        of 0. Call toHTMLElement and toSVGElement in code that checks hasTagName
     29        since it's already checking isHTMLElement and isSVGElement.
     30
     31        * dom/Element.cpp:
     32        (WebCore::attrNodeListMap): Use NeverDestroyed and put the vectors into
     33        the map rather than putting pointers to a vector into the map.
     34        (WebCore::attrNodeListForElement): Take a reference rather than a pointer,
     35        and update for the change above.
     36        (WebCore::ensureAttrNodeListForElement): Ditto.
     37        (WebCore::removeAttrNodeListForElement): Ditto.
     38        (WebCore::findAttrNodeInList): Ditto.
     39        (WebCore::Element::isFocusable): Use ancestorsOfType<HTMLCanvasElement>
     40        to fine the canvas rather than a hand-written loop.
     41        (WebCore::Element::attrNodeList): Update for above changes.
     42        (WebCore::Element::setAttributeNode): Ditto.
     43        (WebCore::Element::attrIfExists): Ditto.
     44        (WebCore::Element::ensureAttr): Ditto.
     45        (WebCore::Element::detachAttrNodeFromElementWithValue): Ditto.
     46        (WebCore::Element::detachAllAttrNodesFromElement): Ditto.
     47
     48        * dom/Element.h: Removed the overload of hasLocalName that takes a
     49        QualifiedName and ignores the non-local-name parts of it. Callers should
     50        use hasTagName instead, now that it's optimized appropriately. Added
     51        overloads of hasTagName for all the specific qualified name types. It's
     52        more efficient to use the Node versions of these functions rather than
     53        using QualifiedName::matches to do the check. Removed the hasTagName and
     54        hasLocalName functions from the Node class; the only convenience functions
     55        needed in Node are the specific checks for tags from HTML, MathML, and SVG,
     56        not the general purpose ones.
     57
     58        * dom/Node.h: Removed hasLocalName and replaced the single hasTagName
     59        that takes a QualifiedName with three faster ones that take HTML, MathML,
     60        and SVG qualified names instead. Also updated to use nullptr instead of 0.
     61
     62        * dom/PositionIterator.cpp: Added now-needed include.
     63        * dom/Text.cpp: Ditto.
     64
     65        * dom/make_names.pl:
     66        (printHeaderHead): Renamed an argument for clarity and added a definitions
     67        argument, which is where we insert the classes derived from QualifiedName.
     68        (printCppHead): Renamed an argument for clarity.
     69        (printTypeHelpers): Use hasTagName rather than hasLocalName, since the
     70        former is now optimized to be the same as what the latter was.
     71        (printNamesHeaderFile): Define a class derived from QualifiedName that can
     72        be used at compile time to avoid having to check the namespace.
     73        (printNamesCppFile): Use the new more-specific type as needed.
     74
     75        * editing/ApplyStyleCommand.cpp:
     76        (WebCore::isLegacyAppleStyleSpan): Use hasTagName instead of hasLocalName,
     77        and references instead of pointers.
     78        (WebCore::ApplyStyleCommand::ApplyStyleCommand): Removed uneeded explicit
     79        construction of a smart pointer.
     80        (WebCore::ApplyStyleCommand::shouldApplyInlineStyleToRun): Updated to use
     81        the enclosingElementWithTag function by its new name.
     82
     83        * editing/Editor.cpp:
     84        (WebCore::Editor::selectionUnorderedListState): Updated to use the
     85        enclosingElementWithTag function by its new name.
     86        (WebCore::Editor::selectionOrderedListState): Ditto.
     87
     88        * editing/InsertListCommand.cpp:
     89        (WebCore::InsertListCommand::doApply): Use a more-specific type for the list tag.
     90        (WebCore::InsertListCommand::doApplyForSingleParagraph): Ditto.
     91        * editing/InsertListCommand.h: Ditto.
     92
     93        * editing/MarkupAccumulator.cpp:
     94        (WebCore::MarkupAccumulator::serializeNodesWithNamespaces): Added an explicit
     95        cast to Element in the loop that is already guarded by an isElementNode check.
     96        Also use a modern C++ for loop.
     97
     98        * editing/ReplaceSelectionCommand.cpp:
     99        (WebCore::ReplaceSelectionCommand::makeInsertedContentRoundTrippableWithHTMLTreeBuilder):
     100        Updated to use the enclosingElementWithTag function by its new name.
     101        (WebCore::ReplaceSelectionCommand::removeUnrenderedTextNodesAtEnds): Ditto.
     102        (WebCore::ReplaceSelectionCommand::positionAtEndOfInsertedContent): Ditto.
     103
     104        * editing/TypingCommand.cpp: Added now-needed includes.
     105        * editing/VisibleUnits.cpp: Ditto.
     106
     107        * editing/htmlediting.cpp:
     108        (WebCore::enclosingElementWithTag): Changed to return an Element instead of a Node,
     109        since nodes other than elements do not have tags.
     110        * editing/htmlediting.h: Ditto.
     111
     112        * editing/mac/EditorMac.mm:
     113        (WebCore::Editor::adjustedSelectionRange): Updated to use the enclosingElementWithTag
     114        function by its new name.
     115        * editing/markup.cpp:
     116        (WebCore::StyledMarkupAccumulator::appendText): Ditto.
     117        (WebCore::StyledMarkupAccumulator::traverseNodesForSerialization): Ditto.
     118        (WebCore::highestAncestorToWrapMarkup): Ditto.
     119        (WebCore::createMarkupInternal): Ditto.
     120        (WebCore::createContextualFragment): Ditto. Use hasTagName instead of hasLocalName,
     121        since the former is now optimized to be the same as the latter was before.
     122
     123        * html/HTMLCollection.cpp:
     124        (WebCore::isMatchingElement): Use hasTagName instead of hasLocalName,
     125        since the former is now optimized to be the same as the latter was before.
     126        (WebCore::nameShouldBeVisibleInDocumentAll): Ditto.
     127        * html/HTMLElement.cpp:
     128        (WebCore::HTMLElement::ieForbidsInsertHTML): Ditto.
     129        (WebCore::unicodeBidiAttributeForDirAuto): Ditto.
     130        (WebCore::HTMLElement::parseBorderWidthAttribute): Ditto.
     131        (WebCore::HTMLElement::setInnerHTML): Ditto.
     132        (WebCore::shouldProhibitSetInnerOuterText): Ditto. Added this to share code between
     133        setInnerText and setOuterText.
     134        (WebCore::HTMLElement::setInnerText): Ditto.
     135        (WebCore::HTMLElement::setOuterText): Ditto.
     136        (WebCore::HTMLElement::rendererIsNeeded): Ditto.
     137        (WebCore::HTMLElement::createElementRenderer): Ditto.
     138
     139        * html/HTMLElement.h: Added hasTagName, which hides the one inherited from Element
     140        and takes the more-specific HTMLQualifiedName type. This means we don't need to check
     141        the namespace at runtime because it's known at compile time. Also put the
     142        implementation of Node::hasTagName for HTMLQualifiedName into this header.
     143
     144        * html/HTMLObjectElement.cpp:
     145        (WebCore::isRecognizedTagName): Updated for change in return type of
     146        HTMLNames::getHTMLTags.
     147
     148        * html/HTMLSelectElement.cpp:
     149        (WebCore::HTMLSelectElement::add): Use hasTagName inastead of hasLocalName.
     150        (WebCore::HTMLSelectElement::value): Use isHTMLOptionElement instead of hasTagName.
     151        Also use a new style for loop and emptyString() instead of "".
     152        (WebCore::HTMLSelectElement::setValue): Ditto.
     153        (WebCore::HTMLSelectElement::setLength): Ditto.
     154        (WebCore::HTMLSelectElement::searchOptionsForValue): Ditto.
     155        (WebCore::HTMLSelectElement::restoreFormControlState): Ditto.
     156
     157        * html/HTMLTableColElement.cpp:
     158        (WebCore::HTMLTableColElement::additionalPresentationAttributeStyle): Use hasTagName
     159        instead of hasLocalName.
     160
     161        * html/HTMLTableRowsCollection.cpp:
     162        (WebCore::isInSection): Updated to use hasTagName and take a reference.
     163        (WebCore::HTMLTableRowsCollection::rowAfter): Pass a reference.
     164
     165        * html/parser/HTMLConstructionSite.cpp: Added now-needed include.
     166
     167        * html/parser/HTMLTreeBuilder.cpp:
     168        (WebCore::createCaseMap): Updated to return a map rather than filling one in, and to
     169        be flxible about the type of the table being used.
     170        (WebCore::adjustSVGTagNameCase): Updated to use NeverDestroyed.
     171        (WebCore::adjustAttributes): Added new helper so we can share more code. Updated
     172        template argument names for clarity.
     173        (WebCore::adjustSVGAttributes): Marked this inline, since it just turns around and
     174        calls a single non-inline function.
     175        (WebCore::adjustMathMLAttributes): Ditto.
     176        (WebCore::addNamesWithPrefix): Changed to take argument by reference instead of pointer.
     177        (WebCore::createForeignAttributesMap): Added. Factors out the map creation from the
     178        function below.
     179        (WebCore::adjustForeignAttributes): Updated for above changes.
     180        (WebCore::HTMLTreeBuilder::processStartTagForInBody): Updated to pass reference.
     181        (WebCore::HTMLTreeBuilder::processTokenInForeignContent): Ditto.
     182
     183        * inspector/InspectorStyleSheet.cpp: Added now-needed include.
     184
     185        * mathml/MathMLElement.h: Added hasTagName, which hides the one inherited from Element
     186        and takes the more-specific MathMLQualifiedName type. This means we don't need to check
     187        the namespace at runtime because it's known at compile time. Also put the
     188        implementation of Node::hasTagName for MathMLQualifiedName into this header.
     189
     190        * mathml/MathMLInlineContainerElement.cpp:
     191        (WebCore::MathMLInlineContainerElement::createElementRenderer): Use hasTagName.
     192
     193        * mathml/MathMLSelectElement.cpp:
     194        (WebCore::MathMLSelectElement::attributeChanged): Use hasTagName.
     195        (WebCore::MathMLSelectElement::getSelectedActionChildAndIndex): Ditto.
     196        (WebCore::MathMLSelectElement::getSelectedActionChild): Ditto.
     197        (WebCore::MathMLSelectElement::getSelectedSemanticsChild): Ditto.
     198        (WebCore::MathMLSelectElement::updateSelectedChild): Ditto.
     199        * mathml/MathMLTextElement.cpp:
     200        (WebCore::MathMLTextElement::createElementRenderer): Ditto.
     201        (WebCore::MathMLTextElement::childShouldCreateRenderer): Ditto.
     202
     203        * platform/mac/HTMLConverter.mm: Added now-needed include.
     204        * rendering/RenderBlockFlow.cpp: Ditto.
     205
     206        * rendering/RenderBoxModelObject.cpp:
     207        (WebCore::RenderBoxModelObject::paintFillLayerExtended): Use hasTagName.
     208        * rendering/RenderElement.cpp:
     209        (WebCore::RenderElement::rendererForRootBackground): Ditto.
     210        * rendering/RenderLayerBacking.cpp:
     211        (WebCore::RenderLayerBacking::isSimpleContainerCompositingLayer): Ditto.
     212
     213        * rendering/RenderReplaced.cpp: Added now-needed include.
     214
     215        * rendering/mathml/RenderMathMLScripts.cpp:
     216        (WebCore::RenderMathMLScripts::RenderMathMLScripts): Use hasTagName.
     217        * rendering/mathml/RenderMathMLUnderOver.cpp:
     218        (WebCore::RenderMathMLUnderOver::RenderMathMLUnderOver): Ditto.
     219
     220        * svg/SVGElement.h: Added hasTagName, which hides the one inherited from Element
     221        and takes the more-specific SVGQualifiedName type. This means we don't need to check
     222        the namespace at runtime because it's known at compile time. Also put the
     223        implementation of Node::hasTagName for SVGQualifiedName into this header.
     224
     225        * svg/SVGFontFaceSrcElement.cpp:
     226        (WebCore::SVGFontFaceSrcElement::childrenChanged): Use isSVGFontFaceElement instead
     227        of calling hasTagName.
     228
     229        * svg/SVGUseElement.cpp:
     230        (WebCore::isDirectReference): Changed to take a reference and a more specific type.
     231        (WebCore::SVGUseElement::toClipPath): Added a type cast.
     232        (WebCore::SVGUseElement::rendererClipChild): Use more specific types so we don't
     233        need a type cast.
     234
     235        * xml/parser/XMLDocumentParser.cpp:
     236        (WebCore::XMLDocumentParser::parseDocumentFragment): Added explicit calls to this
     237        unusual call site that has a good reason to use hasLocalName instead of hasTagName.
     238
    12392014-03-13  Antti Koivisto  <antti@apple.com>
    2240
  • trunk/Source/WebCore/accessibility/AccessibilityObject.cpp

    r165430 r165544  
    15501550bool AccessibilityObject::hasTagName(const QualifiedName& tagName) const
    15511551{
    1552     if (Node* node = this->node())
    1553         return node->hasTagName(tagName);
    1554     return false;
     1552    Node* node = this->node();
     1553    return node && node->isElementNode() && toElement(*node).hasTagName(tagName);
    15551554}
    15561555   
  • trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp

    r165535 r165544  
    24162416bool AccessibilityRenderObject::isDescendantOfElementType(const QualifiedName& tagName) const
    24172417{
    2418     for (RenderObject* parent = m_renderer->parent(); parent; parent = parent->parent()) {
    2419         if (parent->node() && parent->node()->hasTagName(tagName))
     2418    for (auto& ancestor : ancestorsOfType<RenderElement>(*m_renderer)) {
     2419        if (ancestor.element() && ancestor.element()->hasTagName(tagName))
    24202420            return true;
    24212421    }
  • trunk/Source/WebCore/dom/DocumentStyleSheetCollection.cpp

    r164420 r165544  
    263263        return;
    264264
    265     StyleSheetCandidateListHashSet::iterator begin = m_styleSheetCandidateNodes.begin();
    266     StyleSheetCandidateListHashSet::iterator end = m_styleSheetCandidateNodes.end();
    267     for (StyleSheetCandidateListHashSet::iterator it = begin; it != end; ++it) {
    268         Node* n = *it;
    269         StyleSheet* sheet = 0;
    270         if (n->nodeType() == Node::PROCESSING_INSTRUCTION_NODE) {
     265    for (auto& node : m_styleSheetCandidateNodes) {
     266        StyleSheet* sheet = nullptr;
     267        if (node->nodeType() == Node::PROCESSING_INSTRUCTION_NODE) {
    271268            // Processing instruction (XML documents only).
    272269            // We don't support linking to embedded CSS stylesheets, see <https://bugs.webkit.org/show_bug.cgi?id=49281> for discussion.
    273             ProcessingInstruction* pi = toProcessingInstruction(n);
     270            ProcessingInstruction* pi = toProcessingInstruction(node);
    274271            sheet = pi->sheet();
    275272#if ENABLE(XSLT)
     
    282279            }
    283280#endif
    284         } else if ((n->isHTMLElement() && (n->hasTagName(linkTag) || n->hasTagName(styleTag)))
    285             || (n->isSVGElement() && n->hasTagName(SVGNames::styleTag))) {
    286             Element* e = toElement(n);
    287             AtomicString title = e->getAttribute(titleAttr);
     281        } else if ((node->isHTMLElement() && (toHTMLElement(*node).hasTagName(linkTag) || toHTMLElement(*node).hasTagName(styleTag))) || (node->isSVGElement() && toSVGElement(*node).hasTagName(SVGNames::styleTag))) {
     282            Element& element = toElement(*node);
     283            AtomicString title = element.getAttribute(titleAttr);
    288284            bool enabledViaScript = false;
    289             if (e->hasTagName(linkTag)) {
     285            if (isHTMLLinkElement(element)) {
    290286                // <LINK> element
    291                 HTMLLinkElement* linkElement = toHTMLLinkElement(n);
    292                 if (linkElement->isDisabled())
     287                HTMLLinkElement& linkElement = toHTMLLinkElement(element);
     288                if (linkElement.isDisabled())
    293289                    continue;
    294                 enabledViaScript = linkElement->isEnabledViaScript();
    295                 if (linkElement->styleSheetIsLoading()) {
     290                enabledViaScript = linkElement.isEnabledViaScript();
     291                if (linkElement.styleSheetIsLoading()) {
    296292                    // it is loading but we should still decide which style sheet set to use
    297293                    if (!enabledViaScript && !title.isEmpty() && m_preferredStylesheetSetName.isEmpty()) {
    298                         const AtomicString& rel = e->getAttribute(relAttr);
    299                         if (!rel.contains("alternate")) {
     294                        if (!linkElement.fastGetAttribute(relAttr).contains("alternate")) {
    300295                            m_preferredStylesheetSetName = title;
    301296                            m_selectedStylesheetSetName = title;
     
    304299                    continue;
    305300                }
    306                 if (!linkElement->sheet())
     301                if (!linkElement.sheet())
    307302                    title = nullAtom;
    308303            }
    309304            // Get the current preferred styleset. This is the
    310305            // set of sheets that will be enabled.
    311             if (isSVGStyleElement(e))
    312                 sheet = toSVGStyleElement(e)->sheet();
    313             else {
    314                 if (isHTMLLinkElement(e))
    315                     sheet = toHTMLLinkElement(n)->sheet();
    316                 else {
    317                     // <STYLE> element
    318                     sheet = toHTMLStyleElement(e)->sheet();
    319                 }
    320             }
     306            if (isSVGStyleElement(element))
     307                sheet = toSVGStyleElement(element).sheet();
     308            else if (isHTMLLinkElement(element))
     309                sheet = toHTMLLinkElement(element).sheet();
     310            else
     311                sheet = toHTMLStyleElement(element).sheet();
    321312            // Check to see if this sheet belongs to a styleset
    322313            // (thus making it PREFERRED or ALTERNATE rather than
    323314            // PERSISTENT).
    324             AtomicString rel = e->getAttribute(relAttr);
     315            auto& rel = element.fastGetAttribute(relAttr);
    325316            if (!enabledViaScript && !title.isEmpty()) {
    326317                // Yes, we have a title.
     
    330321                    // us as the preferred set. Otherwise, just ignore
    331322                    // this sheet.
    332                     if (e->hasTagName(styleTag) || !rel.contains("alternate"))
     323                    if (isHTMLStyleElement(element) || !rel.contains("alternate"))
    333324                        m_preferredStylesheetSetName = m_selectedStylesheetSetName = title;
    334325                }
    335326                if (title != m_preferredStylesheetSetName)
    336                     sheet = 0;
     327                    sheet = nullptr;
    337328            }
    338329
    339330            if (rel.contains("alternate") && title.isEmpty())
    340                 sheet = 0;
     331                sheet = nullptr;
    341332        }
    342333        if (sheet)
  • trunk/Source/WebCore/dom/Element.cpp

    r165542 r165544  
    4545#include "FrameSelection.h"
    4646#include "FrameView.h"
     47#include "HTMLCanvasElement.h"
    4748#include "HTMLCollection.h"
    4849#include "HTMLDocument.h"
    49 #include "HTMLElement.h"
    5050#include "HTMLFormControlsCollection.h"
    5151#include "HTMLLabelElement.h"
     
    9494}
    9595
    96 typedef Vector<RefPtr<Attr>> AttrNodeList;
    97 typedef HashMap<Element*, OwnPtr<AttrNodeList>> AttrNodeListMap;
    98 
    99 static AttrNodeListMap& attrNodeListMap()
    100 {
    101     DEFINE_STATIC_LOCAL(AttrNodeListMap, map, ());
     96static HashMap<Element*, Vector<RefPtr<Attr>>>& attrNodeListMap()
     97{
     98    static NeverDestroyed<HashMap<Element*, Vector<RefPtr<Attr>>>> map;
    10299    return map;
    103100}
    104101
    105 static AttrNodeList* attrNodeListForElement(Element* element)
    106 {
    107     if (!element->hasSyntheticAttrChildNodes())
    108         return 0;
    109     ASSERT(attrNodeListMap().contains(element));
    110     return attrNodeListMap().get(element);
    111 }
    112 
    113 static AttrNodeList& ensureAttrNodeListForElement(Element* element)
    114 {
    115     if (element->hasSyntheticAttrChildNodes()) {
    116         ASSERT(attrNodeListMap().contains(element));
    117         return *attrNodeListMap().get(element);
    118     }
    119     ASSERT(!attrNodeListMap().contains(element));
    120     element->setHasSyntheticAttrChildNodes(true);
    121     AttrNodeListMap::AddResult result = attrNodeListMap().add(element, adoptPtr(new AttrNodeList));
    122     return *result.iterator->value;
    123 }
    124 
    125 static void removeAttrNodeListForElement(Element* element)
    126 {
    127     ASSERT(element->hasSyntheticAttrChildNodes());
    128     ASSERT(attrNodeListMap().contains(element));
    129     attrNodeListMap().remove(element);
    130     element->setHasSyntheticAttrChildNodes(false);
    131 }
    132 
    133 static Attr* findAttrNodeInList(AttrNodeList& attrNodeList, const QualifiedName& name)
    134 {
    135     for (unsigned i = 0; i < attrNodeList.size(); ++i) {
    136         if (attrNodeList.at(i)->qualifiedName() == name)
    137             return attrNodeList.at(i).get();
    138     }
    139     return 0;
     102static Vector<RefPtr<Attr>>* attrNodeListForElement(Element& element)
     103{
     104    if (!element.hasSyntheticAttrChildNodes())
     105        return nullptr;
     106    ASSERT(attrNodeListMap().contains(&element));
     107    return &attrNodeListMap().find(&element)->value;
     108}
     109
     110static Vector<RefPtr<Attr>>& ensureAttrNodeListForElement(Element& element)
     111{
     112    if (element.hasSyntheticAttrChildNodes()) {
     113        ASSERT(attrNodeListMap().contains(&element));
     114        return attrNodeListMap().find(&element)->value;
     115    }
     116    ASSERT(!attrNodeListMap().contains(&element));
     117    element.setHasSyntheticAttrChildNodes(true);
     118    return attrNodeListMap().add(&element, Vector<RefPtr<Attr>>()).iterator->value;
     119}
     120
     121static void removeAttrNodeListForElement(Element& element)
     122{
     123    ASSERT(element.hasSyntheticAttrChildNodes());
     124    ASSERT(attrNodeListMap().contains(&element));
     125    attrNodeListMap().remove(&element);
     126    element.setHasSyntheticAttrChildNodes(false);
     127}
     128
     129static Attr* findAttrNodeInList(Vector<RefPtr<Attr>>& attrNodeList, const QualifiedName& name)
     130{
     131    for (auto& node : attrNodeList) {
     132        if (node->qualifiedName() == name)
     133            return node.get();
     134    }
     135    return nullptr;
    140136}
    141137
     
    435431    // focusable as long as their canvas is displayed and visible.
    436432    if (isInCanvasSubtree()) {
    437         const Element* e = this;
    438         while (e && !e->hasLocalName(canvasTag))
    439             e = e->parentElement();
    440         ASSERT(e);
    441         return e->renderer() && e->renderer()->style().visibility() == VISIBLE;
     433        ASSERT(ancestorsOfType<HTMLCanvasElement>(*this).first());
     434        auto& canvas = *ancestorsOfType<HTMLCanvasElement>(*this).first();
     435        return canvas.renderer() && canvas.renderer()->style().visibility() == VISIBLE;
    442436    }
    443437
     
    16391633{
    16401634    ASSERT(hasSyntheticAttrChildNodes());
    1641     return *attrNodeListForElement(this);
     1635    return *attrNodeListForElement(*this);
    16421636}
    16431637
     
    16751669    attrNode->attachToElement(this);
    16761670    treeScope().adoptIfNeeded(attrNode);
    1677     ensureAttrNodeListForElement(this).append(attrNode);
     1671    ensureAttrNodeListForElement(*this).append(attrNode);
    16781672
    16791673    return oldAttrNode.release();
     
    27702764PassRefPtr<Attr> Element::attrIfExists(const QualifiedName& name)
    27712765{
    2772     if (AttrNodeList* attrNodeList = attrNodeListForElement(this))
     2766    if (auto* attrNodeList = attrNodeListForElement(*this))
    27732767        return findAttrNodeInList(*attrNodeList, name);
    2774     return 0;
     2768    return nullptr;
    27752769}
    27762770
    27772771PassRefPtr<Attr> Element::ensureAttr(const QualifiedName& name)
    27782772{
    2779     AttrNodeList& attrNodeList = ensureAttrNodeListForElement(this);
     2773    auto& attrNodeList = ensureAttrNodeListForElement(*this);
    27802774    RefPtr<Attr> attrNode = findAttrNodeInList(attrNodeList, name);
    27812775    if (!attrNode) {
     
    27922786    attrNode->detachFromElementWithValue(value);
    27932787
    2794     AttrNodeList* attrNodeList = attrNodeListForElement(this);
     2788    auto* attrNodeList = attrNodeListForElement(*this);
    27952789    for (unsigned i = 0; i < attrNodeList->size(); ++i) {
    27962790        if (attrNodeList->at(i)->qualifiedName() == attrNode->qualifiedName()) {
    27972791            attrNodeList->remove(i);
    27982792            if (attrNodeList->isEmpty())
    2799                 removeAttrNodeListForElement(this);
     2793                removeAttrNodeListForElement(*this);
    28002794            return;
    28012795        }
     
    28062800void Element::detachAllAttrNodesFromElement()
    28072801{
    2808     AttrNodeList* attrNodeList = attrNodeListForElement(this);
     2802    auto* attrNodeList = attrNodeListForElement(*this);
    28092803    ASSERT(attrNodeList);
    28102804
     
    28142808    }
    28152809
    2816     removeAttrNodeListForElement(this);
     2810    removeAttrNodeListForElement(*this);
    28172811}
    28182812
  • trunk/Source/WebCore/dom/Element.h

    r165542 r165544  
    261261    String tagName() const { return nodeName(); }
    262262    bool hasTagName(const QualifiedName& tagName) const { return m_tagName.matches(tagName); }
    263    
     263    bool hasTagName(const HTMLQualifiedName& tagName) const { return ContainerNode::hasTagName(tagName); }
     264    bool hasTagName(const MathMLQualifiedName& tagName) const { return ContainerNode::hasTagName(tagName); }
     265    bool hasTagName(const SVGQualifiedName& tagName) const { return ContainerNode::hasTagName(tagName); }
     266
    264267    // A fast function for checking the local name against another atomic string.
    265268    bool hasLocalName(const AtomicString& other) const { return m_tagName.localName() == other; }
    266     bool hasLocalName(const QualifiedName& other) const { return m_tagName.localName() == other.localName(); }
    267269
    268270    virtual const AtomicString& localName() const override final { return m_tagName.localName(); }
     
    687689template <> inline bool isElementOfType<const Element>(const Element&) { return true; }
    688690
    689 inline bool Node::hasTagName(const QualifiedName& name) const
    690 {
    691     return isElementNode() && toElement(this)->hasTagName(name);
    692 }
    693    
    694 inline bool Node::hasLocalName(const AtomicString& name) const
    695 {
    696     return isElementNode() && toElement(this)->hasLocalName(name);
    697 }
    698 
    699691inline bool Node::hasAttributes() const
    700692{
  • trunk/Source/WebCore/dom/Node.h

    r165479 r165544  
    6161class Frame;
    6262class HTMLInputElement;
     63class HTMLQualifiedName;
    6364class IntRect;
    6465class KeyboardEvent;
     66class MathMLQualifiedName;
    6567class NSResolver;
    6668class NamedNodeMap;
     
    7678class RenderObject;
    7779class RenderStyle;
     80class SVGQualifiedName;
    7881class ShadowRoot;
    7982class TagNodeList;
     
    158161    // DOM methods & attributes for Node
    159162
    160     bool hasTagName(const QualifiedName&) const;
    161     bool hasLocalName(const AtomicString&) const;
     163    bool hasTagName(const HTMLQualifiedName&) const;
     164    bool hasTagName(const MathMLQualifiedName&) const;
     165    bool hasTagName(const SVGQualifiedName&) const;
    162166    virtual String nodeName() const = 0;
    163167    virtual String nodeValue() const;
     
    260264    void setHasSyntheticAttrChildNodes(bool flag) { setFlag(flag, HasSyntheticAttrChildNodesFlag); }
    261265
    262     // If this node is in a shadow tree, returns its shadow host. Otherwise, returns 0.
     266    // If this node is in a shadow tree, returns its shadow host. Otherwise, returns null.
    263267    Element* shadowHost() const;
    264268    // If this node is in a shadow tree, returns its shadow host. Otherwise, returns this.
     
    268272    ShadowRoot* shadowRoot() const;
    269273
    270     // Returns 0, a child of ShadowRoot, or a legacy shadow root.
     274    // Returns null, a child of ShadowRoot, or a legacy shadow root.
    271275    Node* nonBoundaryShadowTreeRootNode();
    272276
     
    277281    Node* highestAncestor() const;
    278282
    279     // Use when it's guaranteed to that shadowHost is 0.
     283    // Use when it's guaranteed to that shadowHost is null.
    280284    ContainerNode* parentNodeGuaranteedHostFree() const;
    281     // Returns the parent node, but 0 if the parent node is a ShadowRoot.
     285    // Returns the parent node, but null if the parent node is a ShadowRoot.
    282286    ContainerNode* nonShadowBoundaryParentNode() const;
    283287
     
    378382    unsigned nodeIndex() const;
    379383
    380     // Returns the DOM ownerDocument attribute. This method never returns 0, except in the case
     384    // Returns the DOM ownerDocument attribute. This method never returns null, except in the case
    381385    // of a Document node.
    382386    Document* ownerDocument() const;
    383387
    384     // Returns the document associated with this node. This method never returns 0.
     388    // Returns the document associated with this node.
    385389    // A Document node returns itself.
    386390    Document& document() const
     
    492496    void showTreeForThis() const;
    493497    void showNodePathForThis() const;
    494     void showTreeAndMark(const Node* markedNode1, const char* markedLabel1, const Node* markedNode2 = 0, const char* markedLabel2 = 0) const;
     498    void showTreeAndMark(const Node* markedNode1, const char* markedLabel1, const Node* markedNode2 = nullptr, const char* markedLabel2 = nullptr) const;
    495499    void showTreeForThisAcrossFrame() const;
    496500#endif
    497501
    498     void invalidateNodeListAndCollectionCachesInAncestors(const QualifiedName* attrName = 0, Element* attributeOwnerElement = 0);
     502    void invalidateNodeListAndCollectionCachesInAncestors(const QualifiedName* attrName = nullptr, Element* attributeOwnerElement = nullptr);
    499503    NodeListsNodeData* nodeLists();
    500504    void clearNodeLists();
     
    671675    virtual void derefEventTarget() override;
    672676
    673     virtual RenderStyle* nonRendererStyle() const { return 0; }
     677    virtual RenderStyle* nonRendererStyle() const { return nullptr; }
    674678
    675679    Element* ancestorElement() const;
  • trunk/Source/WebCore/dom/PositionIterator.cpp

    r163712 r165544  
    2727#include "PositionIterator.h"
    2828
     29#include "HTMLElement.h"
    2930#include "HTMLNames.h"
    3031#include "RenderBlock.h"
  • trunk/Source/WebCore/dom/StyledElement.cpp

    r164856 r165544  
    3131#include "ContentSecurityPolicy.h"
    3232#include "DOMTokenList.h"
     33#include "HTMLElement.h"
    3334#include "HTMLParserIdioms.h"
    3435#include "InspectorInstrumentation.h"
  • trunk/Source/WebCore/dom/Text.cpp

    r163440 r165544  
    2626#include "RenderSVGInlineText.h"
    2727#include "RenderText.h"
     28#include "SVGElement.h"
     29#include "SVGNames.h"
    2830#include "ScopedEventQueue.h"
    2931#include "ShadowRoot.h"
    30 #include "SVGNames.h"
    31 #include "TextNodeTraversal.h"
    32 
    3332#include "StyleInheritedData.h"
    3433#include "StyleResolver.h"
     34#include "TextNodeTraversal.h"
    3535#include <wtf/CheckedArithmetic.h>
    3636#include <wtf/text/CString.h>
  • trunk/Source/WebCore/dom/make_names.pl

    r163534 r165544  
    11#!/usr/bin/perl -w
    22
    3 # Copyright (C) 2005, 2006, 2007, 2009, 2013 Apple Inc. All rights reserved.
     3# Copyright (C) 2005-2007, 2009, 2013-2014 Apple Inc. All rights reserved.
    44# Copyright (C) 2009, Julien Chaffraix <jchaffraix@webkit.org>
    55# Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
     
    104104
    105105    printLicenseHeader($F);
    106     printHeaderHead($F, "CSS", $familyNamesFileBase, "#include <wtf/text/AtomicString.h>");
     106    printHeaderHead($F, "CSS", $familyNamesFileBase, "#include <wtf/text/AtomicString.h>", "");
    107107
    108108    printMacros($F, "extern const WTF::AtomicString", "", \%parameters);
     
    526526sub printHeaderHead
    527527{
    528     my ($F, $prefix, $nsName, $includes) = @_;
    529 
    530     print F "#ifndef ${prefix}_${nsName}Names_h\n";
    531     print F "#define ${prefix}_${nsName}Names_h\n\n";
    532     print F "$includes\n\n";
    533 
    534     print F "namespace WebCore {\n\n";
    535     print F "namespace ${nsName}Names {\n\n";
    536 
    537     print F "#ifndef ${prefix}_${nsName}NAMES_HIDE_GLOBALS\n";
     528    my ($F, $prefix, $namespace, $includes, $definitions) = @_;
     529
     530    print F<<END
     531#ifndef ${prefix}_${namespace}Names_h
     532
     533#define ${prefix}_${namespace}Names_h
     534
     535$includes
     536
     537namespace WebCore {
     538
     539${definitions}namespace ${namespace}Names {
     540
     541#ifndef ${prefix}_${namespace}_NAMES_HIDE_GLOBALS
     542
     543END
     544    ;
    538545}
    539546
    540547sub printCppHead
    541548{
    542     my ($F, $prefix, $nsName, $usedNamespace) = @_;
     549    my ($F, $prefix, $namespace, $usedNamespace) = @_;
    543550
    544551    print F "#include \"config.h\"\n\n";
    545552    print F "#ifdef SKIP_STATIC_CONSTRUCTORS_ON_GCC\n";
    546     print F "#define ${prefix}_${nsName}NAMES_HIDE_GLOBALS 1\n";
     553    print F "#define ${prefix}_${namespace}_NAMES_HIDE_GLOBALS 1\n";
    547554    print F "#else\n";
    548555    print F "#define QNAME_DEFAULT_CONSTRUCTOR 1\n";
    549556    print F "#endif\n\n";
    550557
    551     print F "#include \"${nsName}Names.h\"\n\n";
     558    print F "#include \"${namespace}Names.h\"\n\n";
    552559    print F "#include <wtf/StaticConstructors.h>\n";
    553560
    554561    print F "namespace WebCore {\n\n";
    555     print F "namespace ${nsName}Names {\n\n";
     562    print F "namespace ${namespace}Names {\n\n";
    556563    print F "using namespace $usedNamespace;\n\n";
    557564}
     
    640647                # We need to check for HTMLUnknownElement if it might have been created by the factory.
    641648                print F <<END
    642 inline bool $checkHelper(const HTMLElement& element) { return !element.isHTMLUnknownElement() && element.hasLocalName($parameters{namespace}Names::${name}Tag); }
     649inline bool $checkHelper(const HTMLElement& element) { return !element.isHTMLUnknownElement() && element.hasTagName($parameters{namespace}Names::${name}Tag); }
    643650inline bool $checkHelper(const HTMLElement* element) { ASSERT(element); return $checkHelper(*element); }
    644651END
     
    646653            } else {
    647654                print F <<END
    648 inline bool $checkHelper(const HTMLElement& element) { return element.hasLocalName(HTMLNames::${name}Tag); }
     655inline bool $checkHelper(const HTMLElement& element) { return element.hasTagName(HTMLNames::${name}Tag); }
    649656inline bool $checkHelper(const HTMLElement* element) { ASSERT(element); return $checkHelper(*element); }
    650657END
     
    702709
    703710    printLicenseHeader($F);
    704     printHeaderHead($F, "DOM", $parameters{namespace}, "#include \"QualifiedName.h\"");
    705 
    706     my $lowerNamespace = lc($parameters{namespacePrefix});
     711    printHeaderHead($F, "DOM", $parameters{namespace}, '#include "QualifiedName.h"', "class $parameters{namespace}QualifiedName : public QualifiedName { };\n\n");
     712
     713    my $lowercaseNamespacePrefix = lc($parameters{namespacePrefix});
     714
    707715    print F "// Namespace\n";
    708     print F "extern const WTF::AtomicString ${lowerNamespace}NamespaceURI;\n\n";
     716    print F "extern const WTF::AtomicString ${lowercaseNamespacePrefix}NamespaceURI;\n\n";
    709717
    710718    if (keys %allTags) {
    711719        print F "// Tags\n";
    712         printMacros($F, "extern const WebCore::QualifiedName", "Tag", \%allTags);
     720        printMacros($F, "extern const WebCore::$parameters{namespace}QualifiedName", "Tag", \%allTags);
    713721    }
    714722
     
    721729    if (keys %allTags) {
    722730        print F "const unsigned $parameters{namespace}TagsCount = ", scalar(keys %allTags), ";\n";
    723         print F "const WebCore::QualifiedName* const * get$parameters{namespace}Tags();\n";
     731        print F "const WebCore::$parameters{namespace}QualifiedName* const* get$parameters{namespace}Tags();\n";
    724732    }
    725733
    726734    if (keys %allAttrs) {
    727735        print F "const unsigned $parameters{namespace}AttrsCount = ", scalar(keys %allAttrs), ";\n";
    728         print F "const WebCore::QualifiedName* const * get$parameters{namespace}Attrs();\n";
     736        print F "const WebCore::QualifiedName* const* get$parameters{namespace}Attrs();\n";
    729737    }
    730738
     
    742750    printCppHead($F, "DOM", $parameters{namespace}, "WebCore");
    743751   
    744     my $lowerNamespace = lc($parameters{namespacePrefix});
    745 
    746     print F "DEFINE_GLOBAL(AtomicString, ${lowerNamespace}NamespaceURI)\n\n";
     752    my $lowercaseNamespacePrefix = lc($parameters{namespacePrefix});
     753
     754    print F "DEFINE_GLOBAL(AtomicString, ${lowercaseNamespacePrefix}NamespaceURI)\n\n";
    747755
    748756    print F StaticString::GenerateStrings(\%allStrings);
     
    754762        }
    755763       
    756         print F "\n\nconst WebCore::QualifiedName* const * get$parameters{namespace}Tags()\n";
    757         print F "{\n    static const WebCore::QualifiedName* const $parameters{namespace}Tags[] = {\n";
     764        print F "\n\nconst WebCore::$parameters{namespace}QualifiedName* const* get$parameters{namespace}Tags()\n";
     765        print F "{\n    static const WebCore::$parameters{namespace}QualifiedName* const $parameters{namespace}Tags[] = {\n";
    758766        for my $name (sort keys %allTags) {
    759             print F "        reinterpret_cast<const WebCore::QualifiedName*>(&${name}Tag),\n";
     767            print F "        reinterpret_cast<const WebCore::$parameters{namespace}QualifiedName*>(&${name}Tag),\n";
    760768        }
    761769        print F "    };\n";
     
    769777            print F "DEFINE_GLOBAL(QualifiedName, ", $name, "Attr)\n";
    770778        }
    771         print F "\n\nconst WebCore::QualifiedName* const * get$parameters{namespace}Attrs()\n";
     779        print F "\n\nconst WebCore::QualifiedName* const* get$parameters{namespace}Attrs()\n";
    772780        print F "{\n    static const WebCore::QualifiedName* const $parameters{namespace}Attrs[] = {\n";
    773781        for my $name (sort keys %allAttrs) {
     
    781789    printInit($F, 0);
    782790
    783     print(F "    AtomicString ${lowerNamespace}NS(\"$parameters{namespaceURI}\", AtomicString::ConstructFromLiteral);\n\n");
     791    print(F "    AtomicString ${lowercaseNamespacePrefix}NS(\"$parameters{namespaceURI}\", AtomicString::ConstructFromLiteral);\n\n");
    784792
    785793    print(F "    // Namespace\n");
    786     print(F "    new (NotNull, (void*)&${lowerNamespace}NamespaceURI) AtomicString(${lowerNamespace}NS);\n");
     794    print(F "    new (NotNull, (void*)&${lowercaseNamespacePrefix}NamespaceURI) AtomicString(${lowercaseNamespacePrefix}NS);\n");
    787795    print(F "\n");
    788796    print F StaticString::GenerateStringAsserts(\%allStrings);
    789797
    790798    if (keys %allTags) {
    791         my $tagsNamespace = $parameters{tagsNullNamespace} ? "nullAtom" : "${lowerNamespace}NS";
     799        my $tagsNamespace = $parameters{tagsNullNamespace} ? "nullAtom" : "${lowercaseNamespacePrefix}NS";
    792800        printDefinitions($F, \%allTags, "tags", $tagsNamespace);
    793801    }
    794802    if (keys %allAttrs) {
    795         my $attrsNamespace = $parameters{attrsNullNamespace} ? "nullAtom" : "${lowerNamespace}NS";
     803        my $attrsNamespace = $parameters{attrsNullNamespace} ? "nullAtom" : "${lowercaseNamespacePrefix}NS";
    796804        printDefinitions($F, \%allAttrs, "attributes", $attrsNamespace);
    797805    }
  • trunk/Source/WebCore/editing/ApplyStyleCommand.cpp

    r164964 r165544  
    6666}
    6767
    68 bool isLegacyAppleStyleSpan(const Node *node)
     68bool isLegacyAppleStyleSpan(const Node* node)
    6969{
    7070    if (!node || !node->isHTMLElement())
    7171        return false;
    7272
    73     const HTMLElement* elem = toHTMLElement(node);
    74     return elem->hasLocalName(spanAttr) && elem->getAttribute(classAttr) == styleSpanClassString();
     73    const HTMLElement& element = toHTMLElement(*node);
     74    return element.hasTagName(spanTag) && element.fastGetAttribute(classAttr) == styleSpanClassString();
    7575}
    7676
     
    131131    , m_end(endingSelection().end().upstream())
    132132    , m_useEndingSelection(true)
    133     , m_styledInlineElement(0)
    134133    , m_removeOnly(false)
    135134    , m_isInlineElementToRemoveFunction(0)
     
    145144    , m_end(end)
    146145    , m_useEndingSelection(false)
    147     , m_styledInlineElement(0)
    148146    , m_removeOnly(false)
    149147    , m_isInlineElementToRemoveFunction(0)
     
    173171    , m_end(endingSelection().end().upstream())
    174172    , m_useEndingSelection(true)
    175     , m_styledInlineElement(0)
    176173    , m_removeOnly(true)
    177174    , m_isInlineElementToRemoveFunction(isInlineElementToRemoveFunction)
     
    851848        if (!style->styleIsPresentInComputedStyleOfNode(node))
    852849            return true;
    853         if (m_styledInlineElement && !enclosingNodeWithTag(positionBeforeNode(node), m_styledInlineElement->tagQName()))
     850        if (m_styledInlineElement && !enclosingElementWithTag(positionBeforeNode(node), m_styledInlineElement->tagQName()))
    854851            return true;
    855852    }
  • trunk/Source/WebCore/editing/Editor.cpp

    r165385 r165544  
    798798{
    799799    if (m_frame.selection().isCaret()) {
    800         if (enclosingNodeWithTag(m_frame.selection().selection().start(), ulTag))
     800        if (enclosingElementWithTag(m_frame.selection().selection().start(), ulTag))
    801801            return TrueTriState;
    802802    } else if (m_frame.selection().isRange()) {
    803         Node* startNode = enclosingNodeWithTag(m_frame.selection().selection().start(), ulTag);
    804         Node* endNode = enclosingNodeWithTag(m_frame.selection().selection().end(), ulTag);
     803        auto* startNode = enclosingElementWithTag(m_frame.selection().selection().start(), ulTag);
     804        auto* endNode = enclosingElementWithTag(m_frame.selection().selection().end(), ulTag);
    805805        if (startNode && endNode && startNode == endNode)
    806806            return TrueTriState;
     
    813813{
    814814    if (m_frame.selection().isCaret()) {
    815         if (enclosingNodeWithTag(m_frame.selection().selection().start(), olTag))
     815        if (enclosingElementWithTag(m_frame.selection().selection().start(), olTag))
    816816            return TrueTriState;
    817817    } else if (m_frame.selection().isRange()) {
    818         Node* startNode = enclosingNodeWithTag(m_frame.selection().selection().start(), olTag);
    819         Node* endNode = enclosingNodeWithTag(m_frame.selection().selection().end(), olTag);
     818        auto* startNode = enclosingElementWithTag(m_frame.selection().selection().start(), olTag);
     819        auto* endNode = enclosingElementWithTag(m_frame.selection().selection().end(), olTag);
    820820        if (startNode && endNode && startNode == endNode)
    821821            return TrueTriState;
  • trunk/Source/WebCore/editing/InsertListCommand.cpp

    r163712 r165544  
    131131        setEndingSelection(VisibleSelection(visibleStart, visibleEnd.previous(CannotCrossEditingBoundary), endingSelection().isDirectional()));
    132132
    133     const QualifiedName& listTag = (m_type == OrderedList) ? olTag : ulTag;
     133    auto& listTag = (m_type == OrderedList) ? olTag : ulTag;
    134134    if (endingSelection().isRange()) {
    135135        VisibleSelection selection = selectionForParagraphIteration(endingSelection());
     
    193193}
    194194
    195 void InsertListCommand::doApplyForSingleParagraph(bool forceCreateList, const QualifiedName& listTag, Range* currentSelection)
     195void InsertListCommand::doApplyForSingleParagraph(bool forceCreateList, const HTMLQualifiedName& listTag, Range* currentSelection)
    196196{
    197197    // FIXME: This will produce unexpected results for a selection that starts just before a
     
    208208            listNode = mergeWithNeighboringLists(listNode);
    209209        }
    210         if (!listNode->hasTagName(listTag))
     210        if (!listNode->hasTagName(listTag)) {
    211211            // listChildNode will be removed from the list and a list of type m_type will be created.
    212212            switchListType = true;
     213        }
    213214
    214215        // If the list is of the desired type, and we are not removing the list, then exit early.
  • trunk/Source/WebCore/editing/InsertListCommand.h

    r154938 r165544  
    3232
    3333class HTMLElement;
     34class HTMLQualifiedName;
    3435
    3536class InsertListCommand : public CompositeEditCommand {
     
    5556    bool selectionHasListOfType(const VisibleSelection& selection, const QualifiedName&);
    5657    PassRefPtr<HTMLElement> mergeWithNeighboringLists(PassRefPtr<HTMLElement>);
    57     void doApplyForSingleParagraph(bool forceCreateList, const QualifiedName&, Range* currentSelection);
     58    void doApplyForSingleParagraph(bool forceCreateList, const HTMLQualifiedName&, Range* currentSelection);
    5859    void unlistifyParagraph(const VisiblePosition& originalStart, HTMLElement* listNode, Node* listChildNode);
    5960    PassRefPtr<HTMLElement> listifyParagraph(const VisiblePosition& originalStart, const QualifiedName& listTag);
  • trunk/Source/WebCore/editing/MarkupAccumulator.cpp

    r163854 r165544  
    141141
    142142    if (tagNamesToSkip && targetNode.isElementNode()) {
    143         for (size_t i = 0; i < tagNamesToSkip->size(); ++i) {
    144             if (targetNode.hasTagName(tagNamesToSkip->at(i)))
     143        for (auto& name : *tagNamesToSkip) {
     144            if (toElement(targetNode).hasTagName(name))
    145145                return;
    146146        }
  • trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp

    r161638 r165544  
    629629
    630630        if (isProhibitedParagraphChild(toHTMLElement(node.get())->localName())) {
    631             if (HTMLElement* paragraphElement = toHTMLElement(enclosingNodeWithTag(positionInParentBeforeNode(node.get()), pTag)))
     631            if (auto* paragraphElement = enclosingElementWithTag(positionInParentBeforeNode(node.get()), pTag))
    632632                moveNodeOutOfAncestor(node, paragraphElement);
    633633        }
    634634
    635635        if (isHeaderElement(node.get())) {
    636             if (HTMLElement* headerElement = toHTMLElement(highestEnclosingNodeOfType(positionInParentBeforeNode(node.get()), isHeaderElement)))
     636            if (auto* headerElement = highestEnclosingNodeOfType(positionInParentBeforeNode(node.get()), isHeaderElement))
    637637                moveNodeOutOfAncestor(node, headerElement);
    638638        }
     
    673673    Node* lastLeafInserted = insertedNodes.lastLeafInserted();
    674674    if (lastLeafInserted && lastLeafInserted->isTextNode() && !hasRenderedText(toText(*lastLeafInserted))
    675         && !enclosingNodeWithTag(firstPositionInOrBeforeNode(lastLeafInserted), selectTag)
    676         && !enclosingNodeWithTag(firstPositionInOrBeforeNode(lastLeafInserted), scriptTag)) {
     675        && !enclosingElementWithTag(firstPositionInOrBeforeNode(lastLeafInserted), selectTag)
     676        && !enclosingElementWithTag(firstPositionInOrBeforeNode(lastLeafInserted), scriptTag)) {
    677677        insertedNodes.willRemoveNode(lastLeafInserted);
    678678        removeNode(lastLeafInserted);
     
    691691{
    692692    // FIXME: Why is this hack here?  What's special about <select> tags?
    693     Node* enclosingSelect = enclosingNodeWithTag(m_endOfInsertedContent, selectTag);
     693    auto* enclosingSelect = enclosingElementWithTag(m_endOfInsertedContent, selectTag);
    694694    return enclosingSelect ? lastPositionInOrAfterNode(enclosingSelect) : m_endOfInsertedContent;
    695695}
  • trunk/Source/WebCore/editing/TextIterator.cpp

    r165385 r165544  
    808808static bool hasHeaderTag(HTMLElement& element)
    809809{
    810     return element.hasLocalName(h1Tag)
    811         || element.hasLocalName(h2Tag)
    812         || element.hasLocalName(h3Tag)
    813         || element.hasLocalName(h4Tag)
    814         || element.hasLocalName(h5Tag)
    815         || element.hasLocalName(h6Tag);
     810    return element.hasTagName(h1Tag)
     811        || element.hasTagName(h2Tag)
     812        || element.hasTagName(h3Tag)
     813        || element.hasTagName(h4Tag)
     814        || element.hasTagName(h5Tag)
     815        || element.hasTagName(h6Tag);
    816816}
    817817
     
    826826        auto& element = toHTMLElement(node);
    827827        return hasHeaderTag(element)
    828             || element.hasLocalName(blockquoteTag)
    829             || element.hasLocalName(ddTag)
    830             || element.hasLocalName(divTag)
    831             || element.hasLocalName(dlTag)
    832             || element.hasLocalName(dtTag)
    833             || element.hasLocalName(hrTag)
    834             || element.hasLocalName(liTag)
    835             || element.hasLocalName(listingTag)
    836             || element.hasLocalName(olTag)
    837             || element.hasLocalName(pTag)
    838             || element.hasLocalName(preTag)
    839             || element.hasLocalName(trTag)
    840             || element.hasLocalName(ulTag);
     828            || element.hasTagName(blockquoteTag)
     829            || element.hasTagName(ddTag)
     830            || element.hasTagName(divTag)
     831            || element.hasTagName(dlTag)
     832            || element.hasTagName(dtTag)
     833            || element.hasTagName(hrTag)
     834            || element.hasTagName(liTag)
     835            || element.hasTagName(listingTag)
     836            || element.hasTagName(olTag)
     837            || element.hasTagName(pTag)
     838            || element.hasTagName(preTag)
     839            || element.hasTagName(trTag)
     840            || element.hasTagName(ulTag);
    841841    }
    842842   
     
    895895    if (!node.isHTMLElement())
    896896        return false;
    897     if (!(hasHeaderTag(toHTMLElement(node)) || toHTMLElement(node).hasLocalName(pTag)))
     897    if (!(hasHeaderTag(toHTMLElement(node)) || toHTMLElement(node).hasTagName(pTag)))
    898898        return false;
    899899
  • trunk/Source/WebCore/editing/TypingCommand.cpp

    r164964 r165544  
    3333#include "Element.h"
    3434#include "Frame.h"
     35#include "HTMLElement.h"
    3536#include "HTMLNames.h"
    3637#include "InsertLineBreakCommand.h"
    3738#include "InsertParagraphSeparatorCommand.h"
    3839#include "InsertTextCommand.h"
     40#include "MathMLElement.h"
    3941#include "RenderElement.h"
    4042#include "TextIterator.h"
  • trunk/Source/WebCore/editing/VisibleUnits.cpp

    r165537 r165544  
    2828
    2929#include "Document.h"
    30 #include "Element.h"
     30#include "HTMLElement.h"
    3131#include "HTMLNames.h"
    3232#include "InlineTextBox.h"
  • trunk/Source/WebCore/editing/htmlediting.cpp

    r165385 r165544  
    543543}
    544544
    545 Node* enclosingNodeWithTag(const Position& p, const QualifiedName& tagName)
    546 {
    547     if (p.isNull())
    548         return 0;
    549        
    550     Node* root = highestEditableRoot(p);
    551     for (Node* n = p.deprecatedNode(); n; n = n->parentNode()) {
    552         if (root && !n->hasEditableStyle())
     545Element* enclosingElementWithTag(const Position& position, const QualifiedName& tagName)
     546{
     547    if (position.isNull())
     548        return nullptr;
     549
     550    Node* root = highestEditableRoot(position);
     551    for (Node* node = position.deprecatedNode(); node; node = node->parentNode()) {
     552        if (root && !node->hasEditableStyle())
    553553            continue;
    554         if (n->hasTagName(tagName))
    555             return n;
    556         if (n == root)
    557             return 0;
    558     }
    559    
    560     return 0;
     554        if (!node->isElementNode())
     555            continue;
     556        if (toElement(*node).hasTagName(tagName))
     557            return toElement(node);
     558        if (node == root)
     559            return nullptr;
     560    }
     561
     562    return nullptr;
    561563}
    562564
  • trunk/Source/WebCore/editing/htmlediting.h

    r164964 r165544  
    6666Node* enclosingEmptyListItem(const VisiblePosition&);
    6767Element* enclosingAnchorElement(const Position&);
    68 Node* enclosingNodeWithTag(const Position&, const QualifiedName&);
     68Element* enclosingElementWithTag(const Position&, const QualifiedName&);
    6969Node* enclosingNodeOfType(const Position&, bool (*nodeIsOfType)(const Node*), EditingBoundaryCrossingRule = CannotCrossEditingBoundary);
    7070
  • trunk/Source/WebCore/editing/mac/EditorMac.mm

    r165479 r165544  
    299299    Node* commonAncestor = range->commonAncestorContainer(IGNORE_EXCEPTION);
    300300    ASSERT(commonAncestor);
    301     Node* enclosingAnchor = enclosingNodeWithTag(firstPositionInNode(commonAncestor), HTMLNames::aTag);
     301    auto* enclosingAnchor = enclosingElementWithTag(firstPositionInNode(commonAncestor), HTMLNames::aTag);
    302302    if (enclosingAnchor && comparePositions(firstPositionInOrBeforeNode(range->startPosition().anchorNode()), range->startPosition()) >= 0)
    303303        range->setStart(enclosingAnchor, 0, IGNORE_EXCEPTION);
  • trunk/Source/WebCore/editing/markup.cpp

    r164964 r165544  
    250250        MarkupAccumulator::appendText(out, text);
    251251    else {
    252         const bool useRenderedText = !enclosingNodeWithTag(firstPositionInNode(const_cast<Text*>(&text)), selectTag);
     252        const bool useRenderedText = !enclosingElementWithTag(firstPositionInNode(const_cast<Text*>(&text)), selectTag);
    253253        String content = useRenderedText ? renderedText(text, m_range) : stringValueForRange(text, m_range);
    254254        StringBuilder buffer;
     
    388388            continue;
    389389
    390         if (!n->renderer() && !enclosingNodeWithTag(firstPositionInOrBeforeNode(n), selectTag)) {
     390        if (!n->renderer() && !enclosingElementWithTag(firstPositionInOrBeforeNode(n), selectTag)) {
    391391            next = NodeTraversal::nextSkippingChildren(n);
    392392            // Don't skip over pastEnd.
     
    548548        specialCommonAncestor = commonAncestor;
    549549
    550     if (Node *enclosingAnchor = enclosingNodeWithTag(firstPositionInNode(specialCommonAncestor ? specialCommonAncestor : commonAncestor), aTag))
     550    if (auto* enclosingAnchor = enclosingElementWithTag(firstPositionInNode(specialCommonAncestor ? specialCommonAncestor : commonAncestor), aTag))
    551551        specialCommonAncestor = enclosingAnchor;
    552552
     
    570570    document.updateLayoutIgnorePendingStylesheets();
    571571
    572     Node* body = enclosingNodeWithTag(firstPositionInNode(commonAncestor), bodyTag);
     572    auto* body = enclosingElementWithTag(firstPositionInNode(commonAncestor), bodyTag);
    573573    Node* fullySelectedRoot = 0;
    574574    // FIXME: Do this for all fully selected blocks, not just the body.
     
    949949    }
    950950
    951     if (element->hasLocalName(colTag) || element->hasLocalName(colgroupTag) || element->hasLocalName(framesetTag)
    952         || element->hasLocalName(headTag) || element->hasLocalName(styleTag) || element->hasLocalName(titleTag)) {
     951    if (element->hasTagName(colTag) || element->hasTagName(colgroupTag) || element->hasTagName(framesetTag)
     952        || element->hasTagName(headTag) || element->hasTagName(styleTag) || element->hasTagName(titleTag)) {
    953953        ec = NOT_SUPPORTED_ERR;
    954954        return 0;
  • trunk/Source/WebCore/html/HTMLCollection.cpp

    r165103 r165544  
    177177    switch (type) {
    178178    case DocImages:
    179         return element.hasLocalName(imgTag);
     179        return element.hasTagName(imgTag);
    180180    case DocScripts:
    181         return element.hasLocalName(scriptTag);
     181        return element.hasTagName(scriptTag);
    182182    case DocForms:
    183         return element.hasLocalName(formTag);
     183        return element.hasTagName(formTag);
    184184    case TableTBodies:
    185         return element.hasLocalName(tbodyTag);
     185        return element.hasTagName(tbodyTag);
    186186    case TRCells:
    187         return element.hasLocalName(tdTag) || element.hasLocalName(thTag);
     187        return element.hasTagName(tdTag) || element.hasTagName(thTag);
    188188    case TSectionRows:
    189         return element.hasLocalName(trTag);
     189        return element.hasTagName(trTag);
    190190    case SelectOptions:
    191         return element.hasLocalName(optionTag);
     191        return element.hasTagName(optionTag);
    192192    case SelectedOptions:
    193         return element.hasLocalName(optionTag) && toHTMLOptionElement(element).selected();
     193        return element.hasTagName(optionTag) && toHTMLOptionElement(element).selected();
    194194    case DataListOptions:
    195         if (element.hasLocalName(optionTag)) {
     195        if (element.hasTagName(optionTag)) {
    196196            HTMLOptionElement& option = toHTMLOptionElement(element);
    197197            if (!option.isDisabledFormControl() && !option.value().isEmpty())
     
    200200        return false;
    201201    case MapAreas:
    202         return element.hasLocalName(areaTag);
     202        return element.hasTagName(areaTag);
    203203    case DocApplets:
    204         return element.hasLocalName(appletTag) || (element.hasLocalName(objectTag) && toHTMLObjectElement(element).containsJavaApplet());
     204        return element.hasTagName(appletTag) || (element.hasTagName(objectTag) && toHTMLObjectElement(element).containsJavaApplet());
    205205    case DocEmbeds:
    206         return element.hasLocalName(embedTag);
     206        return element.hasTagName(embedTag);
    207207    case DocLinks:
    208         return (element.hasLocalName(aTag) || element.hasLocalName(areaTag)) && element.fastHasAttribute(hrefAttr);
     208        return (element.hasTagName(aTag) || element.hasTagName(areaTag)) && element.fastHasAttribute(hrefAttr);
    209209    case DocAnchors:
    210         return element.hasLocalName(aTag) && element.fastHasAttribute(nameAttr);
     210        return element.hasTagName(aTag) && element.fastHasAttribute(nameAttr);
    211211    case DocAll:
    212212    case NodeChildren:
     
    270270    // The document.all collection returns only certain types of elements by name,
    271271    // although it returns any type of element by id.
    272     return element.hasLocalName(appletTag)
    273         || element.hasLocalName(embedTag)
    274         || element.hasLocalName(formTag)
    275         || element.hasLocalName(imgTag)
    276         || element.hasLocalName(inputTag)
    277         || element.hasLocalName(objectTag)
    278         || element.hasLocalName(selectTag);
     272    return element.hasTagName(appletTag)
     273        || element.hasTagName(embedTag)
     274        || element.hasTagName(formTag)
     275        || element.hasTagName(imgTag)
     276        || element.hasTagName(inputTag)
     277        || element.hasTagName(objectTag)
     278        || element.hasTagName(selectTag);
    279279}
    280280
  • trunk/Source/WebCore/html/HTMLElement.cpp

    r165045 r165544  
    9292    // for which no end tag should be serialized. It's unclear if the list for
    9393    // IE compat and the list for serialization sanity are the same.
    94     if (hasLocalName(areaTag)
    95         || hasLocalName(baseTag)
    96         || hasLocalName(basefontTag)
    97         || hasLocalName(brTag)
    98         || hasLocalName(colTag)
    99         || hasLocalName(embedTag)
    100         || hasLocalName(frameTag)
    101         || hasLocalName(hrTag)
    102         || hasLocalName(imageTag)
    103         || hasLocalName(imgTag)
    104         || hasLocalName(inputTag)
    105         || hasLocalName(isindexTag)
    106         || hasLocalName(linkTag)
    107         || hasLocalName(metaTag)
    108         || hasLocalName(paramTag)
    109         || hasLocalName(sourceTag)
    110         || hasLocalName(wbrTag))
     94    if (hasTagName(areaTag)
     95        || hasTagName(baseTag)
     96        || hasTagName(basefontTag)
     97        || hasTagName(brTag)
     98        || hasTagName(colTag)
     99        || hasTagName(embedTag)
     100        || hasTagName(frameTag)
     101        || hasTagName(hrTag)
     102        || hasTagName(imageTag)
     103        || hasTagName(imgTag)
     104        || hasTagName(inputTag)
     105        || hasTagName(isindexTag)
     106        || hasTagName(linkTag)
     107        || hasTagName(metaTag)
     108        || hasTagName(paramTag)
     109        || hasTagName(sourceTag)
     110        || hasTagName(wbrTag))
    111111        return true;
    112112    // FIXME: I'm not sure why dashboard mode would want to change the
    113113    // serialization of <canvas>, that seems like a bad idea.
    114114#if ENABLE(DASHBOARD_SUPPORT)
    115     if (hasLocalName(canvasTag)) {
     115    if (hasTagName(canvasTag)) {
    116116        Settings* settings = document().settings();
    117117        if (settings && settings->usesDashboardBackwardCompatibilityMode())
     
    124124static inline CSSValueID unicodeBidiAttributeForDirAuto(HTMLElement& element)
    125125{
    126     if (element.hasLocalName(preTag) || element.hasLocalName(textareaTag))
     126    if (element.hasTagName(preTag) || element.hasTagName(textareaTag))
    127127        return CSSValueWebkitPlaintext;
    128128    // FIXME: For bdo element, dir="auto" should result in "bidi-override isolate" but we don't support having multiple values in unicode-bidi yet.
     
    135135    unsigned borderWidth = 0;
    136136    if (value.isEmpty() || !parseHTMLNonNegativeInteger(value, borderWidth))
    137         return hasLocalName(tableTag) ? 1 : borderWidth;
     137        return hasTagName(tableTag) ? 1 : borderWidth;
    138138    return borderWidth;
    139139}
     
    379379        ContainerNode* container = this;
    380380#if ENABLE(TEMPLATE_ELEMENT)
    381         if (hasLocalName(templateTag))
     381        if (hasTagName(templateTag))
    382382            container = toHTMLTemplateElement(this)->content();
    383383#endif
     
    456456}
    457457
     458static inline bool shouldProhibitSetInnerOuterText(const HTMLElement& element)
     459{
     460    return element.hasTagName(colTag)
     461        || element.hasTagName(colgroupTag)
     462        || element.hasTagName(framesetTag)
     463        || element.hasTagName(headTag)
     464        || element.hasTagName(htmlTag)
     465        || element.hasTagName(tableTag)
     466        || element.hasTagName(tbodyTag)
     467        || element.hasTagName(tfootTag)
     468        || element.hasTagName(theadTag)
     469        || element.hasTagName(trTag);
     470}
     471
    458472void HTMLElement::setInnerText(const String& text, ExceptionCode& ec)
    459473{
     
    462476        return;
    463477    }
    464     if (hasLocalName(colTag) || hasLocalName(colgroupTag) || hasLocalName(framesetTag) ||
    465         hasLocalName(headTag) || hasLocalName(htmlTag) || hasLocalName(tableTag) ||
    466         hasLocalName(tbodyTag) || hasLocalName(tfootTag) || hasLocalName(theadTag) ||
    467         hasLocalName(trTag)) {
     478    if (shouldProhibitSetInnerOuterText(*this)) {
    468479        ec = NO_MODIFICATION_ALLOWED_ERR;
    469480        return;
     
    510521        return;
    511522    }
    512     if (hasLocalName(colTag) || hasLocalName(colgroupTag) || hasLocalName(framesetTag) ||
    513         hasLocalName(headTag) || hasLocalName(htmlTag) || hasLocalName(tableTag) ||
    514         hasLocalName(tbodyTag) || hasLocalName(tfootTag) || hasLocalName(theadTag) ||
    515         hasLocalName(trTag)) {
     523    if (shouldProhibitSetInnerOuterText(*this)) {
    516524        ec = NO_MODIFICATION_ALLOWED_ERR;
    517525        return;
     
    792800bool HTMLElement::rendererIsNeeded(const RenderStyle& style)
    793801{
    794     if (hasLocalName(noscriptTag)) {
     802    if (hasTagName(noscriptTag)) {
    795803        Frame* frame = document().frame();
    796804        if (frame && frame->script().canExecuteScripts(NotAboutToExecuteScript))
    797805            return false;
    798     } else if (hasLocalName(noembedTag)) {
     806    } else if (hasTagName(noembedTag)) {
    799807        Frame* frame = document().frame();
    800808        if (frame && frame->loader().subframeLoader().allowPlugins(NotAboutToInstantiatePlugin))
     
    806814RenderPtr<RenderElement> HTMLElement::createElementRenderer(PassRef<RenderStyle> style)
    807815{
    808     if (hasLocalName(wbrTag))
     816    if (hasTagName(wbrTag))
    809817        return createRenderer<RenderLineBreak>(*this, std::move(style));
    810818    return RenderElement::createFor(*this, std::move(style));
  • trunk/Source/WebCore/html/HTMLElement.h

    r162158 r165544  
    100100    virtual FormNamedItem* asFormNamedItem() { return 0; }
    101101
     102    bool hasTagName(const HTMLQualifiedName& name) const { return hasLocalName(name.localName()); }
     103
    102104protected:
    103105    HTMLElement(const QualifiedName& tagName, Document&, ConstructionType);
     
    152154NODE_TYPE_CASTS(HTMLElement)
    153155
     156inline bool Node::hasTagName(const HTMLQualifiedName& name) const
     157{
     158    return isHTMLElement() && toHTMLElement(*this).hasTagName(name);
     159}
     160
    154161} // namespace WebCore
    155162
  • trunk/Source/WebCore/html/HTMLObjectElement.cpp

    r163457 r165544  
    398398    DEFINE_STATIC_LOCAL(HashSet<AtomicStringImpl*>, tagList, ());
    399399    if (tagList.isEmpty()) {
    400         const QualifiedName* const * tags = HTMLNames::getHTMLTags();
     400        auto* tags = HTMLNames::getHTMLTags();
    401401        for (size_t i = 0; i < HTMLNames::HTMLTagsCount; i++) {
    402402            if (*tags[i] == bgsoundTag
  • trunk/Source/WebCore/html/HTMLSelectElement.cpp

    r165103 r165544  
    221221void HTMLSelectElement::add(HTMLElement* element, HTMLElement* before, ExceptionCode& ec)
    222222{
    223     if (!element || !(element->hasLocalName(optionTag) || element->hasLocalName(hrTag)))
     223    if (!element || !(isHTMLOptionElement(*element) || element->hasTagName(hrTag)))
    224224        return;
    225225
     
    250250String HTMLSelectElement::value() const
    251251{
    252     const Vector<HTMLElement*>& items = listItems();
    253     for (unsigned i = 0; i < items.size(); i++) {
    254         if (items[i]->hasLocalName(optionTag)) {
    255             HTMLOptionElement* option = toHTMLOptionElement(items[i]);
    256             if (option->selected())
    257                 return option->value();
    258         }
    259     }
    260     return "";
     252    for (auto* item : listItems()) {
     253        if (isHTMLOptionElement(*item)) {
     254            HTMLOptionElement& option = toHTMLOptionElement(*item);
     255            if (option.selected())
     256                return option.value();
     257        }
     258    }
     259    return emptyString();
    261260}
    262261
     
    270269
    271270    // Find the option with value() matching the given parameter and make it the current selection.
    272     const Vector<HTMLElement*>& items = listItems();
    273271    unsigned optionIndex = 0;
    274     for (unsigned i = 0; i < items.size(); i++) {
    275         if (items[i]->hasLocalName(optionTag)) {
    276             if (toHTMLOptionElement(items[i])->value() == value) {
     272    for (auto* item : listItems()) {
     273        if (isHTMLOptionElement(*item)) {
     274            if (toHTMLOptionElement(*item).value() == value) {
    277275                setSelectedIndex(optionIndex);
    278276                return;
    279277            }
    280             optionIndex++;
     278            ++optionIndex;
    281279        }
    282280    }
     
    485483        Vector<RefPtr<Element>> itemsToRemove;
    486484        size_t optionIndex = 0;
    487         for (size_t i = 0; i < items.size(); ++i) {
    488             Element* item = items[i];
    489             if (item->hasLocalName(optionTag) && optionIndex++ >= newLen) {
     485        for (auto& item : items) {
     486            if (isHTMLOptionElement(*item) && optionIndex++ >= newLen) {
    490487                ASSERT(item->parentNode());
    491488                itemsToRemove.append(item);
     
    493490        }
    494491
    495         for (size_t i = 0; i < itemsToRemove.size(); ++i) {
    496             Element* item = itemsToRemove[i].get();
     492        for (auto& item : itemsToRemove) {
    497493            if (item->parentNode())
    498                 item->parentNode()->removeChild(item, ec);
     494                item->parentNode()->removeChild(item.get(), ec);
    499495        }
    500496    }
     
    998994    size_t loopEndIndex = std::min(items.size(), listIndexEnd);
    999995    for (size_t i = listIndexStart; i < loopEndIndex; ++i) {
    1000         if (!items[i]->hasLocalName(optionTag))
     996        if (!isHTMLOptionElement(items[i]))
    1001997            continue;
    1002998        if (toHTMLOptionElement(items[i])->value() == value)
     
    10161012
    10171013    for (size_t i = 0; i < itemsSize; ++i) {
    1018         if (!items[i]->hasLocalName(optionTag))
     1014        if (!isHTMLOptionElement(items[i]))
    10191015            continue;
    10201016        toHTMLOptionElement(items[i])->setSelectedState(false);
     
    14961492            // Use space to toggle selection change.
    14971493            m_activeSelectionState = !m_activeSelectionState;
    1498             ASSERT(m_activeSelectionEndIndex >= 0
    1499                 && m_activeSelectionEndIndex < static_cast<int>(listItems.size())
    1500                 && listItems[m_activeSelectionEndIndex]->hasTagName(optionTag));
     1494            ASSERT(m_activeSelectionEndIndex >= 0);
     1495            ASSERT(m_activeSelectionEndIndex < static_cast<int>(listItems.size()));
     1496            ASSERT(isHTMLOptionElement(*listItems[m_activeSelectionEndIndex]));
    15011497            updateSelectedState(m_activeSelectionEndIndex, true /*multi*/, false /*shift*/);
    15021498            listBoxOnChange();
  • trunk/Source/WebCore/html/HTMLTableColElement.cpp

    r165395 r165544  
    8585const StyleProperties* HTMLTableColElement::additionalPresentationAttributeStyle()
    8686{
    87     if (!hasLocalName(colgroupTag))
    88         return 0;
     87    if (!hasTagName(colgroupTag))
     88        return nullptr;
    8989    if (HTMLTableElement* table = findParentTable())
    9090        return table->additionalGroupStyle(false);
    91     return 0;
     91    return nullptr;
    9292}
    9393
  • trunk/Source/WebCore/html/HTMLTableRowsCollection.cpp

    r161583 r165544  
    5555}
    5656
    57 static inline bool isInSection(HTMLTableRowElement* row, const QualifiedName& sectionTag)
     57static inline bool isInSection(HTMLTableRowElement& row, const HTMLQualifiedName& sectionTag)
    5858{
    59     // Because we know that the parent is a table or a section, all of which are in the HTML
    60     // namespace, it's OK to do the faster hasLocalName here instead of the more typical hasTagName,
    61     // since we don't need the check for the HTML namespace.
    62     return toElement(row->parentNode())->hasLocalName(sectionTag);
     59    // Because we know that the parent is a table or a section, it's safe to cast it to an HTMLElement
     60    // giving us access to the faster hasTagName overload from that class.
     61    return toHTMLElement(row.parentNode())->hasTagName(sectionTag);
    6362}
    6463
     
    8281    if (!previous)
    8382        child = ElementTraversal::firstChild(table);
    84     else if (isInSection(previous, theadTag))
     83    else if (isInSection(*previous, theadTag))
    8584        child = ElementTraversal::nextSibling(previous->parentNode());
    8685    for (; child; child = ElementTraversal::nextSibling(child)) {
     
    9291
    9392    // If still looking at top level and bodies, find the next row in top level or the first in the next body section.
    94     if (!previous || isInSection(previous, theadTag))
     93    if (!previous || isInSection(*previous, theadTag))
    9594        child = ElementTraversal::firstChild(table);
    9695    else if (previous->parentNode() == table)
    9796        child = ElementTraversal::nextSibling(previous);
    98     else if (isInSection(previous, tbodyTag))
     97    else if (isInSection(*previous, tbodyTag))
    9998        child = ElementTraversal::nextSibling(previous->parentNode());
    10099    for (; child; child = ElementTraversal::nextSibling(child)) {
     
    108107
    109108    // Find the first row in the next foot section.
    110     if (!previous || !isInSection(previous, tfootTag))
     109    if (!previous || !isInSection(*previous, tfootTag))
    111110        child = ElementTraversal::firstChild(table);
    112111    else
  • trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp

    r163579 r165544  
    4343#include "HTMLTemplateElement.h"
    4444#include "NotImplemented.h"
     45#include "SVGElement.h"
    4546#include "Text.h"
    4647
  • trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp

    r164569 r165544  
    4343#include "XMLNames.h"
    4444#include <wtf/MainThread.h>
     45#include <wtf/NeverDestroyed.h>
    4546#include <wtf/unicode/CharacterNames.h>
    4647
     
    523524}
    524525
    525 typedef HashMap<AtomicString, QualifiedName> PrefixedNameToQualifiedNameMap;
    526 
    527 static void mapLoweredLocalNameToName(PrefixedNameToQualifiedNameMap* map, const QualifiedName* const names[], size_t length)
    528 {
    529     for (size_t i = 0; i < length; ++i) {
     526template <typename TableQualifiedName>
     527static HashMap<AtomicString, QualifiedName> createCaseMap(const TableQualifiedName* const names[], unsigned length)
     528{
     529    HashMap<AtomicString, QualifiedName> map;
     530    for (unsigned i = 0; i < length; ++i) {
    530531        const QualifiedName& name = *names[i];
    531532        const AtomicString& localName = name.localName();
    532533        AtomicString loweredLocalName = localName.lower();
    533534        if (loweredLocalName != localName)
    534             map->add(loweredLocalName, name);
    535     }
    536 }
    537 
    538 static void adjustSVGTagNameCase(AtomicHTMLToken* token)
    539 {
    540     static PrefixedNameToQualifiedNameMap* caseMap = 0;
    541     if (!caseMap) {
    542         caseMap = new PrefixedNameToQualifiedNameMap;
    543         mapLoweredLocalNameToName(caseMap, SVGNames::getSVGTags(), SVGNames::SVGTagsCount);
    544     }
    545 
    546     const QualifiedName& casedName = caseMap->get(token->name());
     535            map.add(loweredLocalName, name);
     536    }
     537    return map;
     538}
     539
     540static void adjustSVGTagNameCase(AtomicHTMLToken& token)
     541{
     542    static NeverDestroyed<HashMap<AtomicString, QualifiedName>> map = createCaseMap(SVGNames::getSVGTags(), SVGNames::SVGTagsCount);
     543    const QualifiedName& casedName = map.get().get(token.name());
    547544    if (casedName.localName().isNull())
    548545        return;
    549     token->setName(casedName.localName());
    550 }
    551 
    552 template<const QualifiedName* const * getAttrs(), unsigned length>
    553 static void adjustAttributes(AtomicHTMLToken* token)
    554 {
    555     static PrefixedNameToQualifiedNameMap* caseMap = 0;
    556     if (!caseMap) {
    557         caseMap = new PrefixedNameToQualifiedNameMap;
    558         mapLoweredLocalNameToName(caseMap, getAttrs(), length);
    559     }
    560 
    561     for (unsigned i = 0; i < token->attributes().size(); ++i) {
    562         Attribute& tokenAttribute = token->attributes().at(i);
    563         const QualifiedName& casedName = caseMap->get(tokenAttribute.localName());
     546    token.setName(casedName.localName());
     547}
     548
     549static inline void adjustAttributes(HashMap<AtomicString, QualifiedName>& map, AtomicHTMLToken& token)
     550{
     551    for (auto& attribute : token.attributes()) {
     552        const QualifiedName& casedName = map.get(attribute.localName());
    564553        if (!casedName.localName().isNull())
    565             tokenAttribute.parserSetName(casedName);
    566     }
    567 }
    568 
    569 static void adjustSVGAttributes(AtomicHTMLToken* token)
     554            attribute.parserSetName(casedName);
     555    }
     556}
     557
     558template<const QualifiedName* const* attributesTable(), unsigned attributesTableLength>
     559static void adjustAttributes(AtomicHTMLToken& token)
     560{
     561    static NeverDestroyed<HashMap<AtomicString, QualifiedName>> map = createCaseMap(attributesTable(), attributesTableLength);
     562    adjustAttributes(map, token);
     563}
     564
     565static inline void adjustSVGAttributes(AtomicHTMLToken& token)
    570566{
    571567    adjustAttributes<SVGNames::getSVGAttrs, SVGNames::SVGAttrsCount>(token);
    572568}
    573569
    574 static void adjustMathMLAttributes(AtomicHTMLToken* token)
     570static inline void adjustMathMLAttributes(AtomicHTMLToken& token)
    575571{
    576572    adjustAttributes<MathMLNames::getMathMLAttrs, MathMLNames::MathMLAttrsCount>(token);
    577573}
    578574
    579 static void addNamesWithPrefix(PrefixedNameToQualifiedNameMap* map, const AtomicString& prefix, const QualifiedName* const names[], size_t length)
    580 {
    581     for (size_t i = 0; i < length; ++i) {
     575static void addNamesWithPrefix(HashMap<AtomicString, QualifiedName>& map, const AtomicString& prefix, const QualifiedName* const names[], unsigned length)
     576{
     577    for (unsigned i = 0; i < length; ++i) {
    582578        const QualifiedName& name = *names[i];
    583579        const AtomicString& localName = name.localName();
    584         AtomicString prefixColonLocalName = prefix + ':' + localName;
    585         QualifiedName nameWithPrefix(prefix, localName, name.namespaceURI());
    586         map->add(prefixColonLocalName, nameWithPrefix);
    587     }
    588 }
    589 
    590 static void adjustForeignAttributes(AtomicHTMLToken* token)
    591 {
    592     static PrefixedNameToQualifiedNameMap* map = 0;
    593     if (!map) {
    594         map = new PrefixedNameToQualifiedNameMap;
    595 
    596         addNamesWithPrefix(map, xlinkAtom, XLinkNames::getXLinkAttrs(), XLinkNames::XLinkAttrsCount);
    597 
    598         addNamesWithPrefix(map, xmlAtom, XMLNames::getXMLAttrs(), XMLNames::XMLAttrsCount);
    599 
    600         map->add(WTF::xmlnsAtom, XMLNSNames::xmlnsAttr);
    601         map->add("xmlns:xlink", QualifiedName(xmlnsAtom, xlinkAtom, XMLNSNames::xmlnsNamespaceURI));
    602     }
    603 
    604     for (unsigned i = 0; i < token->attributes().size(); ++i) {
    605         Attribute& tokenAttribute = token->attributes().at(i);
    606         const QualifiedName& name = map->get(tokenAttribute.localName());
    607         if (!name.localName().isNull())
    608             tokenAttribute.parserSetName(name);
    609     }
     580        map.add(prefix + ':' + localName, QualifiedName(prefix, localName, name.namespaceURI()));
     581    }
     582}
     583
     584static HashMap<AtomicString, QualifiedName> createForeignAttributesMap()
     585{
     586    HashMap<AtomicString, QualifiedName> map;
     587
     588    addNamesWithPrefix(map, xlinkAtom, XLinkNames::getXLinkAttrs(), XLinkNames::XLinkAttrsCount);
     589    addNamesWithPrefix(map, xmlAtom, XMLNames::getXMLAttrs(), XMLNames::XMLAttrsCount);
     590
     591    map.add(WTF::xmlnsAtom, XMLNSNames::xmlnsAttr);
     592    map.add("xmlns:xlink", QualifiedName(xmlnsAtom, xlinkAtom, XMLNSNames::xmlnsNamespaceURI));
     593
     594    return map;
     595}
     596
     597static void adjustForeignAttributes(AtomicHTMLToken& token)
     598{
     599    static NeverDestroyed<HashMap<AtomicString, QualifiedName>> map = createForeignAttributesMap();
     600    adjustAttributes(map, token);
    610601}
    611602
     
    897888    if (token->name() == MathMLNames::mathTag.localName()) {
    898889        m_tree.reconstructTheActiveFormattingElements();
    899         adjustMathMLAttributes(token);
    900         adjustForeignAttributes(token);
     890        adjustMathMLAttributes(*token);
     891        adjustForeignAttributes(*token);
    901892        m_tree.insertForeignElement(token, MathMLNames::mathmlNamespaceURI);
    902893        return;
     
    904895    if (token->name() == SVGNames::svgTag.localName()) {
    905896        m_tree.reconstructTheActiveFormattingElements();
    906         adjustSVGAttributes(token);
    907         adjustForeignAttributes(token);
     897        adjustSVGAttributes(*token);
     898        adjustForeignAttributes(*token);
    908899        m_tree.insertForeignElement(token, SVGNames::svgNamespaceURI);
    909900        return;
     
    29272918        const AtomicString& currentNamespace = m_tree.currentStackItem()->namespaceURI();
    29282919        if (currentNamespace == MathMLNames::mathmlNamespaceURI)
    2929             adjustMathMLAttributes(token);
     2920            adjustMathMLAttributes(*token);
    29302921        if (currentNamespace == SVGNames::svgNamespaceURI) {
    2931             adjustSVGTagNameCase(token);
    2932             adjustSVGAttributes(token);
    2933         }
    2934         adjustForeignAttributes(token);
     2922            adjustSVGTagNameCase(*token);
     2923            adjustSVGAttributes(*token);
     2924        }
     2925        adjustForeignAttributes(*token);
    29352926        m_tree.insertForeignElement(token, currentNamespace);
    29362927        break;
     
    29382929    case HTMLToken::EndTag: {
    29392930        if (m_tree.currentStackItem()->namespaceURI() == SVGNames::svgNamespaceURI)
    2940             adjustSVGTagNameCase(token);
     2931            adjustSVGTagNameCase(*token);
    29412932
    29422933        if (token->name() == SVGNames::scriptTag && m_tree.currentStackItem()->hasTagName(SVGNames::scriptTag)) {
  • trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp

    r164245 r165544  
    4949#include "InspectorPageAgent.h"
    5050#include "Node.h"
     51#include "SVGElement.h"
    5152#include "SVGNames.h"
    5253#include "StyleProperties.h"
  • trunk/Source/WebCore/mathml/MathMLElement.h

    r164856 r165544  
    5555    virtual bool isPresentationMathML() const;
    5656
     57    bool hasTagName(const MathMLQualifiedName& name) const { return hasLocalName(name.localName()); }
     58
    5759protected:
    5860    MathMLElement(const QualifiedName& tagName, Document&);
     
    6466    virtual bool isPresentationAttribute(const QualifiedName&) const override;
    6567    virtual void collectStyleForPresentationAttribute(const QualifiedName&, const AtomicString&, MutableStyleProperties&) override;
    66 private:   
    6768
    68     virtual void updateSelectedChild() { };
     69private:
     70    virtual void updateSelectedChild() { }
    6971};
    7072
     
    7375NODE_TYPE_CASTS(MathMLElement)
    7476
     77inline bool Node::hasTagName(const MathMLQualifiedName& name) const
     78{
     79    return isMathMLElement() && toMathMLElement(*this).hasTagName(name);
     80}
     81
    7582}
    7683
  • trunk/Source/WebCore/mathml/MathMLInlineContainerElement.cpp

    r165461 r165544  
    6161        if (renderer()->isRenderMathMLRow())
    6262            toRenderMathMLRow(renderer())->updateOperatorProperties();
    63         else if (hasLocalName(mathTag) || hasLocalName(msqrtTag)) {
     63        else if (hasTagName(mathTag) || hasTagName(msqrtTag)) {
    6464            auto childRenderer = renderer()->firstChild();
    6565            if (childRenderer && childRenderer->isRenderMathMLRow())
     
    7272RenderPtr<RenderElement> MathMLInlineContainerElement::createElementRenderer(PassRef<RenderStyle> style)
    7373{
    74     if (hasLocalName(annotation_xmlTag))
     74    if (hasTagName(annotation_xmlTag))
    7575        return createRenderer<RenderMathMLRow>(*this, std::move(style));
    76     if (hasLocalName(merrorTag) || hasLocalName(mphantomTag) || hasLocalName(mrowTag) || hasLocalName(mstyleTag))
     76    if (hasTagName(merrorTag) || hasTagName(mphantomTag) || hasTagName(mrowTag) || hasTagName(mstyleTag))
    7777        return createRenderer<RenderMathMLRow>(*this, std::move(style));
    78     if (hasLocalName(msubTag))
     78    if (hasTagName(msubTag))
    7979        return createRenderer<RenderMathMLScripts>(*this, std::move(style));
    80     if (hasLocalName(msupTag))
     80    if (hasTagName(msupTag))
    8181        return createRenderer<RenderMathMLScripts>(*this, std::move(style));
    82     if (hasLocalName(msubsupTag))
     82    if (hasTagName(msubsupTag))
    8383        return createRenderer<RenderMathMLScripts>(*this, std::move(style));
    84     if (hasLocalName(mmultiscriptsTag))
     84    if (hasTagName(mmultiscriptsTag))
    8585        return createRenderer<RenderMathMLScripts>(*this, std::move(style));
    86     if (hasLocalName(moverTag))
     86    if (hasTagName(moverTag))
    8787        return createRenderer<RenderMathMLUnderOver>(*this, std::move(style));
    88     if (hasLocalName(munderTag))
     88    if (hasTagName(munderTag))
    8989        return createRenderer<RenderMathMLUnderOver>(*this, std::move(style));
    90     if (hasLocalName(munderoverTag))
     90    if (hasTagName(munderoverTag))
    9191        return createRenderer<RenderMathMLUnderOver>(*this, std::move(style));
    92     if (hasLocalName(mfracTag))
     92    if (hasTagName(mfracTag))
    9393        return createRenderer<RenderMathMLFraction>(*this, std::move(style));
    94     if (hasLocalName(msqrtTag))
     94    if (hasTagName(msqrtTag))
    9595        return createRenderer<RenderMathMLSquareRoot>(*this, std::move(style));
    96     if (hasLocalName(mrootTag))
     96    if (hasTagName(mrootTag))
    9797        return createRenderer<RenderMathMLRoot>(*this, std::move(style));
    98     if (hasLocalName(mfencedTag))
     98    if (hasTagName(mfencedTag))
    9999        return createRenderer<RenderMathMLFenced>(*this, std::move(style));
    100     if (hasLocalName(mtableTag))
     100    if (hasTagName(mtableTag))
    101101        return createRenderer<RenderMathMLTable>(*this, std::move(style));
    102102
  • trunk/Source/WebCore/mathml/MathMLSelectElement.cpp

    r164856 r165544  
    7272void MathMLSelectElement::attributeChanged(const QualifiedName& name, const AtomicString& oldValue, const AtomicString& newValue, AttributeModificationReason reason)
    7373{
    74     if (hasLocalName(mactionTag) && (name == MathMLNames::actiontypeAttr || name == MathMLNames::selectionAttr))
     74    if (hasTagName(mactionTag) && (name == MathMLNames::actiontypeAttr || name == MathMLNames::selectionAttr))
    7575        updateSelectedChild();
    7676
     
    8080int MathMLSelectElement::getSelectedActionChildAndIndex(Element*& selectedChild)
    8181{
    82     ASSERT(hasLocalName(mactionTag));
     82    ASSERT(hasTagName(mactionTag));
    8383
    8484    // We "round up or down to the closest allowable value" of the selection attribute, as suggested by the MathML specification.
     
    101101Element* MathMLSelectElement::getSelectedActionChild()
    102102{
    103     ASSERT(hasLocalName(mactionTag));
     103    ASSERT(hasTagName(mactionTag));
    104104
    105105    Element* child = firstElementChild();
     
    125125Element* MathMLSelectElement::getSelectedSemanticsChild()
    126126{
    127     ASSERT(hasLocalName(semanticsTag));
     127    ASSERT(hasTagName(semanticsTag));
    128128
    129129    Element* child = firstElementChild();
     
    144144            continue;
    145145
    146         if (child->hasLocalName(MathMLNames::annotationTag)) {
     146        if (child->hasTagName(MathMLNames::annotationTag)) {
    147147            // If the <annotation> element has an src attribute then it is a reference to arbitrary binary data and it is not clear whether we can display it. Hence we just ignore the annotation.
    148148            if (child->hasAttribute(MathMLNames::srcAttr))
     
    152152        }
    153153
    154         if (child->hasLocalName(MathMLNames::annotation_xmlTag)) {
     154        if (child->hasTagName(MathMLNames::annotation_xmlTag)) {
    155155            // If the <annotation-xml> element has an src attribute then it is a reference to arbitrary binary data and it is not clear whether we can display it. Hence we just ignore the annotation.
    156156            if (child->hasAttribute(MathMLNames::srcAttr))
     
    176176void MathMLSelectElement::updateSelectedChild()
    177177{
    178     Element* newSelectedChild = hasLocalName(mactionTag) ? getSelectedActionChild() : getSelectedSemanticsChild();
     178    Element* newSelectedChild = hasTagName(mactionTag) ? getSelectedActionChild() : getSelectedSemanticsChild();
    179179
    180180    if (m_selectedChild == newSelectedChild)
  • trunk/Source/WebCore/mathml/MathMLTextElement.cpp

    r165436 r165544  
    6767RenderPtr<RenderElement> MathMLTextElement::createElementRenderer(PassRef<RenderStyle> style)
    6868{
    69     if (hasLocalName(MathMLNames::moTag))
     69    if (hasTagName(MathMLNames::moTag))
    7070        return createRenderer<RenderMathMLOperator>(*this, std::move(style));
    71     if (hasLocalName(MathMLNames::miTag))
     71    if (hasTagName(MathMLNames::miTag))
    7272        return createRenderer<RenderMathMLToken>(*this, std::move(style));
    73     if (hasLocalName(MathMLNames::mspaceTag))
     73    if (hasTagName(MathMLNames::mspaceTag))
    7474        return createRenderer<RenderMathMLSpace>(*this, std::move(style));
    7575
     
    7979bool MathMLTextElement::childShouldCreateRenderer(const Node& child) const
    8080{
    81     return !hasLocalName(mspaceTag) && child.isTextNode();
     81    return !hasTagName(mspaceTag) && child.isTextNode();
    8282}
    8383
  • trunk/Source/WebCore/platform/mac/HTMLConverter.mm

    r165156 r165544  
    4141#import "Frame.h"
    4242#import "FrameLoader.h"
     43#import "HTMLElement.h"
    4344#import "HTMLNames.h"
    4445#import "HTMLParserIdioms.h"
  • trunk/Source/WebCore/rendering/RenderBlockFlow.cpp

    r164697 r165544  
    2828#include "FloatingObjects.h"
    2929#include "Frame.h"
     30#include "HTMLElement.h"
    3031#include "HitTestLocation.h"
    3132#include "InlineTextBox.h"
     
    4546#if ENABLE(CSS_SHAPES) && ENABLE(CSS_SHAPE_INSIDE)
    4647#include "ShapeInsideInfo.h"
    47 #endif
    48 
    49 #if ENABLE(IOS_TEXT_AUTOSIZING)
    50 #include "HTMLElement.h"
    5148#endif
    5249
  • trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp

    r165484 r165544  
    756756                    if (body) {
    757757                        // Can't scroll a frameset document anyway.
    758                         isOpaqueRoot = body->hasLocalName(framesetTag);
     758                        isOpaqueRoot = body->hasTagName(framesetTag);
    759759                    } else {
    760760                        // SVG documents and XML documents with SVG root nodes are transparent.
  • trunk/Source/WebCore/rendering/RenderElement.cpp

    r165346 r165544  
    10851085        // render object very easily via the DOM.
    10861086        if (auto body = document().body()) {
    1087             if (body->hasLocalName(HTMLNames::bodyTag)) {
     1087            if (body->hasTagName(HTMLNames::bodyTag)) {
    10881088                if (auto renderer = body->renderer())
    10891089                    return *renderer;
  • trunk/Source/WebCore/rendering/RenderLayerBacking.cpp

    r165540 r165544  
    17461746        // Now look at the body's renderer.
    17471747        HTMLElement* body = renderer().document().body();
    1748         RenderObject* bodyObject = (body && body->hasLocalName(bodyTag)) ? body->renderer() : 0;
     1748        RenderObject* bodyObject = (body && body->hasTagName(bodyTag)) ? body->renderer() : 0;
    17491749        if (!bodyObject)
    17501750            return false;
  • trunk/Source/WebCore/rendering/RenderReplaced.cpp

    r165065 r165544  
    2828#include "Frame.h"
    2929#include "GraphicsContext.h"
     30#include "HTMLElement.h"
    3031#include "InlineElementBox.h"
    3132#include "LayoutRepainter.h"
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLScripts.cpp

    r158198 r165544  
    3131#include "RenderMathMLScripts.h"
    3232
    33 #include "MathMLNames.h"
     33#include "MathMLElement.h"
    3434
    3535namespace WebCore {
     
    6262{
    6363    // Determine what kind of sub/sup expression we have by element name
    64     if (element.hasLocalName(MathMLNames::msubTag))
     64    if (element.hasTagName(MathMLNames::msubTag))
    6565        m_kind = Sub;
    66     else if (element.hasLocalName(MathMLNames::msupTag))
     66    else if (element.hasTagName(MathMLNames::msupTag))
    6767        m_kind = Super;
    68     else if (element.hasLocalName(MathMLNames::msubsupTag))
     68    else if (element.hasTagName(MathMLNames::msubsupTag))
    6969        m_kind = SubSup;
    7070    else {
    71         ASSERT(element.hasLocalName(MathMLNames::mmultiscriptsTag));
     71        ASSERT(element.hasTagName(MathMLNames::mmultiscriptsTag));
    7272        m_kind = Multiscripts;
    7373    }
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.cpp

    r158097 r165544  
    3030#include "RenderMathMLUnderOver.h"
    3131
    32 #include "MathMLNames.h"
     32#include "MathMLElement.h"
    3333
    3434namespace WebCore {
     
    4040{
    4141    // Determine what kind of under/over expression we have by element name
    42     if (element.hasLocalName(MathMLNames::munderTag))
     42    if (element.hasTagName(MathMLNames::munderTag))
    4343        m_kind = Under;
    44     else if (element.hasLocalName(MathMLNames::moverTag))
     44    else if (element.hasTagName(MathMLNames::moverTag))
    4545        m_kind = Over;
    4646    else {
    47         ASSERT(element.hasLocalName(MathMLNames::munderoverTag));
     47        ASSERT(element.hasTagName(MathMLNames::munderoverTag));
    4848        m_kind = UnderOver;
    4949    }
  • trunk/Source/WebCore/svg/SVGElement.h

    r165542 r165544  
    141141#endif
    142142
     143    bool hasTagName(const SVGQualifiedName& name) const { return hasLocalName(name.localName()); }
     144
    143145protected:
    144146    SVGElement(const QualifiedName&, Document&);
     
    214216NODE_TYPE_CASTS(SVGElement)
    215217
     218inline bool Node::hasTagName(const SVGQualifiedName& name) const
     219{
     220    return isSVGElement() && toSVGElement(*this).hasTagName(name);
    216221}
    217222
    218 #endif
     223}
     224
     225#endif
  • trunk/Source/WebCore/svg/SVGFontFaceSrcElement.cpp

    r160598 r165544  
    6464{
    6565    SVGElement::childrenChanged(change);
    66     if (parentNode() && parentNode()->hasTagName(font_faceTag))
     66    if (parentNode() && isSVGFontFaceElement(parentNode()))
    6767        toSVGFontFaceElement(parentNode())->rebuildFontFace();
    6868}
  • trunk/Source/WebCore/svg/SVGUseElement.cpp

    r163440 r165544  
    523523}
    524524
    525 static bool isDirectReference(const Node* node)
    526 {
    527     return node->hasTagName(SVGNames::pathTag)
    528            || node->hasTagName(SVGNames::rectTag)
    529            || node->hasTagName(SVGNames::circleTag)
    530            || node->hasTagName(SVGNames::ellipseTag)
    531            || node->hasTagName(SVGNames::polygonTag)
    532            || node->hasTagName(SVGNames::polylineTag)
    533            || node->hasTagName(SVGNames::textTag);
     525static bool isDirectReference(const SVGElement& element)
     526{
     527    return element.hasTagName(SVGNames::pathTag)
     528        || element.hasTagName(SVGNames::rectTag)
     529        || element.hasTagName(SVGNames::circleTag)
     530        || element.hasTagName(SVGNames::ellipseTag)
     531        || element.hasTagName(SVGNames::polygonTag)
     532        || element.hasTagName(SVGNames::polylineTag)
     533        || element.hasTagName(SVGNames::textTag);
    534534}
    535535
     
    542542        return;
    543543
    544     if (n->isSVGElement() && toSVGElement(n)->isSVGGraphicsElement()) {
    545         if (!isDirectReference(n))
     544    if (n->isSVGElement() && toSVGElement(*n).isSVGGraphicsElement()) {
     545        if (!isDirectReference(toSVGElement(*n))) {
    546546            // Spec: Indirect references are an error (14.3.5)
    547547            document().accessSVGExtensions()->reportError("Not allowed to use indirect reference in <clip-path>");
    548         else {
    549             toSVGGraphicsElement(n)->toClipPath(path);
     548        } else {
     549            toSVGGraphicsElement(*n).toClipPath(path);
    550550            // FIXME: Avoid manual resolution of x/y here. Its potentially harmful.
    551551            SVGLengthContext lengthContext(this);
     
    558558RenderElement* SVGUseElement::rendererClipChild() const
    559559{
    560     Node* n = m_targetElementInstance ? m_targetElementInstance->shadowTreeElement() : 0;
    561     if (!n)
    562         return 0;
    563 
    564     if (n->isSVGElement() && isDirectReference(n))
    565         return toSVGElement(n)->renderer();
    566 
    567     return 0;
     560    if (!m_targetElementInstance)
     561        return nullptr;
     562
     563    auto* element = m_targetElementInstance->shadowTreeElement();
     564    if (!element)
     565        return nullptr;
     566
     567    if (!isDirectReference(*element))
     568        return nullptr;
     569
     570    return element->renderer();
    568571}
    569572
  • trunk/Source/WebCore/xml/parser/XMLDocumentParser.cpp

    r163440 r165544  
    276276    // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-xhtml-syntax.html#xml-fragment-parsing-algorithm
    277277    // For now we have a hack for script/style innerHTML support:
    278     if (contextElement && (contextElement->hasLocalName(HTMLNames::scriptTag) || contextElement->hasLocalName(HTMLNames::styleTag))) {
     278    if (contextElement && (contextElement->hasLocalName(HTMLNames::scriptTag.localName()) || contextElement->hasLocalName(HTMLNames::styleTag.localName()))) {
    279279        fragment.parserAppendChild(fragment.document().createTextNode(chunk));
    280280        return true;
     
    283283    RefPtr<XMLDocumentParser> parser = XMLDocumentParser::create(fragment, contextElement, parserContentPolicy);
    284284    bool wellFormed = parser->appendFragmentSource(chunk);
    285     // Do not call finish().  Current finish() and doEnd() implementations touch the main Document/loader
    286     // and can cause crashes in the fragment case.
     285    // Do not call finish(). The finish() and doEnd() implementations touch the main document and loader and can cause crashes in the fragment case.
    287286    parser->detach(); // Allows ~DocumentParser to assert it was detached before destruction.
    288     return wellFormed; // appendFragmentSource()'s wellFormed is more permissive than wellFormed().
     287    return wellFormed; // appendFragmentSource()'s wellFormed is more permissive than Document::wellFormed().
    289288}
    290289
Note: See TracChangeset for help on using the changeset viewer.