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/CSSPrimitiveValue.cpp

    r120849 r121285  
    456456}
    457457
    458 template<> int CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, float multiplier, bool computingFontSize)
    459 {
    460     return roundForImpreciseConversion<int>(computeLengthDouble(style, rootStyle, multiplier, computingFontSize));
    461 }
    462 
    463 template<> unsigned CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, float multiplier, bool computingFontSize)
    464 {
    465     return roundForImpreciseConversion<unsigned>(computeLengthDouble(style, rootStyle, multiplier, computingFontSize));
    466 }
    467 
    468 template<> Length CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, float multiplier, bool computingFontSize)
     458template<> int CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, RenderStyle* parentStyle, float multiplier, bool computingFontSize)
     459{
     460    return roundForImpreciseConversion<int>(computeLengthDouble(style, rootStyle, parentStyle, multiplier, computingFontSize));
     461}
     462
     463template<> unsigned CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, RenderStyle* parentStyle, float multiplier, bool computingFontSize)
     464{
     465    return roundForImpreciseConversion<unsigned>(computeLengthDouble(style, rootStyle, parentStyle, multiplier, computingFontSize));
     466}
     467
     468template<> Length CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, RenderStyle* parentStyle, float multiplier, bool computingFontSize)
    469469{
    470470#if ENABLE(SUBPIXEL_LAYOUT)
    471     return Length(static_cast<float>(computeLengthDouble(style, rootStyle, multiplier, computingFontSize)), Fixed);
     471    return Length(static_cast<float>(computeLengthDouble(style, rootStyle, parentStyle, multiplier, computingFontSize)), Fixed);
    472472#else
    473     return Length(roundForImpreciseConversion<float>(computeLengthDouble(style, rootStyle, multiplier, computingFontSize)), Fixed);
    474 #endif
    475 }
    476 
    477 template<> short CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, float multiplier, bool computingFontSize)
    478 {
    479     return roundForImpreciseConversion<short>(computeLengthDouble(style, rootStyle, multiplier, computingFontSize));
    480 }
    481 
    482 template<> unsigned short CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, float multiplier, bool computingFontSize)
    483 {
    484     return roundForImpreciseConversion<unsigned short>(computeLengthDouble(style, rootStyle, multiplier, computingFontSize));
    485 }
    486 
    487 template<> float CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, float multiplier, bool computingFontSize)
    488 {
    489     return static_cast<float>(computeLengthDouble(style, rootStyle, multiplier, computingFontSize));
    490 }
    491 
    492 template<> double CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, float multiplier, bool computingFontSize)
    493 {
    494     return computeLengthDouble(style, rootStyle, multiplier, computingFontSize);
    495 }
    496 
    497 double CSSPrimitiveValue::computeLengthDouble(RenderStyle* style, RenderStyle* rootStyle, float multiplier, bool computingFontSize)
     473    return Length(roundForImpreciseConversion<float>(computeLengthDouble(style, rootStyle, parentStyle, multiplier, computingFontSize)), Fixed);
     474#endif
     475}
     476
     477template<> short CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, RenderStyle* parentStyle, float multiplier, bool computingFontSize)
     478{
     479    return roundForImpreciseConversion<short>(computeLengthDouble(style, rootStyle, parentStyle, multiplier, computingFontSize));
     480}
     481
     482template<> unsigned short CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, RenderStyle* parentStyle, float multiplier, bool computingFontSize)
     483{
     484    return roundForImpreciseConversion<unsigned short>(computeLengthDouble(style, rootStyle, parentStyle, multiplier, computingFontSize));
     485}
     486
     487template<> float CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, RenderStyle* parentStyle, float multiplier, bool computingFontSize)
     488{
     489    return static_cast<float>(computeLengthDouble(style, rootStyle, parentStyle, multiplier, computingFontSize));
     490}
     491
     492template<> double CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, RenderStyle* parentStyle, float multiplier, bool computingFontSize)
     493{
     494    return computeLengthDouble(style, rootStyle, parentStyle, multiplier, computingFontSize);
     495}
     496
     497double CSSPrimitiveValue::computeLengthDouble(RenderStyle* style, RenderStyle* rootStyle, RenderStyle* parentStyle, float multiplier, bool computingFontSize)
    498498{
    499499    double factor;
     
    538538            ASSERT_NOT_REACHED();
    539539            return -1.0;
     540        case CSS_VW:
     541            factor = parentStyle ? 0.01 * parentStyle->width().getFloatValue() : 0;
     542            break;
     543        case CSS_VH:
     544            factor = parentStyle ? 0.01 * parentStyle->height().getFloatValue() : 0;
     545            break;
     546        case CSS_VMIN:
     547            factor = 0;
     548            if (parentStyle)
     549                factor = .01 * (float) min(parentStyle->width().getFloatValue(), parentStyle->height().getFloatValue());
     550            break;
    540551        default:
    541552            ASSERT_NOT_REACHED();
     
    546557    if (m_primitiveUnitType == CSS_CALC)
    547558        // The multiplier is passed in as 1.0 here to ensure it is only applied once
    548         computedValue = m_value.calc->computeLengthPx(style, rootStyle, 1.0, computingFontSize);
     559        computedValue = m_value.calc->computeLengthPx(style, rootStyle, parentStyle, 1.0, computingFontSize);
    549560    else
    550561        computedValue = getDoubleValue();
Note: See TracChangeset for help on using the changeset viewer.