Implement vw/vh/vmin (viewport sizes) from CSS3 Values and Units
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 27 Mar 2012 19:19:59 +0000 (19:19 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 27 Mar 2012 19:19:59 +0000 (19:19 +0000)
https://bugs.webkit.org/show_bug.cgi?id=27160

Patch by Joe Thomas <joethomas@motorola.com> on 2012-03-27
Reviewed by Antti Koivisto.

vw/vh/vmin are implemented as primitive length units. Added the parsing logic for these new units.
New Length types such as ViewportRelativeWidth, ViewportRelativeHeight and ViewportRelativeMin are added for these length units
and included the support for fetching the value of these relative units based on the current viewport size.

The specification related to this implementation is http://dev.w3.org/csswg/css3-values/#viewport-relative-lengths.

Source/WebCore:

Tests: css3/viewport-relative-lengths/css3-viewport-relative-lengths-getStyle.html
       css3/viewport-relative-lengths/css3-viewport-relative-lengths-vh-absolute.html
       css3/viewport-relative-lengths/css3-viewport-relative-lengths-vh.html
       css3/viewport-relative-lengths/css3-viewport-relative-lengths-vmin-absolute.html
       css3/viewport-relative-lengths/css3-viewport-relative-lengths-vmin.html
       css3/viewport-relative-lengths/css3-viewport-relative-lengths-vw-absolute.html
       css3/viewport-relative-lengths/css3-viewport-relative-lengths-vw.html

* accessibility/gtk/WebKitAccessibleInterfaceText.cpp: Modified to support viewport relative Length types.
(getAttributeSetForAccessibilityObject):
* css/CSSComputedStyleDeclaration.cpp: Ditto.
(WebCore::getPositionOffsetValue):
(WebCore::getBorderRadiusCornerValues):
(WebCore::getBorderRadiusCornerValue):
(WebCore::getBorderRadiusShorthandValue):
(WebCore::lineHeightFromStyle):
(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
* css/CSSGrammar.y: Added vw/vh/vmin support.
* css/CSSParser.cpp: Parsing of relative units and creation of CSSPrimitiveValue.
(WebCore::CSSParser::validUnit): Added vw/vh/vmin to the valid units.
(WebCore::CSSParser::createPrimitiveNumericValue): Added vw/vh/vmin as valid primitive units.
(WebCore::unitFromString):
(WebCore::CSSParser::parseValidPrimitive): Creation of CSSPrimitiveValue for vw/vh/vmin.
(WebCore::CSSParser::detectNumberToken): Parsing the vw/vh/vmin tokens.
* css/CSSPrimitiveValue.cpp:
(WebCore::isValidCSSUnitTypeForDoubleConversion): Added support for vw/vh/vmin.
(WebCore::unitCategory): Ditto.
(WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
(WebCore::CSSPrimitiveValue::canonicalUnitTypeForCategory): Added support for vw/vh/vmin.
(WebCore::CSSPrimitiveValue::customCssText): Ditto.
(WebCore::CSSPrimitiveValue::viewportRelativeLength): Function to create the Length structure for the viewport-relative unit types.
(WebCore):
* css/CSSPrimitiveValue.h:
(WebCore::CSSPrimitiveValue::isViewportRelativeLength): Checks whether the primitive value is ViewportRelative Lengths.
(CSSPrimitiveValue):
* css/CSSPrimitiveValue.idl: Added support for vw/vh/vmin.
* css/CSSPrimitiveValueMappings.h:
(WebCore::CSSPrimitiveValue::convertToLength): Ditto.
* css/CSSStyleApplyProperty.cpp: Applying relative viewport length units to the specific CSS property.
(WebCore::ApplyPropertyLength::applyValue):
(WebCore::ApplyPropertyBorderRadius::applyValue):
(WebCore::ApplyPropertyFontSize::applyValue):
(WebCore::ApplyPropertyLineHeight::applyValue):
(WebCore::ApplyPropertyVerticalAlign::applyValue):
* css/CSSStyleSelector.cpp: Added support for viewport relative units.
* css/LengthFunctions.cpp: Calcuation of length value based on the current viewport size.
(WebCore::miminumValueForLength):
(WebCore::valueForLength):
(WebCore::floatValueForLength):
* css/LengthFunctions.h: Added new RenderView argument.
(WebCore):
* dom/Document.cpp:
(WebCore::Document::pageSizeAndMarginsInPixels): Modified to support viewport relative Length types.
(WebCore::Document::viewportSize): New function to fetch the current viewport size.
(WebCore):
* dom/Document.h: Ditto.
(Document):
* html/HTMLAreaElement.cpp: Modified to support viewport relative Length types.
(WebCore::HTMLAreaElement::getRegion):
* platform/Length.h:
(WebCore::Length::isViewportRelative): To check the Length is of type ViewportRelative.
(WebCore::Length::viewportRelativeLength): To get the relative value.
* rendering/RenderBR.cpp: Modified to support viewport relative Length types.
(WebCore::RenderBR::lineHeight):
* rendering/RenderBlock.cpp: Ditto.
(WebCore::RenderBlock::textIndentOffset):
(WebCore::RenderBlock::computeInlinePreferredLogicalWidths):
(WebCore::RenderBlock::lineHeight):
* rendering/RenderBox.cpp: Ditto.
(WebCore::RenderBox::reflectionOffset):
(WebCore::RenderBox::paintBoxDecorations):
(WebCore::RenderBox::clipRect):
(WebCore::RenderBox::computeLogicalWidthInRegion):
(WebCore::RenderBox::computeLogicalWidthInRegionUsing):
(WebCore::RenderBox::computeInlineDirectionMargins):
(WebCore::RenderBox::computeContentLogicalHeightUsing):
(WebCore::RenderBox::computeReplacedLogicalHeightUsing):
(WebCore::RenderBox::computeBlockDirectionMargins):
(WebCore::RenderBox::computePositionedLogicalWidthUsing):
(WebCore::RenderBox::computePositionedLogicalHeightUsing):
(WebCore::RenderBox::computePositionedLogicalWidthReplaced):
(WebCore::RenderBox::computePositionedLogicalHeightReplaced):
* rendering/RenderBoxModelObject.cpp: Ditto.
(WebCore::RenderBoxModelObject::relativePositionOffsetX):
(WebCore::RenderBoxModelObject::relativePositionOffsetY):
(WebCore::RenderBoxModelObject::paddingTop):
(WebCore::RenderBoxModelObject::paddingBottom):
(WebCore::RenderBoxModelObject::paddingLeft):
(WebCore::RenderBoxModelObject::paddingRight):
(WebCore::RenderBoxModelObject::paddingBefore):
(WebCore::RenderBoxModelObject::paddingAfter):
(WebCore::RenderBoxModelObject::paddingStart):
(WebCore::RenderBoxModelObject::paddingEnd):
(WebCore::RenderBoxModelObject::getBackgroundRoundedRect):
(WebCore::RenderBoxModelObject::calculateFillTileSize):
(WebCore::RenderBoxModelObject::calculateBackgroundImageGeometry):
(WebCore::computeBorderImageSide):
(WebCore::RenderBoxModelObject::paintNinePieceImage):
(WebCore::RenderBoxModelObject::paintBorder):
(WebCore::RenderBoxModelObject::paintBoxShadow):
* rendering/RenderFlexibleBox.cpp: Ditto.
(WebCore::RenderFlexibleBox::preferredMainAxisContentExtentForChild):
(WebCore::RenderFlexibleBox::computeMainAxisPreferredSizes):
(WebCore::RenderFlexibleBox::resolveFlexibleLengths):
* rendering/RenderInline.cpp: Ditto.
(WebCore::computeMargin):
(WebCore::RenderInline::lineHeight):
* rendering/RenderMenuList.cpp: Ditto.
(WebCore::RenderMenuList::updateOptionsWidth):
* rendering/RenderObject.cpp: Ditto.
(WebCore::RenderObject::repaintAfterLayoutIfNeeded):
* rendering/RenderReplaced.cpp: Ditto.
(WebCore::RenderReplaced::paint):
* rendering/RenderScrollbarPart.cpp: Ditto.
(WebCore::calcScrollbarThicknessUsing):
(WebCore::RenderScrollbarPart::computeScrollbarWidth):
(WebCore::RenderScrollbarPart::computeScrollbarHeight):
* rendering/RenderTable.cpp: Ditto.
(WebCore::RenderTable::computeLogicalWidth):
(WebCore::RenderTable::convertStyleLogicalWidthToComputedWidth):
* rendering/RenderTableCell.cpp: Ditto.
(WebCore::RenderTableCell::logicalHeightForRowSizing):
* rendering/RenderTableSection.cpp: Ditto.
(WebCore::RenderTableSection::calcRowLogicalHeight):
* rendering/RenderText.h: Ditto.
(WebCore::RenderText::marginLeft):
(WebCore::RenderText::marginRight):
* rendering/RenderThemeMac.mm: Ditto.
(WebCore::RenderThemeMac::paintMenuListButtonGradients):
* rendering/RenderView.h:
(WebCore::RenderView::viewportSize):
* rendering/RenderWidget.cpp: Ditto.
(WebCore::RenderWidget::paint):
* rendering/RootInlineBox.cpp: Ditto.
(WebCore::RootInlineBox::verticalPositionForBox):
* rendering/style/RenderStyle.cpp: Ditto.
(WebCore::calcRadiiFor):
(WebCore::RenderStyle::getRoundedBorderFor):
* rendering/style/RenderStyle.h: Ditto.
* rendering/svg/RenderSVGRoot.cpp: Ditto.
(WebCore::resolveLengthAttributeForSVG):
(WebCore::RenderSVGRoot::computeReplacedLogicalWidth):
(WebCore::RenderSVGRoot::computeReplacedLogicalHeight):

LayoutTests:

* css3/viewport-relative-lengths/css3-viewport-relative-lengths-getStyle-expected.txt: Added.
* css3/viewport-relative-lengths/css3-viewport-relative-lengths-getStyle.html: Added.
* css3/viewport-relative-lengths/css3-viewport-relative-lengths-vh-absolute-expected.html: Added.
* css3/viewport-relative-lengths/css3-viewport-relative-lengths-vh-absolute.html: Added.
* css3/viewport-relative-lengths/css3-viewport-relative-lengths-vh-expected.html: Added.
* css3/viewport-relative-lengths/css3-viewport-relative-lengths-vh.html: Added.
* css3/viewport-relative-lengths/css3-viewport-relative-lengths-vmin-absolute-expected.html: Added.
* css3/viewport-relative-lengths/css3-viewport-relative-lengths-vmin-absolute.html: Added.
* css3/viewport-relative-lengths/css3-viewport-relative-lengths-vmin-expected.html: Added.
* css3/viewport-relative-lengths/css3-viewport-relative-lengths-vmin.html: Added.
* css3/viewport-relative-lengths/css3-viewport-relative-lengths-vw-absolute-expected.html: Added.
* css3/viewport-relative-lengths/css3-viewport-relative-lengths-vw-absolute.html: Added.
* css3/viewport-relative-lengths/css3-viewport-relative-lengths-vw-expected.html: Added.
* css3/viewport-relative-lengths/css3-viewport-relative-lengths-vw.html: Added.
* fast/dom/Window/window-properties-expected.txt:
* platform/gtk/fast/dom/Window/window-properties-expected.txt:
* platform/mac/fast/dom/Window/window-properties-expected.txt:
* platform/qt/fast/dom/Window/window-properties-expected.txt:
* platform/win/fast/dom/Window/window-properties-expected.txt:

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

58 files changed:
LayoutTests/ChangeLog
LayoutTests/css3/viewport-relative-lengths/css3-viewport-relative-lengths-getStyle-expected.txt [new file with mode: 0644]
LayoutTests/css3/viewport-relative-lengths/css3-viewport-relative-lengths-getStyle.html [new file with mode: 0644]
LayoutTests/css3/viewport-relative-lengths/css3-viewport-relative-lengths-vh-absolute-expected.html [new file with mode: 0644]
LayoutTests/css3/viewport-relative-lengths/css3-viewport-relative-lengths-vh-absolute.html [new file with mode: 0644]
LayoutTests/css3/viewport-relative-lengths/css3-viewport-relative-lengths-vh-expected.html [new file with mode: 0644]
LayoutTests/css3/viewport-relative-lengths/css3-viewport-relative-lengths-vh.html [new file with mode: 0644]
LayoutTests/css3/viewport-relative-lengths/css3-viewport-relative-lengths-vmin-absolute-expected.html [new file with mode: 0644]
LayoutTests/css3/viewport-relative-lengths/css3-viewport-relative-lengths-vmin-absolute.html [new file with mode: 0644]
LayoutTests/css3/viewport-relative-lengths/css3-viewport-relative-lengths-vmin-expected.html [new file with mode: 0644]
LayoutTests/css3/viewport-relative-lengths/css3-viewport-relative-lengths-vmin.html [new file with mode: 0644]
LayoutTests/css3/viewport-relative-lengths/css3-viewport-relative-lengths-vw-absolute-expected.html [new file with mode: 0644]
LayoutTests/css3/viewport-relative-lengths/css3-viewport-relative-lengths-vw-absolute.html [new file with mode: 0644]
LayoutTests/css3/viewport-relative-lengths/css3-viewport-relative-lengths-vw-expected.html [new file with mode: 0644]
LayoutTests/css3/viewport-relative-lengths/css3-viewport-relative-lengths-vw.html [new file with mode: 0644]
LayoutTests/fast/dom/Window/window-properties-expected.txt
LayoutTests/platform/gtk/fast/dom/Window/window-properties-expected.txt
LayoutTests/platform/mac/fast/dom/Window/window-properties-expected.txt
LayoutTests/platform/qt/fast/dom/Window/window-properties-expected.txt
LayoutTests/platform/win/fast/dom/Window/window-properties-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceText.cpp
Source/WebCore/css/CSSComputedStyleDeclaration.cpp
Source/WebCore/css/CSSGrammar.y
Source/WebCore/css/CSSParser.cpp
Source/WebCore/css/CSSPrimitiveValue.cpp
Source/WebCore/css/CSSPrimitiveValue.h
Source/WebCore/css/CSSPrimitiveValue.idl
Source/WebCore/css/CSSPrimitiveValueMappings.h
Source/WebCore/css/CSSStyleApplyProperty.cpp
Source/WebCore/css/CSSStyleSelector.cpp
Source/WebCore/css/LengthFunctions.cpp
Source/WebCore/css/LengthFunctions.h
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/html/HTMLAreaElement.cpp
Source/WebCore/platform/Length.h
Source/WebCore/rendering/RenderBR.cpp
Source/WebCore/rendering/RenderBlock.cpp
Source/WebCore/rendering/RenderBox.cpp
Source/WebCore/rendering/RenderBoxModelObject.cpp
Source/WebCore/rendering/RenderFlexibleBox.cpp
Source/WebCore/rendering/RenderInline.cpp
Source/WebCore/rendering/RenderMenuList.cpp
Source/WebCore/rendering/RenderObject.cpp
Source/WebCore/rendering/RenderReplaced.cpp
Source/WebCore/rendering/RenderScrollbarPart.cpp
Source/WebCore/rendering/RenderTable.cpp
Source/WebCore/rendering/RenderTableCell.cpp
Source/WebCore/rendering/RenderTableSection.cpp
Source/WebCore/rendering/RenderText.h
Source/WebCore/rendering/RenderThemeMac.mm
Source/WebCore/rendering/RenderView.h
Source/WebCore/rendering/RenderWidget.cpp
Source/WebCore/rendering/RootInlineBox.cpp
Source/WebCore/rendering/style/RenderStyle.cpp
Source/WebCore/rendering/style/RenderStyle.h
Source/WebCore/rendering/svg/RenderSVGRoot.cpp

index 0c1d2f4..72b8f99 100644 (file)
@@ -1,3 +1,36 @@
+2012-03-27  Joe Thomas  <joethomas@motorola.com>
+
+        Implement vw/vh/vmin (viewport sizes) from CSS3 Values and Units
+        https://bugs.webkit.org/show_bug.cgi?id=27160
+
+        Reviewed by Antti Koivisto.
+
+        vw/vh/vmin are implemented as primitive length units. Added the parsing logic for these new units.
+        New Length types such as ViewportRelativeWidth, ViewportRelativeHeight and ViewportRelativeMin are added for these length units
+        and included the support for fetching the value of these relative units based on the current viewport size.
+
+        The specification related to this implementation is http://dev.w3.org/csswg/css3-values/#viewport-relative-lengths.
+
+        * css3/viewport-relative-lengths/css3-viewport-relative-lengths-getStyle-expected.txt: Added.
+        * css3/viewport-relative-lengths/css3-viewport-relative-lengths-getStyle.html: Added.
+        * css3/viewport-relative-lengths/css3-viewport-relative-lengths-vh-absolute-expected.html: Added.
+        * css3/viewport-relative-lengths/css3-viewport-relative-lengths-vh-absolute.html: Added.
+        * css3/viewport-relative-lengths/css3-viewport-relative-lengths-vh-expected.html: Added.
+        * css3/viewport-relative-lengths/css3-viewport-relative-lengths-vh.html: Added.
+        * css3/viewport-relative-lengths/css3-viewport-relative-lengths-vmin-absolute-expected.html: Added.
+        * css3/viewport-relative-lengths/css3-viewport-relative-lengths-vmin-absolute.html: Added.
+        * css3/viewport-relative-lengths/css3-viewport-relative-lengths-vmin-expected.html: Added.
+        * css3/viewport-relative-lengths/css3-viewport-relative-lengths-vmin.html: Added.
+        * css3/viewport-relative-lengths/css3-viewport-relative-lengths-vw-absolute-expected.html: Added.
+        * css3/viewport-relative-lengths/css3-viewport-relative-lengths-vw-absolute.html: Added.
+        * css3/viewport-relative-lengths/css3-viewport-relative-lengths-vw-expected.html: Added.
+        * css3/viewport-relative-lengths/css3-viewport-relative-lengths-vw.html: Added.
+        * fast/dom/Window/window-properties-expected.txt:
+        * platform/gtk/fast/dom/Window/window-properties-expected.txt:
+        * platform/mac/fast/dom/Window/window-properties-expected.txt:
+        * platform/qt/fast/dom/Window/window-properties-expected.txt:
+        * platform/win/fast/dom/Window/window-properties-expected.txt:
+
 2012-03-27  Andreas Kling  <kling@webkit.org>
 
         Unreviewed, skip fast/events/dropzone-005.html on mac-wk1.
diff --git a/LayoutTests/css3/viewport-relative-lengths/css3-viewport-relative-lengths-getStyle-expected.txt b/LayoutTests/css3/viewport-relative-lengths/css3-viewport-relative-lengths-getStyle-expected.txt
new file mode 100644 (file)
index 0000000..f34ab9a
--- /dev/null
@@ -0,0 +1,89 @@
+Test for Bug: 27160 - Implement vw/vh/vm (viewport sizes) from CSS 3 Values and Units
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Test for vw
+PASS style.getPropertyValue("height") is '240px'
+PASS style.getPropertyValue("width") is '240px'
+PASS style.getPropertyValue("font-size") is '24px'
+PASS style.getPropertyValue("line-height") is '32px'
+PASS style.getPropertyValue("text-indent") is '2vw'
+PASS style.getPropertyValue("margin-left") is '16px'
+PASS style.getPropertyValue("margin-right") is '16px'
+PASS style.getPropertyValue("margin-top") is '16px'
+PASS style.getPropertyValue("margin-bottom") is '16px'
+PASS style.getPropertyValue("border-top-left-radius") is '8px'
+PASS style.getPropertyValue("border-top-right-radius") is '8px'
+PASS style.getPropertyValue("border-bottom-left-radius") is '8px'
+PASS style.getPropertyValue("border-bottom-right-radius") is '8px'
+PASS style.getPropertyValue("min-height") is '10vw'
+PASS style.getPropertyValue("min-width") is '10vw'
+PASS style.getPropertyValue("max-height") is '60vw'
+PASS style.getPropertyValue("max-width") is '60vw'
+PASS style.getPropertyValue("top") is '80px'
+PASS style.getPropertyValue("bottom") is '80px'
+PASS style.getPropertyValue("left") is '80px'
+PASS style.getPropertyValue("right") is '80px'
+PASS style.getPropertyValue("padding-left") is '16px'
+PASS style.getPropertyValue("padding-right") is '16px'
+PASS style.getPropertyValue("padding-top") is '16px'
+PASS style.getPropertyValue("padding-bottom") is '16px'
+
+Test for vh
+PASS style.getPropertyValue("height") is '180px'
+PASS style.getPropertyValue("width") is '180px'
+PASS style.getPropertyValue("font-size") is '18px'
+PASS style.getPropertyValue("line-height") is '24px'
+PASS style.getPropertyValue("text-indent") is '2vh'
+PASS style.getPropertyValue("margin-left") is '12px'
+PASS style.getPropertyValue("margin-right") is '12px'
+PASS style.getPropertyValue("margin-top") is '12px'
+PASS style.getPropertyValue("margin-bottom") is '12px'
+PASS style.getPropertyValue("border-top-left-radius") is '6px'
+PASS style.getPropertyValue("border-top-right-radius") is '6px'
+PASS style.getPropertyValue("border-bottom-left-radius") is '6px'
+PASS style.getPropertyValue("border-bottom-right-radius") is '6px'
+PASS style.getPropertyValue("min-height") is '10vh'
+PASS style.getPropertyValue("min-width") is '10vh'
+PASS style.getPropertyValue("max-height") is '60vh'
+PASS style.getPropertyValue("max-width") is '60vh'
+PASS style.getPropertyValue("top") is '60px'
+PASS style.getPropertyValue("bottom") is '60px'
+PASS style.getPropertyValue("left") is '60px'
+PASS style.getPropertyValue("right") is '60px'
+PASS style.getPropertyValue("padding-left") is '12px'
+PASS style.getPropertyValue("padding-right") is '12px'
+PASS style.getPropertyValue("padding-top") is '12px'
+PASS style.getPropertyValue("padding-bottom") is '12px'
+
+Test for vmin
+PASS style.getPropertyValue("height") is '180px'
+PASS style.getPropertyValue("width") is '180px'
+PASS style.getPropertyValue("font-size") is '18px'
+PASS style.getPropertyValue("line-height") is '24px'
+PASS style.getPropertyValue("text-indent") is '2vmin'
+PASS style.getPropertyValue("margin-left") is '12px'
+PASS style.getPropertyValue("margin-right") is '12px'
+PASS style.getPropertyValue("margin-top") is '12px'
+PASS style.getPropertyValue("margin-bottom") is '12px'
+PASS style.getPropertyValue("border-top-left-radius") is '6px'
+PASS style.getPropertyValue("border-top-right-radius") is '6px'
+PASS style.getPropertyValue("border-bottom-left-radius") is '6px'
+PASS style.getPropertyValue("border-bottom-right-radius") is '6px'
+PASS style.getPropertyValue("min-height") is '10vmin'
+PASS style.getPropertyValue("min-width") is '10vmin'
+PASS style.getPropertyValue("max-height") is '60vmin'
+PASS style.getPropertyValue("max-width") is '60vmin'
+PASS style.getPropertyValue("top") is '60px'
+PASS style.getPropertyValue("bottom") is '60px'
+PASS style.getPropertyValue("left") is '60px'
+PASS style.getPropertyValue("right") is '60px'
+PASS style.getPropertyValue("padding-left") is '12px'
+PASS style.getPropertyValue("padding-right") is '12px'
+PASS style.getPropertyValue("padding-top") is '12px'
+PASS style.getPropertyValue("padding-bottom") is '12px'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/css3/viewport-relative-lengths/css3-viewport-relative-lengths-getStyle.html b/LayoutTests/css3/viewport-relative-lengths/css3-viewport-relative-lengths-getStyle.html
new file mode 100644 (file)
index 0000000..b8e552d
--- /dev/null
@@ -0,0 +1,215 @@
+<!DOCTYPE>
+<html>
+<style>
+ #element-container-vw {
+   background:green;
+   height:30vw;
+   width:30vw;
+   font-size:3vw;
+   line-height:4vw;
+   text-indent:2vw;
+   margin-left:2vw;
+   margin-right:2vw;
+   margin-top:2vw;
+   margin-bottom:2vw;
+   border-top-left-radius:1vw;
+   border-top-right-radius:1vw;
+   border-bottom-left-radius:1vw;
+   border-bottom-right-radius:1vw;
+   min-height:10vw;
+   min-width:10vw;
+   max-height:60vw;
+   max-width:60vw;
+ }
+
+ #element-container-absolute-vw {
+   background:green;
+   position:absolute;
+   top:10vw;
+   bottom:10vw;
+   left:10vw;
+   right:10vw;
+   padding-left:2vw;
+   padding-right:2vw;
+   padding-top:2vw;
+   padding-bottom:2vw;
+ }
+
+ #element-container-vh {
+   background:green;
+   height:30vh;
+   width:30vh;
+   font-size:3vh;
+   line-height:4vh;
+   text-indent:2vh;
+   margin-left:2vh;
+   margin-right:2vh;
+   margin-top:2vh;
+   margin-bottom:2vh;
+   border-top-left-radius:1vh;
+   border-top-right-radius:1vh;
+   border-bottom-left-radius:1vh;
+   border-bottom-right-radius:1vh;
+   min-height:10vh;
+   min-width:10vh;
+   max-height:60vh;
+   max-width:60vh;
+ }
+
+ #element-container-absolute-vh {
+   background:green;
+   position:absolute;
+   top:10vh;
+   bottom:10vh;
+   left:10vh;
+   right:10vh;
+   padding-left:2vh;
+   padding-right:2vh;
+   padding-top:2vh;
+   padding-bottom:2vh;
+ }
+
+ #element-container-vmin {
+   background:green;
+   height:30vmin;
+   width:30vmin;
+   font-size:3vmin;
+   line-height:4vmin;
+   text-indent:2vmin;
+   margin-left:2vmin;
+   margin-right:2vmin;
+   margin-top:2vmin;
+   margin-bottom:2vmin;
+   border-top-left-radius:1vmin;
+   border-top-right-radius:1vmin;
+   border-bottom-left-radius:1vmin;
+   border-bottom-right-radius:1vmin;
+   min-height:10vmin;
+   min-width:10vmin;
+   max-height:60vmin;
+   max-width:60vmin;
+ }
+
+ #element-container-absolute-vmin {
+   background:green;
+   position:absolute;
+   top:10vmin;
+   bottom:10vmin;
+   left:10vmin;
+   right:10vmin;
+   padding-left:2vmin;
+   padding-right:2vmin;
+   padding-top:2vmin;
+   padding-bottom:2vmin;
+ }
+</style>
+<div id="element-container-vw"></div>
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+<script>
+if (window.layoutTestController)
+    layoutTestController.dumpAsText();
+
+description("Test for Bug: 27160 - Implement vw/vh/vm (viewport sizes) from CSS 3 Values and Units");
+
+// These have to be global for the test helpers to see them.
+var element, style;
+
+function getTheStyle() {
+    debug("Test for vw")
+    element = document.getElementById("element-container-vw");
+    style = window.getComputedStyle(element,null);
+    var viewportWidth = window.innerWidth;
+    shouldBe('style.getPropertyValue("height")', "'" + Math.floor(30 * viewportWidth / 100) + "px'");
+    shouldBe('style.getPropertyValue("width")', "'" + Math.floor(30 * viewportWidth / 100) + "px'");
+    shouldBe('style.getPropertyValue("font-size")', "'" + Math.floor(3 * viewportWidth / 100) + "px'");
+    shouldBe('style.getPropertyValue("line-height")', "'" + Math.floor(4 * viewportWidth / 100) + "px'");
+    shouldBe('style.getPropertyValue("text-indent")', "'2vw'");
+    shouldBe('style.getPropertyValue("margin-left")', "'" + Math.floor(2 * viewportWidth / 100) + "px'");
+    shouldBe('style.getPropertyValue("margin-right")', "'" + Math.floor(2 * viewportWidth / 100) + "px'");
+    shouldBe('style.getPropertyValue("margin-top")', "'" + Math.floor(2 * viewportWidth / 100) + "px'");
+    shouldBe('style.getPropertyValue("margin-bottom")', "'" + Math.floor(2 * viewportWidth / 100) + "px'");
+    shouldBe('style.getPropertyValue("border-top-left-radius")', "'" + Math.floor(1 * viewportWidth / 100) + "px'");
+    shouldBe('style.getPropertyValue("border-top-right-radius")', "'" + Math.floor(1 * viewportWidth / 100) + "px'");
+    shouldBe('style.getPropertyValue("border-bottom-left-radius")', "'" + Math.floor(1 * viewportWidth / 100) + "px'");
+    shouldBe('style.getPropertyValue("border-bottom-right-radius")', "'" + Math.floor(1 * viewportWidth / 100) + "px'");
+    shouldBe('style.getPropertyValue("min-height")', "'10vw'");
+    shouldBe('style.getPropertyValue("min-width")', "'10vw'");
+    shouldBe('style.getPropertyValue("max-height")', "'60vw'");
+    shouldBe('style.getPropertyValue("max-width")', "'60vw'");
+    element.id = "element-container-absolute-vw";
+    shouldBe('style.getPropertyValue("top")', "'" + Math.floor(10 * viewportWidth / 100) + "px'");
+    shouldBe('style.getPropertyValue("bottom")', "'" + Math.floor(10 * viewportWidth / 100) + "px'");
+    shouldBe('style.getPropertyValue("left")', "'" + Math.floor(10 * viewportWidth / 100) + "px'");
+    shouldBe('style.getPropertyValue("right")', "'" + Math.floor(10 * viewportWidth / 100) + "px'");
+    shouldBe('style.getPropertyValue("padding-left")', "'" + Math.floor(2 * viewportWidth / 100) + "px'");
+    shouldBe('style.getPropertyValue("padding-right")', "'" + Math.floor(2 * viewportWidth / 100) + "px'");
+    shouldBe('style.getPropertyValue("padding-top")', "'" + Math.floor(2 * viewportWidth / 100) + "px'");
+    shouldBe('style.getPropertyValue("padding-bottom")', "'" + Math.floor(2 * viewportWidth / 100) + "px'");
+
+    debug("\nTest for vh")
+    element.id = "element-container-vh";
+    style = window.getComputedStyle(element,null);
+    var viewportHeight = window.innerHeight;
+    shouldBe('style.getPropertyValue("height")', "'" + Math.floor(30 * viewportHeight / 100) + "px'");
+    shouldBe('style.getPropertyValue("width")', "'" + Math.floor(30 * viewportHeight / 100) + "px'");
+    shouldBe('style.getPropertyValue("font-size")', "'" + Math.floor(3 * viewportHeight / 100) + "px'");
+    shouldBe('style.getPropertyValue("line-height")', "'" + Math.floor(4 * viewportHeight / 100) + "px'");
+    shouldBe('style.getPropertyValue("text-indent")', "'2vh'");
+    shouldBe('style.getPropertyValue("margin-left")', "'" + Math.floor(2 * viewportHeight / 100) + "px'");
+    shouldBe('style.getPropertyValue("margin-right")', "'" + Math.floor(2 * viewportHeight / 100) + "px'");
+    shouldBe('style.getPropertyValue("margin-top")', "'" + Math.floor(2 * viewportHeight / 100) + "px'");
+    shouldBe('style.getPropertyValue("margin-bottom")', "'" + Math.floor(2 * viewportHeight / 100) + "px'");
+    shouldBe('style.getPropertyValue("border-top-left-radius")', "'" + Math.floor(1 * viewportHeight / 100) + "px'");
+    shouldBe('style.getPropertyValue("border-top-right-radius")', "'" + Math.floor(1 * viewportHeight / 100) + "px'");
+    shouldBe('style.getPropertyValue("border-bottom-left-radius")', "'" + Math.floor(1 * viewportHeight / 100) + "px'");
+    shouldBe('style.getPropertyValue("border-bottom-right-radius")', "'" + Math.floor(1 * viewportHeight / 100) + "px'");
+    shouldBe('style.getPropertyValue("min-height")', "'10vh'");
+    shouldBe('style.getPropertyValue("min-width")', "'10vh'");
+    shouldBe('style.getPropertyValue("max-height")', "'60vh'");
+    shouldBe('style.getPropertyValue("max-width")', "'60vh'");
+    element.id = "element-container-absolute-vh";
+    shouldBe('style.getPropertyValue("top")', "'" + Math.floor(10 * viewportHeight / 100) + "px'");
+    shouldBe('style.getPropertyValue("bottom")', "'" + Math.floor(10 * viewportHeight / 100) + "px'");
+    shouldBe('style.getPropertyValue("left")', "'" + Math.floor(10 * viewportHeight / 100) + "px'");
+    shouldBe('style.getPropertyValue("right")', "'" + Math.floor(10 * viewportHeight / 100) + "px'");
+    shouldBe('style.getPropertyValue("padding-left")', "'" + Math.floor(2 * viewportHeight / 100) + "px'");
+    shouldBe('style.getPropertyValue("padding-right")', "'" + Math.floor(2 * viewportHeight / 100) + "px'");
+    shouldBe('style.getPropertyValue("padding-top")', "'" + Math.floor(2 * viewportHeight / 100) + "px'");
+    shouldBe('style.getPropertyValue("padding-bottom")', "'" + Math.floor(2 * viewportHeight / 100) + "px'");
+
+    debug("\nTest for vmin")
+    element.id = "element-container-vmin";
+    style = window.getComputedStyle(element,null);
+    var viewportMinLength = Math.min(window.innerWidth, window.innerHeight);
+    shouldBe('style.getPropertyValue("height")', "'" + Math.floor(30 * viewportMinLength / 100) + "px'");
+    shouldBe('style.getPropertyValue("width")', "'" + Math.floor(30 * viewportMinLength / 100) + "px'");
+    shouldBe('style.getPropertyValue("font-size")', "'" + Math.floor(3 * viewportMinLength / 100) + "px'");
+    shouldBe('style.getPropertyValue("line-height")', "'" + Math.floor(4 * viewportMinLength / 100) + "px'");
+    shouldBe('style.getPropertyValue("text-indent")', "'2vmin'");
+    shouldBe('style.getPropertyValue("margin-left")', "'" + Math.floor(2 * viewportMinLength / 100) + "px'");
+    shouldBe('style.getPropertyValue("margin-right")', "'" + Math.floor(2 * viewportMinLength / 100) + "px'");
+    shouldBe('style.getPropertyValue("margin-top")', "'" + Math.floor(2 * viewportMinLength / 100) + "px'");
+    shouldBe('style.getPropertyValue("margin-bottom")', "'" + Math.floor(2 * viewportMinLength / 100) + "px'");
+    shouldBe('style.getPropertyValue("border-top-left-radius")', "'" + Math.floor(1 * viewportMinLength / 100) + "px'");
+    shouldBe('style.getPropertyValue("border-top-right-radius")', "'" + Math.floor(1 * viewportMinLength / 100) + "px'");
+    shouldBe('style.getPropertyValue("border-bottom-left-radius")', "'" + Math.floor(1 * viewportMinLength / 100) + "px'");
+    shouldBe('style.getPropertyValue("border-bottom-right-radius")', "'" + Math.floor(1 * viewportMinLength / 100) + "px'");
+    shouldBe('style.getPropertyValue("min-height")', "'10vmin'");
+    shouldBe('style.getPropertyValue("min-width")', "'10vmin'");
+    shouldBe('style.getPropertyValue("max-height")', "'60vmin'");
+    shouldBe('style.getPropertyValue("max-width")', "'60vmin'");
+    element.id = "element-container-absolute-vmin";
+    shouldBe('style.getPropertyValue("top")', "'" + Math.floor(10 * viewportMinLength / 100) + "px'");
+    shouldBe('style.getPropertyValue("bottom")', "'" + Math.floor(10 * viewportMinLength / 100) + "px'");
+    shouldBe('style.getPropertyValue("left")', "'" + Math.floor(10 * viewportMinLength / 100) + "px'");
+    shouldBe('style.getPropertyValue("right")', "'" + Math.floor(10 * viewportMinLength / 100) + "px'");
+    shouldBe('style.getPropertyValue("padding-left")', "'" + Math.floor(2 * viewportMinLength / 100) + "px'");
+    shouldBe('style.getPropertyValue("padding-right")', "'" + Math.floor(2 * viewportMinLength / 100) + "px'");
+    shouldBe('style.getPropertyValue("padding-top")', "'" + Math.floor(2 * viewportMinLength / 100) + "px'");
+    shouldBe('style.getPropertyValue("padding-bottom")', "'" + Math.floor(2 * viewportMinLength / 100) + "px'");
+}
+getTheStyle();
+</script>
+<script src="../../fast/js/resources/js-test-post.js"></script>
+</html>
diff --git a/LayoutTests/css3/viewport-relative-lengths/css3-viewport-relative-lengths-vh-absolute-expected.html b/LayoutTests/css3/viewport-relative-lengths/css3-viewport-relative-lengths-vh-absolute-expected.html
new file mode 100644 (file)
index 0000000..202b045
--- /dev/null
@@ -0,0 +1,21 @@
+<!DOCTYPE>
+<html>
+<style>
+ #element-container-absolute-vh {
+   background:green;
+   position:absolute;
+ }
+</style>
+<div id="element-container-absolute-vh">TEST PASSED</div>
+<script>
+function applyStyle() {
+    var viewportHeight = window.innerHeight;
+    var elementStyle = document.getElementById("element-container-absolute-vh").style;
+    elementStyle.top = Math.floor(10 * viewportHeight / 100) + "px";
+    elementStyle.bottom = Math.floor(10 * viewportHeight / 100) + "px";
+    elementStyle.left = Math.floor(10 * viewportHeight / 100) + "px";
+    elementStyle.right = Math.floor(10 * viewportHeight / 100) + "px";
+}
+applyStyle();
+</script>
+</html>
diff --git a/LayoutTests/css3/viewport-relative-lengths/css3-viewport-relative-lengths-vh-absolute.html b/LayoutTests/css3/viewport-relative-lengths/css3-viewport-relative-lengths-vh-absolute.html
new file mode 100644 (file)
index 0000000..504a882
--- /dev/null
@@ -0,0 +1,14 @@
+<!DOCTYPE>
+<html>
+<style>
+ #element-container-absolute-vh {
+   background:green;
+   position:absolute;
+   top:10vh;
+   bottom:10vh;
+   left:10vh;
+   right:10vh;
+ }
+</style>
+<div id="element-container-absolute-vh">TEST PASSED</div>
+</html>
diff --git a/LayoutTests/css3/viewport-relative-lengths/css3-viewport-relative-lengths-vh-expected.html b/LayoutTests/css3/viewport-relative-lengths/css3-viewport-relative-lengths-vh-expected.html
new file mode 100644 (file)
index 0000000..15f5d06
--- /dev/null
@@ -0,0 +1,37 @@
+<!DOCTYPE>
+<html>
+<style>
+ #element-container-vh {
+   background:green;
+ }
+</style>
+<div id="element-container-vh">TEST PASSED</div>
+<script>
+function applyStyle() {
+    var viewportHeight = window.innerHeight;
+    var elementStyle = document.getElementById("element-container-vh").style;
+    elementStyle.height = Math.floor(30 * viewportHeight / 100) + "px";
+    elementStyle.width = Math.floor(30 * viewportHeight / 100) + "px";
+    elementStyle.fontSize = Math.floor(3 * viewportHeight / 100) + "px";
+    elementStyle.lineHeight = Math.floor(4 * viewportHeight / 100) + "px";
+    elementStyle.textIndent = Math.floor(2 * viewportHeight / 100) + "px";
+    elementStyle.marginLeft = Math.floor(2 * viewportHeight / 100) + "px";
+    elementStyle.marginRight = Math.floor(2 * viewportHeight / 100) + "px";
+    elementStyle.marginTop = Math.floor(2 * viewportHeight / 100) + "px";
+    elementStyle.marginBottom = Math.floor(2 * viewportHeight / 100) + "px";
+    elementStyle.borderTopLeftRadius = Math.floor(1 * viewportHeight / 100) + "px";
+    elementStyle.borderTopRightRadius = Math.floor(1 * viewportHeight / 100) + "px";
+    elementStyle.borderBottomLeftRadius = Math.floor(1 * viewportHeight / 100) + "px";
+    elementStyle.borderBottomRightRadius = Math.floor(1 * viewportHeight / 100) + "px";
+    elementStyle.paddingLeft = Math.floor(2 * viewportHeight / 100) + "px";
+    elementStyle.paddingRight = Math.floor(2 * viewportHeight / 100) + "px";
+    elementStyle.paddingTop = Math.floor(2 * viewportHeight / 100) + "px";
+    elementStyle.paddingBottom = Math.floor(2 * viewportHeight / 100) + "px";
+    elementStyle.minHeight = Math.floor(10 * viewportHeight / 100) + "px";
+    elementStyle.minWidth = Math.floor(10 * viewportHeight / 100) + "px";
+    elementStyle.maxHeight = Math.floor(60 * viewportHeight / 100) + "px";
+    elementStyle.maxWidth = Math.floor(60 * viewportHeight / 100) + "px";
+}
+applyStyle();
+</script>
+</html>
diff --git a/LayoutTests/css3/viewport-relative-lengths/css3-viewport-relative-lengths-vh.html b/LayoutTests/css3/viewport-relative-lengths/css3-viewport-relative-lengths-vh.html
new file mode 100644 (file)
index 0000000..3241f23
--- /dev/null
@@ -0,0 +1,30 @@
+<!DOCTYPE>
+<html>
+<style>
+ #element-container-vh {
+   background:green;
+   height:30vh;
+   width:30vh;
+   font-size:3vh;
+   line-height:4vh;
+   text-indent:2vh;
+   margin-left:2vh;
+   margin-right:2vh;
+   margin-top:2vh;
+   margin-bottom:2vh;
+   border-top-left-radius:1vh;
+   border-top-right-radius:1vh;
+   border-bottom-left-radius:1vh;
+   border-bottom-right-radius:1vh;
+   padding-left:2vh;
+   padding-right:2vh;
+   padding-top:2vh;
+   padding-bottom:2vh;
+   min-height:10vh;
+   min-width:10vh;
+   max-height:60vh;
+   max-width:60vh;
+ }
+</style>
+<div id="element-container-vh">TEST PASSED</div>
+</html>
diff --git a/LayoutTests/css3/viewport-relative-lengths/css3-viewport-relative-lengths-vmin-absolute-expected.html b/LayoutTests/css3/viewport-relative-lengths/css3-viewport-relative-lengths-vmin-absolute-expected.html
new file mode 100644 (file)
index 0000000..f3bf497
--- /dev/null
@@ -0,0 +1,21 @@
+<!DOCTYPE>
+<html>
+<style>
+ #element-container-absolute-vmin {
+   background:green;
+   position:absolute;
+ }
+</style>
+<div id="element-container-absolute-vmin">TEST PASSED</div>
+<script>
+function applyStyle() {
+    var viewportMinLength = Math.min(window.innerWidth, window.innerHeight);
+    var elementStyle = document.getElementById("element-container-absolute-vmin").style;
+    elementStyle.top = Math.floor(10 * viewportMinLength / 100) + "px";
+    elementStyle.bottom = Math.floor(10 * viewportMinLength / 100) + "px";
+    elementStyle.left = Math.floor(10 * viewportMinLength / 100) + "px";
+    elementStyle.right = Math.floor(10 * viewportMinLength / 100) + "px";
+}
+applyStyle();
+</script>
+</html>
diff --git a/LayoutTests/css3/viewport-relative-lengths/css3-viewport-relative-lengths-vmin-absolute.html b/LayoutTests/css3/viewport-relative-lengths/css3-viewport-relative-lengths-vmin-absolute.html
new file mode 100644 (file)
index 0000000..b0c007a
--- /dev/null
@@ -0,0 +1,14 @@
+<!DOCTYPE>
+<html>
+<style>
+ #element-container-absolute-vmin {
+   background:green;
+   position:absolute;
+   top:10vmin;
+   bottom:10vmin;
+   left:10vmin;
+   right:10vmin;
+ }
+</style>
+<div id="element-container-absolute-vmin">TEST PASSED</div>
+</html>
diff --git a/LayoutTests/css3/viewport-relative-lengths/css3-viewport-relative-lengths-vmin-expected.html b/LayoutTests/css3/viewport-relative-lengths/css3-viewport-relative-lengths-vmin-expected.html
new file mode 100644 (file)
index 0000000..e22ef2f
--- /dev/null
@@ -0,0 +1,37 @@
+<!DOCTYPE>
+<html>
+<style>
+ #element-container-vmin {
+   background:green;
+ }
+</style>
+<div id="element-container-vmin">TEST PASSED</div>
+<script>
+function applyStyle() {
+    var viewportMinLength = Math.min(window.innerWidth, window.innerHeight);
+    var elementStyle = document.getElementById("element-container-vmin").style;
+    elementStyle.height = Math.floor(30 * viewportMinLength / 100) + "px";
+    elementStyle.width = Math.floor(30 * viewportMinLength / 100) + "px";
+    elementStyle.fontSize = Math.floor(3 * viewportMinLength / 100) + "px";
+    elementStyle.lineHeight = Math.floor(4 * viewportMinLength / 100) + "px";
+    elementStyle.textIndent = Math.floor(2 * viewportMinLength / 100) + "px";
+    elementStyle.marginLeft = Math.floor(2 * viewportMinLength / 100) + "px";
+    elementStyle.marginRight = Math.floor(2 * viewportMinLength / 100) + "px";
+    elementStyle.marginTop = Math.floor(2 * viewportMinLength / 100) + "px";
+    elementStyle.marginBottom = Math.floor(2 * viewportMinLength / 100) + "px";
+    elementStyle.borderTopLeftRadius = Math.floor(1 * viewportMinLength / 100) + "px";
+    elementStyle.borderTopRightRadius = Math.floor(1 * viewportMinLength / 100) + "px";
+    elementStyle.borderBottomLeftRadius = Math.floor(1 * viewportMinLength / 100) + "px";
+    elementStyle.borderBottomRightRadius = Math.floor(1 * viewportMinLength / 100) + "px";
+    elementStyle.paddingLeft = Math.floor(2 * viewportMinLength / 100) + "px";
+    elementStyle.paddingRight = Math.floor(2 * viewportMinLength / 100) + "px";
+    elementStyle.paddingTop = Math.floor(2 * viewportMinLength / 100) + "px";
+    elementStyle.paddingBottom = Math.floor(2 * viewportMinLength / 100) + "px";
+    elementStyle.minHeight = Math.floor(10 * viewportMinLength / 100) + "px";
+    elementStyle.minWidth = Math.floor(10 * viewportMinLength / 100) + "px";
+    elementStyle.maxHeight = Math.floor(60 * viewportMinLength / 100) + "px";
+    elementStyle.maxWidth = Math.floor(60 * viewportMinLength / 100) + "px";
+}
+applyStyle();
+</script>
+</html>
diff --git a/LayoutTests/css3/viewport-relative-lengths/css3-viewport-relative-lengths-vmin.html b/LayoutTests/css3/viewport-relative-lengths/css3-viewport-relative-lengths-vmin.html
new file mode 100644 (file)
index 0000000..0cfa7b9
--- /dev/null
@@ -0,0 +1,30 @@
+<!DOCTYPE>
+<html>
+<style>
+ #element-container-vmin {
+   background:green;
+   height:30vmin;
+   width:30vmin;
+   font-size:3vmin;
+   line-height:4vmin;
+   text-indent:2vmin;
+   margin-left:2vmin;
+   margin-right:2vmin;
+   margin-top:2vmin;
+   margin-bottom:2vmin;
+   border-top-left-radius:1vmin;
+   border-top-right-radius:1vmin;
+   border-bottom-left-radius:1vmin;
+   border-bottom-right-radius:1vmin;
+   padding-left:2vmin;
+   padding-right:2vmin;
+   padding-top:2vmin;
+   padding-bottom:2vmin;
+   min-height:10vmin;
+   min-width:10vmin;
+   max-height:60vmin;
+   max-width:60vmin;
+ }
+</style>
+<div id="element-container-vmin">TEST PASSED</div>
+</html>
diff --git a/LayoutTests/css3/viewport-relative-lengths/css3-viewport-relative-lengths-vw-absolute-expected.html b/LayoutTests/css3/viewport-relative-lengths/css3-viewport-relative-lengths-vw-absolute-expected.html
new file mode 100644 (file)
index 0000000..14e37c6
--- /dev/null
@@ -0,0 +1,21 @@
+<!DOCTYPE>
+<html>
+<style>
+ #element-container-absolute-vw {
+   background:green;
+   position:absolute;
+ }
+</style>
+<div id="element-container-absolute-vw">TEST PASSED</div>
+<script>
+function applyStyle() {
+    var viewportWidth = window.innerWidth;
+    var elementStyle = document.getElementById("element-container-absolute-vw").style;
+    elementStyle.top = Math.floor(10 * viewportWidth / 100) + "px";
+    elementStyle.bottom = Math.floor(10 * viewportWidth / 100) + "px";
+    elementStyle.left = Math.floor(10 * viewportWidth / 100) + "px";
+    elementStyle.right = Math.floor(10 * viewportWidth / 100) + "px";
+}
+applyStyle();
+</script>
+</html>
diff --git a/LayoutTests/css3/viewport-relative-lengths/css3-viewport-relative-lengths-vw-absolute.html b/LayoutTests/css3/viewport-relative-lengths/css3-viewport-relative-lengths-vw-absolute.html
new file mode 100644 (file)
index 0000000..aa756e6
--- /dev/null
@@ -0,0 +1,14 @@
+<!DOCTYPE>
+<html>
+<style>
+ #element-container-absolute-vw {
+   background:green;
+   position:absolute;
+   top:10vw;
+   bottom:10vw;
+   left:10vw;
+   right:10vw;
+ }
+</style>
+<div id="element-container-absolute-vw">TEST PASSED</div>
+</html>
diff --git a/LayoutTests/css3/viewport-relative-lengths/css3-viewport-relative-lengths-vw-expected.html b/LayoutTests/css3/viewport-relative-lengths/css3-viewport-relative-lengths-vw-expected.html
new file mode 100644 (file)
index 0000000..9a5bfd8
--- /dev/null
@@ -0,0 +1,37 @@
+<!DOCTYPE>
+<html>
+<style>
+ #element-container-vw {
+   background:green;
+ }
+</style>
+<div id="element-container-vw">TEST PASSED</div>
+<script>
+function applyStyle() {
+    var viewportWidth = window.innerWidth;
+    var elementStyle = document.getElementById("element-container-vw").style;
+    elementStyle.height = Math.floor(30 * viewportWidth / 100) + "px";
+    elementStyle.width = Math.floor(30 * viewportWidth / 100) + "px";
+    elementStyle.fontSize = Math.floor(3 * viewportWidth / 100) + "px";
+    elementStyle.lineHeight = Math.floor(3 * viewportWidth / 100) + "px";
+    elementStyle.textIndent = Math.floor(2 * viewportWidth / 100) + "px";
+    elementStyle.marginLeft = Math.floor(2 * viewportWidth / 100) + "px";
+    elementStyle.marginRight = Math.floor(2 * viewportWidth / 100) + "px";
+    elementStyle.marginTop = Math.floor(2 * viewportWidth / 100) + "px";
+    elementStyle.marginBottom = Math.floor(2 * viewportWidth / 100) + "px";
+    elementStyle.borderTopLeftRadius = Math.floor(1 * viewportWidth / 100) + "px";
+    elementStyle.borderTopRightRadius = Math.floor(1 * viewportWidth / 100) + "px";
+    elementStyle.borderBottomLeftRadius = Math.floor(1 * viewportWidth / 100) + "px";
+    elementStyle.borderBottomRightRadius = Math.floor(1 * viewportWidth / 100) + "px";
+    elementStyle.paddingLeft = Math.floor(2 * viewportWidth / 100) + "px";
+    elementStyle.paddingRight = Math.floor(2 * viewportWidth / 100) + "px";
+    elementStyle.paddingTop = Math.floor(2 * viewportWidth / 100) + "px";
+    elementStyle.paddingBottom = Math.floor(2 * viewportWidth / 100) + "px";
+    elementStyle.minHeight = Math.floor(10 * viewportWidth / 100) + "px";
+    elementStyle.minWidth = Math.floor(10 * viewportWidth / 100) + "px";
+    elementStyle.maxHeight = Math.floor(60 * viewportWidth / 100) + "px";
+    elementStyle.maxWidth = Math.floor(60 * viewportWidth / 100) + "px";
+}
+applyStyle();
+</script>
+</html>
diff --git a/LayoutTests/css3/viewport-relative-lengths/css3-viewport-relative-lengths-vw.html b/LayoutTests/css3/viewport-relative-lengths/css3-viewport-relative-lengths-vw.html
new file mode 100644 (file)
index 0000000..d09cbb3
--- /dev/null
@@ -0,0 +1,30 @@
+<!DOCTYPE>
+<html>
+<style>
+ #element-container-vw {
+   background:green;
+   height:30vw;
+   width:30vw;
+   font-size:3vw;
+   line-height:3vw;
+   text-indent:2vw;
+   margin-left:2vw;
+   margin-right:2vw;
+   margin-top:2vw;
+   margin-bottom:2vw;
+   border-top-left-radius:1vw;
+   border-top-right-radius:1vw;
+   border-bottom-left-radius:1vw;
+   border-bottom-right-radius:1vw;
+   padding-left:2vw;
+   padding-right:2vw;
+   padding-top:2vw;
+   padding-bottom:2vw;
+   min-height:10vw;
+   min-width:10vw;
+   max-height:60vw;
+   max-width:60vw;
+ }
+</style>
+<div id="element-container-vw">TEST PASSED</div>
+</html>
index 34e04a4..13a7b0d 100644 (file)
@@ -289,6 +289,9 @@ window.CSSPrimitiveValue.CSS_S [number]
 window.CSSPrimitiveValue.CSS_STRING [number]
 window.CSSPrimitiveValue.CSS_UNKNOWN [number]
 window.CSSPrimitiveValue.CSS_URI [number]
