Ignore:
Timestamp:
Jun 26, 2012, 1:23:26 PM (13 years ago)
Author:
[email protected]
Message:

ietestcenter/css3/valuesandunits/units-000.htm asserts
https://bugs.webkit.org/show_bug.cgi?id=86176

Patch by Dave Tharp <[email protected]> on 2012-06-26
Reviewed by Beth Dakin.

Source/WebCore:

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):

LayoutTests:

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:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/css/StyleResolver.cpp

    r121229 r121285  
    27582758// this is mostly boring stuff on how to apply a certain rule to the renderstyle...
    27592759
    2760 Length StyleResolver::convertToIntLength(CSSPrimitiveValue* primitiveValue, RenderStyle* style, RenderStyle* rootStyle, double multiplier)
    2761 {
    2762     return primitiveValue ? primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion | FractionConversion | ViewportPercentageConversion>(style, rootStyle, multiplier) : Length(Undefined);
    2763 }
    2764 
    2765 Length StyleResolver::convertToFloatLength(CSSPrimitiveValue* primitiveValue, RenderStyle* style, RenderStyle* rootStyle, double multiplier)
    2766 {
    2767     return primitiveValue ? primitiveValue->convertToLength<FixedFloatConversion | PercentConversion | FractionConversion | ViewportPercentageConversion>(style, rootStyle, multiplier) : Length(Undefined);
     2760Length StyleResolver::convertToIntLength(CSSPrimitiveValue* primitiveValue, RenderStyle* style, RenderStyle* rootStyle, RenderStyle* parentStyle, double multiplier)
     2761{
     2762    return primitiveValue ? primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion | FractionConversion | ViewportPercentageConversion>(style, rootStyle, parentStyle, multiplier) : Length(Undefined);
     2763}
     2764
     2765Length StyleResolver::convertToFloatLength(CSSPrimitiveValue* primitiveValue, RenderStyle* style, RenderStyle* rootStyle, RenderStyle* parentStyle, double multiplier)
     2766{
     2767    return primitiveValue ? primitiveValue->convertToLength<FixedFloatConversion | PercentConversion | FractionConversion | ViewportPercentageConversion>(style, rootStyle, parentStyle, multiplier) : Length(Undefined);
    27682768}
    27692769
     
    32443244static bool createGridTrackBreadth(CSSPrimitiveValue* primitiveValue, StyleResolver* selector, Length& length)
    32453245{
    3246     Length workingLength = primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion | ViewportPercentageConversion | AutoConversion>(selector->style(), selector->rootElementStyle(), selector->style()->effectiveZoom());
     3246    Length workingLength = primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion | ViewportPercentageConversion | AutoConversion>(selector->style(), selector->rootElementStyle(), selector->parentStyle(), selector->style()->effectiveZoom());
    32473247    if (workingLength.isUndefined())
    32483248        return false;
     
    37073707                continue;
    37083708            ShadowValue* item = static_cast<ShadowValue*>(currValue);
    3709             int x = item->x->computeLength<int>(style(), m_rootElementStyle, zoomFactor);
    3710             int y = item->y->computeLength<int>(style(), m_rootElementStyle, zoomFactor);
    3711             int blur = item->blur ? item->blur->computeLength<int>(style(), m_rootElementStyle, zoomFactor) : 0;
    3712             int spread = item->spread ? item->spread->computeLength<int>(style(), m_rootElementStyle, zoomFactor) : 0;
     3709            int x = item->x->computeLength<int>(style(), m_rootElementStyle, m_parentStyle, zoomFactor);
     3710            int y = item->y->computeLength<int>(style(), m_rootElementStyle, m_parentStyle, zoomFactor);
     3711            int blur = item->blur ? item->blur->computeLength<int>(style(), m_rootElementStyle, m_parentStyle, zoomFactor) : 0;
     3712            int spread = item->spread ? item->spread->computeLength<int>(style(), m_rootElementStyle, m_parentStyle, zoomFactor) : 0;
    37133713            ShadowStyle shadowStyle = item->style && item->style->getIdent() == CSSValueInset ? Inset : Normal;
    37143714            Color color;
     
    37403740        reflection->setDirection(reflectValue->direction());
    37413741        if (reflectValue->offset())
    3742             reflection->setOffset(reflectValue->offset()->convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion>(style(), m_rootElementStyle, zoomFactor));
     3742            reflection->setOffset(reflectValue->offset()->convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion>(style(), m_rootElementStyle, m_parentStyle, zoomFactor));
    37433743        NinePieceImage mask;
    37443744        mask.setMaskDefaults();
     
    38223822            }
    38233823        } else {
    3824             Length marqueeLength = convertToIntLength(primitiveValue, style(), m_rootElementStyle);
     3824            Length marqueeLength = convertToIntLength(primitiveValue, style(), m_rootElementStyle, m_parentStyle);
    38253825            if (!marqueeLength.isUndefined())
    38263826                m_style->setMarqueeIncrement(marqueeLength);
     
    38683868        DashboardRegion* first = region;
    38693869        while (region) {
    3870             Length top = convertToIntLength(region->top(), style(), m_rootElementStyle);
    3871             Length right = convertToIntLength(region->right(), style(), m_rootElementStyle);
    3872             Length bottom = convertToIntLength(region->bottom(), style(), m_rootElementStyle);
    3873             Length left = convertToIntLength(region->left(), style(), m_rootElementStyle);
     3870            Length top = convertToIntLength(region->top(), style(), m_rootElementStyle, m_parentStyle);
     3871            Length right = convertToIntLength(region->right(), style(), m_rootElementStyle, m_parentStyle);
     3872            Length bottom = convertToIntLength(region->bottom(), style(), m_rootElementStyle, m_parentStyle);
     3873            Length left = convertToIntLength(region->left(), style(), m_rootElementStyle, m_parentStyle);
    38743874
    38753875            if (top.isUndefined())
     
    39063906            else if (primitiveValue->getIdent() == CSSValueThick)
    39073907                result *= 5;
    3908             width = CSSPrimitiveValue::create(result, CSSPrimitiveValue::CSS_EMS)->computeLength<float>(style(), m_rootElementStyle, zoomFactor);
     3908            width = CSSPrimitiveValue::create(result, CSSPrimitiveValue::CSS_EMS)->computeLength<float>(style(), m_rootElementStyle, m_parentStyle, zoomFactor);
    39093909            break;
    39103910        }
    39113911        default:
    3912             width = primitiveValue->computeLength<float>(style(), m_rootElementStyle, zoomFactor);
     3912            width = primitiveValue->computeLength<float>(style(), m_rootElementStyle, m_parentStyle, zoomFactor);
    39133913            break;
    39143914        }
     
    39193919        HANDLE_INHERIT_AND_INITIAL(transform, Transform);
    39203920        TransformOperations operations;
    3921         createTransformOperations(value, style(), m_rootElementStyle, operations);
     3921        createTransformOperations(value, style(), m_rootElementStyle, m_parentStyle, operations);
    39223922        m_style->setTransform(operations);
    39233923        return;
     
    39363936        float perspectiveValue;
    39373937        if (primitiveValue->isLength())
    3938             perspectiveValue = primitiveValue->computeLength<float>(style(), m_rootElementStyle, zoomFactor);
     3938            perspectiveValue = primitiveValue->computeLength<float>(style(), m_rootElementStyle, m_parentStyle, zoomFactor);
    39393939        else if (primitiveValue->isNumber()) {
    39403940            // For backward compatibility, treat valueless numbers as px.
    3941             perspectiveValue = CSSPrimitiveValue::create(primitiveValue->getDoubleValue(), CSSPrimitiveValue::CSS_PX)->computeLength<float>(style(), m_rootElementStyle, zoomFactor);
     3941            perspectiveValue = CSSPrimitiveValue::create(primitiveValue->getDoubleValue(), CSSPrimitiveValue::CSS_PX)->computeLength<float>(style(), m_rootElementStyle, m_parentStyle, zoomFactor);
    39423942        } else
    39433943            return;
     
    48154815}
    48164816
    4817 bool StyleResolver::createTransformOperations(CSSValue* inValue, RenderStyle* style, RenderStyle* rootStyle, TransformOperations& outOperations)
     4817bool StyleResolver::createTransformOperations(CSSValue* inValue, RenderStyle* style, RenderStyle* rootStyle, RenderStyle* parentStyle, TransformOperations& outOperations)
    48184818{
    48194819    if (!inValue || !inValue->isValueList()) {
     
    48994899            Length ty = Length(0, Fixed);
    49004900            if (transformValue->operationType() == WebKitCSSTransformValue::TranslateYTransformOperation)
    4901                 ty = convertToFloatLength(firstValue, style, rootStyle, zoomFactor);
     4901                ty = convertToFloatLength(firstValue, style, rootStyle, parentStyle, zoomFactor);
    49024902            else {
    4903                 tx = convertToFloatLength(firstValue, style, rootStyle, zoomFactor);
     4903                tx = convertToFloatLength(firstValue, style, rootStyle, parentStyle, zoomFactor);
    49044904                if (transformValue->operationType() != WebKitCSSTransformValue::TranslateXTransformOperation) {
    49054905                    if (transformValue->length() > 1) {
    49064906                        CSSPrimitiveValue* secondValue = static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(1));
    4907                         ty = convertToFloatLength(secondValue, style, rootStyle, zoomFactor);
     4907                        ty = convertToFloatLength(secondValue, style, rootStyle, parentStyle, zoomFactor);
    49084908                    }
    49094909                }
     
    49224922            Length tz = Length(0, Fixed);
    49234923            if (transformValue->operationType() == WebKitCSSTransformValue::TranslateZTransformOperation)
    4924                 tz = convertToFloatLength(firstValue, style, rootStyle, zoomFactor);
     4924                tz = convertToFloatLength(firstValue, style, rootStyle, parentStyle, zoomFactor);
    49254925            else if (transformValue->operationType() == WebKitCSSTransformValue::TranslateYTransformOperation)
    4926                 ty = convertToFloatLength(firstValue, style, rootStyle, zoomFactor);
     4926                ty = convertToFloatLength(firstValue, style, rootStyle, parentStyle, zoomFactor);
    49274927            else {
    4928                 tx = convertToFloatLength(firstValue, style, rootStyle, zoomFactor);
     4928                tx = convertToFloatLength(firstValue, style, rootStyle, parentStyle, zoomFactor);
    49294929                if (transformValue->operationType() != WebKitCSSTransformValue::TranslateXTransformOperation) {
    49304930                    if (transformValue->length() > 2) {
    49314931                        CSSPrimitiveValue* thirdValue = static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(2));
    4932                         tz = convertToFloatLength(thirdValue, style, rootStyle, zoomFactor);
     4932                        tz = convertToFloatLength(thirdValue, style, rootStyle, parentStyle, zoomFactor);
    49334933                    }
    49344934                    if (transformValue->length() > 1) {
    49354935                        CSSPrimitiveValue* secondValue = static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(1));
    4936                         ty = convertToFloatLength(secondValue, style, rootStyle, zoomFactor);
     4936                        ty = convertToFloatLength(secondValue, style, rootStyle, parentStyle, zoomFactor);
    49374937                    }
    49384938                }
     
    50375037            Length p = Length(0, Fixed);
    50385038            if (firstValue->isLength())
    5039                 p = convertToFloatLength(firstValue, style, rootStyle, zoomFactor);
     5039                p = convertToFloatLength(firstValue, style, rootStyle, parentStyle, zoomFactor);
    50405040            else {
    50415041                // This is a quirk that should go away when 3d transforms are finalized.
     
    54015401            Length stdDeviation = Length(0, Fixed);
    54025402            if (filterValue->length() >= 1)
    5403                 stdDeviation = convertToFloatLength(firstValue, style, rootStyle, zoomFactor);
     5403                stdDeviation = convertToFloatLength(firstValue, style, rootStyle, parentStyle(), zoomFactor);
    54045404            if (stdDeviation.isUndefined())
    54055405                return false;
     
    54175417
    54185418            ShadowValue* item = static_cast<ShadowValue*>(cssValue);
    5419             IntPoint location(item->x->computeLength<int>(style, rootStyle, zoomFactor),
    5420                               item->y->computeLength<int>(style, rootStyle, zoomFactor));
    5421             int blur = item->blur ? item->blur->computeLength<int>(style, rootStyle, zoomFactor) : 0;
     5419            IntPoint location(item->x->computeLength<int>(style, rootStyle, m_parentStyle, zoomFactor),
     5420                              item->y->computeLength<int>(style, rootStyle, m_parentStyle, zoomFactor));
     5421            int blur = item->blur ? item->blur->computeLength<int>(style, rootStyle, m_parentStyle, zoomFactor) : 0;
    54225422            Color color;
    54235423            if (item->color)
Note: See TracChangeset for help on using the changeset viewer.