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" | |
30 #include "wtf/RefCounted.h" | 28 #include "wtf/RefCounted.h" |
| 29 #include <memory> |
31 | 30 |
32 namespace blink { | 31 namespace blink { |
33 class CSSSelectorList; | 32 class CSSSelectorList; |
34 | 33 |
35 // This class represents a selector for a StyleRule. | 34 // This class represents a selector for a StyleRule. |
36 | 35 |
37 // CSS selector representation is somewhat complicated and subtle. A representat
ive list of selectors is | 36 // CSS selector representation is somewhat complicated and subtle. A representat
ive list of selectors is |
38 // in CSSSelectorTest; run it in a debug build to see useful debugging output. | 37 // in CSSSelectorTest; run it in a debug build to see useful debugging output. |
39 // | 38 // |
40 // ** tagHistory() and relation(): | 39 // ** tagHistory() and relation(): |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 | 244 |
246 #ifndef NDEBUG | 245 #ifndef NDEBUG |
247 void show() const; | 246 void show() const; |
248 void show(int indent) const; | 247 void show(int indent) const; |
249 #endif | 248 #endif |
250 | 249 |
251 bool isASCIILower(const AtomicString& value); | 250 bool isASCIILower(const AtomicString& value); |
252 void setValue(const AtomicString&, bool matchLowerCase); | 251 void setValue(const AtomicString&, bool matchLowerCase); |
253 void setAttribute(const QualifiedName&, AttributeMatchType); | 252 void setAttribute(const QualifiedName&, AttributeMatchType); |
254 void setArgument(const AtomicString&); | 253 void setArgument(const AtomicString&); |
255 void setSelectorList(PassOwnPtr<CSSSelectorList>); | 254 void setSelectorList(std::unique_ptr<CSSSelectorList>); |
256 | 255 |
257 void setNth(int a, int b); | 256 void setNth(int a, int b); |
258 bool matchNth(int count) const; | 257 bool matchNth(int count) const; |
259 | 258 |
260 bool isAdjacentSelector() const { return m_relation == DirectAdjacent || m_r
elation == IndirectAdjacent; } | 259 bool isAdjacentSelector() const { return m_relation == DirectAdjacent || m_r
elation == IndirectAdjacent; } |
261 bool isShadowSelector() const { return m_relation == ShadowPseudo || m_relat
ion == ShadowDeep; } | 260 bool isShadowSelector() const { return m_relation == ShadowPseudo || m_relat
ion == ShadowDeep; } |
262 bool isAttributeSelector() const { return m_match >= FirstAttributeSelectorM
atch; } | 261 bool isAttributeSelector() const { return m_match >= FirstAttributeSelectorM
atch; } |
263 bool isHostPseudoClass() const { return m_pseudoType == PseudoHost || m_pseu
doType == PseudoHostContext; } | 262 bool isHostPseudoClass() const { return m_pseudoType == PseudoHost || m_pseu
doType == PseudoHostContext; } |
264 bool isInsertionPointCrossing() const { return m_pseudoType == PseudoHostCon
text || m_pseudoType == PseudoContent; } | 263 bool isInsertionPointCrossing() const { return m_pseudoType == PseudoHostCon
text || m_pseudoType == PseudoContent; } |
265 | 264 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 AtomicString m_serializingValue; | 330 AtomicString m_serializingValue; |
332 union { | 331 union { |
333 struct { | 332 struct { |
334 int m_a; // Used for :nth-* | 333 int m_a; // Used for :nth-* |
335 int m_b; // Used for :nth-* | 334 int m_b; // Used for :nth-* |
336 } m_nth; | 335 } m_nth; |
337 AttributeMatchType m_attributeMatch; // used for attribute selector
(with value) | 336 AttributeMatchType m_attributeMatch; // used for attribute selector
(with value) |
338 } m_bits; | 337 } m_bits; |
339 QualifiedName m_attribute; // used for attribute selector | 338 QualifiedName m_attribute; // used for attribute selector |
340 AtomicString m_argument; // Used for :contains, :lang, :nth-* | 339 AtomicString m_argument; // Used for :contains, :lang, :nth-* |
341 OwnPtr<CSSSelectorList> m_selectorList; // Used for :-webkit-any and :no
t | 340 std::unique_ptr<CSSSelectorList> m_selectorList; // Used for :-webkit-an
y and :not |
342 | 341 |
343 private: | 342 private: |
344 RareData(const AtomicString& value); | 343 RareData(const AtomicString& value); |
345 }; | 344 }; |
346 void createRareData(); | 345 void createRareData(); |
347 | 346 |
348 union DataUnion { | 347 union DataUnion { |
349 DataUnion() | 348 DataUnion() |
350 : m_value(nullptr) | 349 : m_value(nullptr) |
351 { | 350 { |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 if (m_hasRareData) | 479 if (m_hasRareData) |
481 return m_data.m_rareData->m_serializingValue; | 480 return m_data.m_rareData->m_serializingValue; |
482 // AtomicString is really just a StringImpl* so the cast below is safe. | 481 // AtomicString is really just a StringImpl* so the cast below is safe. |
483 // FIXME: Perhaps call sites could be changed to accept StringImpl? | 482 // FIXME: Perhaps call sites could be changed to accept StringImpl? |
484 return *reinterpret_cast<const AtomicString*>(&m_data.m_value); | 483 return *reinterpret_cast<const AtomicString*>(&m_data.m_value); |
485 } | 484 } |
486 | 485 |
487 } // namespace blink | 486 } // namespace blink |
488 | 487 |
489 #endif // CSSSelector_h | 488 #endif // CSSSelector_h |
OLD | NEW |