+window.CSSPrimitiveValue.CSS_VH [number]
+window.CSSPrimitiveValue.CSS_VMIN [number]
+window.CSSPrimitiveValue.CSS_VW [number]
 window.CSSPrimitiveValue.prototype [object CSSPrimitiveValuePrototype]
 window.CSSPrimitiveValue.prototype.CSS_ATTR [number]
 window.CSSPrimitiveValue.prototype.CSS_CM [number]
@@ -320,6 +323,9 @@ window.CSSPrimitiveValue.prototype.CSS_STRING [number]
 window.CSSPrimitiveValue.prototype.CSS_UNKNOWN [number]
 window.CSSPrimitiveValue.prototype.CSS_URI [number]
 window.CSSPrimitiveValue.prototype.CSS_VALUE_LIST [number]
+window.CSSPrimitiveValue.prototype.CSS_VH [number]
+window.CSSPrimitiveValue.prototype.CSS_VMIN [number]
+window.CSSPrimitiveValue.prototype.CSS_VW [number]
 window.CSSPrimitiveValue.prototype.getCounterValue [function]
 window.CSSPrimitiveValue.prototype.getFloatValue [function]
 window.CSSPrimitiveValue.prototype.getRGBColorValue [function]
index 87beab6..7a6a704 100644 (file)
@@ -292,6 +292,9 @@ window.CSSPrimitiveValue.CSS_S [number]
 window.CSSPrimitiveValue.CSS_STRING [number]
 window.CSSPrimitiveValue.CSS_UNKNOWN [number]
 window.CSSPrimitiveValue.CSS_URI [number]
