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 | 6 * Copyright (C) 2002, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights |
7 * reserved. | 7 * reserved. |
8 * Copyright (C) 2008 David Smith (catfish.man@gmail.com) | 8 * Copyright (C) 2008 David Smith (catfish.man@gmail.com) |
9 * Copyright (C) 2010 Google Inc. All rights reserved. | 9 * Copyright (C) 2010 Google Inc. All rights reserved. |
10 * | 10 * |
(...skipping 890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
901 if (!ValidateSubSelector(sub_selector)) | 901 if (!ValidateSubSelector(sub_selector)) |
902 return false; | 902 return false; |
903 | 903 |
904 prev_sub_selector = sub_selector; | 904 prev_sub_selector = sub_selector; |
905 sub_selector = sub_selector->TagHistory(); | 905 sub_selector = sub_selector->TagHistory(); |
906 } | 906 } |
907 | 907 |
908 return true; | 908 return true; |
909 } | 909 } |
910 | 910 |
911 unsigned CSSSelector::ComputeLinkMatchType() const { | 911 void CSSSelector::UpdateLinkMatchType() { |
912 unsigned link_match_type = kMatchAll; | |
913 | |
914 // Determine if this selector will match a link in visited, unvisited or any | 912 // Determine if this selector will match a link in visited, unvisited or any |
915 // state, or never. | 913 // state, or never. |
916 // :visited never matches other elements than the innermost link element. | 914 // :visited never matches other elements than the innermost link element. |
917 for (const CSSSelector* current = this; current; | 915 for (const CSSSelector* current = this; current; |
918 current = current->TagHistory()) { | 916 current = current->TagHistory()) { |
919 switch (current->GetPseudoType()) { | 917 switch (current->GetPseudoType()) { |
920 case kPseudoNot: { | 918 case kPseudoNot: { |
921 // :not(:visited) is equivalent to :link. Parser enforces that :not | 919 // :not(:visited) is equivalent to :link. Parser enforces that :not |
922 // can't nest. | 920 // can't nest. |
923 DCHECK(current->SelectorList()); | 921 DCHECK(current->SelectorList()); |
924 for (const CSSSelector* sub_selector = current->SelectorList()->First(); | 922 for (const CSSSelector* sub_selector = current->SelectorList()->First(); |
925 sub_selector; sub_selector = sub_selector->TagHistory()) { | 923 sub_selector; sub_selector = sub_selector->TagHistory()) { |
926 PseudoType sub_type = sub_selector->GetPseudoType(); | 924 PseudoType sub_type = sub_selector->GetPseudoType(); |
927 if (sub_type == kPseudoVisited) | 925 if (sub_type == kPseudoVisited) |
928 link_match_type &= ~kMatchVisited; | 926 link_match_type_ &= ~kMatchVisited; |
929 else if (sub_type == kPseudoLink) | 927 else if (sub_type == kPseudoLink) |
930 link_match_type &= ~kMatchLink; | 928 link_match_type_ &= ~kMatchLink; |
931 } | 929 } |
932 } break; | 930 } break; |
933 case kPseudoLink: | 931 case kPseudoLink: |
934 link_match_type &= ~kMatchVisited; | 932 link_match_type_ &= ~kMatchVisited; |
935 break; | 933 break; |
936 case kPseudoVisited: | 934 case kPseudoVisited: |
937 link_match_type &= ~kMatchLink; | 935 link_match_type_ &= ~kMatchLink; |
938 break; | 936 break; |
939 default: | 937 default: |
940 // We don't support :link and :visited inside :-webkit-any. | 938 // We don't support :link and :visited inside :-webkit-any. |
941 break; | 939 break; |
942 } | 940 } |
943 RelationType relation = current->Relation(); | 941 RelationType relation = current->Relation(); |
944 if (relation == kSubSelector) | 942 if (relation == kSubSelector) |
945 continue; | 943 continue; |
946 if (relation != kDescendant && relation != kChild) | 944 if (relation != kDescendant && relation != kChild) |
947 return link_match_type; | 945 return; |
948 if (link_match_type != kMatchAll) | 946 if (link_match_type_ != kMatchAll) |
949 return link_match_type; | 947 return; |
950 } | 948 } |
951 return link_match_type; | |
952 } | 949 } |
953 | 950 |
954 void CSSSelector::SetNth(int a, int b) { | 951 void CSSSelector::SetNth(int a, int b) { |
955 CreateRareData(); | 952 CreateRareData(); |
956 data_.rare_data_->bits_.nth_.a_ = a; | 953 data_.rare_data_->bits_.nth_.a_ = a; |
957 data_.rare_data_->bits_.nth_.b_ = b; | 954 data_.rare_data_->bits_.nth_.b_ = b; |
958 } | 955 } |
959 | 956 |
960 bool CSSSelector::MatchNth(unsigned count) const { | 957 bool CSSSelector::MatchNth(unsigned count) const { |
961 DCHECK(has_rare_data_); | 958 DCHECK(has_rare_data_); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1055 if (count < NthBValue()) | 1052 if (count < NthBValue()) |
1056 return false; | 1053 return false; |
1057 return (count - NthBValue()) % NthAValue() == 0; | 1054 return (count - NthBValue()) % NthAValue() == 0; |
1058 } | 1055 } |
1059 if (count > NthBValue()) | 1056 if (count > NthBValue()) |
1060 return false; | 1057 return false; |
1061 return (NthBValue() - count) % (-NthAValue()) == 0; | 1058 return (NthBValue() - count) % (-NthAValue()) == 0; |
1062 } | 1059 } |
1063 | 1060 |
1064 } // namespace blink | 1061 } // namespace blink |
OLD | NEW |