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

Side by Side Diff: third_party/WebKit/Source/core/css/SelectorFilter.cpp

Issue 2392343005: Reflow comments in core/css (Closed)
Patch Set: Revert clang-format 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com)
4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com)
5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights
6 * reserved.
6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> 8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org>
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
10 * (http://www.torchmobile.com/)
9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. 11 * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. 12 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
11 * Copyright (C) 2012 Google Inc. All rights reserved. 13 * Copyright (C) 2012 Google Inc. All rights reserved.
12 * 14 *
13 * This library is free software; you can redistribute it and/or 15 * This library is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU Library General Public 16 * modify it under the terms of the GNU Library General Public
15 * License as published by the Free Software Foundation; either 17 * License as published by the Free Software Foundation; either
16 * version 2 of the License, or (at your option) any later version. 18 * version 2 of the License, or (at your option) any later version.
17 * 19 *
18 * This library is distributed in the hope that it will be useful, 20 * This library is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * Library General Public License for more details. 23 * Library General Public License for more details.
22 * 24 *
23 * You should have received a copy of the GNU Library General Public License 25 * You should have received a copy of the GNU Library General Public License
24 * along with this library; see the file COPYING.LIB. If not, write to 26 * along with this library; see the file COPYING.LIB. If not, write to
25 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 27 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
26 * Boston, MA 02110-1301, USA. 28 * Boston, MA 02110-1301, USA.
27 */ 29 */
28 30
29 #include "core/css/SelectorFilter.h" 31 #include "core/css/SelectorFilter.h"
30 32
31 #include "core/css/CSSSelector.h" 33 #include "core/css/CSSSelector.h"
32 #include "core/dom/Document.h" 34 #include "core/dom/Document.h"
33 #include "wtf/PtrUtil.h" 35 #include "wtf/PtrUtil.h"
34 36
35 namespace blink { 37 namespace blink {
36 38
37 // Salt to separate otherwise identical string hashes so a class-selector like . article won't match <article> elements. 39 // Salt to separate otherwise identical string hashes so a class-selector like
40 // .article won't match <article> elements.
38 enum { TagNameSalt = 13, IdAttributeSalt = 17, ClassAttributeSalt = 19 }; 41 enum { TagNameSalt = 13, IdAttributeSalt = 17, ClassAttributeSalt = 19 };
39 42
40 static inline void collectElementIdentifierHashes( 43 static inline void collectElementIdentifierHashes(
41 const Element& element, 44 const Element& element,
42 Vector<unsigned, 4>& identifierHashes) { 45 Vector<unsigned, 4>& identifierHashes) {
43 identifierHashes.append( 46 identifierHashes.append(
44 element.localNameForSelectorMatching().impl()->existingHash() * 47 element.localNameForSelectorMatching().impl()->existingHash() *
45 TagNameSalt); 48 TagNameSalt);
46 if (element.hasID()) 49 if (element.hasID())
47 identifierHashes.append( 50 identifierHashes.append(
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 ASSERT(parent.document().inStyleRecalc()); 96 ASSERT(parent.document().inStyleRecalc());
94 ASSERT(parent.inActiveDocument()); 97 ASSERT(parent.inActiveDocument());
95 if (m_parentStack.isEmpty()) { 98 if (m_parentStack.isEmpty()) {
96 ASSERT(parent == parent.document().documentElement()); 99 ASSERT(parent == parent.document().documentElement());
97 ASSERT(!m_ancestorIdentifierFilter); 100 ASSERT(!m_ancestorIdentifierFilter);
98 m_ancestorIdentifierFilter = wrapUnique(new IdentifierFilter); 101 m_ancestorIdentifierFilter = wrapUnique(new IdentifierFilter);
99 pushParentStackFrame(parent); 102 pushParentStackFrame(parent);
100 return; 103 return;
101 } 104 }
102 ASSERT(m_ancestorIdentifierFilter); 105 ASSERT(m_ancestorIdentifierFilter);
103 // We may get invoked for some random elements in some wacky cases during styl e resolve. 106 // We may get invoked for some random elements in some wacky cases during
104 // Pause maintaining the stack in this case. 107 // style resolve. Pause maintaining the stack in this case.
105 if (m_parentStack.last().element != parent.parentOrShadowHostElement()) 108 if (m_parentStack.last().element != parent.parentOrShadowHostElement())
106 return; 109 return;
107 pushParentStackFrame(parent); 110 pushParentStackFrame(parent);
108 } 111 }
109 112
110 void SelectorFilter::popParent(Element& parent) { 113 void SelectorFilter::popParent(Element& parent) {
111 ASSERT(parent.document().inStyleRecalc()); 114 ASSERT(parent.document().inStyleRecalc());
112 ASSERT(parent.inActiveDocument()); 115 ASSERT(parent.inActiveDocument());
113 // Note that we may get invoked for some random elements in some wacky cases d uring style resolve. 116 // Note that we may get invoked for some random elements in some wacky cases
114 // Pause maintaining the stack in this case. 117 // during style resolve. Pause maintaining the stack in this case.
115 if (!parentStackIsConsistent(&parent)) 118 if (!parentStackIsConsistent(&parent))
116 return; 119 return;
117 popParentStackFrame(); 120 popParentStackFrame();
118 } 121 }
119 122
120 static inline void collectDescendantSelectorIdentifierHashes( 123 static inline void collectDescendantSelectorIdentifierHashes(
121 const CSSSelector& selector, 124 const CSSSelector& selector,
122 unsigned*& hash) { 125 unsigned*& hash) {
123 switch (selector.match()) { 126 switch (selector.match()) {
124 case CSSSelector::Id: 127 case CSSSelector::Id:
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 196
194 DEFINE_TRACE(SelectorFilter::ParentStackFrame) { 197 DEFINE_TRACE(SelectorFilter::ParentStackFrame) {
195 visitor->trace(element); 198 visitor->trace(element);
196 } 199 }
197 200
198 DEFINE_TRACE(SelectorFilter) { 201 DEFINE_TRACE(SelectorFilter) {
199 visitor->trace(m_parentStack); 202 visitor->trace(m_parentStack);
200 } 203 }
201 204
202 } // namespace blink 205 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/SelectorFilter.h ('k') | third_party/WebKit/Source/core/css/StylePropertySerializer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698