+window.CSSPrimitiveValue.CSS_VH [number]
+window.CSSPrimitiveValue.CSS_VMIN [number]
+window.CSSPrimitiveValue.CSS_VW [number]
 window.CSSPrimitiveValue.prototype [object CSSPrimitiveValuePrototype]
 window.CSSPrimitiveValue.prototype.CSS_ATTR [number]
 window.CSSPrimitiveValue.prototype.CSS_CM [number]
@@ -323,6 +326,9 @@ window.CSSPrimitiveValue.prototype.CSS_STRING [number]
 window.CSSPrimitiveValue.prototype.CSS_UNKNOWN [number]
 window.CSSPrimitiveValue.prototype.CSS_URI [number]
 window.CSSPrimitiveValue.prototype.CSS_VALUE_LIST [number]
+window.CSSPrimitiveValue.prototype.CSS_VH [number]
+window.CSSPrimitiveValue.prototype.CSS_VMIN [number]
+window.CSSPrimitiveValue.prototype.CSS_VW [number]
 window.CSSPrimitiveValue.prototype.getCounterValue [function]
 window.CSSPrimitiveValue.prototype.getFloatValue [function]
 window.CSSPrimitiveValue.prototype.getRGBColorValue [function]
index 9a89ae8..3949fd3 100644 (file)
@@ -317,6 +317,9 @@ window.CSSPrimitiveValue.CSS_S [number]
 window.CSSPrimitiveValue.CSS_STRING [number]
 window.CSSPrimitiveValue.CSS_UNKNOWN [number]
 window.CSSPrimitiveValue.CSS_URI [number]
+window.CSSPrimitiveValue.CSS_VH [number]
+window.CSSPrimitiveValue.CSS_VMIN [number]
+window.CSSPrimitiveValue.CSS_VW [number]
 window.CSSPrimitiveValue.prototype [object CSSPrimitiveValuePrototype]
 window.CSSPrimitiveValue.prototype.CSS_ATTR [number]
 window.CSSPrimitiveValue.prototype.CSS_CM [number]
@@ -348,6 +351,9 @@ window.CSSPrimitiveValue.prototype.CSS_STRING [number]
 window.CSSPrimitiveValue.prototype.CSS_UNKNOWN [number]
 window.CSSPrimitiveValue.prototype.CSS_URI [number]
 window.CSSPrimitiveValue.prototype.CSS_VALUE_LIST [number]
+window.CSSPrimitiveValue.prototype.CSS_VH [number]
+window.CSSPrimitiveValue.prototype.CSS_VMIN [number]
+window.CSSPrimitiveValue.prototype.CSS_VW [number]
 window.CSSPrimitiveValue.prototype.getCounterValue [function]
 window.CSSPrimitiveValue.prototype.getFloatValue [function]
 window.CSSPrimitiveValue.prototype.getRGBColorValue [function]
index 6254130..90dc850 100644 (file)
@@ -288,6 +288,9 @@ window.CSSPrimitiveValue.CSS_S [number]
 window.CSSPrimitiveValue.CSS_STRING [number]
 window.CSSPrimitiveValue.CSS_UNKNOWN [number]
 window.CSSPrimitiveValue.CSS_URI [number]
+window.CSSPrimitiveValue.CSS_VH [number]
+window.CSSPrimitiveValue.CSS_VMIN [number]
+window.CSSPrimitiveValue.CSS_VW [number]
 window.CSSPrimitiveValue.prototype [object CSSPrimitiveValuePrototype]
 window.CSSPrimitiveValue.prototype.CSS_ATTR [number]
 window.CSSPrimitiveValue.prototype.CSS_CM [number]
@@ -319,6 +322,9 @@ window.CSSPrimitiveValue.prototype.CSS_STRING [number]
 window.CSSPrimitiveValue.prototype.CSS_UNKNOWN [number]
 window.CSSPrimitiveValue.prototype.CSS_URI [number]
 window.CSSPrimitiveValue.prototype.CSS_VALUE_LIST [number]
+window.CSSPrimitiveValue.prototype.CSS_VH [number]
+window.CSSPrimitiveValue.prototype.CSS_VMIN [number]
+window.CSSPrimitiveValue.prototype.CSS_VW [number]
 window.CSSPrimitiveValue.prototype.getCounterValue [function]
 window.CSSPrimitiveValue.prototype.getFloatValue [function]
 window.CSSPrimitiveValue.prototype.getRGBColorValue [function]
index e1b4075..c79b270 100644 (file)
@@ -289,6 +289,9 @@ window.CSSPrimitiveValue.CSS_S [number]
 window.CSSPrimitiveValue.CSS_STRING [number]
 window.CSSPrimitiveValue.CSS_UNKNOWN [number]
 window.CSSPrimitiveValue.CSS_URI [number]
+window.CSSPrimitiveValue.CSS_VH [number]
+window.CSSPrimitiveValue.CSS_VMIN [number]
+window.CSSPrimitiveValue.CSS_VW [number]
 window.CSSPrimitiveValue.prototype [object CSSPrimitiveValuePrototype]
 window.CSSPrimitiveValue.prototype.CSS_ATTR [number]
 window.CSSPrimitiveValue.prototype.CSS_CM [number]
@@ -320,6 +323,9 @@ window.CSSPrimitiveValue.prototype.CSS_STRING [number]
 window.CSSPrimitiveValue.prototype.CSS_UNKNOWN [number]
 window.CSSPrimitiveValue.prototype.CSS_URI [number]
 window.CSSPrimitiveValue.prototype.CSS_VALUE_LIST [number]
+window.CSSPrimitiveValue.prototype.CSS_VH [number]
+window.CSSPrimitiveValue.prototype.CSS_VMIN [number]
+window.CSSPrimitiveValue.prototype.CSS_VW [number]
 window.CSSPrimitiveValue.prototype.getCounterValue [function]
 window.CSSPrimitiveValue.prototype.getFloatValue [function]
 window.CSSPrimitiveValue.prototype.getRGBColorValue [function]
index 38d50ff..f99302b 100644 (file)
@@ -1,3 +1,160 @@
+2012-03-27  Joe Thomas  <joethomas@motorola.com>
+
+        Implement vw/vh/vmin (viewport sizes) from CSS3 Values and Units
+        https://bugs.webkit.org/show_bug.cgi?id=27160
+
+        Reviewed by Antti Koivisto.
+
+        vw/vh/vmin are implemented as primitive length units. Added the parsing logic for these new units.
+        New Length types such as ViewportRelativeWidth, ViewportRelativeHeight and ViewportRelativeMin are added for these length units
+        and included the support for fetching the value of these relative units based on the current viewport size.
+
+        The specification related to this implementation is http://dev.w3.org/csswg/css3-values/#viewport-relative-lengths.
+
+        Tests: css3/viewport-relative-lengths/css3-viewport-relative-lengths-getStyle.html
+               css3/viewport-relative-lengths/css3-viewport-relative-lengths-vh-absolute.html
+               css3/viewport-relative-lengths/css3-viewport-relative-lengths-vh.html
+               css3/viewport-relative-lengths/css3-viewport-relative-lengths-vmin-absolute.html
+               css3/viewport-relative-lengths/css3-viewport-relative-lengths-vmin.html
+               css3/viewport-relative-lengths/css3-viewport-relative-lengths-vw-absolute.html
+               css3/viewport-relative-lengths/css3-viewport-relative-lengths-vw.html
+
+        * accessibility/gtk/WebKitAccessibleInterfaceText.cpp: Modified to support viewport relative Length types.
+        (getAttributeSetForAccessibilityObject):
+        * css/CSSComputedStyleDeclaration.cpp: Ditto.
+        (WebCore::getPositionOffsetValue):
+        (WebCore::getBorderRadiusCornerValues):
+        (WebCore::getBorderRadiusCornerValue):
+        (WebCore::getBorderRadiusShorthandValue):
+        (WebCore::lineHeightFromStyle):
+        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
+        * css/CSSGrammar.y: Added vw/vh/vmin support.
+        * css/CSSParser.cpp: Parsing of relative units and creation of CSSPrimitiveValue.
+        (WebCore::CSSParser::validUnit): Added vw/vh/vmin to the valid units.
+        (WebCore::CSSParser::createPrimitiveNumericValue): Added vw/vh/vmin as valid primitive units.
+        (WebCore::unitFromString):
+        (WebCore::CSSParser::parseValidPrimitive): Creation of CSSPrimitiveValue for vw/vh/vmin.
+        (WebCore::CSSParser::detectNumberToken): Parsing the vw/vh/vmin tokens.
+        * css/CSSPrimitiveValue.cpp:
+        (WebCore::isValidCSSUnitTypeForDoubleConversion): Added support for vw/vh/vmin.
+        (WebCore::unitCategory): Ditto.
+        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
+        (WebCore::CSSPrimitiveValue::canonicalUnitTypeForCategory): Added support for vw/vh/vmin.
+        (WebCore::CSSPrimitiveValue::customCssText): Ditto.
+        (WebCore::CSSPrimitiveValue::viewportRelativeLength): Function to create the Length structure for the viewport-relative unit types.
+        (WebCore):
+        * css/CSSPrimitiveValue.h:
+        (WebCore::CSSPrimitiveValue::isViewportRelativeLength): Checks whether the primitive value is ViewportRelative Lengths.
+        (CSSPrimitiveValue):
+        * css/CSSPrimitiveValue.idl: Added support for vw/vh/vmin.
+        * css/CSSPrimitiveValueMappings.h:
+        (WebCore::CSSPrimitiveValue::convertToLength): Ditto.
+        * css/CSSStyleApplyProperty.cpp: Applying relative viewport length units to the specific CSS property.
+        (WebCore::ApplyPropertyLength::applyValue):
+        (WebCore::ApplyPropertyBorderRadius::applyValue):
+        (WebCore::ApplyPropertyFontSize::applyValue):
+        (WebCore::ApplyPropertyLineHeight::applyValue):
+        (WebCore::ApplyPropertyVerticalAlign::applyValue):
+        * css/CSSStyleSelector.cpp: Added support for viewport relative units.
+        * css/LengthFunctions.cpp: Calcuation of length value based on the current viewport size.
+        (WebCore::miminumValueForLength):
+        (WebCore::valueForLength):
+        (WebCore::floatValueForLength):
+        * css/LengthFunctions.h: Added new RenderView argument.
+        (WebCore):
+        * dom/Document.cpp:
+        (WebCore::Document::pageSizeAndMarginsInPixels): Modified to support viewport relative Length types.
+        (WebCore::Document::viewportSize): New function to fetch the current viewport size.
+        (WebCore):
+        * dom/Document.h: Ditto.
+        (Document):
+        * html/HTMLAreaElement.cpp: Modified to support viewport relative Length types.
+        (WebCore::HTMLAreaElement::getRegion):
+        * platform/Length.h:
+        (WebCore::Length::isViewportRelative): To check the Length is of type ViewportRelative.
+        (WebCore::Length::viewportRelativeLength): To get the relative value.
+        * rendering/RenderBR.cpp: Modified to support viewport relative Length types.
+        (WebCore::RenderBR::lineHeight):
+        * rendering/RenderBlock.cpp: Ditto.
+        (WebCore::RenderBlock::textIndentOffset):
+        (WebCore::RenderBlock::computeInlinePreferredLogicalWidths):
+        (WebCore::RenderBlock::lineHeight):
+        * rendering/RenderBox.cpp: Ditto.
+        (WebCore::RenderBox::reflectionOffset):
+        (WebCore::RenderBox::paintBoxDecorations):
+        (WebCore::RenderBox::clipRect):
+        (WebCore::RenderBox::computeLogicalWidthInRegion):
+        (WebCore::RenderBox::computeLogicalWidthInRegionUsing):
+        (WebCore::RenderBox::computeInlineDirectionMargins):
+        (WebCore::RenderBox::computeContentLogicalHeightUsing):
+        (WebCore::RenderBox::computeReplacedLogicalHeightUsing):
+        (WebCore::RenderBox::computeBlockDirectionMargins):
+        (WebCore::RenderBox::computePositionedLogicalWidthUsing):
+        (WebCore::RenderBox::computePositionedLogicalHeightUsing):
+        (WebCore::RenderBox::computePositionedLogicalWidthReplaced):
+        (WebCore::RenderBox::computePositionedLogicalHeightReplaced):
+        * rendering/RenderBoxModelObject.cpp: Ditto.
+        (WebCore::RenderBoxModelObject::relativePositionOffsetX):
+        (WebCore::RenderBoxModelObject::relativePositionOffsetY):
+        (WebCore::RenderBoxModelObject::paddingTop):
+        (WebCore::RenderBoxModelObject::paddingBottom):
+        (WebCore::RenderBoxModelObject::paddingLeft):
+        (WebCore::RenderBoxModelObject::paddingRight):
+        (WebCore::RenderBoxModelObject::paddingBefore):
+        (WebCore::RenderBoxModelObject::paddingAfter):
+        (WebCore::RenderBoxModelObject::paddingStart):
+        (WebCore::RenderBoxModelObject::paddingEnd):
+        (WebCore::RenderBoxModelObject::getBackgroundRoundedRect):
+        (WebCore::RenderBoxModelObject::calculateFillTileSize):
+        (WebCore::RenderBoxModelObject::calculateBackgroundImageGeometry):
+        (WebCore::computeBorderImageSide):
+        (WebCore::RenderBoxModelObject::paintNinePieceImage):
+        (WebCore::RenderBoxModelObject::paintBorder):
+        (WebCore::RenderBoxModelObject::paintBoxShadow):
+        * rendering/RenderFlexibleBox.cpp: Ditto.
+        (WebCore::RenderFlexibleBox::preferredMainAxisContentExtentForChild):
+        (WebCore::RenderFlexibleBox::computeMainAxisPreferredSizes):
+        (WebCore::RenderFlexibleBox::resolveFlexibleLengths):
+        * rendering/RenderInline.cpp: Ditto.
+        (WebCore::computeMargin):
+        (WebCore::RenderInline::lineHeight):
+        * rendering/RenderMenuList.cpp: Ditto.
+        (WebCore::RenderMenuList::updateOptionsWidth):
+        * rendering/RenderObject.cpp: Ditto.
+        (WebCore::RenderObject::repaintAfterLayoutIfNeeded):
+        * rendering/RenderReplaced.cpp: Ditto.
+        (WebCore::RenderReplaced::paint):
+        * rendering/RenderScrollbarPart.cpp: Ditto.
+        (WebCore::calcScrollbarThicknessUsing):
+        (WebCore::RenderScrollbarPart::computeScrollbarWidth):
+        (WebCore::RenderScrollbarPart::computeScrollbarHeight):
+        * rendering/RenderTable.cpp: Ditto.
+        (WebCore::RenderTable::computeLogicalWidth):
+        (WebCore::RenderTable::convertStyleLogicalWidthToComputedWidth):
+        * rendering/RenderTableCell.cpp: Ditto.
+        (WebCore::RenderTableCell::logicalHeightForRowSizing):
+        * rendering/RenderTableSection.cpp: Ditto.
+        (WebCore::RenderTableSection::calcRowLogicalHeight):
+        * rendering/RenderText.h: Ditto.
+        (WebCore::RenderText::marginLeft):
+        (WebCore::RenderText::marginRight):
+        * rendering/RenderThemeMac.mm: Ditto.
+        (WebCore::RenderThemeMac::paintMenuListButtonGradients):
+        * rendering/RenderView.h:
+        (WebCore::RenderView::viewportSize):
+        * rendering/RenderWidget.cpp: Ditto.
+        (WebCore::RenderWidget::paint):
+        * rendering/RootInlineBox.cpp: Ditto.
+        (WebCore::RootInlineBox::verticalPositionForBox):
+        * rendering/style/RenderStyle.cpp: Ditto.
+        (WebCore::calcRadiiFor):
+        (WebCore::RenderStyle::getRoundedBorderFor):
+        * rendering/style/RenderStyle.h: Ditto.
+        * rendering/svg/RenderSVGRoot.cpp: Ditto.
+        (WebCore::resolveLengthAttributeForSVG):
+        (WebCore::RenderSVGRoot::computeReplacedLogicalWidth):
+        (WebCore::RenderSVGRoot::computeReplacedLogicalHeight):
+
 2012-03-27  Gao Chun  <chun.gao@intel.com>
 
         Remove deprecated LowPass2FilterNode and HighPass2FilterNode
index 343bf05..2b20f9f 100644 (file)
@@ -240,7 +240,7 @@ static AtkAttributeSet* getAttributeSetForAccessibilityObject(const Accessibilit
     }
 
     if (!style->textIndent().isUndefined()) {
-        int indentation = valueForLength(style->textIndent(), object->size().width());
+        int indentation = valueForLength(style->textIndent(), object->size().width(), renderer->view());
         buffer.set(g_strdup_printf("%i", indentation));
         result = addToAtkAttributeSet(result, atk_text_attribute_get_name(ATK_TEXT_ATTR_INDENT), buffer.get());
     }
index e872ba5..b989c1d 100644 (file)
@@ -57,6 +57,7 @@
 #include "RenderBox.h"
 #include "RenderLayer.h"
 #include "RenderStyle.h"
+#include "RenderView.h"
 #include "ShadowValue.h"
 #include "StylePropertySet.h"
 #if ENABLE(CSS_FILTERS)
@@ -545,7 +546,7 @@ static PassRefPtr<CSSValue> valueForReflection(const StyleReflection* reflection
     return CSSReflectValue::create(reflection->direction(), offset.release(), valueForNinePieceImage(reflection->mask(), cssValuePool));
 }
 
