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

Unified Diff: Source/core/css/resolver/StyleResolver.cpp

Issue 19555002: Translate viewport related meta tags into @viewport descriptors as suggested by the CSS Device Adap… (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: Source/core/css/resolver/StyleResolver.cpp
diff --git a/Source/core/css/resolver/StyleResolver.cpp b/Source/core/css/resolver/StyleResolver.cpp
index c5e87af65b09d46f53801ce646e9b8fb0b3dec66..7293eb0a1a2a80ecf987a62ca95a7ee2e1242b6b 100644
--- a/Source/core/css/resolver/StyleResolver.cpp
+++ b/Source/core/css/resolver/StyleResolver.cpp
@@ -50,6 +50,7 @@
#include "core/css/CSSSelector.h"
#include "core/css/CSSStyleRule.h"
#include "core/css/CSSValueList.h"
+#include "core/css/CSSValuePool.h"
#include "core/css/CSSVariableValue.h"
#include "core/css/ElementRuleCollector.h"
#include "core/css/MediaQueryEvaluator.h"
@@ -73,6 +74,7 @@
#include "core/inspector/InspectorInstrumentation.h"
#include "core/page/Frame.h"
#include "core/page/FrameView.h"
+#include "core/page/PageGroup.h"
#include "core/rendering/RenderView.h"
#include "core/rendering/style/KeyframeList.h"
#include "core/rendering/style/StyleCustomFilterProgramCache.h"
@@ -137,6 +139,13 @@ StyleResolver::StyleResolver(Document* document, bool matchAuthorAndUserStyles)
m_styleTree.clear();
+ if (document->isXHTMLMobileProfile()) {
+ Vector<String> whitelist;
+ whitelist.append(document->url());
+ static const char* sheet = "@viewport{-internal-priority:1;width:auto;height:auto;zoom:1;}";
+ document->page()->group().addUserStyleSheet(sheet, KURL(), whitelist, Vector<String>(), InjectInAllFrames, UserStyleAuthorLevel, InjectInExistingDocuments);
+ }
+
DocumentStyleSheetCollection* styleSheetCollection = document->styleSheetCollection();
m_ruleSets.initUserStyle(styleSheetCollection, *m_medium, *this);
@@ -159,6 +168,7 @@ void StyleResolver::appendAuthorStyleSheets(unsigned firstNew, const Vector<RefP
unsigned size = styleSheets.size();
for (unsigned i = firstNew; i < size; ++i) {
CSSStyleSheet* cssSheet = styleSheets[i].get();
+
ASSERT(!cssSheet->disabled());
if (cssSheet->mediaQueries() && !m_medium->eval(cssSheet->mediaQueries(), this))
continue;
@@ -178,8 +188,7 @@ void StyleResolver::finishAppendAuthorStyleSheets()
if (document()->renderer() && document()->renderer()->style())
document()->renderer()->style()->font().update(fontSelector());
- if (RuntimeEnabledFeatures::cssViewportEnabled())
- collectViewportRules();
+ collectViewportRules();
}
void StyleResolver::resetAuthorStyle(const ContainerNode* scopingNode)
@@ -1030,12 +1039,12 @@ PassRefPtr<RenderStyle> StyleResolver::styleForPage(int pageIndex)
void StyleResolver::collectViewportRules()
{
- ASSERT(RuntimeEnabledFeatures::cssViewportEnabled());
-
collectViewportRules(CSSDefaultStyleSheets::defaultStyle);
if (m_ruleSets.userStyle())
collectViewportRules(m_ruleSets.userStyle());
+ // OK to collect here for viewport meta etc, only the parser doesn't allow addition
+ // of @viewport with the runtime check.
if (ScopedStyleResolver* scopedResolver = m_styleTree.scopedStyleResolverForDocument())
scopedResolver->collectViewportRulesTo(this);
@@ -1044,8 +1053,6 @@ void StyleResolver::collectViewportRules()
void StyleResolver::collectViewportRules(RuleSet* rules)
{
- ASSERT(RuntimeEnabledFeatures::cssViewportEnabled());
-
rules->compactRulesIfNeeded();
const Vector<StyleRuleViewport*>& viewportRules = rules->viewportRules();
@@ -1503,6 +1510,7 @@ bool StyleResolver::affectedByViewportChange() const
if (m_medium->eval(&m_viewportDependentMediaQueryResults[i]->m_expression) != m_viewportDependentMediaQueryResults[i]->m_result)
return true;
}
+
return false;
}

Powered by Google App Engine
This is Rietveld 408576698