Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(293)

Unified Diff: third_party/WebKit/Source/core/dom/Node.h

Issue 1962953002: Storage of ComputedStyle separate from LayoutObject. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed ComputedStyle from NodeRareData, instead use existing ComputedStyle from ElementRareData Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/dom/Node.h
diff --git a/third_party/WebKit/Source/core/dom/Node.h b/third_party/WebKit/Source/core/dom/Node.h
index fedf63e639b20271dd49a9d7fb12d86cfa38f785..118eb976970bf6808863de4834aef3842ee1bff3 100644
--- a/third_party/WebKit/Source/core/dom/Node.h
+++ b/third_party/WebKit/Source/core/dom/Node.h
@@ -90,7 +90,7 @@ class TagCollection;
class Text;
class TouchEvent;
-const int nodeStyleChangeShift = 19;
+const int nodeStyleChangeShift = 20;
enum StyleChangeType {
NoStyleChange = 0,
@@ -519,13 +519,22 @@ public:
// As layoutObject() includes a branch you should avoid calling it repeatedly in hot code paths.
// Note that if a Node has a layoutObject, it's parentNode is guaranteed to have one as well.
- LayoutObject* layoutObject() const { return hasRareData() ? m_data.m_rareData->layoutObject() : m_data.m_layoutObject; }
+ LayoutObject* layoutObject() const
+ {
+ if (hasRareData())
+ return m_data.m_rareData->layoutObject();
+ return hasLayoutObject() ? m_data.m_layoutObject : nullptr;
+ }
void setLayoutObject(LayoutObject* layoutObject)
{
if (hasRareData())
m_data.m_rareData->setLayoutObject(layoutObject);
else
m_data.m_layoutObject = layoutObject;
+ if (layoutObject)
+ setFlag(HasLayoutObjectFlag);
+ else
+ clearFlag(HasLayoutObjectFlag);
}
// Use these two methods with caution.
@@ -693,57 +702,58 @@ public:
private:
enum NodeFlags {
- HasRareDataFlag = 1,
+ HasLayoutObjectFlag = 1,
+ HasRareDataFlag = 1 << 1,
// Node type flags. These never change once created.
- IsTextFlag = 1 << 1,
- IsContainerFlag = 1 << 2,
- IsElementFlag = 1 << 3,
- IsHTMLFlag = 1 << 4,
- IsSVGFlag = 1 << 5,
- IsDocumentFragmentFlag = 1 << 6,
- IsInsertionPointFlag = 1 << 7,
+ IsTextFlag = 1 << 2,
+ IsContainerFlag = 1 << 3,
+ IsElementFlag = 1 << 4,
+ IsHTMLFlag = 1 << 5,
+ IsSVGFlag = 1 << 6,
+ IsDocumentFragmentFlag = 1 << 7,
+ IsInsertionPointFlag = 1 << 8,
// Changes based on if the element should be treated like a link,
// ex. When setting the href attribute on an <a>.
- IsLinkFlag = 1 << 8,
+ IsLinkFlag = 1 << 9,
// Changes based on :hover, :active and :focus state.
- IsUserActionElementFlag = 1 << 9,
+ IsUserActionElementFlag = 1 << 10,
// Tree state flags. These change when the element is added/removed
// from a DOM tree.
- InDocumentFlag = 1 << 10,
- IsInShadowTreeFlag = 1 << 11,
+ InDocumentFlag = 1 << 11,
+ IsInShadowTreeFlag = 1 << 12,
// Set by the parser when the children are done parsing.
- IsFinishedParsingChildrenFlag = 1 << 12,
+ IsFinishedParsingChildrenFlag = 1 << 13,
// Flags related to recalcStyle.
- SVGFilterNeedsLayerUpdateFlag = 1 << 13,
- HasCustomStyleCallbacksFlag = 1 << 14,
- ChildNeedsStyleInvalidationFlag = 1 << 15,
- NeedsStyleInvalidationFlag = 1 << 16,
- ChildNeedsDistributionRecalcFlag = 1 << 17,
- ChildNeedsStyleRecalcFlag = 1 << 18,
+ SVGFilterNeedsLayerUpdateFlag = 1 << 14,
+ HasCustomStyleCallbacksFlag = 1 << 15,
+ ChildNeedsStyleInvalidationFlag = 1 << 16,
+ NeedsStyleInvalidationFlag = 1 << 17,
+ ChildNeedsDistributionRecalcFlag = 1 << 18,
+ ChildNeedsStyleRecalcFlag = 1 << 19,
StyleChangeMask = 1 << nodeStyleChangeShift | 1 << (nodeStyleChangeShift + 1),
- CustomElementFlag = 1 << 21,
- CustomElementCustomFlag = 1 << 22,
+ CustomElementFlag = 1 << 22,
+ CustomElementCustomFlag = 1 << 23,
- HasNameOrIsEditingTextFlag = 1 << 23,
- HasWeakReferencesFlag = 1 << 24,
- V8CollectableDuringMinorGCFlag = 1 << 25,
- HasEventTargetDataFlag = 1 << 26,
- AlreadySpellCheckedFlag = 1 << 27,
+ HasNameOrIsEditingTextFlag = 1 << 24,
+ HasWeakReferencesFlag = 1 << 25,
+ V8CollectableDuringMinorGCFlag = 1 << 26,
+ HasEventTargetDataFlag = 1 << 27,
+ AlreadySpellCheckedFlag = 1 << 28,
- V0CustomElementFlag = 1 << 28,
- V0CustomElementUpgradedFlag = 1 << 29,
+ V0CustomElementFlag = 1 << 29,
+ V0CustomElementUpgradedFlag = 1 << 30,
DefaultNodeFlags = IsFinishedParsingChildrenFlag | NeedsReattachStyleChange
};
- // 3 bits remaining.
+ // 1 bit remaining.
bool getFlag(NodeFlags mask) const { return m_nodeFlags & mask; }
void setFlag(bool f, NodeFlags mask) { m_nodeFlags = (m_nodeFlags & ~mask) | (-(int32_t)f & mask); }
@@ -775,6 +785,7 @@ protected:
static void reattachWhitespaceSiblingsIfNeeded(Text* start);
+ bool hasLayoutObject() const { return getFlag(HasLayoutObjectFlag); }
bool hasRareData() const { return getFlag(HasRareDataFlag); }
NodeRareData* rareData() const;
@@ -832,7 +843,8 @@ private:
Member<Node> m_next;
// When a node has rare data we move the layoutObject into the rare data.
union DataUnion {
- DataUnion() : m_layoutObject(nullptr) { }
+ DataUnion() : m_computedStyle(nullptr) { }
Timothy Loh 2016/06/23 23:58:02 I'd leave this as initializing the LayoutObject (i
+ ComputedStyle* m_computedStyle;
// LayoutObjects are fully owned by their DOM node. See LayoutObject's
// LIFETIME documentation section.
LayoutObject* m_layoutObject;
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/Node.cpp » ('j') | third_party/WebKit/Source/core/dom/NodeRareData.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698