-static PassRefPtr<CSSValue> getPositionOffsetValue(RenderStyle* style, int propertyID, CSSValuePool* cssValuePool)
+static PassRefPtr<CSSValue> getPositionOffsetValue(RenderStyle* style, int propertyID, CSSValuePool* cssValuePool, RenderView* renderView)
 {
     if (!style)
         return 0;
@@ -571,6 +572,8 @@ static PassRefPtr<CSSValue> getPositionOffsetValue(RenderStyle* style, int prope
     if (style->position() == AbsolutePosition || style->position() == FixedPosition) {
         if (l.type() == WebCore::Fixed)
             return zoomAdjustedPixelValue(l.value(), style, cssValuePool);
+        else if (l.isViewportRelative())
+            return zoomAdjustedPixelValue(valueForLength(l, 0, renderView), style, cssValuePool);
         return cssValuePool->createValue(l);
     }
 
@@ -592,31 +595,31 @@ PassRefPtr<CSSPrimitiveValue> CSSComputedStyleDeclaration::currentColorOrValidCo
     return cssValuePool->createColorValue(color.rgb());
 }
 
-static PassRefPtr<CSSValueList> getBorderRadiusCornerValues(LengthSize radius, const RenderStyle* style, CSSValuePool* cssValuePool)
+static PassRefPtr<CSSValueList> getBorderRadiusCornerValues(LengthSize radius, const RenderStyle* style, CSSValuePool* cssValuePool, RenderView* renderView)
 {
     RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
     if (radius.width().type() == Percent)
         list->append(cssValuePool->createValue(radius.width().percent(), CSSPrimitiveValue::CSS_PERCENTAGE));
     else
-        list->append(zoomAdjustedPixelValue(radius.width().value(), style, cssValuePool));
+        list->append(zoomAdjustedPixelValue(valueForLength(radius.width(), 0, renderView), style, cssValuePool));
     if (radius.height().type() == Percent)
         list->append(cssValuePool->createValue(radius.height().percent(), CSSPrimitiveValue::CSS_PERCENTAGE));
     else
-        list->append(zoomAdjustedPixelValue(radius.height().value(), style, cssValuePool));
+        list->append(zoomAdjustedPixelValue(valueForLength(radius.height(), 0, renderView), style, cssValuePool));
     return list.release();
 }
 
-static PassRefPtr<CSSValue> getBorderRadiusCornerValue(LengthSize radius, const RenderStyle* style, CSSValuePool* cssValuePool)
+static PassRefPtr<CSSValue> getBorderRadiusCornerValue(LengthSize radius, const RenderStyle* style, CSSValuePool* cssValuePool, RenderView* renderView)
 {
     if (radius.width() == radius.height()) {
         if (radius.width().type() == Percent)
             return cssValuePool->createValue(radius.width().percent(), CSSPrimitiveValue::CSS_PERCENTAGE);
-        return zoomAdjustedPixelValue(radius.width().value(), style, cssValuePool);
+        return zoomAdjustedPixelValue(valueForLength(radius.width(), 0, renderView), style, cssValuePool);
     }
-    return getBorderRadiusCornerValues(radius, style, cssValuePool);
+    return getBorderRadiusCornerValues(radius, style, cssValuePool, renderView);
 }
 
-static PassRefPtr<CSSValueList> getBorderRadiusShorthandValue(const RenderStyle* style, CSSValuePool* cssValuePool)
+static PassRefPtr<CSSValueList> getBorderRadiusShorthandValue(const RenderStyle* style, CSSValuePool* cssValuePool, RenderView* renderView)
 {
     RefPtr<CSSValueList> list = CSSValueList::createSlashSeparated();
     bool showHorizontalBottomLeft = style->borderTopRightRadius().width() != style->borderBottomLeftRadius().width();
@@ -628,10 +631,10 @@ static PassRefPtr<CSSValueList> getBorderRadiusShorthandValue(const RenderStyle*
     bool showVerticalTopRight = (style->borderTopRightRadius().height() != style->borderTopLeftRadius().height()) || showVerticalBottomRight;
     bool showVerticalTopLeft = (style->borderTopLeftRadius().width() != style->borderTopLeftRadius().height());
 
-    RefPtr<CSSValueList> topLeftRadius = getBorderRadiusCornerValues(style->borderTopLeftRadius(), style, cssValuePool);
-    RefPtr<CSSValueList> topRightRadius = getBorderRadiusCornerValues(style->borderTopRightRadius(), style, cssValuePool);
-    RefPtr<CSSValueList> bottomRightRadius = getBorderRadiusCornerValues(style->borderBottomRightRadius(), style, cssValuePool);
-    RefPtr<CSSValueList> bottomLeftRadius = getBorderRadiusCornerValues(style->borderBottomLeftRadius(), style, cssValuePool);
+    RefPtr<CSSValueList> topLeftRadius = getBorderRadiusCornerValues(style->borderTopLeftRadius(), style, cssValuePool, renderView);
+    RefPtr<CSSValueList> topRightRadius = getBorderRadiusCornerValues(style->borderTopRightRadius(), style, cssValuePool, renderView);
+    RefPtr<CSSValueList> bottomRightRadius = getBorderRadiusCornerValues(style->borderBottomRightRadius(), style, cssValuePool, renderView);
+    RefPtr<CSSValueList> bottomLeftRadius = getBorderRadiusCornerValues(style->borderBottomLeftRadius(), style, cssValuePool, renderView);
 
     RefPtr<CSSValueList> horizontalRadii = CSSValueList::createSpaceSeparated();
     horizontalRadii->append(topLeftRadius->item(0));
@@ -1259,7 +1262,7 @@ static PassRefPtr<CSSValueList> fontFamilyFromStyle(RenderStyle* style, CSSValue
     return list.release();
 }
 
-static PassRefPtr<CSSPrimitiveValue> lineHeightFromStyle(RenderStyle* style, CSSValuePool* cssValuePool)
+static PassRefPtr<CSSPrimitiveValue> lineHeightFromStyle(RenderStyle* style, CSSValuePool* cssValuePool, RenderView* renderView)
 {
     Length length = style->lineHeight();
     if (length.isNegative())
@@ -1270,7 +1273,7 @@ static PassRefPtr<CSSPrimitiveValue> lineHeightFromStyle(RenderStyle* style, CSS
         // On the other hand, since font-size doesn't include the zoom factor, we really can't do
         // that here either.
         return zoomAdjustedPixelValue(static_cast<int>(length.percent() * style->fontDescription().specifiedSize()) / 100, style, cssValuePool);
-    return zoomAdjustedPixelValue(length.value(), style, cssValuePool);
+    return zoomAdjustedPixelValue(valueForLength(length, 0, renderView), style, cssValuePool);
 }
 
 static PassRefPtr<CSSPrimitiveValue> fontSizeFromStyle(RenderStyle* style, CSSValuePool* cssValuePool)
@@ -1539,7 +1542,7 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
         case CSSPropertyBorderLeftWidth:
             return zoomAdjustedPixelValue(style->borderLeftWidth(), style.get(), cssValuePool);
         case CSSPropertyBottom:
-            return getPositionOffsetValue(style.get(), CSSPropertyBottom, cssValuePool);
+            return getPositionOffsetValue(style.get(), CSSPropertyBottom, cssValuePool, m_node->document()->renderView());
         case CSSPropertyWebkitBoxAlign:
             return cssValuePool->createValue(style->boxAlign());
         case CSSPropertyWebkitBoxDirection:
@@ -1657,7 +1660,7 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
             computedFont->variant = fontVariantFromStyle(style.get(), cssValuePool);
             computedFont->weight = fontWeightFromStyle(style.get(), cssValuePool);
             computedFont->size = fontSizeFromStyle(style.get(), cssValuePool);
-            computedFont->lineHeight = lineHeightFromStyle(style.get(), cssValuePool);
+            computedFont->lineHeight = lineHeightFromStyle(style.get(), cssValuePool, m_node->document()->renderView());
             computedFont->family = fontFamilyFromStyle(style.get(), cssValuePool);
             return computedFont.release();
         }
@@ -1740,7 +1743,7 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
         case CSSPropertyImageRendering:
             return CSSPrimitiveValue::create(style->imageRendering());
         case CSSPropertyLeft:
-            return getPositionOffsetValue(style.get(), CSSPropertyLeft, cssValuePool);
+            return getPositionOffsetValue(style.get(), CSSPropertyLeft, cssValuePool, m_node->document()->renderView());
         case CSSPropertyLetterSpacing:
             if (!style->letterSpacing())
                 return cssValuePool->createIdentifierValue(CSSValueNormal);
@@ -1750,7 +1753,7 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
                 return cssValuePool->createIdentifierValue(CSSValueNone);
             return cssValuePool->createValue(style->lineClamp().value(), style->lineClamp().isPercentage() ? CSSPrimitiveValue::CSS_PERCENTAGE : CSSPrimitiveValue::CSS_NUMBER);
         case CSSPropertyLineHeight:
-            return lineHeightFromStyle(style.get(), cssValuePool);
+            return lineHeightFromStyle(style.get(), cssValuePool, m_node->document()->renderView());
         case CSSPropertyListStyleImage:
             if (style->listStyleImage())
                 return style->listStyleImage()->cssValue();
@@ -1774,11 +1777,11 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
             if (marginRight.isFixed() || !renderer || !renderer->isBox())
                 return zoomAdjustedPixelValueForLength(marginRight, style.get(), cssValuePool);
             int value;
-            if (marginRight.isPercent())
+            if (marginRight.isPercent() || marginRight.isViewportRelative())
                 // RenderBox gives a marginRight() that is the distance between the right-edge of the child box
                 // and the right-edge of the containing box, when display == BLOCK. Let's calculate the absolute
                 // value of the specified margin-right % instead of relying on RenderBox's marginRight() value.
-                value = minimumValueForLength(marginRight, toRenderBox(renderer)->containingBlockLogicalWidthForContent());
+                value = minimumValueForLength(marginRight, toRenderBox(renderer)->containingBlockLogicalWidthForContent(), m_node->document()->renderView());
             else
                 value = toRenderBox(renderer)->marginRight();
             return zoomAdjustedPixelValue(value, style.get(), cssValuePool);
@@ -1873,7 +1876,7 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
         case CSSPropertyPosition:
             return cssValuePool->createValue(style->position());
         case CSSPropertyRight:
-            return getPositionOffsetValue(style.get(), CSSPropertyRight, cssValuePool);
+            return getPositionOffsetValue(style.get(), CSSPropertyRight, cssValuePool, m_node->document()->renderView());
         case CSSPropertyTableLayout:
             return cssValuePool->createValue(style->tableLayout());
         case CSSPropertyTextAlign:
@@ -1931,7 +1934,7 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
         case CSSPropertyTextTransform:
             return cssValuePool->createValue(style->textTransform());
         case CSSPropertyTop:
-            return getPositionOffsetValue(style.get(), CSSPropertyTop, cssValuePool);
+            return getPositionOffsetValue(style.get(), CSSPropertyTop, cssValuePool, m_node->document()->renderView());
         case CSSPropertyUnicodeBidi:
             return renderUnicodeBidiFlagsToCSSValue(style->unicodeBidi(), cssValuePool);
         case CSSPropertyVerticalAlign:
@@ -2190,8 +2193,9 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
             RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
             if (renderer) {
                 LayoutRect box = sizingBox(renderer);
-                list->append(zoomAdjustedPixelValue(minimumValueForLength(style->perspectiveOriginX(), box.width()), style.get(), cssValuePool));
-                list->append(zoomAdjustedPixelValue(minimumValueForLength(style->perspectiveOriginY(), box.height()), style.get(), cssValuePool));
+                RenderView* renderView = m_node->document()->renderView();
+                list->append(zoomAdjustedPixelValue(minimumValueForLength(style->perspectiveOriginX(), box.width(), renderView), style.get(), cssValuePool));
+                list->append(zoomAdjustedPixelValue(minimumValueForLength(style->perspectiveOriginY(), box.height(), renderView), style.get(), cssValuePool));
             }
             else {
                 list->append(zoomAdjustedPixelValueForLength(style->perspectiveOriginX(), style.get(), cssValuePool));
@@ -2211,13 +2215,13 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
         case CSSPropertyWebkitUserSelect:
             return cssValuePool->createValue(style->userSelect());
         case CSSPropertyBorderBottomLeftRadius:
-            return getBorderRadiusCornerValue(style->borderBottomLeftRadius(), style.get(), cssValuePool);
+            return getBorderRadiusCornerValue(style->borderBottomLeftRadius(), style.get(), cssValuePool, m_node->document()->renderView());
         case CSSPropertyBorderBottomRightRadius:
-            return getBorderRadiusCornerValue(style->borderBottomRightRadius(), style.get(), cssValuePool);
+            return getBorderRadiusCornerValue(style->borderBottomRightRadius(), style.get(), cssValuePool, m_node->document()->renderView());
         case CSSPropertyBorderTopLeftRadius:
-            return getBorderRadiusCornerValue(style->borderTopLeftRadius(), style.get(), cssValuePool);
+            return getBorderRadiusCornerValue(style->borderTopLeftRadius(), style.get(), cssValuePool, m_node->document()->renderView());
         case CSSPropertyBorderTopRightRadius:
-            return getBorderRadiusCornerValue(style->borderTopRightRadius(), style.get(), cssValuePool);
+            return getBorderRadiusCornerValue(style->borderTopRightRadius(), style.get(), cssValuePool, m_node->document()->renderView());
         case CSSPropertyClip: {
             if (!style->hasClip())
                 return cssValuePool->createIdentifierValue(CSSValueAuto);
@@ -2236,8 +2240,9 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
             RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
             if (renderer) {
                 IntRect box = sizingBox(renderer);
-                list->append(zoomAdjustedPixelValue(minimumValueForLength(style->transformOriginX(), box.width()), style.get(), cssValuePool));
-                list->append(zoomAdjustedPixelValue(minimumValueForLength(style->transformOriginY(), box.height()), style.get(), cssValuePool));
+                RenderView* renderView = m_node->document()->renderView();
+                list->append(zoomAdjustedPixelValue(minimumValueForLength(style->transformOriginX(), box.width(), renderView), style.get(), cssValuePool));
+                list->append(zoomAdjustedPixelValue(minimumValueForLength(style->transformOriginY(), box.height(), renderView), style.get(), cssValuePool));
                 if (style->transformOriginZ() != 0)
                     list->append(zoomAdjustedPixelValue(style->transformOriginZ(), style.get(), cssValuePool));
             } else {
@@ -2356,7 +2361,7 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
         case CSSPropertyBorderImage:
             return valueForNinePieceImage(style->borderImage(), cssValuePool);
         case CSSPropertyBorderRadius:
-            return getBorderRadiusShorthandValue(style.get(), cssValuePool);
+            return getBorderRadiusShorthandValue(style.get(), cssValuePool, m_node->document()->renderView());
         case CSSPropertyBorderRight:
             return getCSSPropertyValuesForShorthandProperties(borderRightLonghand());
         case CSSPropertyBorderStyle:
index e2761b6..cdbf9cc 100644 (file)
@@ -99,7 +99,7 @@ static int cssyylex(YYSTYPE* yylval, void* parser)
 
 %}
 
-%expect 55
+%expect 58
 
 %nonassoc LOWEST_PREC
 
@@ -188,6 +188,9 @@ static int cssyylex(YYSTYPE* yylval, void* parser)
 %token <number> PERCENTAGE
 %token <number> FLOATTOKEN
 %token <number> INTEGER
+%token <number> VW
+%token <number> VH
+%token <number> VMIN
 
 %token <string> URI
 %token <string> FUNCTION
@@ -1472,6 +1475,9 @@ unary_term:
       if (Document* doc = p->findDocument())
           doc->setUsesRemUnits(true);
   }
+  | VW maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_VW; }
+  | VH maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_VH; }
+  | VMIN maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_VMIN; }
   ;
 
 function:
index b771ffa..1a86297 100644 (file)
@@ -1206,6 +1206,9 @@ bool CSSParser::validUnit(CSSParserValue* value, Units unitflags, bool strict)
     case CSSPrimitiveValue::CSS_IN:
     case CSSPrimitiveValue::CSS_PT:
     case CSSPrimitiveValue::CSS_PC:
+    case CSSPrimitiveValue::CSS_VW:
+    case CSSPrimitiveValue::CSS_VH:
+    case CSSPrimitiveValue::CSS_VMIN:
         b = (unitflags & FLength);
         break;
     case CSSPrimitiveValue::CSS_MS:
@@ -1237,7 +1240,8 @@ inline PassRefPtr<CSSPrimitiveValue> CSSParser::createPrimitiveNumericValue(CSSP
     }
                
     ASSERT((value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <= CSSPrimitiveValue::CSS_KHZ)
-           || (value->unit >= CSSPrimitiveValue::CSS_TURN && value->unit <= CSSPrimitiveValue::CSS_REMS));
+           || (value->unit >= CSSPrimitiveValue::CSS_TURN && value->unit <= CSSPrimitiveValue::CSS_REMS)
+           || (value->unit >= CSSPrimitiveValue::CSS_VW && value->unit <= CSSPrimitiveValue::CSS_VMIN));
     return cssValuePool()->createValue(value->fValue, static_cast<CSSPrimitiveValue::UnitTypes>(value->unit));
 }
 
@@ -1286,6 +1290,12 @@ static int unitFromString(CSSParserValue* value)
         return CSSPrimitiveValue::CSS_HZ;
     if (equal(value->string, "kHz"))
         return CSSPrimitiveValue::CSS_KHZ;
+    if (equal(value->string, "vw"))
+        return CSSPrimitiveValue::CSS_VW;
+    if (equal(value->string, "vh"))
+        return CSSPrimitiveValue::CSS_VH;
+    if (equal(value->string, "vmin"))
+        return CSSPrimitiveValue::CSS_VMIN;
 
     return 0;
 }
@@ -1331,6 +1341,8 @@ inline PassRefPtr<CSSPrimitiveValue> CSSParser::parseValidPrimitive(int id, CSSP
         return createPrimitiveNumericValue(value);
     if (value->unit >= CSSPrimitiveValue::CSS_TURN && value->unit <= CSSPrimitiveValue::CSS_REMS)
         return createPrimitiveNumericValue(value);
+    if (value->unit >= CSSPrimitiveValue::CSS_VW && value->unit <= CSSPrimitiveValue::CSS_VMIN)
+        return createPrimitiveNumericValue(value);
     if (value->unit >= CSSParserValue::Q_EMS)
         return CSSPrimitiveValue::createAllowingMarginQuirk(value->fValue, CSSPrimitiveValue::CSS_EMS);
     if (isCalculation(value))
@@ -8247,6 +8259,16 @@ inline void CSSParser::detectNumberToken(UChar* type, int length)
                 && isASCIIAlphaCaselessEqual(type[2], 'r') && isASCIIAlphaCaselessEqual(type[3], 'n'))
             m_token = TURNS;
         return;
+    case 'v':
+        if (length == 2) {
+            if (isASCIIAlphaCaselessEqual(type[1], 'w'))
+                m_token = VW;
+            else if (isASCIIAlphaCaselessEqual(type[1], 'h'))
+                m_token = VH;
+        } else if (length == 4 && isASCIIAlphaCaselessEqual(type[1], 'm')
+                && isASCIIAlphaCaselessEqual(type[2], 'i') && isASCIIAlphaCaselessEqual(type[3], 'n'))
+            m_token = VMIN;
+        return;
 
     default:
         if (type[0] == '_' && length == 5 && type[1] == '_' && isASCIIAlphaCaselessEqual(type[2], 'q')
index 105b087..508297b 100644 (file)
@@ -77,6 +77,9 @@ static inline bool isValidCSSUnitTypeForDoubleConversion(CSSPrimitiveValue::Unit
     case CSSPrimitiveValue:: CSS_REMS:
     case CSSPrimitiveValue:: CSS_S:
     case CSSPrimitiveValue:: CSS_TURN:
+    case CSSPrimitiveValue:: CSS_VW:
+    case CSSPrimitiveValue:: CSS_VH:
+    case CSSPrimitiveValue:: CSS_VMIN:
         return true;
     case CSSPrimitiveValue:: CSS_ATTR:
     case CSSPrimitiveValue:: CSS_COUNTER:
@@ -130,6 +133,10 @@ static CSSPrimitiveValue::UnitCategory unitCategory(CSSPrimitiveValue::UnitTypes
     case CSSPrimitiveValue::CSS_HZ:
     case CSSPrimitiveValue::CSS_KHZ:
         return CSSPrimitiveValue::UFrequency;
+    case CSSPrimitiveValue::CSS_VW:
+    case CSSPrimitiveValue::CSS_VH:
+    case CSSPrimitiveValue::CSS_VMIN:
+        return CSSPrimitiveValue::UViewportRelativeLength;
     default:
         return CSSPrimitiveValue::UOther;
     }
@@ -246,6 +253,18 @@ CSSPrimitiveValue::CSSPrimitiveValue(const Length& length)
             ASSERT(isfinite(length.percent()));
             m_value.num = length.percent();
             break;
+        case ViewportRelativeWidth:
+            m_primitiveUnitType = CSS_VW;
+            m_value.num = length.viewportRelativeLength();
+            break;
+        case ViewportRelativeHeight:
+            m_primitiveUnitType = CSS_VH;
+            m_value.num = length.viewportRelativeLength();
+            break;
+        case ViewportRelativeMin:
+            m_primitiveUnitType = CSS_VMIN;
+            m_value.num = length.viewportRelativeLength();
+            break;
         case Calculated:
         case Relative:
         case Undefined:
@@ -574,6 +593,8 @@ CSSPrimitiveValue::UnitTypes CSSPrimitiveValue::canonicalUnitTypeForCategory(Uni
         return CSS_DEG;
     case UFrequency:
         return CSS_HZ;
+    case UViewportRelativeLength:
+        return CSS_UNKNOWN; // Cannot convert between numbers and relative lengths.
     default:
         return CSS_UNKNOWN;
     }
@@ -994,6 +1015,15 @@ String CSSPrimitiveValue::customCssText() const
         case CSS_SHAPE:
             text = m_value.shape->cssText();
             break;
+        case CSS_VW:
+            text = formatNumber(m_value.num) + "vw";
+            break;
+        case CSS_VH:
+            text = formatNumber(m_value.num) + "vh";
+            break;
+        case CSS_VMIN:
+            text = formatNumber(m_value.num) + "vmin";
+            break;
     }
 
     ASSERT(!cssTextCache().contains(this));
@@ -1008,4 +1038,24 @@ void CSSPrimitiveValue::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const C
         addSubresourceURL(urls, styleSheet->completeURL(m_value.string));
 }
 
+Length CSSPrimitiveValue::viewportRelativeLength()
+{
+    ASSERT(isViewportRelativeLength());
+    Length viewportLength;
+    switch (m_primitiveUnitType) {
+    case CSS_VW:
+        viewportLength = Length(getDoubleValue(), ViewportRelativeWidth);
+        break;
+    case CSS_VH:
+        viewportLength = Length(getDoubleValue(), ViewportRelativeHeight);
+        break;
+    case CSS_VMIN:
+        viewportLength = Length(getDoubleValue(), ViewportRelativeMin);
+        break;
+    default:
+        break;
+    }
+    return viewportLength;
+}
+
 } // namespace WebCore
index 6dab3a5..9b980d5 100644 (file)
@@ -80,6 +80,10 @@ public:
         CSS_COUNTER = 23,
         CSS_RECT = 24,
         CSS_RGBCOLOR = 25,
+        // From CSS Values and Units. Viewport Relative Lengths (vw/vh/vmin).
+        CSS_VW = 26,
+        CSS_VH = 27,
+        CSS_VMIN = 28,
         CSS_PAIR = 100, // We envision this being exposed as a means of getting computed style values for pairs (border-spacing/radius, background-position, etc.)
         CSS_DASHBOARD_REGION = 101, // FIXME: Dashboard region should not be a primitive value.
         CSS_UNICODE_RANGE = 102,
@@ -118,6 +122,7 @@ public:
         UAngle,
         UTime,
         UFrequency,
+        UViewportRelativeLength,
         UOther
     };
 
@@ -153,6 +158,7 @@ public:
     bool isCalculated() const { return m_primitiveUnitType == CSS_CALC; }
     bool isCalculatedPercentageWithNumber() const { return primitiveType() == CSS_CALC_PERCENTAGE_WITH_NUMBER; }
     bool isCalculatedPercentageWithLength() const { return primitiveType() == CSS_CALC_PERCENTAGE_WITH_LENGTH; }
+    bool isViewportRelativeLength() const { return m_primitiveUnitType >= CSS_VW && m_primitiveUnitType <= CSS_VMIN; }
 
     static PassRefPtr<CSSPrimitiveValue> createIdentifier(int identifier) { return adoptRef(new CSSPrimitiveValue(identifier)); }
     static PassRefPtr<CSSPrimitiveValue> createColor(unsigned rgbValue) { return adoptRef(new CSSPrimitiveValue(rgbValue)); }
@@ -268,6 +274,8 @@ public:
 
     void addSubresourceStyleURLs(ListHashSet<KURL>&, const CSSStyleSheet*);
 
+    Length viewportRelativeLength();
+
 private:
     // FIXME: int vs. unsigned overloading is too subtle to distinguish the color and identifier cases.
     CSSPrimitiveValue(int ident);
