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 13 matching lines...) Expand all Loading... |
24 * Boston, MA 02110-1301, USA. | 24 * Boston, MA 02110-1301, USA. |
25 */ | 25 */ |
26 | 26 |
27 #include "core/css/CSSSelector.h" | 27 #include "core/css/CSSSelector.h" |
28 | 28 |
29 #include <algorithm> | 29 #include <algorithm> |
30 #include <memory> | 30 #include <memory> |
31 #include "core/HTMLNames.h" | 31 #include "core/HTMLNames.h" |
32 #include "core/css/CSSMarkup.h" | 32 #include "core/css/CSSMarkup.h" |
33 #include "core/css/CSSSelectorList.h" | 33 #include "core/css/CSSSelectorList.h" |
34 #include "core/css/parser/CSSParserContext.h" | |
35 #include "platform/RuntimeEnabledFeatures.h" | 34 #include "platform/RuntimeEnabledFeatures.h" |
36 #include "platform/wtf/Assertions.h" | 35 #include "platform/wtf/Assertions.h" |
37 #include "platform/wtf/HashMap.h" | 36 #include "platform/wtf/HashMap.h" |
38 #include "platform/wtf/StdLibExtras.h" | 37 #include "platform/wtf/StdLibExtras.h" |
39 #include "platform/wtf/text/StringBuilder.h" | 38 #include "platform/wtf/text/StringBuilder.h" |
40 | 39 |
41 #ifndef NDEBUG | 40 #ifndef NDEBUG |
42 #include <stdio.h> | 41 #include <stdio.h> |
43 #endif | 42 #endif |
44 | 43 |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 } | 482 } |
484 | 483 |
485 PseudoId CSSSelector::ParsePseudoId(const String& name) { | 484 PseudoId CSSSelector::ParsePseudoId(const String& name) { |
486 unsigned name_without_colons_start = | 485 unsigned name_without_colons_start = |
487 name[0] == ':' ? (name[1] == ':' ? 2 : 1) : 0; | 486 name[0] == ':' ? (name[1] == ':' ? 2 : 1) : 0; |
488 return GetPseudoId(ParsePseudoType( | 487 return GetPseudoId(ParsePseudoType( |
489 AtomicString(name.Substring(name_without_colons_start)), false)); | 488 AtomicString(name.Substring(name_without_colons_start)), false)); |
490 } | 489 } |
491 | 490 |
492 void CSSSelector::UpdatePseudoType(const AtomicString& value, | 491 void CSSSelector::UpdatePseudoType(const AtomicString& value, |
493 const CSSParserContext& context, | |
494 bool has_arguments) { | 492 bool has_arguments) { |
495 DCHECK(match_ == kPseudoClass || match_ == kPseudoElement || | 493 DCHECK(match_ == kPseudoClass || match_ == kPseudoElement || |
496 match_ == kPagePseudoClass); | 494 match_ == kPagePseudoClass); |
497 | 495 |
498 SetValue(value); | 496 SetValue(value); |
499 SetPseudoType(ParsePseudoType(value, has_arguments)); | 497 SetPseudoType(ParsePseudoType(value, has_arguments)); |
500 | 498 |
501 switch (pseudo_type_) { | 499 switch (pseudo_type_) { |
502 case kPseudoAfter: | 500 case kPseudoAfter: |
503 case kPseudoBefore: | 501 case kPseudoBefore: |
(...skipping 12 matching lines...) Expand all Loading... |
516 case kPseudoScrollbar: | 514 case kPseudoScrollbar: |
517 case kPseudoScrollbarCorner: | 515 case kPseudoScrollbarCorner: |
518 case kPseudoScrollbarButton: | 516 case kPseudoScrollbarButton: |
519 case kPseudoScrollbarThumb: | 517 case kPseudoScrollbarThumb: |
520 case kPseudoScrollbarTrack: | 518 case kPseudoScrollbarTrack: |
521 case kPseudoScrollbarTrackPiece: | 519 case kPseudoScrollbarTrackPiece: |
522 case kPseudoSelection: | 520 case kPseudoSelection: |
523 case kPseudoWebKitCustomElement: | 521 case kPseudoWebKitCustomElement: |
524 case kPseudoBlinkInternalElement: | 522 case kPseudoBlinkInternalElement: |
525 case kPseudoContent: | 523 case kPseudoContent: |
| 524 case kPseudoShadow: |
526 case kPseudoSlotted: | 525 case kPseudoSlotted: |
527 if (match_ != kPseudoElement) | 526 if (match_ != kPseudoElement) |
528 pseudo_type_ = kPseudoUnknown; | 527 pseudo_type_ = kPseudoUnknown; |
529 break; | 528 break; |
530 case kPseudoShadow: | |
531 if (match_ != kPseudoElement || context.IsDynamicProfile()) | |
532 pseudo_type_ = kPseudoUnknown; | |
533 break; | |
534 case kPseudoFirstPage: | 529 case kPseudoFirstPage: |
535 case kPseudoLeftPage: | 530 case kPseudoLeftPage: |
536 case kPseudoRightPage: | 531 case kPseudoRightPage: |
537 if (match_ != kPagePseudoClass) | 532 if (match_ != kPagePseudoClass) |
538 pseudo_type_ = kPseudoUnknown; | 533 pseudo_type_ = kPseudoUnknown; |
539 break; | 534 break; |
540 case kPseudoActive: | 535 case kPseudoActive: |
541 case kPseudoAny: | 536 case kPseudoAny: |
542 case kPseudoAnyLink: | 537 case kPseudoAnyLink: |
543 case kPseudoAutofill: | 538 case kPseudoAutofill: |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
767 cs = cs->TagHistory(); | 762 cs = cs->TagHistory(); |
768 } | 763 } |
769 | 764 |
770 if (const CSSSelector* tag_history = cs->TagHistory()) { | 765 if (const CSSSelector* tag_history = cs->TagHistory()) { |
771 switch (cs->Relation()) { | 766 switch (cs->Relation()) { |
772 case kDescendant: | 767 case kDescendant: |
773 return tag_history->SelectorText(" " + str.ToString() + right_side); | 768 return tag_history->SelectorText(" " + str.ToString() + right_side); |
774 case kChild: | 769 case kChild: |
775 return tag_history->SelectorText(" > " + str.ToString() + right_side); | 770 return tag_history->SelectorText(" > " + str.ToString() + right_side); |
776 case kShadowDeep: | 771 case kShadowDeep: |
777 case kShadowDeepAsDescendant: | |
778 return tag_history->SelectorText(" /deep/ " + str.ToString() + | 772 return tag_history->SelectorText(" /deep/ " + str.ToString() + |
779 right_side); | 773 right_side); |
780 case kShadowPiercingDescendant: | 774 case kShadowPiercingDescendant: |
781 return tag_history->SelectorText(" >>> " + str.ToString() + right_side); | 775 return tag_history->SelectorText(" >>> " + str.ToString() + right_side); |
782 case kDirectAdjacent: | 776 case kDirectAdjacent: |
783 return tag_history->SelectorText(" + " + str.ToString() + right_side); | 777 return tag_history->SelectorText(" + " + str.ToString() + right_side); |
784 case kIndirectAdjacent: | 778 case kIndirectAdjacent: |
785 return tag_history->SelectorText(" ~ " + str.ToString() + right_side); | 779 return tag_history->SelectorText(" ~ " + str.ToString() + right_side); |
786 case kSubSelector: | 780 case kSubSelector: |
787 NOTREACHED(); | 781 NOTREACHED(); |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1029 if (count < NthBValue()) | 1023 if (count < NthBValue()) |
1030 return false; | 1024 return false; |
1031 return (count - NthBValue()) % NthAValue() == 0; | 1025 return (count - NthBValue()) % NthAValue() == 0; |
1032 } | 1026 } |
1033 if (count > NthBValue()) | 1027 if (count > NthBValue()) |
1034 return false; | 1028 return false; |
1035 return (NthBValue() - count) % (-NthAValue()) == 0; | 1029 return (NthBValue() - count) % (-NthAValue()) == 0; |
1036 } | 1030 } |
1037 | 1031 |
1038 } // namespace blink | 1032 } // namespace blink |
OLD | NEW |