Changeset 45919 in webkit


Ignore:
Timestamp:
Jul 15, 2009 10:02:30 AM (15 years ago)
Author:
hyatt@apple.com
Message:

WebCore:

2009-07-14 David Hyatt <hyatt@apple.com>

Reviewed by Simon Fraser.

https://bugs.webkit.org/show_bug.cgi?id=27283

Implement the new 'rem' unit from CSS3.

Added some rem-* tests in fast/css.

  • css/CSSGrammar.y:
  • css/CSSParser.cpp: (WebCore::CSSParser::validUnit): (WebCore::unitFromString): (WebCore::CSSParser::parseValue): (WebCore::CSSParser::lex):
  • css/CSSParserValues.cpp: (WebCore::CSSParserValue::createCSSValue):
  • css/CSSPrimitiveValue.cpp: (WebCore::CSSPrimitiveValue::computeLengthInt): (WebCore::CSSPrimitiveValue::computeLengthIntForLength): (WebCore::CSSPrimitiveValue::computeLengthShort): (WebCore::CSSPrimitiveValue::computeLengthFloat): (WebCore::CSSPrimitiveValue::computeLengthDouble): (WebCore::CSSPrimitiveValue::cssText): (WebCore::CSSPrimitiveValue::parserValue):
  • css/CSSPrimitiveValue.h: (WebCore::CSSPrimitiveValue::): (WebCore::CSSPrimitiveValue::isUnitTypeLength):
  • css/CSSStyleSelector.cpp: (WebCore::CSSStyleSelector::initForStyleResolve): (WebCore::convertToLength): (WebCore::CSSStyleSelector::applyProperty): (WebCore::CSSStyleSelector::mapFillSize): (WebCore::CSSStyleSelector::mapFillXPosition): (WebCore::CSSStyleSelector::mapFillYPosition): (WebCore::CSSStyleSelector::createTransformOperations):
  • css/CSSStyleSelector.h:
  • css/MediaQueryEvaluator.cpp: (WebCore::device_heightMediaFeatureEval): (WebCore::device_widthMediaFeatureEval): (WebCore::heightMediaFeatureEval): (WebCore::widthMediaFeatureEval):
  • css/WebKitCSSMatrix.cpp: (WebCore::WebKitCSSMatrix::setMatrixValue):
  • css/tokenizer.flex:
  • dom/Document.cpp: (WebCore::Document::Document):
  • dom/Document.h: (WebCore::Document::usesRemUnits): (WebCore::Document::setUsesRemUnits):
  • dom/Element.cpp: (WebCore::Element::recalcStyle):
  • rendering/SVGRenderTreeAsText.cpp: (WebCore::writeStyle):
  • rendering/style/SVGRenderStyle.cpp: (WebCore::SVGRenderStyle::cssPrimitiveToLength):
  • svg/graphics/SVGPaintServer.cpp: (WebCore::applyStrokeStyleToContext): (WebCore::dashArrayFromRenderingStyle):
  • svg/graphics/SVGPaintServer.h:

LayoutTests:

2009-07-14 David Hyatt <hyatt@apple.com>

Reviewed by Simon Fraser.

Add layout tests for the new CSS3 'rem' unit type.

  • fast/css/rem-dynamic-scaling.html: Added.
  • fast/css/rem-units-on-root.html: Added.
  • fast/css/remove-shorthand-expected.checksum: Added.
  • fast/css/remove-shorthand-expected.png: Added.
  • platform/mac/fast/css/rem-dynamic-scaling-expected.checksum: Added.
  • platform/mac/fast/css/rem-dynamic-scaling-expected.png: Added.
  • platform/mac/fast/css/rem-dynamic-scaling-expected.txt: Added.
  • platform/mac/fast/css/rem-units-on-root-expected.checksum: Added.
  • platform/mac/fast/css/rem-units-on-root-expected.png: Added.
  • platform/mac/fast/css/rem-units-on-root-expected.txt: Added.
