| 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 FirstAttributeSelectorMatch = AttributeExact, | 110 FirstAttributeSelectorMatch = AttributeExact, |
| 111 }; | 111 }; |
| 112 | 112 |
| 113 enum Relation { | 113 enum Relation { |
| 114 SubSelector, // No combinator | 114 SubSelector, // No combinator |
| 115 Descendant, // "Space" combinator | 115 Descendant, // "Space" combinator |
| 116 Child, // > combinator | 116 Child, // > combinator |
| 117 DirectAdjacent, // + combinator | 117 DirectAdjacent, // + combinator |
| 118 IndirectAdjacent, // ~ combinator | 118 IndirectAdjacent, // ~ combinator |
| 119 ShadowPseudo, // Special case of shadow DOM pseudo elements / shadow pse
udo element | 119 ShadowPseudo, // Special case of shadow DOM pseudo elements / shadow pse
udo element |
| 120 ShadowDeep // /deep/ combinator | 120 ShadowDeep, // /deep/ combinator |
| 121 ShadowSlot // slotted to <slot> element |
| 121 }; | 122 }; |
| 122 | 123 |
| 123 enum PseudoType { | 124 enum PseudoType { |
| 124 PseudoUnknown, | 125 PseudoUnknown, |
| 125 PseudoEmpty, | 126 PseudoEmpty, |
| 126 PseudoFirstChild, | 127 PseudoFirstChild, |
| 127 PseudoFirstOfType, | 128 PseudoFirstOfType, |
| 128 PseudoLastChild, | 129 PseudoLastChild, |
| 129 PseudoLastOfType, | 130 PseudoLastOfType, |
| 130 PseudoOnlyChild, | 131 PseudoOnlyChild, |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 PseudoWebKitCustomElement, | 195 PseudoWebKitCustomElement, |
| 195 PseudoCue, | 196 PseudoCue, |
| 196 PseudoFutureCue, | 197 PseudoFutureCue, |
| 197 PseudoPastCue, | 198 PseudoPastCue, |
| 198 PseudoUnresolved, | 199 PseudoUnresolved, |
| 199 PseudoContent, | 200 PseudoContent, |
| 200 PseudoHost, | 201 PseudoHost, |
| 201 PseudoHostContext, | 202 PseudoHostContext, |
| 202 PseudoShadow, | 203 PseudoShadow, |
| 203 PseudoSpatialNavigationFocus, | 204 PseudoSpatialNavigationFocus, |
| 204 PseudoListBox | 205 PseudoListBox, |
| 206 PseudoSlotted |
| 205 }; | 207 }; |
| 206 | 208 |
| 207 enum AttributeMatchType { | 209 enum AttributeMatchType { |
| 208 CaseSensitive, | 210 CaseSensitive, |
| 209 CaseInsensitive, | 211 CaseInsensitive, |
| 210 }; | 212 }; |
| 211 | 213 |
| 212 PseudoType pseudoType() const { return static_cast<PseudoType>(m_pseudoType)
; } | 214 PseudoType pseudoType() const { return static_cast<PseudoType>(m_pseudoType)
; } |
| 213 void updatePseudoType(const AtomicString&, bool hasArguments); | 215 void updatePseudoType(const AtomicString&, bool hasArguments); |
| 214 | 216 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 | 250 |
| 249 void setNth(int a, int b); | 251 void setNth(int a, int b); |
| 250 bool matchNth(int count) const; | 252 bool matchNth(int count) const; |
| 251 | 253 |
| 252 bool isAdjacentSelector() const { return m_relation == DirectAdjacent || m_r
elation == IndirectAdjacent; } | 254 bool isAdjacentSelector() const { return m_relation == DirectAdjacent || m_r
elation == IndirectAdjacent; } |
| 253 bool isShadowSelector() const { return m_relation == ShadowPseudo || m_relat
ion == ShadowDeep; } | 255 bool isShadowSelector() const { return m_relation == ShadowPseudo || m_relat
ion == ShadowDeep; } |
| 254 bool isSiblingSelector() const; | 256 bool isSiblingSelector() const; |
| 255 bool isAttributeSelector() const { return m_match >= FirstAttributeSelectorM
atch; } | 257 bool isAttributeSelector() const { return m_match >= FirstAttributeSelectorM
atch; } |
| 256 bool isHostPseudoClass() const { return m_pseudoType == PseudoHost || m_pseu
doType == PseudoHostContext; } | 258 bool isHostPseudoClass() const { return m_pseudoType == PseudoHost || m_pseu
doType == PseudoHostContext; } |
| 257 bool isInsertionPointCrossing() const { return m_pseudoType == PseudoHostCon
text || m_pseudoType == PseudoContent; } | 259 bool isInsertionPointCrossing() const { return m_pseudoType == PseudoHostCon
text || m_pseudoType == PseudoContent; } |
| 260 bool isSlottedPseudoElement() const { return m_pseudoType == PseudoSlotted;
} |
| 258 | 261 |
| 259 Relation relation() const { return static_cast<Relation>(m_relation); } | 262 Relation relation() const { return static_cast<Relation>(m_relation); } |
| 260 void setRelation(Relation relation) | 263 void setRelation(Relation relation) |
| 261 { | 264 { |
| 262 m_relation = relation; | 265 m_relation = relation; |
| 263 ASSERT(static_cast<Relation>(m_relation) == relation); // using a bitfie
ld. | 266 ASSERT(static_cast<Relation>(m_relation) == relation); // using a bitfie
ld. |
| 264 } | 267 } |
| 265 | 268 |
| 266 Match match() const { return static_cast<Match>(m_match); } | 269 Match match() const { return static_cast<Match>(m_match); } |
| 267 void setMatch(Match match) | 270 void setMatch(Match match) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 280 | 283 |
| 281 enum LinkMatchMask { MatchLink = 1, MatchVisited = 2, MatchAll = MatchLink |
MatchVisited }; | 284 enum LinkMatchMask { MatchLink = 1, MatchVisited = 2, MatchAll = MatchLink |
MatchVisited }; |
| 282 unsigned computeLinkMatchType() const; | 285 unsigned computeLinkMatchType() const; |
| 283 | 286 |
| 284 bool isForPage() const { return m_isForPage; } | 287 bool isForPage() const { return m_isForPage; } |
| 285 void setForPage() { m_isForPage = true; } | 288 void setForPage() { m_isForPage = true; } |
| 286 | 289 |
| 287 bool relationIsAffectedByPseudoContent() const { return m_relationIsAffected
ByPseudoContent; } | 290 bool relationIsAffectedByPseudoContent() const { return m_relationIsAffected
ByPseudoContent; } |
| 288 void setRelationIsAffectedByPseudoContent() { m_relationIsAffectedByPseudoCo
ntent = true; } | 291 void setRelationIsAffectedByPseudoContent() { m_relationIsAffectedByPseudoCo
ntent = true; } |
| 289 | 292 |
| 293 bool relationIsAffectedByPseudoSlotted() const { return m_relationIsAffected
ByPseudoSlotted; } |
| 294 void setRelationIsAffectedByPseudoSlotted() { m_relationIsAffectedByPseudoSl
otted = true; } |
| 295 |
| 290 private: | 296 private: |
| 291 unsigned m_relation : 3; // enum Relation | 297 unsigned m_relation : 3; // enum Relation |
| 292 unsigned m_match : 4; // enum Match | 298 unsigned m_match : 4; // enum Match |
| 293 unsigned m_pseudoType : 8; // enum PseudoType | 299 unsigned m_pseudoType : 8; // enum PseudoType |
| 294 unsigned m_isLastInSelectorList : 1; | 300 unsigned m_isLastInSelectorList : 1; |
| 295 unsigned m_isLastInTagHistory : 1; | 301 unsigned m_isLastInTagHistory : 1; |
| 296 unsigned m_hasRareData : 1; | 302 unsigned m_hasRareData : 1; |
| 297 unsigned m_isForPage : 1; | 303 unsigned m_isForPage : 1; |
| 298 unsigned m_tagIsImplicit : 1; | 304 unsigned m_tagIsImplicit : 1; |
| 299 unsigned m_relationIsAffectedByPseudoContent : 1; | 305 unsigned m_relationIsAffectedByPseudoContent : 1; |
| 306 unsigned m_relationIsAffectedByPseudoSlotted : 1; |
| 300 | 307 |
| 301 void setPseudoType(PseudoType pseudoType) | 308 void setPseudoType(PseudoType pseudoType) |
| 302 { | 309 { |
| 303 m_pseudoType = pseudoType; | 310 m_pseudoType = pseudoType; |
| 304 ASSERT(static_cast<PseudoType>(m_pseudoType) == pseudoType); // using a
bitfield. | 311 ASSERT(static_cast<PseudoType>(m_pseudoType) == pseudoType); // using a
bitfield. |
| 305 } | 312 } |
| 306 | 313 |
| 307 unsigned specificityForOneSelector() const; | 314 unsigned specificityForOneSelector() const; |
| 308 unsigned specificityForPage() const; | 315 unsigned specificityForPage() const; |
| 309 | 316 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 inline CSSSelector::CSSSelector() | 416 inline CSSSelector::CSSSelector() |
| 410 : m_relation(SubSelector) | 417 : m_relation(SubSelector) |
| 411 , m_match(Unknown) | 418 , m_match(Unknown) |
| 412 , m_pseudoType(PseudoUnknown) | 419 , m_pseudoType(PseudoUnknown) |
| 413 , m_isLastInSelectorList(false) | 420 , m_isLastInSelectorList(false) |
| 414 , m_isLastInTagHistory(true) | 421 , m_isLastInTagHistory(true) |
| 415 , m_hasRareData(false) | 422 , m_hasRareData(false) |
| 416 , m_isForPage(false) | 423 , m_isForPage(false) |
| 417 , m_tagIsImplicit(false) | 424 , m_tagIsImplicit(false) |
| 418 , m_relationIsAffectedByPseudoContent(false) | 425 , m_relationIsAffectedByPseudoContent(false) |
| 426 , m_relationIsAffectedByPseudoSlotted(false) |
| 419 { | 427 { |
| 420 } | 428 } |
| 421 | 429 |
| 422 inline CSSSelector::CSSSelector(const QualifiedName& tagQName, bool tagIsImplici
t) | 430 inline CSSSelector::CSSSelector(const QualifiedName& tagQName, bool tagIsImplici
t) |
| 423 : m_relation(SubSelector) | 431 : m_relation(SubSelector) |
| 424 , m_match(Tag) | 432 , m_match(Tag) |
| 425 , m_pseudoType(PseudoUnknown) | 433 , m_pseudoType(PseudoUnknown) |
| 426 , m_isLastInSelectorList(false) | 434 , m_isLastInSelectorList(false) |
| 427 , m_isLastInTagHistory(true) | 435 , m_isLastInTagHistory(true) |
| 428 , m_hasRareData(false) | 436 , m_hasRareData(false) |
| 429 , m_isForPage(false) | 437 , m_isForPage(false) |
| 430 , m_tagIsImplicit(tagIsImplicit) | 438 , m_tagIsImplicit(tagIsImplicit) |
| 431 , m_relationIsAffectedByPseudoContent(false) | 439 , m_relationIsAffectedByPseudoContent(false) |
| 440 , m_relationIsAffectedByPseudoSlotted(false) |
| 432 { | 441 { |
| 433 m_data.m_tagQName = tagQName.impl(); | 442 m_data.m_tagQName = tagQName.impl(); |
| 434 m_data.m_tagQName->ref(); | 443 m_data.m_tagQName->ref(); |
| 435 } | 444 } |
| 436 | 445 |
| 437 inline CSSSelector::CSSSelector(const CSSSelector& o) | 446 inline CSSSelector::CSSSelector(const CSSSelector& o) |
| 438 : m_relation(o.m_relation) | 447 : m_relation(o.m_relation) |
| 439 , m_match(o.m_match) | 448 , m_match(o.m_match) |
| 440 , m_pseudoType(o.m_pseudoType) | 449 , m_pseudoType(o.m_pseudoType) |
| 441 , m_isLastInSelectorList(o.m_isLastInSelectorList) | 450 , m_isLastInSelectorList(o.m_isLastInSelectorList) |
| 442 , m_isLastInTagHistory(o.m_isLastInTagHistory) | 451 , m_isLastInTagHistory(o.m_isLastInTagHistory) |
| 443 , m_hasRareData(o.m_hasRareData) | 452 , m_hasRareData(o.m_hasRareData) |
| 444 , m_isForPage(o.m_isForPage) | 453 , m_isForPage(o.m_isForPage) |
| 445 , m_tagIsImplicit(o.m_tagIsImplicit) | 454 , m_tagIsImplicit(o.m_tagIsImplicit) |
| 446 , m_relationIsAffectedByPseudoContent(o.m_relationIsAffectedByPseudoContent) | 455 , m_relationIsAffectedByPseudoContent(o.m_relationIsAffectedByPseudoContent) |
| 456 , m_relationIsAffectedByPseudoSlotted(o.m_relationIsAffectedByPseudoSlotted) |
| 447 { | 457 { |
| 448 if (o.m_match == Tag) { | 458 if (o.m_match == Tag) { |
| 449 m_data.m_tagQName = o.m_data.m_tagQName; | 459 m_data.m_tagQName = o.m_data.m_tagQName; |
| 450 m_data.m_tagQName->ref(); | 460 m_data.m_tagQName->ref(); |
| 451 } else if (o.m_hasRareData) { | 461 } else if (o.m_hasRareData) { |
| 452 m_data.m_rareData = o.m_data.m_rareData; | 462 m_data.m_rareData = o.m_data.m_rareData; |
| 453 m_data.m_rareData->ref(); | 463 m_data.m_rareData->ref(); |
| 454 } else if (o.m_data.m_value) { | 464 } else if (o.m_data.m_value) { |
| 455 m_data.m_value = o.m_data.m_value; | 465 m_data.m_value = o.m_data.m_value; |
| 456 m_data.m_value->ref(); | 466 m_data.m_value->ref(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 if (m_hasRareData) | 499 if (m_hasRareData) |
| 490 return m_data.m_rareData->m_serializingValue; | 500 return m_data.m_rareData->m_serializingValue; |
| 491 // AtomicString is really just a StringImpl* so the cast below is safe. | 501 // AtomicString is really just a StringImpl* so the cast below is safe. |
| 492 // FIXME: Perhaps call sites could be changed to accept StringImpl? | 502 // FIXME: Perhaps call sites could be changed to accept StringImpl? |
| 493 return *reinterpret_cast<const AtomicString*>(&m_data.m_value); | 503 return *reinterpret_cast<const AtomicString*>(&m_data.m_value); |
| 494 } | 504 } |
| 495 | 505 |
| 496 } // namespace blink | 506 } // namespace blink |
| 497 | 507 |
| 498 #endif // CSSSelector_h | 508 #endif // CSSSelector_h |
| OLD | NEW |