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

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: More review issues. 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
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_hasAuthorStyle && (m_document->useLegacyViewportArguments() || !m_pro pertySet)) {
82 // FIXME: This is not entirely correct. If the doctype is XHTML MP, or t here is a Meta 83 if (!m_propertySet)
83 // element for setting the viewport, the viewport arguments should fall back to those
84 // settings when the @viewport rules are all removed. For now, reset to implicit when
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()); 84 m_document->setViewportArguments(ViewportArguments());
88 m_document->updateViewportArguments(); 85 else
89 } 86 m_propertySet = 0;
90 return; 87 return;
91 } 88 }
92 89
93 ViewportArguments arguments(ViewportArguments::CSSDeviceAdaptation); 90 ASSERT(m_propertySet);
91
92 ViewportArguments arguments(m_hasAuthorStyle ? ViewportArguments::AuthorStyl eSheet : ViewportArguments::UserAgentStyleSheet);
94 93
95 arguments.userZoom = getViewportArgumentValue(CSSPropertyUserZoom); 94 arguments.userZoom = getViewportArgumentValue(CSSPropertyUserZoom);
96 arguments.zoom = getViewportArgumentValue(CSSPropertyZoom); 95 arguments.zoom = getViewportArgumentValue(CSSPropertyZoom);
97 arguments.minZoom = getViewportArgumentValue(CSSPropertyMinZoom); 96 arguments.minZoom = getViewportArgumentValue(CSSPropertyMinZoom);
98 arguments.maxZoom = getViewportArgumentValue(CSSPropertyMaxZoom); 97 arguments.maxZoom = getViewportArgumentValue(CSSPropertyMaxZoom);
99 arguments.minWidth = getViewportArgumentValue(CSSPropertyMinWidth); 98 arguments.minWidth = getViewportArgumentValue(CSSPropertyMinWidth);
100 arguments.maxWidth = getViewportArgumentValue(CSSPropertyMaxWidth); 99 arguments.maxWidth = getViewportArgumentValue(CSSPropertyMaxWidth);
101 arguments.minHeight = getViewportArgumentValue(CSSPropertyMinHeight); 100 arguments.minHeight = getViewportArgumentValue(CSSPropertyMinHeight);
102 arguments.maxHeight = getViewportArgumentValue(CSSPropertyMaxHeight); 101 arguments.maxHeight = getViewportArgumentValue(CSSPropertyMaxHeight);
103 arguments.orientation = getViewportArgumentValue(CSSPropertyOrientation); 102 arguments.orientation = getViewportArgumentValue(CSSPropertyOrientation);
104 103
105 m_document->setViewportArguments(arguments); 104 m_document->setViewportArguments(arguments);
106 m_document->updateViewportArguments();
107 105
108 m_propertySet = 0; 106 m_propertySet = 0;
107 m_hasAuthorStyle = false;
109 } 108 }
110 109
111 float ViewportStyleResolver::getViewportArgumentValue(CSSPropertyID id) const 110 float ViewportStyleResolver::getViewportArgumentValue(CSSPropertyID id) const
112 { 111 {
113 float defaultValue = ViewportArguments::ValueAuto; 112 float defaultValue = ViewportArguments::ValueAuto;
114 113
115 // UserZoom default value is CSSValueZoom, which maps to true, meaning that 114 // 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 115 // yes, it is user scalable. When the value is set to CSSValueFixed, we
117 // return false. 116 // return false.
118 if (id == CSSPropertyUserZoom) 117 if (id == CSSPropertyUserZoom)
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 case CSSValueInternalExtendToZoom: 160 case CSSValueInternalExtendToZoom:
162 return ViewportArguments::ValueExtendToZoom; 161 return ViewportArguments::ValueExtendToZoom;
163 case CSSValueFixed: 162 case CSSValueFixed:
164 return 0; 163 return 0;
165 default: 164 default:
166 return defaultValue; 165 return defaultValue;
167 } 166 }
168 } 167 }
169 168
170 } // namespace WebCore 169 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698