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

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

Issue 23742003: Use css-device-adapt constraining for legacy viewport tags. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Review issue: one assignent per line/statement Created 7 years, 3 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/resolver/ViewportStyleResolver.h ('k') | Source/core/css/xhtmlmp.css » ('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) 2012-2013 Intel Corporation. All rights reserved. 2 * Copyright (C) 2012-2013 Intel Corporation. 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above 8 * 1. Redistributions of source code must retain the above
9 * copyright notice, this list of conditions and the following 9 * copyright notice, this list of conditions and the following
10 * disclaimer. 10 * disclaimer.
(...skipping 22 matching lines...) Expand all
33 #include "CSSValueKeywords.h" 33 #include "CSSValueKeywords.h"
34 #include "core/css/StylePropertySet.h" 34 #include "core/css/StylePropertySet.h"
35 #include "core/css/StyleRule.h" 35 #include "core/css/StyleRule.h"
36 #include "core/dom/Document.h" 36 #include "core/dom/Document.h"
37 #include "core/dom/NodeRenderStyle.h" 37 #include "core/dom/NodeRenderStyle.h"
38 #include "core/dom/ViewportArguments.h" 38 #include "core/dom/ViewportArguments.h"
39 39
40 namespace WebCore { 40 namespace WebCore {
41 41
42 ViewportStyleResolver::ViewportStyleResolver(Document* document) 42 ViewportStyleResolver::ViewportStyleResolver(Document* document)
43 : m_document(document) 43 : m_document(document),
44 m_hasAuthorStyle(false)
44 { 45 {
45 ASSERT(m_document); 46 ASSERT(m_document);
46 } 47 }
47 48
48 ViewportStyleResolver::~ViewportStyleResolver() 49 ViewportStyleResolver::~ViewportStyleResolver()
49 { 50 {
50 } 51 }
51 52
52 void ViewportStyleResolver::addViewportRule(StyleRuleViewport* viewportRule) 53 void ViewportStyleResolver::addViewportRule(StyleRuleViewport* viewportRule)
53 { 54 {
(...skipping 17 matching lines...) Expand all
71 void ViewportStyleResolver::clearDocument() 72 void ViewportStyleResolver::clearDocument()
72 { 73 {
73 m_document = 0; 74 m_document = 0;
74 } 75 }
75 76
76 void ViewportStyleResolver::resolve() 77 void ViewportStyleResolver::resolve()
77 { 78 {
78 if (!m_document) 79 if (!m_document)
79 return; 80 return;
80 81
81 if (!m_propertySet) { 82 if (!m_propertySet || (!m_hasAuthorStyle && m_document->hasLegacyViewportTag ())) {
82 // FIXME: This is not entirely correct. If the doctype is XHTML MP, or t here is a Meta 83 ASSERT(!m_hasAuthorStyle);
83 // element for setting the viewport, the viewport arguments should fall back to those 84 m_propertySet = 0;
84 // settings when the @viewport rules are all removed. For now, reset to implicit when 85 m_document->setViewportArguments(ViewportArguments());
85 // there was an @viewport rule which has now been removed.
86 if (m_document->viewportArguments().type == ViewportArguments::CSSDevice Adaptation) {
87 m_document->setViewportArguments(ViewportArguments());
88 m_document->updateViewportArguments();
89 }
90 return; 86 return;
91 } 87 }
92 88
93 ViewportArguments arguments(ViewportArguments::CSSDeviceAdaptation); 89 ViewportArguments arguments(m_hasAuthorStyle ? ViewportArguments::AuthorStyl eSheet : ViewportArguments::UserAgentStyleSheet);
94 90
95 arguments.userZoom = viewportArgumentValue(CSSPropertyUserZoom); 91 arguments.userZoom = viewportArgumentValue(CSSPropertyUserZoom);
96 arguments.zoom = viewportArgumentValue(CSSPropertyZoom); 92 arguments.zoom = viewportArgumentValue(CSSPropertyZoom);
97 arguments.minZoom = viewportArgumentValue(CSSPropertyMinZoom); 93 arguments.minZoom = viewportArgumentValue(CSSPropertyMinZoom);
98 arguments.maxZoom = viewportArgumentValue(CSSPropertyMaxZoom); 94 arguments.maxZoom = viewportArgumentValue(CSSPropertyMaxZoom);
99 arguments.minWidth = viewportLengthValue(CSSPropertyMinWidth); 95 arguments.minWidth = viewportLengthValue(CSSPropertyMinWidth);
100 arguments.maxWidth = viewportLengthValue(CSSPropertyMaxWidth); 96 arguments.maxWidth = viewportLengthValue(CSSPropertyMaxWidth);
101 arguments.minHeight = viewportLengthValue(CSSPropertyMinHeight); 97 arguments.minHeight = viewportLengthValue(CSSPropertyMinHeight);
102 arguments.maxHeight = viewportLengthValue(CSSPropertyMaxHeight); 98 arguments.maxHeight = viewportLengthValue(CSSPropertyMaxHeight);
103 arguments.orientation = viewportArgumentValue(CSSPropertyOrientation); 99 arguments.orientation = viewportArgumentValue(CSSPropertyOrientation);
104 100
105 m_document->setViewportArguments(arguments); 101 m_document->setViewportArguments(arguments);
106 m_document->updateViewportArguments();
107 102
108 m_propertySet = 0; 103 m_propertySet = 0;
104 m_hasAuthorStyle = false;
109 } 105 }
110 106
111 float ViewportStyleResolver::viewportArgumentValue(CSSPropertyID id) const 107 float ViewportStyleResolver::viewportArgumentValue(CSSPropertyID id) const
112 { 108 {
113 float defaultValue = ViewportArguments::ValueAuto; 109 float defaultValue = ViewportArguments::ValueAuto;
114 110
115 // UserZoom default value is CSSValueZoom, which maps to true, meaning that 111 // UserZoom default value is CSSValueZoom, which maps to true, meaning that
116 // yes, it is user scalable. When the value is set to CSSValueFixed, we 112 // yes, it is user scalable. When the value is set to CSSValueFixed, we
117 // return false. 113 // return false.
118 if (id == CSSPropertyUserZoom) 114 if (id == CSSPropertyUserZoom)
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 case CSSValueAuto: 185 case CSSValueAuto:
190 return Length(); 186 return Length();
191 default: 187 default:
192 // Unrecognized keyword. 188 // Unrecognized keyword.
193 ASSERT_NOT_REACHED(); 189 ASSERT_NOT_REACHED();
194 return Length(0, Fixed); 190 return Length(0, Fixed);
195 } 191 }
196 } 192 }
197 193
198 } // namespace WebCore 194 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/css/resolver/ViewportStyleResolver.h ('k') | Source/core/css/xhtmlmp.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698