Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 136 return false; | 136 return false; |
| 137 } | 137 } |
| 138 return true; | 138 return true; |
| 139 } | 139 } |
| 140 | 140 |
| 141 void CSSSelectorWatch::watchCSSSelectors(const Vector<String>& selectors) | 141 void CSSSelectorWatch::watchCSSSelectors(const Vector<String>& selectors) |
| 142 { | 142 { |
| 143 m_watchedCallbackSelectors.clear(); | 143 m_watchedCallbackSelectors.clear(); |
| 144 BisonCSSParser parser(CSSParserContext(UASheetMode, 0)); | 144 BisonCSSParser parser(CSSParserContext(UASheetMode, 0)); |
| 145 | 145 |
| 146 const CSSProperty callbackProperty(CSSPropertyInternalCallback, CSSPrimitive Value::createIdentifier(CSSValueInternalPresence)); | 146 // We need a property declaration here otherwise the StylePropertySet will |
| 147 // get ignored. The exact property used doesn't matter as it isn't applied. | |
| 148 const CSSProperty callbackProperty(CSSPropertyBackgroundColor, CSSPrimitiveV alue::createIdentifier(CSSValueRed)); | |
|
esprehn
2014/08/15 14:45:55
This hack feels pretty gross, we can't leave that
Timothy Loh
2014/08/15 15:29:14
Turns out there's a flag on MatchRequest to make u
| |
| 147 const RefPtrWillBeRawPtr<StylePropertySet> callbackPropertySet = ImmutableSt ylePropertySet::create(&callbackProperty, 1, UASheetMode); | 149 const RefPtrWillBeRawPtr<StylePropertySet> callbackPropertySet = ImmutableSt ylePropertySet::create(&callbackProperty, 1, UASheetMode); |
| 148 | 150 |
| 149 CSSSelectorList selectorList; | 151 CSSSelectorList selectorList; |
| 150 for (unsigned i = 0; i < selectors.size(); ++i) { | 152 for (unsigned i = 0; i < selectors.size(); ++i) { |
| 151 parser.parseSelector(selectors[i], selectorList); | 153 parser.parseSelector(selectors[i], selectorList); |
| 152 if (!selectorList.isValid()) | 154 if (!selectorList.isValid()) |
| 153 continue; | 155 continue; |
| 154 | 156 |
| 155 // Only accept Compound Selectors, since they're cheaper to match. | 157 // Only accept Compound Selectors, since they're cheaper to match. |
| 156 if (!allCompound(selectorList)) | 158 if (!allCompound(selectorList)) |
| 157 continue; | 159 continue; |
| 158 | 160 |
| 159 RefPtrWillBeRawPtr<StyleRule> rule = StyleRule::create(); | 161 RefPtrWillBeRawPtr<StyleRule> rule = StyleRule::create(); |
| 160 rule->wrapperAdoptSelectorList(selectorList); | 162 rule->wrapperAdoptSelectorList(selectorList); |
| 161 rule->setProperties(callbackPropertySet); | 163 rule->setProperties(callbackPropertySet); |
| 162 m_watchedCallbackSelectors.append(rule.release()); | 164 m_watchedCallbackSelectors.append(rule.release()); |
| 163 } | 165 } |
| 164 document().changedSelectorWatch(); | 166 document().changedSelectorWatch(); |
| 165 } | 167 } |
| 166 | 168 |
| 167 void CSSSelectorWatch::trace(Visitor* visitor) | 169 void CSSSelectorWatch::trace(Visitor* visitor) |
| 168 { | 170 { |
| 169 visitor->trace(m_watchedCallbackSelectors); | 171 visitor->trace(m_watchedCallbackSelectors); |
| 170 visitor->trace(m_document); | 172 visitor->trace(m_document); |
| 171 DocumentSupplement::trace(visitor); | 173 DocumentSupplement::trace(visitor); |
| 172 } | 174 } |
| 173 | 175 |
| 174 } // namespace blink | 176 } // namespace blink |
| OLD | NEW |