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

Side by Side Diff: third_party/WebKit/Source/core/dom/Node.h

Issue 2380503002: Revert of Storage of ComputedStyle separate from LayoutObject. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed conflicts Created 4 years, 2 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/Node.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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-2011, 2014 Apple Inc. All rights reserved. 5 * Copyright (C) 2004-2011, 2014 Apple Inc. All rights reserved.
6 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 6 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 virtual int maxCharacterOffset() const; 474 virtual int maxCharacterOffset() const;
475 475
476 // Whether or not a selection can be started in this object 476 // Whether or not a selection can be started in this object
477 virtual bool canStartSelection() const; 477 virtual bool canStartSelection() const;
478 478
479 // ------------------------------------------------------------------------- ---- 479 // ------------------------------------------------------------------------- ----
480 // Integration with layout tree 480 // Integration with layout tree
481 481
482 // As layoutObject() includes a branch you should avoid calling it repeatedl y in hot code paths. 482 // As layoutObject() includes a branch you should avoid calling it repeatedl y in hot code paths.
483 // Note that if a Node has a layoutObject, it's parentNode is guaranteed to have one as well. 483 // Note that if a Node has a layoutObject, it's parentNode is guaranteed to have one as well.
484 LayoutObject* layoutObject() const 484 LayoutObject* layoutObject() const { return hasRareData() ? m_data.m_rareDat a->layoutObject() : m_data.m_layoutObject; }
485 {
486 if (hasRareData())
487 return m_data.m_rareData->layoutObject();
488 return hasLayoutObject() ? m_data.m_layoutObject : nullptr;
489 }
490 void setLayoutObject(LayoutObject* layoutObject) 485 void setLayoutObject(LayoutObject* layoutObject)
491 { 486 {
492 if (hasRareData()) 487 if (hasRareData())
493 m_data.m_rareData->setLayoutObject(layoutObject); 488 m_data.m_rareData->setLayoutObject(layoutObject);
494 else 489 else
495 m_data.m_layoutObject = layoutObject; 490 m_data.m_layoutObject = layoutObject;
496 setFlag(static_cast<bool>(layoutObject), HasLayoutObjectFlag);
497 } 491 }
498 492
499 // Use these two methods with caution. 493 // Use these two methods with caution.
500 LayoutBox* layoutBox() const; 494 LayoutBox* layoutBox() const;
501 LayoutBoxModelObject* layoutBoxModelObject() const; 495 LayoutBoxModelObject* layoutBoxModelObject() const;
502 496
503 struct AttachContext { 497 struct AttachContext {
504 STACK_ALLOCATED(); 498 STACK_ALLOCATED();
505 ComputedStyle* resolvedStyle = nullptr; 499 ComputedStyle* resolvedStyle = nullptr;
506 bool performingReattach = false; 500 bool performingReattach = false;
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 693
700 HasNameOrIsEditingTextFlag = 1 << 23, 694 HasNameOrIsEditingTextFlag = 1 << 23,
701 HasWeakReferencesFlag = 1 << 24, 695 HasWeakReferencesFlag = 1 << 24,
702 V8CollectableDuringMinorGCFlag = 1 << 25, 696 V8CollectableDuringMinorGCFlag = 1 << 25,
703 HasEventTargetDataFlag = 1 << 26, 697 HasEventTargetDataFlag = 1 << 26,
704 AlreadySpellCheckedFlag = 1 << 27, 698 AlreadySpellCheckedFlag = 1 << 27,
705 699
706 V0CustomElementFlag = 1 << 28, 700 V0CustomElementFlag = 1 << 28,
707 V0CustomElementUpgradedFlag = 1 << 29, 701 V0CustomElementUpgradedFlag = 1 << 29,
708 702
709 HasLayoutObjectFlag = 1 << 30,
710
711 DefaultNodeFlags = IsFinishedParsingChildrenFlag | NeedsReattachStyleCha nge 703 DefaultNodeFlags = IsFinishedParsingChildrenFlag | NeedsReattachStyleCha nge
712 }; 704 };
713 705
714 // 1 bit remaining. 706 // 3 bits remaining.
715 707
716 bool getFlag(NodeFlags mask) const { return m_nodeFlags & mask; } 708 bool getFlag(NodeFlags mask) const { return m_nodeFlags & mask; }
717 void setFlag(bool f, NodeFlags mask) { m_nodeFlags = (m_nodeFlags & ~mask) | (-(int32_t)f & mask); } 709 void setFlag(bool f, NodeFlags mask) { m_nodeFlags = (m_nodeFlags & ~mask) | (-(int32_t)f & mask); }
718 void setFlag(NodeFlags mask) { m_nodeFlags |= mask; } 710 void setFlag(NodeFlags mask) { m_nodeFlags |= mask; }
719 void clearFlag(NodeFlags mask) { m_nodeFlags &= ~mask; } 711 void clearFlag(NodeFlags mask) { m_nodeFlags &= ~mask; }
720 712
721 protected: 713 protected:
722 enum ConstructionType { 714 enum ConstructionType {
723 CreateOther = DefaultNodeFlags, 715 CreateOther = DefaultNodeFlags,
724 CreateText = DefaultNodeFlags | IsTextFlag, 716 CreateText = DefaultNodeFlags | IsTextFlag,
(...skipping 11 matching lines...) Expand all
736 Node(TreeScope*, ConstructionType); 728 Node(TreeScope*, ConstructionType);
737 729
738 virtual void didMoveToNewDocument(Document& oldDocument); 730 virtual void didMoveToNewDocument(Document& oldDocument);
739 731
740 void addedEventListener(const AtomicString& eventType, RegisteredEventListen er&) override; 732 void addedEventListener(const AtomicString& eventType, RegisteredEventListen er&) override;
741 void removedEventListener(const AtomicString& eventType, const RegisteredEve ntListener&) override; 733 void removedEventListener(const AtomicString& eventType, const RegisteredEve ntListener&) override;
742 DispatchEventResult dispatchEventInternal(Event*) override; 734 DispatchEventResult dispatchEventInternal(Event*) override;
743 735
744 static void reattachWhitespaceSiblingsIfNeeded(Text* start); 736 static void reattachWhitespaceSiblingsIfNeeded(Text* start);
745 737
746 bool hasLayoutObject() const { return getFlag(HasLayoutObjectFlag); }
747 bool hasRareData() const { return getFlag(HasRareDataFlag); } 738 bool hasRareData() const { return getFlag(HasRareDataFlag); }
748 739
749 NodeRareData* rareData() const; 740 NodeRareData* rareData() const;
750 NodeRareData& ensureRareData(); 741 NodeRareData& ensureRareData();
751 742
752 void setHasCustomStyleCallbacks() { setFlag(true, HasCustomStyleCallbacksFla g); } 743 void setHasCustomStyleCallbacks() { setFlag(true, HasCustomStyleCallbacksFla g); }
753 744
754 void setTreeScope(TreeScope* scope) { m_treeScope = scope; } 745 void setTreeScope(TreeScope* scope) { m_treeScope = scope; }
755 746
756 // isTreeScopeInitialized() can be false 747 // isTreeScopeInitialized() can be false
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 HeapHashSet<Member<MutationObserverRegistration>>* transientMutationObserver Registry(); 782 HeapHashSet<Member<MutationObserverRegistration>>* transientMutationObserver Registry();
792 783
793 uint32_t m_nodeFlags; 784 uint32_t m_nodeFlags;
794 Member<ContainerNode> m_parentOrShadowHostNode; 785 Member<ContainerNode> m_parentOrShadowHostNode;
795 Member<TreeScope> m_treeScope; 786 Member<TreeScope> m_treeScope;
796 Member<Node> m_previous; 787 Member<Node> m_previous;
797 Member<Node> m_next; 788 Member<Node> m_next;
798 // When a node has rare data we move the layoutObject into the rare data. 789 // When a node has rare data we move the layoutObject into the rare data.
799 union DataUnion { 790 union DataUnion {
800 DataUnion() : m_layoutObject(nullptr) { } 791 DataUnion() : m_layoutObject(nullptr) { }
801 ComputedStyle* m_computedStyle;
802 // LayoutObjects are fully owned by their DOM node. See LayoutObject's 792 // LayoutObjects are fully owned by their DOM node. See LayoutObject's
803 // LIFETIME documentation section. 793 // LIFETIME documentation section.
804 LayoutObject* m_layoutObject; 794 LayoutObject* m_layoutObject;
805 NodeRareDataBase* m_rareData; 795 NodeRareDataBase* m_rareData;
806 } m_data; 796 } m_data;
807 }; 797 };
808 798
809 inline void Node::setParentOrShadowHostNode(ContainerNode* parent) 799 inline void Node::setParentOrShadowHostNode(ContainerNode* parent)
810 { 800 {
811 DCHECK(isMainThread()); 801 DCHECK(isMainThread());
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 } // namespace blink 874 } // namespace blink
885 875
886 #ifndef NDEBUG 876 #ifndef NDEBUG
887 // Outside the WebCore namespace for ease of invocation from gdb. 877 // Outside the WebCore namespace for ease of invocation from gdb.
888 void showNode(const blink::Node*); 878 void showNode(const blink::Node*);
889 void showTree(const blink::Node*); 879 void showTree(const blink::Node*);
890 void showNodePath(const blink::Node*); 880 void showNodePath(const blink::Node*);
891 #endif 881 #endif
892 882
893 #endif // Node_h 883 #endif // Node_h
OLDNEW
« 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