Changeset 45919 in webkit
- Timestamp:
- Jul 15, 2009 10:02:30 AM (15 years ago)
- Location:
- trunk
- Files:
-
- 10 added
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r45917 r45919 1 2009-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 1 18 2009-07-15 Brian Weinstein <bweinstein@apple.com> 2 19 -
trunk/WebCore/ChangeLog
r45916 r45919 1 2009-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 1 63 2009-07-15 Dimitri Glazkov <dglazkov@chromium.org> 2 64 -
trunk/WebCore/css/CSSGrammar.y
r44075 r45919 94 94 %} 95 95 96 %expect 4996 %expect 50 97 97 98 98 %nonassoc LOWEST_PREC … … 146 146 %token MEDIA_AND 147 147 148 %token <number> REMS 148 149 %token <number> QEMS 149 150 %token <number> EMS … … 1408 1409 | QEMS maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSParserValue::Q_EMS; } 1409 1410 | 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 ; 1411 1420 1412 1421 variable_reference: -
trunk/WebCore/css/CSSParser.cpp
r45747 r45919 425 425 case CSSParserValue::Q_EMS: 426 426 case CSSPrimitiveValue::CSS_EMS: 427 case CSSPrimitiveValue::CSS_REMS: 427 428 case CSSPrimitiveValue::CSS_EXS: 428 429 case CSSPrimitiveValue::CSS_PX: … … 460 461 if (equal(value->string, "em")) 461 462 return CSSPrimitiveValue::CSS_EMS; 463 if (equal(value->string, "rem")) 464 return CSSPrimitiveValue::CSS_REMS; 462 465 if (equal(value->string, "ex")) 463 466 return CSSPrimitiveValue::CSS_EXS; … … 1641 1644 parsedValue = CSSPrimitiveValue::create(value->string, (CSSPrimitiveValue::UnitTypes) value->unit); 1642 1645 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) 1643 1648 parsedValue = CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveValue::UnitTypes) value->unit); 1644 1649 else if (value->unit >= CSSParserValue::Q_EMS) … … 4340 4345 case RADS: 4341 4346 case KHERZ: 4347 case REMS: 4342 4348 length--; 4343 4349 case MSECS: -
trunk/WebCore/css/CSSParserValues.cpp
r40009 r45919 74 74 else if (unit >= CSSPrimitiveValue::CSS_NUMBER && unit <= CSSPrimitiveValue::CSS_KHZ) 75 75 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); 76 78 else if (unit >= CSSParserValue::Q_EMS) 77 79 parsedValue = CSSQuirkPrimitiveValue::create(fValue, CSSPrimitiveValue::CSS_EMS); -
trunk/WebCore/css/CSSPrimitiveValue.cpp
r42081 r45919 319 319 } 320 320 321 int CSSPrimitiveValue::computeLengthInt(RenderStyle* style )322 { 323 double result = computeLengthDouble(style );321 int CSSPrimitiveValue::computeLengthInt(RenderStyle* style, RenderStyle* rootStyle) 322 { 323 double result = computeLengthDouble(style, rootStyle); 324 324 325 325 // This conversion is imprecise, often resulting in values of, e.g., 44.99998. We … … 332 332 } 333 333 334 int CSSPrimitiveValue::computeLengthInt(RenderStyle* style, double multiplier)335 { 336 double result = computeLengthDouble(style, multiplier);334 int CSSPrimitiveValue::computeLengthInt(RenderStyle* style, RenderStyle* rootStyle, double multiplier) 335 { 336 double result = computeLengthDouble(style, rootStyle, multiplier); 337 337 338 338 // This conversion is imprecise, often resulting in values of, e.g., 44.99998. We … … 349 349 350 350 // 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 );351 int CSSPrimitiveValue::computeLengthIntForLength(RenderStyle* style, RenderStyle* rootStyle) 352 { 353 double result = computeLengthDouble(style, rootStyle); 354 354 355 355 // This conversion is imprecise, often resulting in values of, e.g., 44.99998. We … … 363 363 364 364 // 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);365 int CSSPrimitiveValue::computeLengthIntForLength(RenderStyle* style, RenderStyle* rootStyle, double multiplier) 366 { 367 double result = computeLengthDouble(style, rootStyle, multiplier); 368 368 369 369 // This conversion is imprecise, often resulting in values of, e.g., 44.99998. We … … 376 376 } 377 377 378 short CSSPrimitiveValue::computeLengthShort(RenderStyle* style )379 { 380 double result = computeLengthDouble(style );378 short CSSPrimitiveValue::computeLengthShort(RenderStyle* style, RenderStyle* rootStyle) 379 { 380 double result = computeLengthDouble(style, rootStyle); 381 381 382 382 // This conversion is imprecise, often resulting in values of, e.g., 44.99998. We … … 389 389 } 390 390 391 short CSSPrimitiveValue::computeLengthShort(RenderStyle* style, double multiplier)392 { 393 double result = computeLengthDouble(style, multiplier);391 short CSSPrimitiveValue::computeLengthShort(RenderStyle* style, RenderStyle* rootStyle, double multiplier) 392 { 393 double result = computeLengthDouble(style, rootStyle, multiplier); 394 394 395 395 // This conversion is imprecise, often resulting in values of, e.g., 44.99998. We … … 402 402 } 403 403 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)404 float CSSPrimitiveValue::computeLengthFloat(RenderStyle* style, RenderStyle* rootStyle, bool computingFontSize) 405 { 406 return static_cast<float>(computeLengthDouble(style, rootStyle, 1.0, computingFontSize)); 407 } 408 409 float CSSPrimitiveValue::computeLengthFloat(RenderStyle* style, RenderStyle* rootStyle, double multiplier, bool computingFontSize) 410 { 411 return static_cast<float>(computeLengthDouble(style, rootStyle, multiplier, computingFontSize)); 412 } 413 414 double CSSPrimitiveValue::computeLengthDouble(RenderStyle* style, RenderStyle* rootStyle, double multiplier, bool computingFontSize) 415 415 { 416 416 unsigned short type = primitiveType(); … … 434 434 applyZoomMultiplier = false; 435 435 factor = style->font().xHeight(); 436 break; 437 case CSS_REMS: 438 applyZoomMultiplier = false; 439 factor = computingFontSize ? rootStyle->fontDescription().specifiedSize() : rootStyle->fontDescription().computedSize(); 436 440 break; 437 441 case CSS_PX: … … 700 704 case CSS_EXS: 701 705 text = String::format("%.6lgex", m_value.num); 706 break; 707 case CSS_REMS: 708 text = String::format("%.6lgrem", m_value.num); 702 709 break; 703 710 case CSS_PX: … … 893 900 case CSS_EMS: 894 901 case CSS_EXS: 902 case CSS_REMS: 895 903 case CSS_PX: 896 904 case CSS_CM: -
trunk/WebCore/css/CSSPrimitiveValue.h
r44805 r45919 79 79 CSS_PARSER_IDENTIFIER = 107, 80 80 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 83 84 }; 84 85 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; } 86 88 87 89 static PassRefPtr<CSSPrimitiveValue> createIdentifier(int ident); … … 113 115 * and some tool to calibrate. 114 116 */ 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); 124 126 125 127 // use with care!!! -
trunk/WebCore/css/CSSStyleSelector.cpp
r45747 r45919 822 822 else 823 823 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; 824 828 825 829 m_style = 0; … … 2754 2758 // this is mostly boring stuff on how to apply a certain rule to the renderstyle... 2755 2759 2756 static Length convertToLength(CSSPrimitiveValue *primitiveValue, RenderStyle *style, double multiplier = 1, bool *ok = 0)2760 static Length convertToLength(CSSPrimitiveValue* primitiveValue, RenderStyle* style, RenderStyle* rootStyle, double multiplier = 1, bool *ok = 0) 2757 2761 { 2758 2762 // This function is tolerant of a null style value. The only place style is used is in … … 2766 2770 int type = primitiveValue->primitiveType(); 2767 2771 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)) { 2769 2773 if (ok) 2770 2774 *ok = false; 2771 2775 } else if (CSSPrimitiveValue::isUnitTypeLength(type)) 2772 l = Length(primitiveValue->computeLengthIntForLength(style, multiplier), Fixed);2776 l = Length(primitiveValue->computeLengthIntForLength(style, rootStyle, multiplier), Fixed); 2773 2777 else if (type == CSSPrimitiveValue::CSS_PERCENTAGE) 2774 2778 l = Length(primitiveValue->getDoubleValue(), Percent); … … 3208 3212 if (!primitiveValue) 3209 3213 return; 3210 short spacing = primitiveValue->computeLengthShort(style(), zoomFactor);3214 short spacing = primitiveValue->computeLengthShort(style(), m_rootElementStyle, zoomFactor); 3211 3215 m_style->setHorizontalBorderSpacing(spacing); 3212 3216 return; … … 3216 3220 if (!primitiveValue) 3217 3221 return; 3218 short spacing = primitiveValue->computeLengthShort(style(), zoomFactor);3222 short spacing = primitiveValue->computeLengthShort(style(), m_rootElementStyle, zoomFactor); 3219 3223 m_style->setVerticalBorderSpacing(spacing); 3220 3224 return; … … 3391 3395 break; 3392 3396 case CSSValueInvalid: 3393 width = primitiveValue->computeLengthShort(style(), zoomFactor);3397 width = primitiveValue->computeLengthShort(style(), m_rootElementStyle, zoomFactor); 3394 3398 break; 3395 3399 default: … … 3444 3448 if (!primitiveValue) 3445 3449 return; 3446 width = primitiveValue->computeLengthInt(style(), zoomFactor);3450 width = primitiveValue->computeLengthInt(style(), m_rootElementStyle, zoomFactor); 3447 3451 } 3448 3452 switch (id) { … … 3571 3575 if (CSSPrimitiveValue::isUnitTypeLength(type)) 3572 3576 // 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, 3574 3578 primitiveValue->isQuirkValue()); 3575 3579 else if (type == CSSPrimitiveValue::CSS_PERCENTAGE) … … 3671 3675 unsigned short type = primitiveValue->primitiveType(); 3672 3676 if (CSSPrimitiveValue::isUnitTypeLength(type)) 3673 l = Length(primitiveValue->computeLengthIntForLength(style(), zoomFactor), Fixed);3677 l = Length(primitiveValue->computeLengthIntForLength(style(), m_rootElementStyle, zoomFactor), Fixed); 3674 3678 else if (type == CSSPrimitiveValue::CSS_PERCENTAGE) 3675 3679 l = Length(primitiveValue->getDoubleValue(), Percent); … … 3727 3731 Length l; 3728 3732 if (CSSPrimitiveValue::isUnitTypeLength(type)) 3729 l = Length(primitiveValue->computeLengthIntForLength(style(), zoomFactor), Fixed);3733 l = Length(primitiveValue->computeLengthIntForLength(style(), m_rootElementStyle, zoomFactor), Fixed); 3730 3734 else if (type == CSSPrimitiveValue::CSS_PERCENTAGE) 3731 3735 l = Length(primitiveValue->getDoubleValue(), Percent); … … 3789 3793 (type != CSSPrimitiveValue::CSS_PERCENTAGE && 3790 3794 type != CSSPrimitiveValue::CSS_EMS && 3791 type != CSSPrimitiveValue::CSS_EXS)); 3795 type != CSSPrimitiveValue::CSS_EXS && 3796 type != CSSPrimitiveValue::CSS_REMS)); 3792 3797 if (CSSPrimitiveValue::isUnitTypeLength(type)) 3793 size = primitiveValue->computeLengthFloat(m_parentStyle, true);3798 size = primitiveValue->computeLengthFloat(m_parentStyle, m_rootElementStyle, true); 3794 3799 else if (type == CSSPrimitiveValue::CSS_PERCENTAGE) 3795 3800 size = (primitiveValue->getFloatValue() * oldSize) / 100.0f; … … 3857 3862 if (m_style->textSizeAdjust() && m_checker.m_document->frame() && m_checker.m_document->frame()->shouldApplyTextZoom()) 3858 3863 multiplier *= m_checker.m_document->frame()->textZoomFactor(); 3859 lineHeight = Length(primitiveValue->computeLengthIntForLength(style(), m ultiplier), Fixed);3864 lineHeight = Length(primitiveValue->computeLengthIntForLength(style(), m_rootElementStyle, multiplier), Fixed); 3860 3865 } else if (type == CSSPrimitiveValue::CSS_PERCENTAGE) 3861 3866 lineHeight = Length((m_style->fontSize() * primitiveValue->getIntValue()) / 100, Fixed); … … 3911 3916 if (!rect) 3912 3917 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); 3917 3922 } else if (primitiveValue->getIdent() != CSSValueAuto) { 3918 3923 return; … … 4475 4480 return; 4476 4481 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); 4479 4484 if (width < 0 || height < 0) 4480 4485 return; … … 4508 4513 case CSSPropertyOutlineOffset: 4509 4514 HANDLE_INHERIT_AND_INITIAL(outlineOffset, OutlineOffset) 4510 m_style->setOutlineOffset(primitiveValue->computeLengthInt(style(), zoomFactor));4515 m_style->setOutlineOffset(primitiveValue->computeLengthInt(style(), m_rootElementStyle, zoomFactor)); 4511 4516 return; 4512 4517 … … 4528 4533 for (int i = 0; i < len; i++) { 4529 4534 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; 4533 4538 Color color; 4534 4539 if (item->color) … … 4556 4561 reflection->setOffset(Length(reflectValue->offset()->getDoubleValue(), Percent)); 4557 4562 else 4558 reflection->setOffset(Length(reflectValue->offset()->computeLengthIntForLength(style(), zoomFactor), Fixed));4563 reflection->setOffset(Length(reflectValue->offset()->computeLengthIntForLength(style(), m_rootElementStyle, zoomFactor), Fixed)); 4559 4564 } 4560 4565 NinePieceImage mask; … … 4662 4667 return; 4663 4668 } 4664 m_style->setColumnGap(primitiveValue->computeLengthFloat(style(), zoomFactor));4669 m_style->setColumnGap(primitiveValue->computeLengthFloat(style(), m_rootElementStyle, zoomFactor)); 4665 4670 return; 4666 4671 } … … 4676 4681 return; 4677 4682 } 4678 m_style->setColumnWidth(primitiveValue->computeLengthFloat(style(), zoomFactor));4683 m_style->setColumnWidth(primitiveValue->computeLengthFloat(style(), m_rootElementStyle, zoomFactor)); 4679 4684 return; 4680 4685 } … … 4778 4783 else { 4779 4784 bool ok = true; 4780 Length l = convertToLength(primitiveValue, style(), 1, &ok);4785 Length l = convertToLength(primitiveValue, style(), m_rootElementStyle, 1, &ok); 4781 4786 if (ok) 4782 4787 m_style->setMarqueeIncrement(l); … … 4880 4885 DashboardRegion *first = region; 4881 4886 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); 4886 4891 if (region->m_isCircle) 4887 4892 m_style->setDashboardRegion(StyleDashboardRegion::Circle, region->m_label, top, right, bottom, left, region == first ? false : true); … … 4914 4919 else if (primitiveValue->getIdent() == CSSValueThick) 4915 4920 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); 4917 4922 break; 4918 4923 } 4919 4924 default: 4920 width = primitiveValue->computeLengthFloat(style(), zoomFactor);4925 width = primitiveValue->computeLengthFloat(style(), m_rootElementStyle, zoomFactor); 4921 4926 break; 4922 4927 } … … 4927 4932 HANDLE_INHERIT_AND_INITIAL(transform, Transform); 4928 4933 TransformOperations operations; 4929 createTransformOperations(value, style(), operations);4934 createTransformOperations(value, style(), m_rootElementStyle, operations); 4930 4935 m_style->setTransform(operations); 4931 4936 return; … … 4942 4947 int type = primitiveValue->primitiveType(); 4943 4948 if (CSSPrimitiveValue::isUnitTypeLength(type)) 4944 l = Length(primitiveValue->computeLengthIntForLength(style(), zoomFactor), Fixed);4949 l = Length(primitiveValue->computeLengthIntForLength(style(), m_rootElementStyle, zoomFactor), Fixed); 4945 4950 else if (type == CSSPrimitiveValue::CSS_PERCENTAGE) 4946 4951 l = Length(primitiveValue->getDoubleValue(), Percent); … … 4956 4961 int type = primitiveValue->primitiveType(); 4957 4962 if (CSSPrimitiveValue::isUnitTypeLength(type)) 4958 l = Length(primitiveValue->computeLengthIntForLength(style(), zoomFactor), Fixed);4963 l = Length(primitiveValue->computeLengthIntForLength(style(), m_rootElementStyle, zoomFactor), Fixed); 4959 4964 else if (type == CSSPrimitiveValue::CSS_PERCENTAGE) 4960 4965 l = Length(primitiveValue->getDoubleValue(), Percent); … … 4970 4975 int type = primitiveValue->primitiveType(); 4971 4976 if (CSSPrimitiveValue::isUnitTypeLength(type)) 4972 f = static_cast<float>(primitiveValue->computeLengthIntForLength(style() ));4977 f = static_cast<float>(primitiveValue->computeLengthIntForLength(style(), m_rootElementStyle)); 4973 4978 else 4974 4979 return; … … 4991 4996 int type = primitiveValue->primitiveType(); 4992 4997 if (CSSPrimitiveValue::isUnitTypeLength(type)) 4993 perspectiveValue = static_cast<float>(primitiveValue->computeLengthIntForLength(style(), zoomFactor));4998 perspectiveValue = static_cast<float>(primitiveValue->computeLengthIntForLength(style(), m_rootElementStyle, zoomFactor)); 4994 4999 else if (type == CSSPrimitiveValue::CSS_NUMBER) { 4995 5000 // 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); 4997 5002 } else 4998 5003 return; … … 5012 5017 int type = primitiveValue->primitiveType(); 5013 5018 if (CSSPrimitiveValue::isUnitTypeLength(type)) 5014 l = Length(primitiveValue->computeLengthIntForLength(style(), zoomFactor), Fixed);5019 l = Length(primitiveValue->computeLengthIntForLength(style(), m_rootElementStyle, zoomFactor), Fixed); 5015 5020 else if (type == CSSPrimitiveValue::CSS_PERCENTAGE) 5016 5021 l = Length(primitiveValue->getDoubleValue(), Percent); … … 5026 5031 int type = primitiveValue->primitiveType(); 5027 5032 if (CSSPrimitiveValue::isUnitTypeLength(type)) 5028 l = Length(primitiveValue->computeLengthIntForLength(style(), zoomFactor), Fixed);5033 l = Length(primitiveValue->computeLengthIntForLength(style(), m_rootElementStyle, zoomFactor), Fixed); 5029 5034 else if (type == CSSPrimitiveValue::CSS_PERCENTAGE) 5030 5035 l = Length(primitiveValue->getDoubleValue(), Percent); … … 5257 5262 firstLength = Length(Auto); 5258 5263 else if (CSSPrimitiveValue::isUnitTypeLength(firstType)) 5259 firstLength = Length(first->computeLengthIntForLength(style(), zoomFactor), Fixed);5264 firstLength = Length(first->computeLengthIntForLength(style(), m_rootElementStyle, zoomFactor), Fixed); 5260 5265 else if (firstType == CSSPrimitiveValue::CSS_PERCENTAGE) 5261 5266 firstLength = Length(first->getDoubleValue(), Percent); … … 5266 5271 secondLength = Length(Auto); 5267 5272 else if (CSSPrimitiveValue::isUnitTypeLength(secondType)) 5268 secondLength = Length(second->computeLengthIntForLength(style(), zoomFactor), Fixed);5273 secondLength = Length(second->computeLengthIntForLength(style(), m_rootElementStyle, zoomFactor), Fixed); 5269 5274 else if (secondType == CSSPrimitiveValue::CSS_PERCENTAGE) 5270 5275 secondLength = Length(second->getDoubleValue(), Percent); … … 5293 5298 int type = primitiveValue->primitiveType(); 5294 5299 if (CSSPrimitiveValue::isUnitTypeLength(type)) 5295 l = Length(primitiveValue->computeLengthIntForLength(style(), zoomFactor), Fixed);5300 l = Length(primitiveValue->computeLengthIntForLength(style(), m_rootElementStyle, zoomFactor), Fixed); 5296 5301 else if (type == CSSPrimitiveValue::CSS_PERCENTAGE) 5297 5302 l = Length(primitiveValue->getDoubleValue(), Percent); … … 5317 5322 int type = primitiveValue->primitiveType(); 5318 5323 if (CSSPrimitiveValue::isUnitTypeLength(type)) 5319 l = Length(primitiveValue->computeLengthIntForLength(style(), zoomFactor), Fixed);5324 l = Length(primitiveValue->computeLengthIntForLength(style(), m_rootElementStyle, zoomFactor), Fixed); 5320 5325 else if (type == CSSPrimitiveValue::CSS_PERCENTAGE) 5321 5326 l = Length(primitiveValue->getDoubleValue(), Percent); … … 5831 5836 } 5832 5837 5833 bool CSSStyleSelector::createTransformOperations(CSSValue* inValue, RenderStyle* style, TransformOperations& outOperations)5838 bool CSSStyleSelector::createTransformOperations(CSSValue* inValue, RenderStyle* style, RenderStyle* rootStyle, TransformOperations& outOperations) 5834 5839 { 5835 5840 float zoomFactor = style ? style->effectiveZoom() : 1; … … 5898 5903 Length ty = Length(0, Fixed); 5899 5904 if (val->operationType() == WebKitCSSTransformValue::TranslateYTransformOperation) 5900 ty = convertToLength(firstValue, style, zoomFactor, &ok);5905 ty = convertToLength(firstValue, style, rootStyle, zoomFactor, &ok); 5901 5906 else { 5902 tx = convertToLength(firstValue, style, zoomFactor, &ok);5907 tx = convertToLength(firstValue, style, rootStyle, zoomFactor, &ok); 5903 5908 if (val->operationType() != WebKitCSSTransformValue::TranslateXTransformOperation) { 5904 5909 if (val->length() > 1) { 5905 5910 CSSPrimitiveValue* secondValue = static_cast<CSSPrimitiveValue*>(val->itemWithoutBoundsCheck(1)); 5906 ty = convertToLength(secondValue, style, zoomFactor, &ok);5911 ty = convertToLength(secondValue, style, rootStyle, zoomFactor, &ok); 5907 5912 } 5908 5913 } … … 5922 5927 Length tz = Length(0, Fixed); 5923 5928 if (val->operationType() == WebKitCSSTransformValue::TranslateZTransformOperation) 5924 tz = convertToLength(firstValue, style, zoomFactor, &ok);5929 tz = convertToLength(firstValue, style, rootStyle, zoomFactor, &ok); 5925 5930 else if (val->operationType() == WebKitCSSTransformValue::TranslateYTransformOperation) 5926 ty = convertToLength(firstValue, style, zoomFactor, &ok);5931 ty = convertToLength(firstValue, style, rootStyle, zoomFactor, &ok); 5927 5932 else { 5928 tx = convertToLength(firstValue, style, zoomFactor, &ok);5933 tx = convertToLength(firstValue, style, rootStyle, zoomFactor, &ok); 5929 5934 if (val->operationType() != WebKitCSSTransformValue::TranslateXTransformOperation) { 5930 5935 if (val->length() > 2) { 5931 5936 CSSPrimitiveValue* thirdValue = static_cast<CSSPrimitiveValue*>(val->itemWithoutBoundsCheck(2)); 5932 tz = convertToLength(thirdValue, style, zoomFactor, &ok);5937 tz = convertToLength(thirdValue, style, rootStyle, zoomFactor, &ok); 5933 5938 } 5934 5939 if (val->length() > 1) { 5935 5940 CSSPrimitiveValue* secondValue = static_cast<CSSPrimitiveValue*>(val->itemWithoutBoundsCheck(1)); 5936 ty = convertToLength(secondValue, style, zoomFactor, &ok);5941 ty = convertToLength(secondValue, style, rootStyle, zoomFactor, &ok); 5937 5942 } 5938 5943 } -
trunk/WebCore/css/CSSStyleSelector.h
r45891 r45919 153 153 void addKeyframeStyle(PassRefPtr<WebKitCSSKeyframesRule> rule); 154 154 155 static bool createTransformOperations(CSSValue* inValue, RenderStyle* inStyle, TransformOperations& outOperations);155 static bool createTransformOperations(CSSValue* inValue, RenderStyle* inStyle, RenderStyle* rootStyle, TransformOperations& outOperations); 156 156 157 157 private: … … 267 267 RefPtr<RenderStyle> m_style; 268 268 RenderStyle* m_parentStyle; 269 RenderStyle* m_rootElementStyle; 269 270 Element* m_element; 270 271 StyledElement* m_styledElement; -
trunk/WebCore/css/MediaQueryEvaluator.cpp
r45747 r45919 301 301 if (value) { 302 302 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); 304 305 } 305 306 // ({,min-,max-}device-height) … … 312 313 if (value) { 313 314 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); 315 317 } 316 318 // ({,min-,max-}device-width) … … 322 324 { 323 325 FrameView* view = frame->view(); 324 326 RenderStyle* rootStyle = frame->document()->documentElement()->renderStyle(); 327 325 328 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); 327 330 328 331 return view->layoutHeight() != 0; … … 332 335 { 333 336 FrameView* view = frame->view(); 334 337 RenderStyle* rootStyle = frame->document()->documentElement()->renderStyle(); 338 335 339 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); 337 341 338 342 return view->layoutWidth() != 0; -
trunk/WebCore/css/WebKitCSSMatrix.cpp
r40807 r45919 73 73 PassRefPtr<CSSValue> val = styleDeclaration->getPropertyCSSValue(CSSPropertyWebkitTransform); 74 74 TransformOperations operations; 75 if (!CSSStyleSelector::createTransformOperations(val.get(), 0, operations)) {75 if (!CSSStyleSelector::createTransformOperations(val.get(), 0, 0, operations)) { 76 76 ec = SYNTAX_ERR; 77 77 return; -
trunk/WebCore/css/tokenizer.flex
r38959 r45919 74 74 75 75 {num}em {yyTok = EMS; return yyTok;} 76 {num}rem {yyTok = REMS; return yyTok;} 76 77 {num}__qem {yyTok = QEMS; return yyTok;} /* quirky ems */ 77 78 {num}ex {yyTok = EXS; return yyTok;} -
trunk/WebCore/dom/Document.cpp
r45786 r45919 362 362 m_inStyleRecalc = false; 363 363 m_closeAfterStyleRecalc = false; 364 364 365 m_usesDescendantRules = false; 365 366 m_usesSiblingRules = false; … … 367 368 m_usesFirstLetterRules = false; 368 369 m_usesBeforeAfterRules = false; 370 m_usesRemUnits = false; 371 369 372 m_gotoAnchorNeededAfterStylesheetsLoad = false; 370 373 -
trunk/WebCore/dom/Document.h
r45786 r45919 378 378 bool usesBeforeAfterRules() const { return m_usesBeforeAfterRules; } 379 379 void setUsesBeforeAfterRules(bool b) { m_usesBeforeAfterRules = b; } 380 bool usesRemUnits() const { return m_usesRemUnits; } 381 void setUsesRemUnits(bool b) { m_usesRemUnits = b; } 380 382 381 383 // Machinery for saving and restoring state when you leave and then go back to a page. … … 904 906 bool m_usesFirstLetterRules; 905 907 bool m_usesBeforeAfterRules; 908 bool m_usesRemUnits; 906 909 bool m_gotoAnchorNeededAfterStylesheetsLoad; 907 910 bool m_isDNSPrefetchEnabled; -
trunk/WebCore/dom/Element.cpp
r45747 r45919 855 855 856 856 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) 858 862 change = Force; 859 863 else -
trunk/WebCore/rendering/SVGRenderTreeAsText.cpp
r42840 r45919 273 273 274 274 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()); 276 276 double strokeWidth = SVGRenderStyle::cssPrimitiveToLength(&path, svgStyle->strokeWidth(), 1.0f); 277 277 -
trunk/WebCore/rendering/style/SVGRenderStyle.cpp
r40871 r45919 137 137 } 138 138 139 return primitive->computeLengthFloat(const_cast<RenderStyle*>(item->style()) );139 return primitive->computeLengthFloat(const_cast<RenderStyle*>(item->style()), item->document()->documentElement()->renderStyle()); 140 140 } 141 141 -
trunk/WebCore/svg/graphics/SVGPaintServer.cpp
r40871 r45919 159 159 context->setMiterLimit(style->svgStyle()->strokeMiterLimit()); 160 160 161 const DashArray& dashes = dashArrayFromRenderingStyle(object->style() );161 const DashArray& dashes = dashArrayFromRenderingStyle(object->style(), object->document()->documentElement()->renderStyle()); 162 162 float dashOffset = SVGRenderStyle::cssPrimitiveToLength(object, style->svgStyle()->strokeDashOffset(), 0.0f); 163 163 context->setLineDash(dashes, dashOffset); … … 202 202 #endif 203 203 204 DashArray dashArrayFromRenderingStyle(const RenderStyle* style )204 DashArray dashArrayFromRenderingStyle(const RenderStyle* style, RenderStyle* rootStyle) 205 205 { 206 206 DashArray array; … … 215 215 continue; 216 216 217 array.append((float) dash->computeLengthFloat(const_cast<RenderStyle*>(style) ));217 array.append((float) dash->computeLengthFloat(const_cast<RenderStyle*>(style), rootStyle)); 218 218 } 219 219 } -
trunk/WebCore/svg/graphics/SVGPaintServer.h
r40088 r45919 86 86 87 87 void applyStrokeStyleToContext(GraphicsContext*, RenderStyle*, const RenderObject*); 88 DashArray dashArrayFromRenderingStyle(const RenderStyle* style );88 DashArray dashArrayFromRenderingStyle(const RenderStyle* style, RenderStyle* rootStyle); 89 89 } // namespace WebCore 90 90
Note: See TracChangeset
for help on using the changeset viewer.