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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 bool isInsertionPointCrossing() const { | 299 bool isInsertionPointCrossing() const { |
300 return m_pseudoType == PseudoHostContext || m_pseudoType == PseudoContent; | 300 return m_pseudoType == PseudoHostContext || m_pseudoType == PseudoContent; |
301 } | 301 } |
302 bool isIdClassOrAttributeSelector() const; | 302 bool isIdClassOrAttributeSelector() const; |
303 | 303 |
304 RelationType relation() const { | 304 RelationType relation() const { |
305 return static_cast<RelationType>(m_relation); | 305 return static_cast<RelationType>(m_relation); |
306 } | 306 } |
307 void setRelation(RelationType relation) { | 307 void setRelation(RelationType relation) { |
308 m_relation = relation; | 308 m_relation = relation; |
309 ASSERT(static_cast<RelationType>(m_relation) == | 309 DCHECK_EQ(static_cast<RelationType>(m_relation), |
310 relation); // using a bitfield. | 310 relation); // using a bitfield. |
311 } | 311 } |
312 | 312 |
313 MatchType match() const { return static_cast<MatchType>(m_match); } | 313 MatchType match() const { return static_cast<MatchType>(m_match); } |
314 void setMatch(MatchType match) { | 314 void setMatch(MatchType match) { |
315 m_match = match; | 315 m_match = match; |
316 ASSERT(static_cast<MatchType>(m_match) == match); // using a bitfield. | 316 DCHECK_EQ(static_cast<MatchType>(m_match), match); // using a bitfield. |
317 } | 317 } |
318 | 318 |
319 bool isLastInSelectorList() const { return m_isLastInSelectorList; } | 319 bool isLastInSelectorList() const { return m_isLastInSelectorList; } |
320 void setLastInSelectorList() { m_isLastInSelectorList = true; } | 320 void setLastInSelectorList() { m_isLastInSelectorList = true; } |
321 bool isLastInTagHistory() const { return m_isLastInTagHistory; } | 321 bool isLastInTagHistory() const { return m_isLastInTagHistory; } |
322 void setNotLastInTagHistory() { m_isLastInTagHistory = false; } | 322 void setNotLastInTagHistory() { m_isLastInTagHistory = false; } |
323 | 323 |
324 // http://dev.w3.org/csswg/selectors4/#compound | 324 // http://dev.w3.org/csswg/selectors4/#compound |
325 bool isCompound() const; | 325 bool isCompound() const; |
326 | 326 |
(...skipping 27 matching lines...) Expand all Loading... |
354 unsigned m_pseudoType : 8; // enum PseudoType | 354 unsigned m_pseudoType : 8; // enum PseudoType |
355 unsigned m_isLastInSelectorList : 1; | 355 unsigned m_isLastInSelectorList : 1; |
356 unsigned m_isLastInTagHistory : 1; | 356 unsigned m_isLastInTagHistory : 1; |
357 unsigned m_hasRareData : 1; | 357 unsigned m_hasRareData : 1; |
358 unsigned m_isForPage : 1; | 358 unsigned m_isForPage : 1; |
359 unsigned m_tagIsImplicit : 1; | 359 unsigned m_tagIsImplicit : 1; |
360 unsigned m_relationIsAffectedByPseudoContent : 1; | 360 unsigned m_relationIsAffectedByPseudoContent : 1; |
361 | 361 |
362 void setPseudoType(PseudoType pseudoType) { | 362 void setPseudoType(PseudoType pseudoType) { |
363 m_pseudoType = pseudoType; | 363 m_pseudoType = pseudoType; |
364 ASSERT(static_cast<PseudoType>(m_pseudoType) == | 364 DCHECK_EQ(static_cast<PseudoType>(m_pseudoType), |
365 pseudoType); // using a bitfield. | 365 pseudoType); // using a bitfield. |
366 } | 366 } |
367 | 367 |
368 unsigned specificityForOneSelector() const; | 368 unsigned specificityForOneSelector() const; |
369 unsigned specificityForPage() const; | 369 unsigned specificityForPage() const; |
370 | 370 |
371 // Hide. | 371 // Hide. |
372 CSSSelector& operator=(const CSSSelector&); | 372 CSSSelector& operator=(const CSSSelector&); |
373 | 373 |
374 struct RareData : public RefCounted<RareData> { | 374 struct RareData : public RefCounted<RareData> { |
375 static PassRefPtr<RareData> create(const AtomicString& value) { | 375 static PassRefPtr<RareData> create(const AtomicString& value) { |
(...skipping 27 matching lines...) Expand all Loading... |
403 | 403 |
404 union DataUnion { | 404 union DataUnion { |
405 DataUnion() : m_value(nullptr) {} | 405 DataUnion() : m_value(nullptr) {} |
406 StringImpl* m_value; | 406 StringImpl* m_value; |
407 QualifiedName::QualifiedNameImpl* m_tagQName; | 407 QualifiedName::QualifiedNameImpl* m_tagQName; |
408 RareData* m_rareData; | 408 RareData* m_rareData; |
409 } m_data; | 409 } m_data; |
410 }; | 410 }; |
411 | 411 |
412 inline const QualifiedName& CSSSelector::attribute() const { | 412 inline const QualifiedName& CSSSelector::attribute() const { |
413 ASSERT(isAttributeSelector()); | 413 DCHECK(isAttributeSelector()); |
414 ASSERT(m_hasRareData); | 414 DCHECK(m_hasRareData); |
415 return m_data.m_rareData->m_attribute; | 415 return m_data.m_rareData->m_attribute; |
416 } | 416 } |
417 | 417 |
418 inline CSSSelector::AttributeMatchType CSSSelector::attributeMatch() const { | 418 inline CSSSelector::AttributeMatchType CSSSelector::attributeMatch() const { |
419 ASSERT(isAttributeSelector()); | 419 DCHECK(isAttributeSelector()); |
420 ASSERT(m_hasRareData); | 420 DCHECK(m_hasRareData); |
421 return m_data.m_rareData->m_bits.m_attributeMatch; | 421 return m_data.m_rareData->m_bits.m_attributeMatch; |
422 } | 422 } |
423 | 423 |
424 inline bool CSSSelector::isASCIILower(const AtomicString& value) { | 424 inline bool CSSSelector::isASCIILower(const AtomicString& value) { |
425 for (size_t i = 0; i < value.length(); ++i) { | 425 for (size_t i = 0; i < value.length(); ++i) { |
426 if (isASCIIUpper(value[i])) | 426 if (isASCIIUpper(value[i])) |
427 return false; | 427 return false; |
428 } | 428 } |
429 return true; | 429 return true; |
430 } | 430 } |
431 | 431 |
432 inline void CSSSelector::setValue(const AtomicString& value, | 432 inline void CSSSelector::setValue(const AtomicString& value, |
433 bool matchLowerCase = false) { | 433 bool matchLowerCase = false) { |
434 ASSERT(m_match != Tag); | 434 DCHECK_NE(m_match, Tag); |
435 if (matchLowerCase && !m_hasRareData && !isASCIILower(value)) { | 435 if (matchLowerCase && !m_hasRareData && !isASCIILower(value)) { |
436 createRareData(); | 436 createRareData(); |
437 } | 437 } |
438 // Need to do ref counting manually for the union. | 438 // Need to do ref counting manually for the union. |
439 if (!m_hasRareData) { | 439 if (!m_hasRareData) { |
440 if (m_data.m_value) | 440 if (m_data.m_value) |
441 m_data.m_value->deref(); | 441 m_data.m_value->deref(); |
442 m_data.m_value = value.impl(); | 442 m_data.m_value = value.impl(); |
443 m_data.m_value->ref(); | 443 m_data.m_value->ref(); |
444 return; | 444 return; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 inline CSSSelector::~CSSSelector() { | 500 inline CSSSelector::~CSSSelector() { |
501 if (m_match == Tag) | 501 if (m_match == Tag) |
502 m_data.m_tagQName->deref(); | 502 m_data.m_tagQName->deref(); |
503 else if (m_hasRareData) | 503 else if (m_hasRareData) |
504 m_data.m_rareData->deref(); | 504 m_data.m_rareData->deref(); |
505 else if (m_data.m_value) | 505 else if (m_data.m_value) |
506 m_data.m_value->deref(); | 506 m_data.m_value->deref(); |
507 } | 507 } |
508 | 508 |
509 inline const QualifiedName& CSSSelector::tagQName() const { | 509 inline const QualifiedName& CSSSelector::tagQName() const { |
510 ASSERT(m_match == Tag); | 510 DCHECK_EQ(m_match, Tag); |
511 return *reinterpret_cast<const QualifiedName*>(&m_data.m_tagQName); | 511 return *reinterpret_cast<const QualifiedName*>(&m_data.m_tagQName); |
512 } | 512 } |
513 | 513 |
514 inline const AtomicString& CSSSelector::value() const { | 514 inline const AtomicString& CSSSelector::value() const { |
515 ASSERT(m_match != Tag); | 515 DCHECK_NE(m_match, Tag); |
516 if (m_hasRareData) | 516 if (m_hasRareData) |
517 return m_data.m_rareData->m_matchingValue; | 517 return m_data.m_rareData->m_matchingValue; |
518 // AtomicString is really just a StringImpl* so the cast below is safe. | 518 // AtomicString is really just a StringImpl* so the cast below is safe. |
519 // FIXME: Perhaps call sites could be changed to accept StringImpl? | 519 // FIXME: Perhaps call sites could be changed to accept StringImpl? |
520 return *reinterpret_cast<const AtomicString*>(&m_data.m_value); | 520 return *reinterpret_cast<const AtomicString*>(&m_data.m_value); |
521 } | 521 } |
522 | 522 |
523 inline const AtomicString& CSSSelector::serializingValue() const { | 523 inline const AtomicString& CSSSelector::serializingValue() const { |
524 ASSERT(m_match != Tag); | 524 DCHECK_NE(m_match, Tag); |
525 if (m_hasRareData) | 525 if (m_hasRareData) |
526 return m_data.m_rareData->m_serializingValue; | 526 return m_data.m_rareData->m_serializingValue; |
527 // AtomicString is really just a StringImpl* so the cast below is safe. | 527 // AtomicString is really just a StringImpl* so the cast below is safe. |
528 // FIXME: Perhaps call sites could be changed to accept StringImpl? | 528 // FIXME: Perhaps call sites could be changed to accept StringImpl? |
529 return *reinterpret_cast<const AtomicString*>(&m_data.m_value); | 529 return *reinterpret_cast<const AtomicString*>(&m_data.m_value); |
530 } | 530 } |
531 | 531 |
532 inline bool CSSSelector::isUserActionPseudoClass() const { | 532 inline bool CSSSelector::isUserActionPseudoClass() const { |
533 return m_pseudoType == PseudoHover || m_pseudoType == PseudoActive || | 533 return m_pseudoType == PseudoHover || m_pseudoType == PseudoActive || |
534 m_pseudoType == PseudoFocus || m_pseudoType == PseudoDrag; | 534 m_pseudoType == PseudoFocus || m_pseudoType == PseudoDrag; |
535 } | 535 } |
536 | 536 |
537 inline bool CSSSelector::isIdClassOrAttributeSelector() const { | 537 inline bool CSSSelector::isIdClassOrAttributeSelector() const { |
538 return isAttributeSelector() || match() == CSSSelector::Id || | 538 return isAttributeSelector() || match() == CSSSelector::Id || |
539 match() == CSSSelector::Class; | 539 match() == CSSSelector::Class; |
540 } | 540 } |
541 | 541 |
542 } // namespace blink | 542 } // namespace blink |
543 | 543 |
544 #endif // CSSSelector_h | 544 #endif // CSSSelector_h |
OLD | NEW |