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 | 4 * Copyright (C) 2004, 2006, 2007, 2008, 2009, 2010, 2013 Apple Inc. All rights |
| 5 * reserved. | 5 * reserved. |
| 6 * | 6 * |
| 7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 301 bool isInsertionPointCrossing() const { | 301 bool isInsertionPointCrossing() const { |
| 302 return m_pseudoType == PseudoHostContext || m_pseudoType == PseudoContent; | 302 return m_pseudoType == PseudoHostContext || m_pseudoType == PseudoContent; |
| 303 } | 303 } |
| 304 bool isIdClassOrAttributeSelector() const; | 304 bool isIdClassOrAttributeSelector() const; |
| 305 | 305 |
| 306 RelationType relation() const { | 306 RelationType relation() const { |
| 307 return static_cast<RelationType>(m_relation); | 307 return static_cast<RelationType>(m_relation); |
| 308 } | 308 } |
| 309 void setRelation(RelationType relation) { | 309 void setRelation(RelationType relation) { |
| 310 m_relation = relation; | 310 m_relation = relation; |
| 311 ASSERT(static_cast<RelationType>(m_relation) == | 311 DCHECK_EQ(static_cast<RelationType>(m_relation), |
| 312 relation); // using a bitfield. | 312 relation); // using a bitfield. |
| 313 } | 313 } |
| 314 | 314 |
| 315 MatchType match() const { return static_cast<MatchType>(m_match); } | 315 MatchType match() const { return static_cast<MatchType>(m_match); } |
| 316 void setMatch(MatchType match) { | 316 void setMatch(MatchType match) { |
| 317 m_match = match; | 317 m_match = match; |
| 318 ASSERT(static_cast<MatchType>(m_match) == match); // using a bitfield. | 318 DCHECK_EQ(static_cast<MatchType>(m_match), match); // using a bitfield. |
| 319 } | 319 } |
| 320 | 320 |
| 321 bool isLastInSelectorList() const { return m_isLastInSelectorList; } | 321 bool isLastInSelectorList() const { return m_isLastInSelectorList; } |
| 322 void setLastInSelectorList() { m_isLastInSelectorList = true; } | 322 void setLastInSelectorList() { m_isLastInSelectorList = true; } |
| 323 bool isLastInTagHistory() const { return m_isLastInTagHistory; } | 323 bool isLastInTagHistory() const { return m_isLastInTagHistory; } |
| 324 void setNotLastInTagHistory() { m_isLastInTagHistory = false; } | 324 void setNotLastInTagHistory() { m_isLastInTagHistory = false; } |
| 325 | 325 |
| 326 // http://dev.w3.org/csswg/selectors4/#compound | 326 // http://dev.w3.org/csswg/selectors4/#compound |
| 327 bool isCompound() const; | 327 bool isCompound() const; |
| 328 | 328 |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 356 unsigned m_pseudoType : 8; // enum PseudoType | 356 unsigned m_pseudoType : 8; // enum PseudoType |
| 357 unsigned m_isLastInSelectorList : 1; | 357 unsigned m_isLastInSelectorList : 1; |
| 358 unsigned m_isLastInTagHistory : 1; | 358 unsigned m_isLastInTagHistory : 1; |
| 359 unsigned m_hasRareData : 1; | 359 unsigned m_hasRareData : 1; |
| 360 unsigned m_isForPage : 1; | 360 unsigned m_isForPage : 1; |
| 361 unsigned m_tagIsImplicit : 1; | 361 unsigned m_tagIsImplicit : 1; |
| 362 unsigned m_relationIsAffectedByPseudoContent : 1; | 362 unsigned m_relationIsAffectedByPseudoContent : 1; |
| 363 | 363 |
| 364 void setPseudoType(PseudoType pseudoType) { | 364 void setPseudoType(PseudoType pseudoType) { |
| 365 m_pseudoType = pseudoType; | 365 m_pseudoType = pseudoType; |
| 366 ASSERT(static_cast<PseudoType>(m_pseudoType) == | 366 DCHECK_EQ(static_cast<PseudoType>(m_pseudoType), |
| 367 pseudoType); // using a bitfield. | 367 pseudoType); // using a bitfield. |
| 368 } | 368 } |
| 369 | 369 |
| 370 unsigned specificityForOneSelector() const; | 370 unsigned specificityForOneSelector() const; |
| 371 unsigned specificityForPage() const; | 371 unsigned specificityForPage() const; |
| 372 | 372 |
| 373 // Hide. | 373 // Hide. |
| 374 CSSSelector& operator=(const CSSSelector&); | 374 CSSSelector& operator=(const CSSSelector&); |
| 375 | 375 |
| 376 struct RareData : public RefCounted<RareData> { | 376 struct RareData : public RefCounted<RareData> { |
| 377 static PassRefPtr<RareData> create(const AtomicString& value) { | 377 static PassRefPtr<RareData> create(const AtomicString& value) { |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 405 | 405 |
| 406 union DataUnion { | 406 union DataUnion { |
| 407 DataUnion() : m_value(nullptr) {} | 407 DataUnion() : m_value(nullptr) {} |
| 408 StringImpl* m_value; | 408 StringImpl* m_value; |
| 409 QualifiedName::QualifiedNameImpl* m_tagQName; | 409 QualifiedName::QualifiedNameImpl* m_tagQName; |
| 410 RareData* m_rareData; | 410 RareData* m_rareData; |
| 411 } m_data; | 411 } m_data; |
| 412 }; | 412 }; |
| 413 | 413 |
| 414 inline const QualifiedName& CSSSelector::attribute() const { | 414 inline const QualifiedName& CSSSelector::attribute() const { |
| 415 ASSERT(isAttributeSelector()); | 415 DCHECK(isAttributeSelector()); |
| 416 ASSERT(m_hasRareData); | 416 DCHECK(m_hasRareData); |
| 417 return m_data.m_rareData->m_attribute; | 417 return m_data.m_rareData->m_attribute; |
| 418 } | 418 } |
| 419 | 419 |
| 420 inline CSSSelector::AttributeMatchType CSSSelector::attributeMatch() const { | 420 inline CSSSelector::AttributeMatchType CSSSelector::attributeMatch() const { |
| 421 ASSERT(isAttributeSelector()); | 421 DCHECK(isAttributeSelector()); |
| 422 ASSERT(m_hasRareData); | 422 DCHECK(m_hasRareData); |
| 423 return m_data.m_rareData->m_bits.m_attributeMatch; | 423 return m_data.m_rareData->m_bits.m_attributeMatch; |
| 424 } | 424 } |
| 425 | 425 |
| 426 inline bool CSSSelector::isASCIILower(const AtomicString& value) { | 426 inline bool CSSSelector::isASCIILower(const AtomicString& value) { |
| 427 for (size_t i = 0; i < value.length(); ++i) { | 427 for (size_t i = 0; i < value.length(); ++i) { |
| 428 if (isASCIIUpper(value[i])) | 428 if (isASCIIUpper(value[i])) |
| 429 return false; | 429 return false; |
| 430 } | 430 } |
| 431 return true; | 431 return true; |
| 432 } | 432 } |
| 433 | 433 |
| 434 inline void CSSSelector::setValue(const AtomicString& value, | 434 inline void CSSSelector::setValue(const AtomicString& value, |
| 435 bool matchLowerCase = false) { | 435 bool matchLowerCase = false) { |
| 436 ASSERT(m_match != Tag); | 436 DCHECK_NE(m_match, static_cast<unsigned>(Tag)); |
|
nikhil.sahni
2017/03/31 15:07:09
Even changing to this it gives error. Can you plea
tkent
2017/03/31 15:59:55
This was fixed as expected.
| |
| 437 if (matchLowerCase && !m_hasRareData && !isASCIILower(value)) { | 437 if (matchLowerCase && !m_hasRareData && !isASCIILower(value)) { |
| 438 createRareData(); | 438 createRareData(); |
| 439 } | 439 } |
| 440 // Need to do ref counting manually for the union. | 440 // Need to do ref counting manually for the union. |
| 441 if (!m_hasRareData) { | 441 if (!m_hasRareData) { |
| 442 if (m_data.m_value) | 442 if (m_data.m_value) |
| 443 m_data.m_value->deref(); | 443 m_data.m_value->deref(); |
| 444 m_data.m_value = value.impl(); | 444 m_data.m_value = value.impl(); |
| 445 m_data.m_value->ref(); | 445 m_data.m_value->ref(); |
| 446 return; | 446 return; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 502 inline CSSSelector::~CSSSelector() { | 502 inline CSSSelector::~CSSSelector() { |
| 503 if (m_match == Tag) | 503 if (m_match == Tag) |
| 504 m_data.m_tagQName->deref(); | 504 m_data.m_tagQName->deref(); |
| 505 else if (m_hasRareData) | 505 else if (m_hasRareData) |
| 506 m_data.m_rareData->deref(); | 506 m_data.m_rareData->deref(); |
| 507 else if (m_data.m_value) | 507 else if (m_data.m_value) |
| 508 m_data.m_value->deref(); | 508 m_data.m_value->deref(); |
| 509 } | 509 } |
| 510 | 510 |
| 511 inline const QualifiedName& CSSSelector::tagQName() const { | 511 inline const QualifiedName& CSSSelector::tagQName() const { |
| 512 ASSERT(m_match == Tag); | 512 DCHECK_EQ(m_match, static_cast<unsigned>(Tag)); |
|
nikhil.sahni
2017/03/31 15:07:09
Even changing to this it gives error. Can you plea
tkent
2017/03/31 15:59:55
This was fixed as expected.
| |
| 513 return *reinterpret_cast<const QualifiedName*>(&m_data.m_tagQName); | 513 return *reinterpret_cast<const QualifiedName*>(&m_data.m_tagQName); |
| 514 } | 514 } |
| 515 | 515 |
| 516 inline const AtomicString& CSSSelector::value() const { | 516 inline const AtomicString& CSSSelector::value() const { |
| 517 ASSERT(m_match != Tag); | 517 DCHECK_NE(m_match, Tag); |
|
tkent
2017/03/31 15:59:55
This caused another build failure.
https://luci-lo
| |
| 518 if (m_hasRareData) | 518 if (m_hasRareData) |
| 519 return m_data.m_rareData->m_matchingValue; | 519 return m_data.m_rareData->m_matchingValue; |
| 520 // AtomicString is really just a StringImpl* so the cast below is safe. | 520 // AtomicString is really just a StringImpl* so the cast below is safe. |
| 521 // FIXME: Perhaps call sites could be changed to accept StringImpl? | 521 // FIXME: Perhaps call sites could be changed to accept StringImpl? |
| 522 return *reinterpret_cast<const AtomicString*>(&m_data.m_value); | 522 return *reinterpret_cast<const AtomicString*>(&m_data.m_value); |
| 523 } | 523 } |
| 524 | 524 |
| 525 inline const AtomicString& CSSSelector::serializingValue() const { | 525 inline const AtomicString& CSSSelector::serializingValue() const { |
| 526 ASSERT(m_match != Tag); | 526 DCHECK_NE(m_match, Tag); |
| 527 if (m_hasRareData) | 527 if (m_hasRareData) |
| 528 return m_data.m_rareData->m_serializingValue; | 528 return m_data.m_rareData->m_serializingValue; |
| 529 // AtomicString is really just a StringImpl* so the cast below is safe. | 529 // AtomicString is really just a StringImpl* so the cast below is safe. |
| 530 // FIXME: Perhaps call sites could be changed to accept StringImpl? | 530 // FIXME: Perhaps call sites could be changed to accept StringImpl? |
| 531 return *reinterpret_cast<const AtomicString*>(&m_data.m_value); | 531 return *reinterpret_cast<const AtomicString*>(&m_data.m_value); |
| 532 } | 532 } |
| 533 | 533 |
| 534 inline bool CSSSelector::isUserActionPseudoClass() const { | 534 inline bool CSSSelector::isUserActionPseudoClass() const { |
| 535 return m_pseudoType == PseudoHover || m_pseudoType == PseudoActive || | 535 return m_pseudoType == PseudoHover || m_pseudoType == PseudoActive || |
| 536 m_pseudoType == PseudoFocus || m_pseudoType == PseudoDrag; | 536 m_pseudoType == PseudoFocus || m_pseudoType == PseudoDrag; |
| 537 } | 537 } |
| 538 | 538 |
| 539 inline bool CSSSelector::isIdClassOrAttributeSelector() const { | 539 inline bool CSSSelector::isIdClassOrAttributeSelector() const { |
| 540 return isAttributeSelector() || match() == CSSSelector::Id || | 540 return isAttributeSelector() || match() == CSSSelector::Id || |
| 541 match() == CSSSelector::Class; | 541 match() == CSSSelector::Class; |
| 542 } | 542 } |
| 543 | 543 |
| 544 } // namespace blink | 544 } // namespace blink |
| 545 | 545 |
| 546 #endif // CSSSelector_h | 546 #endif // CSSSelector_h |
| OLD | NEW |