| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) | 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) |
| 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) | 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) |
| 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights
reserved. | 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights
reserved. |
| 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> | 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> |
| 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> | 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> |
| 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) |
| 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. | 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. |
| 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. | 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 * You should have received a copy of the GNU Library General Public License | 23 * You should have received a copy of the GNU Library General Public License |
| 24 * along with this library; see the file COPYING.LIB. If not, write to | 24 * along with this library; see the file COPYING.LIB. If not, write to |
| 25 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 25 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 26 * Boston, MA 02110-1301, USA. | 26 * Boston, MA 02110-1301, USA. |
| 27 */ | 27 */ |
| 28 | 28 |
| 29 #include "config.h" | 29 #include "config.h" |
| 30 #include "core/css/SelectorFilter.h" | 30 #include "core/css/SelectorFilter.h" |
| 31 | 31 |
| 32 #include "core/css/CSSSelector.h" | 32 #include "core/css/CSSSelector.h" |
| 33 #include "core/dom/Document.h" |
| 33 | 34 |
| 34 namespace blink { | 35 namespace blink { |
| 35 | 36 |
| 36 // Salt to separate otherwise identical string hashes so a class-selector like .
article won't match <article> elements. | 37 // Salt to separate otherwise identical string hashes so a class-selector like .
article won't match <article> elements. |
| 37 enum { TagNameSalt = 13, IdAttributeSalt = 17, ClassAttributeSalt = 19 }; | 38 enum { TagNameSalt = 13, IdAttributeSalt = 17, ClassAttributeSalt = 19 }; |
| 38 | 39 |
| 39 static inline void collectElementIdentifierHashes(const Element& element, Vector
<unsigned, 4>& identifierHashes) | 40 static inline void collectElementIdentifierHashes(const Element& element, Vector
<unsigned, 4>& identifierHashes) |
| 40 { | 41 { |
| 41 identifierHashes.append(element.localName().impl()->existingHash() * TagName
Salt); | 42 AtomicString localName = element.localName(); |
| 43 if (!element.isHTMLElement() && element.document().isHTMLDocument()) |
| 44 localName = localName.lower(); |
| 45 identifierHashes.append(localName.impl()->existingHash() * TagNameSalt); |
| 42 if (element.hasID()) | 46 if (element.hasID()) |
| 43 identifierHashes.append(element.idForStyleResolution().impl()->existingH
ash() * IdAttributeSalt); | 47 identifierHashes.append(element.idForStyleResolution().impl()->existingH
ash() * IdAttributeSalt); |
| 44 if (element.isStyledElement() && element.hasClass()) { | 48 if (element.isStyledElement() && element.hasClass()) { |
| 45 const SpaceSplitString& classNames = element.classNames(); | 49 const SpaceSplitString& classNames = element.classNames(); |
| 46 size_t count = classNames.size(); | 50 size_t count = classNames.size(); |
| 47 for (size_t i = 0; i < count; ++i) | 51 for (size_t i = 0; i < count; ++i) |
| 48 identifierHashes.append(classNames[i].impl()->existingHash() * Class
AttributeSalt); | 52 identifierHashes.append(classNames[i].impl()->existingHash() * Class
AttributeSalt); |
| 49 } | 53 } |
| 50 } | 54 } |
| 51 | 55 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 } | 180 } |
| 177 | 181 |
| 178 DEFINE_TRACE(SelectorFilter) | 182 DEFINE_TRACE(SelectorFilter) |
| 179 { | 183 { |
| 180 #if ENABLE(OILPAN) | 184 #if ENABLE(OILPAN) |
| 181 visitor->trace(m_parentStack); | 185 visitor->trace(m_parentStack); |
| 182 #endif | 186 #endif |
| 183 } | 187 } |
| 184 | 188 |
| 185 } | 189 } |
| OLD | NEW |