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

Side by Side Diff: Source/core/css/resolver/StyleResolver.cpp

Issue 16646002: Move the CSS Device Adaptation @viewport rule support behind a runtime flag (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: For landing Created 7 years, 6 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 | Annotate | Revision Log
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, 2013 Apple Inc. All rights reserved. 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 newProperties.whitelistType = propertyWhitelistType; 212 newProperties.whitelistType = propertyWhitelistType;
213 matchedRules.append(rule); 213 matchedRules.append(rule);
214 } 214 }
215 215
216 StyleResolver::StyleResolver(Document* document, bool matchAuthorAndUserStyles) 216 StyleResolver::StyleResolver(Document* document, bool matchAuthorAndUserStyles)
217 : m_matchedPropertiesCacheAdditionsSinceLastSweep(0) 217 : m_matchedPropertiesCacheAdditionsSinceLastSweep(0)
218 , m_matchedPropertiesCacheSweepTimer(this, &StyleResolver::sweepMatchedPrope rtiesCache) 218 , m_matchedPropertiesCacheSweepTimer(this, &StyleResolver::sweepMatchedPrope rtiesCache)
219 , m_document(document) 219 , m_document(document)
220 , m_matchAuthorAndUserStyles(matchAuthorAndUserStyles) 220 , m_matchAuthorAndUserStyles(matchAuthorAndUserStyles)
221 , m_fontSelector(CSSFontSelector::create(document)) 221 , m_fontSelector(CSSFontSelector::create(document))
222 #if ENABLE(CSS_DEVICE_ADAPTATION)
223 , m_viewportStyleResolver(ViewportStyleResolver::create(document)) 222 , m_viewportStyleResolver(ViewportStyleResolver::create(document))
224 #endif
225 , m_styleBuilder(DeprecatedStyleBuilder::sharedStyleBuilder()) 223 , m_styleBuilder(DeprecatedStyleBuilder::sharedStyleBuilder())
226 , m_styleMap(this) 224 , m_styleMap(this)
227 { 225 {
228 Element* root = document->documentElement(); 226 Element* root = document->documentElement();
229 227
230 CSSDefaultStyleSheets::initDefaultStyle(root); 228 CSSDefaultStyleSheets::initDefaultStyle(root);
231 229
232 // construct document root element default style. this is needed 230 // construct document root element default style. this is needed
233 // to evaluate media queries that contain relative constraints, like "screen and (max-width: 10em)" 231 // to evaluate media queries that contain relative constraints, like "screen and (max-width: 10em)"
234 // This is here instead of constructor, because when constructor is run, 232 // This is here instead of constructor, because when constructor is run,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 lastUpdatedResolver = resolver; 285 lastUpdatedResolver = resolver;
288 } 286 }
289 287
290 if (lastUpdatedResolver) 288 if (lastUpdatedResolver)
291 lastUpdatedResolver->postAddRulesFromSheet(); 289 lastUpdatedResolver->postAddRulesFromSheet();
292 collectFeatures(); 290 collectFeatures();
293 291
294 if (document()->renderer() && document()->renderer()->style()) 292 if (document()->renderer() && document()->renderer()->style())
295 document()->renderer()->style()->font().update(fontSelector()); 293 document()->renderer()->style()->font().update(fontSelector());
296 294
297 #if ENABLE(CSS_DEVICE_ADAPTATION) 295 if (RuntimeEnabledFeatures::cssViewportEnabled())
298 viewportStyleResolver()->resolve(); 296 viewportStyleResolver()->resolve();
299 #endif
300 } 297 }
301 298
302 void StyleResolver::resetAuthorStyle() 299 void StyleResolver::resetAuthorStyle()
303 { 300 {
304 m_styleTree.clear(); 301 m_styleTree.clear();
305 } 302 }
306 303
307 static PassOwnPtr<RuleSet> makeRuleSet(const Vector<RuleFeature>& rules) 304 static PassOwnPtr<RuleSet> makeRuleSet(const Vector<RuleFeature>& rules)
308 { 305 {
309 size_t size = rules.size(); 306 size_t size = rules.size();
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 // This is a simplified style setting function for keyframe styles 365 // This is a simplified style setting function for keyframe styles
369 void StyleResolver::addKeyframeStyle(PassRefPtr<StyleRuleKeyframes> rule) 366 void StyleResolver::addKeyframeStyle(PassRefPtr<StyleRuleKeyframes> rule)
370 { 367 {
371 AtomicString s(rule->name()); 368 AtomicString s(rule->name());
372 m_keyframesRuleMap.set(s.impl(), rule); 369 m_keyframesRuleMap.set(s.impl(), rule);
373 } 370 }
374 371
375 StyleResolver::~StyleResolver() 372 StyleResolver::~StyleResolver()
376 { 373 {
377 m_fontSelector->clearDocument(); 374 m_fontSelector->clearDocument();
378
379 #if ENABLE(CSS_DEVICE_ADAPTATION)
380 m_viewportStyleResolver->clearDocument(); 375 m_viewportStyleResolver->clearDocument();
381 #endif
382 } 376 }
383 377
384 void StyleResolver::sweepMatchedPropertiesCache(Timer<StyleResolver>*) 378 void StyleResolver::sweepMatchedPropertiesCache(Timer<StyleResolver>*)
385 { 379 {
386 // Look for cache entries containing a style declaration with a single ref a nd remove them. 380 // Look for cache entries containing a style declaration with a single ref a nd remove them.
387 // This may happen when an element attribute mutation causes it to generate a new inlineStyle() 381 // This may happen when an element attribute mutation causes it to generate a new inlineStyle()
388 // or presentationAttributeStyle(), potentially leaving this cache with the last ref on the old one. 382 // or presentationAttributeStyle(), potentially leaving this cache with the last ref on the old one.
389 Vector<unsigned, 16> toRemove; 383 Vector<unsigned, 16> toRemove;
390 MatchedPropertiesCache::iterator it = m_matchedPropertiesCache.begin(); 384 MatchedPropertiesCache::iterator it = m_matchedPropertiesCache.begin();
391 MatchedPropertiesCache::iterator end = m_matchedPropertiesCache.end(); 385 MatchedPropertiesCache::iterator end = m_matchedPropertiesCache.end();
(...skipping 2923 matching lines...) Expand 10 before | Expand all | Expand 10 after
3315 case CSSPropertyWebkitShapeInside: 3309 case CSSPropertyWebkitShapeInside:
3316 case CSSPropertyWebkitShapeOutside: 3310 case CSSPropertyWebkitShapeOutside:
3317 case CSSPropertyWhiteSpace: 3311 case CSSPropertyWhiteSpace:
3318 case CSSPropertyWidows: 3312 case CSSPropertyWidows:
3319 case CSSPropertyWidth: 3313 case CSSPropertyWidth:
3320 case CSSPropertyWordBreak: 3314 case CSSPropertyWordBreak:
3321 case CSSPropertyWordSpacing: 3315 case CSSPropertyWordSpacing:
3322 case CSSPropertyWordWrap: 3316 case CSSPropertyWordWrap:
3323 case CSSPropertyZIndex: 3317 case CSSPropertyZIndex:
3324 case CSSPropertyZoom: 3318 case CSSPropertyZoom:
3325 #if ENABLE(CSS_DEVICE_ADAPTATION)
3326 case CSSPropertyMaxZoom: 3319 case CSSPropertyMaxZoom:
3327 case CSSPropertyMinZoom: 3320 case CSSPropertyMinZoom:
3328 case CSSPropertyOrientation: 3321 case CSSPropertyOrientation:
3329 case CSSPropertyUserZoom: 3322 case CSSPropertyUserZoom:
3330 #endif
3331 ASSERT_NOT_REACHED(); 3323 ASSERT_NOT_REACHED();
3332 return; 3324 return;
3333 default: 3325 default:
3334 // Try the SVG properties 3326 // Try the SVG properties
3335 applySVGProperty(id, value); 3327 applySVGProperty(id, value);
3336 return; 3328 return;
3337 } 3329 }
3338 } 3330 }
3339 3331
3340 PassRefPtr<StyleImage> StyleResolver::styleImage(CSSPropertyID property, CSSValu e* value) 3332 PassRefPtr<StyleImage> StyleResolver::styleImage(CSSPropertyID property, CSSValu e* value)
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
3739 info.addMember(m_state, "state"); 3731 info.addMember(m_state, "state");
3740 3732
3741 // FIXME: move this to a place where it would be called only once? 3733 // FIXME: move this to a place where it would be called only once?
3742 info.addMember(CSSDefaultStyleSheets::defaultStyle, "defaultStyle"); 3734 info.addMember(CSSDefaultStyleSheets::defaultStyle, "defaultStyle");
3743 info.addMember(CSSDefaultStyleSheets::defaultQuirksStyle, "defaultQuirksStyl e"); 3735 info.addMember(CSSDefaultStyleSheets::defaultQuirksStyle, "defaultQuirksStyl e");
3744 info.addMember(CSSDefaultStyleSheets::defaultPrintStyle, "defaultPrintStyle" ); 3736 info.addMember(CSSDefaultStyleSheets::defaultPrintStyle, "defaultPrintStyle" );
3745 info.addMember(CSSDefaultStyleSheets::defaultViewSourceStyle, "defaultViewSo urceStyle"); 3737 info.addMember(CSSDefaultStyleSheets::defaultViewSourceStyle, "defaultViewSo urceStyle");
3746 } 3738 }
3747 3739
3748 } // namespace WebCore 3740 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/css/resolver/StyleResolver.h ('k') | Source/core/css/resolver/ViewportStyleResolver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698