Apply the resolved viewport rules
https://bugs.webkit.org/show_bug.cgi?id=95964
Patch by Thiago Marcos P. Santos <thiago.santos@intel.com> on 2012-11-19
Reviewed by Kenneth Rohde Christiansen.
Source/WebCore:
This patch implements the CSS Device Adaptation specification. The
WebKit implementation relies on the already implemented Viewport Meta
infrastructure to notify the browser of viewport changes.
The implementation was tests with success on the Qt and EFL ports, but
basically every port supporting Viewport Meta should be fine.
The usage of @-webkit-viewport inside media queries (more tests coming
to map all the corner cases) is currently limited when the media query
depends on the viewport dimensions itself. Defining the width and height
based on screen size will fail on ports reporting the screen
size as the size of the browser window instead of the device screen.
Tests: css3/device-adapt/opera/cascading-001.xhtml
css3/device-adapt/opera/cascading-002.xhtml
css3/device-adapt/opera/cascading-003.xhtml
css3/device-adapt/opera/cascading-004.xhtml
css3/device-adapt/opera/constrain-001.xhtml
css3/device-adapt/opera/constrain-002.xhtml
css3/device-adapt/opera/constrain-003.xhtml
css3/device-adapt/opera/constrain-004.xhtml
css3/device-adapt/opera/constrain-005.xhtml
css3/device-adapt/opera/constrain-006.xhtml
css3/device-adapt/opera/constrain-007.xhtml
css3/device-adapt/opera/constrain-008.xhtml
css3/device-adapt/opera/constrain-009.xhtml
css3/device-adapt/opera/constrain-010.xhtml
css3/device-adapt/opera/constrain-011.xhtml
css3/device-adapt/opera/constrain-012.xhtml
css3/device-adapt/opera/constrain-013.xhtml
css3/device-adapt/opera/constrain-014.xhtml
css3/device-adapt/opera/constrain-015.xhtml
css3/device-adapt/opera/constrain-016.xhtml
css3/device-adapt/opera/constrain-017.xhtml
css3/device-adapt/opera/constrain-020.xhtml
css3/device-adapt/opera/syntax-001.xhtml
css3/device-adapt/opera/syntax-002.xhtml
css3/device-adapt/opera/syntax-003.xhtml
* CMakeLists.txt:
* GNUmakefile.list.am:
* Target.pri:
* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* css/CSSAllInOne.cpp:
* css/RuleSet.cpp:
(WebCore::RuleSet::addRulesFromSheet):
* css/StyleResolver.cpp:
(WebCore::StyleResolver::StyleResolver):
(WebCore::StyleResolver::appendAuthorStyleSheets):
(WebCore::StyleResolver::~StyleResolver):
* css/StyleResolver.h:
(StyleResolver):
(WebCore::StyleResolver::viewportStyleResolver):
* css/ViewportStyleResolver.cpp: Added.
(WebCore):
(WebCore::ViewportStyleResolver::ViewportStyleResolver):
(WebCore::ViewportStyleResolver::addViewportRule):
(WebCore::ViewportStyleResolver::clearDocument):
(WebCore::ViewportStyleResolver::resolve):
(WebCore::ViewportStyleResolver::getViewportArgumentValue):
* css/ViewportStyleResolver.h: Added.
(WebCore):
(ViewportStyleResolver):
(WebCore::ViewportStyleResolver::create):
* dom/Document.h:
(WebCore::Document::setViewportArguments):
* dom/ViewportArguments.cpp:
(WebCore::compareIgnoringAuto):
(WebCore):
(WebCore::ViewportArguments::resolve):
* dom/ViewportArguments.h:
(ViewportAttributes):
(WebCore::ViewportArguments::ViewportArguments):
(ViewportArguments):
(WebCore::ViewportArguments::operator==):
LayoutTests:
Imported some of the CSS Device Adaptation tests submitted by
Opera to W3C CSS Test Suite. These tests are not yet approved but
they have a pretty good coverage of the specification.
Tests using Math.floor() where modified from the original version
using Math.round(), the reason being the round() version fails by
1px when the pixel ratio is different from 1.
Despite the fact they are all passing on the EFL MiniBrowser, I could
not enable them yet. WebKitTestRunner does not support fixed layout,
but that is the next goal.
* css3/device-adapt/opera/cascading-001-expected.txt: Added.
* css3/device-adapt/opera/cascading-001.xhtml: Added.
* css3/device-adapt/opera/cascading-002-expected.txt: Added.
* css3/device-adapt/opera/cascading-002.xhtml: Added.
* css3/device-adapt/opera/cascading-003-expected.txt: Added.
* css3/device-adapt/opera/cascading-003.xhtml: Added.
* css3/device-adapt/opera/cascading-004-expected.txt: Added.
* css3/device-adapt/opera/cascading-004.xhtml: Added.
* css3/device-adapt/opera/constrain-001-expected.txt: Added.
* css3/device-adapt/opera/constrain-001.xhtml: Added.
* css3/device-adapt/opera/constrain-002-expected.txt: Added.
* css3/device-adapt/opera/constrain-002.xhtml: Added.
* css3/device-adapt/opera/constrain-003-expected.txt: Added.
* css3/device-adapt/opera/constrain-003.xhtml: Added.
* css3/device-adapt/opera/constrain-004-expected.txt: Added.
* css3/device-adapt/opera/constrain-004.xhtml: Added.
* css3/device-adapt/opera/constrain-005-expected.txt: Added.
* css3/device-adapt/opera/constrain-005.xhtml: Added.
* css3/device-adapt/opera/constrain-006-expected.txt: Added.
* css3/device-adapt/opera/constrain-006.xhtml: Added.
* css3/device-adapt/opera/constrain-007-expected.txt: Added.
* css3/device-adapt/opera/constrain-007.xhtml: Added.
* css3/device-adapt/opera/constrain-008-expected.txt: Added.
* css3/device-adapt/opera/constrain-008.xhtml: Added.
* css3/device-adapt/opera/constrain-009-expected.txt: Added.
* css3/device-adapt/opera/constrain-009.xhtml: Added.
* css3/device-adapt/opera/constrain-010-expected.txt: Added.
* css3/device-adapt/opera/constrain-010.xhtml: Added.
* css3/device-adapt/opera/constrain-011-expected.txt: Added.
* css3/device-adapt/opera/constrain-011.xhtml: Added.
* css3/device-adapt/opera/constrain-012-expected.txt: Added.
* css3/device-adapt/opera/constrain-012.xhtml: Added.
* css3/device-adapt/opera/constrain-013-expected.txt: Added.
* css3/device-adapt/opera/constrain-013.xhtml: Added.
* css3/device-adapt/opera/constrain-014-expected.txt: Added.
* css3/device-adapt/opera/constrain-014.xhtml: Added.
* css3/device-adapt/opera/constrain-015-expected.txt: Added.
* css3/device-adapt/opera/constrain-015.xhtml: Added.
* css3/device-adapt/opera/constrain-016-expected.txt: Added.
* css3/device-adapt/opera/constrain-016.xhtml: Added.
* css3/device-adapt/opera/constrain-017-expected.txt: Added.
* css3/device-adapt/opera/constrain-017.xhtml: Added.
* css3/device-adapt/opera/constrain-020-expected.txt: Added.
* css3/device-adapt/opera/constrain-020.xhtml: Added.
* css3/device-adapt/opera/syntax-001-expected.txt: Added.
* css3/device-adapt/opera/syntax-001.xhtml: Added.
* css3/device-adapt/opera/syntax-002-expected.txt: Added.
* css3/device-adapt/opera/syntax-002.xhtml: Added.
* css3/device-adapt/opera/syntax-003-expected.txt: Added.
* css3/device-adapt/opera/syntax-003.xhtml: Added.
* platform/efl/TestExpectations:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@135163 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 7614b74..68f8279 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,74 @@
+2012-11-19 Thiago Marcos P. Santos <thiago.santos@intel.com>
+
+ Apply the resolved viewport rules
+ https://bugs.webkit.org/show_bug.cgi?id=95964
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ Imported some of the CSS Device Adaptation tests submitted by
+ Opera to W3C CSS Test Suite. These tests are not yet approved but
+ they have a pretty good coverage of the specification.
+
+ Tests using Math.floor() where modified from the original version
+ using Math.round(), the reason being the round() version fails by
+ 1px when the pixel ratio is different from 1.
+
+ Despite the fact they are all passing on the EFL MiniBrowser, I could
+ not enable them yet. WebKitTestRunner does not support fixed layout,
+ but that is the next goal.
+
+ * css3/device-adapt/opera/cascading-001-expected.txt: Added.
+ * css3/device-adapt/opera/cascading-001.xhtml: Added.
+ * css3/device-adapt/opera/cascading-002-expected.txt: Added.
+ * css3/device-adapt/opera/cascading-002.xhtml: Added.
+ * css3/device-adapt/opera/cascading-003-expected.txt: Added.
+ * css3/device-adapt/opera/cascading-003.xhtml: Added.
+ * css3/device-adapt/opera/cascading-004-expected.txt: Added.
+ * css3/device-adapt/opera/cascading-004.xhtml: Added.
+ * css3/device-adapt/opera/constrain-001-expected.txt: Added.
+ * css3/device-adapt/opera/constrain-001.xhtml: Added.
+ * css3/device-adapt/opera/constrain-002-expected.txt: Added.
+ * css3/device-adapt/opera/constrain-002.xhtml: Added.
+ * css3/device-adapt/opera/constrain-003-expected.txt: Added.
+ * css3/device-adapt/opera/constrain-003.xhtml: Added.
+ * css3/device-adapt/opera/constrain-004-expected.txt: Added.
+ * css3/device-adapt/opera/constrain-004.xhtml: Added.
+ * css3/device-adapt/opera/constrain-005-expected.txt: Added.
+ * css3/device-adapt/opera/constrain-005.xhtml: Added.
+ * css3/device-adapt/opera/constrain-006-expected.txt: Added.
+ * css3/device-adapt/opera/constrain-006.xhtml: Added.
+ * css3/device-adapt/opera/constrain-007-expected.txt: Added.
+ * css3/device-adapt/opera/constrain-007.xhtml: Added.
+ * css3/device-adapt/opera/constrain-008-expected.txt: Added.
+ * css3/device-adapt/opera/constrain-008.xhtml: Added.
+ * css3/device-adapt/opera/constrain-009-expected.txt: Added.
+ * css3/device-adapt/opera/constrain-009.xhtml: Added.
+ * css3/device-adapt/opera/constrain-010-expected.txt: Added.
+ * css3/device-adapt/opera/constrain-010.xhtml: Added.
+ * css3/device-adapt/opera/constrain-011-expected.txt: Added.
+ * css3/device-adapt/opera/constrain-011.xhtml: Added.
+ * css3/device-adapt/opera/constrain-012-expected.txt: Added.
+ * css3/device-adapt/opera/constrain-012.xhtml: Added.
+ * css3/device-adapt/opera/constrain-013-expected.txt: Added.
+ * css3/device-adapt/opera/constrain-013.xhtml: Added.
+ * css3/device-adapt/opera/constrain-014-expected.txt: Added.
+ * css3/device-adapt/opera/constrain-014.xhtml: Added.
+ * css3/device-adapt/opera/constrain-015-expected.txt: Added.
+ * css3/device-adapt/opera/constrain-015.xhtml: Added.
+ * css3/device-adapt/opera/constrain-016-expected.txt: Added.
+ * css3/device-adapt/opera/constrain-016.xhtml: Added.
+ * css3/device-adapt/opera/constrain-017-expected.txt: Added.
+ * css3/device-adapt/opera/constrain-017.xhtml: Added.
+ * css3/device-adapt/opera/constrain-020-expected.txt: Added.
+ * css3/device-adapt/opera/constrain-020.xhtml: Added.
+ * css3/device-adapt/opera/syntax-001-expected.txt: Added.
+ * css3/device-adapt/opera/syntax-001.xhtml: Added.
+ * css3/device-adapt/opera/syntax-002-expected.txt: Added.
+ * css3/device-adapt/opera/syntax-002.xhtml: Added.
+ * css3/device-adapt/opera/syntax-003-expected.txt: Added.
+ * css3/device-adapt/opera/syntax-003.xhtml: Added.
+ * platform/efl/TestExpectations:
+
2012-11-19 Erik Arvidsson <arv@chromium.org>
Update DOMException name: SecurityError
diff --git a/LayoutTests/css3/device-adapt/opera/cascading-001-expected.txt b/LayoutTests/css3/device-adapt/opera/cascading-001-expected.txt
new file mode 100644
index 0000000..e4e5d90
--- /dev/null
+++ b/LayoutTests/css3/device-adapt/opera/cascading-001-expected.txt
@@ -0,0 +1,3 @@
+
+PASS CSS Test: @viewport cascading - last declaration wins
+
diff --git a/LayoutTests/css3/device-adapt/opera/cascading-001.xhtml b/LayoutTests/css3/device-adapt/opera/cascading-001.xhtml
new file mode 100644
index 0000000..2dbee24
--- /dev/null
+++ b/LayoutTests/css3/device-adapt/opera/cascading-001.xhtml
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>CSS Test: @viewport cascading - last declaration wins</title>
+ <link rel="author" title="Rune Lillesveen" href="mailto:rune@opera.com"/>
+ <link rel="help" href="http://www.w3.org/TR/css-device-adapt/#the-viewport-rule"/>
+ <meta name="flags" content="visual scroll dom" />
+ <meta name="assert" content="The last of two non-important declarations for the same descriptor wins."/>
+ <script src="../../../resources/testharness.js" type="text/javascript" />
+ <script src="../../../resources/testharnessreport.js" type="text/javascript" />
+ <style type="text/css"><![CDATA[
+ body { margin: 0; }
+ html, body, #test { width: 100%; height: 100%; }
+ #log { padding: 1em; display: none; }
+ /* Reset viewport values to initial values to ignore UA stylesheet. */
+ @-webkit-viewport {
+ width: auto;
+ height: auto;
+ zoom: auto;
+ min-zoom: auto;
+ max-zoom: auto;
+ user-zoom: zoom;
+ orientation: auto;
+ resolution: auto;
+ }
+ ]]></style>
+ <style type="text/css"><![CDATA[
+ /* CSS for the test below. */
+ @-webkit-viewport { width: 300px; width: 500px }
+ /* Set root element font-size to something different from the initial
+ font-size to make sure 'rem' and 'em' for @viewport is based on the
+ initial font-size, not the root element font-size. */
+ html { font-size: 2rem; }
+ body { font-size: 0.5rem; }
+ ]]></style>
+ <script type="text/javascript"><![CDATA[
+ var test = async_test("CSS Test: @viewport cascading - last declaration wins");
+ window.onload = function(){
+
+ var testStyleSheet = document.styleSheets.item(1);
+
+ /* Disable the stylesheet that contains the @viewport to test. */
+ testStyleSheet.disabled = true;
+
+ /* Initialize an object to store viewport values to be used by the test
+ asserts. */
+ var viewport = new Object();
+
+ /* An element with the same size as the initial containing block. */
+ var testElm = document.getElementById("test");
+
+ /* Retrieve the initial viewport values before applying the @viewport to
+ test. */
+ viewport.initialWidth = testElm.offsetWidth;
+ viewport.initialHeight = testElm.offsetHeight;
+ viewport.fontSize = parseInt(getComputedStyle(testElm, "").fontSize);
+
+ /* Enable the stylesheet that contains the @viewport to test. */
+ testStyleSheet.disabled = false;
+
+ /* Retrieve the actual viewport values for the test. */
+ viewport.actualWidth = testElm.offsetWidth;
+ viewport.actualHeight = testElm.offsetHeight;
+ viewport.zoom = viewport.initialWidth / window.innerWidth;
+
+ /* Check viewport values. */
+ test.step(function(){
+ assert_equals(viewport.actualWidth, 500);
+ });
+
+ /* Finished. Show the results. */
+ test.done();
+ testStyleSheet.disabled = true;
+ document.getElementById("log").style.display = "block";
+ }
+ ]]></script>
+ </head>
+ <body>
+ <div id="test">
+ <div id="log"></div>
+ </div>
+ </body>
+</html>
diff --git a/LayoutTests/css3/device-adapt/opera/cascading-002-expected.txt b/LayoutTests/css3/device-adapt/opera/cascading-002-expected.txt
new file mode 100644
index 0000000..82c8135
--- /dev/null
+++ b/LayoutTests/css3/device-adapt/opera/cascading-002-expected.txt
@@ -0,0 +1,3 @@
+
+PASS CSS Test: @viewport cascading - !important declaration wins
+
diff --git a/LayoutTests/css3/device-adapt/opera/cascading-002.xhtml b/LayoutTests/css3/device-adapt/opera/cascading-002.xhtml
new file mode 100644
index 0000000..55cabda
--- /dev/null
+++ b/LayoutTests/css3/device-adapt/opera/cascading-002.xhtml
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>CSS Test: @viewport cascading - !important declaration wins</title>
+ <link rel="author" title="Rune Lillesveen" href="mailto:rune@opera.com"/>
+ <link rel="help" href="http://www.w3.org/TR/css-device-adapt/#the-viewport-rule"/>
+ <meta name="flags" content="visual scroll dom" />
+ <meta name="assert" content="A preceeding !important declaration wins over a non-important descriptor."/>
+ <script src="../../../resources/testharness.js" type="text/javascript" />
+ <script src="../../../resources/testharnessreport.js" type="text/javascript" />
+ <style type="text/css"><![CDATA[
+ body { margin: 0; }
+ html, body, #test { width: 100%; height: 100%; }
+ #log { padding: 1em; display: none; }
+ /* Reset viewport values to initial values to ignore UA stylesheet. */
+ @-webkit-viewport {
+ width: auto;
+ height: auto;
+ zoom: auto;
+ min-zoom: auto;
+ max-zoom: auto;
+ user-zoom: zoom;
+ orientation: auto;
+ resolution: auto;
+ }
+ ]]></style>
+ <style type="text/css"><![CDATA[
+ /* CSS for the test below. */
+ @-webkit-viewport { width: 300px !important; width: 500px }
+ /* Set root element font-size to something different from the initial
+ font-size to make sure 'rem' and 'em' for @viewport is based on the
+ initial font-size, not the root element font-size. */
+ html { font-size: 2rem; }
+ body { font-size: 0.5rem; }
+ ]]></style>
+ <script type="text/javascript"><![CDATA[
+ var test = async_test("CSS Test: @viewport cascading - !important declaration wins");
+ window.onload = function(){
+
+ var testStyleSheet = document.styleSheets.item(1);
+
+ /* Disable the stylesheet that contains the @viewport to test. */
+ testStyleSheet.disabled = true;
+
+ /* Initialize an object to store viewport values to be used by the test
+ asserts. */
+ var viewport = new Object();
+
+ /* An element with the same size as the initial containing block. */
+ var testElm = document.getElementById("test");
+
+ /* Retrieve the initial viewport values before applying the @viewport to
+ test. */
+ viewport.initialWidth = testElm.offsetWidth;
+ viewport.initialHeight = testElm.offsetHeight;
+ viewport.fontSize = parseInt(getComputedStyle(testElm, "").fontSize);
+
+ /* Enable the stylesheet that contains the @viewport to test. */
+ testStyleSheet.disabled = false;
+
+ /* Retrieve the actual viewport values for the test. */
+ viewport.actualWidth = testElm.offsetWidth;
+ viewport.actualHeight = testElm.offsetHeight;
+ viewport.zoom = viewport.initialWidth / window.innerWidth;
+
+ /* Check viewport values. */
+ test.step(function(){
+ assert_equals(viewport.actualWidth, 300);
+ });
+
+ /* Finished. Show the results. */
+ test.done();
+ testStyleSheet.disabled = true;
+ document.getElementById("log").style.display = "block";
+ }
+ ]]></script>
+ </head>
+ <body>
+ <div id="test">
+ <div id="log"></div>
+ </div>
+ </body>
+</html>
diff --git a/LayoutTests/css3/device-adapt/opera/cascading-003-expected.txt b/LayoutTests/css3/device-adapt/opera/cascading-003-expected.txt
new file mode 100644
index 0000000..cd0406b
--- /dev/null
+++ b/LayoutTests/css3/device-adapt/opera/cascading-003-expected.txt
@@ -0,0 +1,3 @@
+
+PASS CSS Test: @viewport cascading - descriptors cascaded separately
+
diff --git a/LayoutTests/css3/device-adapt/opera/cascading-003.xhtml b/LayoutTests/css3/device-adapt/opera/cascading-003.xhtml
new file mode 100644
index 0000000..c06d720
--- /dev/null
+++ b/LayoutTests/css3/device-adapt/opera/cascading-003.xhtml
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>CSS Test: @viewport cascading - descriptors cascaded separately</title>
+ <link rel="author" title="Rune Lillesveen" href="mailto:rune@opera.com"/>
+ <link rel="help" href="http://www.w3.org/TR/css-device-adapt/#the-viewport-rule"/>
+ <meta name="flags" content="visual scroll dom" />
+ <meta name="assert" content="Descriptors are cascaded separately and may stem from different @viewport rules."/>
+ <script src="../../../resources/testharness.js" type="text/javascript" />
+ <script src="../../../resources/testharnessreport.js" type="text/javascript" />
+ <style type="text/css"><![CDATA[
+ body { margin: 0; }
+ html, body, #test { width: 100%; height: 100%; }
+ #log { padding: 1em; display: none; }
+ /* Reset viewport values to initial values to ignore UA stylesheet. */
+ @-webkit-viewport {
+ width: auto;
+ height: auto;
+ zoom: auto;
+ min-zoom: auto;
+ max-zoom: auto;
+ user-zoom: zoom;
+ orientation: auto;
+ resolution: auto;
+ }
+ ]]></style>
+ <style type="text/css"><![CDATA[
+ /* CSS for the test below. */
+ @-webkit-viewport { width: 300px; height: 300px; } @-webkit-viewport { height: 500px; }
+ /* Set root element font-size to something different from the initial
+ font-size to make sure 'rem' and 'em' for @viewport is based on the
+ initial font-size, not the root element font-size. */
+ html { font-size: 2rem; }
+ body { font-size: 0.5rem; }
+ ]]></style>
+ <script type="text/javascript"><![CDATA[
+ var test = async_test("CSS Test: @viewport cascading - descriptors cascaded separately");
+ window.onload = function(){
+
+ var testStyleSheet = document.styleSheets.item(1);
+
+ /* Disable the stylesheet that contains the @viewport to test. */
+ testStyleSheet.disabled = true;
+
+ /* Initialize an object to store viewport values to be used by the test
+ asserts. */
+ var viewport = new Object();
+
+ /* An element with the same size as the initial containing block. */
+ var testElm = document.getElementById("test");
+
+ /* Retrieve the initial viewport values before applying the @viewport to
+ test. */
+ viewport.initialWidth = testElm.offsetWidth;
+ viewport.initialHeight = testElm.offsetHeight;
+ viewport.fontSize = parseInt(getComputedStyle(testElm, "").fontSize);
+
+ /* Enable the stylesheet that contains the @viewport to test. */
+ testStyleSheet.disabled = false;
+
+ /* Retrieve the actual viewport values for the test. */
+ viewport.actualWidth = testElm.offsetWidth;
+ viewport.actualHeight = testElm.offsetHeight;
+ viewport.zoom = viewport.initialWidth / window.innerWidth;
+
+ /* Check viewport values. */
+ test.step(function(){
+ assert_equals(viewport.actualWidth, 300); assert_equals(viewport.actualHeight, 500);
+ });
+
+ /* Finished. Show the results. */
+ test.done();
+ testStyleSheet.disabled = true;
+ document.getElementById("log").style.display = "block";
+ }
+ ]]></script>
+ </head>
+ <body>
+ <div id="test">
+ <div id="log"></div>
+ </div>
+ </body>
+</html>
diff --git a/LayoutTests/css3/device-adapt/opera/cascading-004-expected.txt b/LayoutTests/css3/device-adapt/opera/cascading-004-expected.txt
new file mode 100644
index 0000000..da29b5a
--- /dev/null
+++ b/LayoutTests/css3/device-adapt/opera/cascading-004-expected.txt
@@ -0,0 +1,3 @@
+
+PASS CSS Test: @viewport cascading - !important declaration from preceding rule wins
+
diff --git a/LayoutTests/css3/device-adapt/opera/cascading-004.xhtml b/LayoutTests/css3/device-adapt/opera/cascading-004.xhtml
new file mode 100644
index 0000000..61d65b8
--- /dev/null
+++ b/LayoutTests/css3/device-adapt/opera/cascading-004.xhtml
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>CSS Test: @viewport cascading - !important declaration from preceding rule wins</title>
+ <link rel="author" title="Rune Lillesveen" href="mailto:rune@opera.com"/>
+ <link rel="help" href="http://www.w3.org/TR/css-device-adapt/#the-viewport-rule"/>
+ <meta name="flags" content="visual scroll dom" />
+ <meta name="assert" content="A preceeding !important declaration from a preceding rule wins over a non-important descriptor."/>
+ <script src="../../../resources/testharness.js" type="text/javascript" />
+ <script src="../../../resources/testharnessreport.js" type="text/javascript" />
+ <style type="text/css"><![CDATA[
+ body { margin: 0; }
+ html, body, #test { width: 100%; height: 100%; }
+ #log { padding: 1em; display: none; }
+ /* Reset viewport values to initial values to ignore UA stylesheet. */
+ @-webkit-viewport {
+ width: auto;
+ height: auto;
+ zoom: auto;
+ min-zoom: auto;
+ max-zoom: auto;
+ user-zoom: zoom;
+ orientation: auto;
+ resolution: auto;
+ }
+ ]]></style>
+ <style type="text/css"><![CDATA[
+ /* CSS for the test below. */
+ @-webkit-viewport { width: 300px !important; } @-webkit-viewport { width: 500px; }
+ /* Set root element font-size to something different from the initial
+ font-size to make sure 'rem' and 'em' for @viewport is based on the
+ initial font-size, not the root element font-size. */
+ html { font-size: 2rem; }
+ body { font-size: 0.5rem; }
+ ]]></style>
+ <script type="text/javascript"><![CDATA[
+ var test = async_test("CSS Test: @viewport cascading - !important declaration from preceding rule wins");
+ window.onload = function(){
+
+ var testStyleSheet = document.styleSheets.item(1);
+
+ /* Disable the stylesheet that contains the @viewport to test. */
+ testStyleSheet.disabled = true;
+
+ /* Initialize an object to store viewport values to be used by the test
+ asserts. */
+ var viewport = new Object();
+
+ /* An element with the same size as the initial containing block. */
+ var testElm = document.getElementById("test");
+
+ /* Retrieve the initial viewport values before applying the @viewport to
+ test. */
+ viewport.initialWidth = testElm.offsetWidth;
+ viewport.initialHeight = testElm.offsetHeight;
+ viewport.fontSize = parseInt(getComputedStyle(testElm, "").fontSize);
+
+ /* Enable the stylesheet that contains the @viewport to test. */
+ testStyleSheet.disabled = false;
+
+ /* Retrieve the actual viewport values for the test. */
+ viewport.actualWidth = testElm.offsetWidth;
+ viewport.actualHeight = testElm.offsetHeight;
+ viewport.zoom = viewport.initialWidth / window.innerWidth;
+
+ /* Check viewport values. */
+ test.step(function(){
+ assert_equals(viewport.actualWidth, 300);
+ });
+
+ /* Finished. Show the results. */
+ test.done();
+ testStyleSheet.disabled = true;
+ document.getElementById("log").style.display = "block";
+ }
+ ]]></script>
+ </head>
+ <body>
+ <div id="test">
+ <div id="log"></div>
+ </div>
+ </body>
+</html>
diff --git a/LayoutTests/css3/device-adapt/opera/constrain-001-expected.txt b/LayoutTests/css3/device-adapt/opera/constrain-001-expected.txt
new file mode 100644
index 0000000..18a9da9
--- /dev/null
+++ b/LayoutTests/css3/device-adapt/opera/constrain-001-expected.txt
@@ -0,0 +1,3 @@
+
+PASS CSS Test: @viewport constrained - max-width 200px
+
diff --git a/LayoutTests/css3/device-adapt/opera/constrain-001.xhtml b/LayoutTests/css3/device-adapt/opera/constrain-001.xhtml
new file mode 100644
index 0000000..1fc3434
--- /dev/null
+++ b/LayoutTests/css3/device-adapt/opera/constrain-001.xhtml
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>CSS Test: @viewport constrained - max-width 200px</title>
+ <link rel="author" title="Rune Lillesveen" href="mailto:rune@opera.com"/>
+ <link rel="help" href="http://www.w3.org/TR/css-device-adapt/#constraining-procedure"/>
+ <meta name="flags" content="visual scroll dom" />
+ <meta name="assert" content="Setting max-width in @viewport to a length smaller than the initial viewport width will set the actual viewport width to that length"/>
+ <script src="../../../resources/testharness.js" type="text/javascript" />
+ <script src="../../../resources/testharnessreport.js" type="text/javascript" />
+ <style type="text/css"><![CDATA[
+ body { margin: 0; }
+ html, body, #test { width: 100%; height: 100%; }
+ #log { padding: 1em; display: none; }
+ /* Reset viewport values to initial values to ignore UA stylesheet. */
+ @-webkit-viewport {
+ width: auto;
+ height: auto;
+ zoom: auto;
+ min-zoom: auto;
+ max-zoom: auto;
+ user-zoom: zoom;
+ orientation: auto;
+ resolution: auto;
+ }
+ ]]></style>
+ <style type="text/css"><![CDATA[
+ /* CSS for the test below. */
+ @-webkit-viewport { max-width: 200px }
+ /* Set root element font-size to something different from the initial
+ font-size to make sure 'rem' and 'em' for @viewport is based on the
+ initial font-size, not the root element font-size. */
+ html { font-size: 2rem; }
+ body { font-size: 0.5rem; }
+ ]]></style>
+ <script type="text/javascript"><![CDATA[
+ var test = async_test("CSS Test: @viewport constrained - max-width 200px");
+ window.onload = function(){
+
+ var testStyleSheet = document.styleSheets.item(1);
+
+ /* Disable the stylesheet that contains the @viewport to test. */
+ testStyleSheet.disabled = true;
+
+ /* Initialize an object to store viewport values to be used by the test
+ asserts. */
+ var viewport = new Object();
+
+ /* An element with the same size as the initial containing block. */
+ var testElm = document.getElementById("test");
+
+ /* Retrieve the initial viewport values before applying the @viewport to
+ test. */
+ viewport.initialWidth = testElm.offsetWidth;
+ viewport.initialHeight = testElm.offsetHeight;
+ viewport.fontSize = parseInt(getComputedStyle(testElm, "").fontSize);
+
+ /* Enable the stylesheet that contains the @viewport to test. */
+ testStyleSheet.disabled = false;
+
+ /* Retrieve the actual viewport values for the test. */
+ viewport.actualWidth = testElm.offsetWidth;
+ viewport.actualHeight = testElm.offsetHeight;
+ viewport.zoom = viewport.initialWidth / window.innerWidth;
+
+ /* Check viewport values. */
+ test.step(function(){
+ assert_equals(viewport.actualWidth, 200);
+ });
+
+ /* Finished. Show the results. */
+ test.done();
+ testStyleSheet.disabled = true;
+ document.getElementById("log").style.display = "block";
+ }
+ ]]></script>
+ </head>
+ <body>
+ <div id="test">
+ <div id="log"></div>
+ </div>
+ </body>
+</html>
diff --git a/LayoutTests/css3/device-adapt/opera/constrain-002-expected.txt b/LayoutTests/css3/device-adapt/opera/constrain-002-expected.txt
new file mode 100644
index 0000000..2a78359
--- /dev/null
+++ b/LayoutTests/css3/device-adapt/opera/constrain-002-expected.txt
@@ -0,0 +1,3 @@
+
+PASS CSS Test: @viewport constrained - max-width 10000px
+
diff --git a/LayoutTests/css3/device-adapt/opera/constrain-002.xhtml b/LayoutTests/css3/device-adapt/opera/constrain-002.xhtml
new file mode 100644
index 0000000..dcb9ddc
--- /dev/null
+++ b/LayoutTests/css3/device-adapt/opera/constrain-002.xhtml
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>CSS Test: @viewport constrained - max-width 10000px</title>
+ <link rel="author" title="Rune Lillesveen" href="mailto:rune@opera.com"/>
+ <link rel="help" href="http://www.w3.org/TR/css-device-adapt/#constraining-procedure"/>
+ <meta name="flags" content="visual scroll dom" />
+ <meta name="assert" content="Setting max-width in @viewport to a length larger than the initial viewport width will not change the actual viewport width."/>
+ <script src="../../../resources/testharness.js" type="text/javascript" />
+ <script src="../../../resources/testharnessreport.js" type="text/javascript" />
+ <style type="text/css"><![CDATA[
+ body { margin: 0; }
+ html, body, #test { width: 100%; height: 100%; }
+ #log { padding: 1em; display: none; }
+ /* Reset viewport values to initial values to ignore UA stylesheet. */
+ @-webkit-viewport {
+ width: auto;
+ height: auto;
+ zoom: auto;
+ min-zoom: auto;
+ max-zoom: auto;
+ user-zoom: zoom;
+ orientation: auto;
+ resolution: auto;
+ }
+ ]]></style>
+ <style type="text/css"><![CDATA[
+ /* CSS for the test below. */
+ @-webkit-viewport { max-width: 10000px }
+ /* Set root element font-size to something different from the initial
+ font-size to make sure 'rem' and 'em' for @viewport is based on the
+ initial font-size, not the root element font-size. */
+ html { font-size: 2rem; }
+ body { font-size: 0.5rem; }
+ ]]></style>
+ <script type="text/javascript"><![CDATA[
+ var test = async_test("CSS Test: @viewport constrained - max-width 10000px");
+ window.onload = function(){
+
+ var testStyleSheet = document.styleSheets.item(1);
+
+ /* Disable the stylesheet that contains the @viewport to test. */
+ testStyleSheet.disabled = true;
+
+ /* Initialize an object to store viewport values to be used by the test
+ asserts. */
+ var viewport = new Object();
+
+ /* An element with the same size as the initial containing block. */
+ var testElm = document.getElementById("test");
+
+ /* Retrieve the initial viewport values before applying the @viewport to
+ test. */
+ viewport.initialWidth = testElm.offsetWidth;
+ viewport.initialHeight = testElm.offsetHeight;
+ viewport.fontSize = parseInt(getComputedStyle(testElm, "").fontSize);
+
+ /* Enable the stylesheet that contains the @viewport to test. */
+ testStyleSheet.disabled = false;
+
+ /* Retrieve the actual viewport values for the test. */
+ viewport.actualWidth = testElm.offsetWidth;
+ viewport.actualHeight = testElm.offsetHeight;
+ viewport.zoom = viewport.initialWidth / window.innerWidth;
+
+ /* Check viewport values. */
+ test.step(function(){
+ assert_equals(viewport.actualWidth, viewport.initialWidth);
+ });
+
+ /* Finished. Show the results. */
+ test.done();
+ testStyleSheet.disabled = true;
+ document.getElementById("log").style.display = "block";
+ }
+ ]]></script>
+ </head>
+ <body>
+ <div id="test">
+ <div id="log"></div>
+ </div>
+ </body>
+</html>
diff --git a/LayoutTests/css3/device-adapt/opera/constrain-003-expected.txt b/LayoutTests/css3/device-adapt/opera/constrain-003-expected.txt
new file mode 100644
index 0000000..11c9899
--- /dev/null
+++ b/LayoutTests/css3/device-adapt/opera/constrain-003-expected.txt
@@ -0,0 +1,3 @@
+
+PASS CSS Test: @viewport constrained - min-width 10px
+
diff --git a/LayoutTests/css3/device-adapt/opera/constrain-003.xhtml b/LayoutTests/css3/device-adapt/opera/constrain-003.xhtml
new file mode 100644
index 0000000..3d7820f
--- /dev/null
+++ b/LayoutTests/css3/device-adapt/opera/constrain-003.xhtml
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>CSS Test: @viewport constrained - min-width 10px</title>
+ <link rel="author" title="Rune Lillesveen" href="mailto:rune@opera.com"/>
+ <link rel="help" href="http://www.w3.org/TR/css-device-adapt/#constraining-procedure"/>
+ <meta name="flags" content="visual scroll dom" />
+ <meta name="assert" content="Setting min-width in @viewport to a length smaller than the initial viewport width will not change the actual viewport width."/>
+ <script src="../../../resources/testharness.js" type="text/javascript" />
+ <script src="../../../resources/testharnessreport.js" type="text/javascript" />
+ <style type="text/css"><![CDATA[
+ body { margin: 0; }
+ html, body, #test { width: 100%; height: 100%; }
+ #log { padding: 1em; display: none; }
+ /* Reset viewport values to initial values to ignore UA stylesheet. */
+ @-webkit-viewport {
+ width: auto;
+ height: auto;
+ zoom: auto;
+ min-zoom: auto;
+ max-zoom: auto;
+ user-zoom: zoom;
+ orientation: auto;
+ resolution: auto;
+ }
+ ]]></style>
+ <style type="text/css"><![CDATA[
+ /* CSS for the test below. */
+ @-webkit-viewport { min-width: 10px }
+ /* Set root element font-size to something different from the initial
+ font-size to make sure 'rem' and 'em' for @viewport is based on the
+ initial font-size, not the root element font-size. */
+ html { font-size: 2rem; }
+ body { font-size: 0.5rem; }
+ ]]></style>
+ <script type="text/javascript"><![CDATA[
+ var test = async_test("CSS Test: @viewport constrained - min-width 10px");
+ window.onload = function(){
+
+ var testStyleSheet = document.styleSheets.item(1);
+
+ /* Disable the stylesheet that contains the @viewport to test. */
+ testStyleSheet.disabled = true;
+
+ /* Initialize an object to store viewport values to be used by the test
+ asserts. */
+ var viewport = new Object();
+
+ /* An element with the same size as the initial containing block. */
+ var testElm = document.getElementById("test");
+
+ /* Retrieve the initial viewport values before applying the @viewport to
+ test. */
+ viewport.initialWidth = testElm.offsetWidth;
+ viewport.initialHeight = testElm.offsetHeight;
+ viewport.fontSize = parseInt(getComputedStyle(testElm, "").fontSize);
+
+ /* Enable the stylesheet that contains the @viewport to test. */
+ testStyleSheet.disabled = false;
+
+ /* Retrieve the actual viewport values for the test. */
+ viewport.actualWidth = testElm.offsetWidth;
+ viewport.actualHeight = testElm.offsetHeight;
+ viewport.zoom = viewport.initialWidth / window.innerWidth;
+
+ /* Check viewport values. */
+ test.step(function(){
+ assert_equals(viewport.actualWidth, viewport.initialWidth);
+ });
+
+ /* Finished. Show the results. */
+ test.done();
+ testStyleSheet.disabled = true;
+ document.getElementById("log").style.display = "block";
+ }
+ ]]></script>
+ </head>
+ <body>
+ <div id="test">
+ <div id="log"></div>
+ </div>
+ </body>
+</html>
diff --git a/LayoutTests/css3/device-adapt/opera/constrain-004-expected.txt b/LayoutTests/css3/device-adapt/opera/constrain-004-expected.txt
new file mode 100644
index 0000000..3585d37
--- /dev/null
+++ b/LayoutTests/css3/device-adapt/opera/constrain-004-expected.txt
@@ -0,0 +1,3 @@
+
+PASS CSS Test: @viewport constrained - min-width 10000px
+
diff --git a/LayoutTests/css3/device-adapt/opera/constrain-004.xhtml b/LayoutTests/css3/device-adapt/opera/constrain-004.xhtml
new file mode 100644
index 0000000..2baf638
--- /dev/null
+++ b/LayoutTests/css3/device-adapt/opera/constrain-004.xhtml
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>CSS Test: @viewport constrained - min-width 10000px</title>
+ <link rel="author" title="Rune Lillesveen" href="mailto:rune@opera.com"/>
+ <link rel="help" href="http://www.w3.org/TR/css-device-adapt/#constraining-procedure"/>
+ <meta name="flags" content="visual scroll dom" />
+ <meta name="assert" content="Setting min-width in @viewport to a length larger than the initial viewport width will set the actual viewport width to that length."/>
+ <script src="../../../resources/testharness.js" type="text/javascript" />
+ <script src="../../../resources/testharnessreport.js" type="text/javascript" />
+ <style type="text/css"><![CDATA[
+ body { margin: 0; }
+ html, body, #test { width: 100%; height: 100%; }
+ #log { padding: 1em; display: none; }
+ /* Reset viewport values to initial values to ignore UA stylesheet. */
+ @-webkit-viewport {
+ width: auto;
+ height: auto;
+ zoom: auto;
+ min-zoom: auto;
+ max-zoom: auto;
+ user-zoom: zoom;
+ orientation: auto;
+ resolution: auto;
+ }
+ ]]></style>
+ <style type="text/css"><![CDATA[
+ /* CSS for the test below. */
+ @-webkit-viewport { min-width: 10000px }
+ /* Set root element font-size to something different from the initial
+ font-size to make sure 'rem' and 'em' for @viewport is based on the
+ initial font-size, not the root element font-size. */
+ html { font-size: 2rem; }
+ body { font-size: 0.5rem; }
+ ]]></style>
+ <script type="text/javascript"><![CDATA[
+ var test = async_test("CSS Test: @viewport constrained - min-width 10000px");
+ window.onload = function(){
+
+ var testStyleSheet = document.styleSheets.item(1);
+
+ /* Disable the stylesheet that contains the @viewport to test. */
+ testStyleSheet.disabled = true;
+
+ /* Initialize an object to store viewport values to be used by the test
+ asserts. */
+ var viewport = new Object();
+
+ /* An element with the same size as the initial containing block. */
+ var testElm = document.getElementById("test");
+
+ /* Retrieve the initial viewport values before applying the @viewport to
+ test. */
+ viewport.initialWidth = testElm.offsetWidth;
+ viewport.initialHeight = testElm.offsetHeight;
+ viewport.fontSize = parseInt(getComputedStyle(testElm, "").fontSize);
+
+ /* Enable the stylesheet that contains the @viewport to test. */
+ testStyleSheet.disabled = false;
+
+ /* Retrieve the actual viewport values for the test. */
+ viewport.actualWidth = testElm.offsetWidth;
+ viewport.actualHeight = testElm.offsetHeight;
+ viewport.zoom = viewport.initialWidth / window.innerWidth;
+
+ /* Check viewport values. */
+ test.step(function(){
+ assert_equals(viewport.actualWidth, 10000);
+ });
+
+ /* Finished. Show the results. */
+ test.done();
+ testStyleSheet.disabled = true;
+ document.getElementById("log").style.display = "block";
+ }
+ ]]></script>
+ </head>
+ <body>
+ <div id="test">
+ <div id="log"></div>
+ </div>
+ </body>
+</html>
diff --git a/LayoutTests/css3/device-adapt/opera/constrain-005-expected.txt b/LayoutTests/css3/device-adapt/opera/constrain-005-expected.txt
new file mode 100644
index 0000000..808ddf2
--- /dev/null
+++ b/LayoutTests/css3/device-adapt/opera/constrain-005-expected.txt
@@ -0,0 +1,3 @@
+
+PASS CSS Test: @viewport constrained - min-width greater than max-width.
+
diff --git a/LayoutTests/css3/device-adapt/opera/constrain-005.xhtml b/LayoutTests/css3/device-adapt/opera/constrain-005.xhtml
new file mode 100644
index 0000000..1d6bf46
--- /dev/null
+++ b/LayoutTests/css3/device-adapt/opera/constrain-005.xhtml
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>CSS Test: @viewport constrained - min-width greater than max-width.</title>
+ <link rel="author" title="Rune Lillesveen" href="mailto:rune@opera.com"/>
+ <link rel="help" href="http://www.w3.org/TR/css-device-adapt/#constraining-procedure"/>
+ <meta name="flags" content="visual scroll dom" />
+ <meta name="assert" content="If min-width is greater than max-width, min-width will overrule max-width."/>
+ <script src="../../../resources/testharness.js" type="text/javascript" />
+ <script src="../../../resources/testharnessreport.js" type="text/javascript" />
+ <style type="text/css"><![CDATA[
+ body { margin: 0; }
+ html, body, #test { width: 100%; height: 100%; }
+ #log { padding: 1em; display: none; }
+ /* Reset viewport values to initial values to ignore UA stylesheet. */
+ @-webkit-viewport {
+ width: auto;
+ height: auto;
+ zoom: auto;
+ min-zoom: auto;
+ max-zoom: auto;
+ user-zoom: zoom;
+ orientation: auto;
+ resolution: auto;
+ }
+ ]]></style>
+ <style type="text/css"><![CDATA[
+ /* CSS for the test below. */
+ @-webkit-viewport { min-width: 10000px; max-width: 200px }
+ /* Set root element font-size to something different from the initial
+ font-size to make sure 'rem' and 'em' for @viewport is based on the
+ initial font-size, not the root element font-size. */
+ html { font-size: 2rem; }
+ body { font-size: 0.5rem; }
+ ]]></style>
+ <script type="text/javascript"><![CDATA[
+ var test = async_test("CSS Test: @viewport constrained - min-width greater than max-width.");
+ window.onload = function(){
+
+ var testStyleSheet = document.styleSheets.item(1);
+
+ /* Disable the stylesheet that contains the @viewport to test. */
+ testStyleSheet.disabled = true;
+
+ /* Initialize an object to store viewport values to be used by the test
+ asserts. */
+ var viewport = new Object();
+
+ /* An element with the same size as the initial containing block. */
+ var testElm = document.getElementById("test");
+
+ /* Retrieve the initial viewport values before applying the @viewport to
+ test. */
+ viewport.initialWidth = testElm.offsetWidth;
+ viewport.initialHeight = testElm.offsetHeight;
+ viewport.fontSize = parseInt(getComputedStyle(testElm, "").fontSize);
+
+ /* Enable the stylesheet that contains the @viewport to test. */
+ testStyleSheet.disabled = false;
+
+ /* Retrieve the actual viewport values for the test. */
+ viewport.actualWidth = testElm.offsetWidth;
+ viewport.actualHeight = testElm.offsetHeight;
+ viewport.zoom = viewport.initialWidth / window.innerWidth;
+
+ /* Check viewport values. */
+ test.step(function(){
+ assert_equals(viewport.actualWidth, 10000);
+ });
+
+ /* Finished. Show the results. */
+ test.done();
+ testStyleSheet.disabled = true;
+ document.getElementById("log").style.display = "block";
+ }
+ ]]></script>
+ </head>
+ <body>
+ <div id="test">
+ <div id="log"></div>
+ </div>
+ </body>
+</html>
diff --git a/LayoutTests/css3/device-adapt/opera/constrain-006-expected.txt b/LayoutTests/css3/device-adapt/opera/constrain-006-expected.txt
new file mode 100644
index 0000000..b03d3de
--- /dev/null
+++ b/LayoutTests/css3/device-adapt/opera/constrain-006-expected.txt
@@ -0,0 +1,3 @@
+
+PASS CSS Test: @viewport constrained - width 200%
+
diff --git a/LayoutTests/css3/device-adapt/opera/constrain-006.xhtml b/LayoutTests/css3/device-adapt/opera/constrain-006.xhtml
new file mode 100644
index 0000000..49e714d
--- /dev/null
+++ b/LayoutTests/css3/device-adapt/opera/constrain-006.xhtml
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>CSS Test: @viewport constrained - width 200%</title>
+ <link rel="author" title="Rune Lillesveen" href="mailto:rune@opera.com"/>
+ <link rel="help" href="http://www.w3.org/TR/css-device-adapt/#constraining-procedure"/>
+ <meta name="flags" content="visual scroll dom" />
+ <meta name="assert" content="Setting width in @viewport to 200% will set the actual viewport width to twice the initial-width."/>
+ <script src="../../../resources/testharness.js" type="text/javascript" />
+ <script src="../../../resources/testharnessreport.js" type="text/javascript" />
+ <style type="text/css"><![CDATA[
+ body { margin: 0; }
+ html, body, #test { width: 100%; height: 100%; }
+ #log { padding: 1em; display: none; }
+ /* Reset viewport values to initial values to ignore UA stylesheet. */
+ @-webkit-viewport {
+ width: auto;
+ height: auto;
+ zoom: auto;
+ min-zoom: auto;
+ max-zoom: auto;
+ user-zoom: zoom;
+ orientation: auto;
+ resolution: auto;
+ }
+ ]]></style>
+ <style type="text/css"><![CDATA[
+ /* CSS for the test below. */
+ @-webkit-viewport { width: 200% }
+ /* Set root element font-size to something different from the initial
+ font-size to make sure 'rem' and 'em' for @viewport is based on the
+ initial font-size, not the root element font-size. */
+ html { font-size: 2rem; }
+ body { font-size: 0.5rem; }
+ ]]></style>
+ <script type="text/javascript"><![CDATA[
+ var test = async_test("CSS Test: @viewport constrained - width 200%");
+ window.onload = function(){
+
+ var testStyleSheet = document.styleSheets.item(1);
+
+ /* Disable the stylesheet that contains the @viewport to test. */
+ testStyleSheet.disabled = true;
+
+ /* Initialize an object to store viewport values to be used by the test
+ asserts. */
+ var viewport = new Object();
+
+ /* An element with the same size as the initial containing block. */
+ var testElm = document.getElementById("test");
+
+ /* Retrieve the initial viewport values before applying the @viewport to
+ test. */
+ viewport.initialWidth = testElm.offsetWidth;
+ viewport.initialHeight = testElm.offsetHeight;
+ viewport.fontSize = parseInt(getComputedStyle(testElm, "").fontSize);
+
+ /* Enable the stylesheet that contains the @viewport to test. */
+ testStyleSheet.disabled = false;
+
+ /* Retrieve the actual viewport values for the test. */
+ viewport.actualWidth = testElm.offsetWidth;
+ viewport.actualHeight = testElm.offsetHeight;
+ viewport.zoom = viewport.initialWidth / window.innerWidth;
+
+ /* Check viewport values. */
+ test.step(function(){
+ assert_equals(viewport.actualWidth, 2*viewport.initialWidth);
+ });
+
+ /* Finished. Show the results. */
+ test.done();
+ testStyleSheet.disabled = true;
+ document.getElementById("log").style.display = "block";
+ }
+ ]]></script>
+ </head>
+ <body>
+ <div id="test">
+ <div id="log"></div>
+ </div>
+ </body>
+</html>
diff --git a/LayoutTests/css3/device-adapt/opera/constrain-007-expected.txt b/LayoutTests/css3/device-adapt/opera/constrain-007-expected.txt
new file mode 100644
index 0000000..f345051
--- /dev/null
+++ b/LayoutTests/css3/device-adapt/opera/constrain-007-expected.txt
@@ -0,0 +1,3 @@
+
+PASS CSS Test: @viewport constrained - width 50%
+
diff --git a/LayoutTests/css3/device-adapt/opera/constrain-007.xhtml b/LayoutTests/css3/device-adapt/opera/constrain-007.xhtml
new file mode 100644
index 0000000..a6e0697
--- /dev/null
+++ b/LayoutTests/css3/device-adapt/opera/constrain-007.xhtml
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>CSS Test: @viewport constrained - width 50%</title>
+ <link rel="author" title="Rune Lillesveen" href="mailto:rune@opera.com"/>
+ <link rel="help" href="http://www.w3.org/TR/css-device-adapt/#constraining-procedure"/>
+ <meta name="flags" content="visual scroll dom" />
+ <meta name="assert" content="Setting width in @viewport to 50% will set the actual viewport width to half the initial-width."/>
+ <script src="../../../resources/testharness.js" type="text/javascript" />
+ <script src="../../../resources/testharnessreport.js" type="text/javascript" />
+ <style type="text/css"><![CDATA[
+ body { margin: 0; }
+ html, body, #test { width: 100%; height: 100%; }
+ #log { padding: 1em; display: none; }
+ /* Reset viewport values to initial values to ignore UA stylesheet. */
+ @-webkit-viewport {
+ width: auto;
+ height: auto;
+ zoom: auto;
+ min-zoom: auto;
+ max-zoom: auto;
+ user-zoom: zoom;
+ orientation: auto;
+ resolution: auto;
+ }
+ ]]></style>
+ <style type="text/css"><![CDATA[
+ /* CSS for the test below. */
+ @-webkit-viewport { width: 50% }
+ /* Set root element font-size to something different from the initial
+ font-size to make sure 'rem' and 'em' for @viewport is based on the
+ initial font-size, not the root element font-size. */
+ html { font-size: 2rem; }
+ body { font-size: 0.5rem; }
+ ]]></style>
+ <script type="text/javascript"><![CDATA[
+ var test = async_test("CSS Test: @viewport constrained - width 50%");
+ window.onload = function(){
+
+ var testStyleSheet = document.styleSheets.item(1);
+
+ /* Disable the stylesheet that contains the @viewport to test. */
+ testStyleSheet.disabled = true;
+
+ /* Initialize an object to store viewport values to be used by the test
+ asserts. */
+ var viewport = new Object();
+
+ /* An element with the same size as the initial containing block. */
+ var testElm = document.getElementById("test");
+
+ /* Retrieve the initial viewport values before applying the @viewport to
+ test. */
+ viewport.initialWidth = testElm.offsetWidth;
+ viewport.initialHeight = testElm.offsetHeight;
+ viewport.fontSize = parseInt(getComputedStyle(testElm, "").fontSize);
+
+ /* Enable the stylesheet that contains the @viewport to test. */
+ testStyleSheet.disabled = false;
+
+ /* Retrieve the actual viewport values for the test. */
+ viewport.actualWidth = testElm.offsetWidth;
+ viewport.actualHeight = testElm.offsetHeight;
+ viewport.zoom = viewport.initialWidth / window.innerWidth;
+
+ /* Check viewport values. */
+ test.step(function(){
+ assert_equals(viewport.actualWidth, Math.floor(viewport.initialWidth/2));
+ });
+
+ /* Finished. Show the results. */
+ test.done();
+ testStyleSheet.disabled = true;
+ document.getElementById("log").style.display = "block";
+ }
+ ]]></script>
+ </head>
+ <body>
+ <div id="test">
+ <div id="log"></div>
+ </div>
+ </body>
+</html>
diff --git a/LayoutTests/css3/device-adapt/opera/constrain-008-expected.txt b/LayoutTests/css3/device-adapt/opera/constrain-008-expected.txt
new file mode 100644
index 0000000..8f2ec74
--- /dev/null
+++ b/LayoutTests/css3/device-adapt/opera/constrain-008-expected.txt
@@ -0,0 +1,3 @@
+
+PASS CSS Test: @viewport constrained - min-zoom greater than max-zoom
+
diff --git a/LayoutTests/css3/device-adapt/opera/constrain-008.xhtml b/LayoutTests/css3/device-adapt/opera/constrain-008.xhtml
new file mode 100644
index 0000000..ea9e36a
--- /dev/null
+++ b/LayoutTests/css3/device-adapt/opera/constrain-008.xhtml
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>CSS Test: @viewport constrained - min-zoom greater than max-zoom</title>
+ <link rel="author" title="Rune Lillesveen" href="mailto:rune@opera.com"/>
+ <link rel="help" href="http://www.w3.org/TR/css-device-adapt/#constraining-procedure"/>
+ <meta name="flags" content="visual scroll dom" />
+ <meta name="assert" content="If min-zoom is greater than max-zoom, min-zoom will overrule max-zoom."/>
+ <script src="../../../resources/testharness.js" type="text/javascript" />
+ <script src="../../../resources/testharnessreport.js" type="text/javascript" />
+ <style type="text/css"><![CDATA[
+ body { margin: 0; }
+ html, body, #test { width: 100%; height: 100%; }
+ #log { padding: 1em; display: none; }
+ /* Reset viewport values to initial values to ignore UA stylesheet. */
+ @-webkit-viewport {
+ width: auto;
+ height: auto;
+ zoom: auto;
+ min-zoom: auto;
+ max-zoom: auto;
+ user-zoom: zoom;
+ orientation: auto;
+ resolution: auto;
+ }
+ ]]></style>
+ <style type="text/css"><![CDATA[
+ /* CSS for the test below. */
+ @-webkit-viewport { zoom: 100%; min-zoom: 200%; max-zoom: 50% }
+ /* Set root element font-size to something different from the initial
+ font-size to make sure 'rem' and 'em' for @viewport is based on the
+ initial font-size, not the root element font-size. */
+ html { font-size: 2rem; }
+ body { font-size: 0.5rem; }
+ ]]></style>
+ <script type="text/javascript"><![CDATA[
+ var test = async_test("CSS Test: @viewport constrained - min-zoom greater than max-zoom");
+ window.onload = function(){
+
+ var testStyleSheet = document.styleSheets.item(1);
+
+ /* Disable the stylesheet that contains the @viewport to test. */
+ testStyleSheet.disabled = true;
+
+ /* Initialize an object to store viewport values to be used by the test
+ asserts. */
+ var viewport = new Object();
+
+ /* An element with the same size as the initial containing block. */
+ var testElm = document.getElementById("test");
+
+ /* Retrieve the initial viewport values before applying the @viewport to
+ test. */
+ viewport.initialWidth = testElm.offsetWidth;
+ viewport.initialHeight = testElm.offsetHeight;
+ viewport.fontSize = parseInt(getComputedStyle(testElm, "").fontSize);
+
+ /* Enable the stylesheet that contains the @viewport to test. */
+ testStyleSheet.disabled = false;
+
+ /* Retrieve the actual viewport values for the test. */
+ viewport.actualWidth = testElm.offsetWidth;
+ viewport.actualHeight = testElm.offsetHeight;
+ viewport.zoom = viewport.initialWidth / window.innerWidth;
+
+ /* Check viewport values. */
+ test.step(function(){
+ assert_equals(viewport.actualWidth, Math.floor(viewport.initialWidth/2));
+ });
+
+ /* Finished. Show the results. */
+ test.done();
+ testStyleSheet.disabled = true;
+ document.getElementById("log").style.display = "block";
+ }
+ ]]></script>
+ </head>
+ <body>
+ <div id="test">
+ <div id="log"></div>
+ </div>
+ </body>
+</html>
diff --git a/LayoutTests/css3/device-adapt/opera/constrain-009-expected.txt b/LayoutTests/css3/device-adapt/opera/constrain-009-expected.txt
new file mode 100644
index 0000000..817330a
--- /dev/null
+++ b/LayoutTests/css3/device-adapt/opera/constrain-009-expected.txt
@@ -0,0 +1,3 @@
+
+PASS CSS Test: @viewport constrained - width 20em
+
diff --git a/LayoutTests/css3/device-adapt/opera/constrain-009.xhtml b/LayoutTests/css3/device-adapt/opera/constrain-009.xhtml
new file mode 100644
index 0000000..74f99d1
--- /dev/null
+++ b/LayoutTests/css3/device-adapt/opera/constrain-009.xhtml
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>CSS Test: @viewport constrained - width 20em</title>
+ <link rel="author" title="Rune Lillesveen" href="mailto:rune@opera.com"/>
+ <link rel="help" href="http://www.w3.org/TR/css-device-adapt/#constraining-procedure"/>
+ <meta name="flags" content="visual scroll dom" />
+ <meta name="assert" content="Setting width in @viewport to 20em will set the actual viewport width to 20 times the initial font-size."/>
+ <script src="../../../resources/testharness.js" type="text/javascript" />
+ <script src="../../../resources/testharnessreport.js" type="text/javascript" />
+ <style type="text/css"><![CDATA[
+ body { margin: 0; }
+ html, body, #test { width: 100%; height: 100%; }
+ #log { padding: 1em; display: none; }
+ /* Reset viewport values to initial values to ignore UA stylesheet. */
+ @-webkit-viewport {
+ width: auto;
+ height: auto;
+ zoom: auto;
+ min-zoom: auto;
+ max-zoom: auto;
+ user-zoom: zoom;
+ orientation: auto;
+ resolution: auto;
+ }
+ ]]></style>
+ <style type="text/css"><![CDATA[
+ /* CSS for the test below. */
+ @-webkit-viewport { width: 20em }
+ /* Set root element font-size to something different from the initial
+ font-size to make sure 'rem' and 'em' for @viewport is based on the
+ initial font-size, not the root element font-size. */
+ html { font-size: 2rem; }
+ body { font-size: 0.5rem; }
+ ]]></style>
+ <script type="text/javascript"><![CDATA[
+ var test = async_test("CSS Test: @viewport constrained - width 20em");
+ window.onload = function(){
+
+ var testStyleSheet = document.styleSheets.item(1);
+
+ /* Disable the stylesheet that contains the @viewport to test. */
+ testStyleSheet.disabled = true;
+
+ /* Initialize an object to store viewport values to be used by the test
+ asserts. */
+ var viewport = new Object();
+
+ /* An element with the same size as the initial containing block. */
+ var testElm = document.getElementById("test");
+
+ /* Retrieve the initial viewport values before applying the @viewport to
+ test. */
+ viewport.initialWidth = testElm.offsetWidth;
+ viewport.initialHeight = testElm.offsetHeight;
+ viewport.fontSize = parseInt(getComputedStyle(testElm, "").fontSize);
+
+ /* Enable the stylesheet that contains the @viewport to test. */
+ testStyleSheet.disabled = false;
+
+ /* Retrieve the actual viewport values for the test. */
+ viewport.actualWidth = testElm.offsetWidth;
+ viewport.actualHeight = testElm.offsetHeight;
+ viewport.zoom = viewport.initialWidth / window.innerWidth;
+
+ /* Check viewport values. */
+ test.step(function(){
+ assert_equals(viewport.actualWidth, 20*viewport.fontSize);
+ });
+
+ /* Finished. Show the results. */
+ test.done();
+ testStyleSheet.disabled = true;
+ document.getElementById("log").style.display = "block";
+ }
+ ]]></script>
+ </head>
+ <body>
+ <div id="test">
+ <div id="log"></div>
+ </div>
+ </body>
+</html>
diff --git a/LayoutTests/css3/device-adapt/opera/constrain-010-expected.txt b/LayoutTests/css3/device-adapt/opera/constrain-010-expected.txt
new file mode 100644
index 0000000..413264a
--- /dev/null
+++ b/LayoutTests/css3/device-adapt/opera/constrain-010-expected.txt
@@ -0,0 +1,3 @@
+
+PASS CSS Test: @viewport constrained - width 20rem
+
diff --git a/LayoutTests/css3/device-adapt/opera/constrain-010.xhtml b/LayoutTests/css3/device-adapt/opera/constrain-010.xhtml
new file mode 100644
index 0000000..04802df
--- /dev/null
+++ b/LayoutTests/css3/device-adapt/opera/constrain-010.xhtml
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>CSS Test: @viewport constrained - width 20rem</title>
+ <link rel="author" title="Rune Lillesveen" href="mailto:rune@opera.com"/>
+ <link rel="help" href="http://www.w3.org/TR/css-device-adapt/#constraining-procedure"/>
+ <meta name="flags" content="visual scroll dom" />
+ <meta name="assert" content="Setting width in @viewport to 20rem will set the actual viewport width to 20 times the initial font-size."/>
+ <script src="../../../resources/testharness.js" type="text/javascript" />
+ <script src="../../../resources/testharnessreport.js" type="text/javascript" />
+ <style type="text/css"><![CDATA[
+ body { margin: 0; }
+ html, body, #test { width: 100%; height: 100%; }
+ #log { padding: 1em; display: none; }
+ /* Reset viewport values to initial values to ignore UA stylesheet. */
+ @-webkit-viewport {
+ width: auto;
+ height: auto;
+ zoom: auto;
+ min-zoom: auto;
+ max-zoom: auto;
+ user-zoom: zoom;
+ orientation: auto;
+ resolution: auto;
+ }
+ ]]></style>
+ <style type="text/css"><![CDATA[
+ /* CSS for the test below. */
+ @-webkit-viewport { width: 20rem }
+ /* Set root element font-size to something different from the initial
+ font-size to make sure 'rem' and 'em' for @viewport is based on the
+ initial font-size, not the root element font-size. */
+ html { font-size: 2rem; }
+ body { font-size: 0.5rem; }
+ ]]></style>
+ <script type="text/javascript"><![CDATA[
+ var test = async_test("CSS Test: @viewport constrained - width 20rem");
+ window.onload = function(){
+
+ var testStyleSheet = document.styleSheets.item(1);
+
+ /* Disable the stylesheet that contains the @viewport to test. */
+ testStyleSheet.disabled = true;
+
+ /* Initialize an object to store viewport values to be used by the test
+ asserts. */
+ var viewport = new Object();
+
+ /* An element with the same size as the initial containing block. */
+ var testElm = document.getElementById("test");
+
+ /* Retrieve the initial viewport values before applying the @viewport to
+ test. */
+ viewport.initialWidth = testElm.offsetWidth;
+ viewport.initialHeight = testElm.offsetHeight;
+ viewport.fontSize = parseInt(getComputedStyle(testElm, "").fontSize);
+
+ /* Enable the stylesheet that contains the @viewport to test. */
+ testStyleSheet.disabled = false;
+
+ /* Retrieve the actual viewport values for the test. */
+ viewport.actualWidth = testElm.offsetWidth;
+ viewport.actualHeight = testElm.offsetHeight;
+ viewport.zoom = viewport.initialWidth / window.innerWidth;
+
+ /* Check viewport values. */
+ test.step(function(){
+ assert_equals(viewport.actualWidth, 20*viewport.fontSize);
+ });
+
+ /* Finished. Show the results. */
+ test.done();
+ testStyleSheet.disabled = true;
+ document.getElementById("log").style.display = "block";
+ }
+ ]]></script>
+ </head>
+ <body>
+ <div id="test">
+ <div id="log"></div>
+ </div>
+ </body>
+</html>
diff --git a/LayoutTests/css3/device-adapt/opera/constrain-011-expected.txt b/LayoutTests/css3/device-adapt/opera/constrain-011-expected.txt
new file mode 100644
index 0000000..b79f73d
--- /dev/null
+++ b/LayoutTests/css3/device-adapt/opera/constrain-011-expected.txt
@@ -0,0 +1,3 @@
+
+PASS CSS Test: @viewport constrained - width from zoom: 200%
+
diff --git a/LayoutTests/css3/device-adapt/opera/constrain-011.xhtml b/LayoutTests/css3/device-adapt/opera/constrain-011.xhtml
new file mode 100644
index 0000000..326855c
--- /dev/null
+++ b/LayoutTests/css3/device-adapt/opera/constrain-011.xhtml
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>CSS Test: @viewport constrained - width from zoom: 200%</title>
+ <link rel="author" title="Rune Lillesveen" href="mailto:rune@opera.com"/>
+ <link rel="help" href="http://www.w3.org/TR/css-device-adapt/#constraining-procedure"/>
+ <meta name="flags" content="visual scroll dom" />
+ <meta name="assert" content="Setting zoom in @viewport to 200% will set the actual viewport width to half the initial-width."/>
+ <script src="../../../resources/testharness.js" type="text/javascript" />
+ <script src="../../../resources/testharnessreport.js" type="text/javascript" />
+ <style type="text/css"><![CDATA[
+ body { margin: 0; }
+ html, body, #test { width: 100%; height: 100%; }
+ #log { padding: 1em; display: none; }
+ /* Reset viewport values to initial values to ignore UA stylesheet. */
+ @-webkit-viewport {
+ width: auto;
+ height: auto;
+ zoom: auto;
+ min-zoom: auto;
+ max-zoom: auto;
+ user-zoom: zoom;
+ orientation: auto;
+ resolution: auto;
+ }
+ ]]></style>
+ <style type="text/css"><![CDATA[
+ /* CSS for the test below. */
+ @-webkit-viewport { zoom: 200% }
+ /* Set root element font-size to something different from the initial
+ font-size to make sure 'rem' and 'em' for @viewport is based on the
+ initial font-size, not the root element font-size. */
+ html { font-size: 2rem; }
+ body { font-size: 0.5rem; }
+ ]]></style>
+ <script type="text/javascript"><![CDATA[
+ var test = async_test("CSS Test: @viewport constrained - width from zoom: 200%");
+ window.onload = function(){
+
+ var testStyleSheet = document.styleSheets.item(1);
+
+ /* Disable the stylesheet that contains the @viewport to test. */
+ testStyleSheet.disabled = true;
+
+ /* Initialize an object to store viewport values to be used by the test
+ asserts. */
+ var viewport = new Object();
+
+ /* An element with the same size as the initial containing block. */
+ var testElm = document.getElementById("test");
+
+ /* Retrieve the initial viewport values before applying the @viewport to
+ test. */
+ viewport.initialWidth = testElm.offsetWidth;
+ viewport.initialHeight = testElm.offsetHeight;
+ viewport.fontSize = parseInt(getComputedStyle(testElm, "").fontSize);
+
+ /* Enable the stylesheet that contains the @viewport to test. */
+ testStyleSheet.disabled = false;
+
+ /* Retrieve the actual viewport values for the test. */
+ viewport.actualWidth = testElm.offsetWidth;
+ viewport.actualHeight = testElm.offsetHeight;
+ viewport.zoom = viewport.initialWidth / window.innerWidth;
+
+ /* Check viewport values. */
+ test.step(function(){
+ assert_equals(viewport.actualWidth, Math.floor(viewport.initialWidth/2));
+ });
+
+ /* Finished. Show the results. */
+ test.done();
+ testStyleSheet.disabled = true;
+ document.getElementById("log").style.display = "block";
+ }
+ ]]></script>
+ </head>
+ <body>
+ <div id="test">
+ <div id="log"></div>
+ </div>
+ </body>
+</html>
diff --git a/LayoutTests/css3/device-adapt/opera/constrain-012-expected.txt b/LayoutTests/css3/device-adapt/opera/constrain-012-expected.txt
new file mode 100644
index 0000000..7e5da2d
--- /dev/null
+++ b/LayoutTests/css3/device-adapt/opera/constrain-012-expected.txt
@@ -0,0 +1,3 @@
+
+PASS CSS Test: @viewport constrained - min-zoom not affecting width.
+
diff --git a/LayoutTests/css3/device-adapt/opera/constrain-012.xhtml b/LayoutTests/css3/device-adapt/opera/constrain-012.xhtml
new file mode 100644
index 0000000..8e34d3b
--- /dev/null
+++ b/LayoutTests/css3/device-adapt/opera/constrain-012.xhtml
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>CSS Test: @viewport constrained - min-zoom not affecting width.</title>
+ <link rel="author" title="Rune Lillesveen" href="mailto:rune@opera.com"/>
+ <link rel="help" href="http://www.w3.org/TR/css-device-adapt/#constraining-procedure"/>
+ <meta name="flags" content="visual scroll dom" />
+ <meta name="assert" content="Setting min-zoom in @viewport to 200% will not affect width if zoom is auto."/>
+ <script src="../../../resources/testharness.js" type="text/javascript" />
+ <script src="../../../resources/testharnessreport.js" type="text/javascript" />
+ <style type="text/css"><![CDATA[
+ body { margin: 0; }
+ html, body, #test { width: 100%; height: 100%; }
+ #log { padding: 1em; display: none; }
+ /* Reset viewport values to initial values to ignore UA stylesheet. */
+ @-webkit-viewport {
+ width: auto;
+ height: auto;
+ zoom: auto;
+ min-zoom: auto;
+ max-zoom: auto;
+ user-zoom: zoom;
+ orientation: auto;
+ resolution: auto;
+ }
+ ]]></style>
+ <style type="text/css"><![CDATA[
+ /* CSS for the test below. */
+ @-webkit-viewport { min-zoom: 200% }
+ /* Set root element font-size to something different from the initial
+ font-size to make sure 'rem' and 'em' for @viewport is based on the
+ initial font-size, not the root element font-size. */
+ html { font-size: 2rem; }
+ body { font-size: 0.5rem; }
+ ]]></style>
+ <script type="text/javascript"><![CDATA[
+ var test = async_test("CSS Test: @viewport constrained - min-zoom not affecting width.");
+ window.onload = function(){
+
+ var testStyleSheet = document.styleSheets.item(1);
+
+ /* Disable the stylesheet that contains the @viewport to test. */
+ testStyleSheet.disabled = true;
+
+ /* Initialize an object to store viewport values to be used by the test
+ asserts. */
+ var viewport = new Object();
+
+ /* An element with the same size as the initial containing block. */
+ var testElm = document.getElementById("test");
+
+ /* Retrieve the initial viewport values before applying the @viewport to
+ test. */
+ viewport.initialWidth = testElm.offsetWidth;
+ viewport.initialHeight = testElm.offsetHeight;
+ viewport.fontSize = parseInt(getComputedStyle(testElm, "").fontSize);
+
+ /* Enable the stylesheet that contains the @viewport to test. */
+ testStyleSheet.disabled = false;
+
+ /* Retrieve the actual viewport values for the test. */
+ viewport.actualWidth = testElm.offsetWidth;
+ viewport.actualHeight = testElm.offsetHeight;
+ viewport.zoom = viewport.initialWidth / window.innerWidth;
+
+ /* Check viewport values. */
+ test.step(function(){
+ assert_equals(viewport.actualWidth, viewport.initialWidth);
+ });
+
+ /* Finished. Show the results. */
+ test.done();
+ testStyleSheet.disabled = true;
+ document.getElementById("log").style.display = "block";
+ }
+ ]]></script>
+ </head>
+ <body>
+ <div id="test">
+ <div id="log"></div>
+ </div>
+ </body>
+</html>
diff --git a/LayoutTests/css3/device-adapt/opera/constrain-013-expected.txt b/LayoutTests/css3/device-adapt/opera/constrain-013-expected.txt
new file mode 100644
index 0000000..881ca04
--- /dev/null
+++ b/LayoutTests/css3/device-adapt/opera/constrain-013-expected.txt
@@ -0,0 +1,3 @@
+
+PASS CSS Test: @viewport constrained - max-zoom affecting width.
+
diff --git a/LayoutTests/css3/device-adapt/opera/constrain-013.xhtml b/LayoutTests/css3/device-adapt/opera/constrain-013.xhtml
new file mode 100644
index 0000000..f6bedb7
--- /dev/null
+++ b/LayoutTests/css3/device-adapt/opera/constrain-013.xhtml
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>CSS Test: @viewport constrained - max-zoom affecting width.</title>
+ <link rel="author" title="Rune Lillesveen" href="mailto:rune@opera.com"/>
+ <link rel="help" href="http://www.w3.org/TR/css-device-adapt/#constraining-procedure"/>
+ <meta name="flags" content="visual scroll dom" />
+ <meta name="assert" content="Setting max-zoom in @viewport to 50% affect width if zoom is auto because of step 10 in the constraining procedure."/>
+ <script src="../../../resources/testharness.js" type="text/javascript" />
+ <script src="../../../resources/testharnessreport.js" type="text/javascript" />
+ <style type="text/css"><![CDATA[
+ body { margin: 0; }
+ html, body, #test { width: 100%; height: 100%; }
+ #log { padding: 1em; display: none; }
+ /* Reset viewport values to initial values to ignore UA stylesheet. */
+ @-webkit-viewport {
+ width: auto;
+ height: auto;
+ zoom: auto;
+ min-zoom: auto;
+ max-zoom: auto;
+ user-zoom: zoom;
+ orientation: auto;
+ resolution: auto;
+ }
+ ]]></style>
+ <style type="text/css"><![CDATA[
+ /* CSS for the test below. */
+ @-webkit-viewport { max-zoom: 50% }
+ /* Set root element font-size to something different from the initial
+ font-size to make sure 'rem' and 'em' for @viewport is based on the
+ initial font-size, not the root element font-size. */
+ html { font-size: 2rem; }
+ body { font-size: 0.5rem; }
+ ]]></style>
+ <script type="text/javascript"><![CDATA[
+ var test = async_test("CSS Test: @viewport constrained - max-zoom affecting width.");
+ window.onload = function(){
+
+ var testStyleSheet = document.styleSheets.item(1);
+
+ /* Disable the stylesheet that contains the @viewport to test. */
+ testStyleSheet.disabled = true;
+
+ /* Initialize an object to store viewport values to be used by the test
+ asserts. */
+ var viewport = new Object();
+
+ /* An element with the same size as the initial containing block. */
+ var testElm = document.getElementById("test");
+
+ /* Retrieve the initial viewport values before applying the @viewport to
+ test. */
+ viewport.initialWidth = testElm.offsetWidth;
+ viewport.initialHeight = testElm.offsetHeight;
+ viewport.fontSize = parseInt(getComputedStyle(testElm, "").fontSize);
+
+ /* Enable the stylesheet that contains the @viewport to test. */
+ testStyleSheet.disabled = false;
+
+ /* Retrieve the actual viewport values for the test. */
+ viewport.actualWidth = testElm.offsetWidth;
+ viewport.actualHeight = testElm.offsetHeight;
+ viewport.zoom = viewport.initialWidth / window.innerWidth;
+
+ /* Check viewport values. */
+ test.step(function(){
+ assert_equals(viewport.actualWidth, 2*viewport.initialWidth);
+ });
+
+ /* Finished. Show the results. */
+ test.done();
+ testStyleSheet.disabled = true;
+ document.getElementById("log").style.display = "block";
+ }
+ ]]></script>
+ </head>
+ <body>
+ <div id="test">
+ <div id="log"></div>
+ </div>
+ </body>
+</html>
diff --git a/LayoutTests/css3/device-adapt/opera/constrain-014-expected.txt b/LayoutTests/css3/device-adapt/opera/constrain-014-expected.txt
new file mode 100644
index 0000000..f7880c3
--- /dev/null
+++ b/LayoutTests/css3/device-adapt/opera/constrain-014-expected.txt
@@ -0,0 +1,3 @@
+
+PASS CSS Test: @viewport constrained - zoom greater than max-zoom.
+
diff --git a/LayoutTests/css3/device-adapt/opera/constrain-014.xhtml b/LayoutTests/css3/device-adapt/opera/constrain-014.xhtml
new file mode 100644
index 0000000..1232cc5
--- /dev/null
+++ b/LayoutTests/css3/device-adapt/opera/constrain-014.xhtml
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>CSS Test: @viewport constrained - zoom greater than max-zoom.</title>
+ <link rel="author" title="Rune Lillesveen" href="mailto:rune@opera.com"/>
+ <link rel="help" href="http://www.w3.org/TR/css-device-adapt/#constraining-procedure"/>
+ <meta name="flags" content="visual scroll dom" />
+ <meta name="assert" content="Setting zoom greater than max-zoom will set zoom to max-zoom."/>
+ <script src="../../../resources/testharness.js" type="text/javascript" />
+ <script src="../../../resources/testharnessreport.js" type="text/javascript" />
+ <style type="text/css"><![CDATA[
+ body { margin: 0; }
+ html, body, #test { width: 100%; height: 100%; }
+ #log { padding: 1em; display: none; }
+ /* Reset viewport values to initial values to ignore UA stylesheet. */
+ @-webkit-viewport {
+ width: auto;
+ height: auto;
+ zoom: auto;
+ min-zoom: auto;
+ max-zoom: auto;
+ user-zoom: zoom;
+ orientation: auto;
+ resolution: auto;
+ }
+ ]]></style>
+ <style type="text/css"><![CDATA[
+ /* CSS for the test below. */
+ @-webkit-viewport { max-zoom: 50%; zoom: 150% }
+ /* Set root element font-size to something different from the initial
+ font-size to make sure 'rem' and 'em' for @viewport is based on the
+ initial font-size, not the root element font-size. */
+ html { font-size: 2rem; }
+ body { font-size: 0.5rem; }
+ ]]></style>
+ <script type="text/javascript"><![CDATA[
+ var test = async_test("CSS Test: @viewport constrained - zoom greater than max-zoom.");
+ window.onload = function(){
+
+ var testStyleSheet = document.styleSheets.item(1);
+
+ /* Disable the stylesheet that contains the @viewport to test. */
+ testStyleSheet.disabled = true;
+
+ /* Initialize an object to store viewport values to be used by the test
+ asserts. */
+ var viewport = new Object();
+
+ /* An element with the same size as the initial containing block. */
+ var testElm = document.getElementById("test");
+
+ /* Retrieve the initial viewport values before applying the @viewport to
+ test. */
+ viewport.initialWidth = testElm.offsetWidth;
+ viewport.initialHeight = testElm.offsetHeight;
+ viewport.fontSize = parseInt(getComputedStyle(testElm, "").fontSize);
+
+ /* Enable the stylesheet that contains the @viewport to test. */
+ testStyleSheet.disabled = false;
+
+ /* Retrieve the actual viewport values for the test. */
+ viewport.actualWidth = testElm.offsetWidth;
+ viewport.actualHeight = testElm.offsetHeight;
+ viewport.zoom = viewport.initialWidth / window.innerWidth;
+
+ /* Check viewport values. */
+ test.step(function(){
+ assert_equals(viewport.actualWidth, 2*viewport.initialWidth);
+ });
+
+ /* Finished. Show the results. */
+ test.done();
+ testStyleSheet.disabled = true;
+ document.getElementById("log").style.display = "block";
+ }
+ ]]></script>
+ </head>
+ <body>
+ <div id="test">
+ <div id="log"></div>
+ </div>
+ </body>
+</html>
diff --git a/LayoutTests/css3/device-adapt/opera/constrain-015-expected.txt b/LayoutTests/css3/device-adapt/opera/constrain-015-expected.txt
new file mode 100644
index 0000000..03269e2
--- /dev/null
+++ b/LayoutTests/css3/device-adapt/opera/constrain-015-expected.txt
@@ -0,0 +1,3 @@
+
+PASS CSS Test: @viewport constrained - zoom less than min-zoom.
+
diff --git a/LayoutTests/css3/device-adapt/opera/constrain-015.xhtml b/LayoutTests/css3/device-adapt/opera/constrain-015.xhtml
new file mode 100644
index 0000000..613b1dc
--- /dev/null
+++ b/LayoutTests/css3/device-adapt/opera/constrain-015.xhtml
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>CSS Test: @viewport constrained - zoom less than min-zoom.</title>
+ <link rel="author" title="Rune Lillesveen" href="mailto:rune@opera.com"/>
+ <link rel="help" href="http://www.w3.org/TR/css-device-adapt/#constraining-procedure"/>
+ <meta name="flags" content="visual scroll dom" />
+ <meta name="assert" content="Setting zoom less than min-zoom will set zoom to min-zoom."/>
+ <script src="../../../resources/testharness.js" type="text/javascript" />
+ <script src="../../../resources/testharnessreport.js" type="text/javascript" />
+ <style type="text/css"><![CDATA[
+ body { margin: 0; }
+ html, body, #test { width: 100%; height: 100%; }
+ #log { padding: 1em; display: none; }
+ /* Reset viewport values to initial values to ignore UA stylesheet. */
+ @-webkit-viewport {
+ width: auto;
+ height: auto;
+ zoom: auto;
+ min-zoom: auto;
+ max-zoom: auto;
+ user-zoom: zoom;
+ orientation: auto;
+ resolution: auto;
+ }
+ ]]></style>
+ <style type="text/css"><![CDATA[
+ /* CSS for the test below. */
+ @-webkit-viewport { min-zoom: 200%; zoom: 50% }
+ /* Set root element font-size to something different from the initial
+ font-size to make sure 'rem' and 'em' for @viewport is based on the
+ initial font-size, not the root element font-size. */
+ html { font-size: 2rem; }
+ body { font-size: 0.5rem; }
+ ]]></style>
+ <script type="text/javascript"><![CDATA[
+ var test = async_test("CSS Test: @viewport constrained - zoom less than min-zoom.");
+ window.onload = function(){
+
+ var testStyleSheet = document.styleSheets.item(1);
+
+ /* Disable the stylesheet that contains the @viewport to test. */
+ testStyleSheet.disabled = true;
+
+ /* Initialize an object to store viewport values to be used by the test
+ asserts. */
+ var viewport = new Object();
+
+ /* An element with the same size as the initial containing block. */
+ var testElm = document.getElementById("test");
+
+ /* Retrieve the initial viewport values before applying the @viewport to
+ test. */
+ viewport.initialWidth = testElm.offsetWidth;
+ viewport.initialHeight = testElm.offsetHeight;
+ viewport.fontSize = parseInt(getComputedStyle(testElm, "").fontSize);
+
+ /* Enable the stylesheet that contains the @viewport to test. */
+ testStyleSheet.disabled = false;
+
+ /* Retrieve the actual viewport values for the test. */
+ viewport.actualWidth = testElm.offsetWidth;
+ viewport.actualHeight = testElm.offsetHeight;
+ viewport.zoom = viewport.initialWidth / window.innerWidth;
+
+ /* Check viewport values. */
+ test.step(function(){
+ assert_equals(viewport.actualWidth, Math.floor(viewport.initialWidth/2));
+ });
+
+ /* Finished. Show the results. */
+ test.done();
+ testStyleSheet.disabled = true;
+ document.getElementById("log").style.display = "block";
+ }
+ ]]></script>
+ </head>
+ <body>
+ <div id="test">
+ <div id="log"></div>
+ </div>
+ </body>
+</html>
diff --git a/LayoutTests/css3/device-adapt/opera/constrain-016-expected.txt b/LayoutTests/css3/device-adapt/opera/constrain-016-expected.txt
new file mode 100644
index 0000000..a41c4b8
--- /dev/null
+++ b/LayoutTests/css3/device-adapt/opera/constrain-016-expected.txt
@@ -0,0 +1,3 @@
+
+PASS CSS Test: @viewport constrained - height deduced from width and aspect ratio.
+
diff --git a/LayoutTests/css3/device-adapt/opera/constrain-016.xhtml b/LayoutTests/css3/device-adapt/opera/constrain-016.xhtml
new file mode 100644
index 0000000..7f52396
--- /dev/null
+++ b/LayoutTests/css3/device-adapt/opera/constrain-016.xhtml
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>CSS Test: @viewport constrained - height deduced from width and aspect ratio.</title>
+ <link rel="author" title="Rune Lillesveen" href="mailto:rune@opera.com"/>
+ <link rel="help" href="http://www.w3.org/TR/css-device-adapt/#constraining-procedure"/>
+ <meta name="flags" content="visual scroll dom" />
+ <meta name="assert" content="Setting width and not height will set a height that makes the actual width/height and initial width/height have the same aspect ratio."/>
+ <script src="../../../resources/testharness.js" type="text/javascript" />
+ <script src="../../../resources/testharnessreport.js" type="text/javascript" />
+ <style type="text/css"><![CDATA[
+ body { margin: 0; }
+ html, body, #test { width: 100%; height: 100%; }
+ #log { padding: 1em; display: none; }
+ /* Reset viewport values to initial values to ignore UA stylesheet. */
+ @-webkit-viewport {
+ width: auto;
+ height: auto;
+ zoom: auto;
+ min-zoom: auto;
+ max-zoom: auto;
+ user-zoom: zoom;
+ orientation: auto;
+ resolution: auto;
+ }
+ ]]></style>
+ <style type="text/css"><![CDATA[
+ /* CSS for the test below. */
+ @-webkit-viewport { width: 10000px }
+ /* Set root element font-size to something different from the initial
+ font-size to make sure 'rem' and 'em' for @viewport is based on the
+ initial font-size, not the root element font-size. */
+ html { font-size: 2rem; }
+ body { font-size: 0.5rem; }
+ ]]></style>
+ <script type="text/javascript"><![CDATA[
+ var test = async_test("CSS Test: @viewport constrained - height deduced from width and aspect ratio.");
+ window.onload = function(){
+
+ var testStyleSheet = document.styleSheets.item(1);
+
+ /* Disable the stylesheet that contains the @viewport to test. */
+ testStyleSheet.disabled = true;
+
+ /* Initialize an object to store viewport values to be used by the test
+ asserts. */
+ var viewport = new Object();
+
+ /* An element with the same size as the initial containing block. */
+ var testElm = document.getElementById("test");
+
+ /* Retrieve the initial viewport values before applying the @viewport to
+ test. */
+ viewport.initialWidth = testElm.offsetWidth;
+ viewport.initialHeight = testElm.offsetHeight;
+ viewport.fontSize = parseInt(getComputedStyle(testElm, "").fontSize);
+
+ /* Enable the stylesheet that contains the @viewport to test. */
+ testStyleSheet.disabled = false;
+
+ /* Retrieve the actual viewport values for the test. */
+ viewport.actualWidth = testElm.offsetWidth;
+ viewport.actualHeight = testElm.offsetHeight;
+ viewport.zoom = viewport.initialWidth / window.innerWidth;
+
+ /* Check viewport values. */
+ test.step(function(){
+ assert_equals(viewport.actualWidth, 10000); assert_equals(viewport.actualHeight, Math.floor(10000*viewport.initialHeight/viewport.initialWidth));
+ });
+
+ /* Finished. Show the results. */
+ test.done();
+ testStyleSheet.disabled = true;
+ document.getElementById("log").style.display = "block";
+ }
+ ]]></script>
+ </head>
+ <body>
+ <div id="test">
+ <div id="log"></div>
+ </div>
+ </body>
+</html>
diff --git a/LayoutTests/css3/device-adapt/opera/constrain-017-expected.txt b/LayoutTests/css3/device-adapt/opera/constrain-017-expected.txt
new file mode 100644
index 0000000..3f6d08f
--- /dev/null
+++ b/LayoutTests/css3/device-adapt/opera/constrain-017-expected.txt
@@ -0,0 +1,3 @@
+
+PASS CSS Test: @viewport constrained - Large non-auto height not affecting width.
+
diff --git a/LayoutTests/css3/device-adapt/opera/constrain-017.xhtml b/LayoutTests/css3/device-adapt/opera/constrain-017.xhtml
new file mode 100644
index 0000000..7290995
--- /dev/null
+++ b/LayoutTests/css3/device-adapt/opera/constrain-017.xhtml
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>CSS Test: @viewport constrained - Large non-auto height not affecting width.</title>
+ <link rel="author" title="Rune Lillesveen" href="mailto:rune@opera.com"/>
+ <link rel="help" href="http://www.w3.org/TR/css-device-adapt/#constraining-procedure"/>
+ <meta name="flags" content="visual scroll dom" />
+ <meta name="assert" content="Non-auto height does not affect width if zoom is auto."/>
+ <script src="../../../resources/testharness.js" type="text/javascript" />
+ <script src="../../../resources/testharnessreport.js" type="text/javascript" />
+ <style type="text/css"><![CDATA[
+ body { margin: 0; }
+ html, body, #test { width: 100%; height: 100%; }
+ #log { padding: 1em; display: none; }
+ /* Reset viewport values to initial values to ignore UA stylesheet. */
+ @-webkit-viewport {
+ width: auto;
+ height: auto;
+ zoom: auto;
+ min-zoom: auto;
+ max-zoom: auto;
+ user-zoom: zoom;
+ orientation: auto;
+ resolution: auto;
+ }
+ ]]></style>
+ <style type="text/css"><![CDATA[
+ /* CSS for the test below. */
+ @-webkit-viewport { height: 10000px }
+ /* Set root element font-size to something different from the initial
+ font-size to make sure 'rem' and 'em' for @viewport is based on the
+ initial font-size, not the root element font-size. */
+ html { font-size: 2rem; }
+ body { font-size: 0.5rem; }
+ ]]></style>
+ <script type="text/javascript"><![CDATA[
+ var test = async_test("CSS Test: @viewport constrained - Large non-auto height not affecting width.");
+ window.onload = function(){
+
+ var testStyleSheet = document.styleSheets.item(1);
+
+ /* Disable the stylesheet that contains the @viewport to test. */
+ testStyleSheet.disabled = true;
+
+ /* Initialize an object to store viewport values to be used by the test
+ asserts. */
+ var viewport = new Object();
+
+ /* An element with the same size as the initial containing block. */
+ var testElm = document.getElementById("test");
+
+ /* Retrieve the initial viewport values before applying the @viewport to
+ test. */
+ viewport.initialWidth = testElm.offsetWidth;
+ viewport.initialHeight = testElm.offsetHeight;
+ viewport.fontSize = parseInt(getComputedStyle(testElm, "").fontSize);
+
+ /* Enable the stylesheet that contains the @viewport to test. */
+ testStyleSheet.disabled = false;
+
+ /* Retrieve the actual viewport values for the test. */
+ viewport.actualWidth = testElm.offsetWidth;
+ viewport.actualHeight = testElm.offsetHeight;
+ viewport.zoom = viewport.initialWidth / window.innerWidth;
+
+ /* Check viewport values. */
+ test.step(function(){
+ assert_equals(viewport.actualHeight, 10000); assert_equals(viewport.actualWidth, viewport.initialWidth);
+ });
+
+ /* Finished. Show the results. */
+ test.done();
+ testStyleSheet.disabled = true;
+ document.getElementById("log").style.display = "block";
+ }
+ ]]></script>
+ </head>
+ <body>
+ <div id="test">
+ <div id="log"></div>
+ </div>
+ </body>
+</html>
diff --git a/LayoutTests/css3/device-adapt/opera/constrain-020-expected.txt b/LayoutTests/css3/device-adapt/opera/constrain-020-expected.txt
new file mode 100644
index 0000000..5d35f2f
--- /dev/null
+++ b/LayoutTests/css3/device-adapt/opera/constrain-020-expected.txt
@@ -0,0 +1,3 @@
+
+PASS CSS Test: @viewport constrained - extended width and height for non-auto zoom.
+
diff --git a/LayoutTests/css3/device-adapt/opera/constrain-020.xhtml b/LayoutTests/css3/device-adapt/opera/constrain-020.xhtml
new file mode 100644
index 0000000..a4971a7
--- /dev/null
+++ b/LayoutTests/css3/device-adapt/opera/constrain-020.xhtml
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>CSS Test: @viewport constrained - extended width and height for non-auto zoom.</title>
+ <link rel="author" title="Rune Lillesveen" href="mailto:rune@opera.com"/>
+ <link rel="help" href="http://www.w3.org/TR/css-device-adapt/#constraining-procedure"/>
+ <meta name="flags" content="visual scroll dom" />
+ <meta name="assert" content="When zoom is non-auto, and the constrained width does not fill the viewport for the constrained zoom value, the width is extended to fill the viewport. Likewise for height."/>
+ <script src="../../../resources/testharness.js" type="text/javascript" />
+ <script src="../../../resources/testharnessreport.js" type="text/javascript" />
+ <style type="text/css"><![CDATA[
+ body { margin: 0; }
+ html, body, #test { width: 100%; height: 100%; }
+ #log { padding: 1em; display: none; }
+ /* Reset viewport values to initial values to ignore UA stylesheet. */
+ @-webkit-viewport {
+ width: auto;
+ height: auto;
+ zoom: auto;
+ min-zoom: auto;
+ max-zoom: auto;
+ user-zoom: zoom;
+ orientation: auto;
+ resolution: auto;
+ }
+ ]]></style>
+ <style type="text/css"><![CDATA[
+ /* CSS for the test below. */
+ @-webkit-viewport { width: 1px; height: 1px; zoom: 50% }
+ /* Set root element font-size to something different from the initial
+ font-size to make sure 'rem' and 'em' for @viewport is based on the
+ initial font-size, not the root element font-size. */
+ html { font-size: 2rem; }
+ body { font-size: 0.5rem; }
+ ]]></style>
+ <script type="text/javascript"><![CDATA[
+ var test = async_test("CSS Test: @viewport constrained - extended width and height for non-auto zoom.");
+ window.onload = function(){
+
+ var testStyleSheet = document.styleSheets.item(1);
+
+ /* Disable the stylesheet that contains the @viewport to test. */
+ testStyleSheet.disabled = true;
+
+ /* Initialize an object to store viewport values to be used by the test
+ asserts. */
+ var viewport = new Object();
+
+ /* An element with the same size as the initial containing block. */
+ var testElm = document.getElementById("test");
+
+ /* Retrieve the initial viewport values before applying the @viewport to
+ test. */
+ viewport.initialWidth = testElm.offsetWidth;
+ viewport.initialHeight = testElm.offsetHeight;
+ viewport.fontSize = parseInt(getComputedStyle(testElm, "").fontSize);
+
+ /* Enable the stylesheet that contains the @viewport to test. */
+ testStyleSheet.disabled = false;
+
+ /* Retrieve the actual viewport values for the test. */
+ viewport.actualWidth = testElm.offsetWidth;
+ viewport.actualHeight = testElm.offsetHeight;
+ viewport.zoom = viewport.initialWidth / window.innerWidth;
+
+ /* Check viewport values. */
+ test.step(function(){
+ assert_equals(viewport.actualWidth, 2*viewport.initialWidth); assert_approx_equals(viewport.actualHeight, 2*viewport.initialHeight, 1);
+ });
+
+ /* Finished. Show the results. */
+ test.done();
+ testStyleSheet.disabled = true;
+ document.getElementById("log").style.display = "block";
+ }
+ ]]></script>
+ </head>
+ <body>
+ <div id="test">
+ <div id="log"></div>
+ </div>
+ </body>
+</html>
diff --git a/LayoutTests/css3/device-adapt/opera/syntax-001-expected.txt b/LayoutTests/css3/device-adapt/opera/syntax-001-expected.txt
new file mode 100644
index 0000000..dd06909
--- /dev/null
+++ b/LayoutTests/css3/device-adapt/opera/syntax-001-expected.txt
@@ -0,0 +1,3 @@
+
+PASS CSS Test: @viewport syntax - inside @media
+
diff --git a/LayoutTests/css3/device-adapt/opera/syntax-001.xhtml b/LayoutTests/css3/device-adapt/opera/syntax-001.xhtml
new file mode 100644
index 0000000..1b626cb
--- /dev/null
+++ b/LayoutTests/css3/device-adapt/opera/syntax-001.xhtml
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>CSS Test: @viewport syntax - inside @media</title>
+ <link rel="author" title="Rune Lillesveen" href="mailto:rune@opera.com"/>
+ <link rel="help" href="http://www.w3.org/TR/css-device-adapt/#syntax"/>
+ <meta name="flags" content="visual scroll dom" />
+ <meta name="assert" content="@viewport is allowed inside @media."/>
+ <script src="../../../resources/testharness.js" type="text/javascript" />
+ <script src="../../../resources/testharnessreport.js" type="text/javascript" />
+ <style type="text/css"><![CDATA[
+ body { margin: 0; }
+ html, body, #test { width: 100%; height: 100%; }
+ #log { padding: 1em; display: none; }
+ /* Reset viewport values to initial values to ignore UA stylesheet. */
+ @-webkit-viewport {
+ width: auto;
+ height: auto;
+ zoom: auto;
+ min-zoom: auto;
+ max-zoom: auto;
+ user-zoom: zoom;
+ orientation: auto;
+ resolution: auto;
+ }
+ ]]></style>
+ <style type="text/css"><![CDATA[
+ /* CSS for the test below. */
+ @media all { @-webkit-viewport { width: 500px; } }
+ /* Set root element font-size to something different from the initial
+ font-size to make sure 'rem' and 'em' for @viewport is based on the
+ initial font-size, not the root element font-size. */
+ html { font-size: 2rem; }
+ body { font-size: 0.5rem; }
+ ]]></style>
+ <script type="text/javascript"><![CDATA[
+ var test = async_test("CSS Test: @viewport syntax - inside @media");
+ window.onload = function(){
+
+ var testStyleSheet = document.styleSheets.item(1);
+
+ /* Disable the stylesheet that contains the @viewport to test. */
+ testStyleSheet.disabled = true;
+
+ /* Initialize an object to store viewport values to be used by the test
+ asserts. */
+ var viewport = new Object();
+
+ /* An element with the same size as the initial containing block. */
+ var testElm = document.getElementById("test");
+
+ /* Retrieve the initial viewport values before applying the @viewport to
+ test. */
+ viewport.initialWidth = testElm.offsetWidth;
+ viewport.initialHeight = testElm.offsetHeight;
+ viewport.fontSize = parseInt(getComputedStyle(testElm, "").fontSize);
+
+ /* Enable the stylesheet that contains the @viewport to test. */
+ testStyleSheet.disabled = false;
+
+ /* Retrieve the actual viewport values for the test. */
+ viewport.actualWidth = testElm.offsetWidth;
+ viewport.actualHeight = testElm.offsetHeight;
+ viewport.zoom = viewport.initialWidth / window.innerWidth;
+
+ /* Check viewport values. */
+ test.step(function(){
+ assert_equals(viewport.actualWidth, 500);
+ });
+
+ /* Finished. Show the results. */
+ test.done();
+ testStyleSheet.disabled = true;
+ document.getElementById("log").style.display = "block";
+ }
+ ]]></script>
+ </head>
+ <body>
+ <div id="test">
+ <div id="log"></div>
+ </div>
+ </body>
+</html>
diff --git a/LayoutTests/css3/device-adapt/opera/syntax-002-expected.txt b/LayoutTests/css3/device-adapt/opera/syntax-002-expected.txt
new file mode 100644
index 0000000..b34fcbd
--- /dev/null
+++ b/LayoutTests/css3/device-adapt/opera/syntax-002-expected.txt
@@ -0,0 +1,3 @@
+
+PASS CSS Test: @viewport syntax - unknown descriptor
+
diff --git a/LayoutTests/css3/device-adapt/opera/syntax-002.xhtml b/LayoutTests/css3/device-adapt/opera/syntax-002.xhtml
new file mode 100644
index 0000000..4e0dc2b
--- /dev/null
+++ b/LayoutTests/css3/device-adapt/opera/syntax-002.xhtml
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>CSS Test: @viewport syntax - unknown descriptor</title>
+ <link rel="author" title="Rune Lillesveen" href="mailto:rune@opera.com"/>
+ <link rel="help" href="http://www.w3.org/TR/css-device-adapt/#syntax"/>
+ <meta name="flags" content="visual scroll dom invalid" />
+ <meta name="assert" content="Descriptors after unknown descriptor declaration in @viewport is recognized."/>
+ <script src="../../../resources/testharness.js" type="text/javascript" />
+ <script src="../../../resources/testharnessreport.js" type="text/javascript" />
+ <style type="text/css"><![CDATA[
+ body { margin: 0; }
+ html, body, #test { width: 100%; height: 100%; }
+ #log { padding: 1em; display: none; }
+ /* Reset viewport values to initial values to ignore UA stylesheet. */
+ @-webkit-viewport {
+ width: auto;
+ height: auto;
+ zoom: auto;
+ min-zoom: auto;
+ max-zoom: auto;
+ user-zoom: zoom;
+ orientation: auto;
+ resolution: auto;
+ }
+ ]]></style>
+ <style type="text/css"><![CDATA[
+ /* CSS for the test below. */
+ @-webkit-viewport { a: b; width: 500px }
+ /* Set root element font-size to something different from the initial
+ font-size to make sure 'rem' and 'em' for @viewport is based on the
+ initial font-size, not the root element font-size. */
+ html { font-size: 2rem; }
+ body { font-size: 0.5rem; }
+ ]]></style>
+ <script type="text/javascript"><![CDATA[
+ var test = async_test("CSS Test: @viewport syntax - unknown descriptor");
+ window.onload = function(){
+
+ var testStyleSheet = document.styleSheets.item(1);
+
+ /* Disable the stylesheet that contains the @viewport to test. */
+ testStyleSheet.disabled = true;
+
+ /* Initialize an object to store viewport values to be used by the test
+ asserts. */
+ var viewport = new Object();
+
+ /* An element with the same size as the initial containing block. */
+ var testElm = document.getElementById("test");
+
+ /* Retrieve the initial viewport values before applying the @viewport to
+ test. */
+ viewport.initialWidth = testElm.offsetWidth;
+ viewport.initialHeight = testElm.offsetHeight;
+ viewport.fontSize = parseInt(getComputedStyle(testElm, "").fontSize);
+
+ /* Enable the stylesheet that contains the @viewport to test. */
+ testStyleSheet.disabled = false;
+
+ /* Retrieve the actual viewport values for the test. */
+ viewport.actualWidth = testElm.offsetWidth;
+ viewport.actualHeight = testElm.offsetHeight;
+ viewport.zoom = viewport.initialWidth / window.innerWidth;
+
+ /* Check viewport values. */
+ test.step(function(){
+ assert_equals(viewport.actualWidth, 500);
+ });
+
+ /* Finished. Show the results. */
+ test.done();
+ testStyleSheet.disabled = true;
+ document.getElementById("log").style.display = "block";
+ }
+ ]]></script>
+ </head>
+ <body>
+ <div id="test">
+ <div id="log"></div>
+ </div>
+ </body>
+</html>
diff --git a/LayoutTests/css3/device-adapt/opera/syntax-003-expected.txt b/LayoutTests/css3/device-adapt/opera/syntax-003-expected.txt
new file mode 100644
index 0000000..4e8e35e
--- /dev/null
+++ b/LayoutTests/css3/device-adapt/opera/syntax-003-expected.txt
@@ -0,0 +1,3 @@
+
+PASS CSS Test: @viewport syntax - descriptor recovery
+
diff --git a/LayoutTests/css3/device-adapt/opera/syntax-003.xhtml b/LayoutTests/css3/device-adapt/opera/syntax-003.xhtml
new file mode 100644
index 0000000..f7f1d2a
--- /dev/null
+++ b/LayoutTests/css3/device-adapt/opera/syntax-003.xhtml
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>CSS Test: @viewport syntax - descriptor recovery</title>
+ <link rel="author" title="Rune Lillesveen" href="mailto:rune@opera.com"/>
+ <link rel="help" href="http://www.w3.org/TR/css-device-adapt/#syntax"/>
+ <meta name="flags" content="visual scroll dom invalid" />
+ <meta name="assert" content="@viewport supports forward compatible parsing for descriptors."/>
+ <script src="../../../resources/testharness.js" type="text/javascript" />
+ <script src="../../../resources/testharnessreport.js" type="text/javascript" />
+ <style type="text/css"><![CDATA[
+ body { margin: 0; }
+ html, body, #test { width: 100%; height: 100%; }
+ #log { padding: 1em; display: none; }
+ /* Reset viewport values to initial values to ignore UA stylesheet. */
+ @-webkit-viewport {
+ width: auto;
+ height: auto;
+ zoom: auto;
+ min-zoom: auto;
+ max-zoom: auto;
+ user-zoom: zoom;
+ orientation: auto;
+ resolution: auto;
+ }
+ ]]></style>
+ <style type="text/css"><![CDATA[
+ /* CSS for the test below. */
+ @-webkit-viewport { width: 500px; width: 200px x: { !important []}; height: 700px }
+ /* Set root element font-size to something different from the initial
+ font-size to make sure 'rem' and 'em' for @viewport is based on the
+ initial font-size, not the root element font-size. */
+ html { font-size: 2rem; }
+ body { font-size: 0.5rem; }
+ ]]></style>
+ <script type="text/javascript"><![CDATA[
+ var test = async_test("CSS Test: @viewport syntax - descriptor recovery");
+ window.onload = function(){
+
+ var testStyleSheet = document.styleSheets.item(1);
+
+ /* Disable the stylesheet that contains the @viewport to test. */
+ testStyleSheet.disabled = true;
+
+ /* Initialize an object to store viewport values to be used by the test
+ asserts. */
+ var viewport = new Object();
+
+ /* An element with the same size as the initial containing block. */
+ var testElm = document.getElementById("test");
+
+ /* Retrieve the initial viewport values before applying the @viewport to
+ test. */
+ viewport.initialWidth = testElm.offsetWidth;
+ viewport.initialHeight = testElm.offsetHeight;
+ viewport.fontSize = parseInt(getComputedStyle(testElm, "").fontSize);
+
+ /* Enable the stylesheet that contains the @viewport to test. */
+ testStyleSheet.disabled = false;
+
+ /* Retrieve the actual viewport values for the test. */
+ viewport.actualWidth = testElm.offsetWidth;
+ viewport.actualHeight = testElm.offsetHeight;
+ viewport.zoom = viewport.initialWidth / window.innerWidth;
+
+ /* Check viewport values. */
+ test.step(function(){
+ assert_equals(viewport.actualWidth, 500); assert_equals(viewport.actualHeight, 700);
+ });
+
+ /* Finished. Show the results. */
+ test.done();
+ testStyleSheet.disabled = true;
+ document.getElementById("log").style.display = "block";
+ }
+ ]]></script>
+ </head>
+ <body>
+ <div id="test">
+ <div id="log"></div>
+ </div>
+ </body>
+</html>
diff --git a/LayoutTests/platform/efl/TestExpectations b/LayoutTests/platform/efl/TestExpectations
index 7011084..eeeb35b 100644
--- a/LayoutTests/platform/efl/TestExpectations
+++ b/LayoutTests/platform/efl/TestExpectations
@@ -1215,6 +1215,31 @@
webkit.org/b/84835 editing/execCommand/copy-without-selection.html [ Failure ]
webkit.org/b/84835 editing/execCommand/findString-diacriticals.html [ Failure ]
+# These tests are passing when running on the MiniBrowser, but failing on
+# WebKitTestRunner because it doesn't support fixed layout.
+webkit.org/b/102517 css3/device-adapt/opera/cascading-001.xhtml [ Failure ]
+webkit.org/b/102517 css3/device-adapt/opera/cascading-002.xhtml [ Failure ]
+webkit.org/b/102517 css3/device-adapt/opera/cascading-003.xhtml [ Failure ]
+webkit.org/b/102517 css3/device-adapt/opera/cascading-004.xhtml [ Failure ]
+webkit.org/b/102517 css3/device-adapt/opera/constrain-001.xhtml [ Failure ]
+webkit.org/b/102517 css3/device-adapt/opera/constrain-004.xhtml [ Failure ]
+webkit.org/b/102517 css3/device-adapt/opera/constrain-005.xhtml [ Failure ]
+webkit.org/b/102517 css3/device-adapt/opera/constrain-006.xhtml [ Failure ]
+webkit.org/b/102517 css3/device-adapt/opera/constrain-007.xhtml [ Failure ]
+webkit.org/b/102517 css3/device-adapt/opera/constrain-008.xhtml [ Failure ]
+webkit.org/b/102517 css3/device-adapt/opera/constrain-009.xhtml [ Failure ]
+webkit.org/b/102517 css3/device-adapt/opera/constrain-010.xhtml [ Failure ]
+webkit.org/b/102517 css3/device-adapt/opera/constrain-011.xhtml [ Failure ]
+webkit.org/b/102517 css3/device-adapt/opera/constrain-013.xhtml [ Failure ]
+webkit.org/b/102517 css3/device-adapt/opera/constrain-014.xhtml [ Failure ]
+webkit.org/b/102517 css3/device-adapt/opera/constrain-015.xhtml [ Failure ]
+webkit.org/b/102517 css3/device-adapt/opera/constrain-016.xhtml [ Failure ]
+webkit.org/b/102517 css3/device-adapt/opera/constrain-017.xhtml [ Failure ]
+webkit.org/b/102517 css3/device-adapt/opera/constrain-020.xhtml [ Failure ]
+webkit.org/b/102517 css3/device-adapt/opera/syntax-001.xhtml [ Failure ]
+webkit.org/b/102517 css3/device-adapt/opera/syntax-002.xhtml [ Failure ]
+webkit.org/b/102517 css3/device-adapt/opera/syntax-003.xhtml [ Failure ]
+
# DRT doesn't check for isPrinting().
webkit.org/b/87226 printing/iframe-print.html [ Failure ]
webkit.org/b/87226 printing/media-queries-print.html [ Missing ]
diff --git a/Source/WebCore/CMakeLists.txt b/Source/WebCore/CMakeLists.txt
index 365f38f..92f72cf 100644
--- a/Source/WebCore/CMakeLists.txt
+++ b/Source/WebCore/CMakeLists.txt
@@ -1088,6 +1088,7 @@
css/SVGCSSComputedStyleDeclaration.cpp
css/SVGCSSParser.cpp
css/SVGCSSStyleSelector.cpp
+ css/ViewportStyleResolver.cpp
css/WebKitCSSFilterValue.cpp
css/WebKitCSSKeyframeRule.cpp
css/WebKitCSSKeyframesRule.cpp
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index c1b2ff9..881697e 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,88 @@
+2012-11-19 Thiago Marcos P. Santos <thiago.santos@intel.com>
+
+ Apply the resolved viewport rules
+ https://bugs.webkit.org/show_bug.cgi?id=95964
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ This patch implements the CSS Device Adaptation specification. The
+ WebKit implementation relies on the already implemented Viewport Meta
+ infrastructure to notify the browser of viewport changes.
+
+ The implementation was tests with success on the Qt and EFL ports, but
+ basically every port supporting Viewport Meta should be fine.
+
+ The usage of @-webkit-viewport inside media queries (more tests coming
+ to map all the corner cases) is currently limited when the media query
+ depends on the viewport dimensions itself. Defining the width and height
+ based on screen size will fail on ports reporting the screen
+ size as the size of the browser window instead of the device screen.
+
+ Tests: css3/device-adapt/opera/cascading-001.xhtml
+ css3/device-adapt/opera/cascading-002.xhtml
+ css3/device-adapt/opera/cascading-003.xhtml
+ css3/device-adapt/opera/cascading-004.xhtml
+ css3/device-adapt/opera/constrain-001.xhtml
+ css3/device-adapt/opera/constrain-002.xhtml
+ css3/device-adapt/opera/constrain-003.xhtml
+ css3/device-adapt/opera/constrain-004.xhtml
+ css3/device-adapt/opera/constrain-005.xhtml
+ css3/device-adapt/opera/constrain-006.xhtml
+ css3/device-adapt/opera/constrain-007.xhtml
+ css3/device-adapt/opera/constrain-008.xhtml
+ css3/device-adapt/opera/constrain-009.xhtml
+ css3/device-adapt/opera/constrain-010.xhtml
+ css3/device-adapt/opera/constrain-011.xhtml
+ css3/device-adapt/opera/constrain-012.xhtml
+ css3/device-adapt/opera/constrain-013.xhtml
+ css3/device-adapt/opera/constrain-014.xhtml
+ css3/device-adapt/opera/constrain-015.xhtml
+ css3/device-adapt/opera/constrain-016.xhtml
+ css3/device-adapt/opera/constrain-017.xhtml
+ css3/device-adapt/opera/constrain-020.xhtml
+ css3/device-adapt/opera/syntax-001.xhtml
+ css3/device-adapt/opera/syntax-002.xhtml
+ css3/device-adapt/opera/syntax-003.xhtml
+
+ * CMakeLists.txt:
+ * GNUmakefile.list.am:
+ * Target.pri:
+ * WebCore.gypi:
+ * WebCore.vcproj/WebCore.vcproj:
+ * WebCore.xcodeproj/project.pbxproj:
+ * css/CSSAllInOne.cpp:
+ * css/RuleSet.cpp:
+ (WebCore::RuleSet::addRulesFromSheet):
+ * css/StyleResolver.cpp:
+ (WebCore::StyleResolver::StyleResolver):
+ (WebCore::StyleResolver::appendAuthorStyleSheets):
+ (WebCore::StyleResolver::~StyleResolver):
+ * css/StyleResolver.h:
+ (StyleResolver):
+ (WebCore::StyleResolver::viewportStyleResolver):
+ * css/ViewportStyleResolver.cpp: Added.
+ (WebCore):
+ (WebCore::ViewportStyleResolver::ViewportStyleResolver):
+ (WebCore::ViewportStyleResolver::addViewportRule):
+ (WebCore::ViewportStyleResolver::clearDocument):
+ (WebCore::ViewportStyleResolver::resolve):
+ (WebCore::ViewportStyleResolver::getViewportArgumentValue):
+ * css/ViewportStyleResolver.h: Added.
+ (WebCore):
+ (ViewportStyleResolver):
+ (WebCore::ViewportStyleResolver::create):
+ * dom/Document.h:
+ (WebCore::Document::setViewportArguments):
+ * dom/ViewportArguments.cpp:
+ (WebCore::compareIgnoringAuto):
+ (WebCore):
+ (WebCore::ViewportArguments::resolve):
+ * dom/ViewportArguments.h:
+ (ViewportAttributes):
+ (WebCore::ViewportArguments::ViewportArguments):
+ (ViewportArguments):
+ (WebCore::ViewportArguments::operator==):
+
2012-11-19 Erik Arvidsson <arv@chromium.org>
Update DOMException name: SecurityError
diff --git a/Source/WebCore/GNUmakefile.list.am b/Source/WebCore/GNUmakefile.list.am
index 07a238a..d8439b0 100644
--- a/Source/WebCore/GNUmakefile.list.am
+++ b/Source/WebCore/GNUmakefile.list.am
@@ -2645,6 +2645,8 @@
Source/WebCore/css/SVGCSSComputedStyleDeclaration.cpp \
Source/WebCore/css/SVGCSSParser.cpp \
Source/WebCore/css/SVGCSSStyleSelector.cpp \
+ Source/WebCore/css/ViewportStyleResolver.cpp \
+ Source/WebCore/css/ViewportStyleResolver.h \
Source/WebCore/css/WebKitCSSArrayFunctionValue.cpp \
Source/WebCore/css/WebKitCSSArrayFunctionValue.h \
Source/WebCore/css/WebKitCSSFilterValue.cpp \
diff --git a/Source/WebCore/Target.pri b/Source/WebCore/Target.pri
index 72a17f0..2ca8f7e 100644
--- a/Source/WebCore/Target.pri
+++ b/Source/WebCore/Target.pri
@@ -327,6 +327,7 @@
css/StyleSheet.cpp \
css/StyleSheetContents.cpp \
css/StyleSheetList.cpp \
+ css/ViewportStyleResolver.cpp \
css/WebKitCSSArrayFunctionValue.cpp \
css/WebKitCSSFilterValue.cpp \
css/WebKitCSSKeyframeRule.cpp \
@@ -1508,6 +1509,7 @@
css/StyleSheet.h \
css/StyleSheetContents.h \
css/StyleSheetList.h \
+ css/ViewportStyleResolver.h \
css/WebKitCSSArrayFunctionValue.h \
css/WebKitCSSFilterValue.h \
css/WebKitCSSKeyframeRule.h \
diff --git a/Source/WebCore/WebCore.gypi b/Source/WebCore/WebCore.gypi
index 7edd93c..93b6c0d 100644
--- a/Source/WebCore/WebCore.gypi
+++ b/Source/WebCore/WebCore.gypi
@@ -2631,6 +2631,8 @@
'css/StyleSheetContents.h',
'css/StyleSheetList.cpp',
'css/StyleSheetList.h',
+ 'css/ViewportStyleResolver.cpp',
+ 'css/ViewportStyleResolver.h',
'css/WebKitCSSArrayFunctionValue.cpp',
'css/WebKitCSSArrayFunctionValue.h',
'css/WebKitCSSFilterValue.cpp',
diff --git a/Source/WebCore/WebCore.vcproj/WebCore.vcproj b/Source/WebCore/WebCore.vcproj/WebCore.vcproj
index 20701c3..c47b63f 100755
--- a/Source/WebCore/WebCore.vcproj/WebCore.vcproj
+++ b/Source/WebCore/WebCore.vcproj/WebCore.vcproj
@@ -38118,6 +38118,14 @@
>
</File>
<File
+ RelativePath="..\css\ViewportStyleResolver.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\css\ViewportStyleResolver.h"
+ >
+ </File>
+ <File
RelativePath="..\css\WebKitCSSArrayFunctionValue.cpp"
>
</File>
diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj
index c2e73d2..d67417d 100644
--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -1041,6 +1041,8 @@
3C244FEBA375AC633F88BE6F /* RenderLayerModelObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3C244FE5A375AC633F88BE6F /* RenderLayerModelObject.cpp */; };
3FFFF9A8159D9A550020BBD5 /* WebKitCSSViewportRule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3FFFF9A6159D9A550020BBD5 /* WebKitCSSViewportRule.cpp */; };
3FFFF9A9159D9A550020BBD5 /* WebKitCSSViewportRule.h in Headers */ = {isa = PBXBuildFile; fileRef = 3FFFF9A7159D9A550020BBD5 /* WebKitCSSViewportRule.h */; };
+ 3FFFF9AD159D9B060020BBD5 /* ViewportStyleResolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3FFFF9AB159D9B060020BBD5 /* ViewportStyleResolver.cpp */; };
+ 3FFFF9AE159D9B060020BBD5 /* ViewportStyleResolver.h in Headers */ = {isa = PBXBuildFile; fileRef = 3FFFF9AC159D9B060020BBD5 /* ViewportStyleResolver.h */; };
41002CCD0F66EDEF009E660D /* ScriptFunctionCall.h in Headers */ = {isa = PBXBuildFile; fileRef = 41002CCB0F66EDEF009E660D /* ScriptFunctionCall.h */; };
41002CCE0F66EDEF009E660D /* ScriptFunctionCall.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41002CCC0F66EDEF009E660D /* ScriptFunctionCall.cpp */; };
410B7E721045FAB000D8224F /* JSMessageEventCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 410B7E711045FAB000D8224F /* JSMessageEventCustom.cpp */; };
@@ -8212,6 +8214,8 @@
3C244FE5A375AC633F88BE6F /* RenderLayerModelObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderLayerModelObject.cpp; sourceTree = "<group>"; };
3FFFF9A6159D9A550020BBD5 /* WebKitCSSViewportRule.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebKitCSSViewportRule.cpp; sourceTree = "<group>"; };
3FFFF9A7159D9A550020BBD5 /* WebKitCSSViewportRule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebKitCSSViewportRule.h; sourceTree = "<group>"; };
+ 3FFFF9AB159D9B060020BBD5 /* ViewportStyleResolver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ViewportStyleResolver.cpp; sourceTree = "<group>"; };
+ 3FFFF9AC159D9B060020BBD5 /* ViewportStyleResolver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewportStyleResolver.h; sourceTree = "<group>"; };
41002CCB0F66EDEF009E660D /* ScriptFunctionCall.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptFunctionCall.h; sourceTree = "<group>"; };
41002CCC0F66EDEF009E660D /* ScriptFunctionCall.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptFunctionCall.cpp; sourceTree = "<group>"; };
410B7E711045FAB000D8224F /* JSMessageEventCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMessageEventCustom.cpp; sourceTree = "<group>"; };
@@ -21457,6 +21461,8 @@
B2227B030D00BFF10071B782 /* SVGCSSStyleSelector.cpp */,
B2227B040D00BFF10071B782 /* SVGCSSValueKeywords.in */,
BC5EC1760A507E3E006007F5 /* view-source.css */,
+ 3FFFF9AB159D9B060020BBD5 /* ViewportStyleResolver.cpp */,
+ 3FFFF9AC159D9B060020BBD5 /* ViewportStyleResolver.h */,
150B923715F08DC400E10986 /* WebKitCSSArrayFunctionValue.cpp */,
150B923815F08DC400E10986 /* WebKitCSSArrayFunctionValue.h */,
3106036C14327D2E00ABF4BA /* WebKitCSSFilterValue.cpp */,
@@ -25757,6 +25763,7 @@
AAC08CF315F941FD00F1E188 /* AccessibilitySVGRoot.h in Headers */,
50933350163B0E4300099A60 /* CustomFilterParameterList.h in Headers */,
50D32858163B313F0016111E /* ValidatedCustomFilterOperation.h in Headers */,
+ 3FFFF9AE159D9B060020BBD5 /* ViewportStyleResolver.h in Headers */,
3FFFF9A9159D9A550020BBD5 /* WebKitCSSViewportRule.h in Headers */,
93C38BFF164473C700091EB2 /* ScrollingStateFixedNode.h in Headers */,
93C38C03164473DD00091EB2 /* ScrollingTreeFixedNode.h in Headers */,
@@ -28846,6 +28853,7 @@
93F19B0508245E59001E9ABC /* XSLTProcessorLibxslt.cpp in Sources */,
E1BE512D0CF6C512002EA959 /* XSLTUnicodeSort.cpp in Sources */,
977E2E0E12F0FC9C00C13379 /* XSSAuditor.cpp in Sources */,
+ 3FFFF9AD159D9B060020BBD5 /* ViewportStyleResolver.cpp in Sources */,
FD537352137B651800008DCE /* ZeroPole.cpp in Sources */,
51ABF64D16392E2800132A7A /* LoaderStrategy.cpp in Sources */,
5093334F163B0E4300099A60 /* CustomFilterParameterList.cpp in Sources */,
diff --git a/Source/WebCore/css/CSSAllInOne.cpp b/Source/WebCore/css/CSSAllInOne.cpp
index 84f9fe7..479d8de 100644
--- a/Source/WebCore/css/CSSAllInOne.cpp
+++ b/Source/WebCore/css/CSSAllInOne.cpp
@@ -73,3 +73,4 @@
#include "StylePropertyShorthand.cpp"
#include "StyleResolver.cpp"
#include "StyleScopeResolver.cpp"
+#include "ViewportStyleResolver.cpp"
diff --git a/Source/WebCore/css/RuleSet.cpp b/Source/WebCore/css/RuleSet.cpp
index 372efdb..9a78c0f 100644
--- a/Source/WebCore/css/RuleSet.cpp
+++ b/Source/WebCore/css/RuleSet.cpp
@@ -312,6 +312,14 @@
continue;
resolver->addKeyframeStyle(static_cast<StyleRuleKeyframes*>(childRule));
}
+#if ENABLE(CSS_DEVICE_ADAPTATION)
+ else if (childRule->isViewportRule() && resolver && !resolver->affectedByViewportChange()) {
+ // @viewport should not be scoped.
+ if (scope)
+ continue;
+ resolver->viewportStyleResolver()->addViewportRule(static_cast<StyleRuleViewport*>(childRule));
+ }
+#endif
} // for rules
} // if rules
} else if (rule->isFontFaceRule() && resolver) {
@@ -340,6 +348,14 @@
else if (rule->isHostRule())
resolver->addHostRule(static_cast<StyleRuleHost*>(rule), hasDocumentSecurityOrigin, scope);
#endif
+#if ENABLE(CSS_DEVICE_ADAPTATION)
+ else if (rule->isViewportRule() && resolver) {
+ // @viewport should not be scoped.
+ if (scope)
+ continue;
+ resolver->viewportStyleResolver()->addViewportRule(static_cast<StyleRuleViewport*>(rule));
+ }
+#endif
}
if (m_autoShrinkToFitEnabled)
shrinkToFit();
diff --git a/Source/WebCore/css/StyleResolver.cpp b/Source/WebCore/css/StyleResolver.cpp
index b5970c0..0d07220 100644
--- a/Source/WebCore/css/StyleResolver.cpp
+++ b/Source/WebCore/css/StyleResolver.cpp
@@ -123,6 +123,7 @@
#include "TransformationMatrix.h"
#include "TranslateTransformOperation.h"
#include "UserAgentStyleSheets.h"
+#include "ViewportStyleResolver.h"
#include "WebCoreMemoryInstrumentation.h"
#include "WebKitCSSKeyframeRule.h"
#include "WebKitCSSKeyframesRule.h"
@@ -276,6 +277,9 @@
, m_sameOriginOnly(false)
, m_distributedToInsertionPoint(false)
, m_fontSelector(CSSFontSelector::create(document))
+#if ENABLE(CSS_DEVICE_ADAPTATION)
+ , m_viewportStyleResolver(ViewportStyleResolver::create(document))
+#endif
, m_applyPropertyToRegularStyle(true)
, m_applyPropertyToVisitedLinkStyle(false)
, m_styleBuilder(StyleBuilder::sharedStyleBuilder())
@@ -404,6 +408,10 @@
if (document()->renderer() && document()->renderer()->style())
document()->renderer()->style()->font().update(fontSelector());
+
+#if ENABLE(CSS_DEVICE_ADAPTATION)
+ viewportStyleResolver()->resolve();
+#endif
}
void StyleResolver::pushParentElement(Element* parent)
@@ -458,6 +466,10 @@
StyleResolver::~StyleResolver()
{
m_fontSelector->clearDocument();
+
+#if ENABLE(CSS_DEVICE_ADAPTATION)
+ m_viewportStyleResolver->clearDocument();
+#endif
}
void StyleResolver::sweepMatchedPropertiesCache(Timer<StyleResolver>*)
diff --git a/Source/WebCore/css/StyleResolver.h b/Source/WebCore/css/StyleResolver.h
index 4e775a5..f1266c2 100644
--- a/Source/WebCore/css/StyleResolver.h
+++ b/Source/WebCore/css/StyleResolver.h
@@ -33,6 +33,7 @@
#include "SelectorChecker.h"
#include "StyleInheritedData.h"
#include "StyleScopeResolver.h"
+#include "ViewportStyleResolver.h"
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
#include <wtf/RefPtr.h>
@@ -92,6 +93,7 @@
class StyleSheetContents;
class StyleSheetList;
class StyledElement;
+class ViewportStyleResolver;
class WebKitCSSFilterValue;
class WebKitCSSShaderValue;
class WebKitCSSSVGDocumentValue;
@@ -245,6 +247,9 @@
bool hasSelectorForAttribute(const AtomicString&) const;
CSSFontSelector* fontSelector() const { return m_fontSelector.get(); }
+#if ENABLE(CSS_DEVICE_ADAPTATION)
+ ViewportStyleResolver* viewportStyleResolver() { return m_viewportStyleResolver.get(); }
+#endif
void addViewportDependentMediaQueryResult(const MediaQueryExp*, bool result);
bool hasViewportDependentMediaQueries() const { return !m_viewportDependentMediaQueryResults.isEmpty(); }
@@ -493,6 +498,10 @@
RefPtr<CSSFontSelector> m_fontSelector;
Vector<OwnPtr<MediaQueryResult> > m_viewportDependentMediaQueryResults;
+#if ENABLE(CSS_DEVICE_ADAPTATION)
+ RefPtr<ViewportStyleResolver> m_viewportStyleResolver;
+#endif
+
bool m_applyPropertyToRegularStyle;
bool m_applyPropertyToVisitedLinkStyle;
const StyleBuilder& m_styleBuilder;
diff --git a/Source/WebCore/css/ViewportStyleResolver.cpp b/Source/WebCore/css/ViewportStyleResolver.cpp
new file mode 100644
index 0000000..4148e7c4
--- /dev/null
+++ b/Source/WebCore/css/ViewportStyleResolver.cpp
@@ -0,0 +1,164 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+ * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ViewportStyleResolver.h"
+
+#if ENABLE(CSS_DEVICE_ADAPTATION)
+
+#include "CSSValueKeywords.h"
+#include "Document.h"
+#include "Page.h"
+#include "RenderView.h"
+#include "StylePropertySet.h"
+#include "StyleRule.h"
+#include "ViewportArguments.h"
+
+namespace WebCore {
+
+ViewportStyleResolver::ViewportStyleResolver(Document* document)
+ : m_document(document)
+{
+ ASSERT(m_document);
+
+ m_initialViewportSize.setWidth(m_document->viewportSize().width());
+ m_initialViewportSize.setHeight(m_document->viewportSize().height());
+}
+
+void ViewportStyleResolver::addViewportRule(StyleRuleViewport* viewportRule)
+{
+ StylePropertySet* propertySet = viewportRule->mutableProperties();
+
+ unsigned propertyCount = propertySet->propertyCount();
+ if (!propertyCount)
+ return;
+
+ if (!m_propertySet) {
+ m_propertySet = propertySet->copy();
+ return;
+ }
+
+ // We cannot use mergeAndOverrideOnConflict() here because it doesn't
+ // respect the !important declaration (but addParsedProperty() does).
+ for (unsigned i = 0; i < propertyCount; ++i)
+ m_propertySet->addParsedProperty(propertySet->propertyAt(i).toCSSProperty());
+}
+
+void ViewportStyleResolver::clearDocument()
+{
+ m_document = 0;
+}
+
+void ViewportStyleResolver::resolve()
+{
+ if (!m_document || !m_propertySet)
+ return;
+
+ ViewportArguments arguments(ViewportArguments::CSSDeviceAdaptation);
+
+ arguments.userZoom = getViewportArgumentValue(CSSPropertyUserZoom);
+ arguments.zoom = getViewportArgumentValue(CSSPropertyZoom);
+ arguments.minZoom = getViewportArgumentValue(CSSPropertyMinZoom);
+ arguments.maxZoom = getViewportArgumentValue(CSSPropertyMaxZoom);
+ arguments.minWidth = getViewportArgumentValue(CSSPropertyMinWidth);
+ arguments.maxWidth = getViewportArgumentValue(CSSPropertyMaxWidth);
+ arguments.minHeight = getViewportArgumentValue(CSSPropertyMinHeight);
+ arguments.maxHeight = getViewportArgumentValue(CSSPropertyMaxHeight);
+ arguments.orientation = getViewportArgumentValue(CSSPropertyOrientation);
+
+ m_document->setViewportArguments(arguments);
+ m_document->updateViewportArguments();
+
+ m_propertySet = 0;
+}
+
+float ViewportStyleResolver::getViewportArgumentValue(CSSPropertyID id) const
+{
+ float defaultValue = ViewportArguments::ValueAuto;
+
+ // UserZoom default value is CSSValueZoom, which maps to true, meaning that
+ // yes, it is user scalable. When the value is set to CSSValueFixed, we
+ // return false.
+ if (id == CSSPropertyUserZoom)
+ defaultValue = 1;
+
+ RefPtr<CSSValue> value = m_propertySet->getPropertyCSSValue(id);
+ if (!value || !value->isPrimitiveValue())
+ return defaultValue;
+
+ CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value.get());
+
+ if (primitiveValue->isNumber() || primitiveValue->isPx())
+ return primitiveValue->getFloatValue();
+
+ if (primitiveValue->isFontRelativeLength())
+ return primitiveValue->getFloatValue() * m_document->documentElement()->renderStyle()->fontDescription().computedSize();
+
+ if (primitiveValue->isPercentage()) {
+ float percentValue = primitiveValue->getFloatValue() / 100.0f;
+ switch (id) {
+ case CSSPropertyMaxHeight:
+ case CSSPropertyMinHeight:
+ return percentValue * m_initialViewportSize.height();
+ case CSSPropertyMaxWidth:
+ case CSSPropertyMinWidth:
+ return percentValue * m_initialViewportSize.width();
+ case CSSPropertyMaxZoom:
+ case CSSPropertyMinZoom:
+ case CSSPropertyZoom:
+ return percentValue;
+ default:
+ ASSERT_NOT_REACHED();
+ break;
+ }
+ }
+
+ switch (primitiveValue->getIdent()) {
+ case CSSValueAuto:
+ return defaultValue;
+ case CSSValueDeviceHeight:
+ return ViewportArguments::ValueDeviceHeight;
+ case CSSValueDeviceWidth:
+ return ViewportArguments::ValueDeviceWidth;
+ case CSSValueLandscape:
+ return ViewportArguments::ValueLandscape;
+ case CSSValuePortrait:
+ return ViewportArguments::ValuePortrait;
+ case CSSValueZoom:
+ return defaultValue;
+ case CSSValueFixed:
+ return 0;
+ default:
+ return defaultValue;
+ }
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(CSS_DEVICE_ADAPTATION)
diff --git a/Source/WebCore/css/ViewportStyleResolver.h b/Source/WebCore/css/ViewportStyleResolver.h
new file mode 100644
index 0000000..0b8ff57
--- /dev/null
+++ b/Source/WebCore/css/ViewportStyleResolver.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+ * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef ViewportStyleResolver_h
+#define ViewportStyleResolver_h
+
+#if ENABLE(CSS_DEVICE_ADAPTATION)
+
+#include "CSSPropertyNames.h"
+#include "FloatSize.h"
+#include <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+class CSSPrimitiveValue;
+class Document;
+class StyleRuleViewport;
+class StylePropertySet;
+
+class ViewportStyleResolver : public RefCounted<ViewportStyleResolver> {
+public:
+ static PassRefPtr<ViewportStyleResolver> create(Document* document)
+ {
+ return adoptRef(new ViewportStyleResolver(document));
+ }
+
+ void addViewportRule(StyleRuleViewport*);
+
+ void clearDocument();
+ void resolve();
+
+private:
+ explicit ViewportStyleResolver(Document*);
+
+ float getViewportArgumentValue(CSSPropertyID) const;
+
+ Document* m_document;
+ RefPtr<StylePropertySet> m_propertySet;
+
+ FloatSize m_initialViewportSize;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(CSS_DEVICE_ADAPTATION)
+
+#endif // ViewportStyleResolver_h
diff --git a/Source/WebCore/dom/Document.h b/Source/WebCore/dom/Document.h
index 440cfa2..b961c35 100644
--- a/Source/WebCore/dom/Document.h
+++ b/Source/WebCore/dom/Document.h
@@ -323,6 +323,7 @@
DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitvisibilitychange);
#endif
+ void setViewportArguments(const ViewportArguments& viewportArguments) { m_viewportArguments = viewportArguments; }
ViewportArguments viewportArguments() const { return m_viewportArguments; }
#ifndef NDEBUG
bool didDispatchViewportPropertiesChanged() const { return m_didDispatchViewportPropertiesChanged; }
diff --git a/Source/WebCore/dom/ViewportArguments.cpp b/Source/WebCore/dom/ViewportArguments.cpp
index d88404e..e1ade63 100644
--- a/Source/WebCore/dom/ViewportArguments.cpp
+++ b/Source/WebCore/dom/ViewportArguments.cpp
@@ -6,6 +6,7 @@
* Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserved.
* Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -43,6 +44,19 @@
const float ViewportArguments::deprecatedTargetDPI = 160;
+static const float& compareIgnoringAuto(const float& value1, const float& value2, const float& (*compare) (const float&, const float&))
+{
+ ASSERT(value1 != ViewportArguments::ValueAuto || value2 != ViewportArguments::ValueAuto);
+
+ if (value1 == ViewportArguments::ValueAuto)
+ return value2;
+
+ if (value2 == ViewportArguments::ValueAuto)
+ return value1;
+
+ return compare(value1, value2);
+}
+
static inline float clampLengthValue(float value)
{
ASSERT(value != ViewportArguments::ValueDeviceWidth);
@@ -68,7 +82,11 @@
ViewportAttributes ViewportArguments::resolve(const FloatSize& initialViewportSize, const FloatSize& deviceSize, int defaultWidth) const
{
float resultWidth = width;
+ float resultMaxWidth = maxWidth;
+ float resultMinWidth = minWidth;
float resultHeight = height;
+ float resultMinHeight = minHeight;
+ float resultMaxHeight = maxHeight;
float resultZoom = zoom;
float resultMinZoom = minZoom;
float resultMaxZoom = maxZoom;
@@ -92,6 +110,73 @@
break;
}
+ if (type == ViewportArguments::CSSDeviceAdaptation) {
+ switch (int(resultMinWidth)) {
+ case ViewportArguments::ValueDeviceWidth:
+ resultMinWidth = deviceSize.width();
+ break;
+ case ViewportArguments::ValueDeviceHeight:
+ resultMinWidth = deviceSize.height();
+ break;
+ }
+
+ switch (int(resultMaxWidth)) {
+ case ViewportArguments::ValueDeviceWidth:
+ resultMaxWidth = deviceSize.width();
+ break;
+ case ViewportArguments::ValueDeviceHeight:
+ resultMaxWidth = deviceSize.height();
+ break;
+ }
+
+ switch (int(resultMinHeight)) {
+ case ViewportArguments::ValueDeviceWidth:
+ resultMinHeight = deviceSize.width();
+ break;
+ case ViewportArguments::ValueDeviceHeight:
+ resultMinHeight = deviceSize.height();
+ break;
+ }
+
+ switch (int(resultMaxHeight)) {
+ case ViewportArguments::ValueDeviceWidth:
+ resultMaxHeight = deviceSize.width();
+ break;
+ case ViewportArguments::ValueDeviceHeight:
+ resultMaxHeight = deviceSize.height();
+ break;
+ }
+
+ if (resultMinWidth != ViewportArguments::ValueAuto || resultMaxWidth != ViewportArguments::ValueAuto)
+ resultWidth = compareIgnoringAuto(resultMinWidth, compareIgnoringAuto(resultMaxWidth, deviceSize.width(), min), max);
+
+ if (resultMinHeight != ViewportArguments::ValueAuto || resultMaxHeight != ViewportArguments::ValueAuto)
+ resultHeight = compareIgnoringAuto(resultMinHeight, compareIgnoringAuto(resultMaxHeight, deviceSize.height(), min), max);
+
+ if (resultMinZoom != ViewportArguments::ValueAuto && resultMaxZoom != ViewportArguments::ValueAuto)
+ resultMaxZoom = max(resultMinZoom, resultMaxZoom);
+
+ if (resultZoom != ViewportArguments::ValueAuto)
+ resultZoom = compareIgnoringAuto(resultMinZoom, compareIgnoringAuto(resultMaxZoom, resultZoom, min), max);
+
+ if (resultWidth == ViewportArguments::ValueAuto && resultZoom == ViewportArguments::ValueAuto)
+ resultWidth = deviceSize.width();
+
+ if (resultWidth == ViewportArguments::ValueAuto && resultHeight == ViewportArguments::ValueAuto)
+ resultWidth = deviceSize.width() / resultZoom;
+
+ if (resultWidth == ViewportArguments::ValueAuto)
+ resultWidth = resultHeight * deviceSize.width() / deviceSize.height();
+
+ if (resultHeight == ViewportArguments::ValueAuto)
+ resultHeight = resultWidth * deviceSize.height() / deviceSize.width();
+
+ if (resultZoom != ViewportArguments::ValueAuto || resultMaxZoom != ViewportArguments::ValueAuto) {
+ resultWidth = compareIgnoringAuto(resultWidth, deviceSize.width() / compareIgnoringAuto(resultZoom, resultMaxZoom, min), max);
+ resultHeight = compareIgnoringAuto(resultHeight, deviceSize.height() / compareIgnoringAuto(resultZoom, resultMaxZoom, min), max);
+ }
+ }
+
// Clamp values to valid range.
resultWidth = clampLengthValue(resultWidth);
resultHeight = clampLengthValue(resultHeight);
@@ -100,6 +185,7 @@
resultMaxZoom = clampScaleValue(resultMaxZoom);
ViewportAttributes result;
+ result.orientation = orientation;
// Resolve minimum-scale and maximum-scale values according to spec.
if (resultMinZoom == ViewportArguments::ValueAuto)
@@ -155,6 +241,7 @@
// result.initialScale = ViewportArguments::ValueAuto;
result.userScalable = resultUserZoom;
+ result.orientation = orientation;
return result;
}
diff --git a/Source/WebCore/dom/ViewportArguments.h b/Source/WebCore/dom/ViewportArguments.h
index 17c8adf..e2f6f2e 100644
--- a/Source/WebCore/dom/ViewportArguments.h
+++ b/Source/WebCore/dom/ViewportArguments.h
@@ -6,6 +6,7 @@
* Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
* Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -50,6 +51,7 @@
float maximumScale;
float userScalable;
+ float orientation;
};
struct ViewportArguments {
@@ -62,23 +64,31 @@
HandheldFriendlyMeta,
MobileOptimizedMeta,
#endif
- ViewportMeta
+ ViewportMeta,
+ CSSDeviceAdaptation
} type;
enum {
ValueAuto = -1,
ValueDeviceWidth = -2,
ValueDeviceHeight = -3,
+ ValuePortrait = -4,
+ ValueLandscape = -5
};
ViewportArguments(Type type = Implicit)
: type(type)
, width(ValueAuto)
+ , minWidth(ValueAuto)
+ , maxWidth(ValueAuto)
, height(ValueAuto)
+ , minHeight(ValueAuto)
+ , maxHeight(ValueAuto)
, zoom(ValueAuto)
, minZoom(ValueAuto)
, maxZoom(ValueAuto)
, userZoom(ValueAuto)
+ , orientation(ValueAuto)
{
}
@@ -86,22 +96,32 @@
ViewportAttributes resolve(const FloatSize& initialViewportSize, const FloatSize& deviceSize, int defaultWidth) const;
float width;
+ float minWidth;
+ float maxWidth;
float height;
+ float minHeight;
+ float maxHeight;
float zoom;
float minZoom;
float maxZoom;
float userZoom;
+ float orientation;
bool operator==(const ViewportArguments& other) const
{
// Used for figuring out whether to reset the viewport or not,
// thus we are not taking type into account.
return width == other.width
+ && minWidth == other.minWidth
+ && maxWidth == other.maxWidth
&& height == other.height
+ && minHeight == other.minHeight
+ && maxHeight == other.maxHeight
&& zoom == other.zoom
&& minZoom == other.minZoom
&& maxZoom == other.maxZoom
- && userZoom == other.userZoom;
+ && userZoom == other.userZoom
+ && orientation == other.orientation;
}
bool operator!=(const ViewportArguments& other) const