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

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: compressed Node::setLayoutObject and added Node::setComputedStyle method Created 4 years, 7 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/Node.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 acd595fb9729ad9112a3489c70eeabbbe650027f..339b797de2209082d16267e0c08657da30baf1dd 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,
@@ -111,13 +111,17 @@ class NodeRareDataBase {
public:
LayoutObject* layoutObject() const { return m_layoutObject; }
void setLayoutObject(LayoutObject* layoutObject) { m_layoutObject = layoutObject; }
+ ComputedStyle* computedStyle() const { return m_computedStyle; }
+ void setComputedStyle(ComputedStyle* computedStyle) { m_computedStyle = computedStyle; }
protected:
NodeRareDataBase(LayoutObject* layoutObject)
- : m_layoutObject(layoutObject)
+ : m_computedStyle(nullptr)
+ , m_layoutObject(layoutObject)
{ }
protected:
+ ComputedStyle* m_computedStyle;
Timothy Loh 2016/05/26 07:06:37 This should be a RefPtr<ComputedStyle> and should
// LayoutObjects are fully owned by their DOM node. See LayoutObject's
// LIFETIME documentation section.
LayoutObject* m_layoutObject;
@@ -516,14 +520,15 @@ 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; }
- void setLayoutObject(LayoutObject* layoutObject)
+ LayoutObject* layoutObject() const
{
if (hasRareData())
- m_data.m_rareData->setLayoutObject(layoutObject);
+ return m_data.m_rareData->layoutObject();
else
- m_data.m_layoutObject = layoutObject;
+ return hasLayoutObject() ? m_data.m_layoutObject : nullptr;
}
+ void setLayoutObject(LayoutObject*);
+ void clearStyleAndLayoutObject();
// Use these two methods with caution.
LayoutBox* layoutBox() const;
@@ -556,6 +561,7 @@ public:
// Wrapper for nodes that don't have a layoutObject, but still cache the style (like HTMLOptionElement).
ComputedStyle* mutableComputedStyle() const;
const ComputedStyle* computedStyle() const;
+ void setComputedStyle(ComputedStyle*);
const ComputedStyle* parentComputedStyle() const;
const ComputedStyle& computedStyleRef() const;
@@ -689,49 +695,50 @@ 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,
@@ -771,6 +778,7 @@ protected:
static void reattachWhitespaceSiblingsIfNeeded(Text* start);
+ bool hasLayoutObject() const { return getFlag(HasLayoutObjectFlag); }
bool hasRareData() const { return getFlag(HasRareDataFlag); }
NodeRareData* rareData() const;
@@ -826,7 +834,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) { }
+ ComputedStyle* m_computedStyle;
Timothy Loh 2016/05/26 07:06:37 This probably needs lifetime management (i.e. refs
// 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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698