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

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

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
Index: third_party/WebKit/Source/core/dom/Node.cpp
diff --git a/third_party/WebKit/Source/core/dom/Node.cpp b/third_party/WebKit/Source/core/dom/Node.cpp
index 9565e1f766926b92b9cf56ffaf5b471310b59f08..cefce86da630022ab2b72b615f1d7230a09b6452 100644
--- a/third_party/WebKit/Source/core/dom/Node.cpp
+++ b/third_party/WebKit/Source/core/dom/Node.cpp
@@ -592,6 +592,67 @@ bool Node::isEditableToAccessibility(EditableLevel editableLevel) const
return false;
}
+void Node::setLayoutObject(LayoutObject* layoutObject)
+{
+ DCHECK(!layoutObject->style() || layoutObject->style() == computedStyle());
+ // this will probably cause a crash because of the <option> case
+ // if (layoutObject)
+ // layoutObject->setStyleInternal(computedStyle());
+ if (hasRareData()) {
+ if (hasLayoutObject()) {
+ if (this->layoutObject()->style()) {
+ if (layoutObject) {
+ layoutObject->setStyleInternal(this->layoutObject()->mutableStyle());
+ } else {
+ m_data.m_rareData->setComputedStyle(this->layoutObject()->mutableStyle());
+ }
+ }
+ } else if (m_data.m_rareData->computedStyle() && layoutObject) {
+ layoutObject->setStyleInternal(m_data.m_rareData->computedStyle());
+ m_data.m_rareData->setComputedStyle(nullptr);
+ }
+ m_data.m_rareData->setLayoutObject(layoutObject);
+ } else {
+ if (hasLayoutObject()) {
+ if (this->layoutObject()->style()) {
+ if (layoutObject) {
+ layoutObject->setStyleInternal(this->layoutObject()->mutableStyle());
+ m_data.m_layoutObject = layoutObject;
+ } else {
+ m_data.m_computedStyle = this->layoutObject()->mutableStyle();
+ }
+ } else {
+ m_data.m_layoutObject = layoutObject;
+ }
+ } else {
+ if (m_data.m_computedStyle && layoutObject) {
+ layoutObject->setStyleInternal(m_data.m_computedStyle);
+ }
+ m_data.m_layoutObject = layoutObject;
+ }
+ // if (!(hasLayoutObject() && this->layoutObject()->style() && !layoutObject))
+ // m_data.m_layoutObject = layoutObject;
+ }
+
+ if (layoutObject) {
+ setFlag(HasLayoutObjectFlag);
+ } else {
+ clearFlag(HasLayoutObjectFlag);
+ }
+}
+
+void Node::clearStyleAndLayoutObject()
+{
+ if (hasRareData()) {
+ m_data.m_rareData->setLayoutObject(nullptr);
+ m_data.m_rareData->setComputedStyle(nullptr);
+ } else {
+ // Will nullify the data regardless of whether it is a LayoutObject or a ComputedStyle
+ m_data.m_layoutObject = nullptr;
+ }
+ clearFlag(HasLayoutObjectFlag);
+}
+
LayoutBox* Node::layoutBox() const
{
LayoutObject* layoutObject = this->layoutObject();
@@ -931,7 +992,7 @@ void Node::detach(const AttachContext& context)
if (layoutObject())
layoutObject()->destroyAndCleanupAnonymousWrappers();
- setLayoutObject(nullptr);
+ clearStyleAndLayoutObject();
setStyleChange(NeedsReattachStyleChange);
clearChildNeedsStyleInvalidation();
}

Powered by Google App Engine
This is Rietveld 408576698