Changeset 165544 in webkit
- Timestamp:
- Mar 13, 2014 10:45:38 AM (10 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 50 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r165543 r165544 1 2014-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 1 239 2014-03-13 Antti Koivisto <antti@apple.com> 2 240 -
trunk/Source/WebCore/accessibility/AccessibilityObject.cpp
r165430 r165544 1550 1550 bool AccessibilityObject::hasTagName(const QualifiedName& tagName) const 1551 1551 { 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); 1555 1554 } 1556 1555 -
trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp
r165535 r165544 2416 2416 bool AccessibilityRenderObject::isDescendantOfElementType(const QualifiedName& tagName) const 2417 2417 { 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)) 2420 2420 return true; 2421 2421 } -
trunk/Source/WebCore/dom/DocumentStyleSheetCollection.cpp
r164420 r165544 263 263 return; 264 264 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) { 271 268 // Processing instruction (XML documents only). 272 269 // 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); 274 271 sheet = pi->sheet(); 275 272 #if ENABLE(XSLT) … … 282 279 } 283 280 #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); 288 284 bool enabledViaScript = false; 289 if ( e->hasTagName(linkTag)) {285 if (isHTMLLinkElement(element)) { 290 286 // <LINK> element 291 HTMLLinkElement * linkElement = toHTMLLinkElement(n);292 if (linkElement ->isDisabled())287 HTMLLinkElement& linkElement = toHTMLLinkElement(element); 288 if (linkElement.isDisabled()) 293 289 continue; 294 enabledViaScript = linkElement ->isEnabledViaScript();295 if (linkElement ->styleSheetIsLoading()) {290 enabledViaScript = linkElement.isEnabledViaScript(); 291 if (linkElement.styleSheetIsLoading()) { 296 292 // it is loading but we should still decide which style sheet set to use 297 293 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")) { 300 295 m_preferredStylesheetSetName = title; 301 296 m_selectedStylesheetSetName = title; … … 304 299 continue; 305 300 } 306 if (!linkElement ->sheet())301 if (!linkElement.sheet()) 307 302 title = nullAtom; 308 303 } 309 304 // Get the current preferred styleset. This is the 310 305 // 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(); 321 312 // Check to see if this sheet belongs to a styleset 322 313 // (thus making it PREFERRED or ALTERNATE rather than 323 314 // PERSISTENT). 324 AtomicString rel = e->getAttribute(relAttr);315 auto& rel = element.fastGetAttribute(relAttr); 325 316 if (!enabledViaScript && !title.isEmpty()) { 326 317 // Yes, we have a title. … … 330 321 // us as the preferred set. Otherwise, just ignore 331 322 // this sheet. 332 if ( e->hasTagName(styleTag) || !rel.contains("alternate"))323 if (isHTMLStyleElement(element) || !rel.contains("alternate")) 333 324 m_preferredStylesheetSetName = m_selectedStylesheetSetName = title; 334 325 } 335 326 if (title != m_preferredStylesheetSetName) 336 sheet = 0;327 sheet = nullptr; 337 328 } 338 329 339 330 if (rel.contains("alternate") && title.isEmpty()) 340 sheet = 0;331 sheet = nullptr; 341 332 } 342 333 if (sheet) -
trunk/Source/WebCore/dom/Element.cpp
r165542 r165544 45 45 #include "FrameSelection.h" 46 46 #include "FrameView.h" 47 #include "HTMLCanvasElement.h" 47 48 #include "HTMLCollection.h" 48 49 #include "HTMLDocument.h" 49 #include "HTMLElement.h"50 50 #include "HTMLFormControlsCollection.h" 51 51 #include "HTMLLabelElement.h" … … 94 94 } 95 95 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, ()); 96 static HashMap<Element*, Vector<RefPtr<Attr>>>& attrNodeListMap() 97 { 98 static NeverDestroyed<HashMap<Element*, Vector<RefPtr<Attr>>>> map; 102 99 return map; 103 100 } 104 101 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; 102 static 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 110 static 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 121 static void removeAttrNodeListForElement(Element& element) 122 { 123 ASSERT(element.hasSyntheticAttrChildNodes()); 124 ASSERT(attrNodeListMap().contains(&element)); 125 attrNodeListMap().remove(&element); 126 element.setHasSyntheticAttrChildNodes(false); 127 } 128 129 static 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; 140 136 } 141 137 … … 435 431 // focusable as long as their canvas is displayed and visible. 436 432 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; 442 436 } 443 437 … … 1639 1633 { 1640 1634 ASSERT(hasSyntheticAttrChildNodes()); 1641 return *attrNodeListForElement( this);1635 return *attrNodeListForElement(*this); 1642 1636 } 1643 1637 … … 1675 1669 attrNode->attachToElement(this); 1676 1670 treeScope().adoptIfNeeded(attrNode); 1677 ensureAttrNodeListForElement( this).append(attrNode);1671 ensureAttrNodeListForElement(*this).append(attrNode); 1678 1672 1679 1673 return oldAttrNode.release(); … … 2770 2764 PassRefPtr<Attr> Element::attrIfExists(const QualifiedName& name) 2771 2765 { 2772 if ( AttrNodeList* attrNodeList = attrNodeListForElement(this))2766 if (auto* attrNodeList = attrNodeListForElement(*this)) 2773 2767 return findAttrNodeInList(*attrNodeList, name); 2774 return 0;2768 return nullptr; 2775 2769 } 2776 2770 2777 2771 PassRefPtr<Attr> Element::ensureAttr(const QualifiedName& name) 2778 2772 { 2779 AttrNodeList& attrNodeList = ensureAttrNodeListForElement(this);2773 auto& attrNodeList = ensureAttrNodeListForElement(*this); 2780 2774 RefPtr<Attr> attrNode = findAttrNodeInList(attrNodeList, name); 2781 2775 if (!attrNode) { … … 2792 2786 attrNode->detachFromElementWithValue(value); 2793 2787 2794 AttrNodeList* attrNodeList = attrNodeListForElement(this);2788 auto* attrNodeList = attrNodeListForElement(*this); 2795 2789 for (unsigned i = 0; i < attrNodeList->size(); ++i) { 2796 2790 if (attrNodeList->at(i)->qualifiedName() == attrNode->qualifiedName()) { 2797 2791 attrNodeList->remove(i); 2798 2792 if (attrNodeList->isEmpty()) 2799 removeAttrNodeListForElement( this);2793 removeAttrNodeListForElement(*this); 2800 2794 return; 2801 2795 } … … 2806 2800 void Element::detachAllAttrNodesFromElement() 2807 2801 { 2808 AttrNodeList* attrNodeList = attrNodeListForElement(this);2802 auto* attrNodeList = attrNodeListForElement(*this); 2809 2803 ASSERT(attrNodeList); 2810 2804 … … 2814 2808 } 2815 2809 2816 removeAttrNodeListForElement( this);2810 removeAttrNodeListForElement(*this); 2817 2811 } 2818 2812 -
trunk/Source/WebCore/dom/Element.h
r165542 r165544 261 261 String tagName() const { return nodeName(); } 262 262 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 264 267 // A fast function for checking the local name against another atomic string. 265 268 bool hasLocalName(const AtomicString& other) const { return m_tagName.localName() == other; } 266 bool hasLocalName(const QualifiedName& other) const { return m_tagName.localName() == other.localName(); }267 269 268 270 virtual const AtomicString& localName() const override final { return m_tagName.localName(); } … … 687 689 template <> inline bool isElementOfType<const Element>(const Element&) { return true; } 688 690 689 inline bool Node::hasTagName(const QualifiedName& name) const690 {691 return isElementNode() && toElement(this)->hasTagName(name);692 }693 694 inline bool Node::hasLocalName(const AtomicString& name) const695 {696 return isElementNode() && toElement(this)->hasLocalName(name);697 }698 699 691 inline bool Node::hasAttributes() const 700 692 { -
trunk/Source/WebCore/dom/Node.h
r165479 r165544 61 61 class Frame; 62 62 class HTMLInputElement; 63 class HTMLQualifiedName; 63 64 class IntRect; 64 65 class KeyboardEvent; 66 class MathMLQualifiedName; 65 67 class NSResolver; 66 68 class NamedNodeMap; … … 76 78 class RenderObject; 77 79 class RenderStyle; 80 class SVGQualifiedName; 78 81 class ShadowRoot; 79 82 class TagNodeList; … … 158 161 // DOM methods & attributes for Node 159 162 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; 162 166 virtual String nodeName() const = 0; 163 167 virtual String nodeValue() const; … … 260 264 void setHasSyntheticAttrChildNodes(bool flag) { setFlag(flag, HasSyntheticAttrChildNodesFlag); } 261 265 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. 263 267 Element* shadowHost() const; 264 268 // If this node is in a shadow tree, returns its shadow host. Otherwise, returns this. … … 268 272 ShadowRoot* shadowRoot() const; 269 273 270 // Returns 0, a child of ShadowRoot, or a legacy shadow root.274 // Returns null, a child of ShadowRoot, or a legacy shadow root. 271 275 Node* nonBoundaryShadowTreeRootNode(); 272 276 … … 277 281 Node* highestAncestor() const; 278 282 279 // Use when it's guaranteed to that shadowHost is 0.283 // Use when it's guaranteed to that shadowHost is null. 280 284 ContainerNode* parentNodeGuaranteedHostFree() const; 281 // Returns the parent node, but 0if the parent node is a ShadowRoot.285 // Returns the parent node, but null if the parent node is a ShadowRoot. 282 286 ContainerNode* nonShadowBoundaryParentNode() const; 283 287 … … 378 382 unsigned nodeIndex() const; 379 383 380 // Returns the DOM ownerDocument attribute. This method never returns 0, except in the case384 // Returns the DOM ownerDocument attribute. This method never returns null, except in the case 381 385 // of a Document node. 382 386 Document* ownerDocument() const; 383 387 384 // Returns the document associated with this node. This method never returns 0.388 // Returns the document associated with this node. 385 389 // A Document node returns itself. 386 390 Document& document() const … … 492 496 void showTreeForThis() const; 493 497 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; 495 499 void showTreeForThisAcrossFrame() const; 496 500 #endif 497 501 498 void invalidateNodeListAndCollectionCachesInAncestors(const QualifiedName* attrName = 0, Element* attributeOwnerElement = 0);502 void invalidateNodeListAndCollectionCachesInAncestors(const QualifiedName* attrName = nullptr, Element* attributeOwnerElement = nullptr); 499 503 NodeListsNodeData* nodeLists(); 500 504 void clearNodeLists(); … … 671 675 virtual void derefEventTarget() override; 672 676 673 virtual RenderStyle* nonRendererStyle() const { return 0; }677 virtual RenderStyle* nonRendererStyle() const { return nullptr; } 674 678 675 679 Element* ancestorElement() const; -
trunk/Source/WebCore/dom/PositionIterator.cpp
r163712 r165544 27 27 #include "PositionIterator.h" 28 28 29 #include "HTMLElement.h" 29 30 #include "HTMLNames.h" 30 31 #include "RenderBlock.h" -
trunk/Source/WebCore/dom/StyledElement.cpp
r164856 r165544 31 31 #include "ContentSecurityPolicy.h" 32 32 #include "DOMTokenList.h" 33 #include "HTMLElement.h" 33 34 #include "HTMLParserIdioms.h" 34 35 #include "InspectorInstrumentation.h" -
trunk/Source/WebCore/dom/Text.cpp
r163440 r165544 26 26 #include "RenderSVGInlineText.h" 27 27 #include "RenderText.h" 28 #include "SVGElement.h" 29 #include "SVGNames.h" 28 30 #include "ScopedEventQueue.h" 29 31 #include "ShadowRoot.h" 30 #include "SVGNames.h"31 #include "TextNodeTraversal.h"32 33 32 #include "StyleInheritedData.h" 34 33 #include "StyleResolver.h" 34 #include "TextNodeTraversal.h" 35 35 #include <wtf/CheckedArithmetic.h> 36 36 #include <wtf/text/CString.h> -
trunk/Source/WebCore/dom/make_names.pl
r163534 r165544 1 1 #!/usr/bin/perl -w 2 2 3 # Copyright (C) 2005 , 2006, 2007, 2009, 2013Apple Inc. All rights reserved.3 # Copyright (C) 2005-2007, 2009, 2013-2014 Apple Inc. All rights reserved. 4 4 # Copyright (C) 2009, Julien Chaffraix <jchaffraix@webkit.org> 5 5 # Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/) … … 104 104 105 105 printLicenseHeader($F); 106 printHeaderHead($F, "CSS", $familyNamesFileBase, "#include <wtf/text/AtomicString.h>" );106 printHeaderHead($F, "CSS", $familyNamesFileBase, "#include <wtf/text/AtomicString.h>", ""); 107 107 108 108 printMacros($F, "extern const WTF::AtomicString", "", \%parameters); … … 526 526 sub printHeaderHead 527 527 { 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 537 namespace WebCore { 538 539 ${definitions}namespace ${namespace}Names { 540 541 #ifndef ${prefix}_${namespace}_NAMES_HIDE_GLOBALS 542 543 END 544 ; 538 545 } 539 546 540 547 sub printCppHead 541 548 { 542 my ($F, $prefix, $n sName, $usedNamespace) = @_;549 my ($F, $prefix, $namespace, $usedNamespace) = @_; 543 550 544 551 print F "#include \"config.h\"\n\n"; 545 552 print F "#ifdef SKIP_STATIC_CONSTRUCTORS_ON_GCC\n"; 546 print F "#define ${prefix}_${n sName}NAMES_HIDE_GLOBALS 1\n";553 print F "#define ${prefix}_${namespace}_NAMES_HIDE_GLOBALS 1\n"; 547 554 print F "#else\n"; 548 555 print F "#define QNAME_DEFAULT_CONSTRUCTOR 1\n"; 549 556 print F "#endif\n\n"; 550 557 551 print F "#include \"${n sName}Names.h\"\n\n";558 print F "#include \"${namespace}Names.h\"\n\n"; 552 559 print F "#include <wtf/StaticConstructors.h>\n"; 553 560 554 561 print F "namespace WebCore {\n\n"; 555 print F "namespace ${n sName}Names {\n\n";562 print F "namespace ${namespace}Names {\n\n"; 556 563 print F "using namespace $usedNamespace;\n\n"; 557 564 } … … 640 647 # We need to check for HTMLUnknownElement if it might have been created by the factory. 641 648 print F <<END 642 inline bool $checkHelper(const HTMLElement& element) { return !element.isHTMLUnknownElement() && element.has LocalName($parameters{namespace}Names::${name}Tag); }649 inline bool $checkHelper(const HTMLElement& element) { return !element.isHTMLUnknownElement() && element.hasTagName($parameters{namespace}Names::${name}Tag); } 643 650 inline bool $checkHelper(const HTMLElement* element) { ASSERT(element); return $checkHelper(*element); } 644 651 END … … 646 653 } else { 647 654 print F <<END 648 inline bool $checkHelper(const HTMLElement& element) { return element.has LocalName(HTMLNames::${name}Tag); }655 inline bool $checkHelper(const HTMLElement& element) { return element.hasTagName(HTMLNames::${name}Tag); } 649 656 inline bool $checkHelper(const HTMLElement* element) { ASSERT(element); return $checkHelper(*element); } 650 657 END … … 702 709 703 710 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 707 715 print F "// Namespace\n"; 708 print F "extern const WTF::AtomicString ${lower Namespace}NamespaceURI;\n\n";716 print F "extern const WTF::AtomicString ${lowercaseNamespacePrefix}NamespaceURI;\n\n"; 709 717 710 718 if (keys %allTags) { 711 719 print F "// Tags\n"; 712 printMacros($F, "extern const WebCore:: QualifiedName", "Tag", \%allTags);720 printMacros($F, "extern const WebCore::$parameters{namespace}QualifiedName", "Tag", \%allTags); 713 721 } 714 722 … … 721 729 if (keys %allTags) { 722 730 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"; 724 732 } 725 733 726 734 if (keys %allAttrs) { 727 735 print F "const unsigned $parameters{namespace}AttrsCount = ", scalar(keys %allAttrs), ";\n"; 728 print F "const WebCore::QualifiedName* const 736 print F "const WebCore::QualifiedName* const* get$parameters{namespace}Attrs();\n"; 729 737 } 730 738 … … 742 750 printCppHead($F, "DOM", $parameters{namespace}, "WebCore"); 743 751 744 my $lower Namespace= lc($parameters{namespacePrefix});745 746 print F "DEFINE_GLOBAL(AtomicString, ${lower Namespace}NamespaceURI)\n\n";752 my $lowercaseNamespacePrefix = lc($parameters{namespacePrefix}); 753 754 print F "DEFINE_GLOBAL(AtomicString, ${lowercaseNamespacePrefix}NamespaceURI)\n\n"; 747 755 748 756 print F StaticString::GenerateStrings(\%allStrings); … … 754 762 } 755 763 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"; 758 766 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"; 760 768 } 761 769 print F " };\n"; … … 769 777 print F "DEFINE_GLOBAL(QualifiedName, ", $name, "Attr)\n"; 770 778 } 771 print F "\n\nconst WebCore::QualifiedName* const 779 print F "\n\nconst WebCore::QualifiedName* const* get$parameters{namespace}Attrs()\n"; 772 780 print F "{\n static const WebCore::QualifiedName* const $parameters{namespace}Attrs[] = {\n"; 773 781 for my $name (sort keys %allAttrs) { … … 781 789 printInit($F, 0); 782 790 783 print(F " AtomicString ${lower Namespace}NS(\"$parameters{namespaceURI}\", AtomicString::ConstructFromLiteral);\n\n");791 print(F " AtomicString ${lowercaseNamespacePrefix}NS(\"$parameters{namespaceURI}\", AtomicString::ConstructFromLiteral);\n\n"); 784 792 785 793 print(F " // Namespace\n"); 786 print(F " new (NotNull, (void*)&${lower Namespace}NamespaceURI) AtomicString(${lowerNamespace}NS);\n");794 print(F " new (NotNull, (void*)&${lowercaseNamespacePrefix}NamespaceURI) AtomicString(${lowercaseNamespacePrefix}NS);\n"); 787 795 print(F "\n"); 788 796 print F StaticString::GenerateStringAsserts(\%allStrings); 789 797 790 798 if (keys %allTags) { 791 my $tagsNamespace = $parameters{tagsNullNamespace} ? "nullAtom" : "${lower Namespace}NS";799 my $tagsNamespace = $parameters{tagsNullNamespace} ? "nullAtom" : "${lowercaseNamespacePrefix}NS"; 792 800 printDefinitions($F, \%allTags, "tags", $tagsNamespace); 793 801 } 794 802 if (keys %allAttrs) { 795 my $attrsNamespace = $parameters{attrsNullNamespace} ? "nullAtom" : "${lower Namespace}NS";803 my $attrsNamespace = $parameters{attrsNullNamespace} ? "nullAtom" : "${lowercaseNamespacePrefix}NS"; 796 804 printDefinitions($F, \%allAttrs, "attributes", $attrsNamespace); 797 805 } -
trunk/Source/WebCore/editing/ApplyStyleCommand.cpp
r164964 r165544 66 66 } 67 67 68 bool isLegacyAppleStyleSpan(const Node *node)68 bool isLegacyAppleStyleSpan(const Node* node) 69 69 { 70 70 if (!node || !node->isHTMLElement()) 71 71 return false; 72 72 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(); 75 75 } 76 76 … … 131 131 , m_end(endingSelection().end().upstream()) 132 132 , m_useEndingSelection(true) 133 , m_styledInlineElement(0)134 133 , m_removeOnly(false) 135 134 , m_isInlineElementToRemoveFunction(0) … … 145 144 , m_end(end) 146 145 , m_useEndingSelection(false) 147 , m_styledInlineElement(0)148 146 , m_removeOnly(false) 149 147 , m_isInlineElementToRemoveFunction(0) … … 173 171 , m_end(endingSelection().end().upstream()) 174 172 , m_useEndingSelection(true) 175 , m_styledInlineElement(0)176 173 , m_removeOnly(true) 177 174 , m_isInlineElementToRemoveFunction(isInlineElementToRemoveFunction) … … 851 848 if (!style->styleIsPresentInComputedStyleOfNode(node)) 852 849 return true; 853 if (m_styledInlineElement && !enclosing NodeWithTag(positionBeforeNode(node), m_styledInlineElement->tagQName()))850 if (m_styledInlineElement && !enclosingElementWithTag(positionBeforeNode(node), m_styledInlineElement->tagQName())) 854 851 return true; 855 852 } -
trunk/Source/WebCore/editing/Editor.cpp
r165385 r165544 798 798 { 799 799 if (m_frame.selection().isCaret()) { 800 if (enclosing NodeWithTag(m_frame.selection().selection().start(), ulTag))800 if (enclosingElementWithTag(m_frame.selection().selection().start(), ulTag)) 801 801 return TrueTriState; 802 802 } 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); 805 805 if (startNode && endNode && startNode == endNode) 806 806 return TrueTriState; … … 813 813 { 814 814 if (m_frame.selection().isCaret()) { 815 if (enclosing NodeWithTag(m_frame.selection().selection().start(), olTag))815 if (enclosingElementWithTag(m_frame.selection().selection().start(), olTag)) 816 816 return TrueTriState; 817 817 } 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); 820 820 if (startNode && endNode && startNode == endNode) 821 821 return TrueTriState; -
trunk/Source/WebCore/editing/InsertListCommand.cpp
r163712 r165544 131 131 setEndingSelection(VisibleSelection(visibleStart, visibleEnd.previous(CannotCrossEditingBoundary), endingSelection().isDirectional())); 132 132 133 const QualifiedName& listTag = (m_type == OrderedList) ? olTag : ulTag;133 auto& listTag = (m_type == OrderedList) ? olTag : ulTag; 134 134 if (endingSelection().isRange()) { 135 135 VisibleSelection selection = selectionForParagraphIteration(endingSelection()); … … 193 193 } 194 194 195 void InsertListCommand::doApplyForSingleParagraph(bool forceCreateList, const QualifiedName& listTag, Range* currentSelection)195 void InsertListCommand::doApplyForSingleParagraph(bool forceCreateList, const HTMLQualifiedName& listTag, Range* currentSelection) 196 196 { 197 197 // FIXME: This will produce unexpected results for a selection that starts just before a … … 208 208 listNode = mergeWithNeighboringLists(listNode); 209 209 } 210 if (!listNode->hasTagName(listTag)) 210 if (!listNode->hasTagName(listTag)) { 211 211 // listChildNode will be removed from the list and a list of type m_type will be created. 212 212 switchListType = true; 213 } 213 214 214 215 // 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 32 32 33 33 class HTMLElement; 34 class HTMLQualifiedName; 34 35 35 36 class InsertListCommand : public CompositeEditCommand { … … 55 56 bool selectionHasListOfType(const VisibleSelection& selection, const QualifiedName&); 56 57 PassRefPtr<HTMLElement> mergeWithNeighboringLists(PassRefPtr<HTMLElement>); 57 void doApplyForSingleParagraph(bool forceCreateList, const QualifiedName&, Range* currentSelection);58 void doApplyForSingleParagraph(bool forceCreateList, const HTMLQualifiedName&, Range* currentSelection); 58 59 void unlistifyParagraph(const VisiblePosition& originalStart, HTMLElement* listNode, Node* listChildNode); 59 60 PassRefPtr<HTMLElement> listifyParagraph(const VisiblePosition& originalStart, const QualifiedName& listTag); -
trunk/Source/WebCore/editing/MarkupAccumulator.cpp
r163854 r165544 141 141 142 142 if (tagNamesToSkip && targetNode.isElementNode()) { 143 for ( size_t i = 0; i < tagNamesToSkip->size(); ++i) {144 if (t argetNode.hasTagName(tagNamesToSkip->at(i)))143 for (auto& name : *tagNamesToSkip) { 144 if (toElement(targetNode).hasTagName(name)) 145 145 return; 146 146 } -
trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp
r161638 r165544 629 629 630 630 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)) 632 632 moveNodeOutOfAncestor(node, paragraphElement); 633 633 } 634 634 635 635 if (isHeaderElement(node.get())) { 636 if ( HTMLElement* headerElement = toHTMLElement(highestEnclosingNodeOfType(positionInParentBeforeNode(node.get()), isHeaderElement)))636 if (auto* headerElement = highestEnclosingNodeOfType(positionInParentBeforeNode(node.get()), isHeaderElement)) 637 637 moveNodeOutOfAncestor(node, headerElement); 638 638 } … … 673 673 Node* lastLeafInserted = insertedNodes.lastLeafInserted(); 674 674 if (lastLeafInserted && lastLeafInserted->isTextNode() && !hasRenderedText(toText(*lastLeafInserted)) 675 && !enclosing NodeWithTag(firstPositionInOrBeforeNode(lastLeafInserted), selectTag)676 && !enclosing NodeWithTag(firstPositionInOrBeforeNode(lastLeafInserted), scriptTag)) {675 && !enclosingElementWithTag(firstPositionInOrBeforeNode(lastLeafInserted), selectTag) 676 && !enclosingElementWithTag(firstPositionInOrBeforeNode(lastLeafInserted), scriptTag)) { 677 677 insertedNodes.willRemoveNode(lastLeafInserted); 678 678 removeNode(lastLeafInserted); … … 691 691 { 692 692 // 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); 694 694 return enclosingSelect ? lastPositionInOrAfterNode(enclosingSelect) : m_endOfInsertedContent; 695 695 } -
trunk/Source/WebCore/editing/TextIterator.cpp
r165385 r165544 808 808 static bool hasHeaderTag(HTMLElement& element) 809 809 { 810 return element.has LocalName(h1Tag)811 || element.has LocalName(h2Tag)812 || element.has LocalName(h3Tag)813 || element.has LocalName(h4Tag)814 || element.has LocalName(h5Tag)815 || element.has LocalName(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); 816 816 } 817 817 … … 826 826 auto& element = toHTMLElement(node); 827 827 return hasHeaderTag(element) 828 || element.has LocalName(blockquoteTag)829 || element.has LocalName(ddTag)830 || element.has LocalName(divTag)831 || element.has LocalName(dlTag)832 || element.has LocalName(dtTag)833 || element.has LocalName(hrTag)834 || element.has LocalName(liTag)835 || element.has LocalName(listingTag)836 || element.has LocalName(olTag)837 || element.has LocalName(pTag)838 || element.has LocalName(preTag)839 || element.has LocalName(trTag)840 || element.has LocalName(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); 841 841 } 842 842 … … 895 895 if (!node.isHTMLElement()) 896 896 return false; 897 if (!(hasHeaderTag(toHTMLElement(node)) || toHTMLElement(node).has LocalName(pTag)))897 if (!(hasHeaderTag(toHTMLElement(node)) || toHTMLElement(node).hasTagName(pTag))) 898 898 return false; 899 899 -
trunk/Source/WebCore/editing/TypingCommand.cpp
r164964 r165544 33 33 #include "Element.h" 34 34 #include "Frame.h" 35 #include "HTMLElement.h" 35 36 #include "HTMLNames.h" 36 37 #include "InsertLineBreakCommand.h" 37 38 #include "InsertParagraphSeparatorCommand.h" 38 39 #include "InsertTextCommand.h" 40 #include "MathMLElement.h" 39 41 #include "RenderElement.h" 40 42 #include "TextIterator.h" -
trunk/Source/WebCore/editing/VisibleUnits.cpp
r165537 r165544 28 28 29 29 #include "Document.h" 30 #include " Element.h"30 #include "HTMLElement.h" 31 31 #include "HTMLNames.h" 32 32 #include "InlineTextBox.h" -
trunk/Source/WebCore/editing/htmlediting.cpp
r165385 r165544 543 543 } 544 544 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())545 Element* 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()) 553 553 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; 561 563 } 562 564 -
trunk/Source/WebCore/editing/htmlediting.h
r164964 r165544 66 66 Node* enclosingEmptyListItem(const VisiblePosition&); 67 67 Element* enclosingAnchorElement(const Position&); 68 Node* enclosingNodeWithTag(const Position&, const QualifiedName&);68 Element* enclosingElementWithTag(const Position&, const QualifiedName&); 69 69 Node* enclosingNodeOfType(const Position&, bool (*nodeIsOfType)(const Node*), EditingBoundaryCrossingRule = CannotCrossEditingBoundary); 70 70 -
trunk/Source/WebCore/editing/mac/EditorMac.mm
r165479 r165544 299 299 Node* commonAncestor = range->commonAncestorContainer(IGNORE_EXCEPTION); 300 300 ASSERT(commonAncestor); 301 Node* enclosingAnchor = enclosingNodeWithTag(firstPositionInNode(commonAncestor), HTMLNames::aTag);301 auto* enclosingAnchor = enclosingElementWithTag(firstPositionInNode(commonAncestor), HTMLNames::aTag); 302 302 if (enclosingAnchor && comparePositions(firstPositionInOrBeforeNode(range->startPosition().anchorNode()), range->startPosition()) >= 0) 303 303 range->setStart(enclosingAnchor, 0, IGNORE_EXCEPTION); -
trunk/Source/WebCore/editing/markup.cpp
r164964 r165544 250 250 MarkupAccumulator::appendText(out, text); 251 251 else { 252 const bool useRenderedText = !enclosing NodeWithTag(firstPositionInNode(const_cast<Text*>(&text)), selectTag);252 const bool useRenderedText = !enclosingElementWithTag(firstPositionInNode(const_cast<Text*>(&text)), selectTag); 253 253 String content = useRenderedText ? renderedText(text, m_range) : stringValueForRange(text, m_range); 254 254 StringBuilder buffer; … … 388 388 continue; 389 389 390 if (!n->renderer() && !enclosing NodeWithTag(firstPositionInOrBeforeNode(n), selectTag)) {390 if (!n->renderer() && !enclosingElementWithTag(firstPositionInOrBeforeNode(n), selectTag)) { 391 391 next = NodeTraversal::nextSkippingChildren(n); 392 392 // Don't skip over pastEnd. … … 548 548 specialCommonAncestor = commonAncestor; 549 549 550 if ( Node *enclosingAnchor = enclosingNodeWithTag(firstPositionInNode(specialCommonAncestor ? specialCommonAncestor : commonAncestor), aTag))550 if (auto* enclosingAnchor = enclosingElementWithTag(firstPositionInNode(specialCommonAncestor ? specialCommonAncestor : commonAncestor), aTag)) 551 551 specialCommonAncestor = enclosingAnchor; 552 552 … … 570 570 document.updateLayoutIgnorePendingStylesheets(); 571 571 572 Node* body = enclosingNodeWithTag(firstPositionInNode(commonAncestor), bodyTag);572 auto* body = enclosingElementWithTag(firstPositionInNode(commonAncestor), bodyTag); 573 573 Node* fullySelectedRoot = 0; 574 574 // FIXME: Do this for all fully selected blocks, not just the body. … … 949 949 } 950 950 951 if (element->has LocalName(colTag) || element->hasLocalName(colgroupTag) || element->hasLocalName(framesetTag)952 || element->has LocalName(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)) { 953 953 ec = NOT_SUPPORTED_ERR; 954 954 return 0; -
trunk/Source/WebCore/html/HTMLCollection.cpp
r165103 r165544 177 177 switch (type) { 178 178 case DocImages: 179 return element.has LocalName(imgTag);179 return element.hasTagName(imgTag); 180 180 case DocScripts: 181 return element.has LocalName(scriptTag);181 return element.hasTagName(scriptTag); 182 182 case DocForms: 183 return element.has LocalName(formTag);183 return element.hasTagName(formTag); 184 184 case TableTBodies: 185 return element.has LocalName(tbodyTag);185 return element.hasTagName(tbodyTag); 186 186 case TRCells: 187 return element.has LocalName(tdTag) || element.hasLocalName(thTag);187 return element.hasTagName(tdTag) || element.hasTagName(thTag); 188 188 case TSectionRows: 189 return element.has LocalName(trTag);189 return element.hasTagName(trTag); 190 190 case SelectOptions: 191 return element.has LocalName(optionTag);191 return element.hasTagName(optionTag); 192 192 case SelectedOptions: 193 return element.has LocalName(optionTag) && toHTMLOptionElement(element).selected();193 return element.hasTagName(optionTag) && toHTMLOptionElement(element).selected(); 194 194 case DataListOptions: 195 if (element.has LocalName(optionTag)) {195 if (element.hasTagName(optionTag)) { 196 196 HTMLOptionElement& option = toHTMLOptionElement(element); 197 197 if (!option.isDisabledFormControl() && !option.value().isEmpty()) … … 200 200 return false; 201 201 case MapAreas: 202 return element.has LocalName(areaTag);202 return element.hasTagName(areaTag); 203 203 case DocApplets: 204 return element.has LocalName(appletTag) || (element.hasLocalName(objectTag) && toHTMLObjectElement(element).containsJavaApplet());204 return element.hasTagName(appletTag) || (element.hasTagName(objectTag) && toHTMLObjectElement(element).containsJavaApplet()); 205 205 case DocEmbeds: 206 return element.has LocalName(embedTag);206 return element.hasTagName(embedTag); 207 207 case DocLinks: 208 return (element.has LocalName(aTag) || element.hasLocalName(areaTag)) && element.fastHasAttribute(hrefAttr);208 return (element.hasTagName(aTag) || element.hasTagName(areaTag)) && element.fastHasAttribute(hrefAttr); 209 209 case DocAnchors: 210 return element.has LocalName(aTag) && element.fastHasAttribute(nameAttr);210 return element.hasTagName(aTag) && element.fastHasAttribute(nameAttr); 211 211 case DocAll: 212 212 case NodeChildren: … … 270 270 // The document.all collection returns only certain types of elements by name, 271 271 // although it returns any type of element by id. 272 return element.has LocalName(appletTag)273 || element.has LocalName(embedTag)274 || element.has LocalName(formTag)275 || element.has LocalName(imgTag)276 || element.has LocalName(inputTag)277 || element.has LocalName(objectTag)278 || element.has LocalName(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); 279 279 } 280 280 -
trunk/Source/WebCore/html/HTMLElement.cpp
r165045 r165544 92 92 // for which no end tag should be serialized. It's unclear if the list for 93 93 // IE compat and the list for serialization sanity are the same. 94 if (has LocalName(areaTag)95 || has LocalName(baseTag)96 || has LocalName(basefontTag)97 || has LocalName(brTag)98 || has LocalName(colTag)99 || has LocalName(embedTag)100 || has LocalName(frameTag)101 || has LocalName(hrTag)102 || has LocalName(imageTag)103 || has LocalName(imgTag)104 || has LocalName(inputTag)105 || has LocalName(isindexTag)106 || has LocalName(linkTag)107 || has LocalName(metaTag)108 || has LocalName(paramTag)109 || has LocalName(sourceTag)110 || has LocalName(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)) 111 111 return true; 112 112 // FIXME: I'm not sure why dashboard mode would want to change the 113 113 // serialization of <canvas>, that seems like a bad idea. 114 114 #if ENABLE(DASHBOARD_SUPPORT) 115 if (has LocalName(canvasTag)) {115 if (hasTagName(canvasTag)) { 116 116 Settings* settings = document().settings(); 117 117 if (settings && settings->usesDashboardBackwardCompatibilityMode()) … … 124 124 static inline CSSValueID unicodeBidiAttributeForDirAuto(HTMLElement& element) 125 125 { 126 if (element.has LocalName(preTag) || element.hasLocalName(textareaTag))126 if (element.hasTagName(preTag) || element.hasTagName(textareaTag)) 127 127 return CSSValueWebkitPlaintext; 128 128 // FIXME: For bdo element, dir="auto" should result in "bidi-override isolate" but we don't support having multiple values in unicode-bidi yet. … … 135 135 unsigned borderWidth = 0; 136 136 if (value.isEmpty() || !parseHTMLNonNegativeInteger(value, borderWidth)) 137 return has LocalName(tableTag) ? 1 : borderWidth;137 return hasTagName(tableTag) ? 1 : borderWidth; 138 138 return borderWidth; 139 139 } … … 379 379 ContainerNode* container = this; 380 380 #if ENABLE(TEMPLATE_ELEMENT) 381 if (has LocalName(templateTag))381 if (hasTagName(templateTag)) 382 382 container = toHTMLTemplateElement(this)->content(); 383 383 #endif … … 456 456 } 457 457 458 static 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 458 472 void HTMLElement::setInnerText(const String& text, ExceptionCode& ec) 459 473 { … … 462 476 return; 463 477 } 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)) { 468 479 ec = NO_MODIFICATION_ALLOWED_ERR; 469 480 return; … … 510 521 return; 511 522 } 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)) { 516 524 ec = NO_MODIFICATION_ALLOWED_ERR; 517 525 return; … … 792 800 bool HTMLElement::rendererIsNeeded(const RenderStyle& style) 793 801 { 794 if (has LocalName(noscriptTag)) {802 if (hasTagName(noscriptTag)) { 795 803 Frame* frame = document().frame(); 796 804 if (frame && frame->script().canExecuteScripts(NotAboutToExecuteScript)) 797 805 return false; 798 } else if (has LocalName(noembedTag)) {806 } else if (hasTagName(noembedTag)) { 799 807 Frame* frame = document().frame(); 800 808 if (frame && frame->loader().subframeLoader().allowPlugins(NotAboutToInstantiatePlugin)) … … 806 814 RenderPtr<RenderElement> HTMLElement::createElementRenderer(PassRef<RenderStyle> style) 807 815 { 808 if (has LocalName(wbrTag))816 if (hasTagName(wbrTag)) 809 817 return createRenderer<RenderLineBreak>(*this, std::move(style)); 810 818 return RenderElement::createFor(*this, std::move(style)); -
trunk/Source/WebCore/html/HTMLElement.h
r162158 r165544 100 100 virtual FormNamedItem* asFormNamedItem() { return 0; } 101 101 102 bool hasTagName(const HTMLQualifiedName& name) const { return hasLocalName(name.localName()); } 103 102 104 protected: 103 105 HTMLElement(const QualifiedName& tagName, Document&, ConstructionType); … … 152 154 NODE_TYPE_CASTS(HTMLElement) 153 155 156 inline bool Node::hasTagName(const HTMLQualifiedName& name) const 157 { 158 return isHTMLElement() && toHTMLElement(*this).hasTagName(name); 159 } 160 154 161 } // namespace WebCore 155 162 -
trunk/Source/WebCore/html/HTMLObjectElement.cpp
r163457 r165544 398 398 DEFINE_STATIC_LOCAL(HashSet<AtomicStringImpl*>, tagList, ()); 399 399 if (tagList.isEmpty()) { 400 const QualifiedName* const* tags = HTMLNames::getHTMLTags();400 auto* tags = HTMLNames::getHTMLTags(); 401 401 for (size_t i = 0; i < HTMLNames::HTMLTagsCount; i++) { 402 402 if (*tags[i] == bgsoundTag -
trunk/Source/WebCore/html/HTMLSelectElement.cpp
r165103 r165544 221 221 void HTMLSelectElement::add(HTMLElement* element, HTMLElement* before, ExceptionCode& ec) 222 222 { 223 if (!element || !( element->hasLocalName(optionTag) || element->hasLocalName(hrTag)))223 if (!element || !(isHTMLOptionElement(*element) || element->hasTagName(hrTag))) 224 224 return; 225 225 … … 250 250 String HTMLSelectElement::value() const 251 251 { 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(); 261 260 } 262 261 … … 270 269 271 270 // Find the option with value() matching the given parameter and make it the current selection. 272 const Vector<HTMLElement*>& items = listItems();273 271 unsigned optionIndex = 0; 274 for ( unsigned i = 0; i < items.size(); i++) {275 if (i tems[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) { 277 275 setSelectedIndex(optionIndex); 278 276 return; 279 277 } 280 optionIndex++;278 ++optionIndex; 281 279 } 282 280 } … … 485 483 Vector<RefPtr<Element>> itemsToRemove; 486 484 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) { 490 487 ASSERT(item->parentNode()); 491 488 itemsToRemove.append(item); … … 493 490 } 494 491 495 for (size_t i = 0; i < itemsToRemove.size(); ++i) { 496 Element* item = itemsToRemove[i].get(); 492 for (auto& item : itemsToRemove) { 497 493 if (item->parentNode()) 498 item->parentNode()->removeChild(item , ec);494 item->parentNode()->removeChild(item.get(), ec); 499 495 } 500 496 } … … 998 994 size_t loopEndIndex = std::min(items.size(), listIndexEnd); 999 995 for (size_t i = listIndexStart; i < loopEndIndex; ++i) { 1000 if (!i tems[i]->hasLocalName(optionTag))996 if (!isHTMLOptionElement(items[i])) 1001 997 continue; 1002 998 if (toHTMLOptionElement(items[i])->value() == value) … … 1016 1012 1017 1013 for (size_t i = 0; i < itemsSize; ++i) { 1018 if (!i tems[i]->hasLocalName(optionTag))1014 if (!isHTMLOptionElement(items[i])) 1019 1015 continue; 1020 1016 toHTMLOptionElement(items[i])->setSelectedState(false); … … 1496 1492 // Use space to toggle selection change. 1497 1493 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])); 1501 1497 updateSelectedState(m_activeSelectionEndIndex, true /*multi*/, false /*shift*/); 1502 1498 listBoxOnChange(); -
trunk/Source/WebCore/html/HTMLTableColElement.cpp
r165395 r165544 85 85 const StyleProperties* HTMLTableColElement::additionalPresentationAttributeStyle() 86 86 { 87 if (!has LocalName(colgroupTag))88 return 0;87 if (!hasTagName(colgroupTag)) 88 return nullptr; 89 89 if (HTMLTableElement* table = findParentTable()) 90 90 return table->additionalGroupStyle(false); 91 return 0;91 return nullptr; 92 92 } 93 93 -
trunk/Source/WebCore/html/HTMLTableRowsCollection.cpp
r161583 r165544 55 55 } 56 56 57 static inline bool isInSection(HTMLTableRowElement * row, constQualifiedName& sectionTag)57 static inline bool isInSection(HTMLTableRowElement& row, const HTMLQualifiedName& sectionTag) 58 58 { 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); 63 62 } 64 63 … … 82 81 if (!previous) 83 82 child = ElementTraversal::firstChild(table); 84 else if (isInSection( previous, theadTag))83 else if (isInSection(*previous, theadTag)) 85 84 child = ElementTraversal::nextSibling(previous->parentNode()); 86 85 for (; child; child = ElementTraversal::nextSibling(child)) { … … 92 91 93 92 // 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)) 95 94 child = ElementTraversal::firstChild(table); 96 95 else if (previous->parentNode() == table) 97 96 child = ElementTraversal::nextSibling(previous); 98 else if (isInSection( previous, tbodyTag))97 else if (isInSection(*previous, tbodyTag)) 99 98 child = ElementTraversal::nextSibling(previous->parentNode()); 100 99 for (; child; child = ElementTraversal::nextSibling(child)) { … … 108 107 109 108 // Find the first row in the next foot section. 110 if (!previous || !isInSection( previous, tfootTag))109 if (!previous || !isInSection(*previous, tfootTag)) 111 110 child = ElementTraversal::firstChild(table); 112 111 else -
trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp
r163579 r165544 43 43 #include "HTMLTemplateElement.h" 44 44 #include "NotImplemented.h" 45 #include "SVGElement.h" 45 46 #include "Text.h" 46 47 -
trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp
r164569 r165544 43 43 #include "XMLNames.h" 44 44 #include <wtf/MainThread.h> 45 #include <wtf/NeverDestroyed.h> 45 46 #include <wtf/unicode/CharacterNames.h> 46 47 … … 523 524 } 524 525 525 t ypedef HashMap<AtomicString, QualifiedName> PrefixedNameToQualifiedNameMap;526 527 static void mapLoweredLocalNameToName(PrefixedNameToQualifiedNameMap* map, const QualifiedName* const names[], size_t length) 528 { 529 for ( size_ti = 0; i < length; ++i) {526 template <typename TableQualifiedName> 527 static HashMap<AtomicString, QualifiedName> createCaseMap(const TableQualifiedName* const names[], unsigned length) 528 { 529 HashMap<AtomicString, QualifiedName> map; 530 for (unsigned i = 0; i < length; ++i) { 530 531 const QualifiedName& name = *names[i]; 531 532 const AtomicString& localName = name.localName(); 532 533 AtomicString loweredLocalName = localName.lower(); 533 534 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 540 static 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()); 547 544 if (casedName.localName().isNull()) 548 545 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 549 static inline void adjustAttributes(HashMap<AtomicString, QualifiedName>& map, AtomicHTMLToken& token) 550 { 551 for (auto& attribute : token.attributes()) { 552 const QualifiedName& casedName = map.get(attribute.localName()); 564 553 if (!casedName.localName().isNull()) 565 tokenAttribute.parserSetName(casedName); 566 } 567 } 568 569 static void adjustSVGAttributes(AtomicHTMLToken* token) 554 attribute.parserSetName(casedName); 555 } 556 } 557 558 template<const QualifiedName* const* attributesTable(), unsigned attributesTableLength> 559 static void adjustAttributes(AtomicHTMLToken& token) 560 { 561 static NeverDestroyed<HashMap<AtomicString, QualifiedName>> map = createCaseMap(attributesTable(), attributesTableLength); 562 adjustAttributes(map, token); 563 } 564 565 static inline void adjustSVGAttributes(AtomicHTMLToken& token) 570 566 { 571 567 adjustAttributes<SVGNames::getSVGAttrs, SVGNames::SVGAttrsCount>(token); 572 568 } 573 569 574 static void adjustMathMLAttributes(AtomicHTMLToken*token)570 static inline void adjustMathMLAttributes(AtomicHTMLToken& token) 575 571 { 576 572 adjustAttributes<MathMLNames::getMathMLAttrs, MathMLNames::MathMLAttrsCount>(token); 577 573 } 578 574 579 static void addNamesWithPrefix( PrefixedNameToQualifiedNameMap* map, const AtomicString& prefix, const QualifiedName* const names[], size_tlength)580 { 581 for ( size_ti = 0; i < length; ++i) {575 static void addNamesWithPrefix(HashMap<AtomicString, QualifiedName>& map, const AtomicString& prefix, const QualifiedName* const names[], unsigned length) 576 { 577 for (unsigned i = 0; i < length; ++i) { 582 578 const QualifiedName& name = *names[i]; 583 579 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 584 static 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 597 static void adjustForeignAttributes(AtomicHTMLToken& token) 598 { 599 static NeverDestroyed<HashMap<AtomicString, QualifiedName>> map = createForeignAttributesMap(); 600 adjustAttributes(map, token); 610 601 } 611 602 … … 897 888 if (token->name() == MathMLNames::mathTag.localName()) { 898 889 m_tree.reconstructTheActiveFormattingElements(); 899 adjustMathMLAttributes( token);900 adjustForeignAttributes( token);890 adjustMathMLAttributes(*token); 891 adjustForeignAttributes(*token); 901 892 m_tree.insertForeignElement(token, MathMLNames::mathmlNamespaceURI); 902 893 return; … … 904 895 if (token->name() == SVGNames::svgTag.localName()) { 905 896 m_tree.reconstructTheActiveFormattingElements(); 906 adjustSVGAttributes( token);907 adjustForeignAttributes( token);897 adjustSVGAttributes(*token); 898 adjustForeignAttributes(*token); 908 899 m_tree.insertForeignElement(token, SVGNames::svgNamespaceURI); 909 900 return; … … 2927 2918 const AtomicString& currentNamespace = m_tree.currentStackItem()->namespaceURI(); 2928 2919 if (currentNamespace == MathMLNames::mathmlNamespaceURI) 2929 adjustMathMLAttributes( token);2920 adjustMathMLAttributes(*token); 2930 2921 if (currentNamespace == SVGNames::svgNamespaceURI) { 2931 adjustSVGTagNameCase( token);2932 adjustSVGAttributes( token);2933 } 2934 adjustForeignAttributes( token);2922 adjustSVGTagNameCase(*token); 2923 adjustSVGAttributes(*token); 2924 } 2925 adjustForeignAttributes(*token); 2935 2926 m_tree.insertForeignElement(token, currentNamespace); 2936 2927 break; … … 2938 2929 case HTMLToken::EndTag: { 2939 2930 if (m_tree.currentStackItem()->namespaceURI() == SVGNames::svgNamespaceURI) 2940 adjustSVGTagNameCase( token);2931 adjustSVGTagNameCase(*token); 2941 2932 2942 2933 if (token->name() == SVGNames::scriptTag && m_tree.currentStackItem()->hasTagName(SVGNames::scriptTag)) { -
trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp
r164245 r165544 49 49 #include "InspectorPageAgent.h" 50 50 #include "Node.h" 51 #include "SVGElement.h" 51 52 #include "SVGNames.h" 52 53 #include "StyleProperties.h" -
trunk/Source/WebCore/mathml/MathMLElement.h
r164856 r165544 55 55 virtual bool isPresentationMathML() const; 56 56 57 bool hasTagName(const MathMLQualifiedName& name) const { return hasLocalName(name.localName()); } 58 57 59 protected: 58 60 MathMLElement(const QualifiedName& tagName, Document&); … … 64 66 virtual bool isPresentationAttribute(const QualifiedName&) const override; 65 67 virtual void collectStyleForPresentationAttribute(const QualifiedName&, const AtomicString&, MutableStyleProperties&) override; 66 private:67 68 68 virtual void updateSelectedChild() { }; 69 private: 70 virtual void updateSelectedChild() { } 69 71 }; 70 72 … … 73 75 NODE_TYPE_CASTS(MathMLElement) 74 76 77 inline bool Node::hasTagName(const MathMLQualifiedName& name) const 78 { 79 return isMathMLElement() && toMathMLElement(*this).hasTagName(name); 80 } 81 75 82 } 76 83 -
trunk/Source/WebCore/mathml/MathMLInlineContainerElement.cpp
r165461 r165544 61 61 if (renderer()->isRenderMathMLRow()) 62 62 toRenderMathMLRow(renderer())->updateOperatorProperties(); 63 else if (has LocalName(mathTag) || hasLocalName(msqrtTag)) {63 else if (hasTagName(mathTag) || hasTagName(msqrtTag)) { 64 64 auto childRenderer = renderer()->firstChild(); 65 65 if (childRenderer && childRenderer->isRenderMathMLRow()) … … 72 72 RenderPtr<RenderElement> MathMLInlineContainerElement::createElementRenderer(PassRef<RenderStyle> style) 73 73 { 74 if (has LocalName(annotation_xmlTag))74 if (hasTagName(annotation_xmlTag)) 75 75 return createRenderer<RenderMathMLRow>(*this, std::move(style)); 76 if (has LocalName(merrorTag) || hasLocalName(mphantomTag) || hasLocalName(mrowTag) || hasLocalName(mstyleTag))76 if (hasTagName(merrorTag) || hasTagName(mphantomTag) || hasTagName(mrowTag) || hasTagName(mstyleTag)) 77 77 return createRenderer<RenderMathMLRow>(*this, std::move(style)); 78 if (has LocalName(msubTag))78 if (hasTagName(msubTag)) 79 79 return createRenderer<RenderMathMLScripts>(*this, std::move(style)); 80 if (has LocalName(msupTag))80 if (hasTagName(msupTag)) 81 81 return createRenderer<RenderMathMLScripts>(*this, std::move(style)); 82 if (has LocalName(msubsupTag))82 if (hasTagName(msubsupTag)) 83 83 return createRenderer<RenderMathMLScripts>(*this, std::move(style)); 84 if (has LocalName(mmultiscriptsTag))84 if (hasTagName(mmultiscriptsTag)) 85 85 return createRenderer<RenderMathMLScripts>(*this, std::move(style)); 86 if (has LocalName(moverTag))86 if (hasTagName(moverTag)) 87 87 return createRenderer<RenderMathMLUnderOver>(*this, std::move(style)); 88 if (has LocalName(munderTag))88 if (hasTagName(munderTag)) 89 89 return createRenderer<RenderMathMLUnderOver>(*this, std::move(style)); 90 if (has LocalName(munderoverTag))90 if (hasTagName(munderoverTag)) 91 91 return createRenderer<RenderMathMLUnderOver>(*this, std::move(style)); 92 if (has LocalName(mfracTag))92 if (hasTagName(mfracTag)) 93 93 return createRenderer<RenderMathMLFraction>(*this, std::move(style)); 94 if (has LocalName(msqrtTag))94 if (hasTagName(msqrtTag)) 95 95 return createRenderer<RenderMathMLSquareRoot>(*this, std::move(style)); 96 if (has LocalName(mrootTag))96 if (hasTagName(mrootTag)) 97 97 return createRenderer<RenderMathMLRoot>(*this, std::move(style)); 98 if (has LocalName(mfencedTag))98 if (hasTagName(mfencedTag)) 99 99 return createRenderer<RenderMathMLFenced>(*this, std::move(style)); 100 if (has LocalName(mtableTag))100 if (hasTagName(mtableTag)) 101 101 return createRenderer<RenderMathMLTable>(*this, std::move(style)); 102 102 -
trunk/Source/WebCore/mathml/MathMLSelectElement.cpp
r164856 r165544 72 72 void MathMLSelectElement::attributeChanged(const QualifiedName& name, const AtomicString& oldValue, const AtomicString& newValue, AttributeModificationReason reason) 73 73 { 74 if (has LocalName(mactionTag) && (name == MathMLNames::actiontypeAttr || name == MathMLNames::selectionAttr))74 if (hasTagName(mactionTag) && (name == MathMLNames::actiontypeAttr || name == MathMLNames::selectionAttr)) 75 75 updateSelectedChild(); 76 76 … … 80 80 int MathMLSelectElement::getSelectedActionChildAndIndex(Element*& selectedChild) 81 81 { 82 ASSERT(has LocalName(mactionTag));82 ASSERT(hasTagName(mactionTag)); 83 83 84 84 // We "round up or down to the closest allowable value" of the selection attribute, as suggested by the MathML specification. … … 101 101 Element* MathMLSelectElement::getSelectedActionChild() 102 102 { 103 ASSERT(has LocalName(mactionTag));103 ASSERT(hasTagName(mactionTag)); 104 104 105 105 Element* child = firstElementChild(); … … 125 125 Element* MathMLSelectElement::getSelectedSemanticsChild() 126 126 { 127 ASSERT(has LocalName(semanticsTag));127 ASSERT(hasTagName(semanticsTag)); 128 128 129 129 Element* child = firstElementChild(); … … 144 144 continue; 145 145 146 if (child->has LocalName(MathMLNames::annotationTag)) {146 if (child->hasTagName(MathMLNames::annotationTag)) { 147 147 // 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. 148 148 if (child->hasAttribute(MathMLNames::srcAttr)) … … 152 152 } 153 153 154 if (child->has LocalName(MathMLNames::annotation_xmlTag)) {154 if (child->hasTagName(MathMLNames::annotation_xmlTag)) { 155 155 // 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. 156 156 if (child->hasAttribute(MathMLNames::srcAttr)) … … 176 176 void MathMLSelectElement::updateSelectedChild() 177 177 { 178 Element* newSelectedChild = has LocalName(mactionTag) ? getSelectedActionChild() : getSelectedSemanticsChild();178 Element* newSelectedChild = hasTagName(mactionTag) ? getSelectedActionChild() : getSelectedSemanticsChild(); 179 179 180 180 if (m_selectedChild == newSelectedChild) -
trunk/Source/WebCore/mathml/MathMLTextElement.cpp
r165436 r165544 67 67 RenderPtr<RenderElement> MathMLTextElement::createElementRenderer(PassRef<RenderStyle> style) 68 68 { 69 if (has LocalName(MathMLNames::moTag))69 if (hasTagName(MathMLNames::moTag)) 70 70 return createRenderer<RenderMathMLOperator>(*this, std::move(style)); 71 if (has LocalName(MathMLNames::miTag))71 if (hasTagName(MathMLNames::miTag)) 72 72 return createRenderer<RenderMathMLToken>(*this, std::move(style)); 73 if (has LocalName(MathMLNames::mspaceTag))73 if (hasTagName(MathMLNames::mspaceTag)) 74 74 return createRenderer<RenderMathMLSpace>(*this, std::move(style)); 75 75 … … 79 79 bool MathMLTextElement::childShouldCreateRenderer(const Node& child) const 80 80 { 81 return !has LocalName(mspaceTag) && child.isTextNode();81 return !hasTagName(mspaceTag) && child.isTextNode(); 82 82 } 83 83 -
trunk/Source/WebCore/platform/mac/HTMLConverter.mm
r165156 r165544 41 41 #import "Frame.h" 42 42 #import "FrameLoader.h" 43 #import "HTMLElement.h" 43 44 #import "HTMLNames.h" 44 45 #import "HTMLParserIdioms.h" -
trunk/Source/WebCore/rendering/RenderBlockFlow.cpp
r164697 r165544 28 28 #include "FloatingObjects.h" 29 29 #include "Frame.h" 30 #include "HTMLElement.h" 30 31 #include "HitTestLocation.h" 31 32 #include "InlineTextBox.h" … … 45 46 #if ENABLE(CSS_SHAPES) && ENABLE(CSS_SHAPE_INSIDE) 46 47 #include "ShapeInsideInfo.h" 47 #endif48 49 #if ENABLE(IOS_TEXT_AUTOSIZING)50 #include "HTMLElement.h"51 48 #endif 52 49 -
trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp
r165484 r165544 756 756 if (body) { 757 757 // Can't scroll a frameset document anyway. 758 isOpaqueRoot = body->has LocalName(framesetTag);758 isOpaqueRoot = body->hasTagName(framesetTag); 759 759 } else { 760 760 // SVG documents and XML documents with SVG root nodes are transparent. -
trunk/Source/WebCore/rendering/RenderElement.cpp
r165346 r165544 1085 1085 // render object very easily via the DOM. 1086 1086 if (auto body = document().body()) { 1087 if (body->has LocalName(HTMLNames::bodyTag)) {1087 if (body->hasTagName(HTMLNames::bodyTag)) { 1088 1088 if (auto renderer = body->renderer()) 1089 1089 return *renderer; -
trunk/Source/WebCore/rendering/RenderLayerBacking.cpp
r165540 r165544 1746 1746 // Now look at the body's renderer. 1747 1747 HTMLElement* body = renderer().document().body(); 1748 RenderObject* bodyObject = (body && body->has LocalName(bodyTag)) ? body->renderer() : 0;1748 RenderObject* bodyObject = (body && body->hasTagName(bodyTag)) ? body->renderer() : 0; 1749 1749 if (!bodyObject) 1750 1750 return false; -
trunk/Source/WebCore/rendering/RenderReplaced.cpp
r165065 r165544 28 28 #include "Frame.h" 29 29 #include "GraphicsContext.h" 30 #include "HTMLElement.h" 30 31 #include "InlineElementBox.h" 31 32 #include "LayoutRepainter.h" -
trunk/Source/WebCore/rendering/mathml/RenderMathMLScripts.cpp
r158198 r165544 31 31 #include "RenderMathMLScripts.h" 32 32 33 #include "MathML Names.h"33 #include "MathMLElement.h" 34 34 35 35 namespace WebCore { … … 62 62 { 63 63 // Determine what kind of sub/sup expression we have by element name 64 if (element.has LocalName(MathMLNames::msubTag))64 if (element.hasTagName(MathMLNames::msubTag)) 65 65 m_kind = Sub; 66 else if (element.has LocalName(MathMLNames::msupTag))66 else if (element.hasTagName(MathMLNames::msupTag)) 67 67 m_kind = Super; 68 else if (element.has LocalName(MathMLNames::msubsupTag))68 else if (element.hasTagName(MathMLNames::msubsupTag)) 69 69 m_kind = SubSup; 70 70 else { 71 ASSERT(element.has LocalName(MathMLNames::mmultiscriptsTag));71 ASSERT(element.hasTagName(MathMLNames::mmultiscriptsTag)); 72 72 m_kind = Multiscripts; 73 73 } -
trunk/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.cpp
r158097 r165544 30 30 #include "RenderMathMLUnderOver.h" 31 31 32 #include "MathML Names.h"32 #include "MathMLElement.h" 33 33 34 34 namespace WebCore { … … 40 40 { 41 41 // Determine what kind of under/over expression we have by element name 42 if (element.has LocalName(MathMLNames::munderTag))42 if (element.hasTagName(MathMLNames::munderTag)) 43 43 m_kind = Under; 44 else if (element.has LocalName(MathMLNames::moverTag))44 else if (element.hasTagName(MathMLNames::moverTag)) 45 45 m_kind = Over; 46 46 else { 47 ASSERT(element.has LocalName(MathMLNames::munderoverTag));47 ASSERT(element.hasTagName(MathMLNames::munderoverTag)); 48 48 m_kind = UnderOver; 49 49 } -
trunk/Source/WebCore/svg/SVGElement.h
r165542 r165544 141 141 #endif 142 142 143 bool hasTagName(const SVGQualifiedName& name) const { return hasLocalName(name.localName()); } 144 143 145 protected: 144 146 SVGElement(const QualifiedName&, Document&); … … 214 216 NODE_TYPE_CASTS(SVGElement) 215 217 218 inline bool Node::hasTagName(const SVGQualifiedName& name) const 219 { 220 return isSVGElement() && toSVGElement(*this).hasTagName(name); 216 221 } 217 222 218 #endif 223 } 224 225 #endif -
trunk/Source/WebCore/svg/SVGFontFaceSrcElement.cpp
r160598 r165544 64 64 { 65 65 SVGElement::childrenChanged(change); 66 if (parentNode() && parentNode()->hasTagName(font_faceTag))66 if (parentNode() && isSVGFontFaceElement(parentNode())) 67 67 toSVGFontFaceElement(parentNode())->rebuildFontFace(); 68 68 } -
trunk/Source/WebCore/svg/SVGUseElement.cpp
r163440 r165544 523 523 } 524 524 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);525 static 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); 534 534 } 535 535 … … 542 542 return; 543 543 544 if (n->isSVGElement() && toSVGElement( n)->isSVGGraphicsElement()) {545 if (!isDirectReference( n))544 if (n->isSVGElement() && toSVGElement(*n).isSVGGraphicsElement()) { 545 if (!isDirectReference(toSVGElement(*n))) { 546 546 // Spec: Indirect references are an error (14.3.5) 547 547 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); 550 550 // FIXME: Avoid manual resolution of x/y here. Its potentially harmful. 551 551 SVGLengthContext lengthContext(this); … … 558 558 RenderElement* SVGUseElement::rendererClipChild() const 559 559 { 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(); 568 571 } 569 572 -
trunk/Source/WebCore/xml/parser/XMLDocumentParser.cpp
r163440 r165544 276 276 // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-xhtml-syntax.html#xml-fragment-parsing-algorithm 277 277 // 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()))) { 279 279 fragment.parserAppendChild(fragment.document().createTextNode(chunk)); 280 280 return true; … … 283 283 RefPtr<XMLDocumentParser> parser = XMLDocumentParser::create(fragment, contextElement, parserContentPolicy); 284 284 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. 287 286 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(). 289 288 } 290 289
Note: See TracChangeset
for help on using the changeset viewer.