Commit a67f96a0 authored by hyatt@apple.com's avatar hyatt@apple.com

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.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@45919 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 07d848ab
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.
2009-07-15 Brian Weinstein <bweinstein@apple.com>
Rubberstamped by Mark Rowe.
......
<html>
<body>
This is a test of dynamic rem unit scaling. Changes to the root element's font size need to cause dependent elements in the document tree
to update as well.
<div style="font-size:10px">
This text should be small.
<div style="font-size:1rem">
This text should match the root (and be 24px).
</div>
</div>
<script>
document.body.offsetWidth;
document.documentElement.style.fontSize = '24px';
</script>
</body>
</html>
<html style="font-size:2rem">
<body>
This is a test to make sure rem units used on the root element are relative to the user agent default.
</body>
</html>
49f5a7603bf118b5e0bb51b1d269a64f
\ No newline at end of file
301886fd3d21ad6414fc4553eb0b319c
\ No newline at end of file
layer at (0,0) size 800x600
RenderView at (0,0) size 800x600
layer at (0,0) size 800x600
RenderBlock {HTML} at (0,0) size 800x600
RenderBody {BODY} at (8,8) size 784x584
RenderBlock (anonymous) at (0,0) size 784x56
RenderText {#text} at (0,0) size 756x56
text run at (0,0) width 413: "This is a test of dynamic rem unit scaling. "
text run at (413,0) width 331: "Changes to the root element's font"
text run at (0,28) width 756: "size need to cause dependent elements in the document tree to update as well."
RenderBlock {DIV} at (0,56) size 784x41
RenderBlock (anonymous) at (0,0) size 784x13
RenderText {#text} at (0,0) size 106x13
text run at (0,0) width 106: "This text should be small."
RenderBlock {DIV} at (0,13) size 784x28
RenderText {#text} at (0,0) size 449x28
text run at (0,0) width 449: "This text should match the root (and be 24px)."
5ea182ef3ae8d77a935b2afa992e0755
\ No newline at end of file
layer at (0,0) size 800x600
RenderView at (0,0) size 800x600
layer at (0,0) size 800x600
RenderBlock {HTML} at (0,0) size 800x600
RenderBody {BODY} at (8,8) size 784x584
RenderText {#text} at (0,0) size 781x74
text run at (0,0) width 781: "This is a test to make sure rem units used on the root element"
text run at (0,37) width 466: "are relative to the user agent default."
RenderText {#text} at (0,0) size 0x0
RenderText {#text} at (0,0) size 0x0
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:
2009-07-15 Dimitri Glazkov <dglazkov@chromium.org>
Unreviewed, build fix.
......
......@@ -93,7 +93,7 @@ static int cssyylex(YYSTYPE* yylval, void* parser)
%}
%expect 49
%expect 50
%nonassoc LOWEST_PREC
......@@ -145,6 +145,7 @@ static int cssyylex(YYSTYPE* yylval, void* parser)
%token MEDIA_NOT
%token MEDIA_AND
%token <number> REMS
%token <number> QEMS
%token <number> EMS
%token <number> EXS
......@@ -1407,7 +1408,15 @@ unary_term:
| EMS maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_EMS; }
| QEMS maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSParserValue::Q_EMS; }
| EXS maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_EXS; }
;
| REMS maybe_space {
$$.id = 0;
$$.fValue = $1;
$$.unit = CSSPrimitiveValue::CSS_REMS;
CSSParser* p = static_cast<CSSParser*>(parser);
if (Document* doc = p->document())
doc->setUsesRemUnits(true);
}
;
variable_reference:
VARCALL {
......
......@@ -424,6 +424,7 @@ bool CSSParser::validUnit(CSSParserValue* value, Units unitflags, bool strict)
break;
case CSSParserValue::Q_EMS:
case CSSPrimitiveValue::CSS_EMS:
case CSSPrimitiveValue::CSS_REMS:
case CSSPrimitiveValue::CSS_EXS:
case CSSPrimitiveValue::CSS_PX:
case CSSPrimitiveValue::CSS_CM:
......@@ -459,6 +460,8 @@ static int unitFromString(CSSParserValue* value)
if (equal(value->string, "em"))
return CSSPrimitiveValue::CSS_EMS;
if (equal(value->string, "rem"))
return CSSPrimitiveValue::CSS_REMS;
if (equal(value->string, "ex"))
return CSSPrimitiveValue::CSS_EXS;
if (equal(value->string, "px"))
......@@ -1641,6 +1644,8 @@ bool CSSParser::parseValue(int propId, bool important)
parsedValue = CSSPrimitiveValue::create(value->string, (CSSPrimitiveValue::UnitTypes) value->unit);
else if (value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <= CSSPrimitiveValue::CSS_KHZ)
parsedValue = CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveValue::UnitTypes) value->unit);
else if (value->unit >= CSSPrimitiveValue::CSS_TURN && value->unit <= CSSPrimitiveValue::CSS_REMS)
parsedValue = CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveValue::UnitTypes) value->unit);
else if (value->unit >= CSSParserValue::Q_EMS)
parsedValue = CSSQuirkPrimitiveValue::create(value->fValue, CSSPrimitiveValue::CSS_EMS);
m_valueList->next();
......@@ -4339,6 +4344,7 @@ int CSSParser::lex(void* yylvalWithoutType)
case DEGS:
case RADS:
case KHERZ:
case REMS:
length--;
case MSECS:
case HERZ:
......
......@@ -73,6 +73,8 @@ PassRefPtr<CSSValue> CSSParserValue::createCSSValue()
parsedValue = CSSPrimitiveValue::create(string, (CSSPrimitiveValue::UnitTypes)unit);
else if (unit >= CSSPrimitiveValue::CSS_NUMBER && unit <= CSSPrimitiveValue::CSS_KHZ)
parsedValue = CSSPrimitiveValue::create(fValue, (CSSPrimitiveValue::UnitTypes)unit);
else if (unit >= CSSPrimitiveValue::CSS_TURN && unit <= CSSPrimitiveValue::CSS_REMS) // CSS3 Values and Units
parsedValue = CSSPrimitiveValue::create(fValue, (CSSPrimitiveValue::UnitTypes)unit);
else if (unit >= CSSParserValue::Q_EMS)
parsedValue = CSSQuirkPrimitiveValue::create(fValue, CSSPrimitiveValue::CSS_EMS);
return parsedValue;
......
......@@ -318,9 +318,9 @@ void CSSPrimitiveValue::cleanup()
m_type = 0;
}
int CSSPrimitiveValue::computeLengthInt(RenderStyle* style)
int CSSPrimitiveValue::computeLengthInt(RenderStyle* style, RenderStyle* rootStyle)
{
double result = computeLengthDouble(style);
double result = computeLengthDouble(style, rootStyle);
// This conversion is imprecise, often resulting in values of, e.g., 44.99998. We
// need to go ahead and round if we're really close to the next integer value.
......@@ -331,9 +331,9 @@ int CSSPrimitiveValue::computeLengthInt(RenderStyle* style)
return static_cast<int>(result);
}
int CSSPrimitiveValue::computeLengthInt(RenderStyle* style, double multiplier)
int CSSPrimitiveValue::computeLengthInt(RenderStyle* style, RenderStyle* rootStyle, double multiplier)
{
double result = computeLengthDouble(style, multiplier);
double result = computeLengthDouble(style, rootStyle, multiplier);
// This conversion is imprecise, often resulting in values of, e.g., 44.99998. We
// need to go ahead and round if we're really close to the next integer value.
......@@ -348,9 +348,9 @@ const int intMaxForLength = 0x7ffffff; // max value for a 28-bit int
const int intMinForLength = (-0x7ffffff - 1); // min value for a 28-bit int
// Lengths expect an int that is only 28-bits, so we have to check for a different overflow.
int CSSPrimitiveValue::computeLengthIntForLength(RenderStyle* style)
int CSSPrimitiveValue::computeLengthIntForLength(RenderStyle* style, RenderStyle* rootStyle)
{
double result = computeLengthDouble(style);
double result = computeLengthDouble(style, rootStyle);
// This conversion is imprecise, often resulting in values of, e.g., 44.99998. We
// need to go ahead and round if we're really close to the next integer value.
......@@ -362,9 +362,9 @@ int CSSPrimitiveValue::computeLengthIntForLength(RenderStyle* style)
}
// Lengths expect an int that is only 28-bits, so we have to check for a different overflow.
int CSSPrimitiveValue::computeLengthIntForLength(RenderStyle* style, double multiplier)
int CSSPrimitiveValue::computeLengthIntForLength(RenderStyle* style, RenderStyle* rootStyle, double multiplier)
{
double result = computeLengthDouble(style, multiplier);
double result = computeLengthDouble(style, rootStyle, multiplier);
// This conversion is imprecise, often resulting in values of, e.g., 44.99998. We
// need to go ahead and round if we're really close to the next integer value.
......@@ -375,9 +375,9 @@ int CSSPrimitiveValue::computeLengthIntForLength(RenderStyle* style, double mult
return static_cast<int>(result);
}
short CSSPrimitiveValue::computeLengthShort(RenderStyle* style)
short CSSPrimitiveValue::computeLengthShort(RenderStyle* style, RenderStyle* rootStyle)
{
double result = computeLengthDouble(style);
double result = computeLengthDouble(style, rootStyle);
// This conversion is imprecise, often resulting in values of, e.g., 44.99998. We
// need to go ahead and round if we're really close to the next integer value.
......@@ -388,9 +388,9 @@ short CSSPrimitiveValue::computeLengthShort(RenderStyle* style)
return static_cast<short>(result);
}
short CSSPrimitiveValue::computeLengthShort(RenderStyle* style, double multiplier)
short CSSPrimitiveValue::computeLengthShort(RenderStyle* style, RenderStyle* rootStyle, double multiplier)
{
double result = computeLengthDouble(style, multiplier);
double result = computeLengthDouble(style, rootStyle, multiplier);
// This conversion is imprecise, often resulting in values of, e.g., 44.99998. We
// need to go ahead and round if we're really close to the next integer value.
......@@ -401,17 +401,17 @@ short CSSPrimitiveValue::computeLengthShort(RenderStyle* style, double multiplie
return static_cast<short>(result);
}
float CSSPrimitiveValue::computeLengthFloat(RenderStyle* style, bool computingFontSize)
float CSSPrimitiveValue::computeLengthFloat(RenderStyle* style, RenderStyle* rootStyle, bool computingFontSize)
{
return static_cast<float>(computeLengthDouble(style, 1.0, computingFontSize));
return static_cast<float>(computeLengthDouble(style, rootStyle, 1.0, computingFontSize));
}
float CSSPrimitiveValue::computeLengthFloat(RenderStyle* style, double multiplier, bool computingFontSize)
float CSSPrimitiveValue::computeLengthFloat(RenderStyle* style, RenderStyle* rootStyle, double multiplier, bool computingFontSize)
{
return static_cast<float>(computeLengthDouble(style, multiplier, computingFontSize));
return static_cast<float>(computeLengthDouble(style, rootStyle, multiplier, computingFontSize));
}
double CSSPrimitiveValue::computeLengthDouble(RenderStyle* style, double multiplier, bool computingFontSize)
double CSSPrimitiveValue::computeLengthDouble(RenderStyle* style, RenderStyle* rootStyle, double multiplier, bool computingFontSize)
{
unsigned short type = primitiveType();
......@@ -434,6 +434,10 @@ double CSSPrimitiveValue::computeLengthDouble(RenderStyle* style, double multipl
applyZoomMultiplier = false;
factor = style->font().xHeight();
break;
case CSS_REMS:
applyZoomMultiplier = false;
factor = computingFontSize ? rootStyle->fontDescription().specifiedSize() : rootStyle->fontDescription().computedSize();
break;
case CSS_PX:
break;
case CSS_CM:
......@@ -700,6 +704,9 @@ String CSSPrimitiveValue::cssText() const
case CSS_EXS:
text = String::format("%.6lgex", m_value.num);
break;
case CSS_REMS:
text = String::format("%.6lgrem", m_value.num);
break;
case CSS_PX:
text = String::format("%.6lgpx", m_value.num);
break;
......@@ -892,6 +899,7 @@ CSSParserValue CSSPrimitiveValue::parserValue() const
case CSS_PERCENTAGE:
case CSS_EMS:
case CSS_EXS:
case CSS_REMS:
case CSS_PX:
case CSS_CM:
case CSS_MM:
......
......@@ -78,11 +78,13 @@ public:
// This is used internally for unknown identifiers
CSS_PARSER_IDENTIFIER = 107,
// This unit is in CSS 3, but that isn't a finished standard yet
CSS_TURN = 108
// These are from CSS3 Values and Units, but that isn't a finished standard yet
CSS_TURN = 108,
CSS_REMS = 109
};
static bool isUnitTypeLength(int type) { return type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG; }
static bool isUnitTypeLength(int type) { return (type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG) ||
type == CSSPrimitiveValue::CSS_REMS; }
static PassRefPtr<CSSPrimitiveValue> createIdentifier(int ident);
static PassRefPtr<CSSPrimitiveValue> createColor(unsigned rgbValue);
......@@ -112,15 +114,15 @@ public:
* this is screen/printer dependent, so we probably need a config option for this,
* and some tool to calibrate.
*/
int computeLengthInt(RenderStyle*);
int computeLengthInt(RenderStyle*, double multiplier);
int computeLengthIntForLength(RenderStyle*);
int computeLengthIntForLength(RenderStyle*, double multiplier);
short computeLengthShort(RenderStyle*);
short computeLengthShort(RenderStyle*, double multiplier);
float computeLengthFloat(RenderStyle*, bool computingFontSize = false);
float computeLengthFloat(RenderStyle*, double multiplier, bool computingFontSize = false);
double computeLengthDouble(RenderStyle*, double multiplier = 1.0, bool computingFontSize = false);
int computeLengthInt(RenderStyle* currStyle, RenderStyle* rootStyle);
int computeLengthInt(RenderStyle* currStyle, RenderStyle* rootStyle, double multiplier);
int computeLengthIntForLength(RenderStyle* currStyle, RenderStyle* rootStyle);
int computeLengthIntForLength(RenderStyle* currStyle, RenderStyle* rootStyle, double multiplier);
short computeLengthShort(RenderStyle* currStyle, RenderStyle* rootStyle);
short computeLengthShort(RenderStyle* currStyle, RenderStyle* rootStyle, double multiplier);
float computeLengthFloat(RenderStyle* currStyle, RenderStyle* rootStyle, bool computingFontSize = false);
float computeLengthFloat(RenderStyle* currStyle, RenderStyle* rootStyle, double multiplier, bool computingFontSize = false);
double computeLengthDouble(RenderStyle* currentStyle, RenderStyle* rootStyle, double multiplier = 1.0, bool computingFontSize = false);
// use with care!!!
void setPrimitiveType(unsigned short type) { m_type = type; }
......
This diff is collapsed.
......@@ -152,7 +152,7 @@ public:
void addKeyframeStyle(PassRefPtr<WebKitCSSKeyframesRule> rule);
static bool createTransformOperations(CSSValue* inValue, RenderStyle* inStyle, TransformOperations& outOperations);
static bool createTransformOperations(CSSValue* inValue, RenderStyle* inStyle, RenderStyle* rootStyle, TransformOperations& outOperations);
private:
enum SelectorMatch { SelectorMatches, SelectorFailsLocally, SelectorFailsCompletely };
......@@ -266,6 +266,7 @@ public:
RefPtr<RenderStyle> m_style;
RenderStyle* m_parentStyle;
RenderStyle* m_rootElementStyle;
Element* m_element;
StyledElement* m_styledElement;
Node* m_parentNode;
......
......@@ -300,7 +300,8 @@ static bool device_heightMediaFeatureEval(CSSValue* value, RenderStyle* style, F
{
if (value) {
FloatRect sg = screenRect(frame->page()->mainFrame()->view());
return value->isPrimitiveValue() && compareValue(static_cast<int>(sg.height()), static_cast<CSSPrimitiveValue*>(value)->computeLengthInt(style), op);
RenderStyle* rootStyle = frame->document()->documentElement()->renderStyle();
return value->isPrimitiveValue() && compareValue(static_cast<int>(sg.height()), static_cast<CSSPrimitiveValue*>(value)->computeLengthInt(style, rootStyle), op);
}
// ({,min-,max-}device-height)
// assume if we have a device, assume non-zero
......@@ -311,7 +312,8 @@ static bool device_widthMediaFeatureEval(CSSValue* value, RenderStyle* style, Fr
{
if (value) {
FloatRect sg = screenRect(frame->page()->mainFrame()->view());
return value->isPrimitiveValue() && compareValue(static_cast<int>(sg.width()), static_cast<CSSPrimitiveValue*>(value)->computeLengthInt(style), op);
RenderStyle* rootStyle = frame->document()->documentElement()->renderStyle();
return value->isPrimitiveValue() && compareValue(static_cast<int>(sg.width()), static_cast<CSSPrimitiveValue*>(value)->computeLengthInt(style, rootStyle), op);
}
// ({,min-,max-}device-width)
// assume if we have a device, assume non-zero
......@@ -321,9 +323,10 @@ static bool device_widthMediaFeatureEval(CSSValue* value, RenderStyle* style, Fr
static bool heightMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix op)
{
FrameView* view = frame->view();
RenderStyle* rootStyle = frame->document()->documentElement()->renderStyle();
if (value)
return value->isPrimitiveValue() && compareValue(view->layoutHeight(), static_cast<CSSPrimitiveValue*>(value)->computeLengthInt(style), op);
return value->isPrimitiveValue() && compareValue(view->layoutHeight(), static_cast<CSSPrimitiveValue*>(value)->computeLengthInt(style, rootStyle), op);
return view->layoutHeight() != 0;
}
......@@ -331,9 +334,10 @@ static bool heightMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* f
static bool widthMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix op)
{
FrameView* view = frame->view();
RenderStyle* rootStyle = frame->document()->documentElement()->renderStyle();
if (value)
return value->isPrimitiveValue() && compareValue(view->layoutWidth(), static_cast<CSSPrimitiveValue*>(value)->computeLengthInt(style), op);
return value->isPrimitiveValue() && compareValue(view->layoutWidth(), static_cast<CSSPrimitiveValue*>(value)->computeLengthInt(style, rootStyle), op);
return view->layoutWidth() != 0;
}
......
......@@ -72,7 +72,7 @@ void WebKitCSSMatrix::setMatrixValue(const String& string, ExceptionCode& ec)
// requires style (i.e., param uses 'ems' or 'exs')
PassRefPtr<CSSValue> val = styleDeclaration->getPropertyCSSValue(CSSPropertyWebkitTransform);
TransformOperations operations;
if (!CSSStyleSelector::createTransformOperations(val.get(), 0, operations)) {
if (!CSSStyleSelector::createTransformOperations(val.get(), 0, 0, operations)) {
ec = SYNTAX_ERR;
return;
}
......
......@@ -73,6 +73,7 @@ nth (-?[0-9]*n[\+-][0-9]+)|(-?[0-9]*n)
"!"{w}"important" {yyTok = IMPORTANT_SYM; return yyTok;}
{num}em {yyTok = EMS; return yyTok;}
{num}rem {yyTok = REMS; return yyTok;}
{num}__qem {yyTok = QEMS; return yyTok;} /* quirky ems */
{num}ex {yyTok = EXS; return yyTok;}
{num}px {yyTok = PXS; return yyTok;}
......
......@@ -361,11 +361,14 @@ Document::Document(Frame* frame, bool isXHTML)
m_inDocument = true;
m_inStyleRecalc = false;
m_closeAfterStyleRecalc = false;
m_usesDescendantRules = false;
m_usesSiblingRules = false;
m_usesFirstLineRules = false;
m_usesFirstLetterRules = false;
m_usesBeforeAfterRules = false;
m_usesRemUnits = false;
m_gotoAnchorNeededAfterStylesheetsLoad = false;
m_styleSelector = 0;
......
......@@ -377,6 +377,8 @@ public:
void setUsesFirstLetterRules(bool b) { m_usesFirstLetterRules = b; }
bool usesBeforeAfterRules() const { return m_usesBeforeAfterRules; }
void setUsesBeforeAfterRules(bool b) { m_usesBeforeAfterRules = b; }
bool usesRemUnits() const { return m_usesRemUnits; }
void setUsesRemUnits(bool b) { m_usesRemUnits = b; }
// Machinery for saving and restoring state when you leave and then go back to a page.
void registerFormElementWithState(Element* e) { m_formElementsWithState.add(e); }
......@@ -903,6 +905,7 @@ private:
bool m_usesFirstLineRules;
bool m_usesFirstLetterRules;
bool m_usesBeforeAfterRules;
bool m_usesRemUnits;
bool m_gotoAnchorNeededAfterStylesheetsLoad;
bool m_isDNSPrefetchEnabled;
bool m_haveExplicitlyDisabledDNSPrefetch;
......
......@@ -854,7 +854,11 @@ void Element::recalcStyle(StyleChange change)
setRenderStyle(newStyle);
if (change != Force) {
if ((document()->usesDescendantRules() || hasPositionalRules) && styleChangeType() >= FullStyleChange)
// 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
// 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).
if (document()->usesRemUnits() && ch != NoChange && currentStyle && newStyle && currentStyle->fontSize() != newStyle->fontSize() && document()->documentElement() == this)
change = Force;
else if ((document()->usesDescendantRules() || hasPositionalRules) && styleChangeType() >= FullStyleChange)
change = Force;
else
change = ch;
......
......@@ -272,7 +272,7 @@ static void writeStyle(TextStream& ts, const RenderObject& object)
ts << s << *strokePaintServer;
double dashOffset = SVGRenderStyle::cssPrimitiveToLength(&path, svgStyle->strokeDashOffset(), 0.0f);
const DashArray& dashArray = dashArrayFromRenderingStyle(style);
const DashArray& dashArray = dashArrayFromRenderingStyle(style, object.document()->documentElement()->renderStyle());
double strokeWidth = SVGRenderStyle::cssPrimitiveToLength(&path, svgStyle->strokeWidth(), 1.0f);
writeIfNotDefault(ts, "opacity", svgStyle->strokeOpacity(), 1.0f);
......
......@@ -136,7 +136,7 @@ float SVGRenderStyle::cssPrimitiveToLength(const RenderObject* item, CSSValue* v
}
}
return primitive->computeLengthFloat(const_cast<RenderStyle*>(item->style()));
return primitive->computeLengthFloat(const_cast<RenderStyle*>(item->style()), item->document()->documentElement()->renderStyle());
}
}
......
......@@ -158,7 +158,7 @@ void applyStrokeStyleToContext(GraphicsContext* context, RenderStyle* style, con
if (style->svgStyle()->joinStyle() == MiterJoin)
context->setMiterLimit(style->svgStyle()->strokeMiterLimit());
const DashArray& dashes = dashArrayFromRenderingStyle(object->style());
const DashArray& dashes = dashArrayFromRenderingStyle(object->style(), object->document()->documentElement()->renderStyle());
float dashOffset = SVGRenderStyle::cssPrimitiveToLength(object, style->svgStyle()->strokeDashOffset(), 0.0f);
context->setLineDash(dashes, dashOffset);
}
......@@ -201,7 +201,7 @@ void SVGPaintServer::teardown(GraphicsContext*&, const RenderObject*, SVGPaintTa
}
#endif
DashArray dashArrayFromRenderingStyle(const RenderStyle* style)
DashArray dashArrayFromRenderingStyle(const RenderStyle* style, RenderStyle* rootStyle)
{
DashArray array;
......@@ -214,7 +214,7 @@ DashArray dashArrayFromRenderingStyle(const RenderStyle* style)
if (!dash)
continue;
array.append((float) dash->computeLengthFloat(const_cast<RenderStyle*>(style)));
array.append((float) dash->computeLengthFloat(const_cast<RenderStyle*>(style), rootStyle));
}
}
......
......@@ -85,7 +85,7 @@ namespace WebCore {
SVGPaintServer* getPaintServerById(Document*, const AtomicString&);
void applyStrokeStyleToContext(GraphicsContext*, RenderStyle*, const RenderObject*);
DashArray dashArrayFromRenderingStyle(const RenderStyle* style);
DashArray dashArrayFromRenderingStyle(const RenderStyle* style, RenderStyle* rootStyle);
} // namespace WebCore
#endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment