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

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

Issue 2088453002: Implement the inert attribute (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 3 years, 7 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 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
6 * rights reserved. 6 * rights reserved.
7 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 7 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. 8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved.
9 * (http://www.torchmobile.com/) 9 * (http://www.torchmobile.com/)
10 * 10 *
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 for (Node* node = ParentOrShadowHostNode(); 746 for (Node* node = ParentOrShadowHostNode();
747 node && !node->ChildNeedsStyleInvalidation(); 747 node && !node->ChildNeedsStyleInvalidation();
748 node = node->ParentOrShadowHostNode()) 748 node = node->ParentOrShadowHostNode())
749 node->SetChildNeedsStyleInvalidation(); 749 node->SetChildNeedsStyleInvalidation();
750 GetDocument().ScheduleLayoutTreeUpdateIfNeeded(); 750 GetDocument().ScheduleLayoutTreeUpdateIfNeeded();
751 } 751 }
752 752
753 void Node::MarkAncestorsWithChildNeedsDistributionRecalc() { 753 void Node::MarkAncestorsWithChildNeedsDistributionRecalc() {
754 ScriptForbiddenScope forbid_script_during_raw_iteration; 754 ScriptForbiddenScope forbid_script_during_raw_iteration;
755 for (Node* node = this; node && !node->ChildNeedsDistributionRecalc(); 755 for (Node* node = this; node && !node->ChildNeedsDistributionRecalc();
756 node = node->ParentOrShadowHostNode()) 756 node = node->ParentOrShadowHostNode()) {
757 node->SetChildNeedsDistributionRecalc(); 757 node->SetChildNeedsDistributionRecalc();
758 }
758 GetDocument().ScheduleLayoutTreeUpdateIfNeeded(); 759 GetDocument().ScheduleLayoutTreeUpdateIfNeeded();
759 } 760 }
760 761
761 inline void Node::SetStyleChange(StyleChangeType change_type) { 762 inline void Node::SetStyleChange(StyleChangeType change_type) {
762 node_flags_ = (node_flags_ & ~kStyleChangeMask) | change_type; 763 node_flags_ = (node_flags_ & ~kStyleChangeMask) | change_type;
763 } 764 }
764 765
765 void Node::MarkAncestorsWithChildNeedsStyleRecalc() { 766 void Node::MarkAncestorsWithChildNeedsStyleRecalc() {
766 for (ContainerNode* p = ParentOrShadowHostNode(); 767 for (ContainerNode* p = ParentOrShadowHostNode();
767 p && !p->ChildNeedsStyleRecalc(); p = p->ParentOrShadowHostNode()) 768 p && !p->ChildNeedsStyleRecalc(); p = p->ParentOrShadowHostNode())
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 839
839 Node* Node::FocusDelegate() { 840 Node* Node::FocusDelegate() {
840 return this; 841 return this;
841 } 842 }
842 843
843 bool Node::ShouldHaveFocusAppearance() const { 844 bool Node::ShouldHaveFocusAppearance() const {
844 DCHECK(IsFocused()); 845 DCHECK(IsFocused());
845 return true; 846 return true;
846 } 847 }
847 848
848 bool Node::IsInert() const { 849 bool Node::IsInert() const {
kochi 2017/05/22 07:31:15 Could you also update the comment in Node.h above
aboxhall 2017/05/23 02:45:43 Added some links in the .h
850 if (!CanParticipateInFlatTree())
851 return true;
852
853 if (!isConnected())
kochi 2017/05/22 07:31:15 style nit: you can combine line 850 and 853 into o
aboxhall 2017/05/23 02:45:43 Makes sense, done.
854 return true;
855
856 DCHECK(!ChildNeedsDistributionRecalc());
857
849 const HTMLDialogElement* dialog = GetDocument().ActiveModalDialog(); 858 const HTMLDialogElement* dialog = GetDocument().ActiveModalDialog();
850 if (dialog && this != GetDocument() && 859 if (dialog && this != GetDocument() &&
851 (!CanParticipateInFlatTree() || 860 !FlatTreeTraversal::ContainsIncludingPseudoElement(*dialog, *this)) {
852 !FlatTreeTraversal::ContainsIncludingPseudoElement(*dialog, *this)))
853 return true; 861 return true;
862 }
863
864 if (RuntimeEnabledFeatures::inertAttributeEnabled()) {
865 const Element* element = this->IsElementNode()
866 ? ToElement(this)
867 : FlatTreeTraversal::ParentElement(*this);
868 while (element) {
869 if (element->hasAttribute(HTMLNames::inertAttr))
870 return true;
871 element = FlatTreeTraversal::ParentElement(*element);
872 }
873 }
854 return GetDocument().LocalOwner() && GetDocument().LocalOwner()->IsInert(); 874 return GetDocument().LocalOwner() && GetDocument().LocalOwner()->IsInert();
855 } 875 }
856 876
857 unsigned Node::NodeIndex() const { 877 unsigned Node::NodeIndex() const {
858 const Node* temp_node = previousSibling(); 878 const Node* temp_node = previousSibling();
859 unsigned count = 0; 879 unsigned count = 0;
860 for (count = 0; temp_node; count++) 880 for (count = 0; temp_node; count++)
861 temp_node = temp_node->previousSibling(); 881 temp_node = temp_node->previousSibling();
862 return count; 882 return count;
863 } 883 }
(...skipping 1759 matching lines...) Expand 10 before | Expand all | Expand 10 after
2623 if (node) { 2643 if (node) {
2624 std::stringstream stream; 2644 std::stringstream stream;
2625 node->PrintNodePathTo(stream); 2645 node->PrintNodePathTo(stream);
2626 LOG(INFO) << stream.str(); 2646 LOG(INFO) << stream.str();
2627 } else { 2647 } else {
2628 LOG(INFO) << "Cannot showNodePath for <null>"; 2648 LOG(INFO) << "Cannot showNodePath for <null>";
2629 } 2649 }
2630 } 2650 }
2631 2651
2632 #endif 2652 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698