Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(391)

Side by Side Diff: Source/core/css/RuleSet.cpp

Issue 134473008: Remove CSS regions support, keeping a bare minimum to support "region-based" multicol. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase master Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/css/RuleSet.h ('k') | Source/core/css/RuntimeCSSEnabled.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 if (current->isAttributeSelector()) 105 if (current->isAttributeSelector())
106 return true; 106 return true;
107 if (selectorListContainsUncommonAttributeSelector(current)) 107 if (selectorListContainsUncommonAttributeSelector(current))
108 return true; 108 return true;
109 } 109 }
110 return false; 110 return false;
111 } 111 }
112 112
113 static inline PropertyWhitelistType determinePropertyWhitelistType(const AddRule Flags addRuleFlags, const CSSSelector& selector) 113 static inline PropertyWhitelistType determinePropertyWhitelistType(const AddRule Flags addRuleFlags, const CSSSelector& selector)
114 { 114 {
115 if (addRuleFlags & RuleIsInRegionRule)
116 return PropertyWhitelistRegion;
117 for (const CSSSelector* component = &selector; component; component = compon ent->tagHistory()) { 115 for (const CSSSelector* component = &selector; component; component = compon ent->tagHistory()) {
118 if (component->pseudoType() == CSSSelector::PseudoCue || (component->m_m atch == CSSSelector::PseudoElement && component->value() == TextTrackCue::cueSha dowPseudoId())) 116 if (component->pseudoType() == CSSSelector::PseudoCue || (component->m_m atch == CSSSelector::PseudoElement && component->value() == TextTrackCue::cueSha dowPseudoId()))
119 return PropertyWhitelistCue; 117 return PropertyWhitelistCue;
120 } 118 }
121 return PropertyWhitelistNone; 119 return PropertyWhitelistNone;
122 } 120 }
123 121
124 namespace { 122 namespace {
125 123
126 // FIXME: Should we move this class to WTF? 124 // FIXME: Should we move this class to WTF?
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 ensurePendingRules(); // So that m_fontFaceRules.shrinkToFit() gets called. 326 ensurePendingRules(); // So that m_fontFaceRules.shrinkToFit() gets called.
329 m_fontFaceRules.append(rule); 327 m_fontFaceRules.append(rule);
330 } 328 }
331 329
332 void RuleSet::addKeyframesRule(StyleRuleKeyframes* rule) 330 void RuleSet::addKeyframesRule(StyleRuleKeyframes* rule)
333 { 331 {
334 ensurePendingRules(); // So that m_keyframesRules.shrinkToFit() gets called. 332 ensurePendingRules(); // So that m_keyframesRules.shrinkToFit() gets called.
335 m_keyframesRules.append(rule); 333 m_keyframesRules.append(rule);
336 } 334 }
337 335
338 void RuleSet::addRegionRule(StyleRuleRegion* regionRule, bool hasDocumentSecurit yOrigin)
339 {
340 ensurePendingRules(); // So that m_regionSelectorsAndRuleSets.shrinkToFit() gets called.
341 OwnPtr<RuleSet> regionRuleSet = RuleSet::create();
342 // The region rule set should take into account the position inside the pare nt rule set.
343 // Otherwise, the rules inside region block might be incorrectly positioned before other similar rules from
344 // the stylesheet that contains the region block.
345 regionRuleSet->m_ruleCount = m_ruleCount;
346
347 // Collect the region rules into a rule set
348 // FIXME: Should this add other types of rules? (i.e. use addChildRules() di rectly?)
349 const Vector<RefPtr<StyleRuleBase> >& childRules = regionRule->childRules();
350 AddRuleFlags addRuleFlags = hasDocumentSecurityOrigin ? RuleHasDocumentSecur ityOrigin : RuleHasNoSpecialState;
351 addRuleFlags = static_cast<AddRuleFlags>(addRuleFlags | RuleIsInRegionRule | RuleCanUseFastCheckSelector);
352 for (unsigned i = 0; i < childRules.size(); ++i) {
353 StyleRuleBase* regionStylingRule = childRules[i].get();
354 if (regionStylingRule->isStyleRule())
355 regionRuleSet->addStyleRule(toStyleRule(regionStylingRule), addRuleF lags);
356 }
357 // Update the "global" rule count so that proper order is maintained
358 m_ruleCount = regionRuleSet->m_ruleCount;
359
360 m_regionSelectorsAndRuleSets.append(RuleSetSelectorPair(regionRule->selector List().first(), regionRuleSet.release()));
361 }
362
363 void RuleSet::addChildRules(const Vector<RefPtr<StyleRuleBase> >& rules, const M ediaQueryEvaluator& medium, AddRuleFlags addRuleFlags) 336 void RuleSet::addChildRules(const Vector<RefPtr<StyleRuleBase> >& rules, const M ediaQueryEvaluator& medium, AddRuleFlags addRuleFlags)
364 { 337 {
365 for (unsigned i = 0; i < rules.size(); ++i) { 338 for (unsigned i = 0; i < rules.size(); ++i) {
366 StyleRuleBase* rule = rules[i].get(); 339 StyleRuleBase* rule = rules[i].get();
367 340
368 if (rule->isStyleRule()) { 341 if (rule->isStyleRule()) {
369 StyleRule* styleRule = toStyleRule(rule); 342 StyleRule* styleRule = toStyleRule(rule);
370 343
371 const CSSSelectorList& selectorList = styleRule->selectorList(); 344 const CSSSelectorList& selectorList = styleRule->selectorList();
372 for (size_t selectorIndex = 0; selectorIndex != kNotFound; selectorI ndex = selectorList.indexOfNextSelectorAfter(selectorIndex)) { 345 for (size_t selectorIndex = 0; selectorIndex != kNotFound; selectorI ndex = selectorList.indexOfNextSelectorAfter(selectorIndex)) {
373 if (selectorList.hasCombinatorCrossingTreeBoundaryAt(selectorInd ex)) { 346 if (selectorList.hasCombinatorCrossingTreeBoundaryAt(selectorInd ex)) {
374 m_treeBoundaryCrossingRules.append(MinimalRuleData(styleRule , selectorIndex, addRuleFlags)); 347 m_treeBoundaryCrossingRules.append(MinimalRuleData(styleRule , selectorIndex, addRuleFlags));
375 } else if (selectorList.hasShadowDistributedAt(selectorIndex)) { 348 } else if (selectorList.hasShadowDistributedAt(selectorIndex)) {
376 m_shadowDistributedRules.append(MinimalRuleData(styleRule, s electorIndex, addRuleFlags)); 349 m_shadowDistributedRules.append(MinimalRuleData(styleRule, s electorIndex, addRuleFlags));
377 } else { 350 } else {
378 addRule(styleRule, selectorIndex, addRuleFlags); 351 addRule(styleRule, selectorIndex, addRuleFlags);
379 } 352 }
380 } 353 }
381 } else if (rule->isPageRule()) { 354 } else if (rule->isPageRule()) {
382 addPageRule(toStyleRulePage(rule)); 355 addPageRule(toStyleRulePage(rule));
383 } else if (rule->isMediaRule()) { 356 } else if (rule->isMediaRule()) {
384 StyleRuleMedia* mediaRule = toStyleRuleMedia(rule); 357 StyleRuleMedia* mediaRule = toStyleRuleMedia(rule);
385 if ((!mediaRule->mediaQueries() || medium.eval(mediaRule->mediaQueri es(), &m_viewportDependentMediaQueryResults))) 358 if ((!mediaRule->mediaQueries() || medium.eval(mediaRule->mediaQueri es(), &m_viewportDependentMediaQueryResults)))
386 addChildRules(mediaRule->childRules(), medium, addRuleFlags); 359 addChildRules(mediaRule->childRules(), medium, addRuleFlags);
387 } else if (rule->isFontFaceRule()) { 360 } else if (rule->isFontFaceRule()) {
388 addFontFaceRule(toStyleRuleFontFace(rule)); 361 addFontFaceRule(toStyleRuleFontFace(rule));
389 } else if (rule->isKeyframesRule()) { 362 } else if (rule->isKeyframesRule()) {
390 addKeyframesRule(toStyleRuleKeyframes(rule)); 363 addKeyframesRule(toStyleRuleKeyframes(rule));
391 } else if (rule->isRegionRule()) {
392 addRegionRule(toStyleRuleRegion(rule), addRuleFlags & RuleHasDocumen tSecurityOrigin);
393 } else if (rule->isViewportRule()) { 364 } else if (rule->isViewportRule()) {
394 addViewportRule(toStyleRuleViewport(rule)); 365 addViewportRule(toStyleRuleViewport(rule));
395 } else if (rule->isSupportsRule() && toStyleRuleSupports(rule)->conditio nIsSupported()) { 366 } else if (rule->isSupportsRule() && toStyleRuleSupports(rule)->conditio nIsSupported()) {
396 addChildRules(toStyleRuleSupports(rule)->childRules(), medium, addRu leFlags); 367 addChildRules(toStyleRuleSupports(rule)->childRules(), medium, addRu leFlags);
397 } 368 }
398 } 369 }
399 } 370 }
400 371
401 void RuleSet::addRulesFromSheet(StyleSheetContents* sheet, const MediaQueryEvalu ator& medium, AddRuleFlags addRuleFlags) 372 void RuleSet::addRulesFromSheet(StyleSheetContents* sheet, const MediaQueryEvalu ator& medium, AddRuleFlags addRuleFlags)
402 { 373 {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 #ifndef NDEBUG 433 #ifndef NDEBUG
463 434
464 void RuleSet::show() 435 void RuleSet::show()
465 { 436 {
466 for (Vector<RuleData>::const_iterator it = m_allRules.begin(); it != m_allRu les.end(); ++it) 437 for (Vector<RuleData>::const_iterator it = m_allRules.begin(); it != m_allRu les.end(); ++it)
467 it->selector().show(); 438 it->selector().show();
468 } 439 }
469 #endif 440 #endif
470 441
471 } // namespace WebCore 442 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/css/RuleSet.h ('k') | Source/core/css/RuntimeCSSEnabled.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698