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

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

Issue 2473743003: Call Element::rebuildLayoutTree from Document::updateStyle directly (Closed)
Patch Set: Mirror setChildNeedsStyleRecalc and markAncestorsWithNeedsReattachLayoutTree with setChildNeedsReat… Created 3 years, 10 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-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 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 // Note: As a shadow host whose root with delegatesFocus=false may become 387 // Note: As a shadow host whose root with delegatesFocus=false may become
388 // focused state when an inner element gets focused, in that case more than 388 // focused state when an inner element gets focused, in that case more than
389 // one elements in a document can return true for |isFocused()|. Use 389 // one elements in a document can return true for |isFocused()|. Use
390 // Element::isFocusedElementInDocument() or Document::focusedElement() to 390 // Element::isFocusedElementInDocument() or Document::focusedElement() to
391 // check which element is exactly focused. 391 // check which element is exactly focused.
392 bool isFocused() const { 392 bool isFocused() const {
393 return isUserActionElement() && isUserActionElementFocused(); 393 return isUserActionElement() && isUserActionElementFocused();
394 } 394 }
395 395
396 bool needsAttach() const { 396 bool needsAttach() const {
397 return getStyleChangeType() == NeedsReattachStyleChange; 397 return getStyleChangeType() == NeedsReattachStyleChange ||
398 getFlag(NeedsReattachLayoutTree);
398 } 399 }
399 bool needsStyleRecalc() const { 400 bool needsStyleRecalc() const {
400 return getStyleChangeType() != NoStyleChange; 401 return getStyleChangeType() != NoStyleChange;
401 } 402 }
402 StyleChangeType getStyleChangeType() const { 403 StyleChangeType getStyleChangeType() const {
403 return static_cast<StyleChangeType>(m_nodeFlags & StyleChangeMask); 404 return static_cast<StyleChangeType>(m_nodeFlags & StyleChangeMask);
404 } 405 }
405 bool childNeedsStyleRecalc() const { 406 bool childNeedsStyleRecalc() const {
406 return getFlag(ChildNeedsStyleRecalcFlag); 407 return getFlag(ChildNeedsStyleRecalcFlag);
407 } 408 }
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 824
824 HasNameOrIsEditingTextFlag = 1 << 22, 825 HasNameOrIsEditingTextFlag = 1 << 22,
825 HasEventTargetDataFlag = 1 << 23, 826 HasEventTargetDataFlag = 1 << 23,
826 827
827 V0CustomElementFlag = 1 << 24, 828 V0CustomElementFlag = 1 << 24,
828 V0CustomElementUpgradedFlag = 1 << 25, 829 V0CustomElementUpgradedFlag = 1 << 25,
829 830
830 NeedsReattachLayoutTree = 1 << 26, 831 NeedsReattachLayoutTree = 1 << 26,
831 ChildNeedsReattachLayoutTree = 1 << 27, 832 ChildNeedsReattachLayoutTree = 1 << 27,
832 833
833 DefaultNodeFlags = IsFinishedParsingChildrenFlag | NeedsReattachStyleChange 834 DefaultNodeFlags = IsFinishedParsingChildrenFlag |
835 NeedsReattachStyleChange |
836 NeedsReattachLayoutTree
834 }; 837 };
835 838
836 // 4 bits remaining. 839 // 4 bits remaining.
837 840
838 bool getFlag(NodeFlags mask) const { return m_nodeFlags & mask; } 841 bool getFlag(NodeFlags mask) const { return m_nodeFlags & mask; }
839 void setFlag(bool f, NodeFlags mask) { 842 void setFlag(bool f, NodeFlags mask) {
840 m_nodeFlags = (m_nodeFlags & ~mask) | (-(int32_t)f & mask); 843 m_nodeFlags = (m_nodeFlags & ~mask) | (-(int32_t)f & mask);
841 } 844 }
842 void setFlag(NodeFlags mask) { m_nodeFlags |= mask; } 845 void setFlag(NodeFlags mask) { m_nodeFlags |= mask; }
843 void clearFlag(NodeFlags mask) { m_nodeFlags &= ~mask; } 846 void clearFlag(NodeFlags mask) { m_nodeFlags &= ~mask; }
844 847
845 // TODO(mustaq): This is a hack to fix sites with flash objects. We should 848 // TODO(mustaq): This is a hack to fix sites with flash objects. We should
846 // instead route all WebMouseEvents through EventHandler. See 849 // instead route all WebMouseEvents through EventHandler. See
847 // crbug.com/665924. 850 // crbug.com/665924.
848 void createAndDispatchPointerEvent(const AtomicString& mouseEventName, 851 void createAndDispatchPointerEvent(const AtomicString& mouseEventName,
849 const WebMouseEvent&, 852 const WebMouseEvent&,
850 LocalDOMWindow* view); 853 LocalDOMWindow* view);
851 854
852 protected: 855 protected:
853 enum ConstructionType { 856 enum ConstructionType {
854 CreateOther = DefaultNodeFlags, 857 CreateOther = DefaultNodeFlags,
855 CreateText = DefaultNodeFlags | IsTextFlag, 858 CreateText = DefaultNodeFlags | IsTextFlag,
856 CreateContainer = 859 CreateContainer = DefaultNodeFlags | ChildNeedsStyleRecalcFlag |
857 DefaultNodeFlags | ChildNeedsStyleRecalcFlag | IsContainerFlag, 860 ChildNeedsReattachLayoutTree |
861 IsContainerFlag,
858 CreateElement = CreateContainer | IsElementFlag, 862 CreateElement = CreateContainer | IsElementFlag,
859 CreateShadowRoot = 863 CreateShadowRoot =
860 CreateContainer | IsDocumentFragmentFlag | IsInShadowTreeFlag, 864 CreateContainer | IsDocumentFragmentFlag | IsInShadowTreeFlag,
861 CreateDocumentFragment = CreateContainer | IsDocumentFragmentFlag, 865 CreateDocumentFragment = CreateContainer | IsDocumentFragmentFlag,
862 CreateHTMLElement = CreateElement | IsHTMLFlag, 866 CreateHTMLElement = CreateElement | IsHTMLFlag,
863 CreateSVGElement = CreateElement | IsSVGFlag, 867 CreateSVGElement = CreateElement | IsSVGFlag,
864 CreateDocument = CreateContainer | IsConnectedFlag, 868 CreateDocument = CreateContainer | IsConnectedFlag,
865 CreateInsertionPoint = CreateHTMLElement | IsInsertionPointFlag, 869 CreateInsertionPoint = CreateHTMLElement | IsInsertionPointFlag,
866 CreateEditingText = CreateText | HasNameOrIsEditingTextFlag, 870 CreateEditingText = CreateText | HasNameOrIsEditingTextFlag,
867 }; 871 };
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 if (needsAttach()) 975 if (needsAttach())
972 return; 976 return;
973 if (!inActiveDocument()) 977 if (!inActiveDocument())
974 return; 978 return;
975 979
976 AttachContext context; 980 AttachContext context;
977 context.performingReattach = true; 981 context.performingReattach = true;
978 982
979 detachLayoutTree(context); 983 detachLayoutTree(context);
980 markAncestorsWithChildNeedsStyleRecalc(); 984 markAncestorsWithChildNeedsStyleRecalc();
985 markAncestorsWithChildNeedsReattachLayoutTree();
981 } 986 }
982 987
983 inline bool Node::shouldCallRecalcStyle(StyleRecalcChange change) { 988 inline bool Node::shouldCallRecalcStyle(StyleRecalcChange change) {
984 return change >= IndependentInherit || needsStyleRecalc() || 989 return change >= IndependentInherit || needsStyleRecalc() ||
985 childNeedsStyleRecalc(); 990 childNeedsStyleRecalc();
986 } 991 }
987 992
988 inline bool isTreeScopeRoot(const Node* node) { 993 inline bool isTreeScopeRoot(const Node* node) {
989 return !node || node->isDocumentNode() || node->isShadowRoot(); 994 return !node || node->isDocumentNode() || node->isShadowRoot();
990 } 995 }
(...skipping 29 matching lines...) Expand all
1020 } // namespace blink 1025 } // namespace blink
1021 1026
1022 #ifndef NDEBUG 1027 #ifndef NDEBUG
1023 // Outside the WebCore namespace for ease of invocation from gdb. 1028 // Outside the WebCore namespace for ease of invocation from gdb.
1024 void showNode(const blink::Node*); 1029 void showNode(const blink::Node*);
1025 void showTree(const blink::Node*); 1030 void showTree(const blink::Node*);
1026 void showNodePath(const blink::Node*); 1031 void showNodePath(const blink::Node*);
1027 #endif 1032 #endif
1028 1033
1029 #endif // Node_h 1034 #endif // Node_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698