+2012-06-26 Dave Tharp <dtharp@codeaurora.org>
+
+ ietestcenter/css3/valuesandunits/units-000.htm asserts
+ https://bugs.webkit.org/show_bug.cgi?id=86176
+
+ Reviewed by Beth Dakin.
+
+ Adding explicit tests for viewport border length tests. Inspired by IE Test center
+ units-000 test which highlighted that vw, vh, and vmin were not being handled in computeLengthDouble().
+ Also, adjusting test_expectations and Skipped for units-000, which no longer Asserts with this
+ patch implemented.
+
+ * css3/viewport-percentage-lengths/css3-viewport-percentage-lengths-vh-border-expected.html: Added.
+ * css3/viewport-percentage-lengths/css3-viewport-percentage-lengths-vh-border.html: Added.
+ * css3/viewport-percentage-lengths/css3-viewport-percentage-lengths-vmin-border-expected.html: Added.
+ * css3/viewport-percentage-lengths/css3-viewport-percentage-lengths-vmin-border.html: Added.
+ * css3/viewport-percentage-lengths/css3-viewport-percentage-lengths-vw-border-expected.htm: Added.
+ * css3/viewport-percentage-lengths/css3-viewport-percentage-lengths-vw-border.html: Added.
+ * ietestcenter/css3/valuesandunits/units-000.htm:
+ * platform/chromium/TestExpectations:
+ * platform/efl/TestExpectations:
+ * platform/gtk/TestExpectations:
+ * platform/mac/TestExpectations:
+ * platform/qt/TestExpectations:
+
2012-06-26 Filip Pizlo <fpizlo@apple.com>
DFG::operationNewArray is unnecessarily slow, and may use the wrong array
--- /dev/null
+<!DOCTYPE html PUBLIC "-//W3C//DTD//XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>CSS Test: vh unit - Reference</title>
+ <link rel="author" title="Codeaurora" href="http://www.codeaurora.org/" />
+ <link rel="help" href="http://www.w3.org/TR/CSS21/" />
+ <style type="text/css">
+ body div
+ {
+ font: 16px/1em ahem;
+ color: green;
+ height: 16px;
+ }
+ #parent
+ {
+ background: green;
+ position: relative;
+ overflow: hidden;
+ width: 1in;
+ height: 1in;
+ }
+ </style>
+ </head>
+ <body>
+ <p>Test passes if there is no red visible on the page.</p>
+ <div id="parent">
+ </div>
+ </body>
+</html>
--- /dev/null
+<!DOCTYPE html PUBLIC "-//W3C//DTD//XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>CSS Test: vh unit</title>
+ <link rel="author" title="Codeaurora" href="http://www.codeaurora.org/" />
+ <link rel="help" href="http://www.w3.org/TR/CSS21/" />
+ <meta name="assert" content="Verifying vh unit values are supported." />
+ <style type="text/css">
+ body div
+ {
+ font: 16px/1em ahem;
+ color: green;
+ height: 16px;
+ }
+ #parent
+ {
+ background: red;
+ position: relative;
+ overflow: hidden;
+ width: 1in;
+ height: 1in;
+ }
+ #div-vh
+ {
+ border-right: solid green 100vh;
+ height: 16px;
+ width: 0;
+ }
+ #div-fill
+ {
+ background: green;
+ width: 1in;
+ height: 80px;
+ }
+ </style>
+ </head>
+ <body>
+ <p>Test passes if there is no red visible on the page.</p>
+ <div id="parent">
+ <div id="div-vh"></div>
+ <div id="div-fill"></div>
+ </div>
+ </body>
+</html>
--- /dev/null
+<!DOCTYPE html PUBLIC "-//W3C//DTD//XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>CSS Test: vmin unit - Reference</title>
+ <link rel="author" title="Codeaurora" href="http://www.codeaurora.org/" />
+ <link rel="help" href="http://www.w3.org/TR/CSS21/" />
+ <style type="text/css">
+ body div
+ {
+ font: 16px/1em ahem;
+ color: green;
+ height: 16px;
+ }
+ #parent
+ {
+ background: green;
+ position: relative;
+ overflow: hidden;
+ width: 1in;
+ height: 112px;
+ }
+ </style>
+ </head>
+ <body>
+ <p>Test passes if there is no red visible on the page.</p>
+ <div id="parent">
+ </div>
+ </body>
+</html>
--- /dev/null
+<!DOCTYPE html PUBLIC "-//W3C//DTD//XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>CSS Test: vmin unit</title>
+ <link rel="author" title="Codeaurora" href="http://www.codeaurora.org/" />
+ <link rel="help" href="http://www.w3.org/TR/CSS21/" />
+ <meta name="assert" content="Verifying vmin unit values are supported." />
+ <style type="text/css">
+ body div
+ {
+ font: 16px/1em ahem;
+ color: green;
+ height: 16px;
+ }
+ #parent
+ {
+ background: red;
+ position: relative;
+ overflow: hidden;
+ width: 1in;
+ height: 112px;
+ }
+ #div-vh
+ {
+ border-right: solid green 100vmin;
+ height: 16px;
+ width: 0;
+ }
+ #div-fill
+ {
+ background: green;
+ width: 1in;
+ height: 96px;
+ }
+ </style>
+ </head>
+ <body>
+ <p>Test passes if there is no red visible on the page.</p>
+ <div id="parent">
+ <div id="div-vh"></div>
+ <div id="div-fill"></div>
+ </div>
+ </body>
+</html>
--- /dev/null
+<!DOCTYPE html PUBLIC "-//W3C//DTD//XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>CSS Test: vw unit - Reference</title>
+ <link rel="author" title="Codeaurora" href="http://www.codeaurora.org/" />
+ <link rel="help" href="http://www.w3.org/TR/CSS21/" />
+ <style type="text/css">
+ body div
+ {
+ font: 16px/1em ahem;
+ color: green;
+ height: 16px;
+ }
+ #parent
+ {
+ background: green;
+ position: relative;
+ overflow: hidden;
+ width: 1in;
+ height: 16px;
+ }
+ </style>
+ </head>
+ <body>
+ <p>Test passes if there is no red visible on the page.</p>
+ <div id="parent">
+ </div>
+ </body>
+</html>
--- /dev/null
+<!DOCTYPE html PUBLIC "-//W3C//DTD//XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>CSS Test: vw unit</title>
+ <link rel="author" title="Codeaurora" href="http://www.codeaurora.org/" />
+ <link rel="help" href="http://www.w3.org/TR/CSS21/" />
+ <meta name="assert" content="Verifying vw unit values are supported." />
+ <style type="text/css">
+ body div
+ {
+ font: 16px/1em ahem;
+ color: green;
+ height: 16px;
+ }
+ #parent
+ {
+ background: red;
+ position: relative;
+ overflow: hidden;
+ width: 1in;
+ height: 16px;
+ }
+ #div-vh
+ {
+ border-right: solid green 100vw;
+ height: 16px;
+ width: 0;
+ }
+ </style>
+ </head>
+ <body>
+ <p>Test passes if there is no red visible on the page.</p>
+ <div id="parent">
+ <div id="div-vh"></div>
+ </div>
+ </body>
+</html>
}
#div12
{
- border-right: solid green 100vm;
+ border-right: solid green 100vmin;
height: 16px;
width: 0;
}
BUGWK85211 : ietestcenter/css3/flexbox/flexbox-align-stretch-001.htm = IMAGE
BUGWK85212 : ietestcenter/css3/flexbox/flexbox-layout-002.htm = IMAGE
// IETC CSS units
-BUGWK85308 DEBUG : ietestcenter/css3/valuesandunits/units-000.htm = CRASH
-BUGWK85308 RELEASE : ietestcenter/css3/valuesandunits/units-000.htm = IMAGE
+BUGWK85308 : ietestcenter/css3/valuesandunits/units-000.htm = IMAGE
BUGWK85310 : ietestcenter/css3/valuesandunits/units-010.htm = IMAGE
// IETC namespace failures
BUGWK86137 : ietestcenter/css3/namespaces/prefix-007.xml = IMAGE
BUGWKEFL SLOW DEBUG : http/tests/incremental/slow-utf8-html.pl = PASS
// Tests imported in r116658
-BUGWK85308 : ietestcenter/css3/valuesandunits/units-000.htm = IMAGE CRASH
+BUGWK85308 : ietestcenter/css3/valuesandunits/units-000.htm = IMAGE
BUGWK85310 : ietestcenter/css3/valuesandunits/units-010.htm = IMAGE
// New test introduced in r116694 fails
BUGWK86443 : plugins/npruntime/delete-plugin-within-getProperty.html = CRASH
BUGWK86443 : plugins/npruntime/delete-plugin-within-invoke.html = CRASH
-BUGWK86176 DEBUG : ietestcenter/css3/valuesandunits/units-000.htm = CRASH
-
BUGWK89188 RELEASE : storage/websql/quota-tracking.html = CRASH PASS
BUGWK89954 DEBUG : http/tests/xmlhttprequest/reentrant-cancel.html = CRASH
// Started failing after it was added in r116563
BUGWK86061 : http/tests/security/referrer-policy-redirect-link.html = TEXT
-BUGWK85308 RELEASE : ietestcenter/css3/valuesandunits/units-000.htm = IMAGE
+// IETC Units test failures
+BUGWK85308 : ietestcenter/css3/valuesandunits/units-000.htm = IMAGE
BUGWK85310 : ietestcenter/css3/valuesandunits/units-010.htm = IMAGE
// IETC namespace failures
// Interferes with the tests that should pass
BUGWK85689 SKIP : fast/animation/request-animation-frame-disabled.html = TEXT
-// Hits assert https://bugs.webkit.org/show_bug.cgi?id=86208
-BUGWK85308 SKIP : ietestcenter/css3/valuesandunits/units-000.htm = IMAGE
+// IETC units test failures
+BUGWK85308 : ietestcenter/css3/valuesandunits/units-000.htm = IMAGE
BUGWK85310 : ietestcenter/css3/valuesandunits/units-010.htm = IMAGE
// IETC namespace failures
// Interferes with the tests that should pass
BUGWK85689 SKIP : fast/animation/request-animation-frame-disabled.html = TEXT
-// ietestcenter/css3/valuesandunits/units-000.htm asserts
-// https://bugs.webkit.org/show_bug.cgi?id=86176
-BUGWK85308 SKIP : ietestcenter/css3/valuesandunits/units-000.htm = IMAGE
+// IETC units test failures
+BUGWK85308 : ietestcenter/css3/valuesandunits/units-000.htm = IMAGE
BUGWK85310 : ietestcenter/css3/valuesandunits/units-010.htm = IMAGE
// IETC namespace failures
+2012-06-26 Dave Tharp <dtharp@codeaurora.org>
+
+ ietestcenter/css3/valuesandunits/units-000.htm asserts
+ https://bugs.webkit.org/show_bug.cgi?id=86176
+
+ Reviewed by Beth Dakin.
+
+ Modified computeLengthDouble() to handle vh, vw, and vmin units. Per the spec
+ (http://dev.w3.org/csswg/css3-values/#viewport-relative-lengths) viewport -percentage
+ lengths are "relative to the size of the initial containing block", which I read to be
+ the size of the parent element. Since parentStyle was not available in computeLengthDouble,
+ most of the changes for this patch involved "pushing down" the parentStyle pointer through
+ the network of computeLength methods and dependencies.
+
+ Tests: css3/viewport-percentage-lengths/css3-viewport-percentage-lengths-vh-border.html
+ css3/viewport-percentage-lengths/css3-viewport-percentage-lengths-vmin-border.html
+ css3/viewport-percentage-lengths/css3-viewport-percentage-lengths-vw-border.html
+
+ * css/CSSCalculationValue.cpp:
+ (WebCore::CSSCalcValue::computeLengthPx):
+ (WebCore::CSSCalcPrimitiveValue::toCalcValue):
+ (WebCore::CSSCalcPrimitiveValue::computeLengthPx):
+ (WebCore::CSSCalcBinaryOperation::toCalcValue):
+ (WebCore::CSSCalcBinaryOperation::computeLengthPx):
+ * css/CSSCalculationValue.h:
+ (CSSCalcExpressionNode):
+ (WebCore::CSSCalcValue::toCalcValue):
+ (CSSCalcValue):
+ * css/CSSGradientValue.cpp:
+ (WebCore::CSSGradientValue::addStops):
+ (WebCore::positionFromValue):
+ (WebCore::CSSGradientValue::computeEndPoint):
+ (WebCore::CSSLinearGradientValue::createGradient):
+ (WebCore::CSSRadialGradientValue::resolveRadius):
+ (WebCore::CSSRadialGradientValue::createGradient):
+ * css/CSSGradientValue.h:
+ (CSSGradientValue):
+ (CSSRadialGradientValue):
+ * css/CSSPrimitiveValue.cpp:
+ (WebCore::CSSPrimitiveValue::computeLength):
+ (WebCore::CSSPrimitiveValue::computeLengthDouble):
+ * css/CSSPrimitiveValue.h:
+ (CSSPrimitiveValue):
+ * css/CSSPrimitiveValueMappings.h:
+ (WebCore::CSSPrimitiveValue::convertToLength):
+ * css/CSSToStyleMap.cpp:
+ (WebCore::CSSToStyleMap::parentStyle):
+ (WebCore):
+ (WebCore::CSSToStyleMap::mapFillSize):
+ (WebCore::CSSToStyleMap::mapFillXPosition):
+ (WebCore::CSSToStyleMap::mapFillYPosition):
+ (WebCore::CSSToStyleMap::mapNinePieceImageQuad):
+ * css/CSSToStyleMap.h:
+ (CSSToStyleMap):
+ * css/MediaQueryEvaluator.cpp:
+ (WebCore::computeLength):
+ (WebCore::device_heightMediaFeatureEval):
+ (WebCore::device_widthMediaFeatureEval):
+ (WebCore::heightMediaFeatureEval):
+ (WebCore::widthMediaFeatureEval):
+ * css/SVGCSSStyleSelector.cpp:
+ (WebCore::StyleResolver::applySVGProperty):
+ * css/StyleBuilder.cpp:
+ (WebCore::ApplyPropertyAuto::applyValue):
+ (WebCore::ApplyPropertyClip::convertToLength):
+ (WebCore::ApplyPropertyLength::applyValue):
+ (WebCore::ApplyPropertyBorderRadius::applyValue):
+ (WebCore::ApplyPropertyComputeLength::applyValue):
+ (WebCore::ApplyPropertyFontSize::applyValue):
+ (WebCore::ApplyPropertyLineHeight::applyValue):
+ (WebCore::ApplyPropertyPageSize::mmLength):
+ (WebCore::ApplyPropertyPageSize::inchLength):
+ (WebCore::ApplyPropertyPageSize::applyValue):
+ (WebCore::ApplyPropertyVerticalAlign::applyValue):
+ * css/StyleResolver.cpp:
+ (WebCore::StyleResolver::collectMatchingRulesForList):
+ * css/StyleResolver.h:
+ (WebCore::StyleResolver::parentNode):
+ (StyleResolver):
+ * css/WebKitCSSMatrix.cpp:
+ (WebCore::WebKitCSSMatrix::setMatrixValue):
+
2012-06-25 James Robinson <jamesr@chromium.org>
[chromium] Add WebLayer API for scrolling
return clampToPermittedRange(m_expression->doubleValue());
}
-double CSSCalcValue::computeLengthPx(RenderStyle* currentStyle, RenderStyle* rootStyle, double multiplier, bool computingFontSize) const
+double CSSCalcValue::computeLengthPx(RenderStyle* currentStyle, RenderStyle* rootStyle, RenderStyle* parentStyle, double multiplier, bool computingFontSize) const
{
- return clampToPermittedRange(m_expression->computeLengthPx(currentStyle, rootStyle, multiplier, computingFontSize));
+ return clampToPermittedRange(m_expression->computeLengthPx(currentStyle, rootStyle, parentStyle, multiplier, computingFontSize));
}
CSSCalcExpressionNode::~CSSCalcExpressionNode()
return m_value->cssText();
}
- virtual PassOwnPtr<CalcExpressionNode> toCalcValue(RenderStyle* style, RenderStyle* rootStyle, double zoom) const
+ virtual PassOwnPtr<CalcExpressionNode> toCalcValue(RenderStyle* style, RenderStyle* rootStyle, RenderStyle* parentStyle, double zoom) const
{
switch (m_category) {
case CalcNumber:
return adoptPtr(new CalcExpressionNumber(m_value->getFloatValue()));
case CalcLength:
- return adoptPtr(new CalcExpressionNumber(m_value->computeLength<float>(style, rootStyle, zoom)));
+ return adoptPtr(new CalcExpressionNumber(m_value->computeLength<float>(style, rootStyle, parentStyle, zoom)));
case CalcPercent:
case CalcPercentLength:
- return adoptPtr(new CalcExpressionLength(StyleResolver::convertToFloatLength(m_value.get(), style, rootStyle, zoom)));
+ return adoptPtr(new CalcExpressionLength(StyleResolver::convertToFloatLength(m_value.get(), style, rootStyle, parentStyle, zoom)));
// Only types that could be part of a Length expression can be converted
// to a CalcExpressionNode. CalcPercentNumber makes no sense as a Length.
case CalcPercentNumber:
return 0;
}
- virtual double computeLengthPx(RenderStyle* currentStyle, RenderStyle* rootStyle, double multiplier, bool computingFontSize) const
+ virtual double computeLengthPx(RenderStyle* currentStyle, RenderStyle* rootStyle, RenderStyle* parentStyle, double multiplier, bool computingFontSize) const
{
switch (m_category) {
case CalcLength:
- return m_value->computeLength<double>(currentStyle, rootStyle, multiplier, computingFontSize);
+ return m_value->computeLength<double>(currentStyle, rootStyle, parentStyle, multiplier, computingFontSize);
case CalcPercent:
case CalcNumber:
return m_value->getDoubleValue();
return !doubleValue();
}
- virtual PassOwnPtr<CalcExpressionNode> toCalcValue(RenderStyle* style, RenderStyle* rootStyle, double zoom) const
+ virtual PassOwnPtr<CalcExpressionNode> toCalcValue(RenderStyle* style, RenderStyle* rootStyle, RenderStyle* parentStyle, double zoom) const
{
- OwnPtr<CalcExpressionNode> left(m_leftSide->toCalcValue(style, rootStyle, zoom));
+ OwnPtr<CalcExpressionNode> left(m_leftSide->toCalcValue(style, rootStyle, parentStyle, zoom));
if (!left)
return nullptr;
- OwnPtr<CalcExpressionNode> right(m_rightSide->toCalcValue(style, rootStyle, zoom));
+ OwnPtr<CalcExpressionNode> right(m_rightSide->toCalcValue(style, rootStyle, parentStyle, zoom));
if (!right)
return nullptr;
return adoptPtr(new CalcExpressionBinaryOperation(left.release(), right.release(), m_operator));
return evaluate(m_leftSide->doubleValue(), m_rightSide->doubleValue());
}
- virtual double computeLengthPx(RenderStyle* currentStyle, RenderStyle* rootStyle, double multiplier, bool computingFontSize) const
+ virtual double computeLengthPx(RenderStyle* currentStyle, RenderStyle* rootStyle, RenderStyle* parentStyle, double multiplier, bool computingFontSize) const
{
- const double leftValue = m_leftSide->computeLengthPx(currentStyle, rootStyle, multiplier, computingFontSize);
- const double rightValue = m_rightSide->computeLengthPx(currentStyle, rootStyle, multiplier, computingFontSize);
+ const double leftValue = m_leftSide->computeLengthPx(currentStyle, rootStyle, parentStyle, multiplier, computingFontSize);
+ const double rightValue = m_rightSide->computeLengthPx(currentStyle, rootStyle, parentStyle, multiplier, computingFontSize);
return evaluate(leftValue, rightValue);
}
virtual ~CSSCalcExpressionNode() = 0;
virtual bool isZero() const = 0;
- virtual PassOwnPtr<CalcExpressionNode> toCalcValue(RenderStyle*, RenderStyle* rootStyle, double zoom = 1.0) const = 0;
+ virtual PassOwnPtr<CalcExpressionNode> toCalcValue(RenderStyle*, RenderStyle* rootStyle, RenderStyle* parentStyle, double zoom = 1.0) const = 0;
virtual double doubleValue() const = 0;
- virtual double computeLengthPx(RenderStyle* currentStyle, RenderStyle* rootStyle, double multiplier = 1.0, bool computingFontSize = false) const = 0;
+ virtual double computeLengthPx(RenderStyle* currentStyle, RenderStyle* rootStyle, RenderStyle* parentStyle, double multiplier = 1.0, bool computingFontSize = false) const = 0;
virtual String customCssText() const = 0;
CalculationCategory category() const { return m_category; }
static PassRefPtr<CSSCalcValue> create(CSSParserString name, CSSParserValueList*, CalculationPermittedValueRange);
static PassRefPtr<CSSCalcValue> create(CalculationValue*);
- PassRefPtr<CalculationValue> toCalcValue(RenderStyle* style, RenderStyle* rootStyle, double zoom = 1.0) const
+ PassRefPtr<CalculationValue> toCalcValue(RenderStyle* style, RenderStyle* rootStyle, RenderStyle* parentStyle, double zoom = 1.0) const
{
- return CalculationValue::create(m_expression->toCalcValue(style, rootStyle, zoom), m_nonNegative ? CalculationRangeNonNegative : CalculationRangeAll);
+ return CalculationValue::create(m_expression->toCalcValue(style, rootStyle, parentStyle, zoom), m_nonNegative ? CalculationRangeNonNegative : CalculationRangeAll);
}
CalculationCategory category() const { return m_expression->category(); }
bool isInt() const { return m_expression->isInteger(); }
double doubleValue() const;
bool isNegative() const { return m_expression->doubleValue() < 0; }
- double computeLengthPx(RenderStyle* currentStyle, RenderStyle* rootStyle, double multiplier = 1.0, bool computingFontSize = false) const;
+ double computeLengthPx(RenderStyle* currentStyle, RenderStyle* rootStyle, RenderStyle* parentStyle, double multiplier = 1.0, bool computingFontSize = false) const;
String customCssText() const;
{ }
};
-void CSSGradientValue::addStops(Gradient* gradient, RenderObject* renderer, RenderStyle* rootStyle, float maxLengthForRepeat)
+void CSSGradientValue::addStops(Gradient* gradient, RenderObject* renderer, RenderStyle* rootStyle, RenderStyle* parentStyle, float maxLengthForRepeat)
{
RenderStyle* style = renderer->style();
}
float length;
if (stop.m_position->isLength())
- length = stop.m_position->computeLength<float>(style, rootStyle, style->effectiveZoom());
+ length = stop.m_position->computeLength<float>(style, rootStyle, parentStyle, style->effectiveZoom());
else
- length = stop.m_position->cssCalcValue()->toCalcValue(style, rootStyle, style->effectiveZoom())->evaluate(gradientLength);
+ length = stop.m_position->cssCalcValue()->toCalcValue(style, rootStyle, parentStyle, style->effectiveZoom())->evaluate(gradientLength);
stops[i].offset = (gradientLength > 0) ? length / gradientLength : 0;
} else {
ASSERT_NOT_REACHED();
gradient->setStopsSorted(true);
}
-static float positionFromValue(CSSPrimitiveValue* value, RenderStyle* style, RenderStyle* rootStyle, const IntSize& size, bool isHorizontal)
+static float positionFromValue(CSSPrimitiveValue* value, RenderStyle* style, RenderStyle* rootStyle, RenderStyle* parentStyle, const IntSize& size, bool isHorizontal)
{
float zoomFactor = style->effectiveZoom();
return value->getFloatValue() / 100.f * edgeDistance;
if (value->isCalculatedPercentageWithLength())
- return value->cssCalcValue()->toCalcValue(style, rootStyle, style->effectiveZoom())->evaluate(edgeDistance);
+ return value->cssCalcValue()->toCalcValue(style, rootStyle, parentStyle, style->effectiveZoom())->evaluate(edgeDistance);
switch (value->getIdent()) {
case CSSValueTop:
return size.width();
}
- return value->computeLength<float>(style, rootStyle, zoomFactor);
+ return value->computeLength<float>(style, rootStyle, parentStyle, zoomFactor);
}
-FloatPoint CSSGradientValue::computeEndPoint(CSSPrimitiveValue* first, CSSPrimitiveValue* second, RenderStyle* style, RenderStyle* rootStyle, const IntSize& size)
+FloatPoint CSSGradientValue::computeEndPoint(CSSPrimitiveValue* first, CSSPrimitiveValue* second, RenderStyle* style, RenderStyle* rootStyle, RenderStyle* parentStyle, const IntSize& size)
{
FloatPoint result;
if (first)
- result.setX(positionFromValue(first, style, rootStyle, size, true));
+ result.setX(positionFromValue(first, style, rootStyle, parentStyle, size, true));
if (second)
- result.setY(positionFromValue(second, style, rootStyle, size, false));
+ result.setY(positionFromValue(second, style, rootStyle, parentStyle, size, false));
return result;
}
ASSERT(!size.isEmpty());
RenderStyle* rootStyle = renderer->document()->documentElement()->renderStyle();
+ RenderObject* parent = renderer->parent();
+ RenderStyle* parentStyle = parent ? parent->style() : 0;
FloatPoint firstPoint;
FloatPoint secondPoint;
float angle = m_angle->getFloatValue(CSSPrimitiveValue::CSS_DEG);
endPointsFromAngle(angle, size, firstPoint, secondPoint);
} else {
- firstPoint = computeEndPoint(m_firstX.get(), m_firstY.get(), renderer->style(), rootStyle, size);
+ firstPoint = computeEndPoint(m_firstX.get(), m_firstY.get(), renderer->style(), rootStyle, parentStyle, size);
if (m_secondX || m_secondY)
- secondPoint = computeEndPoint(m_secondX.get(), m_secondY.get(), renderer->style(), rootStyle, size);
+ secondPoint = computeEndPoint(m_secondX.get(), m_secondY.get(), renderer->style(), rootStyle, parentStyle, size);
else {
if (m_firstX)
secondPoint.setX(size.width() - firstPoint.x());
RefPtr<Gradient> gradient = Gradient::create(firstPoint, secondPoint);
// Now add the stops.
- addStops(gradient.get(), renderer, rootStyle, 1);
+ addStops(gradient.get(), renderer, rootStyle, parentStyle, 1);
return gradient.release();
}
return result;
}
-float CSSRadialGradientValue::resolveRadius(CSSPrimitiveValue* radius, RenderStyle* style, RenderStyle* rootStyle, float* widthOrHeight)
+float CSSRadialGradientValue::resolveRadius(CSSPrimitiveValue* radius, RenderStyle* style, RenderStyle* rootStyle, RenderStyle* parentStyle, float* widthOrHeight)
{
float zoomFactor = style->effectiveZoom();
else if (widthOrHeight && radius->isPercentage())
result = *widthOrHeight * radius->getFloatValue() / 100;
else
- result = radius->computeLength<float>(style, rootStyle, zoomFactor);
+ result = radius->computeLength<float>(style, rootStyle, parentStyle, zoomFactor);
return result;
}
ASSERT(!size.isEmpty());
RenderStyle* rootStyle = renderer->document()->documentElement()->renderStyle();
+ RenderObject* parent = renderer->parent();
+ RenderStyle* parentStyle = parent ? parent->style() : 0;
- FloatPoint firstPoint = computeEndPoint(m_firstX.get(), m_firstY.get(), renderer->style(), rootStyle, size);
+ FloatPoint firstPoint = computeEndPoint(m_firstX.get(), m_firstY.get(), renderer->style(), rootStyle, parentStyle, size);
if (!m_firstX)
firstPoint.setX(size.width() / 2);
if (!m_firstY)
firstPoint.setY(size.height() / 2);
- FloatPoint secondPoint = computeEndPoint(m_secondX.get(), m_secondY.get(), renderer->style(), rootStyle, size);
+ FloatPoint secondPoint = computeEndPoint(m_secondX.get(), m_secondY.get(), renderer->style(), rootStyle, parentStyle, size);
if (!m_secondX)
secondPoint.setX(size.width() / 2);
if (!m_secondY)
float firstRadius = 0;
if (m_firstRadius)
- firstRadius = resolveRadius(m_firstRadius.get(), renderer->style(), rootStyle);
+ firstRadius = resolveRadius(m_firstRadius.get(), renderer->style(), rootStyle, parentStyle);
float secondRadius = 0;
float aspectRatio = 1; // width / height.
if (m_secondRadius)
- secondRadius = resolveRadius(m_secondRadius.get(), renderer->style(), rootStyle);
+ secondRadius = resolveRadius(m_secondRadius.get(), renderer->style(), rootStyle, parentStyle);
else if (m_endHorizontalSize || m_endVerticalSize) {
float width = size.width();
float height = size.height();
- secondRadius = resolveRadius(m_endHorizontalSize.get(), renderer->style(), rootStyle, &width);
- aspectRatio = secondRadius / resolveRadius(m_endVerticalSize.get(), renderer->style(), rootStyle, &height);
+ secondRadius = resolveRadius(m_endHorizontalSize.get(), renderer->style(), rootStyle, parentStyle, &width);
+ aspectRatio = secondRadius / resolveRadius(m_endVerticalSize.get(), renderer->style(), rootStyle, parentStyle, &height);
} else {
enum GradientShape { Circle, Ellipse };
GradientShape shape = Ellipse;
}
// Now add the stops.
- addStops(gradient.get(), renderer, rootStyle, maxExtent);
+ addStops(gradient.get(), renderer, rootStyle, parentStyle, maxExtent);
return gradient.release();
}
{
}
- void addStops(Gradient*, RenderObject*, RenderStyle* rootStyle, float maxLengthForRepeat = 0);
+ void addStops(Gradient*, RenderObject*, RenderStyle* rootStyle, RenderStyle* parentStyle, float maxLengthForRepeat = 0);
// Resolve points/radii to front end values.
- FloatPoint computeEndPoint(CSSPrimitiveValue*, CSSPrimitiveValue*, RenderStyle*, RenderStyle* rootStyle, const IntSize&);
+ FloatPoint computeEndPoint(CSSPrimitiveValue*, CSSPrimitiveValue*, RenderStyle*, RenderStyle* rootStyle, RenderStyle* parentStyle, const IntSize&);
bool isCacheable() const;
}
// Resolve points/radii to front end values.
- float resolveRadius(CSSPrimitiveValue*, RenderStyle*, RenderStyle* rootStyle, float* widthOrHeight = 0);
+ float resolveRadius(CSSPrimitiveValue*, RenderStyle*, RenderStyle* rootStyle, RenderStyle* parentStyle, float* widthOrHeight = 0);
// These may be null for non-deprecated gradients.
RefPtr<CSSPrimitiveValue> m_firstRadius;
}
}
-template<> int CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, float multiplier, bool computingFontSize)
+template<> int CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, RenderStyle* parentStyle, float multiplier, bool computingFontSize)
{
- return roundForImpreciseConversion<int>(computeLengthDouble(style, rootStyle, multiplier, computingFontSize));
+ return roundForImpreciseConversion<int>(computeLengthDouble(style, rootStyle, parentStyle, multiplier, computingFontSize));
}
-template<> unsigned CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, float multiplier, bool computingFontSize)
+template<> unsigned CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, RenderStyle* parentStyle, float multiplier, bool computingFontSize)
{
- return roundForImpreciseConversion<unsigned>(computeLengthDouble(style, rootStyle, multiplier, computingFontSize));
+ return roundForImpreciseConversion<unsigned>(computeLengthDouble(style, rootStyle, parentStyle, multiplier, computingFontSize));
}
-template<> Length CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, float multiplier, bool computingFontSize)
+template<> Length CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, RenderStyle* parentStyle, float multiplier, bool computingFontSize)
{
#if ENABLE(SUBPIXEL_LAYOUT)
- return Length(static_cast<float>(computeLengthDouble(style, rootStyle, multiplier, computingFontSize)), Fixed);
+ return Length(static_cast<float>(computeLengthDouble(style, rootStyle, parentStyle, multiplier, computingFontSize)), Fixed);
#else
- return Length(roundForImpreciseConversion<float>(computeLengthDouble(style, rootStyle, multiplier, computingFontSize)), Fixed);
+ return Length(roundForImpreciseConversion<float>(computeLengthDouble(style, rootStyle, parentStyle, multiplier, computingFontSize)), Fixed);
#endif
}
-template<> short CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, float multiplier, bool computingFontSize)
+template<> short CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, RenderStyle* parentStyle, float multiplier, bool computingFontSize)
{
- return roundForImpreciseConversion<short>(computeLengthDouble(style, rootStyle, multiplier, computingFontSize));
+ return roundForImpreciseConversion<short>(computeLengthDouble(style, rootStyle, parentStyle, multiplier, computingFontSize));
}
-template<> unsigned short CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, float multiplier, bool computingFontSize)
+template<> unsigned short CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, RenderStyle* parentStyle, float multiplier, bool computingFontSize)
{
- return roundForImpreciseConversion<unsigned short>(computeLengthDouble(style, rootStyle, multiplier, computingFontSize));
+ return roundForImpreciseConversion<unsigned short>(computeLengthDouble(style, rootStyle, parentStyle, multiplier, computingFontSize));
}
-template<> float CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, float multiplier, bool computingFontSize)
+template<> float CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, RenderStyle* parentStyle, float multiplier, bool computingFontSize)
{
- return static_cast<float>(computeLengthDouble(style, rootStyle, multiplier, computingFontSize));
+ return static_cast<float>(computeLengthDouble(style, rootStyle, parentStyle, multiplier, computingFontSize));
}
-template<> double CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, float multiplier, bool computingFontSize)
+template<> double CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, RenderStyle* parentStyle, float multiplier, bool computingFontSize)
{
- return computeLengthDouble(style, rootStyle, multiplier, computingFontSize);
+ return computeLengthDouble(style, rootStyle, parentStyle, multiplier, computingFontSize);
}
-double CSSPrimitiveValue::computeLengthDouble(RenderStyle* style, RenderStyle* rootStyle, float multiplier, bool computingFontSize)
+double CSSPrimitiveValue::computeLengthDouble(RenderStyle* style, RenderStyle* rootStyle, RenderStyle* parentStyle, float multiplier, bool computingFontSize)
{
double factor;
case CSS_CALC_PERCENTAGE_WITH_NUMBER:
ASSERT_NOT_REACHED();
return -1.0;
+ case CSS_VW:
+ factor = parentStyle ? 0.01 * parentStyle->width().getFloatValue() : 0;
+ break;
+ case CSS_VH:
+ factor = parentStyle ? 0.01 * parentStyle->height().getFloatValue() : 0;
+ break;
+ case CSS_VMIN:
+ factor = 0;
+ if (parentStyle)
+ factor = .01 * (float) min(parentStyle->width().getFloatValue(), parentStyle->height().getFloatValue());
+ break;
default:
ASSERT_NOT_REACHED();
return -1.0;
double computedValue;
if (m_primitiveUnitType == CSS_CALC)
// The multiplier is passed in as 1.0 here to ensure it is only applied once
- computedValue = m_value.calc->computeLengthPx(style, rootStyle, 1.0, computingFontSize);
+ computedValue = m_value.calc->computeLengthPx(style, rootStyle, parentStyle, 1.0, computingFontSize);
else
computedValue = getDoubleValue();
* this is screen/printer dependent, so we probably need a config option for this,
* and some tool to calibrate.
*/
- template<typename T> T computeLength(RenderStyle* currStyle, RenderStyle* rootStyle, float multiplier = 1.0f, bool computingFontSize = false);
+ template<typename T> T computeLength(RenderStyle* currStyle, RenderStyle* rootStyle, RenderStyle* parentStyle, float multiplier = 1.0f, bool computingFontSize = false);
// Converts to a Length, mapping various unit types appropriately.
- template<int> Length convertToLength(RenderStyle* currStyle, RenderStyle* rootStyle, double multiplier = 1.0, bool computingFontSize = false);
+ template<int> Length convertToLength(RenderStyle* currStyle, RenderStyle* rootStyle, RenderStyle* parentStyle, double multiplier = 1.0, bool computingFontSize = false);
// use with care!!!
void setPrimitiveType(unsigned short type) { m_primitiveUnitType = type; }
void init(PassRefPtr<CSSCalcValue>);
bool getDoubleValueInternal(UnitTypes targetUnitType, double* result) const;
- double computeLengthDouble(RenderStyle* currentStyle, RenderStyle* rootStyle, float multiplier, bool computingFontSize);
+ double computeLengthDouble(RenderStyle* currentStyle, RenderStyle* rootStyle, RenderStyle* parentStyle, float multiplier, bool computingFontSize);
union {
int ident;
ViewportPercentageConversion = 1 << 6
};
-template<int supported> Length CSSPrimitiveValue::convertToLength(RenderStyle* style, RenderStyle* rootStyle, double multiplier, bool computingFontSize)
+template<int supported> Length CSSPrimitiveValue::convertToLength(RenderStyle* style, RenderStyle* rootStyle, RenderStyle* parentStyle, double multiplier, bool computingFontSize)
{
if ((supported & (FixedIntegerConversion | FixedFloatConversion)) && isFontRelativeLength() && (!style || !rootStyle))
return Length(Undefined);
if ((supported & FixedIntegerConversion) && isLength())
- return computeLength<Length>(style, rootStyle, multiplier, computingFontSize);
+ return computeLength<Length>(style, rootStyle, parentStyle, multiplier, computingFontSize);
if ((supported & FixedFloatConversion) && isLength())
- return Length(computeLength<double>(style, rootStyle, multiplier), Fixed);
+ return Length(computeLength<double>(style, rootStyle, parentStyle, multiplier), Fixed);
if ((supported & PercentConversion) && isPercentage())
return Length(getDoubleValue(), Percent);
if ((supported & FractionConversion) && isNumber())
if ((supported & AutoConversion) && getIdent() == CSSValueAuto)
return Length(Auto);
if ((supported & CalculatedConversion) && isCalculated())
- return Length(cssCalcValue()->toCalcValue(style, rootStyle, multiplier));
+ return Length(cssCalcValue()->toCalcValue(style, rootStyle, parentStyle, multiplier));
if ((supported & ViewportPercentageConversion) && isViewportPercentageLength())
return viewportPercentageLength();
return Length(Undefined);
return m_resolver->rootElementStyle();
}
+RenderStyle* CSSToStyleMap::parentStyle() const
+{
+ return m_resolver->parentStyle();
+}
+
bool CSSToStyleMap::useSVGZoomRules() const
{
return m_resolver->useSVGZoomRules();
if (Pair* pair = primitiveValue->getPairValue()) {
CSSPrimitiveValue* first = static_cast<CSSPrimitiveValue*>(pair->first());
CSSPrimitiveValue* second = static_cast<CSSPrimitiveValue*>(pair->second());
- firstLength = first->convertToLength<AnyConversion>(style(), rootElementStyle(), zoomFactor);
- secondLength = second->convertToLength<AnyConversion>(style(), rootElementStyle(), zoomFactor);
+ firstLength = first->convertToLength<AnyConversion>(style(), rootElementStyle(), parentStyle(), zoomFactor);
+ secondLength = second->convertToLength<AnyConversion>(style(), rootElementStyle(), parentStyle(), zoomFactor);
} else {
- firstLength = primitiveValue->convertToLength<AnyConversion>(style(), rootElementStyle(), zoomFactor);
+ firstLength = primitiveValue->convertToLength<AnyConversion>(style(), rootElementStyle(), parentStyle(), zoomFactor);
secondLength = Length();
}
CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
Length length;
if (primitiveValue->isLength())
- length = primitiveValue->computeLength<Length>(style(), rootElementStyle(), zoomFactor);
+ length = primitiveValue->computeLength<Length>(style(), rootElementStyle(), parentStyle(), zoomFactor);
else if (primitiveValue->isPercentage())
length = Length(primitiveValue->getDoubleValue(), Percent);
else if (primitiveValue->isCalculatedPercentageWithLength())
- length = Length(primitiveValue->cssCalcValue()->toCalcValue(style(), rootElementStyle(), zoomFactor));
+ length = Length(primitiveValue->cssCalcValue()->toCalcValue(style(), rootElementStyle(), parentStyle(), zoomFactor));
else if (primitiveValue->isViewportPercentageLength())
length = primitiveValue->viewportPercentageLength();
else
CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
Length length;
if (primitiveValue->isLength())
- length = primitiveValue->computeLength<Length>(style(), rootElementStyle(), zoomFactor);
+ length = primitiveValue->computeLength<Length>(style(), rootElementStyle(), parentStyle(), zoomFactor);
else if (primitiveValue->isPercentage())
length = Length(primitiveValue->getDoubleValue(), Percent);
else if (primitiveValue->isCalculatedPercentageWithLength())
- length = Length(primitiveValue->cssCalcValue()->toCalcValue(style(), rootElementStyle(), zoomFactor));
+ length = Length(primitiveValue->cssCalcValue()->toCalcValue(style(), rootElementStyle(), parentStyle(), zoomFactor));
else if (primitiveValue->isViewportPercentageLength())
length = primitiveValue->viewportPercentageLength();
else
else if (slices->top()->isPercentage())
box.m_top = Length(slices->top()->getDoubleValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent);
else if (slices->top()->getIdent() != CSSValueAuto)
- box.m_top = slices->top()->computeLength<Length>(style(), rootElementStyle(), zoom);
+ box.m_top = slices->top()->computeLength<Length>(style(), rootElementStyle(), parentStyle(), zoom);
if (slices->right()->isNumber())
box.m_right = Length(slices->right()->getIntValue(), Relative);
else if (slices->right()->isPercentage())
box.m_right = Length(slices->right()->getDoubleValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent);
else if (slices->right()->getIdent() != CSSValueAuto)
- box.m_right = slices->right()->computeLength<Length>(style(), rootElementStyle(), zoom);
+ box.m_right = slices->right()->computeLength<Length>(style(), rootElementStyle(), parentStyle(), zoom);
if (slices->bottom()->isNumber())
box.m_bottom = Length(slices->bottom()->getIntValue(), Relative);
else if (slices->bottom()->isPercentage())
box.m_bottom = Length(slices->bottom()->getDoubleValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent);
else if (slices->bottom()->getIdent() != CSSValueAuto)
- box.m_bottom = slices->bottom()->computeLength<Length>(style(), rootElementStyle(), zoom);
+ box.m_bottom = slices->bottom()->computeLength<Length>(style(), rootElementStyle(), parentStyle(), zoom);
if (slices->left()->isNumber())
box.m_left = Length(slices->left()->getIntValue(), Relative);
else if (slices->left()->isPercentage())
box.m_left = Length(slices->left()->getDoubleValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent);
else if (slices->left()->getIdent() != CSSValueAuto)
- box.m_left = slices->left()->computeLength<Length>(style(), rootElementStyle(), zoom);
+ box.m_left = slices->left()->computeLength<Length>(style(), rootElementStyle(), parentStyle(), zoom);
return box;
}
// the current paint/layout.
RenderStyle* style() const;
RenderStyle* rootElementStyle() const;
+ RenderStyle* parentStyle() const;
bool useSVGZoomRules() const;
// FIXME: This should be part of some sort of StyleImageCache object which
return false;
}
-static bool computeLength(CSSValue* value, bool strict, RenderStyle* style, RenderStyle* rootStyle, int& result)
+static bool computeLength(CSSValue* value, bool strict, RenderStyle* style, RenderStyle* rootStyle, RenderStyle* parentStyle, int& result)
{
if (!value->isPrimitiveValue())
return false;
}
if (primitiveValue->isLength()) {
- result = primitiveValue->computeLength<int>(style, rootStyle);
+ result = primitiveValue->computeLength<int>(style, rootStyle, parentStyle);
return true;
}
if (value) {
FloatRect sg = screenRect(frame->page()->mainFrame()->view());
RenderStyle* rootStyle = frame->document()->documentElement()->renderStyle();
+ ContainerNode* parentNode = frame->document()->documentElement()->parentNodeForRenderingAndStyle();
+ RenderStyle* parentStyle = parentNode ? parentNode->renderStyle() : 0;
int length;
long height = sg.height();
InspectorInstrumentation::applyScreenHeightOverride(frame, &height);
- return computeLength(value, !frame->document()->inQuirksMode(), style, rootStyle, length) && compareValue(static_cast<int>(height), length, op);
+ return computeLength(value, !frame->document()->inQuirksMode(), style, rootStyle, parentStyle, length) && compareValue(static_cast<int>(height), length, op);
}
// ({,min-,max-}device-height)
// assume if we have a device, assume non-zero
if (value) {
FloatRect sg = screenRect(frame->page()->mainFrame()->view());
RenderStyle* rootStyle = frame->document()->documentElement()->renderStyle();
+ ContainerNode* parentNode = frame->document()->documentElement()->parentNodeForRenderingAndStyle();
+ RenderStyle* parentStyle = parentNode ? parentNode->renderStyle() : 0;
int length;
long width = sg.width();
InspectorInstrumentation::applyScreenWidthOverride(frame, &width);
- return computeLength(value, !frame->document()->inQuirksMode(), style, rootStyle, length) && compareValue(static_cast<int>(width), length, op);
+ return computeLength(value, !frame->document()->inQuirksMode(), style, rootStyle, parentStyle, length) && compareValue(static_cast<int>(width), length, op);
}
// ({,min-,max-}device-width)
// assume if we have a device, assume non-zero
if (value) {
RenderStyle* rootStyle = frame->document()->documentElement()->renderStyle();
+ ContainerNode* parentNode = frame->document()->documentElement()->parentNodeForRenderingAndStyle();
+ RenderStyle* parentStyle = parentNode ? parentNode->renderStyle() : 0;
int length;
- return computeLength(value, !frame->document()->inQuirksMode(), style, rootStyle, length) && compareValue(view->layoutHeight(), length, op);
+ return computeLength(value, !frame->document()->inQuirksMode(), style, rootStyle, parentStyle, length) && compareValue(view->layoutHeight(), length, op);
}
return view->layoutHeight() != 0;
if (value) {
RenderStyle* rootStyle = frame->document()->documentElement()->renderStyle();
+ ContainerNode* parentNode = frame->document()->documentElement()->parentNodeForRenderingAndStyle();
+ RenderStyle* parentStyle = parentNode ? parentNode->renderStyle() : 0;
int length;
- return computeLength(value, !frame->document()->inQuirksMode(), style, rootStyle, length) && compareValue(view->layoutWidth(), length, op);
+ return computeLength(value, !frame->document()->inQuirksMode(), style, rootStyle, parentStyle, length) && compareValue(view->layoutWidth(), length, op);
}
return view->layoutWidth() != 0;
if (!firstValue->isShadowValue())
return;
ShadowValue* item = static_cast<ShadowValue*>(firstValue);
- IntPoint location(item->x->computeLength<int>(style(), m_rootElementStyle),
- item->y->computeLength<int>(style(), m_rootElementStyle));
- int blur = item->blur ? item->blur->computeLength<int>(style(), m_rootElementStyle) : 0;
+ IntPoint location(item->x->computeLength<int>(style(), m_rootElementStyle, m_parentStyle),
+ item->y->computeLength<int>(style(), m_rootElementStyle, m_parentStyle));
+ int blur = item->blur ? item->blur->computeLength<int>(style(), m_rootElementStyle, m_parentStyle) : 0;
Color color;
if (item->color)
color = colorFromPrimitiveValue(item->color.get());
#include "CursorList.h"
#include "Document.h"
#include "Element.h"
+#include "NodeRenderStyle.h"
#include "Pair.h"
#include "Rect.h"
#include "RenderObject.h"
else if (valueType == Number)
setValue(styleResolver->style(), *primitiveValue);
else if (valueType == ComputeLength)
- setValue(styleResolver->style(), primitiveValue->computeLength<T>(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom()));
+ setValue(styleResolver->style(), primitiveValue->computeLength<T>(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->parentStyle(), styleResolver->style()->effectiveZoom()));
}
static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); }
private:
static Length convertToLength(StyleResolver* styleResolver, CSSPrimitiveValue* value)
{
- return value->convertToLength<FixedIntegerConversion | PercentConversion | FractionConversion | AutoConversion>(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom());
+ return value->convertToLength<FixedIntegerConversion | PercentConversion | FractionConversion | AutoConversion>(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->parentStyle(), styleResolver->style()->effectiveZoom());
}
public:
static void applyInheritValue(StyleResolver* styleResolver)
if (autoEnabled && primitiveValue->getIdent() == CSSValueAuto)
setValue(styleResolver->style(), Length());
else if (primitiveValue->isLength()) {
- Length length = primitiveValue->computeLength<Length>(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom());
+ Length length = primitiveValue->computeLength<Length>(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->parentStyle(), styleResolver->style()->effectiveZoom());
length.setQuirk(primitiveValue->isQuirkValue());
setValue(styleResolver->style(), length);
} else if (primitiveValue->isPercentage())
setValue(styleResolver->style(), Length(primitiveValue->getDoubleValue(), Percent));
else if (primitiveValue->isCalculatedPercentageWithLength())
- setValue(styleResolver->style(), Length(primitiveValue->cssCalcValue()->toCalcValue(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom())));
+ setValue(styleResolver->style(), Length(primitiveValue->cssCalcValue()->toCalcValue(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->parentStyle(), styleResolver->style()->effectiveZoom())));
else if (primitiveValue->isViewportPercentageLength())
setValue(styleResolver->style(), primitiveValue->viewportPercentageLength());
}
// handle this case
return;
} else
- radiusWidth = pair->first()->computeLength<Length>(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom());
+ radiusWidth = pair->first()->computeLength<Length>(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->parentStyle(), styleResolver->style()->effectiveZoom());
if (pair->second()->isPercentage())
radiusHeight = Length(pair->second()->getDoubleValue(), Percent);
else if (pair->second()->isViewportPercentageLength())
// handle this case
return;
} else
- radiusHeight = pair->second()->computeLength<Length>(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom());
+ radiusHeight = pair->second()->computeLength<Length>(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->parentStyle(), styleResolver->style()->effectiveZoom());
int width = radiusWidth.value();
int height = radiusHeight.value();
if (width < 0 || height < 0)
length = 5;
} else if (ident == CSSValueInvalid) {
float zoom = (svgZoomEnabled && styleResolver->useSVGZoomRules()) ? 1.0f : styleResolver->style()->effectiveZoom();
- length = primitiveValue->computeLength<T>(styleResolver->style(), styleResolver->rootElementStyle(), zoom);
+ length = primitiveValue->computeLength<T>(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->parentStyle(), zoom);
} else {
ASSERT_NOT_REACHED();
length = 0;
} else {
fontDescription.setIsAbsoluteSize(parentIsAbsoluteSize
|| !(primitiveValue->isPercentage() || primitiveValue->isFontRelativeLength()));
+
+ RenderStyle* gpStyle = 0;
+ ContainerNode* parentNode = styleResolver->parentNode();
+ if (parentNode) {
+ ContainerNode* gpNode = parentNode->parentNodeForRenderingAndStyle();
+ gpStyle = gpNode ? gpNode->renderStyle() : 0;
+ }
+
if (primitiveValue->isLength())
- size = primitiveValue->computeLength<float>(styleResolver->parentStyle(), styleResolver->rootElementStyle(), 1.0, true);
+ size = primitiveValue->computeLength<float>(styleResolver->parentStyle(), styleResolver->rootElementStyle(), gpStyle, 1.0, true);
else if (primitiveValue->isPercentage())
size = (primitiveValue->getFloatValue() * parentSize) / 100.0f;
else if (primitiveValue->isCalculatedPercentageWithLength())
- size = primitiveValue->cssCalcValue()->toCalcValue(styleResolver->parentStyle(), styleResolver->rootElementStyle())->evaluate(parentSize);
+ size = primitiveValue->cssCalcValue()->toCalcValue(styleResolver->parentStyle(), styleResolver->rootElementStyle(), gpStyle)->evaluate(parentSize);
else if (primitiveValue->isViewportPercentageLength())
size = valueForLength(primitiveValue->viewportPercentageLength(), 0, styleResolver->document()->renderView());
else
if (Frame* frame = styleResolver->document()->frame())
multiplier *= frame->textZoomFactor();
}
- lineHeight = primitiveValue->computeLength<Length>(styleResolver->style(), styleResolver->rootElementStyle(), multiplier);
+ lineHeight = primitiveValue->computeLength<Length>(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->parentStyle(), multiplier);
} else if (primitiveValue->isPercentage()) {
// FIXME: percentage should not be restricted to an integer here.
lineHeight = Length((styleResolver->style()->fontSize() * primitiveValue->getIntValue()) / 100, Fixed);
class ApplyPropertyPageSize {
private:
- static Length mmLength(double mm) { return CSSPrimitiveValue::create(mm, CSSPrimitiveValue::CSS_MM)->computeLength<Length>(0, 0); }
- static Length inchLength(double inch) { return CSSPrimitiveValue::create(inch, CSSPrimitiveValue::CSS_IN)->computeLength<Length>(0, 0); }
+ static Length mmLength(double mm) { return CSSPrimitiveValue::create(mm, CSSPrimitiveValue::CSS_MM)->computeLength<Length>(0, 0, 0); }
+ static Length inchLength(double inch) { return CSSPrimitiveValue::create(inch, CSSPrimitiveValue::CSS_IN)->computeLength<Length>(0, 0, 0); }
static bool getPageSizeFromName(CSSPrimitiveValue* pageSizeName, CSSPrimitiveValue* pageOrientation, Length& width, Length& height)
{
DEFINE_STATIC_LOCAL(Length, a5Width, (mmLength(148)));
// <length>{2}
if (!second->isLength())
return;
- width = first->computeLength<Length>(styleResolver->style(), styleResolver->rootElementStyle());
- height = second->computeLength<Length>(styleResolver->style(), styleResolver->rootElementStyle());
+ width = first->computeLength<Length>(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->parentStyle());
+ height = second->computeLength<Length>(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->parentStyle());
} else {
// <page-size> <orientation>
// The value order is guaranteed. See CSSParser::parseSizeParameter.
if (primitiveValue->isLength()) {
// <length>
pageSizeType = PAGE_SIZE_RESOLVED;
- width = height = primitiveValue->computeLength<Length>(styleResolver->style(), styleResolver->rootElementStyle());
+ width = height = primitiveValue->computeLength<Length>(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->parentStyle());
} else {
switch (primitiveValue->getIdent()) {
case 0:
if (primitiveValue->getIdent())
return styleResolver->style()->setVerticalAlign(*primitiveValue);
- styleResolver->style()->setVerticalAlignLength(primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion | ViewportPercentageConversion>(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom()));
+ styleResolver->style()->setVerticalAlignLength(primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion | ViewportPercentageConversion>(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->parentStyle(), styleResolver->style()->effectiveZoom()));
}
static PropertyHandler createHandler()
// -------------------------------------------------------------------------------------
// this is mostly boring stuff on how to apply a certain rule to the renderstyle...
-Length StyleResolver::convertToIntLength(CSSPrimitiveValue* primitiveValue, RenderStyle* style, RenderStyle* rootStyle, double multiplier)
+Length StyleResolver::convertToIntLength(CSSPrimitiveValue* primitiveValue, RenderStyle* style, RenderStyle* rootStyle, RenderStyle* parentStyle, double multiplier)
{
- return primitiveValue ? primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion | FractionConversion | ViewportPercentageConversion>(style, rootStyle, multiplier) : Length(Undefined);
+ return primitiveValue ? primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion | FractionConversion | ViewportPercentageConversion>(style, rootStyle, parentStyle, multiplier) : Length(Undefined);
}
-Length StyleResolver::convertToFloatLength(CSSPrimitiveValue* primitiveValue, RenderStyle* style, RenderStyle* rootStyle, double multiplier)
+Length StyleResolver::convertToFloatLength(CSSPrimitiveValue* primitiveValue, RenderStyle* style, RenderStyle* rootStyle, RenderStyle* parentStyle, double multiplier)
{
- return primitiveValue ? primitiveValue->convertToLength<FixedFloatConversion | PercentConversion | FractionConversion | ViewportPercentageConversion>(style, rootStyle, multiplier) : Length(Undefined);
+ return primitiveValue ? primitiveValue->convertToLength<FixedFloatConversion | PercentConversion | FractionConversion | ViewportPercentageConversion>(style, rootStyle, parentStyle, multiplier) : Length(Undefined);
}
template <StyleResolver::StyleApplicationPass pass>
static bool createGridTrackBreadth(CSSPrimitiveValue* primitiveValue, StyleResolver* selector, Length& length)
{
- Length workingLength = primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion | ViewportPercentageConversion | AutoConversion>(selector->style(), selector->rootElementStyle(), selector->style()->effectiveZoom());
+ Length workingLength = primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion | ViewportPercentageConversion | AutoConversion>(selector->style(), selector->rootElementStyle(), selector->parentStyle(), selector->style()->effectiveZoom());
if (workingLength.isUndefined())
return false;
if (!currValue->isShadowValue())
continue;
ShadowValue* item = static_cast<ShadowValue*>(currValue);
- int x = item->x->computeLength<int>(style(), m_rootElementStyle, zoomFactor);
- int y = item->y->computeLength<int>(style(), m_rootElementStyle, zoomFactor);
- int blur = item->blur ? item->blur->computeLength<int>(style(), m_rootElementStyle, zoomFactor) : 0;
- int spread = item->spread ? item->spread->computeLength<int>(style(), m_rootElementStyle, zoomFactor) : 0;
+ int x = item->x->computeLength<int>(style(), m_rootElementStyle, m_parentStyle, zoomFactor);
+ int y = item->y->computeLength<int>(style(), m_rootElementStyle, m_parentStyle, zoomFactor);
+ int blur = item->blur ? item->blur->computeLength<int>(style(), m_rootElementStyle, m_parentStyle, zoomFactor) : 0;
+ int spread = item->spread ? item->spread->computeLength<int>(style(), m_rootElementStyle, m_parentStyle, zoomFactor) : 0;
ShadowStyle shadowStyle = item->style && item->style->getIdent() == CSSValueInset ? Inset : Normal;
Color color;
if (item->color)
RefPtr<StyleReflection> reflection = StyleReflection::create();
reflection->setDirection(reflectValue->direction());
if (reflectValue->offset())
- reflection->setOffset(reflectValue->offset()->convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion>(style(), m_rootElementStyle, zoomFactor));
+ reflection->setOffset(reflectValue->offset()->convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion>(style(), m_rootElementStyle, m_parentStyle, zoomFactor));
NinePieceImage mask;
mask.setMaskDefaults();
m_styleMap.mapNinePieceImage(id, reflectValue->mask(), mask);
break;
}
} else {
- Length marqueeLength = convertToIntLength(primitiveValue, style(), m_rootElementStyle);
+ Length marqueeLength = convertToIntLength(primitiveValue, style(), m_rootElementStyle, m_parentStyle);
if (!marqueeLength.isUndefined())
m_style->setMarqueeIncrement(marqueeLength);
}
DashboardRegion* first = region;
while (region) {
- Length top = convertToIntLength(region->top(), style(), m_rootElementStyle);
- Length right = convertToIntLength(region->right(), style(), m_rootElementStyle);
- Length bottom = convertToIntLength(region->bottom(), style(), m_rootElementStyle);
- Length left = convertToIntLength(region->left(), style(), m_rootElementStyle);
+ Length top = convertToIntLength(region->top(), style(), m_rootElementStyle, m_parentStyle);
+ Length right = convertToIntLength(region->right(), style(), m_rootElementStyle, m_parentStyle);
+ Length bottom = convertToIntLength(region->bottom(), style(), m_rootElementStyle, m_parentStyle);
+ Length left = convertToIntLength(region->left(), style(), m_rootElementStyle, m_parentStyle);
if (top.isUndefined())
top = Length();
result *= 3;
else if (primitiveValue->getIdent() == CSSValueThick)
result *= 5;
- width = CSSPrimitiveValue::create(result, CSSPrimitiveValue::CSS_EMS)->computeLength<float>(style(), m_rootElementStyle, zoomFactor);
+ width = CSSPrimitiveValue::create(result, CSSPrimitiveValue::CSS_EMS)->computeLength<float>(style(), m_rootElementStyle, m_parentStyle, zoomFactor);
break;
}
default:
- width = primitiveValue->computeLength<float>(style(), m_rootElementStyle, zoomFactor);
+ width = primitiveValue->computeLength<float>(style(), m_rootElementStyle, m_parentStyle, zoomFactor);
break;
}
m_style->setTextStrokeWidth(width);
case CSSPropertyWebkitTransform: {
HANDLE_INHERIT_AND_INITIAL(transform, Transform);
TransformOperations operations;
- createTransformOperations(value, style(), m_rootElementStyle, operations);
+ createTransformOperations(value, style(), m_rootElementStyle, m_parentStyle, operations);
m_style->setTransform(operations);
return;
}
float perspectiveValue;
if (primitiveValue->isLength())
- perspectiveValue = primitiveValue->computeLength<float>(style(), m_rootElementStyle, zoomFactor);
+ perspectiveValue = primitiveValue->computeLength<float>(style(), m_rootElementStyle, m_parentStyle, zoomFactor);
else if (primitiveValue->isNumber()) {
// For backward compatibility, treat valueless numbers as px.
- perspectiveValue = CSSPrimitiveValue::create(primitiveValue->getDoubleValue(), CSSPrimitiveValue::CSS_PX)->computeLength<float>(style(), m_rootElementStyle, zoomFactor);
+ perspectiveValue = CSSPrimitiveValue::create(primitiveValue->getDoubleValue(), CSSPrimitiveValue::CSS_PX)->computeLength<float>(style(), m_rootElementStyle, m_parentStyle, zoomFactor);
} else
return;
return TransformOperation::NONE;
}
-bool StyleResolver::createTransformOperations(CSSValue* inValue, RenderStyle* style, RenderStyle* rootStyle, TransformOperations& outOperations)
+bool StyleResolver::createTransformOperations(CSSValue* inValue, RenderStyle* style, RenderStyle* rootStyle, RenderStyle* parentStyle, TransformOperations& outOperations)
{
if (!inValue || !inValue->isValueList()) {
outOperations.clear();
Length tx = Length(0, Fixed);
Length ty = Length(0, Fixed);
if (transformValue->operationType() == WebKitCSSTransformValue::TranslateYTransformOperation)
- ty = convertToFloatLength(firstValue, style, rootStyle, zoomFactor);
+ ty = convertToFloatLength(firstValue, style, rootStyle, parentStyle, zoomFactor);
else {
- tx = convertToFloatLength(firstValue, style, rootStyle, zoomFactor);
+ tx = convertToFloatLength(firstValue, style, rootStyle, parentStyle, zoomFactor);
if (transformValue->operationType() != WebKitCSSTransformValue::TranslateXTransformOperation) {
if (transformValue->length() > 1) {
CSSPrimitiveValue* secondValue = static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(1));
- ty = convertToFloatLength(secondValue, style, rootStyle, zoomFactor);
+ ty = convertToFloatLength(secondValue, style, rootStyle, parentStyle, zoomFactor);
}
}
}
Length ty = Length(0, Fixed);
Length tz = Length(0, Fixed);
if (transformValue->operationType() == WebKitCSSTransformValue::TranslateZTransformOperation)
- tz = convertToFloatLength(firstValue, style, rootStyle, zoomFactor);
+ tz = convertToFloatLength(firstValue, style, rootStyle, parentStyle, zoomFactor);
else if (transformValue->operationType() == WebKitCSSTransformValue::TranslateYTransformOperation)
- ty = convertToFloatLength(firstValue, style, rootStyle, zoomFactor);
+ ty = convertToFloatLength(firstValue, style, rootStyle, parentStyle, zoomFactor);
else {
- tx = convertToFloatLength(firstValue, style, rootStyle, zoomFactor);
+ tx = convertToFloatLength(firstValue, style, rootStyle, parentStyle, zoomFactor);
if (transformValue->operationType() != WebKitCSSTransformValue::TranslateXTransformOperation) {
if (transformValue->length() > 2) {
CSSPrimitiveValue* thirdValue = static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(2));
- tz = convertToFloatLength(thirdValue, style, rootStyle, zoomFactor);
+ tz = convertToFloatLength(thirdValue, style, rootStyle, parentStyle, zoomFactor);
}
if (transformValue->length() > 1) {
CSSPrimitiveValue* secondValue = static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(1));
- ty = convertToFloatLength(secondValue, style, rootStyle, zoomFactor);
+ ty = convertToFloatLength(secondValue, style, rootStyle, parentStyle, zoomFactor);
}
}
}
case WebKitCSSTransformValue::PerspectiveTransformOperation: {
Length p = Length(0, Fixed);
if (firstValue->isLength())
- p = convertToFloatLength(firstValue, style, rootStyle, zoomFactor);
+ p = convertToFloatLength(firstValue, style, rootStyle, parentStyle, zoomFactor);
else {
// This is a quirk that should go away when 3d transforms are finalized.
double val = firstValue->getDoubleValue();
case WebKitCSSFilterValue::BlurFilterOperation: {
Length stdDeviation = Length(0, Fixed);
if (filterValue->length() >= 1)
- stdDeviation = convertToFloatLength(firstValue, style, rootStyle, zoomFactor);
+ stdDeviation = convertToFloatLength(firstValue, style, rootStyle, parentStyle(), zoomFactor);
if (stdDeviation.isUndefined())
return false;
continue;
ShadowValue* item = static_cast<ShadowValue*>(cssValue);
- IntPoint location(item->x->computeLength<int>(style, rootStyle, zoomFactor),
- item->y->computeLength<int>(style, rootStyle, zoomFactor));
- int blur = item->blur ? item->blur->computeLength<int>(style, rootStyle, zoomFactor) : 0;
+ IntPoint location(item->x->computeLength<int>(style, rootStyle, m_parentStyle, zoomFactor),
+ item->y->computeLength<int>(style, rootStyle, m_parentStyle, zoomFactor));
+ int blur = item->blur ? item->blur->computeLength<int>(style, rootStyle, m_parentStyle, zoomFactor) : 0;
Color color;
if (item->color)
color = colorFromPrimitiveValue(item->color.get());
void setEffectiveZoom(float f) { m_fontDirty |= style()->setEffectiveZoom(f); }
void setTextSizeAdjust(bool b) { m_fontDirty |= style()->setTextSizeAdjust(b); }
bool hasParentNode() const { return m_parentNode; }
-
+ ContainerNode* parentNode() const { return m_parentNode; }
+
void appendAuthorStylesheets(unsigned firstNew, const Vector<RefPtr<StyleSheet> >&);
// Find the ids or classes the selectors on a stylesheet are scoped to. The selectors only apply to elements in subtrees where the root element matches the scope.
bool usesBeforeAfterRules() const { return m_features.usesBeforeAfterRules; }
bool usesLinkRules() const { return m_features.usesLinkRules; }
- static bool createTransformOperations(CSSValue* inValue, RenderStyle* inStyle, RenderStyle* rootStyle, TransformOperations& outOperations);
+ static bool createTransformOperations(CSSValue* inValue, RenderStyle* inStyle, RenderStyle* rootStyle, RenderStyle* parentStyle, TransformOperations& outOperations);
void invalidateMatchedPropertiesCache();
bool applyPropertyToRegularStyle() const { return m_applyPropertyToRegularStyle; }
bool applyPropertyToVisitedLinkStyle() const { return m_applyPropertyToVisitedLinkStyle; }
- static Length convertToIntLength(CSSPrimitiveValue*, RenderStyle*, RenderStyle* rootStyle, double multiplier = 1);
- static Length convertToFloatLength(CSSPrimitiveValue*, RenderStyle*, RenderStyle* rootStyle, double multiplier = 1);
+ static Length convertToIntLength(CSSPrimitiveValue*, RenderStyle*, RenderStyle* rootStyle, RenderStyle* parentStyle, double multiplier = 1);
+ static Length convertToFloatLength(CSSPrimitiveValue*, RenderStyle*, RenderStyle* rootStyle, RenderStyle* parentStyle, double multiplier = 1);
CSSToStyleMap* styleMap() { return &m_styleMap; }
return;
TransformOperations operations;
- if (!StyleResolver::createTransformOperations(value.get(), 0, 0, operations)) {
+ if (!StyleResolver::createTransformOperations(value.get(), 0, 0, 0, operations)) {
ec = SYNTAX_ERR;
return;
}