index 517aba2..6c637c9 100644 (file)
@@ -48,7 +48,10 @@ module css {
         const unsigned short CSS_COUNTER    = 23;
         const unsigned short CSS_RECT       = 24;
         const unsigned short CSS_RGBCOLOR   = 25;
-
+        const unsigned short CSS_VW         = 26;
+        const unsigned short CSS_VH         = 27;
+        const unsigned short CSS_VMIN       = 28;
+        
         readonly attribute unsigned short primitiveType;
 
         [ObjCLegacyUnnamedParameters] void setFloatValue(in [Optional=DefaultIsUndefined] unsigned short unitType,
index 52e5e1f..8c822d9 100644 (file)
@@ -3774,7 +3774,8 @@ enum LengthConversion {
     AutoConversion = 1 << 2,
     PercentConversion = 1 << 3,
     FractionConversion = 1 << 4,
-    CalculatedConversion = 1 << 5
+    CalculatedConversion = 1 << 5,
+    ViewportRelativeConversion = 1 << 6
 };
 
 template<int supported> Length CSSPrimitiveValue::convertToLength(RenderStyle* style, RenderStyle* rootStyle, double multiplier, bool computingFontSize)
@@ -3793,6 +3794,8 @@ template<int supported> Length CSSPrimitiveValue::convertToLength(RenderStyle* s
         return Length(Auto);
     if ((supported & CalculatedConversion) && isCalculated())
         return Length(cssCalcValue()->toCalcValue(style, rootStyle, multiplier));
+    if ((supported & ViewportRelativeConversion) && isViewportRelativeLength())
+        return viewportRelativeLength();
     return Length(Undefined);
 }
 
index 836f722..31a87af 100644 (file)
@@ -39,6 +39,7 @@
 #include "Rect.h"
 #include "RenderObject.h"
 #include "RenderStyle.h"
+#include "RenderView.h"
 #include "Settings.h"
 #include <wtf/StdLibExtras.h>
 #include <wtf/UnusedParam.h>
@@ -392,6 +393,8 @@ public:
                 setValue(selector->style(), Length(primitiveValue->getDoubleValue(), Percent));
             else if (primitiveValue->isCalculatedPercentageWithLength())
                 setValue(selector->style(), Length(primitiveValue->cssCalcValue()->toCalcValue(selector->style(), selector->rootElementStyle(), selector->style()->effectiveZoom())));            
+            else if (primitiveValue->isViewportRelativeLength())
+                setValue(selector->style(), primitiveValue->viewportRelativeLength());
         }
     }
 
@@ -443,6 +446,8 @@ public:
         Length radiusHeight;
         if (pair->first()->isPercentage())
             radiusWidth = Length(pair->first()->getDoubleValue(), Percent);
+        else if (pair->first()->isViewportRelativeLength())
+            radiusWidth = pair->first()->viewportRelativeLength();
         else if (pair->first()->isCalculatedPercentageWithLength()) {
             // FIXME calc(): http://webkit.org/b/16662
             // handle this case
@@ -451,6 +456,8 @@ public:
             radiusWidth = pair->first()->computeLength<Length>(selector->style(), selector->rootElementStyle(), selector->style()->effectiveZoom());
         if (pair->second()->isPercentage())
             radiusHeight = Length(pair->second()->getDoubleValue(), Percent);
+        else if (pair->second()->isViewportRelativeLength())
+            radiusHeight = pair->second()->viewportRelativeLength();
         else if (pair->second()->isCalculatedPercentageWithLength()) {
             // FIXME calc(): http://webkit.org/b/16662
             // handle this case
@@ -745,6 +752,8 @@ public:
                 size = (primitiveValue->getFloatValue() * parentSize) / 100.0f;
             else if (primitiveValue->isCalculatedPercentageWithLength())
                 size = primitiveValue->cssCalcValue()->toCalcValue(selector->parentStyle(), selector->rootElementStyle())->evaluate(parentSize);                
+            else if (primitiveValue->isViewportRelativeLength())
+                size = valueForLength(primitiveValue->viewportRelativeLength(), 0, selector->document()->renderView());
             else
                 return;
         }
@@ -1206,6 +1215,8 @@ public:
         } else if (primitiveValue->isNumber()) {
             // FIXME: number and percentage values should produce the same type of Length (ie. Fixed or Percent).
             lineHeight = Length(primitiveValue->getDoubleValue() * 100.0, Percent);
+        } else if (primitiveValue->isViewportRelativeLength()) {
+            lineHeight = primitiveValue->viewportRelativeLength();
         } else
             return;
         selector->style()->setLineHeight(lineHeight);
@@ -1567,7 +1578,7 @@ public:
         if (primitiveValue->getIdent())
             return selector->style()->setVerticalAlign(*primitiveValue);
 
-        selector->style()->setVerticalAlignLength(primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion>(selector->style(), selector->rootElementStyle(), selector->style()->effectiveZoom()));
+        selector->style()->setVerticalAlignLength(primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion | ViewportRelativeConversion>(selector->style(), selector->rootElementStyle(), selector->style()->effectiveZoom()));
     }
 
     static PropertyHandler createHandler()
index 9d29149..3ec2d6d 100644 (file)
@@ -2548,12 +2548,12 @@ void RuleSet::shrinkToFit()
 
 Length CSSStyleSelector::convertToIntLength(CSSPrimitiveValue* primitiveValue, RenderStyle* style, RenderStyle* rootStyle, double multiplier)
 {
-    return primitiveValue ? primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion | FractionConversion>(style, rootStyle, multiplier) : Length(Undefined);
+    return primitiveValue ? primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion | FractionConversion | ViewportRelativeConversion>(style, rootStyle, multiplier) : Length(Undefined);
 }
 
 Length CSSStyleSelector::convertToFloatLength(CSSPrimitiveValue* primitiveValue, RenderStyle* style, RenderStyle* rootStyle, double multiplier)
 {
-    return primitiveValue ? primitiveValue->convertToLength<FixedFloatConversion | PercentConversion | FractionConversion>(style, rootStyle, multiplier) : Length(Undefined);
+    return primitiveValue ? primitiveValue->convertToLength<FixedFloatConversion | PercentConversion | FractionConversion | ViewportRelativeConversion>(style, rootStyle, multiplier) : Length(Undefined);
 }
 
 template <bool applyFirst>
