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 * 2001 Andreas Schlapbach (schlpbch@iam.unibe.ch) | 4 * 2001 Andreas Schlapbach (schlpbch@iam.unibe.ch) |
5 * 2001-2003 Dirk Mueller (mueller@kde.org) | 5 * 2001-2003 Dirk Mueller (mueller@kde.org) |
6 * Copyright (C) 2002, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv
ed. | 6 * Copyright (C) 2002, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv
ed. |
7 * Copyright (C) 2008 David Smith (catfish.man@gmail.com) | 7 * Copyright (C) 2008 David Smith (catfish.man@gmail.com) |
8 * Copyright (C) 2010 Google Inc. All rights reserved. | 8 * Copyright (C) 2010 Google Inc. All rights reserved. |
9 * | 9 * |
10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 void CSSSelector::show() const | 429 void CSSSelector::show() const |
430 { | 430 { |
431 printf("\n******* CSSSelector::show(\"%s\") *******\n", selectorText().ascii
().data()); | 431 printf("\n******* CSSSelector::show(\"%s\") *******\n", selectorText().ascii
().data()); |
432 show(2); | 432 show(2); |
433 printf("******* end *******\n"); | 433 printf("******* end *******\n"); |
434 } | 434 } |
435 #endif | 435 #endif |
436 | 436 |
437 CSSSelector::PseudoType CSSSelector::parsePseudoType(const AtomicString& name, b
ool hasArguments) | 437 CSSSelector::PseudoType CSSSelector::parsePseudoType(const AtomicString& name, b
ool hasArguments) |
438 { | 438 { |
439 CSSSelector::PseudoType pseudoType = nameToPseudoType(name, hasArguments); | 439 PseudoType pseudoType = nameToPseudoType(name, hasArguments); |
440 if (pseudoType != PseudoUnknown) | 440 if (pseudoType != PseudoUnknown) |
441 return pseudoType; | 441 return pseudoType; |
442 | 442 |
443 if (name.startsWith("-webkit-")) | 443 if (name.startsWith("-webkit-")) |
444 return PseudoWebKitCustomElement; | 444 return PseudoWebKitCustomElement; |
445 | 445 |
446 return PseudoUnknown; | 446 return PseudoUnknown; |
447 } | 447 } |
448 | 448 |
449 void CSSSelector::extractPseudoType() const | 449 void CSSSelector::extractPseudoType() const |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 if (sel1 || sel2) | 585 if (sel1 || sel2) |
586 return false; | 586 return false; |
587 | 587 |
588 return true; | 588 return true; |
589 } | 589 } |
590 | 590 |
591 String CSSSelector::selectorText(const String& rightSide) const | 591 String CSSSelector::selectorText(const String& rightSide) const |
592 { | 592 { |
593 StringBuilder str; | 593 StringBuilder str; |
594 | 594 |
595 if (m_match == CSSSelector::Tag && !m_tagIsForNamespaceRule) { | 595 if (m_match == Tag && !m_tagIsForNamespaceRule) { |
596 if (tagQName().prefix().isNull()) | 596 if (tagQName().prefix().isNull()) |
597 str.append(tagQName().localName()); | 597 str.append(tagQName().localName()); |
598 else { | 598 else { |
599 str.append(tagQName().prefix().string()); | 599 str.append(tagQName().prefix().string()); |
600 str.append('|'); | 600 str.append('|'); |
601 str.append(tagQName().localName()); | 601 str.append(tagQName().localName()); |
602 } | 602 } |
603 } | 603 } |
604 | 604 |
605 const CSSSelector* cs = this; | 605 const CSSSelector* cs = this; |
606 while (true) { | 606 while (true) { |
607 if (cs->m_match == CSSSelector::Id) { | 607 if (cs->m_match == Id) { |
608 str.append('#'); | 608 str.append('#'); |
609 serializeIdentifier(cs->value(), str); | 609 serializeIdentifier(cs->value(), str); |
610 } else if (cs->m_match == CSSSelector::Class) { | 610 } else if (cs->m_match == Class) { |
611 str.append('.'); | 611 str.append('.'); |
612 serializeIdentifier(cs->value(), str); | 612 serializeIdentifier(cs->value(), str); |
613 } else if (cs->m_match == CSSSelector::PseudoClass || cs->m_match == CSS
Selector::PagePseudoClass) { | 613 } else if (cs->m_match == PseudoClass || cs->m_match == PagePseudoClass)
{ |
614 str.append(':'); | 614 str.append(':'); |
615 str.append(cs->value()); | 615 str.append(cs->value()); |
616 | 616 |
617 switch (cs->pseudoType()) { | 617 switch (cs->pseudoType()) { |
618 case PseudoNot: | 618 case PseudoNot: |
619 ASSERT(cs->selectorList()); | 619 ASSERT(cs->selectorList()); |
620 str.append('('); | 620 str.append('('); |
621 str.append(cs->selectorList()->first()->selectorText()); | 621 str.append(cs->selectorList()->first()->selectorText()); |
622 str.append(')'); | 622 str.append(')'); |
623 break; | 623 break; |
(...skipping 27 matching lines...) Expand all Loading... |
651 str.append(','); | 651 str.append(','); |
652 str.append(subSelector->selectorText()); | 652 str.append(subSelector->selectorText()); |
653 } | 653 } |
654 str.append(')'); | 654 str.append(')'); |
655 } | 655 } |
656 break; | 656 break; |
657 } | 657 } |
658 default: | 658 default: |
659 break; | 659 break; |
660 } | 660 } |
661 } else if (cs->m_match == CSSSelector::PseudoElement) { | 661 } else if (cs->m_match == PseudoElement) { |
662 str.appendLiteral("::"); | 662 str.appendLiteral("::"); |
663 str.append(cs->value()); | 663 str.append(cs->value()); |
664 | 664 |
665 if (cs->pseudoType() == PseudoContent) { | 665 if (cs->pseudoType() == PseudoContent) { |
666 if (cs->relation() == CSSSelector::SubSelector && cs->tagHistory
()) | 666 if (cs->relation() == SubSelector && cs->tagHistory()) |
667 return cs->tagHistory()->selectorText() + str.toString() + r
ightSide; | 667 return cs->tagHistory()->selectorText() + str.toString() + r
ightSide; |
| 668 } else if (cs->pseudoType() == PseudoCue) { |
| 669 if (cs->selectorList()) { |
| 670 str.append('('); |
| 671 const CSSSelector* firstSubSelector = cs->selectorList()->fi
rst(); |
| 672 for (const CSSSelector* subSelector = firstSubSelector; subS
elector; subSelector = CSSSelectorList::next(*subSelector)) { |
| 673 if (subSelector != firstSubSelector) |
| 674 str.append(','); |
| 675 str.append(subSelector->selectorText()); |
| 676 } |
| 677 str.append(')'); |
| 678 } |
668 } | 679 } |
669 } else if (cs->isAttributeSelector()) { | 680 } else if (cs->isAttributeSelector()) { |
670 str.append('['); | 681 str.append('['); |
671 const AtomicString& prefix = cs->attribute().prefix(); | 682 const AtomicString& prefix = cs->attribute().prefix(); |
672 if (!prefix.isNull()) { | 683 if (!prefix.isNull()) { |
673 str.append(prefix); | 684 str.append(prefix); |
674 str.append('|'); | 685 str.append('|'); |
675 } | 686 } |
676 str.append(cs->attribute().localName()); | 687 str.append(cs->attribute().localName()); |
677 switch (cs->m_match) { | 688 switch (cs->m_match) { |
678 case CSSSelector::AttributeExact: | 689 case AttributeExact: |
679 str.append('='); | 690 str.append('='); |
680 break; | 691 break; |
681 case CSSSelector::AttributeSet: | 692 case AttributeSet: |
682 // set has no operator or value, just the attrName | 693 // set has no operator or value, just the attrName |
683 str.append(']'); | 694 str.append(']'); |
684 break; | 695 break; |
685 case CSSSelector::AttributeList: | 696 case AttributeList: |
686 str.appendLiteral("~="); | 697 str.appendLiteral("~="); |
687 break; | 698 break; |
688 case CSSSelector::AttributeHyphen: | 699 case AttributeHyphen: |
689 str.appendLiteral("|="); | 700 str.appendLiteral("|="); |
690 break; | 701 break; |
691 case CSSSelector::AttributeBegin: | 702 case AttributeBegin: |
692 str.appendLiteral("^="); | 703 str.appendLiteral("^="); |
693 break; | 704 break; |
694 case CSSSelector::AttributeEnd: | 705 case AttributeEnd: |
695 str.appendLiteral("$="); | 706 str.appendLiteral("$="); |
696 break; | 707 break; |
697 case CSSSelector::AttributeContain: | 708 case AttributeContain: |
698 str.appendLiteral("*="); | 709 str.appendLiteral("*="); |
699 break; | 710 break; |
700 default: | 711 default: |
701 break; | 712 break; |
702 } | 713 } |
703 if (cs->m_match != CSSSelector::AttributeSet) { | 714 if (cs->m_match != AttributeSet) { |
704 serializeString(cs->value(), str); | 715 serializeString(cs->value(), str); |
705 if (cs->attributeMatchType() == CaseInsensitive) | 716 if (cs->attributeMatchType() == CaseInsensitive) |
706 str.appendLiteral(" i"); | 717 str.appendLiteral(" i"); |
707 str.append(']'); | 718 str.append(']'); |
708 } | 719 } |
709 } | 720 } |
710 if (cs->relation() != CSSSelector::SubSelector || !cs->tagHistory()) | 721 if (cs->relation() != SubSelector || !cs->tagHistory()) |
711 break; | 722 break; |
712 cs = cs->tagHistory(); | 723 cs = cs->tagHistory(); |
713 } | 724 } |
714 | 725 |
715 if (const CSSSelector* tagHistory = cs->tagHistory()) { | 726 if (const CSSSelector* tagHistory = cs->tagHistory()) { |
716 switch (cs->relation()) { | 727 switch (cs->relation()) { |
717 case CSSSelector::Descendant: | 728 case Descendant: |
718 return tagHistory->selectorText(" " + str.toString() + rightSide); | 729 return tagHistory->selectorText(" " + str.toString() + rightSide); |
719 case CSSSelector::Child: | 730 case Child: |
720 return tagHistory->selectorText(" > " + str.toString() + rightSide); | 731 return tagHistory->selectorText(" > " + str.toString() + rightSide); |
721 case CSSSelector::ShadowDeep: | 732 case ShadowDeep: |
722 return tagHistory->selectorText(" /deep/ " + str.toString() + rightS
ide); | 733 return tagHistory->selectorText(" /deep/ " + str.toString() + rightS
ide); |
723 case CSSSelector::DirectAdjacent: | 734 case DirectAdjacent: |
724 return tagHistory->selectorText(" + " + str.toString() + rightSide); | 735 return tagHistory->selectorText(" + " + str.toString() + rightSide); |
725 case CSSSelector::IndirectAdjacent: | 736 case IndirectAdjacent: |
726 return tagHistory->selectorText(" ~ " + str.toString() + rightSide); | 737 return tagHistory->selectorText(" ~ " + str.toString() + rightSide); |
727 case CSSSelector::SubSelector: | 738 case SubSelector: |
728 ASSERT_NOT_REACHED(); | 739 ASSERT_NOT_REACHED(); |
729 case CSSSelector::ShadowPseudo: | 740 case ShadowPseudo: |
730 return tagHistory->selectorText(str.toString() + rightSide); | 741 return tagHistory->selectorText(str.toString() + rightSide); |
731 } | 742 } |
732 } | 743 } |
733 return str.toString() + rightSide; | 744 return str.toString() + rightSide; |
734 } | 745 } |
735 | 746 |
736 void CSSSelector::setAttribute(const QualifiedName& value, AttributeMatchType ma
tchType) | 747 void CSSSelector::setAttribute(const QualifiedName& value, AttributeMatchType ma
tchType) |
737 { | 748 { |
738 createRareData(); | 749 createRareData(); |
739 m_data.m_rareData->m_attribute = value; | 750 m_data.m_rareData->m_attribute = value; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
805 | 816 |
806 bool CSSSelector::isCompound() const | 817 bool CSSSelector::isCompound() const |
807 { | 818 { |
808 if (!validateSubSelector(this)) | 819 if (!validateSubSelector(this)) |
809 return false; | 820 return false; |
810 | 821 |
811 const CSSSelector* prevSubSelector = this; | 822 const CSSSelector* prevSubSelector = this; |
812 const CSSSelector* subSelector = tagHistory(); | 823 const CSSSelector* subSelector = tagHistory(); |
813 | 824 |
814 while (subSelector) { | 825 while (subSelector) { |
815 if (prevSubSelector->relation() != CSSSelector::SubSelector) | 826 if (prevSubSelector->relation() != SubSelector) |
816 return false; | 827 return false; |
817 if (!validateSubSelector(subSelector)) | 828 if (!validateSubSelector(subSelector)) |
818 return false; | 829 return false; |
819 | 830 |
820 prevSubSelector = subSelector; | 831 prevSubSelector = subSelector; |
821 subSelector = subSelector->tagHistory(); | 832 subSelector = subSelector->tagHistory(); |
822 } | 833 } |
823 | 834 |
824 return true; | 835 return true; |
825 } | 836 } |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
908 if (count < nthBValue()) | 919 if (count < nthBValue()) |
909 return false; | 920 return false; |
910 return (count - nthBValue()) % nthAValue() == 0; | 921 return (count - nthBValue()) % nthAValue() == 0; |
911 } | 922 } |
912 if (count > nthBValue()) | 923 if (count > nthBValue()) |
913 return false; | 924 return false; |
914 return (nthBValue() - count) % (-nthAValue()) == 0; | 925 return (nthBValue() - count) % (-nthAValue()) == 0; |
915 } | 926 } |
916 | 927 |
917 } // namespace blink | 928 } // namespace blink |
OLD | NEW |