Chromium Code Reviews| 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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 230 BottomRightMarginBox, | 230 BottomRightMarginBox, |
| 231 BottomRightCornerMarginBox, | 231 BottomRightCornerMarginBox, |
| 232 LeftTopMarginBox, | 232 LeftTopMarginBox, |
| 233 LeftMiddleMarginBox, | 233 LeftMiddleMarginBox, |
| 234 LeftBottomMarginBox, | 234 LeftBottomMarginBox, |
| 235 RightTopMarginBox, | 235 RightTopMarginBox, |
| 236 RightMiddleMarginBox, | 236 RightMiddleMarginBox, |
| 237 RightBottomMarginBox, | 237 RightBottomMarginBox, |
| 238 }; | 238 }; |
| 239 | 239 |
| 240 enum AttributeFlags { | |
| 241 NoAttributeFlags, | |
| 242 CaseInsensitive, | |
| 243 }; | |
| 244 | |
| 240 PseudoType pseudoType() const | 245 PseudoType pseudoType() const |
| 241 { | 246 { |
| 242 if (m_pseudoType == PseudoNotParsed) | 247 if (m_pseudoType == PseudoNotParsed) |
| 243 extractPseudoType(); | 248 extractPseudoType(); |
| 244 return static_cast<PseudoType>(m_pseudoType); | 249 return static_cast<PseudoType>(m_pseudoType); |
| 245 } | 250 } |
| 246 | 251 |
| 247 static PseudoType parsePseudoType(const AtomicString&); | 252 static PseudoType parsePseudoType(const AtomicString&); |
| 248 static PseudoId pseudoId(PseudoType); | 253 static PseudoId pseudoId(PseudoType); |
| 249 | 254 |
| 250 // Selectors are kept in an array by CSSSelectorList. The next component of the selector is | 255 // Selectors are kept in an array by CSSSelectorList. The next component of the selector is |
| 251 // the next item in the array. | 256 // the next item in the array. |
| 252 const CSSSelector* tagHistory() const { return m_isLastInTagHistory ? 0 : const_cast<CSSSelector*>(this + 1); } | 257 const CSSSelector* tagHistory() const { return m_isLastInTagHistory ? 0 : const_cast<CSSSelector*>(this + 1); } |
| 253 | 258 |
| 254 const QualifiedName& tagQName() const; | 259 const QualifiedName& tagQName() const; |
| 255 const AtomicString& value() const; | 260 const AtomicString& value() const; |
| 256 | 261 |
| 257 // WARNING: Use of QualifiedName by attribute() is a lie. | 262 // WARNING: Use of QualifiedName by attribute() is a lie. |
| 258 // attribute() will return a QualifiedName with prefix and namespaceURI | 263 // attribute() will return a QualifiedName with prefix and namespaceURI |
| 259 // set to starAtom to mean "matches any namespace". Be very careful | 264 // set to starAtom to mean "matches any namespace". Be very careful |
| 260 // how you use the returned QualifiedName. | 265 // how you use the returned QualifiedName. |
| 261 // http://www.w3.org/TR/css3-selectors/#attrnmsp | 266 // http://www.w3.org/TR/css3-selectors/#attrnmsp |
| 262 const QualifiedName& attribute() const; | 267 const QualifiedName& attribute() const; |
| 268 unsigned attributeFlags() const; | |
|
eseidel
2014/05/07 18:12:58
Can't this return the enum? Normally we store enu
fs
2014/06/12 16:42:31
Sure (done in [1]). It doesn't really add much in
| |
| 263 // Returns the argument of a parameterized selector. For example, nth-ch ild(2) would have an argument of 2. | 269 // Returns the argument of a parameterized selector. For example, nth-ch ild(2) would have an argument of 2. |
| 264 const AtomicString& argument() const { return m_hasRareData ? m_data.m_r areData->m_argument : nullAtom; } | 270 const AtomicString& argument() const { return m_hasRareData ? m_data.m_r areData->m_argument : nullAtom; } |
| 265 const CSSSelectorList* selectorList() const { return m_hasRareData ? m_d ata.m_rareData->m_selectorList.get() : 0; } | 271 const CSSSelectorList* selectorList() const { return m_hasRareData ? m_d ata.m_rareData->m_selectorList.get() : 0; } |
| 266 | 272 |
| 267 #ifndef NDEBUG | 273 #ifndef NDEBUG |
| 268 void show() const; | 274 void show() const; |
| 269 void show(int indent) const; | 275 void show(int indent) const; |
| 270 #endif | 276 #endif |
| 271 | 277 |
| 272 void setValue(const AtomicString&); | 278 void setValue(const AtomicString&); |
| 273 void setAttribute(const QualifiedName&); | 279 void setAttribute(const QualifiedName&, unsigned flags); |
| 274 void setArgument(const AtomicString&); | 280 void setArgument(const AtomicString&); |
| 275 void setSelectorList(PassOwnPtr<CSSSelectorList>); | 281 void setSelectorList(PassOwnPtr<CSSSelectorList>); |
| 276 void setMatchUserAgentOnly(); | 282 void setMatchUserAgentOnly(); |
| 277 | 283 |
| 278 bool parseNth() const; | 284 bool parseNth() const; |
| 279 bool matchNth(int count) const; | 285 bool matchNth(int count) const; |
| 280 | 286 |
| 281 bool matchesPseudoElement() const; | 287 bool matchesPseudoElement() const; |
| 282 bool isUnknownPseudoElement() const; | 288 bool isUnknownPseudoElement() const; |
| 283 bool isCustomPseudoElement() const; | 289 bool isCustomPseudoElement() const; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 330 static PassRefPtr<RareData> create(const AtomicString& value) { retu rn adoptRef(new RareData(value)); } | 336 static PassRefPtr<RareData> create(const AtomicString& value) { retu rn adoptRef(new RareData(value)); } |
| 331 ~RareData(); | 337 ~RareData(); |
| 332 | 338 |
| 333 bool parseNth(); | 339 bool parseNth(); |
| 334 bool matchNth(int count); | 340 bool matchNth(int count); |
| 335 | 341 |
| 336 AtomicString m_value; | 342 AtomicString m_value; |
| 337 int m_a; // Used for :nth-* | 343 int m_a; // Used for :nth-* |
| 338 int m_b; // Used for :nth-* | 344 int m_b; // Used for :nth-* |
| 339 QualifiedName m_attribute; // used for attribute selector | 345 QualifiedName m_attribute; // used for attribute selector |
| 346 unsigned m_attributeFlags; // used for attribute selector (with valu e) | |
|
eseidel
2014/05/29 00:25:01
I think we have a ton of CSSSelector objects... I
apavlov
2014/06/11 12:26:19
This is RareData. Consequently, it will be found i
fs
2014/06/12 16:42:31
Yes, hopefully they are indeed "rare". Disregardin
| |
| 340 AtomicString m_argument; // Used for :contains, :lang, :nth-* | 347 AtomicString m_argument; // Used for :contains, :lang, :nth-* |
| 341 OwnPtr<CSSSelectorList> m_selectorList; // Used for :-webkit-any and :not | 348 OwnPtr<CSSSelectorList> m_selectorList; // Used for :-webkit-any and :not |
| 342 | 349 |
| 343 private: | 350 private: |
| 344 RareData(const AtomicString& value); | 351 RareData(const AtomicString& value); |
| 345 }; | 352 }; |
| 346 void createRareData(); | 353 void createRareData(); |
| 347 | 354 |
| 348 union DataUnion { | 355 union DataUnion { |
| 349 DataUnion() : m_value(0) { } | 356 DataUnion() : m_value(0) { } |
| 350 StringImpl* m_value; | 357 StringImpl* m_value; |
| 351 QualifiedName::QualifiedNameImpl* m_tagQName; | 358 QualifiedName::QualifiedNameImpl* m_tagQName; |
| 352 RareData* m_rareData; | 359 RareData* m_rareData; |
| 353 } m_data; | 360 } m_data; |
| 354 }; | 361 }; |
| 355 | 362 |
| 356 inline const QualifiedName& CSSSelector::attribute() const | 363 inline const QualifiedName& CSSSelector::attribute() const |
| 357 { | 364 { |
| 358 ASSERT(isAttributeSelector()); | 365 ASSERT(isAttributeSelector()); |
| 359 ASSERT(m_hasRareData); | 366 ASSERT(m_hasRareData); |
| 360 return m_data.m_rareData->m_attribute; | 367 return m_data.m_rareData->m_attribute; |
| 361 } | 368 } |
| 362 | 369 |
| 370 inline unsigned CSSSelector::attributeFlags() const | |
| 371 { | |
| 372 ASSERT(isAttributeSelector()); | |
| 373 ASSERT(m_hasRareData); | |
| 374 return m_data.m_rareData->m_attributeFlags; | |
| 375 } | |
| 376 | |
| 363 inline bool CSSSelector::matchesPseudoElement() const | 377 inline bool CSSSelector::matchesPseudoElement() const |
| 364 { | 378 { |
| 365 if (m_pseudoType == PseudoUnknown) | 379 if (m_pseudoType == PseudoUnknown) |
| 366 extractPseudoType(); | 380 extractPseudoType(); |
| 367 return m_match == PseudoElement; | 381 return m_match == PseudoElement; |
| 368 } | 382 } |
| 369 | 383 |
| 370 inline bool CSSSelector::isUnknownPseudoElement() const | 384 inline bool CSSSelector::isUnknownPseudoElement() const |
| 371 { | 385 { |
| 372 return m_match == PseudoElement && m_pseudoType == PseudoUnknown; | 386 return m_match == PseudoElement && m_pseudoType == PseudoUnknown; |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 512 if (m_hasRareData) | 526 if (m_hasRareData) |
| 513 return m_data.m_rareData->m_value; | 527 return m_data.m_rareData->m_value; |
| 514 // AtomicString is really just a StringImpl* so the cast below is safe. | 528 // AtomicString is really just a StringImpl* so the cast below is safe. |
| 515 // FIXME: Perhaps call sites could be changed to accept StringImpl? | 529 // FIXME: Perhaps call sites could be changed to accept StringImpl? |
| 516 return *reinterpret_cast<const AtomicString*>(&m_data.m_value); | 530 return *reinterpret_cast<const AtomicString*>(&m_data.m_value); |
| 517 } | 531 } |
| 518 | 532 |
| 519 } // namespace WebCore | 533 } // namespace WebCore |
| 520 | 534 |
| 521 #endif // CSSSelector_h | 535 #endif // CSSSelector_h |
| OLD | NEW |