- Revision
- 151071
- Author
- [email protected]
- Date
- 2013-06-01 03:20:25 -0700 (Sat, 01 Jun 2013)
Log Message
Move Node::hasName() to Element.
<http://webkit.org/b/117107>
Reviewed by Antti Koivisto.
A Node can't have attributes, and thus can't have a name.
Use a bit on ElementData instead of (half) a Node flag to track whether we have a name.
* dom/Element.cpp:
(WebCore::Element::attributeChanged):
(WebCore::ElementData::ElementData):
* dom/Element.h:
(WebCore::ElementData::hasName):
(WebCore::Element::hasName):
* dom/Node.h:
(WebCore::Node::isEditingText):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (151070 => 151071)
--- trunk/Source/WebCore/ChangeLog 2013-06-01 09:48:33 UTC (rev 151070)
+++ trunk/Source/WebCore/ChangeLog 2013-06-01 10:20:25 UTC (rev 151071)
@@ -1,5 +1,24 @@
2013-06-01 Andreas Kling <[email protected]>
+ Move Node::hasName() to Element.
+ <http://webkit.org/b/117107>
+
+ Reviewed by Antti Koivisto.
+
+ A Node can't have attributes, and thus can't have a name.
+ Use a bit on ElementData instead of (half) a Node flag to track whether we have a name.
+
+ * dom/Element.cpp:
+ (WebCore::Element::attributeChanged):
+ (WebCore::ElementData::ElementData):
+ * dom/Element.h:
+ (WebCore::ElementData::hasName):
+ (WebCore::Element::hasName):
+ * dom/Node.h:
+ (WebCore::Node::isEditingText):
+
+2013-06-01 Andreas Kling <[email protected]>
+
Move Node::hasID() and hasClass() to Element.
<http://webkit.org/b/117104>
Modified: trunk/Source/WebCore/dom/Element.cpp (151070 => 151071)
--- trunk/Source/WebCore/dom/Element.cpp 2013-06-01 09:48:33 UTC (rev 151070)
+++ trunk/Source/WebCore/dom/Element.cpp 2013-06-01 10:20:25 UTC (rev 151071)
@@ -1027,7 +1027,7 @@
} else if (name == classAttr)
classAttributeChanged(newValue);
else if (name == HTMLNames::nameAttr)
- setHasName(!newValue.isNull());
+ elementData()->m_hasNameAttribute = newValue.isNull();
else if (name == HTMLNames::pseudoAttr)
shouldInvalidateStyle |= testShouldInvalidateStyle && isInShadowTree();
@@ -3193,6 +3193,7 @@
ElementData::ElementData()
: m_isUnique(true)
, m_arraySize(0)
+ , m_hasNameAttribute(false)
, m_presentationAttributeStyleIsDirty(false)
, m_styleAttributeIsDirty(false)
#if ENABLE(SVG)
@@ -3204,6 +3205,7 @@
ElementData::ElementData(unsigned arraySize)
: m_isUnique(false)
, m_arraySize(arraySize)
+ , m_hasNameAttribute(false)
, m_presentationAttributeStyleIsDirty(false)
, m_styleAttributeIsDirty(false)
#if ENABLE(SVG)
@@ -3265,6 +3267,7 @@
ElementData::ElementData(const ElementData& other, bool isUnique)
: m_isUnique(isUnique)
, m_arraySize(isUnique ? 0 : other.length())
+ , m_hasNameAttribute(other.m_hasNameAttribute)
, m_presentationAttributeStyleIsDirty(other.m_presentationAttributeStyleIsDirty)
, m_styleAttributeIsDirty(other.m_styleAttributeIsDirty)
#if ENABLE(SVG)
Modified: trunk/Source/WebCore/dom/Element.h (151070 => 151071)
--- trunk/Source/WebCore/dom/Element.h 2013-06-01 09:48:33 UTC (rev 151070)
+++ trunk/Source/WebCore/dom/Element.h 2013-06-01 10:20:25 UTC (rev 151071)
@@ -83,6 +83,7 @@
bool hasID() const { return !m_idForStyleResolution.isNull(); }
bool hasClass() const { return !m_classNames.isNull(); }
+ bool hasName() const { return m_hasNameAttribute; }
bool isEquivalent(const ElementData* other) const;
@@ -94,7 +95,8 @@
ElementData(const ElementData&, bool isUnique);
unsigned m_isUnique : 1;
- unsigned m_arraySize : 28;
+ unsigned m_arraySize : 27;
+ mutable unsigned m_hasNameAttribute : 1;
mutable unsigned m_presentationAttributeStyleIsDirty : 1;
mutable unsigned m_styleAttributeIsDirty : 1;
#if ENABLE(SVG)
@@ -627,6 +629,7 @@
bool hasID() const;
bool hasClass() const;
+ bool hasName() const;
const SpaceSplitString& classNames() const;
IntSize savedLayerScrollOffset() const;
@@ -908,6 +911,11 @@
return elementData() && elementData()->hasClass();
}
+inline bool Element::hasName() const
+{
+ return elementData() && elementData()->hasName();
+}
+
inline UniqueElementData* Element::ensureUniqueElementData()
{
if (!elementData() || !elementData()->isUnique())
Modified: trunk/Source/WebCore/dom/Node.h (151070 => 151071)
--- trunk/Source/WebCore/dom/Node.h 2013-06-01 09:48:33 UTC (rev 151070)
+++ trunk/Source/WebCore/dom/Node.h 2013-06-01 10:20:25 UTC (rev 151071)
@@ -327,8 +327,6 @@
virtual void notifyLoadedSheetAndAllCriticalSubresources(bool /* error loading subresource */) { }
virtual void startLoadingDynamicSheet() { ASSERT_NOT_REACHED(); }
- bool hasName() const { return !isTextNode() && getFlag(HasNameOrIsEditingTextFlag); }
-
bool isUserActionElement() const { return getFlag(IsUserActionElement); }
void setUserActionElement(bool flag) { setFlag(flag, IsUserActionElement); }
@@ -338,9 +336,8 @@
StyleChangeType styleChangeType() const { return static_cast<StyleChangeType>(m_nodeFlags & StyleChangeMask); }
bool childNeedsStyleRecalc() const { return getFlag(ChildNeedsStyleRecalcFlag); }
bool isLink() const { return getFlag(IsLinkFlag); }
- bool isEditingText() const { return isTextNode() && getFlag(HasNameOrIsEditingTextFlag); }
+ bool isEditingText() const { return getFlag(IsEditingTextFlag); }
- void setHasName(bool f) { ASSERT(!isTextNode()); setFlag(f, HasNameOrIsEditingTextFlag); }
void setChildNeedsStyleRecalc() { setFlag(ChildNeedsStyleRecalcFlag); }
void clearChildNeedsStyleRecalc() { clearFlag(ChildNeedsStyleRecalcFlag); }
@@ -661,7 +658,7 @@
SelfOrAncestorHasDirAutoFlag = 1 << 17,
- HasNameOrIsEditingTextFlag = 1 << 18,
+ IsEditingTextFlag = 1 << 18,
InNamedFlowFlag = 1 << 19,
HasSyntheticAttrChildNodesFlag = 1 << 20,
@@ -695,7 +692,7 @@
CreateSVGElement = CreateStyledElement | IsSVGFlag,
CreateDocument = CreateContainer | InDocumentFlag,
CreateInsertionPoint = CreateHTMLElement | NeedsShadowTreeWalkerFlag,
- CreateEditingText = CreateText | HasNameOrIsEditingTextFlag,
+ CreateEditingText = CreateText | IsEditingTextFlag,
};
Node(Document*, ConstructionType);