OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999-2003 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999-2003 Lars Knoll (knoll@kde.org) |
3 * 1999 Waldo Bastian (bastian@kde.org) | 3 * 1999 Waldo Bastian (bastian@kde.org) |
4 * Copyright (C) 2004, 2006, 2007, 2008, 2009, 2010, 2013 Apple Inc. All rights
reserved. | 4 * Copyright (C) 2004, 2006, 2007, 2008, 2009, 2010, 2013 Apple Inc. All rights
reserved. |
5 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
11 * This library is distributed in the hope that it will be useful, | 11 * This library is distributed in the hope that it will be useful, |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 * Library General Public License for more details. | 14 * Library General Public License for more details. |
15 * | 15 * |
16 * You should have received a copy of the GNU Library General Public License | 16 * You should have received a copy of the GNU Library General Public License |
17 * along with this library; see the file COPYING.LIB. If not, write to | 17 * along with this library; see the file COPYING.LIB. If not, write to |
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
19 * Boston, MA 02110-1301, USA. | 19 * Boston, MA 02110-1301, USA. |
20 */ | 20 */ |
21 | 21 |
22 #ifndef CSSSelector_h | 22 #ifndef CSSSelector_h |
23 #define CSSSelector_h | 23 #define CSSSelector_h |
24 | 24 |
25 #include "core/CoreExport.h" | 25 #include "core/CoreExport.h" |
26 #include "core/dom/QualifiedName.h" | 26 #include "core/dom/QualifiedName.h" |
27 #include "core/style/ComputedStyleConstants.h" | 27 #include "core/style/ComputedStyleConstants.h" |
| 28 #include "wtf/OwnPtr.h" |
| 29 #include "wtf/PassOwnPtr.h" |
28 #include "wtf/RefCounted.h" | 30 #include "wtf/RefCounted.h" |
29 #include <memory> | |
30 | 31 |
31 namespace blink { | 32 namespace blink { |
32 class CSSSelectorList; | 33 class CSSSelectorList; |
33 | 34 |
34 // This class represents a selector for a StyleRule. | 35 // This class represents a selector for a StyleRule. |
35 | 36 |
36 // CSS selector representation is somewhat complicated and subtle. A representat
ive list of selectors is | 37 // CSS selector representation is somewhat complicated and subtle. A representat
ive list of selectors is |
37 // in CSSSelectorTest; run it in a debug build to see useful debugging output. | 38 // in CSSSelectorTest; run it in a debug build to see useful debugging output. |
38 // | 39 // |
39 // ** tagHistory() and relation(): | 40 // ** tagHistory() and relation(): |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 | 245 |
245 #ifndef NDEBUG | 246 #ifndef NDEBUG |
246 void show() const; | 247 void show() const; |
247 void show(int indent) const; | 248 void show(int indent) const; |
248 #endif | 249 #endif |
249 | 250 |
250 bool isASCIILower(const AtomicString& value); | 251 bool isASCIILower(const AtomicString& value); |
251 void setValue(const AtomicString&, bool matchLowerCase); | 252 void setValue(const AtomicString&, bool matchLowerCase); |
252 void setAttribute(const QualifiedName&, AttributeMatchType); | 253 void setAttribute(const QualifiedName&, AttributeMatchType); |
253 void setArgument(const AtomicString&); | 254 void setArgument(const AtomicString&); |
254 void setSelectorList(std::unique_ptr<CSSSelectorList>); | 255 void setSelectorList(PassOwnPtr<CSSSelectorList>); |
255 | 256 |
256 void setNth(int a, int b); | 257 void setNth(int a, int b); |
257 bool matchNth(int count) const; | 258 bool matchNth(int count) const; |
258 | 259 |
259 bool isAdjacentSelector() const { return m_relation == DirectAdjacent || m_r
elation == IndirectAdjacent; } | 260 bool isAdjacentSelector() const { return m_relation == DirectAdjacent || m_r
elation == IndirectAdjacent; } |
260 bool isShadowSelector() const { return m_relation == ShadowPseudo || m_relat
ion == ShadowDeep; } | 261 bool isShadowSelector() const { return m_relation == ShadowPseudo || m_relat
ion == ShadowDeep; } |
261 bool isAttributeSelector() const { return m_match >= FirstAttributeSelectorM
atch; } | 262 bool isAttributeSelector() const { return m_match >= FirstAttributeSelectorM
atch; } |
262 bool isHostPseudoClass() const { return m_pseudoType == PseudoHost || m_pseu
doType == PseudoHostContext; } | 263 bool isHostPseudoClass() const { return m_pseudoType == PseudoHost || m_pseu
doType == PseudoHostContext; } |
263 bool isInsertionPointCrossing() const { return m_pseudoType == PseudoHostCon
text || m_pseudoType == PseudoContent; } | 264 bool isInsertionPointCrossing() const { return m_pseudoType == PseudoHostCon
text || m_pseudoType == PseudoContent; } |
264 | 265 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 AtomicString m_serializingValue; | 331 AtomicString m_serializingValue; |
331 union { | 332 union { |
332 struct { | 333 struct { |
333 int m_a; // Used for :nth-* | 334 int m_a; // Used for :nth-* |
334 int m_b; // Used for :nth-* | 335 int m_b; // Used for :nth-* |
335 } m_nth; | 336 } m_nth; |
336 AttributeMatchType m_attributeMatch; // used for attribute selector
(with value) | 337 AttributeMatchType m_attributeMatch; // used for attribute selector
(with value) |
337 } m_bits; | 338 } m_bits; |
338 QualifiedName m_attribute; // used for attribute selector | 339 QualifiedName m_attribute; // used for attribute selector |
339 AtomicString m_argument; // Used for :contains, :lang, :nth-* | 340 AtomicString m_argument; // Used for :contains, :lang, :nth-* |
340 std::unique_ptr<CSSSelectorList> m_selectorList; // Used for :-webkit-an
y and :not | 341 OwnPtr<CSSSelectorList> m_selectorList; // Used for :-webkit-any and :no
t |
341 | 342 |
342 private: | 343 private: |
343 RareData(const AtomicString& value); | 344 RareData(const AtomicString& value); |
344 }; | 345 }; |
345 void createRareData(); | 346 void createRareData(); |
346 | 347 |
347 union DataUnion { | 348 union DataUnion { |
348 DataUnion() | 349 DataUnion() |
349 : m_value(nullptr) | 350 : m_value(nullptr) |
350 { | 351 { |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 if (m_hasRareData) | 480 if (m_hasRareData) |
480 return m_data.m_rareData->m_serializingValue; | 481 return m_data.m_rareData->m_serializingValue; |
481 // AtomicString is really just a StringImpl* so the cast below is safe. | 482 // AtomicString is really just a StringImpl* so the cast below is safe. |
482 // FIXME: Perhaps call sites could be changed to accept StringImpl? | 483 // FIXME: Perhaps call sites could be changed to accept StringImpl? |
483 return *reinterpret_cast<const AtomicString*>(&m_data.m_value); | 484 return *reinterpret_cast<const AtomicString*>(&m_data.m_value); |
484 } | 485 } |
485 | 486 |
486 } // namespace blink | 487 } // namespace blink |
487 | 488 |
488 #endif // CSSSelector_h | 489 #endif // CSSSelector_h |
OLD | NEW |