Chromium Code Reviews| OLD | NEW |
|---|---|
| 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. | 6 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. |
| 7 * (http://www.torchmobile.com/) | 7 * (http://www.torchmobile.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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 77 class StyleChangeReasonForTracing; | 77 class StyleChangeReasonForTracing; |
| 78 class Text; | 78 class Text; |
| 79 class TouchEvent; | 79 class TouchEvent; |
| 80 | 80 |
| 81 const int nodeStyleChangeShift = 18; | 81 const int nodeStyleChangeShift = 18; |
| 82 const int nodeCustomElementShift = 20; | 82 const int nodeCustomElementShift = 20; |
| 83 | 83 |
| 84 enum StyleChangeType { | 84 enum StyleChangeType { |
| 85 NoStyleChange = 0, | 85 NoStyleChange = 0, |
| 86 LocalStyleChange = 1 << nodeStyleChangeShift, | 86 LocalStyleChange = 1 << nodeStyleChangeShift, |
| 87 SubtreeStyleChange = 2 << nodeStyleChangeShift, | 87 SubtreeStyleChange = 2 << nodeStyleChangeShift |
|
nainar
2016/11/29 06:13:39
Redundant information this is encapsulated in Need
| |
| 88 NeedsReattachStyleChange = 3 << nodeStyleChangeShift, | |
| 89 }; | 88 }; |
| 90 | 89 |
| 91 enum class CustomElementState { | 90 enum class CustomElementState { |
| 92 // https://dom.spec.whatwg.org/#concept-element-custom-element-state | 91 // https://dom.spec.whatwg.org/#concept-element-custom-element-state |
| 93 Uncustomized = 0, | 92 Uncustomized = 0, |
| 94 Custom = 1 << nodeCustomElementShift, | 93 Custom = 1 << nodeCustomElementShift, |
| 95 Undefined = 2 << nodeCustomElementShift, | 94 Undefined = 2 << nodeCustomElementShift, |
| 96 Failed = 3 << nodeCustomElementShift, | 95 Failed = 3 << nodeCustomElementShift, |
| 97 | 96 |
| 98 NotDefinedFlag = 2 << nodeCustomElementShift, | 97 NotDefinedFlag = 2 << nodeCustomElementShift, |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 389 } | 388 } |
| 390 // Note: As a shadow host whose root with delegatesFocus=false may become | 389 // Note: As a shadow host whose root with delegatesFocus=false may become |
| 391 // focused state when an inner element gets focused, in that case more than | 390 // focused state when an inner element gets focused, in that case more than |
| 392 // one elements in a document can return true for |isFocused()|. Use | 391 // one elements in a document can return true for |isFocused()|. Use |
| 393 // Element::isFocusedElementInDocument() or Document::focusedElement() to | 392 // Element::isFocusedElementInDocument() or Document::focusedElement() to |
| 394 // check which element is exactly focused. | 393 // check which element is exactly focused. |
| 395 bool isFocused() const { | 394 bool isFocused() const { |
| 396 return isUserActionElement() && isUserActionElementFocused(); | 395 return isUserActionElement() && isUserActionElementFocused(); |
| 397 } | 396 } |
| 398 | 397 |
| 399 bool needsAttach() const { | |
|
nainar
2016/11/29 06:13:39
Redundant information this is encapsulated in need
| |
| 400 return getStyleChangeType() == NeedsReattachStyleChange; | |
| 401 } | |
| 402 bool needsStyleRecalc() const { | 398 bool needsStyleRecalc() const { |
| 403 return getStyleChangeType() != NoStyleChange; | 399 return getStyleChangeType() != NoStyleChange; |
| 404 } | 400 } |
| 405 StyleChangeType getStyleChangeType() const { | 401 StyleChangeType getStyleChangeType() const { |
| 406 return static_cast<StyleChangeType>(m_nodeFlags & StyleChangeMask); | 402 return static_cast<StyleChangeType>(m_nodeFlags & StyleChangeMask); |
| 407 } | 403 } |
| 408 bool childNeedsStyleRecalc() const { | 404 bool childNeedsStyleRecalc() const { |
| 409 return getFlag(ChildNeedsStyleRecalcFlag); | 405 return getFlag(ChildNeedsStyleRecalcFlag); |
| 410 } | 406 } |
| 411 bool isLink() const { return getFlag(IsLinkFlag); } | 407 bool isLink() const { return getFlag(IsLinkFlag); } |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 423 | 419 |
| 424 void setNeedsStyleRecalc(StyleChangeType, const StyleChangeReasonForTracing&); | 420 void setNeedsStyleRecalc(StyleChangeType, const StyleChangeReasonForTracing&); |
| 425 void clearNeedsStyleRecalc(); | 421 void clearNeedsStyleRecalc(); |
| 426 | 422 |
| 427 bool needsReattachLayoutTree() { return getFlag(NeedsReattachLayoutTree); } | 423 bool needsReattachLayoutTree() { return getFlag(NeedsReattachLayoutTree); } |
| 428 bool childNeedsReattachLayoutTree() { | 424 bool childNeedsReattachLayoutTree() { |
| 429 return getFlag(ChildNeedsReattachLayoutTree); | 425 return getFlag(ChildNeedsReattachLayoutTree); |
| 430 } | 426 } |
| 431 | 427 |
| 432 void setNeedsReattachLayoutTree(); | 428 void setNeedsReattachLayoutTree(); |
| 429 void setLocalNeedsReattachLayoutTree() { setFlag(NeedsReattachLayoutTree); } | |
| 433 void setChildNeedsReattachLayoutTree() { | 430 void setChildNeedsReattachLayoutTree() { |
| 434 setFlag(ChildNeedsReattachLayoutTree); | 431 setFlag(ChildNeedsReattachLayoutTree); |
| 435 } | 432 } |
| 436 | 433 |
| 437 void clearNeedsReattachLayoutTree() { clearFlag(NeedsReattachLayoutTree); } | 434 void clearNeedsReattachLayoutTree() { clearFlag(NeedsReattachLayoutTree); } |
| 438 void clearChildNeedsReattachLayoutTree() { | 435 void clearChildNeedsReattachLayoutTree() { |
| 439 clearFlag(ChildNeedsReattachLayoutTree); | 436 clearFlag(ChildNeedsReattachLayoutTree); |
| 440 } | 437 } |
| 441 | 438 |
| 442 void markAncestorsWithChildNeedsReattachLayoutTree(); | 439 void markAncestorsWithChildNeedsReattachLayoutTree(); |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 825 | 822 |
| 826 HasNameOrIsEditingTextFlag = 1 << 22, | 823 HasNameOrIsEditingTextFlag = 1 << 22, |
| 827 HasEventTargetDataFlag = 1 << 23, | 824 HasEventTargetDataFlag = 1 << 23, |
| 828 | 825 |
| 829 V0CustomElementFlag = 1 << 24, | 826 V0CustomElementFlag = 1 << 24, |
| 830 V0CustomElementUpgradedFlag = 1 << 25, | 827 V0CustomElementUpgradedFlag = 1 << 25, |
| 831 | 828 |
| 832 NeedsReattachLayoutTree = 1 << 26, | 829 NeedsReattachLayoutTree = 1 << 26, |
| 833 ChildNeedsReattachLayoutTree = 1 << 27, | 830 ChildNeedsReattachLayoutTree = 1 << 27, |
| 834 | 831 |
| 835 DefaultNodeFlags = IsFinishedParsingChildrenFlag | NeedsReattachStyleChange | 832 DefaultNodeFlags = IsFinishedParsingChildrenFlag |
| 836 }; | 833 }; |
| 837 | 834 |
| 838 // 4 bits remaining. | 835 // 4 bits remaining. |
| 839 | 836 |
| 840 bool getFlag(NodeFlags mask) const { return m_nodeFlags & mask; } | 837 bool getFlag(NodeFlags mask) const { return m_nodeFlags & mask; } |
| 841 void setFlag(bool f, NodeFlags mask) { | 838 void setFlag(bool f, NodeFlags mask) { |
| 842 m_nodeFlags = (m_nodeFlags & ~mask) | (-(int32_t)f & mask); | 839 m_nodeFlags = (m_nodeFlags & ~mask) | (-(int32_t)f & mask); |
| 843 } | 840 } |
| 844 void setFlag(NodeFlags mask) { m_nodeFlags |= mask; } | 841 void setFlag(NodeFlags mask) { m_nodeFlags |= mask; } |
| 845 void clearFlag(NodeFlags mask) { m_nodeFlags &= ~mask; } | 842 void clearFlag(NodeFlags mask) { m_nodeFlags &= ~mask; } |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 961 inline ContainerNode* Node::parentOrShadowHostNode() const { | 958 inline ContainerNode* Node::parentOrShadowHostNode() const { |
| 962 DCHECK(isMainThread()); | 959 DCHECK(isMainThread()); |
| 963 return m_parentOrShadowHostNode; | 960 return m_parentOrShadowHostNode; |
| 964 } | 961 } |
| 965 | 962 |
| 966 inline ContainerNode* Node::parentNode() const { | 963 inline ContainerNode* Node::parentNode() const { |
| 967 return isShadowRoot() ? nullptr : parentOrShadowHostNode(); | 964 return isShadowRoot() ? nullptr : parentOrShadowHostNode(); |
| 968 } | 965 } |
| 969 | 966 |
| 970 inline void Node::lazyReattachIfAttached() { | 967 inline void Node::lazyReattachIfAttached() { |
| 971 if (getStyleChangeType() == NeedsReattachStyleChange) | 968 if (needsReattachLayoutTree()) |
| 972 return; | 969 return; |
| 973 if (!inActiveDocument()) | 970 if (!inActiveDocument()) |
| 974 return; | 971 return; |
| 975 | 972 |
| 976 AttachContext context; | 973 AttachContext context; |
| 977 context.performingReattach = true; | 974 context.performingReattach = true; |
| 978 | 975 |
| 979 detachLayoutTree(context); | 976 detachLayoutTree(context); |
| 980 markAncestorsWithChildNeedsStyleRecalc(); | 977 markAncestorsWithChildNeedsReattachLayoutTree(); |
|
nainar
2016/11/29 06:13:39
Changed to the equivalent reattachLayoutTree funct
| |
| 981 } | 978 } |
| 982 | 979 |
| 983 inline bool Node::shouldCallRecalcStyle(StyleRecalcChange change) { | 980 inline bool Node::shouldCallRecalcStyle(StyleRecalcChange change) { |
| 984 return change >= IndependentInherit || needsStyleRecalc() || | 981 return change >= IndependentInherit || needsStyleRecalc() || |
| 985 childNeedsStyleRecalc(); | 982 childNeedsStyleRecalc(); |
| 986 } | 983 } |
| 987 | 984 |
| 988 inline bool isTreeScopeRoot(const Node* node) { | 985 inline bool isTreeScopeRoot(const Node* node) { |
| 989 return !node || node->isDocumentNode() || node->isShadowRoot(); | 986 return !node || node->isDocumentNode() || node->isShadowRoot(); |
| 990 } | 987 } |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 1020 } // namespace blink | 1017 } // namespace blink |
| 1021 | 1018 |
| 1022 #ifndef NDEBUG | 1019 #ifndef NDEBUG |
| 1023 // Outside the WebCore namespace for ease of invocation from gdb. | 1020 // Outside the WebCore namespace for ease of invocation from gdb. |
| 1024 void showNode(const blink::Node*); | 1021 void showNode(const blink::Node*); |
| 1025 void showTree(const blink::Node*); | 1022 void showTree(const blink::Node*); |
| 1026 void showNodePath(const blink::Node*); | 1023 void showNodePath(const blink::Node*); |
| 1027 #endif | 1024 #endif |
| 1028 | 1025 |
| 1029 #endif // Node_h | 1026 #endif // Node_h |
| OLD | NEW |