Title: [152290] trunk/Source/WebCore
- Revision
- 152290
- Author
- [email protected]
- Date
- 2013-07-02 06:48:16 -0700 (Tue, 02 Jul 2013)
Log Message
is/toHTMLStyleElement should use Element* for its argument
https://bugs.webkit.org/show_bug.cgi?id=118286
Reviewed by Andreas Kling.
To reduce unnecessary call of isElementNode(), this patch replaces argument
of is/toHTMLStyleElement from Node* to Element*. Plus, use Element::hasTagName
in collectActiveStyleSheets function for minor code refactoring since
its cost is cheaper than Node::hasTagName.
* css/CSSStyleSheet.cpp:
(WebCore::isAcceptableCSSStyleSheetParent):
* css/StyleScopeResolver.cpp:
(WebCore::StyleScopeResolver::scopeFor):
* dom/DocumentStyleSheetCollection.cpp:
(WebCore::DocumentStyleSheetCollection::collectActiveStyleSheets):
* dom/Node.cpp:
(WebCore::Node::numberOfScopedHTMLStyleChildren):
* html/HTMLStyleElement.h:
(WebCore::isHTMLStyleElement):
(WebCore::toHTMLStyleElement):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (152289 => 152290)
--- trunk/Source/WebCore/ChangeLog 2013-07-02 13:36:09 UTC (rev 152289)
+++ trunk/Source/WebCore/ChangeLog 2013-07-02 13:48:16 UTC (rev 152290)
@@ -1,3 +1,27 @@
+2013-07-02 Kangil Han <[email protected]>
+
+ is/toHTMLStyleElement should use Element* for its argument
+ https://bugs.webkit.org/show_bug.cgi?id=118286
+
+ Reviewed by Andreas Kling.
+
+ To reduce unnecessary call of isElementNode(), this patch replaces argument
+ of is/toHTMLStyleElement from Node* to Element*. Plus, use Element::hasTagName
+ in collectActiveStyleSheets function for minor code refactoring since
+ its cost is cheaper than Node::hasTagName.
+
+ * css/CSSStyleSheet.cpp:
+ (WebCore::isAcceptableCSSStyleSheetParent):
+ * css/StyleScopeResolver.cpp:
+ (WebCore::StyleScopeResolver::scopeFor):
+ * dom/DocumentStyleSheetCollection.cpp:
+ (WebCore::DocumentStyleSheetCollection::collectActiveStyleSheets):
+ * dom/Node.cpp:
+ (WebCore::Node::numberOfScopedHTMLStyleChildren):
+ * html/HTMLStyleElement.h:
+ (WebCore::isHTMLStyleElement):
+ (WebCore::toHTMLStyleElement):
+
2013-07-02 Ryosuke Niwa <[email protected]>
Unexpose EditingPropertiesToInclude in EditingStyle.h after r151772
Modified: trunk/Source/WebCore/css/CSSStyleSheet.cpp (152289 => 152290)
--- trunk/Source/WebCore/css/CSSStyleSheet.cpp 2013-07-02 13:36:09 UTC (rev 152289)
+++ trunk/Source/WebCore/css/CSSStyleSheet.cpp 2013-07-02 13:48:16 UTC (rev 152290)
@@ -65,7 +65,7 @@
return !parentNode
|| parentNode->isDocumentNode()
|| parentNode->hasTagName(HTMLNames::linkTag)
- || isHTMLStyleElement(parentNode)
+ || (parentNode->isElementNode() && isHTMLStyleElement(toElement(parentNode)))
#if ENABLE(SVG)
|| parentNode->hasTagName(SVGNames::styleTag)
#endif
Modified: trunk/Source/WebCore/css/StyleScopeResolver.cpp (152289 => 152290)
--- trunk/Source/WebCore/css/StyleScopeResolver.cpp 2013-07-02 13:36:09 UTC (rev 152289)
+++ trunk/Source/WebCore/css/StyleScopeResolver.cpp 2013-07-02 13:48:16 UTC (rev 152290)
@@ -60,10 +60,10 @@
if (!document)
return 0;
Node* ownerNode = sheet->ownerNode();
- if (!ownerNode || !ownerNode->isHTMLElement() || !isHTMLStyleElement(ownerNode))
+ if (!ownerNode || !ownerNode->isHTMLElement() || !isHTMLStyleElement(toElement(ownerNode)))
return 0;
- HTMLStyleElement* styleElement = toHTMLStyleElement(ownerNode);
+ HTMLStyleElement* styleElement = toHTMLStyleElement(toElement(ownerNode));
if (!styleElement->scoped())
return styleElement->isInShadowTree() ? styleElement->containingShadowRoot() : 0;
Modified: trunk/Source/WebCore/dom/DocumentStyleSheetCollection.cpp (152289 => 152290)
--- trunk/Source/WebCore/dom/DocumentStyleSheetCollection.cpp 2013-07-02 13:36:09 UTC (rev 152289)
+++ trunk/Source/WebCore/dom/DocumentStyleSheetCollection.cpp 2013-07-02 13:48:16 UTC (rev 152290)
@@ -299,7 +299,7 @@
Element* e = toElement(n);
AtomicString title = e->getAttribute(titleAttr);
bool enabledViaScript = false;
- if (e->hasLocalName(linkTag)) {
+ if (e->hasTagName(linkTag)) {
// <LINK> element
HTMLLinkElement* linkElement = static_cast<HTMLLinkElement*>(n);
if (linkElement->isDisabled())
@@ -322,15 +322,17 @@
// Get the current preferred styleset. This is the
// set of sheets that will be enabled.
#if ENABLE(SVG)
- if (n->isSVGElement() && n->hasTagName(SVGNames::styleTag))
+ if (e->hasTagName(SVGNames::styleTag))
sheet = static_cast<SVGStyleElement*>(n)->sheet();
else
#endif
- if (e->hasLocalName(linkTag))
- sheet = static_cast<HTMLLinkElement*>(n)->sheet();
- else
- // <STYLE> element
- sheet = toHTMLStyleElement(n)->sheet();
+ {
+ if (e->hasTagName(linkTag))
+ sheet = static_cast<HTMLLinkElement*>(n)->sheet();
+ else
+ // <STYLE> element
+ sheet = toHTMLStyleElement(e)->sheet();
+ }
// Check to see if this sheet belongs to a styleset
// (thus making it PREFERRED or ALTERNATE rather than
// PERSISTENT).
@@ -342,7 +344,7 @@
// we are NOT an alternate sheet, then establish
// us as the preferred set. Otherwise, just ignore
// this sheet.
- if (e->hasLocalName(styleTag) || !rel.contains("alternate"))
+ if (e->hasTagName(styleTag) || !rel.contains("alternate"))
m_preferredStylesheetSetName = m_selectedStylesheetSetName = title;
}
if (title != m_preferredStylesheetSetName)
Modified: trunk/Source/WebCore/dom/Node.cpp (152289 => 152290)
--- trunk/Source/WebCore/dom/Node.cpp 2013-07-02 13:36:09 UTC (rev 152289)
+++ trunk/Source/WebCore/dom/Node.cpp 2013-07-02 13:48:16 UTC (rev 152290)
@@ -2530,8 +2530,8 @@
size_t Node::numberOfScopedHTMLStyleChildren() const
{
size_t count = 0;
- for (Node* child = firstChild(); child; child = child->nextSibling()) {
- if (isHTMLStyleElement(child) && toHTMLStyleElement(child)->isRegisteredAsScoped())
+ for (Element* element = ElementTraversal::firstWithin(this); element; element = ElementTraversal::next(element, this)) {
+ if (isHTMLStyleElement(element) && toHTMLStyleElement(element)->isRegisteredAsScoped())
count++;
}
Modified: trunk/Source/WebCore/html/HTMLStyleElement.h (152289 => 152290)
--- trunk/Source/WebCore/html/HTMLStyleElement.h 2013-07-02 13:36:09 UTC (rev 152289)
+++ trunk/Source/WebCore/html/HTMLStyleElement.h 2013-07-02 13:48:16 UTC (rev 152290)
@@ -97,15 +97,15 @@
ScopedStyleRegistrationState m_scopedStyleRegistrationState;
};
-inline bool isHTMLStyleElement(Node* node)
+inline bool isHTMLStyleElement(Element* element)
{
- return node->hasTagName(HTMLNames::styleTag);
+ return element->hasTagName(HTMLNames::styleTag);
}
-inline HTMLStyleElement* toHTMLStyleElement(Node* node)
+inline HTMLStyleElement* toHTMLStyleElement(Element* element)
{
- ASSERT_WITH_SECURITY_IMPLICATION(!node || isHTMLStyleElement(node));
- return static_cast<HTMLStyleElement*>(node);
+ ASSERT_WITH_SECURITY_IMPLICATION(!element || isHTMLStyleElement(element));
+ return static_cast<HTMLStyleElement*>(element);
}
} //namespace
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes