CSS Device Adaptation: window.innerWidth returns wrong value if CSS viewport descriptors are applied
https://bugs.webkit.org/show_bug.cgi?id=103737
Patch by Mikhail Pozdnyakov <mikhail.pozdnyakov@intel.com> on 2012-12-03
Reviewed by Kenneth Rohde Christiansen.
Source/WebCore:
ViewportStyleResolver used frame view visibleContentRect size as initial viewport size.
This however caused a problem when page enabled/disabled CSS stylesheets, having viewport
descriptors. Viewport descriptors from new stylesheet were applied to the visibleContentRect
affected already by the viewport descriptors from the previous stylesheet.
New 'initialViewportSize' property (http://dev.w3.org/csswg/css-device-adapt/#initial-viewport)
was added to frame view so that viewport descriptors can always be applied to the reliable
viewport size.
Test: css3/device-adapt/viewport-width-check-window-innerwidth-correct.html
* css/ViewportStyleResolver.cpp:
(WebCore::ViewportStyleResolver::ViewportStyleResolver):
(WebCore::ViewportStyleResolver::getViewportArgumentValue):
* css/ViewportStyleResolver.h:
(ViewportStyleResolver):
* dom/Document.cpp:
(WebCore):
(WebCore::Document::initialViewportSize):
* dom/Document.h:
(Document):
* page/FrameView.h:
(FrameView):
(WebCore::FrameView::initialViewportSize):
(WebCore::FrameView::setInitialViewportSize):
Source/WebKit2:
ViewportStyleResolver used frame view visibleContentRect size as initial viewport size.
This however caused a problem when page enabled/disabled CSS stylesheets, having viewport
descriptors. Viewport descriptors from new stylesheet were applied to the visibleContentRect
affected already by the viewport descriptors from the previous stylesheet.
New 'initialViewportSize' property (http://dev.w3.org/csswg/css-device-adapt/#initial-viewport)
was added to frame view so that viewport descriptors can always be applied to the reliable
viewport size.
Both newly added 'initialViewportSize' property and 'fixedVisibleContentRect' property
are assigned appropriately now in WebPage::sendViewportAttributesChanged().
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::sendViewportAttributesChanged):
LayoutTests:
Added new test css3/device-adapt/viewport-width-check-window-innerwidth-correct.html.
* css3/device-adapt/viewport-width-check-window-innerwidth-correct-expected.txt: Added.
* css3/device-adapt/viewport-width-check-window-innerwidth-correct.html: Added.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@136373 268f45cc-cd09-0410-ab3c-d52691b4dbfc
12 files changed