| 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, 2012 Apple Inc. All r
ights reserved. | 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All r
ights 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 25 matching lines...) Expand all Loading... |
| 36 #include "core/css/CSSSelectorList.h" | 36 #include "core/css/CSSSelectorList.h" |
| 37 #include "core/css/SelectorChecker.h" | 37 #include "core/css/SelectorChecker.h" |
| 38 #include "core/css/SelectorCheckerFastPath.h" | 38 #include "core/css/SelectorCheckerFastPath.h" |
| 39 #include "core/css/SelectorFilter.h" | 39 #include "core/css/SelectorFilter.h" |
| 40 #include "core/css/StyleRuleImport.h" | 40 #include "core/css/StyleRuleImport.h" |
| 41 #include "core/css/StyleSheetContents.h" | 41 #include "core/css/StyleSheetContents.h" |
| 42 #include "core/html/track/TextTrackCue.h" | 42 #include "core/html/track/TextTrackCue.h" |
| 43 #include "platform/TraceEvent.h" | 43 #include "platform/TraceEvent.h" |
| 44 #include "platform/weborigin/SecurityOrigin.h" | 44 #include "platform/weborigin/SecurityOrigin.h" |
| 45 | 45 |
| 46 #include "wtf/TerminatedArrayBuilder.h" |
| 47 |
| 46 namespace WebCore { | 48 namespace WebCore { |
| 47 | 49 |
| 48 using namespace HTMLNames; | 50 using namespace HTMLNames; |
| 49 | 51 |
| 50 // ----------------------------------------------------------------- | 52 // ----------------------------------------------------------------- |
| 51 | 53 |
| 52 static inline bool isSelectorMatchingHTMLBasedOnRuleHash(const CSSSelector& sele
ctor) | 54 static inline bool isSelectorMatchingHTMLBasedOnRuleHash(const CSSSelector& sele
ctor) |
| 53 { | 55 { |
| 54 if (selector.m_match == CSSSelector::Tag) { | 56 if (selector.m_match == CSSSelector::Tag) { |
| 55 const AtomicString& selectorNamespace = selector.tagQName().namespaceURI
(); | 57 const AtomicString& selectorNamespace = selector.tagQName().namespaceURI
(); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 | 114 |
| 113 static inline PropertyWhitelistType determinePropertyWhitelistType(const AddRule
Flags addRuleFlags, const CSSSelector& selector) | 115 static inline PropertyWhitelistType determinePropertyWhitelistType(const AddRule
Flags addRuleFlags, const CSSSelector& selector) |
| 114 { | 116 { |
| 115 for (const CSSSelector* component = &selector; component; component = compon
ent->tagHistory()) { | 117 for (const CSSSelector* component = &selector; component; component = compon
ent->tagHistory()) { |
| 116 if (component->pseudoType() == CSSSelector::PseudoCue || (component->m_m
atch == CSSSelector::PseudoElement && component->value() == TextTrackCue::cueSha
dowPseudoId())) | 118 if (component->pseudoType() == CSSSelector::PseudoCue || (component->m_m
atch == CSSSelector::PseudoElement && component->value() == TextTrackCue::cueSha
dowPseudoId())) |
| 117 return PropertyWhitelistCue; | 119 return PropertyWhitelistCue; |
| 118 } | 120 } |
| 119 return PropertyWhitelistNone; | 121 return PropertyWhitelistNone; |
| 120 } | 122 } |
| 121 | 123 |
| 122 namespace { | |
| 123 | |
| 124 // FIXME: Should we move this class to WTF? | |
| 125 template<typename T> | |
| 126 class TerminatedArrayBuilder { | |
| 127 public: | |
| 128 explicit TerminatedArrayBuilder(PassOwnPtr<T> array) | |
| 129 : m_array(array) | |
| 130 , m_count(0) | |
| 131 , m_capacity(0) | |
| 132 { | |
| 133 if (!m_array) | |
| 134 return; | |
| 135 for (T* item = m_array.get(); !item->isLastInArray(); ++item) | |
| 136 ++m_count; | |
| 137 ++m_count; // To count the last item itself. | |
| 138 m_capacity = m_count; | |
| 139 } | |
| 140 | |
| 141 void grow(size_t count) | |
| 142 { | |
| 143 ASSERT(count); | |
| 144 if (!m_array) { | |
| 145 ASSERT(!m_count); | |
| 146 ASSERT(!m_capacity); | |
| 147 m_capacity = count; | |
| 148 m_array = adoptPtr(static_cast<T*>(fastMalloc(m_capacity * sizeof(T)
))); | |
| 149 return; | |
| 150 } | |
| 151 m_capacity += count; | |
| 152 m_array = adoptPtr(static_cast<T*>(fastRealloc(m_array.leakPtr(), m_capa
city * sizeof(T)))); | |
| 153 m_array.get()[m_count - 1].setLastInArray(false); | |
| 154 } | |
| 155 | |
| 156 void append(const T& item) | |
| 157 { | |
| 158 RELEASE_ASSERT(m_count < m_capacity); | |
| 159 ASSERT(!item.isLastInArray()); | |
| 160 m_array.get()[m_count++] = item; | |
| 161 } | |
| 162 | |
| 163 PassOwnPtr<T> release() | |
| 164 { | |
| 165 RELEASE_ASSERT(m_count == m_capacity); | |
| 166 if (m_array) | |
| 167 m_array.get()[m_count - 1].setLastInArray(true); | |
| 168 assertValid(); | |
| 169 return m_array.release(); | |
| 170 } | |
| 171 | |
| 172 private: | |
| 173 #ifndef NDEBUG | |
| 174 void assertValid() | |
| 175 { | |
| 176 for (size_t i = 0; i < m_count; ++i) { | |
| 177 bool isLastInArray = (i + 1 == m_count); | |
| 178 ASSERT(m_array.get()[i].isLastInArray() == isLastInArray); | |
| 179 } | |
| 180 } | |
| 181 #else | |
| 182 void assertValid() { } | |
| 183 #endif | |
| 184 | |
| 185 OwnPtr<T> m_array; | |
| 186 size_t m_count; | |
| 187 size_t m_capacity; | |
| 188 }; | |
| 189 | |
| 190 } | |
| 191 | |
| 192 RuleData::RuleData(StyleRule* rule, unsigned selectorIndex, unsigned position, A
ddRuleFlags addRuleFlags) | 124 RuleData::RuleData(StyleRule* rule, unsigned selectorIndex, unsigned position, A
ddRuleFlags addRuleFlags) |
| 193 : m_rule(rule) | 125 : m_rule(rule) |
| 194 , m_selectorIndex(selectorIndex) | 126 , m_selectorIndex(selectorIndex) |
| 195 , m_isLastInArray(false) | 127 , m_isLastInArray(false) |
| 196 , m_position(position) | 128 , m_position(position) |
| 197 , m_hasFastCheckableSelector((addRuleFlags & RuleCanUseFastCheckSelector) &&
SelectorCheckerFastPath::canUse(selector())) | 129 , m_hasFastCheckableSelector((addRuleFlags & RuleCanUseFastCheckSelector) &&
SelectorCheckerFastPath::canUse(selector())) |
| 198 , m_specificity(selector().specificity()) | 130 , m_specificity(selector().specificity()) |
| 199 , m_hasMultipartSelector(!!selector().tagHistory()) | 131 , m_hasMultipartSelector(!!selector().tagHistory()) |
| 200 , m_hasRightmostSelectorMatchingHTMLBasedOnRuleHash(isSelectorMatchingHTMLBa
sedOnRuleHash(selector())) | 132 , m_hasRightmostSelectorMatchingHTMLBasedOnRuleHash(isSelectorMatchingHTMLBa
sedOnRuleHash(selector())) |
| 201 , m_containsUncommonAttributeSelector(WebCore::containsUncommonAttributeSele
ctor(selector())) | 133 , m_containsUncommonAttributeSelector(WebCore::containsUncommonAttributeSele
ctor(selector())) |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 #ifndef NDEBUG | 365 #ifndef NDEBUG |
| 434 | 366 |
| 435 void RuleSet::show() | 367 void RuleSet::show() |
| 436 { | 368 { |
| 437 for (Vector<RuleData>::const_iterator it = m_allRules.begin(); it != m_allRu
les.end(); ++it) | 369 for (Vector<RuleData>::const_iterator it = m_allRules.begin(); it != m_allRu
les.end(); ++it) |
| 438 it->selector().show(); | 370 it->selector().show(); |
| 439 } | 371 } |
| 440 #endif | 372 #endif |
| 441 | 373 |
| 442 } // namespace WebCore | 374 } // namespace WebCore |
| OLD | NEW |