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
Computed grid items' positions shouldn't be using Length
https://bugs.webkit.org/show_bug.cgi?id=102537

Reviewed by Tony Chang.

This change refactors how we store the grid items' position to use
a new type GridPosition. Length was a temporary type as it supported
'auto' | <integer> but it was starting to get more and more confusing
as we were implementing the layout routines.

No change in behavior.

* GNUmakefile.list.am:
* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
Added the new file to the build systems.

* rendering/style/RenderStyle.h:
Updated after the type change. Also made some getters
return a const reference instead of forcing a copy.

* rendering/style/StyleGridItemData.h:
(StyleGridItemData):
Ditto, also removed a comment about adding a new type.

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::valueForGridPosition):
* css/StyleResolver.cpp:
(WebCore::createGridPosition):
(WebCore::StyleResolver::applyProperty):
* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::resolveGridPosition):
Updated these sites after switching to GridPosition.

* rendering/RenderGrid.h:
Changed resolveGridPosition signature: it now takes a GridPosition.

* rendering/style/GridPosition.h: Added.
(WebCore::GridPosition::GridPosition):
Default constructor, creates an 'auto' position.

(WebCore::GridPosition::isPositive):
(WebCore::GridPosition::type):
(WebCore::GridPosition::isAuto):
(WebCore::GridPosition::setIntegerPosition):
(WebCore::GridPosition::integerPosition):
Helper functions.

(WebCore::GridPosition::operator==):
Required comparison operator for StyleGridItemData.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@135164 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Use device scale factor instead of physical screen DPI for screen DPI
https://bugs.webkit.org/show_bug.cgi?id=101769

Patch by Sami Kyostila <skyostil@chromium.org> on 2012-11-19
Reviewed by Adam Barth.

Media queries call WebCore::Screen::{horizontal,vertical}DPI() to determine
the dots per CSS inch[1] value for the "screen" media type. On Chromium these
functions currently return the physical screen DPI, which is wrong. To fix
this, we remove both of these functions entirely and make media queries use
the device scale factor multiplied by 96 on all ports.

[1] http://www.w3.org/TR/css3-mediaqueries/#resolution0

* page/Screen.cpp:
(WebCore::Screen::horizontalDPI):
(WebCore::Screen::verticalDPI):
* platform/PlatformScreen.h:
(WebCore):
* platform/blackberry/PlatformScreenBlackBerry.cpp:
* platform/chromium/PlatformScreenChromium.cpp:
* platform/efl/PlatformScreenEfl.cpp:
* platform/gtk/PlatformScreenGtk.cpp:
* platform/mac/PlatformScreenMac.mm:
* platform/qt/PlatformScreenQt.cpp:
* platform/win/PlatformScreenWin.cpp:
* platform/wx/ScreenWx.cpp:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@135165 268f45cc-cd09-0410-ab3c-d52691b4dbfc