| 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 * |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 enum Relation { | 125 enum Relation { |
| 126 Descendant = 0, // "Space" combinator | 126 Descendant = 0, // "Space" combinator |
| 127 Child, // > combinator | 127 Child, // > combinator |
| 128 DirectAdjacent, // + combinator | 128 DirectAdjacent, // + combinator |
| 129 IndirectAdjacent, // ~ combinator | 129 IndirectAdjacent, // ~ combinator |
| 130 SubSelector, // "No space" combinator | 130 SubSelector, // "No space" combinator |
| 131 ShadowPseudo, // Special case of shadow DOM pseudo elements | 131 ShadowPseudo, // Special case of shadow DOM pseudo elements |
| 132 // FIXME: implement named combinator and replace the following /shad
ow/, /shadow-all/ and | 132 // FIXME: implement named combinator and replace the following /shad
ow/, /shadow-all/ and |
| 133 // /shadow-deep/ with named combinator's implementation. | 133 // /shadow-deep/ with named combinator's implementation. |
| 134 ShadowAll, | 134 ShadowAll, |
| 135 ShadowDeep | 135 ShadowDeep, |
| 136 ShadowContent // /content/ for shadow styling |
| 136 }; | 137 }; |
| 137 | 138 |
| 138 enum PseudoType { | 139 enum PseudoType { |
| 139 PseudoNotParsed = 0, | 140 PseudoNotParsed = 0, |
| 140 PseudoUnknown, | 141 PseudoUnknown, |
| 141 PseudoEmpty, | 142 PseudoEmpty, |
| 142 PseudoFirstChild, | 143 PseudoFirstChild, |
| 143 PseudoFirstOfType, | 144 PseudoFirstOfType, |
| 144 PseudoLastChild, | 145 PseudoLastChild, |
| 145 PseudoLastOfType, | 146 PseudoLastOfType, |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 PseudoFullScreenAncestor, | 210 PseudoFullScreenAncestor, |
| 210 PseudoInRange, | 211 PseudoInRange, |
| 211 PseudoOutOfRange, | 212 PseudoOutOfRange, |
| 212 PseudoUserAgentCustomElement, | 213 PseudoUserAgentCustomElement, |
| 213 PseudoWebKitCustomElement, | 214 PseudoWebKitCustomElement, |
| 214 PseudoCue, | 215 PseudoCue, |
| 215 PseudoFutureCue, | 216 PseudoFutureCue, |
| 216 PseudoPastCue, | 217 PseudoPastCue, |
| 217 PseudoDistributed, | 218 PseudoDistributed, |
| 218 PseudoUnresolved, | 219 PseudoUnresolved, |
| 219 PseudoContent, | |
| 220 PseudoHost, | 220 PseudoHost, |
| 221 PseudoAncestor | 221 PseudoAncestor |
| 222 }; | 222 }; |
| 223 | 223 |
| 224 enum MarginBoxType { | 224 enum MarginBoxType { |
| 225 TopLeftCornerMarginBox, | 225 TopLeftCornerMarginBox, |
| 226 TopLeftMarginBox, | 226 TopLeftMarginBox, |
| 227 TopCenterMarginBox, | 227 TopCenterMarginBox, |
| 228 TopRightMarginBox, | 228 TopRightMarginBox, |
| 229 TopRightCornerMarginBox, | 229 TopRightCornerMarginBox, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 bool parseNth() const; | 281 bool parseNth() const; |
| 282 bool matchNth(int count) const; | 282 bool matchNth(int count) const; |
| 283 | 283 |
| 284 bool matchesPseudoElement() const; | 284 bool matchesPseudoElement() const; |
| 285 bool isUnknownPseudoElement() const; | 285 bool isUnknownPseudoElement() const; |
| 286 bool isCustomPseudoElement() const; | 286 bool isCustomPseudoElement() const; |
| 287 bool isDirectAdjacentSelector() const { return m_relation == DirectAdjac
ent; } | 287 bool isDirectAdjacentSelector() const { return m_relation == DirectAdjac
ent; } |
| 288 bool isSiblingSelector() const; | 288 bool isSiblingSelector() const; |
| 289 bool isAttributeSelector() const; | 289 bool isAttributeSelector() const; |
| 290 bool isDistributedPseudoElement() const; | 290 bool isDistributedPseudoElement() const; |
| 291 bool isContentPseudoElement() const; | |
| 292 bool isHostPseudoClass() const; | 291 bool isHostPseudoClass() const; |
| 293 | 292 |
| 294 // FIXME: selectors with no tagHistory() get a relation() of Descendant.
It should instead be | 293 // FIXME: selectors with no tagHistory() get a relation() of Descendant.
It should instead be |
| 295 // None. | 294 // None. |
| 296 Relation relation() const { return static_cast<Relation>(m_relation); } | 295 Relation relation() const { return static_cast<Relation>(m_relation); } |
| 297 | 296 |
| 298 bool isLastInSelectorList() const { return m_isLastInSelectorList; } | 297 bool isLastInSelectorList() const { return m_isLastInSelectorList; } |
| 299 void setLastInSelectorList() { m_isLastInSelectorList = true; } | 298 void setLastInSelectorList() { m_isLastInSelectorList = true; } |
| 300 bool isLastInTagHistory() const { return m_isLastInTagHistory; } | 299 bool isLastInTagHistory() const { return m_isLastInTagHistory; } |
| 301 void setNotLastInTagHistory() { m_isLastInTagHistory = false; } | 300 void setNotLastInTagHistory() { m_isLastInTagHistory = false; } |
| 302 | 301 |
| 303 // http://dev.w3.org/csswg/selectors4/#compound | 302 // http://dev.w3.org/csswg/selectors4/#compound |
| 304 bool isCompound() const; | 303 bool isCompound() const; |
| 305 | 304 |
| 306 bool isForPage() const { return m_isForPage; } | 305 bool isForPage() const { return m_isForPage; } |
| 307 void setForPage() { m_isForPage = true; } | 306 void setForPage() { m_isForPage = true; } |
| 308 | 307 |
| 309 bool relationIsAffectedByPseudoContent() const { return m_relationIsAffe
ctedByPseudoContent; } | 308 bool relationIsAffectedByPseudoContent() const { return m_relationIsAffe
ctedByPseudoContent; } |
| 310 void setRelationIsAffectedByPseudoContent() { m_relationIsAffectedByPseu
doContent = true; } | 309 void setRelationIsAffectedByPseudoContent() { m_relationIsAffectedByPseu
doContent = true; } |
| 311 | 310 |
| 312 unsigned m_relation : 3; // enum Relation | 311 unsigned m_relation : 4; // enum Relation |
| 313 mutable unsigned m_match : 4; // enum Match | 312 mutable unsigned m_match : 4; // enum Match |
| 314 mutable unsigned m_pseudoType : 8; // PseudoType | 313 mutable unsigned m_pseudoType : 8; // PseudoType |
| 315 | 314 |
| 316 private: | 315 private: |
| 317 mutable unsigned m_parsedNth : 1; // Used for :nth-* | 316 mutable unsigned m_parsedNth : 1; // Used for :nth-* |
| 318 unsigned m_isLastInSelectorList : 1; | 317 unsigned m_isLastInSelectorList : 1; |
| 319 unsigned m_isLastInTagHistory : 1; | 318 unsigned m_isLastInTagHistory : 1; |
| 320 unsigned m_hasRareData : 1; | 319 unsigned m_hasRareData : 1; |
| 321 unsigned m_isForPage : 1; | 320 unsigned m_isForPage : 1; |
| 322 unsigned m_tagIsForNamespaceRule : 1; | 321 unsigned m_tagIsForNamespaceRule : 1; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 || m_match == CSSSelector::Contain | 411 || m_match == CSSSelector::Contain |
| 413 || m_match == CSSSelector::Begin | 412 || m_match == CSSSelector::Begin |
| 414 || m_match == CSSSelector::End; | 413 || m_match == CSSSelector::End; |
| 415 } | 414 } |
| 416 | 415 |
| 417 inline bool CSSSelector::isDistributedPseudoElement() const | 416 inline bool CSSSelector::isDistributedPseudoElement() const |
| 418 { | 417 { |
| 419 return m_match == PseudoElement && pseudoType() == PseudoDistributed; | 418 return m_match == PseudoElement && pseudoType() == PseudoDistributed; |
| 420 } | 419 } |
| 421 | 420 |
| 422 inline bool CSSSelector::isContentPseudoElement() const | |
| 423 { | |
| 424 return m_match == PseudoElement && pseudoType() == PseudoContent; | |
| 425 } | |
| 426 | |
| 427 inline void CSSSelector::setValue(const AtomicString& value) | 421 inline void CSSSelector::setValue(const AtomicString& value) |
| 428 { | 422 { |
| 429 ASSERT(m_match != Tag); | 423 ASSERT(m_match != Tag); |
| 430 ASSERT(m_pseudoType == PseudoNotParsed); | 424 ASSERT(m_pseudoType == PseudoNotParsed); |
| 431 // Need to do ref counting manually for the union. | 425 // Need to do ref counting manually for the union. |
| 432 if (m_hasRareData) { | 426 if (m_hasRareData) { |
| 433 m_data.m_rareData->m_value = value; | 427 m_data.m_rareData->m_value = value; |
| 434 return; | 428 return; |
| 435 } | 429 } |
| 436 if (m_data.m_value) | 430 if (m_data.m_value) |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 if (m_hasRareData) | 509 if (m_hasRareData) |
| 516 return m_data.m_rareData->m_value; | 510 return m_data.m_rareData->m_value; |
| 517 // AtomicString is really just a StringImpl* so the cast below is safe. | 511 // AtomicString is really just a StringImpl* so the cast below is safe. |
| 518 // FIXME: Perhaps call sites could be changed to accept StringImpl? | 512 // FIXME: Perhaps call sites could be changed to accept StringImpl? |
| 519 return *reinterpret_cast<const AtomicString*>(&m_data.m_value); | 513 return *reinterpret_cast<const AtomicString*>(&m_data.m_value); |
| 520 } | 514 } |
| 521 | 515 |
| 522 } // namespace WebCore | 516 } // namespace WebCore |
| 523 | 517 |
| 524 #endif // CSSSelector_h | 518 #endif // CSSSelector_h |
| OLD | NEW |