summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGurpreet Kaur <k.gurpreet@samsung.com>2016-03-28 20:08:16 +0300
committerKonstantin Tokarev <annulen@yandex.ru>2016-09-27 07:16:35 +0000
commita7a5227e2ca154172d19cdde023ca6ea76070369 (patch)
treee6a65591f298d3914685e3f4ec0b82e3258108b7
parent490b7b65edbd06da0818c0ac765ca6ebd219dce3 (diff)
downloadqtwebkit-a7a5227e2ca154172d19cdde023ca6ea76070369.tar.gz
CSS Unit vw in border-width maps to 0px
https://bugs.webkit.org/show_bug.cgi?id=109229 Patch by Gurpreet Kaur <k.gurpreet@samsung.com> on 2013-09-12 Reviewed by Darin Adler. Source/WebCore: Border and outline properties were not applied incase its values were given in vh/vw units. Tests: fast/css/viewport-height-border.html fast/css/viewport-height-outline.html fast/css/viewport-width-border.html fast/css/viewport-width-outline.html * css/CSSPrimitiveValue.cpp: (WebCore::CSSPrimitiveValue::computeLengthDouble): Added case CSS_VH and CSS_VW. * css/CSSPrimitiveValue.h: (WebCore::CSSPrimitiveValue::isViewportPercentageWidth): (WebCore::CSSPrimitiveValue::isViewportPercentageHeight): Added APIs to check the unit type(CSS_VW and CSS_VH). * css/DeprecatedStyleBuilder.cpp: (WebCore::ApplyPropertyComputeLength::applyValue): Calculating the border values which has been specified in vh/vw units.The vh/vw units are calcultated as percent of viewport height and viewport width respectively. LayoutTests: * fast/css/viewport-height-border-expected.txt: Added. * fast/css/viewport-height-border.html: Added. * fast/css/viewport-height-outline-expected.txt: Added. * fast/css/viewport-height-outline.html: Added. * fast/css/viewport-width-border-expected.txt: Added. * fast/css/viewport-width-border.html: Added. * fast/css/viewport-width-outline-expected.txt: Added. * fast/css/viewport-width-outline.html: Added. Added new tests for verifying that border and outline properties are applied when its values are given in vh/vw units. * resources/js-test-pre.js: (shouldNotBeEqualToString): Added this API so that can compare two strings.Similiar to shouldBeEqualToString. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@155624 268f45cc-cd09-0410-ab3c-d52691b4dbfc Change-Id: I77c04e5ace2d16158502295622132551a8b866fd Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
-rw-r--r--Source/WebCore/css/CSSPrimitiveValue.cpp4
-rw-r--r--Source/WebCore/css/CSSPrimitiveValue.h2
-rw-r--r--Source/WebCore/css/DeprecatedStyleBuilder.cpp6
3 files changed, 11 insertions, 1 deletions
diff --git a/Source/WebCore/css/CSSPrimitiveValue.cpp b/Source/WebCore/css/CSSPrimitiveValue.cpp
index f3902c7be..3ee8cdf53 100644
--- a/Source/WebCore/css/CSSPrimitiveValue.cpp
+++ b/Source/WebCore/css/CSSPrimitiveValue.cpp
@@ -600,6 +600,10 @@ double CSSPrimitiveValue::computeLengthDouble(const RenderStyle* style, const Re
case CSS_CALC_PERCENTAGE_WITH_NUMBER:
ASSERT_NOT_REACHED();
return -1.0;
+ case CSS_VH:
+ case CSS_VW:
+ factor = 1.0;
+ break;
default:
ASSERT_NOT_REACHED();
return -1.0;
diff --git a/Source/WebCore/css/CSSPrimitiveValue.h b/Source/WebCore/css/CSSPrimitiveValue.h
index 28ae4e882..88acf041c 100644
--- a/Source/WebCore/css/CSSPrimitiveValue.h
+++ b/Source/WebCore/css/CSSPrimitiveValue.h
@@ -202,6 +202,8 @@ public:
bool isVariableName() const { return primitiveType() == CSS_VARIABLE_NAME; }
#endif
bool isViewportPercentageLength() const { return m_primitiveUnitType >= CSS_VW && m_primitiveUnitType <= CSS_VMAX; }
+ bool isViewportPercentageWidth() const { return m_primitiveUnitType == CSS_VW; }
+ bool isViewportPercentageHeight() const { return m_primitiveUnitType == CSS_VH; }
bool isValueID() const { return m_primitiveUnitType == CSS_VALUE_ID; }
static PassRefPtr<CSSPrimitiveValue> createIdentifier(CSSValueID valueID) { return adoptRef(new CSSPrimitiveValue(valueID)); }
diff --git a/Source/WebCore/css/DeprecatedStyleBuilder.cpp b/Source/WebCore/css/DeprecatedStyleBuilder.cpp
index 68bb3bcb7..7c6105285 100644
--- a/Source/WebCore/css/DeprecatedStyleBuilder.cpp
+++ b/Source/WebCore/css/DeprecatedStyleBuilder.cpp
@@ -31,6 +31,7 @@
#include "CSSAspectRatioValue.h"
#include "CSSCalculationValue.h"
#include "CSSCursorImageValue.h"
+#include "CSSPrimitiveValue.h"
#include "CSSPrimitiveValueMappings.h"
#include "CSSToStyleMap.h"
#include "CSSValueList.h"
@@ -612,7 +613,10 @@ public:
if (originalLength >= 1.0)
length = 1.0;
}
-
+ if (primitiveValue->isViewportPercentageHeight())
+ length = styleResolver->document()->renderView()->viewportSize().height() * length / 100.0f;
+ else if (primitiveValue->isViewportPercentageWidth())
+ length = styleResolver->document()->renderView()->viewportSize().width() * length / 100.0f;
} else {
ASSERT_NOT_REACHED();
length = 0;