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

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: Revert histograms.xml 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
« no previous file with comments | « third_party/WebKit/Source/core/dom/Node.h ('k') | third_party/WebKit/Source/core/dom/Text.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, 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 737 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 for (Node* node = ParentOrShadowHostNode(); 748 for (Node* node = ParentOrShadowHostNode();
749 node && !node->ChildNeedsStyleInvalidation(); 749 node && !node->ChildNeedsStyleInvalidation();
750 node = node->ParentOrShadowHostNode()) 750 node = node->ParentOrShadowHostNode())
751 node->SetChildNeedsStyleInvalidation(); 751 node->SetChildNeedsStyleInvalidation();
752 GetDocument().ScheduleLayoutTreeUpdateIfNeeded(); 752 GetDocument().ScheduleLayoutTreeUpdateIfNeeded();
753 } 753 }
754 754
755 void Node::MarkAncestorsWithChildNeedsDistributionRecalc() { 755 void Node::MarkAncestorsWithChildNeedsDistributionRecalc() {
756 ScriptForbiddenScope forbid_script_during_raw_iteration; 756 ScriptForbiddenScope forbid_script_during_raw_iteration;
757 for (Node* node = this; node && !node->ChildNeedsDistributionRecalc(); 757 for (Node* node = this; node && !node->ChildNeedsDistributionRecalc();
758 node = node->ParentOrShadowHostNode()) 758 node = node->ParentOrShadowHostNode()) {
759 node->SetChildNeedsDistributionRecalc(); 759 node->SetChildNeedsDistributionRecalc();
760 }
760 GetDocument().ScheduleLayoutTreeUpdateIfNeeded(); 761 GetDocument().ScheduleLayoutTreeUpdateIfNeeded();
761 } 762 }
762 763
763 inline void Node::SetStyleChange(StyleChangeType change_type) { 764 inline void Node::SetStyleChange(StyleChangeType change_type) {
764 node_flags_ = (node_flags_ & ~kStyleChangeMask) | change_type; 765 node_flags_ = (node_flags_ & ~kStyleChangeMask) | change_type;
765 } 766 }
766 767
767 void Node::MarkAncestorsWithChildNeedsStyleRecalc() { 768 void Node::MarkAncestorsWithChildNeedsStyleRecalc() {
768 for (ContainerNode* p = ParentOrShadowHostNode(); 769 for (ContainerNode* p = ParentOrShadowHostNode();
769 p && !p->ChildNeedsStyleRecalc(); p = p->ParentOrShadowHostNode()) 770 p && !p->ChildNeedsStyleRecalc(); p = p->ParentOrShadowHostNode())
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 Node* Node::FocusDelegate() { 842 Node* Node::FocusDelegate() {
842 return this; 843 return this;
843 } 844 }
844 845
845 bool Node::ShouldHaveFocusAppearance() const { 846 bool Node::ShouldHaveFocusAppearance() const {
846 DCHECK(IsFocused()); 847 DCHECK(IsFocused());
847 return true; 848 return true;
848 } 849 }
849 850
850 bool Node::IsInert() const { 851 bool Node::IsInert() const {
852 if (!isConnected() || !CanParticipateInFlatTree())
853 return true;
854
855 DCHECK(!ChildNeedsDistributionRecalc());
856
851 const HTMLDialogElement* dialog = GetDocument().ActiveModalDialog(); 857 const HTMLDialogElement* dialog = GetDocument().ActiveModalDialog();
852 if (dialog && this != GetDocument() && 858 if (dialog && this != GetDocument() &&
853 (!CanParticipateInFlatTree() || 859 !FlatTreeTraversal::ContainsIncludingPseudoElement(*dialog, *this)) {
854 !FlatTreeTraversal::ContainsIncludingPseudoElement(*dialog, *this)))
855 return true; 860 return true;
861 }
862
863 if (RuntimeEnabledFeatures::inertAttributeEnabled()) {
864 const Element* element = this->IsElementNode()
865 ? ToElement(this)
866 : FlatTreeTraversal::ParentElement(*this);
867 while (element) {
868 if (element->hasAttribute(HTMLNames::inertAttr))
869 return true;
870 element = FlatTreeTraversal::ParentElement(*element);
871 }
872 }
856 return GetDocument().LocalOwner() && GetDocument().LocalOwner()->IsInert(); 873 return GetDocument().LocalOwner() && GetDocument().LocalOwner()->IsInert();
857 } 874 }
858 875
859 unsigned Node::NodeIndex() const { 876 unsigned Node::NodeIndex() const {
860 const Node* temp_node = previousSibling(); 877 const Node* temp_node = previousSibling();
861 unsigned count = 0; 878 unsigned count = 0;
862 for (count = 0; temp_node; count++) 879 for (count = 0; temp_node; count++)
863 temp_node = temp_node->previousSibling(); 880 temp_node = temp_node->previousSibling();
864 return count; 881 return count;
865 } 882 }
(...skipping 1775 matching lines...) Expand 10 before | Expand all | Expand 10 after
2641 if (node) { 2658 if (node) {
2642 std::stringstream stream; 2659 std::stringstream stream;
2643 node->PrintNodePathTo(stream); 2660 node->PrintNodePathTo(stream);
2644 LOG(INFO) << stream.str(); 2661 LOG(INFO) << stream.str();
2645 } else { 2662 } else {
2646 LOG(INFO) << "Cannot showNodePath for <null>"; 2663 LOG(INFO) << "Cannot showNodePath for <null>";
2647 } 2664 }
2648 } 2665 }
2649 2666
2650 #endif 2667 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Node.h ('k') | third_party/WebKit/Source/core/dom/Text.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698