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/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();