| 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 |
| 7 * reserved. |
| 7 * Copyright (C) 2008 David Smith (catfish.man@gmail.com) | 8 * Copyright (C) 2008 David Smith (catfish.man@gmail.com) |
| 8 * Copyright (C) 2010 Google Inc. All rights reserved. | 9 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 9 * | 10 * |
| 10 * This library is free software; you can redistribute it and/or | 11 * This library is free software; you can redistribute it and/or |
| 11 * modify it under the terms of the GNU Library General Public | 12 * modify it under the terms of the GNU Library General Public |
| 12 * License as published by the Free Software Foundation; either | 13 * License as published by the Free Software Foundation; either |
| 13 * version 2 of the License, or (at your option) any later version. | 14 * version 2 of the License, or (at your option) any later version. |
| 14 * | 15 * |
| 15 * This library is distributed in the hope that it will be useful, | 16 * This library is distributed in the hope that it will be useful, |
| 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 total |= classMask; | 87 total |= classMask; |
| 87 else if ((temp & elementMask) < (total & elementMask)) | 88 else if ((temp & elementMask) < (total & elementMask)) |
| 88 total |= elementMask; | 89 total |= elementMask; |
| 89 else | 90 else |
| 90 total = temp; | 91 total = temp; |
| 91 } | 92 } |
| 92 return total; | 93 return total; |
| 93 } | 94 } |
| 94 | 95 |
| 95 inline unsigned CSSSelector::specificityForOneSelector() const { | 96 inline unsigned CSSSelector::specificityForOneSelector() const { |
| 96 // FIXME: Pseudo-elements and pseudo-classes do not have the same specificity.
This function | 97 // FIXME: Pseudo-elements and pseudo-classes do not have the same specificity. |
| 97 // isn't quite correct. | 98 // This function isn't quite correct. |
| 98 // http://www.w3.org/TR/selectors/#specificity | 99 // http://www.w3.org/TR/selectors/#specificity |
| 99 switch (m_match) { | 100 switch (m_match) { |
| 100 case Id: | 101 case Id: |
| 101 return 0x010000; | 102 return 0x010000; |
| 102 case PseudoClass: | 103 case PseudoClass: |
| 103 switch (getPseudoType()) { | 104 switch (getPseudoType()) { |
| 104 case PseudoHost: | 105 case PseudoHost: |
| 105 case PseudoHostContext: | 106 case PseudoHostContext: |
| 106 // We dynamically compute the specificity of :host and :host-context | 107 // We dynamically compute the specificity of :host and :host-context |
| 107 // during matching. | 108 // during matching. |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 | 392 |
| 392 class NameToPseudoCompare { | 393 class NameToPseudoCompare { |
| 393 public: | 394 public: |
| 394 NameToPseudoCompare(const AtomicString& key) : m_key(key) { | 395 NameToPseudoCompare(const AtomicString& key) : m_key(key) { |
| 395 ASSERT(m_key.is8Bit()); | 396 ASSERT(m_key.is8Bit()); |
| 396 } | 397 } |
| 397 | 398 |
| 398 bool operator()(const NameToPseudoStruct& entry, const NameToPseudoStruct&) { | 399 bool operator()(const NameToPseudoStruct& entry, const NameToPseudoStruct&) { |
| 399 ASSERT(entry.string); | 400 ASSERT(entry.string); |
| 400 const char* key = reinterpret_cast<const char*>(m_key.characters8()); | 401 const char* key = reinterpret_cast<const char*>(m_key.characters8()); |
| 401 // If strncmp returns 0, then either the keys are equal, or |m_key| sorts be
fore |entry|. | 402 // If strncmp returns 0, then either the keys are equal, or |m_key| sorts |
| 403 // before |entry|. |
| 402 return strncmp(entry.string, key, m_key.length()) < 0; | 404 return strncmp(entry.string, key, m_key.length()) < 0; |
| 403 } | 405 } |
| 404 | 406 |
| 405 private: | 407 private: |
| 406 const AtomicString& m_key; | 408 const AtomicString& m_key; |
| 407 }; | 409 }; |
| 408 | 410 |
| 409 static CSSSelector::PseudoType nameToPseudoType(const AtomicString& name, | 411 static CSSSelector::PseudoType nameToPseudoType(const AtomicString& name, |
| 410 bool hasArguments) { | 412 bool hasArguments) { |
| 411 if (name.isNull() || !name.is8Bit()) | 413 if (name.isNull() || !name.is8Bit()) |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 859 prevSubSelector = subSelector; | 861 prevSubSelector = subSelector; |
| 860 subSelector = subSelector->tagHistory(); | 862 subSelector = subSelector->tagHistory(); |
| 861 } | 863 } |
| 862 | 864 |
| 863 return true; | 865 return true; |
| 864 } | 866 } |
| 865 | 867 |
| 866 unsigned CSSSelector::computeLinkMatchType() const { | 868 unsigned CSSSelector::computeLinkMatchType() const { |
| 867 unsigned linkMatchType = MatchAll; | 869 unsigned linkMatchType = MatchAll; |
| 868 | 870 |
| 869 // Determine if this selector will match a link in visited, unvisited or any s
tate, or never. | 871 // Determine if this selector will match a link in visited, unvisited or any |
| 872 // state, or never. |
| 870 // :visited never matches other elements than the innermost link element. | 873 // :visited never matches other elements than the innermost link element. |
| 871 for (const CSSSelector* current = this; current; | 874 for (const CSSSelector* current = this; current; |
| 872 current = current->tagHistory()) { | 875 current = current->tagHistory()) { |
| 873 switch (current->getPseudoType()) { | 876 switch (current->getPseudoType()) { |
| 874 case PseudoNot: { | 877 case PseudoNot: { |
| 875 // :not(:visited) is equivalent to :link. Parser enforces that :not can'
t nest. | 878 // :not(:visited) is equivalent to :link. Parser enforces that :not |
| 879 // can't nest. |
| 876 ASSERT(current->selectorList()); | 880 ASSERT(current->selectorList()); |
| 877 for (const CSSSelector* subSelector = current->selectorList()->first(); | 881 for (const CSSSelector* subSelector = current->selectorList()->first(); |
| 878 subSelector; subSelector = subSelector->tagHistory()) { | 882 subSelector; subSelector = subSelector->tagHistory()) { |
| 879 PseudoType subType = subSelector->getPseudoType(); | 883 PseudoType subType = subSelector->getPseudoType(); |
| 880 if (subType == PseudoVisited) | 884 if (subType == PseudoVisited) |
| 881 linkMatchType &= ~MatchVisited; | 885 linkMatchType &= ~MatchVisited; |
| 882 else if (subType == PseudoLink) | 886 else if (subType == PseudoLink) |
| 883 linkMatchType &= ~MatchLink; | 887 linkMatchType &= ~MatchLink; |
| 884 } | 888 } |
| 885 } break; | 889 } break; |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 997 if (count < nthBValue()) | 1001 if (count < nthBValue()) |
| 998 return false; | 1002 return false; |
| 999 return (count - nthBValue()) % nthAValue() == 0; | 1003 return (count - nthBValue()) % nthAValue() == 0; |
| 1000 } | 1004 } |
| 1001 if (count > nthBValue()) | 1005 if (count > nthBValue()) |
| 1002 return false; | 1006 return false; |
| 1003 return (nthBValue() - count) % (-nthAValue()) == 0; | 1007 return (nthBValue() - count) % (-nthAValue()) == 0; |
| 1004 } | 1008 } |
| 1005 | 1009 |
| 1006 } // namespace blink | 1010 } // namespace blink |
| OLD | NEW |