@@ -2938,7 +2938,7 @@ bool CSSStyleSelector::useSVGZoomRules()
 
 static bool createGridTrackBreadth(CSSPrimitiveValue* primitiveValue, CSSStyleSelector* selector, Length& length)
 {
-    Length workingLength = primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion | AutoConversion>(selector->style(), selector->rootElementStyle(), selector->style()->effectiveZoom());
+    Length workingLength = primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion | ViewportRelativeConversion | AutoConversion>(selector->style(), selector->rootElementStyle(), selector->style()->effectiveZoom());
     if (workingLength.isUndefined())
         return false;
 
@@ -4282,6 +4282,8 @@ void CSSStyleSelector::mapFillXPosition(CSSPropertyID, FillLayer* layer, CSSValu
         l = Length(primitiveValue->getDoubleValue(), Percent);
     else if (primitiveValue->isCalculatedPercentageWithLength())
         l = Length(primitiveValue->cssCalcValue()->toCalcValue(style(), m_rootElementStyle, zoomFactor));
+    else if (primitiveValue->isViewportRelativeLength())
+        l = primitiveValue->viewportRelativeLength();
     else
         return;
     layer->setXPosition(l);
@@ -4307,6 +4309,8 @@ void CSSStyleSelector::mapFillYPosition(CSSPropertyID, FillLayer* layer, CSSValu
         l = Length(primitiveValue->getDoubleValue(), Percent);
     else if (primitiveValue->isCalculatedPercentageWithLength())
         l = Length(primitiveValue->cssCalcValue()->toCalcValue(style(), m_rootElementStyle, zoomFactor));
+    else if (primitiveValue->isViewportRelativeLength())
+        l = primitiveValue->viewportRelativeLength();
     else
         return;
     layer->setYPosition(l);
index 3758fc4..9b701c1 100644 (file)
 #include "LengthFunctions.h"
 
 #include "Length.h"
+#include "RenderView.h"
 
 namespace WebCore {
 
-int minimumValueForLength(Length length, int maximumValue, bool roundPercentages)
+int minimumValueForLength(Length length, int maximumValue, RenderView* renderView, bool roundPercentages)
 {
     switch (length.type()) {
     case Fixed:
@@ -40,6 +41,20 @@ int minimumValueForLength(Length length, int maximumValue, bool roundPercentages
         return static_cast<int>(static_cast<float>(maximumValue * length.percent() / 100.0f));
     case Calculated:
         return length.nonNanCalculatedValue(maximumValue);
+    case ViewportRelativeWidth:
+        if (renderView)
+            return static_cast<int>(renderView->viewportSize().width() * length.viewportRelativeLength() / 100.0f);
+        return 0;
+    case ViewportRelativeHeight:
+        if (renderView)
+            return static_cast<int>(renderView->viewportSize().height() * length.viewportRelativeLength() / 100.0f);
+        return 0;
+    case ViewportRelativeMin:
+        if (renderView) {
+            IntSize viewportSize = renderView->viewportSize();
+            return static_cast<int>(std::min(viewportSize.width(), viewportSize.height()) * length.viewportRelativeLength() / 100.0f);
+        }
+        return 0;
     case Auto:
         return 0;
     case Relative:
@@ -53,13 +68,16 @@ int minimumValueForLength(Length length, int maximumValue, bool roundPercentages
     return 0;
 }
 
-int valueForLength(Length length, int maximumValue, bool roundPercentages)
+int valueForLength(Length length, int maximumValue, RenderView* renderView, bool roundPercentages)
 {
     switch (length.type()) {
     case Fixed:
     case Percent:
     case Calculated:
-        return minimumValueForLength(length, maximumValue, roundPercentages);
+    case ViewportRelativeWidth:
+    case ViewportRelativeHeight:
+    case ViewportRelativeMin:
+        return minimumValueForLength(length, maximumValue, renderView, roundPercentages);
     case Auto:
         return maximumValue;
     case Relative:
@@ -74,7 +92,7 @@ int valueForLength(Length length, int maximumValue, bool roundPercentages)
 }
 
 // FIXME: when subpixel layout is supported this copy of floatValueForLength() can be removed. See bug 71143.
-float floatValueForLength(Length length, int maximumValue)
+float floatValueForLength(Length length, int maximumValue, RenderView* renderView)
 {
     switch (length.type()) {
     case Fixed:
@@ -85,6 +103,20 @@ float floatValueForLength(Length length, int maximumValue)
         return static_cast<float>(maximumValue);
     case Calculated:
         return length.nonNanCalculatedValue(maximumValue);                
+    case ViewportRelativeWidth:
+        if (renderView)
+            return static_cast<int>(renderView->viewportSize().width() * length.viewportRelativeLength() / 100.0f);
+        return 0;
+    case ViewportRelativeHeight:
+        if (renderView)
+            return static_cast<int>(renderView->viewportSize().height() * length.viewportRelativeLength() / 100.0f);
+        return 0;
+    case ViewportRelativeMin:
+        if (renderView) {
+            IntSize viewportSize = renderView->viewportSize();
+            return static_cast<int>(std::min(viewportSize.width(), viewportSize.height()) * length.viewportRelativeLength() / 100.0f);
+        }
+        return 0;
     case Relative:
     case Intrinsic:
     case MinIntrinsic:
@@ -96,7 +128,7 @@ float floatValueForLength(Length length, int maximumValue)
     return 0;
 }
 
-float floatValueForLength(Length length, float maximumValue)
+float floatValueForLength(Length length, float maximumValue, RenderView* renderView)
 {
     switch (length.type()) {
     case Fixed:
@@ -107,6 +139,20 @@ float floatValueForLength(Length length, float maximumValue)
         return static_cast<float>(maximumValue);
     case Calculated:
         return length.nonNanCalculatedValue(maximumValue);
+    case ViewportRelativeWidth:
+        if (renderView)
+            return static_cast<int>(renderView->viewportSize().width() * length.viewportRelativeLength() / 100.0f);
+        return 0;
+    case ViewportRelativeHeight:
+        if (renderView)
+            return static_cast<int>(renderView->viewportSize().height() * length.viewportRelativeLength() / 100.0f);
+        return 0;
+    case ViewportRelativeMin:
+        if (renderView) {
+            IntSize viewportSize = renderView->viewportSize();
+            return static_cast<int>(std::min(viewportSize.width(), viewportSize.height()) * length.viewportRelativeLength() / 100.0f);
+        }
+        return 0;
     case Relative:
     case Intrinsic:
     case MinIntrinsic:
index f2510d5..3106561 100644 (file)
 
 namespace WebCore {
 
+class RenderView;
 struct Length;
 
-int minimumValueForLength(Length, int maximumValue, bool roundPercentages = false);
-int valueForLength(Length, int maximumValue, bool roundPercentages = false);
-float floatValueForLength(Length, int maximumValue);
-float floatValueForLength(Length, float maximumValue);
+int minimumValueForLength(Length, int maximumValue, RenderView* = 0, bool roundPercentages = false);
+int valueForLength(Length, int maximumValue, RenderView* = 0, bool roundPercentages = false);
+float floatValueForLength(Length, int maximumValue, RenderView* = 0);
+float floatValueForLength(Length, float maximumValue, RenderView* = 0);
 
 } // namespace WebCore
 
index 6f0a0b1..96f9cc9 100644 (file)
@@ -1809,6 +1809,7 @@ bool Document::isPageBoxVisible(int pageIndex)
 void Document::pageSizeAndMarginsInPixels(int pageIndex, IntSize& pageSize, int& marginTop, int& marginRight, int& marginBottom, int& marginLeft)
 {
     RefPtr<RenderStyle> style = styleForPage(pageIndex);
+    RenderView* view = renderView();
 
     int width = pageSize.width();
     int height = pageSize.height();
@@ -1827,8 +1828,8 @@ void Document::pageSizeAndMarginsInPixels(int pageIndex, IntSize& pageSize, int&
         LengthSize size = style->pageSize();
         ASSERT(size.width().isFixed());
         ASSERT(size.height().isFixed());
-        width = valueForLength(size.width(), 0);
-        height = valueForLength(size.height(), 0);
+        width = valueForLength(size.width(), 0, view);
+        height = valueForLength(size.height(), 0, view);
         break;
     }
     default:
@@ -1838,10 +1839,10 @@ void Document::pageSizeAndMarginsInPixels(int pageIndex, IntSize& pageSize, int&
 
     // The percentage is calculated with respect to the width even for margin top and bottom.
     // http://www.w3.org/TR/CSS2/box.html#margin-properties
-    marginTop = style->marginTop().isAuto() ? marginTop : valueForLength(style->marginTop(), width);
-    marginRight = style->marginRight().isAuto() ? marginRight : valueForLength(style->marginRight(), width);
-    marginBottom = style->marginBottom().isAuto() ? marginBottom : valueForLength(style->marginBottom(), width);
-    marginLeft = style->marginLeft().isAuto() ? marginLeft : valueForLength(style->marginLeft(), width);
+    marginTop = style->marginTop().isAuto() ? marginTop : valueForLength(style->marginTop(), width, view);
+    marginRight = style->marginRight().isAuto() ? marginRight : valueForLength(style->marginRight(), width, view);
+    marginBottom = style->marginBottom().isAuto() ? marginBottom : valueForLength(style->marginBottom(), width, view);
+    marginLeft = style->marginLeft().isAuto() ? marginLeft : valueForLength(style->marginLeft(), width, view);
 }
 
 PassRefPtr<CSSValuePool> Document::cssValuePool() const
@@ -5746,4 +5747,11 @@ void Document::removeCachedMicroDataItemList(MicroDataItemList* list, const Stri
 }
 #endif
 
+IntSize Document::viewportSize() const
+{
+    if (!view())
+        return IntSize();
+    return view()->visibleContentRect(/* includeScrollbars */ true).size();
+}
+
 } // namespace WebCore
index 96eb3aa..d255e97 100644 (file)
@@ -1133,6 +1133,8 @@ public:
     void suspendScheduledTasks();
     void resumeScheduledTasks();
 
+    IntSize viewportSize() const;
+
 protected:
     Document(Frame*, const KURL&, bool isXHTML, bool isHTML);
 
index fe43010..d3ea242 100644 (file)
@@ -31,6 +31,7 @@
 #include "HitTestResult.h"
 #include "Path.h"
 #include "RenderImage.h"
+#include "RenderView.h"
 
 using namespace std;
 
@@ -143,29 +144,30 @@ Path HTMLAreaElement::getRegion(const LayoutSize& size) const
     }
 
     Path path;
+    RenderView* renderView = document()->renderView();
     switch (shape) {
         case Poly:
             if (m_coordsLen >= 6) {
                 int numPoints = m_coordsLen / 2;
-                path.moveTo(FloatPoint(minimumValueForLength(m_coords[0], width), minimumValueForLength(m_coords[1], height)));
+                path.moveTo(FloatPoint(minimumValueForLength(m_coords[0], width, renderView), minimumValueForLength(m_coords[1], height, renderView)));
                 for (int i = 1; i < numPoints; ++i)
-                    path.addLineTo(FloatPoint(minimumValueForLength(m_coords[i * 2], width), minimumValueForLength(m_coords[i * 2 + 1], height)));
+                    path.addLineTo(FloatPoint(minimumValueForLength(m_coords[i * 2], width, renderView), minimumValueForLength(m_coords[i * 2 + 1], height, renderView)));
                 path.closeSubpath();
             }
             break;
         case Circle:
             if (m_coordsLen >= 3) {
                 Length radius = m_coords[2];
-                int r = min(minimumValueForLength(radius, width), minimumValueForLength(radius, height));
-                path.addEllipse(FloatRect(minimumValueForLength(m_coords[0], width) - r, minimumValueForLength(m_coords[1], height) - r, 2 * r, 2 * r));
+                int r = min(minimumValueForLength(radius, width, renderView), minimumValueForLength(radius, height, renderView));
+                path.addEllipse(FloatRect(minimumValueForLength(m_coords[0], width, renderView) - r, minimumValueForLength(m_coords[1], height, renderView) - r, 2 * r, 2 * r));
             }
             break;
         case Rect:
             if (m_coordsLen >= 4) {
-                int x0 = minimumValueForLength(m_coords[0], width);
-                int y0 = minimumValueForLength(m_coords[1], height);
-                int x1 = minimumValueForLength(m_coords[2], width);
-                int y1 = minimumValueForLength(m_coords[3], height);
+                int x0 = minimumValueForLength(m_coords[0], width, renderView);
+                int y0 = minimumValueForLength(m_coords[1], height, renderView);
+                int x1 = minimumValueForLength(m_coords[2], width, renderView);
+                int y1 = minimumValueForLength(m_coords[3], height, renderView);
                 path.addRect(FloatRect(x0, y0, x1 - x0, y1 - y0));
             }
             break;
index 5634dda..9786a1e 100644 (file)
@@ -33,7 +33,7 @@
 
 namespace WebCore {
 
-enum LengthType { Auto, Relative, Percent, Fixed, Intrinsic, MinIntrinsic, Calculated, Undefined };
+enum LengthType { Auto, Relative, Percent, Fixed, Intrinsic, MinIntrinsic, Calculated, ViewportRelativeWidth, ViewportRelativeHeight, ViewportRelativeMin, Undefined };
  
 class CalculationValue;    
     
@@ -226,6 +226,16 @@ public:
     }
     float nonNanCalculatedValue(int maxValue) const;
 
+    bool isViewportRelative() const
+    {
+        LengthType lengthType = type();
+        return lengthType >= ViewportRelativeWidth && lengthType <= ViewportRelativeMin;
+    }
+    float viewportRelativeLength() const
+    {
+        ASSERT(isViewportRelative());
+        return getFloatValue();
+    }
 private:
     int getIntValue() const
     {
index ca14e45..d803936 100644 (file)
@@ -43,11 +43,11 @@ int RenderBR::lineHeight(bool firstLine) const
     if (firstLine && document()->usesFirstLineRules()) {
         RenderStyle* s = style(firstLine);
         if (s != style())
-            return s->computedLineHeight();
+            return s->computedLineHeight(view());
     }
     
     if (m_lineHeight == -1)
-        m_lineHeight = style()->computedLineHeight();
+        m_lineHeight = style()->computedLineHeight(view());
     
     return m_lineHeight;
 }
index 1f130e1..d46d5b9 100755 (executable)
@@ -3919,9 +3919,12 @@ inline void RenderBlock::FloatIntervalSearchAdapter<FloatTypeValue>::collectIfNe
 LayoutUnit RenderBlock::textIndentOffset() const
 {
     LayoutUnit cw = 0;
+    RenderView* renderView = 0;
     if (style()->textIndent().isPercent())
         cw = containingBlock()->availableLogicalWidth();
-    return minimumValueForLength(style()->textIndent(), cw);
+    else if (style()->textIndent().isViewportRelative())
+        renderView = view();
+    return minimumValueForLength(style()->textIndent(), cw, renderView);
 }
 
 LayoutUnit RenderBlock::logicalLeftOffsetForContent(RenderRegion* region, LayoutUnit offsetFromLogicalTopOfFirstPage) const
@@ -5561,7 +5564,7 @@ void RenderBlock::computeInlinePreferredLogicalWidths()
                 LayoutUnit ti = 0;
                 if (!addedTextIndent) {
                     addedTextIndent = true;
-                    ti = minimumValueForLength(styleToUse->textIndent(), cw);
+                    ti = minimumValueForLength(styleToUse->textIndent(), cw, view());
                     childMin += ti;
                     childMax += ti;
                 }
@@ -5632,7 +5635,7 @@ void RenderBlock::computeInlinePreferredLogicalWidths()
                 LayoutUnit ti = 0;
                 if (!addedTextIndent) {
                     addedTextIndent = true;
-                    ti = minimumValueForLength(styleToUse->textIndent(), cw);
+                    ti = minimumValueForLength(styleToUse->textIndent(), cw, view());
                     childMin+=ti; beginMin += ti;
                     childMax+=ti; beginMax += ti;
                 }
@@ -5826,11 +5829,11 @@ LayoutUnit RenderBlock::lineHeight(bool firstLine, LineDirectionMode direction,
     if (firstLine && document()->usesFirstLineRules()) {
         RenderStyle* s = style(firstLine);
         if (s != style())
-            return s->computedLineHeight();
+            return s->computedLineHeight(view());
     }
     
     if (m_lineHeight == -1)
-        m_lineHeight = style()->computedLineHeight();
+        m_lineHeight = style()->computedLineHeight(view());
 
     return m_lineHeight;
 }
index c4eff70..99293d3 100644 (file)
@@ -622,9 +622,10 @@ int RenderBox::reflectionOffset() const
 {
     if (!style()->boxReflect())
         return 0;
+    RenderView* renderView = view();
     if (style()->boxReflect()->direction() == ReflectionLeft || style()->boxReflect()->direction() == ReflectionRight)
-        return valueForLength(style()->boxReflect()->offset(), borderBoxRect().width());
-    return valueForLength(style()->boxReflect()->offset(), borderBoxRect().height());
+        return valueForLength(style()->boxReflect()->offset(), borderBoxRect().width(), renderView);
+    return valueForLength(style()->boxReflect()->offset(), borderBoxRect().height(), renderView);
 }
 
 LayoutRect RenderBox::reflectedRect(const LayoutRect& r) const
@@ -991,7 +992,7 @@ void RenderBox::paintBoxDecorations(PaintInfo& paintInfo, const LayoutPoint& pai
         // To avoid the background color bleeding out behind the border, we'll render background and border
         // into a transparency layer, and then clip that in one go (which requires setting up the clip before
         // beginning the layer).
-        RoundedRect border = style()->getRoundedBorderFor(paintRect);
+        RoundedRect border = style()->getRoundedBorderFor(paintRect, view());
         stateSaver.save();
         paintInfo.context->addRoundedRectClip(border);
         paintInfo.context->beginTransparencyLayer(1);
@@ -1292,9 +1293,10 @@ LayoutRect RenderBox::clipRect(const LayoutPoint& location, RenderRegion* region
 {
     LayoutRect borderBoxRect = borderBoxRectInRegion(region);
     LayoutRect clipRect = LayoutRect(borderBoxRect.location() + location, borderBoxRect.size());
+    RenderView* renderView = view();
 
     if (!style()->clipLeft().isAuto()) {
-        LayoutUnit c = valueForLength(style()->clipLeft(), borderBoxRect.width());
+        LayoutUnit c = valueForLength(style()->clipLeft(), borderBoxRect.width(), renderView);
         clipRect.move(c, 0);
         clipRect.contract(c, 0);
     }
@@ -1303,16 +1305,16 @@ LayoutRect RenderBox::clipRect(const LayoutPoint& location, RenderRegion* region
     // from the left and top edges. Therefore it's better to avoid constraining to smaller widths and heights.
 
     if (!style()->clipRight().isAuto())
-        clipRect.contract(width() - valueForLength(style()->clipRight(), width()), 0);
+        clipRect.contract(width() - valueForLength(style()->clipRight(), width(), renderView), 0);
 
     if (!style()->clipTop().isAuto()) {
-        LayoutUnit c = valueForLength(style()->clipTop(), borderBoxRect.height());
+        LayoutUnit c = valueForLength(style()->clipTop(), borderBoxRect.height(), renderView);
         clipRect.move(0, c);
         clipRect.contract(0, c);
     }
 
     if (!style()->clipBottom().isAuto())
-        clipRect.contract(0, height() - valueForLength(style()->clipBottom(), height()));
+        clipRect.contract(0, height() - valueForLength(style()->clipBottom(), height(), renderView));
 
     return clipRect;
 }
@@ -1779,8 +1781,9 @@ void RenderBox::computeLogicalWidthInRegion(RenderRegion* region, LayoutUnit off
     
     if (isInline() && !isInlineBlockOrInlineTable()) {
         // just calculate margins
-        setMarginStart(minimumValueForLength(styleToUse->marginStart(), containerLogicalWidth));
-        setMarginEnd(minimumValueForLength(styleToUse->marginEnd(), containerLogicalWidth));
+        RenderView* renderView = view();
+        setMarginStart(minimumValueForLength(styleToUse->marginStart(), containerLogicalWidth, renderView));
+        setMarginEnd(minimumValueForLength(styleToUse->marginEnd(), containerLogicalWidth, renderView));
         if (treatAsReplaced)
             setLogicalWidth(max<LayoutUnit>(floatValueForLength(logicalWidthLength, 0) + borderAndPaddingLogicalWidth(), minPreferredLogicalWidth()));
         return;
@@ -1818,8 +1821,9 @@ void RenderBox::computeLogicalWidthInRegion(RenderRegion* region, LayoutUnit off
 
     // Margin calculations.
     if (logicalWidthLength.isAuto() || hasPerpendicularContainingBlock) {
-        setMarginStart(minimumValueForLength(styleToUse->marginStart(), containerLogicalWidth));
-        setMarginEnd(minimumValueForLength(styleToUse->marginEnd(), containerLogicalWidth));
+        RenderView* renderView = view();
+        setMarginStart(minimumValueForLength(styleToUse->marginStart(), containerLogicalWidth, renderView));
+        setMarginEnd(minimumValueForLength(styleToUse->marginEnd(), containerLogicalWidth, renderView));
     } else
         computeInlineDirectionMargins(cb, containerLogicalWidth, logicalWidth());
 
@@ -1842,8 +1846,9 @@ LayoutUnit RenderBox::computeLogicalWidthInRegionUsing(LogicalWidthType widthTyp
         logicalWidth = styleToUse->logicalMaxWidth();
 
     if (logicalWidth.isIntrinsicOrAuto()) {
-        LayoutUnit marginStart = minimumValueForLength(styleToUse->marginStart(), availableLogicalWidth);
-        LayoutUnit marginEnd = minimumValueForLength(styleToUse->marginEnd(), availableLogicalWidth);
+        RenderView* renderView = view();
+        LayoutUnit marginStart = minimumValueForLength(styleToUse->marginStart(), availableLogicalWidth, renderView);
+        LayoutUnit marginEnd = minimumValueForLength(styleToUse->marginEnd(), availableLogicalWidth, renderView);
         logicalWidthResult = availableLogicalWidth - marginStart - marginEnd;
 
         if (shrinkToAvoidFloats() && cb->containsFloats())
@@ -1854,7 +1859,7 @@ LayoutUnit RenderBox::computeLogicalWidthInRegionUsing(LogicalWidthType widthTyp
             logicalWidthResult = min(logicalWidthResult, maxPreferredLogicalWidth());
         }
     } else // FIXME: If the containing block flow is perpendicular to our direction we need to use the available logical height instead.
-        logicalWidthResult = computeBorderBoxLogicalWidth(valueForLength(logicalWidth, availableLogicalWidth)); 
+        logicalWidthResult = computeBorderBoxLogicalWidth(valueForLength(logicalWidth, availableLogicalWidth, view())); 
 
     return logicalWidthResult;
 }
@@ -1922,11 +1927,12 @@ void RenderBox::computeInlineDirectionMargins(RenderBlock* containingBlock, Layo
     const RenderStyle* containingBlockStyle = containingBlock->style();
     Length marginStartLength = style()->marginStartUsing(containingBlockStyle);
     Length marginEndLength = style()->marginEndUsing(containingBlockStyle);
+    RenderView* renderView = view();
 
     if (isFloating() || isInline()) {
         // Inline blocks/tables and floats don't have their margins increased.
-        containingBlock->setMarginStartForChild(this, minimumValueForLength(marginStartLength, containerWidth));
-        containingBlock->setMarginEndForChild(this, minimumValueForLength(marginEndLength, containerWidth));
+        containingBlock->setMarginStartForChild(this, minimumValueForLength(marginStartLength, containerWidth, renderView));
+        containingBlock->setMarginEndForChild(this, minimumValueForLength(marginEndLength, containerWidth, renderView));
         return;
     }
 
@@ -1940,7 +1946,7 @@ void RenderBox::computeInlineDirectionMargins(RenderBlock* containingBlock, Layo
     
     // Case Two: The object is being pushed to the start of the containing block's available logical width.
     if (marginEndLength.isAuto() && childWidth < containerWidth) {
-        containingBlock->setMarginStartForChild(this, valueForLength(marginStartLength, containerWidth));
+        containingBlock->setMarginStartForChild(this, valueForLength(marginStartLength, containerWidth, renderView));
         containingBlock->setMarginEndForChild(this, containerWidth - childWidth - containingBlock->marginStartForChild(this));
         return;
     } 
@@ -1949,15 +1955,15 @@ void RenderBox::computeInlineDirectionMargins(RenderBlock* containingBlock, Layo
     bool pushToEndFromTextAlign = !marginEndLength.isAuto() && ((!containingBlockStyle->isLeftToRightDirection() && containingBlockStyle->textAlign() == WEBKIT_LEFT)
         || (containingBlockStyle->isLeftToRightDirection() && containingBlockStyle->textAlign() == WEBKIT_RIGHT));
     if ((marginStartLength.isAuto() && childWidth < containerWidth) || pushToEndFromTextAlign) {
-        containingBlock->setMarginEndForChild(this, valueForLength(marginEndLength, containerWidth));
+        containingBlock->setMarginEndForChild(this, valueForLength(marginEndLength, containerWidth, renderView));
         containingBlock->setMarginStartForChild(this, containerWidth - childWidth - containingBlock->marginEndForChild(this));
         return;
     } 
     
     // Case Four: Either no auto margins, or our width is >= the container width (css2.1, 10.3.3).  In that case
     // auto margins will just turn into 0.
-    containingBlock->setMarginStartForChild(this, minimumValueForLength(marginStartLength, containerWidth));
-    containingBlock->setMarginEndForChild(this, minimumValueForLength(marginEndLength, containerWidth));
+    containingBlock->setMarginStartForChild(this, minimumValueForLength(marginStartLength, containerWidth, renderView));
+    containingBlock->setMarginEndForChild(this, minimumValueForLength(marginEndLength, containerWidth, renderView));
 }
 
 RenderBoxRegionInfo* RenderBox::renderBoxRegionInfo(RenderRegion* region, LayoutUnit offsetFromLogicalTopOfFirstPage, RenderBoxRegionInfoFlags cacheFlag) const
@@ -2168,6 +2174,8 @@ LayoutUnit RenderBox::computeContentLogicalHeightUsing(const Length& height)
             logicalHeight = height.value();
         else if (height.isPercent())
             logicalHeight = computePercentageLogicalHeight(height);
+        else if (height.isViewportRelative())
+            logicalHeight = valueForLength(height, 0, view());
     }
     return logicalHeight;
 }
@@ -2353,6 +2361,10 @@ LayoutUnit RenderBox::computeReplacedLogicalHeightUsing(Length logicalHeight) co
             }
             return computeContentBoxLogicalHeight(valueForLength(logicalHeight, availableHeight));
         }
+        case ViewportRelativeWidth:
+        case ViewportRelativeHeight:
+        case ViewportRelativeMin:
+            return computeContentBoxLogicalHeight(valueForLength(logicalHeight, 0, view()));
         default:
             return intrinsicLogicalHeight();
     }
@@ -2416,10 +2428,10 @@ void RenderBox::computeBlockDirectionMargins(RenderBlock* containingBlock)
     // Margins are calculated with respect to the logical width of
     // the containing block (8.3)
     LayoutUnit cw = containingBlockLogicalWidthForContent();
-
+    RenderView* renderView = view();
     RenderStyle* containingBlockStyle = containingBlock->style();
-    containingBlock->setMarginBeforeForChild(this, minimumValueForLength(style()->marginBeforeUsing(containingBlockStyle), cw));
-    containingBlock->setMarginAfterForChild(this, minimumValueForLength(style()->marginAfterUsing(containingBlockStyle), cw));
+    containingBlock->setMarginBeforeForChild(this, minimumValueForLength(style()->marginBeforeUsing(containingBlockStyle), cw, renderView));
+    containingBlock->setMarginAfterForChild(this, minimumValueForLength(style()->marginAfterUsing(containingBlockStyle), cw, renderView));
 }
 
 LayoutUnit RenderBox::containingBlockLogicalWidthForPositioned(const RenderBoxModelObject* containingBlock, RenderRegion* region,
@@ -2742,6 +2754,7 @@ void RenderBox::computePositionedLogicalWidthUsing(Length logicalWidth, const Re
     bool logicalWidthIsAuto = logicalWidth.isIntrinsicOrAuto();
     bool logicalLeftIsAuto = logicalLeft.isAuto();
     bool logicalRightIsAuto = logicalRight.isAuto();
+    RenderView* renderView = view();
 
     if (!logicalLeftIsAuto && !logicalWidthIsAuto && !logicalRightIsAuto) {
         /*-----------------------------------------------------------------------*\
@@ -2759,10 +2772,10 @@ void RenderBox::computePositionedLogicalWidthUsing(Length logicalWidth, const Re
         // NOTE:  It is not necessary to solve for 'right' in the over constrained
         // case because the value is not used for any further calculations.
 
-        logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth);
-        logicalWidthValue = computeContentBoxLogicalWidth(valueForLength(logicalWidth, containerLogicalWidth));
+        logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth, renderView);
+        logicalWidthValue = computeContentBoxLogicalWidth(valueForLength(logicalWidth, containerLogicalWidth, renderView));
 
-        const LayoutUnit availableSpace = containerLogicalWidth - (logicalLeftValue + logicalWidthValue + valueForLength(logicalRight, containerLogicalWidth) + bordersPlusPadding);
+        const LayoutUnit availableSpace = containerLogicalWidth - (logicalLeftValue + logicalWidthValue + valueForLength(logicalRight, containerLogicalWidth, renderView) + bordersPlusPadding);
 
         // Margins are now the only unknown
         if (marginLogicalLeft.isAuto() && marginLogicalRight.isAuto()) {
@@ -2783,16 +2796,16 @@ void RenderBox::computePositionedLogicalWidthUsing(Length logicalWidth, const Re
             }
         } else if (marginLogicalLeft.isAuto()) {
             // Solve for left margin
-            marginLogicalRightValue = valueForLength(marginLogicalRight, containerLogicalWidth);
+            marginLogicalRightValue = valueForLength(marginLogicalRight, containerLogicalWidth, renderView);
             marginLogicalLeftValue = availableSpace - marginLogicalRightValue;
         } else if (marginLogicalRight.isAuto()) {
             // Solve for right margin
-            marginLogicalLeftValue = valueForLength(marginLogicalLeft, containerLogicalWidth);
+            marginLogicalLeftValue = valueForLength(marginLogicalLeft, containerLogicalWidth, renderView);
             marginLogicalRightValue = availableSpace - marginLogicalLeftValue;
         } else {
             // Over-constrained, solve for left if direction is RTL
-            marginLogicalLeftValue = valueForLength(marginLogicalLeft, containerLogicalWidth);
-            marginLogicalRightValue = valueForLength(marginLogicalRight, containerLogicalWidth);
+            marginLogicalLeftValue = valueForLength(marginLogicalLeft, containerLogicalWidth, renderView);
+            marginLogicalRightValue = valueForLength(marginLogicalRight, containerLogicalWidth, renderView);
 
             // Use the containing block's direction rather than the parent block's
             // per CSS 2.1 reference test abspos-non-replaced-width-margin-000.
@@ -2842,8 +2855,8 @@ void RenderBox::computePositionedLogicalWidthUsing(Length logicalWidth, const Re
         // because the value is not used for any further calculations.
 
         // Calculate margins, 'auto' margins are ignored.
-        marginLogicalLeftValue = minimumValueForLength(marginLogicalLeft, containerLogicalWidth);
-        marginLogicalRightValue = minimumValueForLength(marginLogicalRight, containerLogicalWidth);
+        marginLogicalLeftValue = minimumValueForLength(marginLogicalLeft, containerLogicalWidth, renderView);
+        marginLogicalRightValue = minimumValueForLength(marginLogicalRight, containerLogicalWidth, renderView);
 
         const LayoutUnit availableSpace = containerLogicalWidth - (marginLogicalLeftValue + marginLogicalRightValue + bordersPlusPadding);
 
@@ -2851,7 +2864,7 @@ void RenderBox::computePositionedLogicalWidthUsing(Length logicalWidth, const Re
         // Use rule/case that applies.
         if (logicalLeftIsAuto && logicalWidthIsAuto && !logicalRightIsAuto) {
             // RULE 1: (use shrink-to-fit for width, and solve of left)
-            LayoutUnit logicalRightValue = valueForLength(logicalRight, containerLogicalWidth);
+            LayoutUnit logicalRightValue = valueForLength(logicalRight, containerLogicalWidth, renderView);
 
             // FIXME: would it be better to have shrink-to-fit in one step?
             LayoutUnit preferredWidth = maxPreferredLogicalWidth() - bordersPlusPadding;
@@ -2861,7 +2874,7 @@ void RenderBox::computePositionedLogicalWidthUsing(Length logicalWidth, const Re
             logicalLeftValue = availableSpace - (logicalWidthValue + logicalRightValue);
         } else if (!logicalLeftIsAuto && logicalWidthIsAuto && logicalRightIsAuto) {
             // RULE 3: (use shrink-to-fit for width, and no need solve of right)
-            logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth);
+            logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth, renderView);
 
             // FIXME: would it be better to have shrink-to-fit in one step?
             LayoutUnit preferredWidth = maxPreferredLogicalWidth() - bordersPlusPadding;
@@ -2870,16 +2883,16 @@ void RenderBox::computePositionedLogicalWidthUsing(Length logicalWidth, const Re
             logicalWidthValue = min(max(preferredMinWidth, availableWidth), preferredWidth);
         } else if (logicalLeftIsAuto && !logicalWidthIsAuto && !logicalRightIsAuto) {
             // RULE 4: (solve for left)
-            logicalWidthValue = computeContentBoxLogicalWidth(valueForLength(logicalWidth, containerLogicalWidth));
-            logicalLeftValue = availableSpace - (logicalWidthValue + valueForLength(logicalRight, containerLogicalWidth));
+            logicalWidthValue = computeContentBoxLogicalWidth(valueForLength(logicalWidth, containerLogicalWidth, renderView));
+            logicalLeftValue = availableSpace - (logicalWidthValue + valueForLength(logicalRight, containerLogicalWidth, renderView));
         } else if (!logicalLeftIsAuto && logicalWidthIsAuto && !logicalRightIsAuto) {
             // RULE 5: (solve for width)
-            logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth);
-            logicalWidthValue = availableSpace - (logicalLeftValue + valueForLength(logicalRight, containerLogicalWidth));
+            logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth, renderView);
+            logicalWidthValue = availableSpace - (logicalLeftValue + valueForLength(logicalRight, containerLogicalWidth, renderView));
         } else if (!logicalLeftIsAuto && !logicalWidthIsAuto && logicalRightIsAuto) {
             // RULE 6: (no need solve for right)
-            logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth);
-            logicalWidthValue = computeContentBoxLogicalWidth(valueForLength(logicalWidth, containerLogicalWidth));
+            logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth, renderView);
+            logicalWidthValue = computeContentBoxLogicalWidth(valueForLength(logicalWidth, containerLogicalWidth, renderView));
         }
     }
 
@@ -3075,6 +3088,7 @@ void RenderBox::computePositionedLogicalHeightUsing(Length logicalHeightLength,
     bool logicalHeightIsAuto = logicalHeightLength.isAuto();
     bool logicalTopIsAuto = logicalTop.isAuto();
     bool logicalBottomIsAuto = logicalBottom.isAuto();
+    RenderView* renderView = view();
 
     // Height is never unsolved for tables.
     if (isTable()) {
@@ -3094,10 +3108,10 @@ void RenderBox::computePositionedLogicalHeightUsing(Length logicalHeightLength,
         // NOTE:  It is not necessary to solve for 'bottom' in the over constrained
         // case because the value is not used for any further calculations.
 
-        logicalHeightValue = computeContentBoxLogicalHeight(valueForLength(logicalHeightLength, containerLogicalHeight));
-        logicalTopValue = valueForLength(logicalTop, containerLogicalHeight);
+        logicalHeightValue = computeContentBoxLogicalHeight(valueForLength(logicalHeightLength, containerLogicalHeight, renderView));
+        logicalTopValue = valueForLength(logicalTop, containerLogicalHeight, renderView);
 
-        const LayoutUnit availableSpace = containerLogicalHeight - (logicalTopValue + logicalHeightValue + valueForLength(logicalBottom, containerLogicalHeight) + bordersPlusPadding);
+        const LayoutUnit availableSpace = containerLogicalHeight - (logicalTopValue + logicalHeightValue + valueForLength(logicalBottom, containerLogicalHeight, renderView) + bordersPlusPadding);
 
         // Margins are now the only unknown
         if (marginBefore.isAuto() && marginAfter.isAuto()) {
@@ -3107,16 +3121,16 @@ void RenderBox::computePositionedLogicalHeightUsing(Length logicalHeightLength,
             marginAfterValue = availableSpace - marginBeforeValue; // account for odd valued differences
         } else if (marginBefore.isAuto()) {
             // Solve for top margin
-            marginAfterValue = valueForLength(marginAfter, containerLogicalHeight);
+            marginAfterValue = valueForLength(marginAfter, containerLogicalHeight, renderView);
             marginBeforeValue = availableSpace - marginAfterValue;
         } else if (marginAfter.isAuto()) {
             // Solve for bottom margin
-            marginBeforeValue = valueForLength(marginBefore, containerLogicalHeight);
+            marginBeforeValue = valueForLength(marginBefore, containerLogicalHeight, renderView);
             marginAfterValue = availableSpace - marginBeforeValue;
         } else {
             // Over-constrained, (no need solve for bottom)
-            marginBeforeValue = valueForLength(marginBefore, containerLogicalHeight);
-            marginAfterValue = valueForLength(marginAfter, containerLogicalHeight);
+            marginBeforeValue = valueForLength(marginBefore, containerLogicalHeight, renderView);
+            marginAfterValue = valueForLength(marginAfter, containerLogicalHeight, renderView);
         }
     } else {
         /*--------------------------------------------------------------------*\
@@ -3145,8 +3159,8 @@ void RenderBox::computePositionedLogicalHeightUsing(Length logicalHeightLength,
         // because the value is not used for any further calculations.
 
         // Calculate margins, 'auto' margins are ignored.
-        marginBeforeValue = minimumValueForLength(marginBefore, containerLogicalHeight);
-        marginAfterValue = minimumValueForLength(marginAfter, containerLogicalHeight);
+        marginBeforeValue = minimumValueForLength(marginBefore, containerLogicalHeight, renderView);
+        marginAfterValue = minimumValueForLength(marginAfter, containerLogicalHeight, renderView);
 
         const LayoutUnit availableSpace = containerLogicalHeight - (marginBeforeValue + marginAfterValue + bordersPlusPadding);
 
@@ -3154,23 +3168,23 @@ void RenderBox::computePositionedLogicalHeightUsing(Length logicalHeightLength,
         if (logicalTopIsAuto && logicalHeightIsAuto && !logicalBottomIsAuto) {
             // RULE 1: (height is content based, solve of top)
             logicalHeightValue = contentLogicalHeight;
-            logicalTopValue = availableSpace - (logicalHeightValue + valueForLength(logicalBottom, containerLogicalHeight));
+            logicalTopValue = availableSpace - (logicalHeightValue + valueForLength(logicalBottom, containerLogicalHeight, renderView));
         } else if (!logicalTopIsAuto && logicalHeightIsAuto && logicalBottomIsAuto) {
             // RULE 3: (height is content based, no need solve of bottom)
-            logicalTopValue = valueForLength(logicalTop, containerLogicalHeight);
+            logicalTopValue = valueForLength(logicalTop, containerLogicalHeight, renderView);
             logicalHeightValue = contentLogicalHeight;
         } else if (logicalTopIsAuto && !logicalHeightIsAuto && !logicalBottomIsAuto) {
             // RULE 4: (solve of top)
-            logicalHeightValue = computeContentBoxLogicalHeight(valueForLength(logicalHeightLength, containerLogicalHeight));
-            logicalTopValue = availableSpace - (logicalHeightValue + valueForLength(logicalBottom, containerLogicalHeight));
+            logicalHeightValue = computeContentBoxLogicalHeight(valueForLength(logicalHeightLength, containerLogicalHeight, renderView));
+            logicalTopValue = availableSpace - (logicalHeightValue + valueForLength(logicalBottom, containerLogicalHeight, renderView));
         } else if (!logicalTopIsAuto && logicalHeightIsAuto && !logicalBottomIsAuto) {
             // RULE 5: (solve of height)
-            logicalTopValue = valueForLength(logicalTop, containerLogicalHeight);
-            logicalHeightValue = max<LayoutUnit>(0, availableSpace - (logicalTopValue + valueForLength(logicalBottom, containerLogicalHeight)));
+            logicalTopValue = valueForLength(logicalTop, containerLogicalHeight, renderView);
+            logicalHeightValue = max<LayoutUnit>(0, availableSpace - (logicalTopValue + valueForLength(logicalBottom, containerLogicalHeight, renderView)));
         } else if (!logicalTopIsAuto && !logicalHeightIsAuto && logicalBottomIsAuto) {
             // RULE 6: (no need solve of bottom)
-            logicalHeightValue = computeContentBoxLogicalHeight(valueForLength(logicalHeightLength, containerLogicalHeight));
-            logicalTopValue = valueForLength(logicalTop, containerLogicalHeight);
+            logicalHeightValue = computeContentBoxLogicalHeight(valueForLength(logicalHeightLength, containerLogicalHeight, renderView));
+            logicalTopValue = valueForLength(logicalTop, containerLogicalHeight, renderView);
         }
     }
 
@@ -3246,13 +3260,14 @@ void RenderBox::computePositionedLogicalWidthReplaced()
     \*-----------------------------------------------------------------------*/
     LayoutUnit logicalLeftValue = 0;
     LayoutUnit logicalRightValue = 0;
+    RenderView* renderView = view();
 
     if (marginLogicalLeft.isAuto() && marginLogicalRight.isAuto()) {
         // 'left' and 'right' cannot be 'auto' due to step 3
         ASSERT(!(logicalLeft.isAuto() && logicalRight.isAuto()));
 
-        logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth);
-        logicalRightValue = valueForLength(logicalRight, containerLogicalWidth);
+        logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth, renderView);
+        logicalRightValue = valueForLength(logicalRight, containerLogicalWidth, renderView);
 
         LayoutUnit difference = availableSpace - (logicalLeftValue + logicalRightValue);
         if (difference > 0) {
@@ -3275,39 +3290,39 @@ void RenderBox::computePositionedLogicalWidthReplaced()
      *    that value.
     \*-----------------------------------------------------------------------*/
     } else if (logicalLeft.isAuto()) {
-        marginLogicalLeftAlias = valueForLength(marginLogicalLeft, containerLogicalWidth);
-        marginLogicalRightAlias = valueForLength(marginLogicalRight, containerLogicalWidth);
-        logicalRightValue = valueForLength(logicalRight, containerLogicalWidth);
+        marginLogicalLeftAlias = valueForLength(marginLogicalLeft, containerLogicalWidth, renderView);
+        marginLogicalRightAlias = valueForLength(marginLogicalRight, containerLogicalWidth, renderView);
+        logicalRightValue = valueForLength(logicalRight, containerLogicalWidth, renderView);
 
         // Solve for 'left'
         logicalLeftValue = availableSpace - (logicalRightValue + marginLogicalLeftAlias + marginLogicalRightAlias);
     } else if (logicalRight.isAuto()) {
-        marginLogicalLeftAlias = valueForLength(marginLogicalLeft, containerLogicalWidth);
-        marginLogicalRightAlias = valueForLength(marginLogicalRight, containerLogicalWidth);
-        logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth);
+        marginLogicalLeftAlias = valueForLength(marginLogicalLeft, containerLogicalWidth, renderView);
+        marginLogicalRightAlias = valueForLength(marginLogicalRight, containerLogicalWidth, renderView);
+        logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth, renderView);
 
         // Solve for 'right'
         logicalRightValue = availableSpace - (logicalLeftValue + marginLogicalLeftAlias + marginLogicalRightAlias);
     } else if (marginLogicalLeft.isAuto()) {
-        marginLogicalRightAlias = valueForLength(marginLogicalRight, containerLogicalWidth);
-        logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth);
-        logicalRightValue = valueForLength(logicalRight, containerLogicalWidth);
+        marginLogicalRightAlias = valueForLength(marginLogicalRight, containerLogicalWidth, renderView);
+        logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth, renderView);
+        logicalRightValue = valueForLength(logicalRight, containerLogicalWidth, renderView);
 
         // Solve for 'margin-left'
         marginLogicalLeftAlias = availableSpace - (logicalLeftValue + logicalRightValue + marginLogicalRightAlias);
     } else if (marginLogicalRight.isAuto()) {
-        marginLogicalLeftAlias = valueForLength(marginLogicalLeft, containerLogicalWidth);
-        logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth);
-        logicalRightValue = valueForLength(logicalRight, containerLogicalWidth);
+        marginLogicalLeftAlias = valueForLength(marginLogicalLeft, containerLogicalWidth, renderView);
+        logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth, renderView);
+        logicalRightValue = valueForLength(logicalRight, containerLogicalWidth, renderView);
 
         // Solve for 'margin-right'
         marginLogicalRightAlias = availableSpace - (logicalLeftValue + logicalRightValue + marginLogicalLeftAlias);
     } else {
         // Nothing is 'auto', just calculate the values.
-        marginLogicalLeftAlias = valueForLength(marginLogicalLeft, containerLogicalWidth);
-        marginLogicalRightAlias = valueForLength(marginLogicalRight, containerLogicalWidth);
-        logicalRightValue = valueForLength(logicalRight, containerLogicalWidth);
-        logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth);
+        marginLogicalLeftAlias = valueForLength(marginLogicalLeft, containerLogicalWidth, renderView);
+        marginLogicalRightAlias = valueForLength(marginLogicalRight, containerLogicalWidth, renderView);
+        logicalRightValue = valueForLength(logicalRight, containerLogicalWidth, renderView);
+        logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth, renderView);
         // If the containing block is right-to-left, then push the left position as far to the right as possible
         if (containerDirection == RTL) {
             int totalLogicalWidth = logicalWidth() + logicalLeftValue + logicalRightValue +  marginLogicalLeftAlias + marginLogicalRightAlias;
@@ -3370,6 +3385,7 @@ void RenderBox::computePositionedLogicalHeightReplaced()
 
     Length logicalTop = style()->logicalTop();
     Length logicalBottom = style()->logicalBottom();
+    RenderView* renderView = view();
 
     /*-----------------------------------------------------------------------*\
      * 1. The used value of 'height' is determined as for inline replaced
@@ -3413,8 +3429,8 @@ void RenderBox::computePositionedLogicalHeightReplaced()
         // 'top' and 'bottom' cannot be 'auto' due to step 2 and 3 combined.
         ASSERT(!(logicalTop.isAuto() || logicalBottom.isAuto()));
 
-        logicalTopValue = valueForLength(logicalTop, containerLogicalHeight);
-        logicalBottomValue = valueForLength(logicalBottom, containerLogicalHeight);
+        logicalTopValue = valueForLength(logicalTop, containerLogicalHeight, renderView);
+        logicalBottomValue = valueForLength(logicalBottom, containerLogicalHeight, renderView);
 
         LayoutUnit difference = availableSpace - (logicalTopValue + logicalBottomValue);
         // NOTE: This may result in negative values.
@@ -3426,39 +3442,39 @@ void RenderBox::computePositionedLogicalHeightReplaced()
      *    for that value.
     \*-----------------------------------------------------------------------*/
     } else if (logicalTop.isAuto()) {
-        marginBeforeAlias = valueForLength(marginBefore, containerLogicalHeight);
-        marginAfterAlias = valueForLength(marginAfter, containerLogicalHeight);
-        logicalBottomValue = valueForLength(logicalBottom, containerLogicalHeight);
+        marginBeforeAlias = valueForLength(marginBefore, containerLogicalHeight, renderView);
+        marginAfterAlias = valueForLength(marginAfter, containerLogicalHeight, renderView);
+        logicalBottomValue = valueForLength(logicalBottom, containerLogicalHeight, renderView);
 
         // Solve for 'top'
         logicalTopValue = availableSpace - (logicalBottomValue + marginBeforeAlias + marginAfterAlias);
     } else if (logicalBottom.isAuto()) {
-        marginBeforeAlias = valueForLength(marginBefore, containerLogicalHeight);
-        marginAfterAlias = valueForLength(marginAfter, containerLogicalHeight);
-        logicalTopValue = valueForLength(logicalTop, containerLogicalHeight);
+        marginBeforeAlias = valueForLength(marginBefore, containerLogicalHeight, renderView);
+        marginAfterAlias = valueForLength(marginAfter, containerLogicalHeight, renderView);
+        logicalTopValue = valueForLength(logicalTop, containerLogicalHeight, renderView);
 
         // Solve for 'bottom'
         // NOTE: It is not necessary to solve for 'bottom' because we don't ever
         // use the value.
     } else if (marginBefore.isAuto()) {
-        marginAfterAlias = valueForLength(marginAfter, containerLogicalHeight);
-        logicalTopValue = valueForLength(logicalTop, containerLogicalHeight);
-        logicalBottomValue = valueForLength(logicalBottom, containerLogicalHeight);
+        marginAfterAlias = valueForLength(marginAfter, containerLogicalHeight, renderView);
+        logicalTopValue = valueForLength(logicalTop, containerLogicalHeight, renderView);
+        logicalBottomValue = valueForLength(logicalBottom, containerLogicalHeight, renderView);
 
         // Solve for 'margin-top'
         marginBeforeAlias = availableSpace - (logicalTopValue + logicalBottomValue + marginAfterAlias);
     } else if (marginAfter.isAuto()) {
-        marginBeforeAlias = valueForLength(marginBefore, containerLogicalHeight);
-        logicalTopValue = valueForLength(logicalTop, containerLogicalHeight);
-        logicalBottomValue = valueForLength(logicalBottom, containerLogicalHeight);
+        marginBeforeAlias = valueForLength(marginBefore, containerLogicalHeight, renderView);
+        logicalTopValue = valueForLength(logicalTop, containerLogicalHeight, renderView);
+        logicalBottomValue = valueForLength(logicalBottom, containerLogicalHeight, renderView);
 
         // Solve for 'margin-bottom'
         marginAfterAlias = availableSpace - (logicalTopValue + logicalBottomValue + marginBeforeAlias);
     } else {
         // Nothing is 'auto', just calculate the values.
-        marginBeforeAlias = valueForLength(marginBefore, containerLogicalHeight);
-        marginAfterAlias = valueForLength(marginAfter, containerLogicalHeight);
-        logicalTopValue = valueForLength(logicalTop, containerLogicalHeight);
+        marginBeforeAlias = valueForLength(marginBefore, containerLogicalHeight, renderView);
+        marginAfterAlias = valueForLength(marginAfter, containerLogicalHeight, renderView);
+        logicalTopValue = valueForLength(logicalTop, containerLogicalHeight, renderView);
         // NOTE: It is not necessary to solve for 'bottom' because we don't ever
         // use the value.
      }
index 5d5fa91..6a57618 100644 (file)
@@ -437,12 +437,12 @@ LayoutUnit RenderBoxModelObject::relativePositionOffsetX() const
     if (!style()->left().isAuto()) {
         RenderBlock* cb = containingBlock();
         if (!style()->right().isAuto() && !cb->style()->isLeftToRightDirection())
-            return -valueForLength(style()->right(), cb->availableWidth());
-        return offset + valueForLength(style()->left(), cb->availableWidth());
+            return -valueForLength(style()->right(), cb->availableWidth(), view());
+        return offset + valueForLength(style()->left(), cb->availableWidth(), view());
     }
     if (!style()->right().isAuto()) {
         RenderBlock* cb = containingBlock();
-        return offset + -valueForLength(style()->right(), cb->availableWidth());
+        return offset + -valueForLength(style()->right(), cb->availableWidth(), view());
     }
     return offset;
 }
@@ -462,13 +462,13 @@ LayoutUnit RenderBoxModelObject::relativePositionOffsetY() const
         && (!containingBlock->style()->height().isAuto()
             || !style()->top().isPercent()
             || containingBlock->stretchesToViewport()))
-        return offset + valueForLength(style()->top(), containingBlock->availableHeight());
+        return offset + valueForLength(style()->top(), containingBlock->availableHeight(), view());
 
     if (!style()->bottom().isAuto()
         && (!containingBlock->style()->height().isAuto()
             || !style()->bottom().isPercent()
             || containingBlock->stretchesToViewport()))
-        return offset + -valueForLength(style()->bottom(), containingBlock->availableHeight());
+        return offset + -valueForLength(style()->bottom(), containingBlock->availableHeight(), view());
 
     return offset;
 }
@@ -553,81 +553,106 @@ int RenderBoxModelObject::pixelSnappedOffsetHeight() const
 LayoutUnit RenderBoxModelObject::paddingTop(PaddingOptions) const
 {
     LayoutUnit w = 0;
+    RenderView* renderView = 0;
     Length padding = style()->paddingTop();
     if (padding.isPercent())
         w = containingBlock()->availableLogicalWidth();
-    return minimumValueForLength(padding, w);
+    else if (padding.isViewportRelative())
+        renderView = view();
+    return minimumValueForLength(padding, w, renderView);
 }
 
 LayoutUnit RenderBoxModelObject::paddingBottom(PaddingOptions) const
 {
     LayoutUnit w = 0;
+    RenderView* renderView = 0;
     Length padding = style()->paddingBottom();
     if (padding.isPercent())
         w = containingBlock()->availableLogicalWidth();
-    return minimumValueForLength(padding, w);
+    else if (padding.isViewportRelative())
+        renderView = view();
+    return minimumValueForLength(padding, w, renderView);
 }
 
 LayoutUnit RenderBoxModelObject::paddingLeft(PaddingOptions) const
 {
     LayoutUnit w = 0;
+    RenderView* renderView = 0;
     Length padding = style()->paddingLeft();
     if (padding.isPercent())
         w = containingBlock()->availableLogicalWidth();
-    return minimumValueForLength(padding, w);
+    else if (padding.isViewportRelative())
+        renderView = view();
+    return minimumValueForLength(padding, w, renderView);
 }
 
 LayoutUnit RenderBoxModelObject::paddingRight(PaddingOptions) const
 {
     LayoutUnit w = 0;
+    RenderView* renderView = 0;
     Length padding = style()->paddingRight();
     if (padding.isPercent())
         w = containingBlock()->availableLogicalWidth();
-    return minimumValueForLength(padding, w);
+    else if (padding.isViewportRelative())
+        renderView = view();
+    return minimumValueForLength(padding, w, renderView);
 }
 
 LayoutUnit RenderBoxModelObject::paddingBefore(PaddingOptions) const
 {
     LayoutUnit w = 0;
+    RenderView* renderView = 0;
     Length padding = style()->paddingBefore();
     if (padding.isPercent())
         w = containingBlock()->availableLogicalWidth();
-    return minimumValueForLength(padding, w);
+    else if (padding.isViewportRelative())
+        renderView = view();
+    return minimumValueForLength(padding, w, renderView);
 }
 
 LayoutUnit RenderBoxModelObject::paddingAfter(PaddingOptions) const
 {
     LayoutUnit w = 0;
+    RenderView* renderView = 0;
     Length padding = style()->paddingAfter();
     if (padding.isPercent())
         w = containingBlock()->availableLogicalWidth();
-    return minimumValueForLength(padding, w);
+    else if (padding.isViewportRelative())
+        renderView = view();
+    return minimumValueForLength(padding, w, renderView);
 }
 
 LayoutUnit RenderBoxModelObject::paddingStart(PaddingOptions) const
 {
     LayoutUnit w = 0;
+    RenderView* renderView = 0;
     Length padding = style()->paddingStart();
     if (padding.isPercent())
         w = containingBlock()->availableLogicalWidth();
-    return minimumValueForLength(padding, w);
+    else if (padding.isViewportRelative())
+        renderView = view();
+    return minimumValueForLength(padding, w, renderView);
 }
 
 LayoutUnit RenderBoxModelObject::paddingEnd(PaddingOptions) const
 {
     LayoutUnit w = 0;
+    RenderView* renderView = 0;
     Length padding = style()->paddingEnd();
     if (padding.isPercent())
         w = containingBlock()->availableLogicalWidth();
-    return minimumValueForLength(padding, w);
+    else if (padding.isViewportRelative())
+        renderView = view();
+    return minimumValueForLength(padding, w, renderView);
 }
 
 RoundedRect RenderBoxModelObject::getBackgroundRoundedRect(const LayoutRect& borderRect, InlineFlowBox* box, LayoutUnit inlineBoxWidth, LayoutUnit inlineBoxHeight,
     bool includeLogicalLeftEdge, bool includeLogicalRightEdge)
 {
-    RoundedRect border = style()->getRoundedBorderFor(borderRect, includeLogicalLeftEdge, includeLogicalRightEdge);
+    RenderView* renderView = view();
+    RoundedRect border = style()->getRoundedBorderFor(borderRect, renderView, includeLogicalLeftEdge, includeLogicalRightEdge);
     if (box && (box->nextLineBox() || box->prevLineBox())) {
-        RoundedRect segmentBorder = style()->getRoundedBorderFor(LayoutRect(0, 0, inlineBoxWidth, inlineBoxHeight), includeLogicalLeftEdge, includeLogicalRightEdge);
+        RoundedRect segmentBorder = style()->getRoundedBorderFor(LayoutRect(0, 0, inlineBoxWidth, inlineBoxHeight), renderView, includeLogicalLeftEdge, includeLogicalRightEdge);
         border.setRadii(segmentBorder.radii());
     }
 
@@ -986,7 +1011,7 @@ IntSize RenderBoxModelObject::calculateFillTileSize(const FillLayer* fillLayer,
     EFillSizeType type = fillLayer->size().type;
 
     IntSize imageIntrinsicSize = calculateImageIntrinsicDimensions(image, positioningAreaSize);
-
+    RenderView* renderView = view();
     switch (type) {
         case SizeLength: {
             int w = positioningAreaSize.width();
@@ -997,13 +1022,13 @@ IntSize RenderBoxModelObject::calculateFillTileSize(const FillLayer* fillLayer,
 
             if (layerWidth.isFixed())
                 w = layerWidth.value();
-            else if (layerWidth.isPercent())
-                w = valueForLength(layerWidth, positioningAreaSize.width());
+            else if (layerWidth.isPercent() || layerHeight.isViewportRelative())
+                w = valueForLength(layerWidth, positioningAreaSize.width(), renderView);
             
             if (layerHeight.isFixed())
                 h = layerHeight.value();
-            else if (layerHeight.isPercent())
-                h = valueForLength(layerHeight, positioningAreaSize.height());
+            else if (layerHeight.isPercent() || layerHeight.isViewportRelative())
+                h = valueForLength(layerHeight, positioningAreaSize.height(), renderView);
             
             // If one of the values is auto we have to use the appropriate
             // scale to maintain our aspect ratio.
@@ -1138,14 +1163,15 @@ void RenderBoxModelObject::calculateBackgroundImageGeometry(const FillLayer* fil
 
     EFillRepeat backgroundRepeatX = fillLayer->repeatX();
     EFillRepeat backgroundRepeatY = fillLayer->repeatY();
+    RenderView* renderView = view();
 
-    LayoutUnit xPosition = minimumValueForLength(fillLayer->xPosition(), positioningAreaSize.width() - geometry.tileSize().width(), true);
+    LayoutUnit xPosition = minimumValueForLength(fillLayer->xPosition(), positioningAreaSize.width() - geometry.tileSize().width(), renderView, true);
     if (backgroundRepeatX == RepeatFill)
         geometry.setPhaseX(geometry.tileSize().width() ? geometry.tileSize().width() - (xPosition + left) % geometry.tileSize().width() : 0);
     else
         geometry.setNoRepeatX(xPosition + left);
 
-    LayoutUnit yPosition = minimumValueForLength(fillLayer->yPosition(), positioningAreaSize.height() - geometry.tileSize().height(), true);
+    LayoutUnit yPosition = minimumValueForLength(fillLayer->yPosition(), positioningAreaSize.height() - geometry.tileSize().height(), renderView, true);
     if (backgroundRepeatY == RepeatFill)
         geometry.setPhaseY(geometry.tileSize().height() ? geometry.tileSize().height() - (yPosition + top) % geometry.tileSize().height() : 0);
     else 
@@ -1158,13 +1184,13 @@ void RenderBoxModelObject::calculateBackgroundImageGeometry(const FillLayer* fil
     geometry.setDestOrigin(geometry.destRect().location());
 }
 
-static LayoutUnit computeBorderImageSide(Length borderSlice, LayoutUnit borderSide, LayoutUnit imageSide, LayoutUnit boxExtent)
+static LayoutUnit computeBorderImageSide(Length borderSlice, LayoutUnit borderSide, LayoutUnit imageSide, LayoutUnit boxExtent, RenderView* renderView)
 {
     if (borderSlice.isRelative())
         return borderSlice.value() * borderSide;
     if (borderSlice.isAuto())
         return imageSide;
-    return valueForLength(borderSlice, boxExtent);
+    return valueForLength(borderSlice, boxExtent, renderView);
 }
 
 bool RenderBoxModelObject::paintNinePieceImage(GraphicsContext* graphicsContext, const LayoutRect& rect, const RenderStyle* style,
@@ -1201,19 +1227,20 @@ bool RenderBoxModelObject::paintNinePieceImage(GraphicsContext* graphicsContext,
 
     int imageWidth = imageSize.width() / style->effectiveZoom();
     int imageHeight = imageSize.height() / style->effectiveZoom();
+    RenderView* renderView = view();
 
-    int topSlice = min<int>(imageHeight, valueForLength(ninePieceImage.imageSlices().top(), imageHeight));
-    int rightSlice = min<int>(imageWidth, valueForLength(ninePieceImage.imageSlices().right(), imageWidth));
-    int bottomSlice = min<int>(imageHeight, valueForLength(ninePieceImage.imageSlices().bottom(), imageHeight));
-    int leftSlice = min<int>(imageWidth, valueForLength(ninePieceImage.imageSlices().left(), imageWidth));
+    int topSlice = min<int>(imageHeight, valueForLength(ninePieceImage.imageSlices().top(), imageHeight, renderView));
+    int rightSlice = min<int>(imageWidth, valueForLength(ninePieceImage.imageSlices().right(), imageWidth, renderView));
+    int bottomSlice = min<int>(imageHeight, valueForLength(ninePieceImage.imageSlices().bottom(), imageHeight, renderView));
+    int leftSlice = min<int>(imageWidth, valueForLength(ninePieceImage.imageSlices().left(), imageWidth, renderView));
 
     ENinePieceImageRule hRule = ninePieceImage.horizontalRule();
     ENinePieceImageRule vRule = ninePieceImage.verticalRule();
-   
-    LayoutUnit topWidth = computeBorderImageSide(ninePieceImage.borderSlices().top(), style->borderTopWidth(), topSlice, borderImageRect.height());
-    LayoutUnit rightWidth = computeBorderImageSide(ninePieceImage.borderSlices().right(), style->borderRightWidth(), rightSlice, borderImageRect.width());
-    LayoutUnit bottomWidth = computeBorderImageSide(ninePieceImage.borderSlices().bottom(), style->borderBottomWidth(), bottomSlice, borderImageRect.height());
-    LayoutUnit leftWidth = computeBorderImageSide(ninePieceImage.borderSlices().left(), style->borderLeftWidth(), leftSlice, borderImageRect.width());
+
+    LayoutUnit topWidth = computeBorderImageSide(ninePieceImage.borderSlices().top(), style->borderTopWidth(), topSlice, borderImageRect.height(), renderView);
+    LayoutUnit rightWidth = computeBorderImageSide(ninePieceImage.borderSlices().right(), style->borderRightWidth(), rightSlice, borderImageRect.width(), renderView);
+    LayoutUnit bottomWidth = computeBorderImageSide(ninePieceImage.borderSlices().bottom(), style->borderBottomWidth(), bottomSlice, borderImageRect.height(), renderView);
+    LayoutUnit leftWidth = computeBorderImageSide(ninePieceImage.borderSlices().left(), style->borderLeftWidth(), leftSlice, borderImageRect.width(), renderView);
     
     // Reduce the widths if they're too large.
     // The spec says: Given Lwidth as the width of the border image area, Lheight as its height, and Wside as the border image width
@@ -1757,8 +1784,7 @@ void RenderBoxModelObject::paintBorder(const PaintInfo& info, const LayoutRect&
 
     BorderEdge edges[4];
     getBorderEdgeInfo(edges, style, includeLogicalLeftEdge, includeLogicalRightEdge);
-
-    RoundedRect outerBorder = style->getRoundedBorderFor(rect, includeLogicalLeftEdge, includeLogicalRightEdge);
+    RoundedRect outerBorder = style->getRoundedBorderFor(rect, view(), includeLogicalLeftEdge, includeLogicalRightEdge);
     RoundedRect innerBorder = style->getRoundedInnerBorderFor(rect, includeLogicalLeftEdge, includeLogicalRightEdge);
 
     bool haveAlphaColor = false;
@@ -2043,7 +2069,7 @@ void RenderBoxModelObject::paintBorder(const PaintInfo& info, const IntRect& rec
     
     GraphicsContextStateSaver stateSaver(*graphicsContext, false);
     if (style->hasBorderRadius()) {
-        border.includeLogicalEdges(style->getRoundedBorderFor(border.rect()).radii(),
+        border.includeLogicalEdges(style->getRoundedBorderFor(border.rect(), view()).radii(),
                                    horizontal, includeLogicalLeftEdge, includeLogicalRightEdge);
         if (border.isRounded()) {
             stateSaver.save();
@@ -2696,7 +2722,7 @@ void RenderBoxModelObject::paintBoxShadow(const PaintInfo& info, const LayoutRec
         return;
 
     RoundedRect border = (shadowStyle == Inset) ? s->getRoundedInnerBorderFor(paintRect, includeLogicalLeftEdge, includeLogicalRightEdge)
-                                                   : s->getRoundedBorderFor(paintRect, includeLogicalLeftEdge, includeLogicalRightEdge);
+                                                   : s->getRoundedBorderFor(paintRect, view(), includeLogicalLeftEdge, includeLogicalRightEdge);
 
     bool hasBorderRadius = s->hasBorderRadius();
     bool isHorizontal = s->isHorizontalWritingMode();
index 22422ce..25ab5e1 100644 (file)
@@ -586,7 +586,7 @@ LayoutUnit RenderFlexibleBox::preferredMainAxisContentExtentForChild(RenderBox*
         LayoutUnit mainAxisExtent = hasOrthogonalFlow(child) ? child->logicalHeight() : child->maxPreferredLogicalWidth();
         return mainAxisExtent - mainAxisBorderAndPaddingExtentForChild(child);
     }
-    return minimumValueForLength(mainAxisLength, mainAxisContentExtent());
+    return minimumValueForLength(mainAxisLength, mainAxisContentExtent(), view());
 }
 
 LayoutUnit RenderFlexibleBox::computeAvailableFreeSpace(LayoutUnit preferredMainAxisExtent)
@@ -660,6 +660,7 @@ LayoutUnit RenderFlexibleBox::marginBoxAscentForChild(RenderBox* child)
 void RenderFlexibleBox::computeMainAxisPreferredSizes(bool relayoutChildren, FlexOrderHashSet& flexOrderValues)
 {
     LayoutUnit flexboxAvailableContentExtent = mainAxisContentExtent();
+    RenderView* renderView = view();
     for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBox()) {
         flexOrderValues.add(child->style()->flexOrder());
 
@@ -677,11 +678,11 @@ void RenderFlexibleBox::computeMainAxisPreferredSizes(bool relayoutChildren, Fle
         // of 0 and because if we're not auto sizing, we don't do a layout that
         // computes the start/end margins.
         if (isHorizontalFlow()) {
-            child->setMarginLeft(minimumValueForLength(child->style()->marginLeft(), flexboxAvailableContentExtent));
-            child->setMarginRight(minimumValueForLength(child->style()->marginRight(), flexboxAvailableContentExtent));
+            child->setMarginLeft(minimumValueForLength(child->style()->marginLeft(), flexboxAvailableContentExtent, renderView));
+            child->setMarginRight(minimumValueForLength(child->style()->marginRight(), flexboxAvailableContentExtent, renderView));
         } else {
-            child->setMarginTop(minimumValueForLength(child->style()->marginTop(), flexboxAvailableContentExtent));
-            child->setMarginBottom(minimumValueForLength(child->style()->marginBottom(), flexboxAvailableContentExtent));
+            child->setMarginTop(minimumValueForLength(child->style()->marginTop(), flexboxAvailableContentExtent, renderView));
+            child->setMarginBottom(minimumValueForLength(child->style()->marginBottom(), flexboxAvailableContentExtent, renderView));
         }
     }
 }
@@ -704,12 +705,13 @@ LayoutUnit RenderFlexibleBox::adjustChildSizeForMinAndMax(RenderBox* child, Layo
 {
     Length max = isHorizontalFlow() ? child->style()->maxWidth() : child->style()->maxHeight();
     Length min = isHorizontalFlow() ? child->style()->minWidth() : child->style()->minHeight();
+    RenderView* renderView = view();
     // FIXME: valueForLength isn't quite right in quirks mode: percentage heights should check parents until a value is found.
     // https://bugs.webkit.org/show_bug.cgi?id=81809
-    if (max.isSpecified() && childSize > valueForLength(max, flexboxAvailableContentExtent))
-        childSize = valueForLength(max, flexboxAvailableContentExtent);
-    if (min.isSpecified() && childSize < valueForLength(min, flexboxAvailableContentExtent))
-        childSize = valueForLength(min, flexboxAvailableContentExtent);
+    if (max.isSpecified() && childSize > valueForLength(max, flexboxAvailableContentExtent, renderView))
+        childSize = valueForLength(max, flexboxAvailableContentExtent, renderView);
+    if (min.isSpecified() && childSize < valueForLength(min, flexboxAvailableContentExtent, renderView))
+        childSize = valueForLength(min, flexboxAvailableContentExtent, renderView);
     return childSize;
 }
 
@@ -765,7 +767,6 @@ void RenderFlexibleBox::freezeViolations(const WTF::Vector<Violation>& violation
 bool RenderFlexibleBox::resolveFlexibleLengths(FlexSign flexSign, const OrderedFlexItemList& children, LayoutUnit& availableFreeSpace, float& totalPositiveFlexibility, float& totalNegativeFlexibility, InflexibleFlexItemSize& inflexibleItems, WTF::Vector<LayoutUnit>& childSizes)
 {
     childSizes.clear();
-
     LayoutUnit flexboxAvailableContentExtent = mainAxisContentExtent();
     LayoutUnit totalViolation = 0;
     WTF::Vector<Violation> minViolations;
index 5f57547..6fa29e7 100644 (file)
@@ -702,6 +702,8 @@ static LayoutUnit computeMargin(const RenderInline* renderer, const Length& marg
         return margin.value();
     if (margin.isPercent())
         return minimumValueForLength(margin, max<LayoutUnit>(0, renderer->containingBlock()->availableLogicalWidth()));
+    if (margin.isViewportRelative())
+        return valueForLength(margin, 0, renderer->view());
     return 0;
 }
 
@@ -1313,10 +1315,10 @@ LayoutUnit RenderInline::lineHeight(bool firstLine, LineDirectionMode /*directio
     if (firstLine && document()->usesFirstLineRules()) {
         RenderStyle* s = style(firstLine);
         if (s != style())
-            return s->computedLineHeight();
+            return s->computedLineHeight(view());
     }
 
-    return style()->computedLineHeight();
+    return style()->computedLineHeight(view());
 }
 
 LayoutUnit RenderInline::baselinePosition(FontBaseline baselineType, bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const
index 039e3fb..ee96fc1 100644 (file)
@@ -162,7 +162,7 @@ void RenderMenuList::updateOptionsWidth()
             // Add in the option's text indent.  We can't calculate percentage values for now.
             float optionWidth = 0;
             if (RenderStyle* optionStyle = element->renderStyle())
-                optionWidth += minimumValueForLength(optionStyle->textIndent(), 0);
+                optionWidth += minimumValueForLength(optionStyle->textIndent(), 0, view());
             if (!text.isEmpty())
                 optionWidth += style()->font().width(text);
             maxOptionWidth = max(maxOptionWidth, optionWidth);
index e4c5a95..5b0175b 100755 (executable)
@@ -1442,7 +1442,7 @@ bool RenderObject::repaintAfterLayoutIfNeeded(RenderBoxModelObject* repaintConta
 
         int borderRight = isBox() ? toRenderBox(this)->borderRight() : 0;
         LayoutUnit boxWidth = isBox() ? toRenderBox(this)->width() : zeroLayoutUnit;
-        LayoutUnit borderWidth = max<LayoutUnit>(-outlineStyle->outlineOffset(), max<LayoutUnit>(borderRight, max<LayoutUnit>(valueForLength(style()->borderTopRightRadius().width(), boxWidth), valueForLength(style()->borderBottomRightRadius().width(), boxWidth)))) + max<LayoutUnit>(ow, shadowRight);
+        LayoutUnit borderWidth = max<LayoutUnit>(-outlineStyle->outlineOffset(), max<LayoutUnit>(borderRight, max<LayoutUnit>(valueForLength(style()->borderTopRightRadius().width(), boxWidth, v), valueForLength(style()->borderBottomRightRadius().width(), boxWidth, v)))) + max<LayoutUnit>(ow, shadowRight);
         LayoutRect rightRect(newOutlineBox.x() + min(newOutlineBox.width(), oldOutlineBox.width()) - borderWidth,
             newOutlineBox.y(),
             width + borderWidth,
@@ -1461,7 +1461,7 @@ bool RenderObject::repaintAfterLayoutIfNeeded(RenderBoxModelObject* repaintConta
 
         int borderBottom = isBox() ? toRenderBox(this)->borderBottom() : 0;
         LayoutUnit boxHeight = isBox() ? toRenderBox(this)->height() : zeroLayoutUnit;
-        LayoutUnit borderHeight = max<LayoutUnit>(-outlineStyle->outlineOffset(), max<LayoutUnit>(borderBottom, max<LayoutUnit>(valueForLength(style()->borderBottomLeftRadius().height(), boxHeight), valueForLength(style()->borderBottomRightRadius().height(), boxHeight)))) + max<LayoutUnit>(ow, shadowBottom);
+        LayoutUnit borderHeight = max<LayoutUnit>(-outlineStyle->outlineOffset(), max<LayoutUnit>(borderBottom, max<LayoutUnit>(valueForLength(style()->borderBottomLeftRadius().height(), boxHeight, v), valueForLength(style()->borderBottomRightRadius().height(), boxHeight, v)))) + max<LayoutUnit>(ow, shadowBottom);
         LayoutRect bottomRect(newOutlineBox.x(),
             min(newOutlineBox.maxY(), oldOutlineBox.maxY()) - borderHeight,
             max(newOutlineBox.width(), oldOutlineBox.width()),
index 4a27b8b..7bfb1d4 100644 (file)
@@ -145,7 +145,7 @@ void RenderReplaced::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
         else {
             // Push a clip if we have a border radius, since we want to round the foreground content that gets painted.
             paintInfo.context->save();
-            paintInfo.context->addRoundedRectClip(style()->getRoundedBorderFor(paintRect));
+            paintInfo.context->addRoundedRectClip(style()->getRoundedBorderFor(paintRect, view()));
         }
     }
 
index 858f560..5e6ee67 100644 (file)
@@ -79,41 +79,43 @@ void RenderScrollbarPart::layoutVerticalPart()
     } 
 }
 
-static int calcScrollbarThicknessUsing(const Length& l, int containingLength)
+static int calcScrollbarThicknessUsing(const Length& length, int containingLength, RenderView* renderView)
 {
-    if (l.isIntrinsicOrAuto())
+    if (length.isIntrinsicOrAuto())
         return ScrollbarTheme::theme()->scrollbarThickness();
-    return minimumValueForLength(l, containingLength);
+    return minimumValueForLength(length, containingLength, renderView);
 }
 
 void RenderScrollbarPart::computeScrollbarWidth()
 {
     if (!m_scrollbar->owningRenderer())
         return;
+    RenderView* renderView = view();
     int visibleSize = m_scrollbar->owningRenderer()->width() - m_scrollbar->owningRenderer()->borderLeft() - m_scrollbar->owningRenderer()->borderRight();
-    int w = calcScrollbarThicknessUsing(style()->width(), visibleSize);
-    int minWidth = calcScrollbarThicknessUsing(style()->minWidth(), visibleSize);
-    int maxWidth = style()->maxWidth().isUndefined() ? w : calcScrollbarThicknessUsing(style()->maxWidth(), visibleSize);
+    int w = calcScrollbarThicknessUsing(style()->width(), visibleSize, renderView);
+    int minWidth = calcScrollbarThicknessUsing(style()->minWidth(), visibleSize, renderView);
+    int maxWidth = style()->maxWidth().isUndefined() ? w : calcScrollbarThicknessUsing(style()->maxWidth(), visibleSize, renderView);
     setWidth(max(minWidth, min(maxWidth, w)));
     
     // Buttons and track pieces can all have margins along the axis of the scrollbar. 
-    m_marginLeft = minimumValueForLength(style()->marginLeft(), visibleSize);
-    m_marginRight = minimumValueForLength(style()->marginRight(), visibleSize);
+    m_marginLeft = minimumValueForLength(style()->marginLeft(), visibleSize, renderView);
+    m_marginRight = minimumValueForLength(style()->marginRight(), visibleSize, renderView);
 }
 
 void RenderScrollbarPart::computeScrollbarHeight()
 {
     if (!m_scrollbar->owningRenderer())
         return;
+    RenderView* renderView = view();
     int visibleSize = m_scrollbar->owningRenderer()->height() -  m_scrollbar->owningRenderer()->borderTop() - m_scrollbar->owningRenderer()->borderBottom();
-    int h = calcScrollbarThicknessUsing(style()->height(), visibleSize);
-    int minHeight = calcScrollbarThicknessUsing(style()->minHeight(), visibleSize);
-    int maxHeight = style()->maxHeight().isUndefined() ? h : calcScrollbarThicknessUsing(style()->maxHeight(), visibleSize);
+    int h = calcScrollbarThicknessUsing(style()->height(), visibleSize, renderView);
+    int minHeight = calcScrollbarThicknessUsing(style()->minHeight(), visibleSize, renderView);
+    int maxHeight = style()->maxHeight().isUndefined() ? h : calcScrollbarThicknessUsing(style()->maxHeight(), visibleSize, renderView);
     setHeight(max(minHeight, min(maxHeight, h)));
 
     // Buttons and track pieces can all have margins along the axis of the scrollbar. 
-    m_marginTop = minimumValueForLength(style()->marginTop(), visibleSize);
-    m_marginBottom = minimumValueForLength(style()->marginBottom(), visibleSize);
+    m_marginTop = minimumValueForLength(style()->marginTop(), visibleSize, renderView);
+    m_marginBottom = minimumValueForLength(style()->marginBottom(), visibleSize, renderView);
 }
 
 void RenderScrollbarPart::computePreferredLogicalWidths()
index 538203e..17039dc 100644 (file)
@@ -222,6 +222,7 @@ void RenderTable::computeLogicalWidth()
         computePositionedLogicalWidth();
 
     RenderBlock* cb = containingBlock();
+    RenderView* renderView = view();
 
     LayoutUnit availableLogicalWidth = containingBlockLogicalWidthForContent();
     bool hasPerpendicularContainingBlock = cb->style()->isHorizontalWritingMode() != style()->isHorizontalWritingMode();
@@ -232,10 +233,10 @@ void RenderTable::computeLogicalWidth()
         setLogicalWidth(convertStyleLogicalWidthToComputedWidth(styleLogicalWidth, containerWidthInInlineDirection));
     else {
         // Subtract out any fixed margins from our available width for auto width tables.
-        LayoutUnit marginStart = minimumValueForLength(style()->marginStart(), availableLogicalWidth);
-        LayoutUnit marginEnd = minimumValueForLength(style()->marginEnd(), availableLogicalWidth);
+        LayoutUnit marginStart = minimumValueForLength(style()->marginStart(), availableLogicalWidth, renderView);
+        LayoutUnit marginEnd = minimumValueForLength(style()->marginEnd(), availableLogicalWidth, renderView);
         LayoutUnit marginTotal = marginStart + marginEnd;
-        
+
         // Subtract out our margins to get the available content width.
         LayoutUnit availableContentLogicalWidth = max<LayoutUnit>(0, containerWidthInInlineDirection - marginTotal);
         if (shrinkToAvoidFloats() && cb->containsFloats() && !hasPerpendicularContainingBlock) {
@@ -261,8 +262,8 @@ void RenderTable::computeLogicalWidth()
     if (!hasPerpendicularContainingBlock)
         computeInlineDirectionMargins(cb, availableLogicalWidth, logicalWidth());
     else {
-        setMarginStart(minimumValueForLength(style()->marginStart(), availableLogicalWidth));
-        setMarginEnd(minimumValueForLength(style()->marginEnd(), availableLogicalWidth));
+        setMarginStart(minimumValueForLength(style()->marginStart(), availableLogicalWidth, renderView));
+        setMarginEnd(minimumValueForLength(style()->marginEnd(), availableLogicalWidth, renderView));
     }
 }
 
@@ -276,7 +277,7 @@ LayoutUnit RenderTable::convertStyleLogicalWidthToComputedWidth(const Length& st
         recalcBordersInRowDirection();
         borders = borderStart() + borderEnd() + (collapseBorders() ? 0 : paddingStart() + paddingEnd());
     }
-    return minimumValueForLength(styleLogicalWidth, availableWidth) + borders;
+    return minimumValueForLength(styleLogicalWidth, availableWidth, view()) + borders;
 }
 
 void RenderTable::layoutCaption(RenderTableCaption* caption)
index b8d344a..27e15f6 100644 (file)
@@ -95,7 +95,7 @@ LayoutUnit RenderTableCell::logicalHeightForRowSizing() const
 {
     LayoutUnit adjustedLogicalHeight = logicalHeight() - (intrinsicPaddingBefore() + intrinsicPaddingAfter());
 
-    LayoutUnit styleLogicalHeight = valueForLength(style()->logicalHeight(), 0);
+    LayoutUnit styleLogicalHeight = valueForLength(style()->logicalHeight(), 0, view());
     if (document()->inQuirksMode() || style()->boxSizing() == BORDER_BOX) {
         // Explicit heights use the border box in quirks mode.
         // Don't adjust height.
index 2541fbe..7235e25 100644 (file)
@@ -327,8 +327,9 @@ int RenderTableSection::calcRowLogicalHeight()
     RenderTableCell* cell;
 
     int spacing = table()->vBorderSpacing();
-
-    LayoutStateMaintainer statePusher(view());
+    
+    RenderView* viewRenderer = view();
+    LayoutStateMaintainer statePusher(viewRenderer);
 
     m_rowPos.resize(m_grid.size() + 1);
     m_rowPos[0] = spacing;
@@ -338,7 +339,7 @@ int RenderTableSection::calcRowLogicalHeight()
         LayoutUnit baselineDescent = 0;
 
         // Our base size is the biggest logical height from our cells' styles (excluding row spanning cells).
-        m_rowPos[r + 1] = max(m_rowPos[r] + minimumValueForLength(m_grid[r].logicalHeight, 0), 0);
+        m_rowPos[r + 1] = max(m_rowPos[r] + minimumValueForLength(m_grid[r].logicalHeight, 0, viewRenderer), 0);
 
         Row& row = m_grid[r].row;
         unsigned totalCols = row.size();
index 5705eb9..dcd8dd7 100644 (file)
@@ -24,6 +24,7 @@
 #define RenderText_h
 
 #include "RenderObject.h"
+#include "RenderView.h"
 #include <wtf/Forward.h>
 
 namespace WebCore {
@@ -99,8 +100,8 @@ public:
     virtual LayoutRect selectionRectForRepaint(RenderBoxModelObject* repaintContainer, bool clipToVisibleContent = true);
     virtual LayoutRect localCaretRect(InlineBox*, int caretOffset, LayoutUnit* extraWidthToEndOfLine = 0);
 
-    virtual LayoutUnit marginLeft() const { return minimumValueForLength(style()->marginLeft(), 0); }
-    virtual LayoutUnit marginRight() const { return minimumValueForLength(style()->marginRight(), 0); }
+    virtual LayoutUnit marginLeft() const { return minimumValueForLength(style()->marginLeft(), 0, view()); }
+    virtual LayoutUnit marginRight() const { return minimumValueForLength(style()->marginRight(), 0, view()); }
 
     virtual LayoutRect clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer) const;
 
index 43d5489..d9e2e86 100644 (file)
@@ -1074,7 +1074,7 @@ void RenderThemeMac::paintMenuListButtonGradients(RenderObject* o, const PaintIn
 
     GraphicsContextStateSaver stateSaver(*paintInfo.context);
 
-    RoundedRect border = o->style()->getRoundedBorderFor(r);
+    RoundedRect border = o->style()->getRoundedBorderFor(r, o->view());
     int radius = border.radii().topLeft().width();
 
     CGColorSpaceRef cspace = deviceRGBColorSpaceRef();
index 6600094..3b9a384 100644 (file)
@@ -191,6 +191,7 @@ public:
 
     IntervalArena* intervalArena();
 
+    IntSize viewportSize() const { return document()->viewportSize(); }
 protected:
     virtual void mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool useTransforms, bool fixed, TransformState&, bool* wasFixed = 0) const;
     virtual void mapAbsoluteToLocalPoint(bool fixed, bool useTransforms, TransformState&) const;
index ed8a095..da87a97 100644 (file)
@@ -278,7 +278,7 @@ void RenderWidget::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
 
         // Push a clip if we have a border radius, since we want to round the foreground content that gets painted.
         paintInfo.context->save();
-        paintInfo.context->addRoundedRectClip(style()->getRoundedBorderFor(borderRect));
+        paintInfo.context->addRoundedRectClip(style()->getRoundedBorderFor(borderRect, view()));
     }
 
     if (m_widget) {
index 705fb04..781a66b 100644 (file)
@@ -844,7 +844,7 @@ LayoutUnit RootInlineBox::verticalPositionForBox(InlineBox* box, VerticalPositio
         } else if (verticalAlign == BASELINE_MIDDLE)
             verticalPosition += -renderer->lineHeight(firstLine, lineDirection) / 2 + renderer->baselinePosition(baselineType(), firstLine, lineDirection);
         else if (verticalAlign == LENGTH)
-            verticalPosition -= valueForLength(renderer->style()->verticalAlignLength(), renderer->lineHeight(firstLine, lineDirection));
+            verticalPosition -= valueForLength(renderer->style()->verticalAlignLength(), renderer->lineHeight(firstLine, lineDirection), renderer->view());
     }
 
     // Store the cached value.
index 114d636..e4065bb 100644 (file)
@@ -874,17 +874,17 @@ void RenderStyle::setBoxShadow(PassOwnPtr<ShadowData> shadowData, bool add)
     rareData->m_boxShadow = shadowData;
 }
 
-static RoundedRect::Radii calcRadiiFor(const BorderData& border, LayoutSize size)
+static RoundedRect::Radii calcRadiiFor(const BorderData& border, LayoutSize size, RenderView* renderView)
 {
     return RoundedRect::Radii(
-        IntSize(valueForLength(border.topLeft().width(), size.width()), 
-                valueForLength(border.topLeft().height(), size.height())),
-        IntSize(valueForLength(border.topRight().width(), size.width()),
-                valueForLength(border.topRight().height(), size.height())),
-        IntSize(valueForLength(border.bottomLeft().width(), size.width()), 
-                valueForLength(border.bottomLeft().height(), size.height())),
-        IntSize(valueForLength(border.bottomRight().width(), size.width()), 
-                valueForLength(border.bottomRight().height(), size.height())));
+        IntSize(valueForLength(border.topLeft().width(), size.width(), renderView), 
+                valueForLength(border.topLeft().height(), size.height(), renderView)),
+        IntSize(valueForLength(border.topRight().width(), size.width(), renderView),
+                valueForLength(border.topRight().height(), size.height(), renderView)),
+        IntSize(valueForLength(border.bottomLeft().width(), size.width(), renderView), 
+                valueForLength(border.bottomLeft().height(), size.height(), renderView)),
+        IntSize(valueForLength(border.bottomRight().width(), size.width(), renderView), 
+                valueForLength(border.bottomRight().height(), size.height(), renderView)));
 }
 
 static float calcConstraintScaleFor(const IntRect& rect, const RoundedRect::Radii& radii)
@@ -919,11 +919,11 @@ static float calcConstraintScaleFor(const IntRect& rect, const RoundedRect::Radi
     return factor;
 }
 
-RoundedRect RenderStyle::getRoundedBorderFor(const LayoutRect& borderRect, bool includeLogicalLeftEdge, bool includeLogicalRightEdge) const
+RoundedRect RenderStyle::getRoundedBorderFor(const LayoutRect& borderRect, RenderView* renderView, bool includeLogicalLeftEdge, bool includeLogicalRightEdge) const
 {
     RoundedRect roundedRect(pixelSnappedIntRect(borderRect));
     if (hasBorderRadius()) {
-        RoundedRect::Radii radii = calcRadiiFor(surround->border, borderRect.size());
+        RoundedRect::Radii radii = calcRadiiFor(surround->border, borderRect.size(), renderView);
         radii.scale(calcConstraintScaleFor(borderRect, radii));
         roundedRect.includeLogicalEdges(radii, isHorizontalWritingMode(), includeLogicalLeftEdge, includeLogicalRightEdge);
     }
index e9acce8..f680181 100644 (file)
@@ -622,7 +622,7 @@ public:
     bool isLeftToRightDirection() const { return direction() == LTR; }
 
     Length lineHeight() const { return inherited->line_height; }
-    int computedLineHeight() const
+    int computedLineHeight(RenderView* renderView = 0) const
     {
         const Length& lh = inherited->line_height;
 
@@ -633,6 +633,9 @@ public:
         if (lh.isPercent())
             return minimumValueForLength(lh, fontSize());
 
+        if (lh.isViewportRelative())
+            return valueForLength(lh, 0, renderView);
+
         return lh.value();
     }
 
@@ -1065,7 +1068,7 @@ public:
         setBorderRadius(LengthSize(Length(s.width(), Fixed), Length(s.height(), Fixed)));
     }
     
-    RoundedRect getRoundedBorderFor(const LayoutRect& borderRect, bool includeLogicalLeftEdge = true, bool includeLogicalRightEdge = true) const;
+    RoundedRect getRoundedBorderFor(const LayoutRect& borderRect, RenderView* = 0, bool includeLogicalLeftEdge = true, bool includeLogicalRightEdge = true) const;
     RoundedRect getRoundedInnerBorderFor(const LayoutRect& borderRect, bool includeLogicalLeftEdge = true, bool includeLogicalRightEdge = true) const;
 
     RoundedRect getRoundedInnerBorderFor(const LayoutRect& borderRect,
index fb06bf1..d5d5954 100644 (file)
@@ -153,9 +153,9 @@ bool RenderSVGRoot::isEmbeddedThroughFrameContainingSVGDocument() const
     return frame->document()->isSVGDocument();
 }
 
-static inline LayoutUnit resolveLengthAttributeForSVG(const Length& length, float scale, float maxSize)
+static inline LayoutUnit resolveLengthAttributeForSVG(const Length& length, float scale, float maxSize, RenderView* renderView)
 {
-    return static_cast<LayoutUnit>(valueForLength(length, maxSize) * (length.isFixed() ? scale : 1));
+    return static_cast<LayoutUnit>(valueForLength(length, maxSize, renderView) * (length.isFixed() ? scale : 1));
 }
 
 LayoutUnit RenderSVGRoot::computeReplacedLogicalWidth(bool includeMaxWidth) const
@@ -171,7 +171,7 @@ LayoutUnit RenderSVGRoot::computeReplacedLogicalWidth(bool includeMaxWidth) cons
         return RenderReplaced::computeReplacedLogicalWidth(includeMaxWidth);
 
     if (svg->widthAttributeEstablishesViewport())
-        return resolveLengthAttributeForSVG(svg->intrinsicWidth(SVGSVGElement::IgnoreCSSProperties), style()->effectiveZoom(), containingBlock()->availableLogicalWidth());
+        return resolveLengthAttributeForSVG(svg->intrinsicWidth(SVGSVGElement::IgnoreCSSProperties), style()->effectiveZoom(), containingBlock()->availableLogicalWidth(), view());
 
     // Only SVGs embedded in <object> reach this point.
     ASSERT(isEmbeddedThroughFrameContainingSVGDocument());
@@ -202,7 +202,7 @@ LayoutUnit RenderSVGRoot::computeReplacedLogicalHeight() const
         } else
             RenderBlock::removePercentHeightDescendant(const_cast<RenderSVGRoot*>(this));
 
-        return resolveLengthAttributeForSVG(height, style()->effectiveZoom(), containingBlock()->availableLogicalHeight());
+        return resolveLengthAttributeForSVG(height, style()->effectiveZoom(), containingBlock()->availableLogicalHeight(), view());
     }
 
     // Only SVGs embedded in <object> reach this point.