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

Side by Side 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, 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved.
6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 if (editableLevel == RichlyEditable) 585 if (editableLevel == RichlyEditable)
586 return false; 586 return false;
587 587
588 // FIXME(dmazzoni): support ScopedAXObjectCache (crbug/489851). 588 // FIXME(dmazzoni): support ScopedAXObjectCache (crbug/489851).
589 if (AXObjectCache* cache = document().existingAXObjectCache()) 589 if (AXObjectCache* cache = document().existingAXObjectCache())
590 return cache->rootAXEditableElement(this); 590 return cache->rootAXEditableElement(this);
591 591
592 return false; 592 return false;
593 } 593 }
594 594
595 void Node::setLayoutObject(LayoutObject* layoutObject)
596 {
597 DCHECK(!layoutObject->style() || layoutObject->style() == computedStyle());
598 // this will probably cause a crash because of the <option> case
599 // if (layoutObject)
600 // layoutObject->setStyleInternal(computedStyle());
601 if (hasRareData()) {
602 if (hasLayoutObject()) {
603 if (this->layoutObject()->style()) {
604 if (layoutObject) {
605 layoutObject->setStyleInternal(this->layoutObject()->mutable Style());
606 } else {
607 m_data.m_rareData->setComputedStyle(this->layoutObject()->mu tableStyle());
608 }
609 }
610 } else if (m_data.m_rareData->computedStyle() && layoutObject) {
611 layoutObject->setStyleInternal(m_data.m_rareData->computedStyle());
612 m_data.m_rareData->setComputedStyle(nullptr);
613 }
614 m_data.m_rareData->setLayoutObject(layoutObject);
615 } else {
616 if (hasLayoutObject()) {
617 if (this->layoutObject()->style()) {
618 if (layoutObject) {
619 layoutObject->setStyleInternal(this->layoutObject()->mutable Style());
620 m_data.m_layoutObject = layoutObject;
621 } else {
622 m_data.m_computedStyle = this->layoutObject()->mutableStyle( );
623 }
624 } else {
625 m_data.m_layoutObject = layoutObject;
626 }
627 } else {
628 if (m_data.m_computedStyle && layoutObject) {
629 layoutObject->setStyleInternal(m_data.m_computedStyle);
630 }
631 m_data.m_layoutObject = layoutObject;
632 }
633 // if (!(hasLayoutObject() && this->layoutObject()->style() && !layoutOb ject))
634 // m_data.m_layoutObject = layoutObject;
635 }
636
637 if (layoutObject) {
638 setFlag(HasLayoutObjectFlag);
639 } else {
640 clearFlag(HasLayoutObjectFlag);
641 }
642 }
643
644 void Node::clearStyleAndLayoutObject()
645 {
646 if (hasRareData()) {
647 m_data.m_rareData->setLayoutObject(nullptr);
648 m_data.m_rareData->setComputedStyle(nullptr);
649 } else {
650 // Will nullify the data regardless of whether it is a LayoutObject or a ComputedStyle
651 m_data.m_layoutObject = nullptr;
652 }
653 clearFlag(HasLayoutObjectFlag);
654 }
655
595 LayoutBox* Node::layoutBox() const 656 LayoutBox* Node::layoutBox() const
596 { 657 {
597 LayoutObject* layoutObject = this->layoutObject(); 658 LayoutObject* layoutObject = this->layoutObject();
598 return layoutObject && layoutObject->isBox() ? toLayoutBox(layoutObject) : n ullptr; 659 return layoutObject && layoutObject->isBox() ? toLayoutBox(layoutObject) : n ullptr;
599 } 660 }
600 661
601 LayoutBoxModelObject* Node::layoutBoxModelObject() const 662 LayoutBoxModelObject* Node::layoutBoxModelObject() const
602 { 663 {
603 LayoutObject* layoutObject = this->layoutObject(); 664 LayoutObject* layoutObject = this->layoutObject();
604 return layoutObject && layoutObject->isBoxModelObject() ? toLayoutBoxModelOb ject(layoutObject) : nullptr; 665 return layoutObject && layoutObject->isBoxModelObject() ? toLayoutBoxModelOb ject(layoutObject) : nullptr;
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
924 cache->updateCacheAfterNodeIsAttached(this); 985 cache->updateCacheAfterNodeIsAttached(this);
925 } 986 }
926 987
927 void Node::detach(const AttachContext& context) 988 void Node::detach(const AttachContext& context)
928 { 989 {
929 DCHECK(document().lifecycle().stateAllowsDetach()); 990 DCHECK(document().lifecycle().stateAllowsDetach());
930 DocumentLifecycle::DetachScope willDetach(document().lifecycle()); 991 DocumentLifecycle::DetachScope willDetach(document().lifecycle());
931 992
932 if (layoutObject()) 993 if (layoutObject())
933 layoutObject()->destroyAndCleanupAnonymousWrappers(); 994 layoutObject()->destroyAndCleanupAnonymousWrappers();
934 setLayoutObject(nullptr); 995 clearStyleAndLayoutObject();
935 setStyleChange(NeedsReattachStyleChange); 996 setStyleChange(NeedsReattachStyleChange);
936 clearChildNeedsStyleInvalidation(); 997 clearChildNeedsStyleInvalidation();
937 } 998 }
938 999
939 void Node::reattachWhitespaceSiblingsIfNeeded(Text* start) 1000 void Node::reattachWhitespaceSiblingsIfNeeded(Text* start)
940 { 1001 {
941 ScriptForbiddenScope forbidScriptDuringRawIteration; 1002 ScriptForbiddenScope forbidScriptDuringRawIteration;
942 for (Node* sibling = start; sibling; sibling = sibling->nextSibling()) { 1003 for (Node* sibling = start; sibling; sibling = sibling->nextSibling()) {
943 if (sibling->isTextNode() && toText(sibling)->containsOnlyWhitespace()) { 1004 if (sibling->isTextNode() && toText(sibling)->containsOnlyWhitespace()) {
944 bool hadLayoutObject = !!sibling->layoutObject(); 1005 bool hadLayoutObject = !!sibling->layoutObject();
(...skipping 1530 matching lines...) Expand 10 before | Expand all | Expand 10 after
2475 2536
2476 void showNodePath(const blink::Node* node) 2537 void showNodePath(const blink::Node* node)
2477 { 2538 {
2478 if (node) 2539 if (node)
2479 node->showNodePathForThis(); 2540 node->showNodePathForThis();
2480 else 2541 else
2481 fprintf(stderr, "Cannot showNodePath for (nil)\n"); 2542 fprintf(stderr, "Cannot showNodePath for (nil)\n");
2482 } 2543 }
2483 2544
2484 #endif 2545 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698