Location:
trunk
Files:
10 added
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r45917 r45919  
     12009-07-14  David Hyatt  <hyatt@apple.com>
     2
     3        Reviewed by Simon Fraser.
     4
     5        Add layout tests for the new CSS3 'rem' unit type.
     6
     7        * fast/css/rem-dynamic-scaling.html: Added.
     8        * fast/css/rem-units-on-root.html: Added.
     9        * fast/css/remove-shorthand-expected.checksum: Added.
     10        * fast/css/remove-shorthand-expected.png: Added.
     11        * platform/mac/fast/css/rem-dynamic-scaling-expected.checksum: Added.
     12        * platform/mac/fast/css/rem-dynamic-scaling-expected.png: Added.
     13        * platform/mac/fast/css/rem-dynamic-scaling-expected.txt: Added.
     14        * platform/mac/fast/css/rem-units-on-root-expected.checksum: Added.
     15        * platform/mac/fast/css/rem-units-on-root-expected.png: Added.
     16        * platform/mac/fast/css/rem-units-on-root-expected.txt: Added.
     17
    1182009-07-15  Brian Weinstein  <bweinstein@apple.com>
    219
  • trunk/WebCore/ChangeLog

    r45916 r45919  
     12009-07-14  David Hyatt  <hyatt@apple.com>
     2
     3        Reviewed by Simon Fraser.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=27283
     6
     7        Implement the new 'rem' unit from CSS3.
     8
     9        Added some rem-* tests in fast/css.
     10
     11        * css/CSSGrammar.y:
     12        * css/CSSParser.cpp:
     13        (WebCore::CSSParser::validUnit):
     14        (WebCore::unitFromString):
     15        (WebCore::CSSParser::parseValue):
     16        (WebCore::CSSParser::lex):
     17        * css/CSSParserValues.cpp:
     18        (WebCore::CSSParserValue::createCSSValue):
     19        * css/CSSPrimitiveValue.cpp:
     20        (WebCore::CSSPrimitiveValue::computeLengthInt):
     21        (WebCore::CSSPrimitiveValue::computeLengthIntForLength):
     22        (WebCore::CSSPrimitiveValue::computeLengthShort):
     23        (WebCore::CSSPrimitiveValue::computeLengthFloat):
     24        (WebCore::CSSPrimitiveValue::computeLengthDouble):
     25        (WebCore::CSSPrimitiveValue::cssText):
     26        (WebCore::CSSPrimitiveValue::parserValue):
     27        * css/CSSPrimitiveValue.h:
     28        (WebCore::CSSPrimitiveValue::):
     29        (WebCore::CSSPrimitiveValue::isUnitTypeLength):
     30        * css/CSSStyleSelector.cpp:
     31        (WebCore::CSSStyleSelector::initForStyleResolve):
     32        (WebCore::convertToLength):
     33        (WebCore::CSSStyleSelector::applyProperty):
     34        (WebCore::CSSStyleSelector::mapFillSize):
     35        (WebCore::CSSStyleSelector::mapFillXPosition):
     36        (WebCore::CSSStyleSelector::mapFillYPosition):
     37        (WebCore::CSSStyleSelector::createTransformOperations):
     38        * css/CSSStyleSelector.h:
     39        * css/MediaQueryEvaluator.cpp:
     40        (WebCore::device_heightMediaFeatureEval):
     41        (WebCore::device_widthMediaFeatureEval):
     42        (WebCore::heightMediaFeatureEval):
     43        (WebCore::widthMediaFeatureEval):
     44        * css/WebKitCSSMatrix.cpp:
     45        (WebCore::WebKitCSSMatrix::setMatrixValue):
     46        * css/tokenizer.flex:
     47        * dom/Document.cpp:
     48        (WebCore::Document::Document):
     49        * dom/Document.h:
     50        (WebCore::Document::usesRemUnits):
     51        (WebCore::Document::setUsesRemUnits):
     52        * dom/Element.cpp:
     53        (WebCore::Element::recalcStyle):
     54        * rendering/SVGRenderTreeAsText.cpp:
     55        (WebCore::writeStyle):
     56        * rendering/style/SVGRenderStyle.cpp:
     57        (WebCore::SVGRenderStyle::cssPrimitiveToLength):
     58        * svg/graphics/SVGPaintServer.cpp:
     59        (WebCore::applyStrokeStyleToContext):
     60        (WebCore::dashArrayFromRenderingStyle):
     61        * svg/graphics/SVGPaintServer.h:
     62
    1632009-07-15  Dimitri Glazkov  <dglazkov@chromium.org>
    264
  • trunk/WebCore/css/CSSGrammar.y

    r44075 r45919  
    9494%}
    9595
    96 %expect 49
     96%expect 50
    9797
    9898%nonassoc LOWEST_PREC
     
    146146%token MEDIA_AND
    147147
     148%token <number> REMS
    148149%token <number> QEMS
    149150%token <number> EMS
     
    14081409  | QEMS maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSParserValue::Q_EMS; }
    14091410  | EXS maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_EXS; }
    1410     ;
     1411  | REMS maybe_space {
     1412      $$.id = 0;
     1413      $$.fValue = $1;
     1414      $$.unit = CSSPrimitiveValue::CSS_REMS;
     1415      CSSParser* p = static_cast<CSSParser*>(parser);
     1416      if (Document* doc = p->document())
     1417          doc->setUsesRemUnits(true);
     1418  }
     1419  ;
    14111420
    14121421variable_reference:
  • trunk/WebCore/css/CSSParser.cpp

    r45747 r45919  
    425425    case CSSParserValue::Q_EMS:
    426426    case CSSPrimitiveValue::CSS_EMS:
     427    case CSSPrimitiveValue::CSS_REMS:
    427428    case CSSPrimitiveValue::CSS_EXS:
    428429    case CSSPrimitiveValue::CSS_PX:
     
    460461    if (equal(value->string, "em"))
    461462        return CSSPrimitiveValue::CSS_EMS;
     463    if (equal(value->string, "rem"))
     464        return CSSPrimitiveValue::CSS_REMS;
    462465    if (equal(value->string, "ex"))
    463466        return CSSPrimitiveValue::CSS_EXS;
     
    16411644            parsedValue = CSSPrimitiveValue::create(value->string, (CSSPrimitiveValue::UnitTypes) value->unit);
    16421645        else if (value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <= CSSPrimitiveValue::CSS_KHZ)
     1646            parsedValue = CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveValue::UnitTypes) value->unit);
     1647        else if (value->unit >= CSSPrimitiveValue::CSS_TURN && value->unit <= CSSPrimitiveValue::CSS_REMS)
    16431648            parsedValue = CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveValue::UnitTypes) value->unit);
    16441649        else if (value->unit >= CSSParserValue::Q_EMS)
     
    43404345    case RADS:
    43414346    case KHERZ:
     4347    case REMS:
    43424348        length--;
    43434349    case MSECS:
  • trunk/WebCore/css/CSSParserValues.cpp

    r40009 r45919  
    7474    else if (unit >= CSSPrimitiveValue::CSS_NUMBER && unit <= CSSPrimitiveValue::CSS_KHZ)
    7575        parsedValue = CSSPrimitiveValue::create(fValue, (CSSPrimitiveValue::UnitTypes)unit);
     76    else if (unit >= CSSPrimitiveValue::CSS_TURN && unit <= CSSPrimitiveValue::CSS_REMS) // CSS3 Values and Units
     77        parsedValue = CSSPrimitiveValue::create(fValue, (CSSPrimitiveValue::UnitTypes)unit);
    7678    else if (unit >= CSSParserValue::Q_EMS)
    7779        parsedValue = CSSQuirkPrimitiveValue::create(fValue, CSSPrimitiveValue::CSS_EMS);
  • trunk/WebCore/css/CSSPrimitiveValue.cpp

    r42081 r45919  
    319319}
    320320
    321 int CSSPrimitiveValue::computeLengthInt(RenderStyle* style)
    322 {
    323     double result = computeLengthDouble(style);
     321int CSSPrimitiveValue::computeLengthInt(RenderStyle* style, RenderStyle* rootStyle)
     322{
     323    double result = computeLengthDouble(style, rootStyle);
    324324
    325325    // This conversion is imprecise, often resulting in values of, e.g., 44.99998.  We
     
    332332}
    333333
    334 int CSSPrimitiveValue::computeLengthInt(RenderStyle* style, double multiplier)
    335 {
    336     double result = computeLengthDouble(style, multiplier);
     334int CSSPrimitiveValue::computeLengthInt(RenderStyle* style, RenderStyle* rootStyle, double multiplier)
     335{
     336    double result = computeLengthDouble(style, rootStyle, multiplier);
    337337
    338338    // This conversion is imprecise, often resulting in values of, e.g., 44.99998.  We
     
    349349
    350350// Lengths expect an int that is only 28-bits, so we have to check for a different overflow.
    351 int CSSPrimitiveValue::computeLengthIntForLength(RenderStyle* style)
    352 {
    353     double result = computeLengthDouble(style);
     351int CSSPrimitiveValue::computeLengthIntForLength(RenderStyle* style, RenderStyle* rootStyle)
     352{
     353    double result = computeLengthDouble(style, rootStyle);
    354354
    355355    // This conversion is imprecise, often resulting in values of, e.g., 44.99998.  We
     
    363363
    364364// Lengths expect an int that is only 28-bits, so we have to check for a different overflow.
    365 int CSSPrimitiveValue::computeLengthIntForLength(RenderStyle* style, double multiplier)
    366 {
    367     double result = computeLengthDouble(style, multiplier);
     365int CSSPrimitiveValue::computeLengthIntForLength(RenderStyle* style, RenderStyle* rootStyle, double multiplier)
     366{
     367    double result = computeLengthDouble(style, rootStyle, multiplier);
    368368
    369369    // This conversion is imprecise, often resulting in values of, e.g., 44.99998.  We
     
    376376}
    377377
    378 short CSSPrimitiveValue::computeLengthShort(RenderStyle* style)
    379 {
    380     double result = computeLengthDouble(style);
     378short CSSPrimitiveValue::computeLengthShort(RenderStyle* style, RenderStyle* rootStyle)
     379{
     380    double result = computeLengthDouble(style, rootStyle);
    381381
    382382    // This conversion is imprecise, often resulting in values of, e.g., 44.99998.  We
     
    389389}
    390390
    391 short CSSPrimitiveValue::computeLengthShort(RenderStyle* style, double multiplier)
    392 {
    393     double result = computeLengthDouble(style, multiplier);
     391short CSSPrimitiveValue::computeLengthShort(RenderStyle* style, RenderStyle* rootStyle, double multiplier)
     392{
     393    double result = computeLengthDouble(style, rootStyle, multiplier);
    394394
    395395    // This conversion is imprecise, often resulting in values of, e.g., 44.99998.  We
     
    402402}
    403403
    404 float CSSPrimitiveValue::computeLengthFloat(RenderStyle* style, bool computingFontSize)
    405 {
    406     return static_cast<float>(computeLengthDouble(style, 1.0, computingFontSize));
    407 }
    408 
    409 float CSSPrimitiveValue::computeLengthFloat(RenderStyle* style, double multiplier, bool computingFontSize)
    410 {
    411     return static_cast<float>(computeLengthDouble(style, multiplier, computingFontSize));
    412 }
    413 
    414 double CSSPrimitiveValue::computeLengthDouble(RenderStyle* style, double multiplier, bool computingFontSize)
     404float CSSPrimitiveValue::computeLengthFloat(RenderStyle* style, RenderStyle* rootStyle, bool computingFontSize)
     405{
     406    return static_cast<float>(computeLengthDouble(style, rootStyle, 1.0, computingFontSize));
     407}
     408
     409float CSSPrimitiveValue::computeLengthFloat(RenderStyle* style, RenderStyle* rootStyle, double multiplier, bool computingFontSize)
     410{
     411    return static_cast<float>(computeLengthDouble(style, rootStyle, multiplier, computingFontSize));
     412}
     413
     414double CSSPrimitiveValue::computeLengthDouble(RenderStyle* style, RenderStyle* rootStyle, double multiplier, bool computingFontSize)
    415415{
    416416    unsigned short type = primitiveType();
     
    434434            applyZoomMultiplier = false;
    435435            factor = style->font().xHeight();
     436            break;
     437        case CSS_REMS:
     438            applyZoomMultiplier = false;
     439            factor = computingFontSize ? rootStyle->fontDescription().specifiedSize() : rootStyle->fontDescription().computedSize();
    436440            break;
    437441        case CSS_PX:
     
    700704        case CSS_EXS:
    701705            text = String::format("%.6lgex", m_value.num);
     706            break;
     707        case CSS_REMS:
     708            text = String::format("%.6lgrem", m_value.num);
    702709            break;
    703710        case CSS_PX:
     
    893900        case CSS_EMS:
    894901        case CSS_EXS:
     902        case CSS_REMS:
    895903        case CSS_PX:
    896904        case CSS_CM:
  • trunk/WebCore/css/CSSPrimitiveValue.h

    r44805 r45919  
    7979        CSS_PARSER_IDENTIFIER = 107,
    8080       
    81         // This unit is in CSS 3, but that isn't a finished standard yet
    82         CSS_TURN = 108
     81        // These are from CSS3 Values and Units, but that isn't a finished standard yet
     82        CSS_TURN = 108,
     83        CSS_REMS = 109
    8384    };
    8485   
    85     static bool isUnitTypeLength(int type) { return type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG; }
     86    static bool isUnitTypeLength(int type) { return (type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG) ||
     87                                                    type == CSSPrimitiveValue::CSS_REMS; }
    8688
    8789    static PassRefPtr<CSSPrimitiveValue> createIdentifier(int ident);
     
    113115     * and some tool to calibrate.
    114116     */
    115     int computeLengthInt(RenderStyle*);
    116     int computeLengthInt(RenderStyle*, double multiplier);
    117     int computeLengthIntForLength(RenderStyle*);
    118     int computeLengthIntForLength(RenderStyle*, double multiplier);
    119     short computeLengthShort(RenderStyle*);
    120     short computeLengthShort(RenderStyle*, double multiplier);
    121     float computeLengthFloat(RenderStyle*, bool computingFontSize = false);
    122     float computeLengthFloat(RenderStyle*, double multiplier, bool computingFontSize = false);
    123     double computeLengthDouble(RenderStyle*, double multiplier = 1.0, bool computingFontSize = false);
     117    int computeLengthInt(RenderStyle* currStyle, RenderStyle* rootStyle);
     118    int computeLengthInt(RenderStyle* currStyle, RenderStyle* rootStyle, double multiplier);
     119    int computeLengthIntForLength(RenderStyle* currStyle, RenderStyle* rootStyle);
     120    int computeLengthIntForLength(RenderStyle* currStyle, RenderStyle* rootStyle, double multiplier);
     121    short computeLengthShort(RenderStyle* currStyle, RenderStyle* rootStyle);
     122    short computeLengthShort(RenderStyle* currStyle, RenderStyle* rootStyle, double multiplier);
     123    float computeLengthFloat(RenderStyle* currStyle, RenderStyle* rootStyle, bool computingFontSize = false);
     124    float computeLengthFloat(RenderStyle* currStyle, RenderStyle* rootStyle, double multiplier, bool computingFontSize = false);
     125    double computeLengthDouble(RenderStyle* currentStyle, RenderStyle* rootStyle, double multiplier = 1.0, bool computingFontSize = false);
    124126
    125127    // use with care!!!
  • trunk/WebCore/css/CSSStyleSelector.cpp

    r45747 r45919  
    822822    else
    823823        m_parentStyle = m_parentNode ? m_parentNode->renderStyle() : 0;
     824
     825    Node* docElement = e ? e->document()->documentElement() : 0;
     826    RenderStyle* docStyle = m_checker.m_document->renderStyle();
     827    m_rootElementStyle = docElement && e != docElement ? docElement->renderStyle() : docStyle;
    824828
    825829    m_style = 0;
     
    27542758// this is mostly boring stuff on how to apply a certain rule to the renderstyle...
    27552759
    2756 static Length convertToLength(CSSPrimitiveValue *primitiveValue, RenderStyle *style, double multiplier = 1, bool *ok = 0)
     2760static Length convertToLength(CSSPrimitiveValue* primitiveValue, RenderStyle* style, RenderStyle* rootStyle, double multiplier = 1, bool *ok = 0)
    27572761{
    27582762    // This function is tolerant of a null style value. The only place style is used is in
     
    27662770        int type = primitiveValue->primitiveType();
    27672771       
    2768         if (!style && (type == CSSPrimitiveValue::CSS_EMS || type == CSSPrimitiveValue::CSS_EXS)) {
     2772        if (!style && (type == CSSPrimitiveValue::CSS_EMS || type == CSSPrimitiveValue::CSS_EXS || type == CSSPrimitiveValue::CSS_REMS)) {
    27692773            if (ok)
    27702774                *ok = false;
    27712775        } else if (CSSPrimitiveValue::isUnitTypeLength(type))
    2772             l = Length(primitiveValue->computeLengthIntForLength(style, multiplier), Fixed);
     2776            l = Length(primitiveValue->computeLengthIntForLength(style, rootStyle, multiplier), Fixed);
    27732777        else if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
    27742778            l = Length(primitiveValue->getDoubleValue(), Percent);
     
    32083212        if (!primitiveValue)
    32093213            return;
    3210         short spacing = primitiveValue->computeLengthShort(style(), zoomFactor);
     3214        short spacing = primitiveValue->computeLengthShort(style(), m_rootElementStyle, zoomFactor);
    32113215        m_style->setHorizontalBorderSpacing(spacing);
    32123216        return;
     
    32163220        if (!primitiveValue)
    32173221            return;
    3218         short spacing = primitiveValue->computeLengthShort(style(), zoomFactor);
     3222        short spacing = primitiveValue->computeLengthShort(style(), m_rootElementStyle, zoomFactor);
    32193223        m_style->setVerticalBorderSpacing(spacing);
    32203224        return;
     
    33913395            break;
    33923396        case CSSValueInvalid:
    3393             width = primitiveValue->computeLengthShort(style(), zoomFactor);
     3397            width = primitiveValue->computeLengthShort(style(), m_rootElementStyle, zoomFactor);
    33943398            break;
    33953399        default:
     
    34443448            if (!primitiveValue)
    34453449                return;
    3446             width = primitiveValue->computeLengthInt(style(), zoomFactor);
     3450            width = primitiveValue->computeLengthInt(style(), m_rootElementStyle, zoomFactor);
    34473451        }
    34483452        switch (id) {
     
    35713575            if (CSSPrimitiveValue::isUnitTypeLength(type))
    35723576                // Handle our quirky margin units if we have them.
    3573                 l = Length(primitiveValue->computeLengthIntForLength(style(), zoomFactor), Fixed,
     3577                l = Length(primitiveValue->computeLengthIntForLength(style(), m_rootElementStyle, zoomFactor), Fixed,
    35743578                           primitiveValue->isQuirkValue());
    35753579            else if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
     
    36713675            unsigned short type = primitiveValue->primitiveType();
    36723676            if (CSSPrimitiveValue::isUnitTypeLength(type))
    3673                 l = Length(primitiveValue->computeLengthIntForLength(style(), zoomFactor), Fixed);
     3677                l = Length(primitiveValue->computeLengthIntForLength(style(), m_rootElementStyle, zoomFactor), Fixed);
    36743678            else if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
    36753679                l = Length(primitiveValue->getDoubleValue(), Percent);
     
    37273731          Length l;
    37283732          if (CSSPrimitiveValue::isUnitTypeLength(type))
    3729             l = Length(primitiveValue->computeLengthIntForLength(style(), zoomFactor), Fixed);
     3733            l = Length(primitiveValue->computeLengthIntForLength(style(), m_rootElementStyle, zoomFactor), Fixed);
    37303734          else if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
    37313735            l = Length(primitiveValue->getDoubleValue(), Percent);
     
    37893793                                              (type != CSSPrimitiveValue::CSS_PERCENTAGE &&
    37903794                                               type != CSSPrimitiveValue::CSS_EMS &&
    3791                                                type != CSSPrimitiveValue::CSS_EXS));
     3795                                               type != CSSPrimitiveValue::CSS_EXS &&
     3796                                               type != CSSPrimitiveValue::CSS_REMS));
    37923797            if (CSSPrimitiveValue::isUnitTypeLength(type))
    3793                 size = primitiveValue->computeLengthFloat(m_parentStyle, true);
     3798                size = primitiveValue->computeLengthFloat(m_parentStyle, m_rootElementStyle, true);
    37943799            else if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
    37953800                size = (primitiveValue->getFloatValue() * oldSize) / 100.0f;
     
    38573862            if (m_style->textSizeAdjust() && m_checker.m_document->frame() && m_checker.m_document->frame()->shouldApplyTextZoom())
    38583863                multiplier *= m_checker.m_document->frame()->textZoomFactor();
    3859             lineHeight = Length(primitiveValue->computeLengthIntForLength(style(), multiplier), Fixed);
     3864            lineHeight = Length(primitiveValue->computeLengthIntForLength(style(), m_rootElementStyle,  multiplier), Fixed);
    38603865        } else if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
    38613866            lineHeight = Length((m_style->fontSize() * primitiveValue->getIntValue()) / 100, Fixed);
     
    39113916            if (!rect)
    39123917                return;
    3913             top = convertToLength(rect->top(), style(), zoomFactor);
    3914             right = convertToLength(rect->right(), style(), zoomFactor);
    3915             bottom = convertToLength(rect->bottom(), style(), zoomFactor);
    3916             left = convertToLength(rect->left(), style(), zoomFactor);
     3918            top = convertToLength(rect->top(), style(), m_rootElementStyle, zoomFactor);
     3919            right = convertToLength(rect->right(), style(), m_rootElementStyle, zoomFactor);
     3920            bottom = convertToLength(rect->bottom(), style(), m_rootElementStyle, zoomFactor);
     3921            left = convertToLength(rect->left(), style(), m_rootElementStyle, zoomFactor);
    39173922        } else if (primitiveValue->getIdent() != CSSValueAuto) {
    39183923            return;
     
    44754480            return;
    44764481
    4477         int width = pair->first()->computeLengthInt(style(), zoomFactor);
    4478         int height = pair->second()->computeLengthInt(style(), zoomFactor);
     4482        int width = pair->first()->computeLengthInt(style(), m_rootElementStyle, zoomFactor);
     4483        int height = pair->second()->computeLengthInt(style(), m_rootElementStyle,  zoomFactor);
    44794484        if (width < 0 || height < 0)
    44804485            return;
     
    45084513    case CSSPropertyOutlineOffset:
    45094514        HANDLE_INHERIT_AND_INITIAL(outlineOffset, OutlineOffset)
    4510         m_style->setOutlineOffset(primitiveValue->computeLengthInt(style(), zoomFactor));
     4515        m_style->setOutlineOffset(primitiveValue->computeLengthInt(style(), m_rootElementStyle, zoomFactor));
    45114516        return;
    45124517
     
    45284533        for (int i = 0; i < len; i++) {
    45294534            ShadowValue* item = static_cast<ShadowValue*>(list->itemWithoutBoundsCheck(i));
    4530             int x = item->x->computeLengthInt(style(), zoomFactor);
    4531             int y = item->y->computeLengthInt(style(), zoomFactor);
    4532             int blur = item->blur ? item->blur->computeLengthInt(style(), zoomFactor) : 0;
     4535            int x = item->x->computeLengthInt(style(), m_rootElementStyle, zoomFactor);
     4536            int y = item->y->computeLengthInt(style(), m_rootElementStyle, zoomFactor);
     4537            int blur = item->blur ? item->blur->computeLengthInt(style(), m_rootElementStyle, zoomFactor) : 0;
    45334538            Color color;
    45344539            if (item->color)
     
    45564561                reflection->setOffset(Length(reflectValue->offset()->getDoubleValue(), Percent));
    45574562            else
    4558                 reflection->setOffset(Length(reflectValue->offset()->computeLengthIntForLength(style(), zoomFactor), Fixed));
     4563                reflection->setOffset(Length(reflectValue->offset()->computeLengthIntForLength(style(), m_rootElementStyle, zoomFactor), Fixed));
    45594564        }
    45604565        NinePieceImage mask;
     
    46624667            return;
    46634668        }
    4664         m_style->setColumnGap(primitiveValue->computeLengthFloat(style(), zoomFactor));
     4669        m_style->setColumnGap(primitiveValue->computeLengthFloat(style(), m_rootElementStyle, zoomFactor));
    46654670        return;
    46664671    }
     
    46764681            return;
    46774682        }
    4678         m_style->setColumnWidth(primitiveValue->computeLengthFloat(style(), zoomFactor));
     4683        m_style->setColumnWidth(primitiveValue->computeLengthFloat(style(), m_rootElementStyle, zoomFactor));
    46794684        return;
    46804685    }
     
    47784783        else {
    47794784            bool ok = true;
    4780             Length l = convertToLength(primitiveValue, style(), 1, &ok);
     4785            Length l = convertToLength(primitiveValue, style(), m_rootElementStyle, 1, &ok);
    47814786            if (ok)
    47824787                m_style->setMarqueeIncrement(l);
     
    48804885        DashboardRegion *first = region;
    48814886        while (region) {
    4882             Length top = convertToLength(region->top(), style());
    4883             Length right = convertToLength(region->right(), style());
    4884             Length bottom = convertToLength(region->bottom(), style());
    4885             Length left = convertToLength(region->left(), style());
     4887            Length top = convertToLength(region->top(), style(), m_rootElementStyle);
     4888            Length right = convertToLength(region->right(), style(), m_rootElementStyle);
     4889            Length bottom = convertToLength(region->bottom(), style(), m_rootElementStyle);
     4890            Length left = convertToLength(region->left(), style(), m_rootElementStyle);
    48864891            if (region->m_isCircle)
    48874892                m_style->setDashboardRegion(StyleDashboardRegion::Circle, region->m_label, top, right, bottom, left, region == first ? false : true);
     
    49144919                else if (primitiveValue->getIdent() == CSSValueThick)
    49154920                    result *= 5;
    4916                 width = CSSPrimitiveValue::create(result, CSSPrimitiveValue::CSS_EMS)->computeLengthFloat(style(), zoomFactor);
     4921                width = CSSPrimitiveValue::create(result, CSSPrimitiveValue::CSS_EMS)->computeLengthFloat(style(), m_rootElementStyle, zoomFactor);
    49174922                break;
    49184923            }
    49194924            default:
    4920                 width = primitiveValue->computeLengthFloat(style(), zoomFactor);
     4925                width = primitiveValue->computeLengthFloat(style(), m_rootElementStyle, zoomFactor);
    49214926                break;
    49224927        }
     
    49274932        HANDLE_INHERIT_AND_INITIAL(transform, Transform);
    49284933        TransformOperations operations;
    4929         createTransformOperations(value, style(), operations);
     4934        createTransformOperations(value, style(), m_rootElementStyle, operations);
    49304935        m_style->setTransform(operations);
    49314936        return;
     
    49424947        int type = primitiveValue->primitiveType();
    49434948        if (CSSPrimitiveValue::isUnitTypeLength(type))
    4944             l = Length(primitiveValue->computeLengthIntForLength(style(), zoomFactor), Fixed);
     4949            l = Length(primitiveValue->computeLengthIntForLength(style(), m_rootElementStyle, zoomFactor), Fixed);
    49454950        else if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
    49464951            l = Length(primitiveValue->getDoubleValue(), Percent);
     
    49564961        int type = primitiveValue->primitiveType();
    49574962        if (CSSPrimitiveValue::isUnitTypeLength(type))
    4958             l = Length(primitiveValue->computeLengthIntForLength(style(), zoomFactor), Fixed);
     4963            l = Length(primitiveValue->computeLengthIntForLength(style(), m_rootElementStyle, zoomFactor), Fixed);
    49594964        else if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
    49604965            l = Length(primitiveValue->getDoubleValue(), Percent);
     
    49704975        int type = primitiveValue->primitiveType();
    49714976        if (CSSPrimitiveValue::isUnitTypeLength(type))
    4972             f = static_cast<float>(primitiveValue->computeLengthIntForLength(style()));
     4977            f = static_cast<float>(primitiveValue->computeLengthIntForLength(style(), m_rootElementStyle));
    49734978        else
    49744979            return;
     
    49914996        int type = primitiveValue->primitiveType();
    49924997        if (CSSPrimitiveValue::isUnitTypeLength(type))
    4993             perspectiveValue = static_cast<float>(primitiveValue->computeLengthIntForLength(style(), zoomFactor));
     4998            perspectiveValue = static_cast<float>(primitiveValue->computeLengthIntForLength(style(), m_rootElementStyle, zoomFactor));
    49944999        else if (type == CSSPrimitiveValue::CSS_NUMBER) {
    49955000            // For backward compatibility, treat valueless numbers as px.
    4996             perspectiveValue = CSSPrimitiveValue::create(primitiveValue->getDoubleValue(), CSSPrimitiveValue::CSS_PX)->computeLengthFloat(style(), zoomFactor);
     5001            perspectiveValue = CSSPrimitiveValue::create(primitiveValue->getDoubleValue(), CSSPrimitiveValue::CSS_PX)->computeLengthFloat(style(), m_rootElementStyle, zoomFactor);
    49975002        } else
    49985003            return;
     
    50125017        int type = primitiveValue->primitiveType();
    50135018        if (CSSPrimitiveValue::isUnitTypeLength(type))
    5014             l = Length(primitiveValue->computeLengthIntForLength(style(), zoomFactor), Fixed);
     5019            l = Length(primitiveValue->computeLengthIntForLength(style(), m_rootElementStyle, zoomFactor), Fixed);
    50155020        else if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
    50165021            l = Length(primitiveValue->getDoubleValue(), Percent);
     
    50265031        int type = primitiveValue->primitiveType();
    50275032        if (CSSPrimitiveValue::isUnitTypeLength(type))
    5028             l = Length(primitiveValue->computeLengthIntForLength(style(), zoomFactor), Fixed);
     5033            l = Length(primitiveValue->computeLengthIntForLength(style(), m_rootElementStyle, zoomFactor), Fixed);
    50295034        else if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
    50305035            l = Length(primitiveValue->getDoubleValue(), Percent);
     
    52575262        firstLength = Length(Auto);
    52585263    else if (CSSPrimitiveValue::isUnitTypeLength(firstType))
    5259         firstLength = Length(first->computeLengthIntForLength(style(), zoomFactor), Fixed);
     5264        firstLength = Length(first->computeLengthIntForLength(style(), m_rootElementStyle, zoomFactor), Fixed);
    52605265    else if (firstType == CSSPrimitiveValue::CSS_PERCENTAGE)
    52615266        firstLength = Length(first->getDoubleValue(), Percent);
     
    52665271        secondLength = Length(Auto);
    52675272    else if (CSSPrimitiveValue::isUnitTypeLength(secondType))
    5268         secondLength = Length(second->computeLengthIntForLength(style(), zoomFactor), Fixed);
     5273        secondLength = Length(second->computeLengthIntForLength(style(), m_rootElementStyle, zoomFactor), Fixed);
    52695274    else if (secondType == CSSPrimitiveValue::CSS_PERCENTAGE)
    52705275        secondLength = Length(second->getDoubleValue(), Percent);
     
    52935298    int type = primitiveValue->primitiveType();
    52945299    if (CSSPrimitiveValue::isUnitTypeLength(type))
    5295         l = Length(primitiveValue->computeLengthIntForLength(style(), zoomFactor), Fixed);
     5300        l = Length(primitiveValue->computeLengthIntForLength(style(), m_rootElementStyle, zoomFactor), Fixed);
    52965301    else if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
    52975302        l = Length(primitiveValue->getDoubleValue(), Percent);
     
    53175322    int type = primitiveValue->primitiveType();
    53185323    if (CSSPrimitiveValue::isUnitTypeLength(type))
    5319         l = Length(primitiveValue->computeLengthIntForLength(style(), zoomFactor), Fixed);
     5324        l = Length(primitiveValue->computeLengthIntForLength(style(), m_rootElementStyle, zoomFactor), Fixed);
    53205325    else if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
    53215326        l = Length(primitiveValue->getDoubleValue(), Percent);
     
    58315836}
    58325837
    5833 bool CSSStyleSelector::createTransformOperations(CSSValue* inValue, RenderStyle* style, TransformOperations& outOperations)
     5838bool CSSStyleSelector::createTransformOperations(CSSValue* inValue, RenderStyle* style, RenderStyle* rootStyle, TransformOperations& outOperations)
    58345839{
    58355840    float zoomFactor = style ? style->effectiveZoom() : 1;
     
    58985903                    Length ty = Length(0, Fixed);
    58995904                    if (val->operationType() == WebKitCSSTransformValue::TranslateYTransformOperation)
    5900                         ty = convertToLength(firstValue, style, zoomFactor, &ok);
     5905                        ty = convertToLength(firstValue, style, rootStyle, zoomFactor, &ok);
    59015906                    else {
    5902                         tx = convertToLength(firstValue, style, zoomFactor, &ok);
     5907                        tx = convertToLength(firstValue, style, rootStyle, zoomFactor, &ok);
    59035908                        if (val->operationType() != WebKitCSSTransformValue::TranslateXTransformOperation) {
    59045909                            if (val->length() > 1) {
    59055910                                CSSPrimitiveValue* secondValue = static_cast<CSSPrimitiveValue*>(val->itemWithoutBoundsCheck(1));
    5906                                 ty = convertToLength(secondValue, style, zoomFactor, &ok);
     5911                                ty = convertToLength(secondValue, style, rootStyle, zoomFactor, &ok);
    59075912                            }
    59085913                        }
     
    59225927                    Length tz = Length(0, Fixed);
    59235928                    if (val->operationType() == WebKitCSSTransformValue::TranslateZTransformOperation)
    5924                         tz = convertToLength(firstValue, style, zoomFactor, &ok);
     5929                        tz = convertToLength(firstValue, style, rootStyle, zoomFactor, &ok);
    59255930                    else if (val->operationType() == WebKitCSSTransformValue::TranslateYTransformOperation)
    5926                         ty = convertToLength(firstValue, style, zoomFactor, &ok);
     5931                        ty = convertToLength(firstValue, style, rootStyle, zoomFactor, &ok);
    59275932                    else {
    5928                         tx = convertToLength(firstValue, style, zoomFactor, &ok);
     5933                        tx = convertToLength(firstValue, style, rootStyle, zoomFactor, &ok);
    59295934                        if (val->operationType() != WebKitCSSTransformValue::TranslateXTransformOperation) {
    59305935                            if (val->length() > 2) {
    59315936                                CSSPrimitiveValue* thirdValue = static_cast<CSSPrimitiveValue*>(val->itemWithoutBoundsCheck(2));
    5932                                 tz = convertToLength(thirdValue, style, zoomFactor, &ok);
     5937                                tz = convertToLength(thirdValue, style, rootStyle, zoomFactor, &ok);
    59335938                            }
    59345939                            if (val->length() > 1) {
    59355940                                CSSPrimitiveValue* secondValue = static_cast<CSSPrimitiveValue*>(val->itemWithoutBoundsCheck(1));
    5936                                 ty = convertToLength(secondValue, style, zoomFactor, &ok);
     5941                                ty = convertToLength(secondValue, style, rootStyle, zoomFactor, &ok);
    59375942                            }
    59385943                        }
  • trunk/WebCore/css/CSSStyleSelector.h

    r45891 r45919  
    153153        void addKeyframeStyle(PassRefPtr<WebKitCSSKeyframesRule> rule);
    154154
    155         static bool createTransformOperations(CSSValue* inValue, RenderStyle* inStyle, TransformOperations& outOperations);
     155        static bool createTransformOperations(CSSValue* inValue, RenderStyle* inStyle, RenderStyle* rootStyle, TransformOperations& outOperations);
    156156
    157157    private:
     
    267267        RefPtr<RenderStyle> m_style;
    268268        RenderStyle* m_parentStyle;
     269        RenderStyle* m_rootElementStyle;
    269270        Element* m_element;
    270271        StyledElement* m_styledElement;
  • trunk/WebCore/css/MediaQueryEvaluator.cpp

    r45747 r45919  
    301301    if (value) {
    302302        FloatRect sg = screenRect(frame->page()->mainFrame()->view());
    303         return value->isPrimitiveValue() && compareValue(static_cast<int>(sg.height()), static_cast<CSSPrimitiveValue*>(value)->computeLengthInt(style), op);
     303        RenderStyle* rootStyle = frame->document()->documentElement()->renderStyle();
     304        return value->isPrimitiveValue() && compareValue(static_cast<int>(sg.height()), static_cast<CSSPrimitiveValue*>(value)->computeLengthInt(style, rootStyle), op);
    304305    }
    305306    // ({,min-,max-}device-height)
     
    312313    if (value) {
    313314        FloatRect sg = screenRect(frame->page()->mainFrame()->view());
    314         return value->isPrimitiveValue() && compareValue(static_cast<int>(sg.width()), static_cast<CSSPrimitiveValue*>(value)->computeLengthInt(style), op);
     315        RenderStyle* rootStyle = frame->document()->documentElement()->renderStyle();
     316        return value->isPrimitiveValue() && compareValue(static_cast<int>(sg.width()), static_cast<CSSPrimitiveValue*>(value)->computeLengthInt(style, rootStyle), op);
    315317    }
    316318    // ({,min-,max-}device-width)
     
    322324{
    323325    FrameView* view = frame->view();
    324    
     326    RenderStyle* rootStyle = frame->document()->documentElement()->renderStyle();
     327
    325328    if (value)
    326         return value->isPrimitiveValue() && compareValue(view->layoutHeight(), static_cast<CSSPrimitiveValue*>(value)->computeLengthInt(style), op);
     329        return value->isPrimitiveValue() && compareValue(view->layoutHeight(), static_cast<CSSPrimitiveValue*>(value)->computeLengthInt(style, rootStyle), op);
    327330
    328331    return view->layoutHeight() != 0;
     
    332335{
    333336    FrameView* view = frame->view();
    334    
     337    RenderStyle* rootStyle = frame->document()->documentElement()->renderStyle();
     338
    335339    if (value)
    336         return value->isPrimitiveValue() && compareValue(view->layoutWidth(), static_cast<CSSPrimitiveValue*>(value)->computeLengthInt(style), op);
     340        return value->isPrimitiveValue() && compareValue(view->layoutWidth(), static_cast<CSSPrimitiveValue*>(value)->computeLengthInt(style, rootStyle), op);
    337341
    338342    return view->layoutWidth() != 0;
  • trunk/WebCore/css/WebKitCSSMatrix.cpp

    r40807 r45919  
    7373        PassRefPtr<CSSValue> val =  styleDeclaration->getPropertyCSSValue(CSSPropertyWebkitTransform);
    7474        TransformOperations operations;
    75         if (!CSSStyleSelector::createTransformOperations(val.get(), 0, operations)) {
     75        if (!CSSStyleSelector::createTransformOperations(val.get(), 0, 0, operations)) {
    7676            ec = SYNTAX_ERR;
    7777            return;
  • trunk/WebCore/css/tokenizer.flex

    r38959 r45919  
    7474
    7575{num}em                 {yyTok = EMS; return yyTok;}
     76{num}rem                {yyTok = REMS; return yyTok;}
    7677{num}__qem              {yyTok = QEMS; return yyTok;} /* quirky ems */
    7778{num}ex                 {yyTok = EXS; return yyTok;}
  • trunk/WebCore/dom/Document.cpp

    r45786 r45919  
    362362    m_inStyleRecalc = false;
    363363    m_closeAfterStyleRecalc = false;
     364
    364365    m_usesDescendantRules = false;
    365366    m_usesSiblingRules = false;
     
    367368    m_usesFirstLetterRules = false;
    368369    m_usesBeforeAfterRules = false;
     370    m_usesRemUnits = false;
     371
    369372    m_gotoAnchorNeededAfterStylesheetsLoad = false;
    370373 
  • trunk/WebCore/dom/Document.h

    r45786 r45919  
    378378    bool usesBeforeAfterRules() const { return m_usesBeforeAfterRules; }
    379379    void setUsesBeforeAfterRules(bool b) { m_usesBeforeAfterRules = b; }
     380    bool usesRemUnits() const { return m_usesRemUnits; }
     381    void setUsesRemUnits(bool b) { m_usesRemUnits = b; }
    380382
    381383    // Machinery for saving and restoring state when you leave and then go back to a page.
     
    904906    bool m_usesFirstLetterRules;
    905907    bool m_usesBeforeAfterRules;
     908    bool m_usesRemUnits;
    906909    bool m_gotoAnchorNeededAfterStylesheetsLoad;
    907910    bool m_isDNSPrefetchEnabled;
  • trunk/WebCore/dom/Element.cpp

    r45747 r45919  
    855855
    856856        if (change != Force) {
    857             if ((document()->usesDescendantRules() || hasPositionalRules) && styleChangeType() >= FullStyleChange)
     857            // If "rem" units are used anywhere in the document, and if the document element's font size changes, then go ahead and force font updating
     858            // all the way down the tree.  This is simpler than having to maintain a cache of objects (and such font size changes should be rare anyway).
     859            if (document()->usesRemUnits() && ch != NoChange && currentStyle && newStyle && currentStyle->fontSize() != newStyle->fontSize() && document()->documentElement() == this)
     860                change = Force;
     861            else if ((document()->usesDescendantRules() || hasPositionalRules) && styleChangeType() >= FullStyleChange)
    858862                change = Force;
    859863            else
  • trunk/WebCore/rendering/SVGRenderTreeAsText.cpp

    r42840 r45919  
    273273
    274274            double dashOffset = SVGRenderStyle::cssPrimitiveToLength(&path, svgStyle->strokeDashOffset(), 0.0f);
    275             const DashArray& dashArray = dashArrayFromRenderingStyle(style);
     275            const DashArray& dashArray = dashArrayFromRenderingStyle(style, object.document()->documentElement()->renderStyle());
    276276            double strokeWidth = SVGRenderStyle::cssPrimitiveToLength(&path, svgStyle->strokeWidth(), 1.0f);
    277277
  • trunk/WebCore/rendering/style/SVGRenderStyle.cpp

    r40871 r45919  
    137137    }
    138138
    139     return primitive->computeLengthFloat(const_cast<RenderStyle*>(item->style()));
     139    return primitive->computeLengthFloat(const_cast<RenderStyle*>(item->style()), item->document()->documentElement()->renderStyle());
    140140}
    141141
  • trunk/WebCore/svg/graphics/SVGPaintServer.cpp

    r40871 r45919  
    159159        context->setMiterLimit(style->svgStyle()->strokeMiterLimit());
    160160
    161     const DashArray& dashes = dashArrayFromRenderingStyle(object->style());
     161    const DashArray& dashes = dashArrayFromRenderingStyle(object->style(), object->document()->documentElement()->renderStyle());
    162162    float dashOffset = SVGRenderStyle::cssPrimitiveToLength(object, style->svgStyle()->strokeDashOffset(), 0.0f);
    163163    context->setLineDash(dashes, dashOffset);
     
    202202#endif
    203203
    204 DashArray dashArrayFromRenderingStyle(const RenderStyle* style)
     204DashArray dashArrayFromRenderingStyle(const RenderStyle* style, RenderStyle* rootStyle)
    205205{
    206206    DashArray array;
     
    215215                continue;
    216216
    217             array.append((float) dash->computeLengthFloat(const_cast<RenderStyle*>(style)));
     217            array.append((float) dash->computeLengthFloat(const_cast<RenderStyle*>(style), rootStyle));
    218218        }
    219219    }
  • trunk/WebCore/svg/graphics/SVGPaintServer.h

    r40088 r45919  
    8686
    8787    void applyStrokeStyleToContext(GraphicsContext*, RenderStyle*, const RenderObject*);
    88     DashArray dashArrayFromRenderingStyle(const RenderStyle* style);
     88    DashArray dashArrayFromRenderingStyle(const RenderStyle* style, RenderStyle* rootStyle);
    8989} // namespace WebCore
    9090
Note: See TracChangeset for help on using the changeset viewer.