| 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();
|
| }
|
|
|