OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011, 2013 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011, 2013 Apple Inc. All rights reserved. |
3 * Copyright (C) 2014 Samsung Electronics. All rights reserved. | 3 * Copyright (C) 2014 Samsung Electronics. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * | 8 * |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 SelectorQuery::SelectorQuery(CSSSelectorList& selectorList) | 45 SelectorQuery::SelectorQuery(CSSSelectorList& selectorList) |
46 { | 46 { |
47 m_selectors.adopt(selectorList); | 47 m_selectors.adopt(selectorList); |
48 } | 48 } |
49 | 49 |
50 bool SelectorQuery::matches(Element& element) const | 50 bool SelectorQuery::matches(Element& element) const |
51 { | 51 { |
52 return selectorMatches(element, element); | 52 return selectorMatches(element, element); |
53 } | 53 } |
54 | 54 |
55 PassRefPtr<StaticElementList> SelectorQuery::queryAll(ContainerNode& rootNode) c
onst | 55 Vector<RefPtr<Element>> SelectorQuery::queryAll(ContainerNode& rootNode) const |
56 { | 56 { |
57 Vector<RefPtr<Element> > result; | 57 Vector<RefPtr<Element>> result; |
58 for (Element* element = ElementTraversal::firstWithin(rootNode); element; el
ement = ElementTraversal::next(*element, &rootNode)) { | 58 for (Element* element = ElementTraversal::firstWithin(rootNode); element; el
ement = ElementTraversal::next(*element, &rootNode)) { |
59 if (selectorMatches(rootNode, *element)) | 59 if (selectorMatches(rootNode, *element)) |
60 result.append(element); | 60 result.append(element); |
61 } | 61 } |
62 return StaticElementList::adopt(result); | 62 return result; |
63 } | 63 } |
64 | 64 |
65 PassRefPtr<Element> SelectorQuery::queryFirst(ContainerNode& rootNode) const | 65 PassRefPtr<Element> SelectorQuery::queryFirst(ContainerNode& rootNode) const |
66 { | 66 { |
67 for (Element* element = ElementTraversal::firstWithin(rootNode); element; el
ement = ElementTraversal::next(*element, &rootNode)) { | 67 for (Element* element = ElementTraversal::firstWithin(rootNode); element; el
ement = ElementTraversal::next(*element, &rootNode)) { |
68 if (selectorMatches(rootNode, *element)) | 68 if (selectorMatches(rootNode, *element)) |
69 return element; | 69 return element; |
70 } | 70 } |
71 return nullptr; | 71 return nullptr; |
72 } | 72 } |
(...skipping 25 matching lines...) Expand all Loading... |
98 } | 98 } |
99 | 99 |
100 const unsigned maximumSelectorQueryCacheSize = 256; | 100 const unsigned maximumSelectorQueryCacheSize = 256; |
101 if (m_entries.size() == maximumSelectorQueryCacheSize) | 101 if (m_entries.size() == maximumSelectorQueryCacheSize) |
102 m_entries.remove(m_entries.begin()); | 102 m_entries.remove(m_entries.begin()); |
103 | 103 |
104 return m_entries.add(selectors, SelectorQuery::adopt(selectorList)).storedVa
lue->value.get(); | 104 return m_entries.add(selectors, SelectorQuery::adopt(selectorList)).storedVa
lue->value.get(); |
105 } | 105 } |
106 | 106 |
107 } | 107 } |
OLD | NEW |