Commit 25d0b096 authored by Andrea Iacovitti's avatar Andrea Iacovitti

Support 'rem' font-relative length unit type.

TODO: handle dynamic font size change on root element (should be rare anyway)
by triggering a style recalc on elements that uses rem unit length.
parent b9f25d91
......@@ -543,7 +543,7 @@ static bool device_heightMediaFeatureEval(CSSValueImpl* value, RenderStyle* styl
doc = static_cast<DOM::DocumentImpl*>(part->document().handle());
}
int logicalDpiY = doc->logicalDpiY();
return value->isPrimitiveValue() && compareValue(height, static_cast<CSSPrimitiveValueImpl*>(value)->computeLength(style,logicalDpiY), op);
return value->isPrimitiveValue() && compareValue(height, static_cast<CSSPrimitiveValueImpl*>(value)->computeLength(style, style, logicalDpiY), op);
}
// ({,min-,max-}device-height)
// assume if we have a device, assume non-zero
......@@ -566,7 +566,7 @@ static bool device_widthMediaFeatureEval(CSSValueImpl* value, RenderStyle* style
doc = static_cast<DOM::DocumentImpl*>(part->document().handle());
}
int logicalDpiY = doc->logicalDpiY();
return value->isPrimitiveValue() && compareValue(width, static_cast<CSSPrimitiveValueImpl*>(value)->computeLength(style,logicalDpiY), op);
return value->isPrimitiveValue() && compareValue(width, static_cast<CSSPrimitiveValueImpl*>(value)->computeLength(style, style, logicalDpiY), op);
}
// ({,min-,max-}device-width)
// assume if we have a device, assume non-zero
......@@ -593,7 +593,7 @@ static bool widthMediaFeatureEval(CSSValueImpl* value, RenderStyle* style, KHTML
}
int logicalDpiY = doc->logicalDpiY();
if (value)
return value->isPrimitiveValue() && compareValue(width, static_cast<CSSPrimitiveValueImpl*>(value)->computeLength(style, logicalDpiY), op);
return value->isPrimitiveValue() && compareValue(width, static_cast<CSSPrimitiveValueImpl*>(value)->computeLength(style, style, logicalDpiY), op);
return width > 0;
}
......@@ -614,7 +614,7 @@ static bool heightMediaFeatureEval(CSSValueImpl* value, RenderStyle* style, KHTM
}
int logicalDpiY = doc->logicalDpiY();
if (value)
return value->isPrimitiveValue() && compareValue(height, static_cast<CSSPrimitiveValueImpl*>(value)->computeLength(style, logicalDpiY), op);
return value->isPrimitiveValue() && compareValue(height, static_cast<CSSPrimitiveValueImpl*>(value)->computeLength(style, style, logicalDpiY), op);
return height > 0;
}
......
......@@ -1068,12 +1068,12 @@ void CSSPrimitiveValueImpl::cleanup()
m_type = 0;
}
int CSSPrimitiveValueImpl::computeLength( khtml::RenderStyle *style, int logicalDpiY)
int CSSPrimitiveValueImpl::computeLength(khtml::RenderStyle *style, khtml::RenderStyle *rootStyle, int logicalDpiY)
{
return snapValue( computeLengthFloat( style, logicalDpiY ) );
return snapValue( computeLengthFloat(style, rootStyle, logicalDpiY) );
}
double CSSPrimitiveValueImpl::computeLengthFloat( khtml::RenderStyle *style, int logicalDpiY)
double CSSPrimitiveValueImpl::computeLengthFloat(khtml::RenderStyle *style, khtml::RenderStyle *rootStyle, int logicalDpiY)
{
unsigned short type = primitiveType();
......@@ -1102,6 +1102,9 @@ double CSSPrimitiveValueImpl::computeLengthFloat( khtml::RenderStyle *style, int
}
break;
}
case CSSPrimitiveValue::CSS_REMS:
factor = rootStyle->font().pixelSize();
break;
case CSSPrimitiveValue::CSS_PX:
break;
case CSSPrimitiveValue::CSS_CM:
......@@ -1224,6 +1227,9 @@ DOM::DOMString CSSPrimitiveValueImpl::cssText() const
case CSSPrimitiveValue::CSS_CHS:
text = DOMString(QString::number( m_value.num ) + "ch");
break;
case CSSPrimitiveValue::CSS_REMS:
text = DOMString(QString::number( m_value.num ) + "rem");
break;
case CSSPrimitiveValue::CSS_PX:
text = DOMString(QString::number( m_value.num ) + "px");
break;
......
......@@ -216,9 +216,9 @@ public:
* this is screen/printer dependent, so we probably need a config option for this,
* and some tool to calibrate.
*/
int computeLength( khtml::RenderStyle *style, int logicalDpiY);
int computeLength(khtml::RenderStyle *style, khtml::RenderStyle *rootStyle, int logicalDpiY);
double computeLengthFloat( khtml::RenderStyle *style, int logicalDpiY);
double computeLengthFloat(khtml::RenderStyle *style, khtml::RenderStyle *rootStyle, int logicalDpiY);
/*
* rounds a computer value into integer as appropriate. This takes
......
......@@ -450,6 +450,7 @@ bool CSSParser::validUnit( Value *value, int unitflags, bool strict )
case CSSPrimitiveValue::CSS_EMS:
case CSSPrimitiveValue::CSS_EXS:
case CSSPrimitiveValue::CSS_CHS:
case CSSPrimitiveValue::CSS_REMS:
case CSSPrimitiveValue::CSS_PX:
case CSSPrimitiveValue::CSS_CM:
case CSSPrimitiveValue::CSS_MM:
......@@ -2924,6 +2925,7 @@ int DOM::CSSParser::lex( void *_yylval )
case RADS:
case KHERZ:
case DPI:
case REMS:
length--;
case MSECS:
case HERZ:
......
......@@ -630,6 +630,9 @@ RenderStyle *CSSStyleSelector::styleForElement(ElementImpl *e, RenderStyle* fall
else
parentStyle = style;
const RenderObject *docElementRenderer = e->document()->documentElement()->renderer();
m_rootStyle = docElementRenderer ? docElementRenderer->style() : m_rootDefaultStyle;
// try to sort out most style rules as early as possible.
quint16 cssTagId = localNamePart(element->id());
int smatch = 0;
......@@ -2252,7 +2255,7 @@ void CSSOrderedPropertyList::append(DOM::CSSStyleDeclarationImpl *decl, uint sel
// -------------------------------------------------------------------------------------
// this is mostly boring stuff on how to apply a certain rule to the renderstyle...
static Length convertToLength( CSSPrimitiveValueImpl *primitiveValue, RenderStyle *style, int logicalDpiY, bool *ok = 0 )
static Length convertToLength(CSSPrimitiveValueImpl *primitiveValue, RenderStyle *style, khtml::RenderStyle *rootStyle, int logicalDpiY, bool *ok = 0)
{
Length l;
if ( !primitiveValue ) {
......@@ -2261,7 +2264,7 @@ static Length convertToLength( CSSPrimitiveValueImpl *primitiveValue, RenderStyl
} else {
int type = primitiveValue->primitiveType();
if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
l = Length(primitiveValue->computeLength(style, logicalDpiY), Fixed);
l = Length(primitiveValue->computeLength(style, rootStyle, logicalDpiY), Fixed);
else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
l = Length(primitiveValue->floatValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent);
else if(type == CSSPrimitiveValue::CSS_NUMBER)
......@@ -2275,7 +2278,7 @@ static Length convertToLength( CSSPrimitiveValueImpl *primitiveValue, RenderStyl
}
// Extracts out border radii lengths from a pair
static BorderRadii convertToBorderRadii(CSSPrimitiveValueImpl *value, RenderStyle *style, int logicalDpiY)
static BorderRadii convertToBorderRadii(CSSPrimitiveValueImpl *value, RenderStyle *style, khtml::RenderStyle *rootStyle, int logicalDpiY)
{
BorderRadii ret;
if (!value)
......@@ -2286,8 +2289,8 @@ static BorderRadii convertToBorderRadii(CSSPrimitiveValueImpl *value, RenderStyl
return ret;
assert(p->first()->isPrimitiveValue() && p->second()->isPrimitiveValue());
ret.horizontal = static_cast<CSSPrimitiveValueImpl*>(p->first())->computeLength(style, logicalDpiY);
ret.vertical = static_cast<CSSPrimitiveValueImpl*>(p->second())->computeLength(style, logicalDpiY);
ret.horizontal = static_cast<CSSPrimitiveValueImpl*>(p->first())->computeLength(style, rootStyle, logicalDpiY);
ret.vertical = static_cast<CSSPrimitiveValueImpl*>(p->second())->computeLength(style, rootStyle, logicalDpiY);
return ret;
}
......@@ -2932,14 +2935,14 @@ void CSSStyleSelector::applyRule( int id, DOM::CSSValueImpl *value )
case CSS_PROP__KHTML_BORDER_HORIZONTAL_SPACING: {
HANDLE_INITIAL_AND_INHERIT_ON_NONINHERITED_PROPERTY(borderHorizontalSpacing, BorderHorizontalSpacing)
if (!primitiveValue) break;
short spacing = primitiveValue->computeLength(style, logicalDpiY);
short spacing = primitiveValue->computeLength(style, m_rootStyle, logicalDpiY);
style->setBorderHorizontalSpacing(spacing);
break;
}
case CSS_PROP__KHTML_BORDER_VERTICAL_SPACING: {
HANDLE_INITIAL_AND_INHERIT_ON_NONINHERITED_PROPERTY(borderVerticalSpacing, BorderVerticalSpacing)
if (!primitiveValue) break;
short spacing = primitiveValue->computeLength(style, logicalDpiY);
short spacing = primitiveValue->computeLength(style, m_rootStyle, logicalDpiY);
style->setBorderVerticalSpacing(spacing);
break;
}
......@@ -2947,19 +2950,19 @@ void CSSStyleSelector::applyRule( int id, DOM::CSSValueImpl *value )
// ### should these handle initial & inherit?
case CSS_PROP__KHTML_BORDER_TOP_RIGHT_RADIUS:
case CSS_PROP_BORDER_TOP_RIGHT_RADIUS:
style->setBorderTopRightRadius(convertToBorderRadii(primitiveValue, style, logicalDpiY));
style->setBorderTopRightRadius(convertToBorderRadii(primitiveValue, style, m_rootStyle, logicalDpiY));
break;
case CSS_PROP__KHTML_BORDER_TOP_LEFT_RADIUS:
case CSS_PROP_BORDER_TOP_LEFT_RADIUS:
style->setBorderTopLeftRadius(convertToBorderRadii(primitiveValue, style, logicalDpiY));
style->setBorderTopLeftRadius(convertToBorderRadii(primitiveValue, style, m_rootStyle, logicalDpiY));
break;
case CSS_PROP__KHTML_BORDER_BOTTOM_RIGHT_RADIUS:
case CSS_PROP_BORDER_BOTTOM_RIGHT_RADIUS:
style->setBorderBottomRightRadius(convertToBorderRadii(primitiveValue, style, logicalDpiY));
style->setBorderBottomRightRadius(convertToBorderRadii(primitiveValue, style, m_rootStyle, logicalDpiY));
break;
case CSS_PROP__KHTML_BORDER_BOTTOM_LEFT_RADIUS:
case CSS_PROP_BORDER_BOTTOM_LEFT_RADIUS:
style->setBorderBottomLeftRadius(convertToBorderRadii(primitiveValue, style, logicalDpiY));
style->setBorderBottomLeftRadius(convertToBorderRadii(primitiveValue, style, m_rootStyle, logicalDpiY));
break;
case CSS_PROP_CURSOR:
......@@ -3141,7 +3144,7 @@ void CSSStyleSelector::applyRule( int id, DOM::CSSValueImpl *value )
break;
case CSS_VAL_INVALID:
{
double widthd = primitiveValue->computeLengthFloat(style, logicalDpiY);
double widthd = primitiveValue->computeLengthFloat(style, m_rootStyle, logicalDpiY);
width = CSSPrimitiveValueImpl::snapValue(widthd);
// somewhat resemble Mozilla's granularity
// this makes border-width: 0.5pt borders visible
......@@ -3192,7 +3195,7 @@ void CSSStyleSelector::applyRule( int id, DOM::CSSValueImpl *value )
int width = 0;
if (primitiveValue->getIdent() != CSS_VAL_NORMAL)
width = primitiveValue->computeLength(style, logicalDpiY);
width = primitiveValue->computeLength(style, m_rootStyle, logicalDpiY);
switch(id)
{
......@@ -3283,8 +3286,7 @@ void CSSStyleSelector::applyRule( int id, DOM::CSSValueImpl *value )
int type = primitiveValue->primitiveType();
if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
// Handle our quirky margin units if we have them.
l = Length(primitiveValue->computeLength(style, logicalDpiY), Fixed,
primitiveValue->isQuirkValue());
l = Length(primitiveValue->computeLength(style, m_rootStyle, logicalDpiY), Fixed, primitiveValue->isQuirkValue());
else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
l = Length(primitiveValue->floatValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent);
else if (type == CSSPrimitiveValue::CSS_HTML_RELATIVE)
......@@ -3361,7 +3363,7 @@ void CSSStyleSelector::applyRule( int id, DOM::CSSValueImpl *value )
{
int type = primitiveValue->primitiveType();
if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
l = Length(primitiveValue->computeLength(style, logicalDpiY), Fixed);
l = Length(primitiveValue->computeLength(style, m_rootStyle, logicalDpiY), Fixed);
else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
l = Length(primitiveValue->floatValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent);
else
......@@ -3419,7 +3421,7 @@ void CSSStyleSelector::applyRule( int id, DOM::CSSValueImpl *value )
int type = primitiveValue->primitiveType();
Length l;
if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
l = Length(primitiveValue->computeLength(style, logicalDpiY), Fixed );
l = Length(primitiveValue->computeLength(style, m_rootStyle, logicalDpiY), Fixed);
else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
l = Length( primitiveValue->floatValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent );
......@@ -3433,6 +3435,8 @@ void CSSStyleSelector::applyRule( int id, DOM::CSSValueImpl *value )
FontDef fontDef = style->htmlFont().fontDef;
int size = 0;
const bool isRootElement = element && (element->document()->documentElement() == element);
if (isInherit )
size = parentStyle->font().pixelSize();
else if (isInitial)
......@@ -3473,14 +3477,14 @@ void CSSStyleSelector::applyRule( int id, DOM::CSSValueImpl *value )
}
} else {
int type = primitiveValue->primitiveType();
const int type = primitiveValue->primitiveType();
if (type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG) {
// Scale for the font zoom factor only for types other than "em", "ex", "ch", since those are
// already based on the font size.
if (!khtml::printpainter && !(type >= CSSPrimitiveValue::CSS_EMS && type <= CSSPrimitiveValue::CSS_CHS) && view && view->part()) {
size = qRound(primitiveValue->computeLengthFloat(parentStyle, logicalDpiY) * view->part()->fontScaleFactor() / 100.0);
// Scale for the font zoom factor only for types other than "em", "ex", "ch", "rem",
// since those are already based on the font size.
if (!khtml::printpainter && !(type >= CSSPrimitiveValue::CSS_EMS && type <= CSSPrimitiveValue::CSS_REMS) && view && view->part()) {
size = qRound(primitiveValue->computeLengthFloat(parentStyle, m_rootStyle, logicalDpiY) * view->part()->fontScaleFactor() / 100.0);
} else {
size = qRound(primitiveValue->computeLengthFloat(parentStyle, logicalDpiY));
size = qRound(primitiveValue->computeLengthFloat(parentStyle, isRootElement ? m_rootDefaultStyle : m_rootStyle, logicalDpiY));
}
} else if (type == CSSPrimitiveValue::CSS_PERCENTAGE) {
size = qRound(primitiveValue->floatValue(CSSPrimitiveValue::CSS_PERCENTAGE) * parentStyle->font().pixelSize() / 100.0);
......@@ -3499,6 +3503,14 @@ void CSSStyleSelector::applyRule( int id, DOM::CSSValueImpl *value )
fontDef.size = size;
fontDirty |= style->setFontDef( fontDef );
if (isRootElement) {
// We changed font size of root element, update now our root style reference
// so that root css properties based on 'rem' unit are correctly computed
// TESTCASE: html { font-size: 30px; width: 10rem; border: solid; }
m_rootStyle = style;
}
return;
}
......@@ -3558,16 +3570,16 @@ void CSSStyleSelector::applyRule( int id, DOM::CSSValueImpl *value )
HANDLE_INITIAL_AND_INHERIT_ON_INHERITED_PROPERTY(lineHeight, LineHeight)
if(!primitiveValue) return;
Length lineHeight;
int type = primitiveValue->primitiveType();
const int type = primitiveValue->primitiveType();
if (primitiveValue->getIdent() == CSS_VAL_NORMAL)
lineHeight = Length( -100.0, Percent );
else if (type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG) {
// Scale for the font zoom factor only for types other than "em", "ex", "ch", since those are
// already based on the font size.
if (!khtml::printpainter && !(type >= CSSPrimitiveValue::CSS_EMS && type <= CSSPrimitiveValue::CSS_CHS) && view && view->part()) {
lineHeight = Length(primitiveValue->computeLength(style, logicalDpiY) * view->part()->fontScaleFactor() / 100, Fixed);
// Scale for the font zoom factor only for types other than "em", "ex", "ch", "rem",
// since those are already based on the font size.
if (!khtml::printpainter && !(type >= CSSPrimitiveValue::CSS_EMS && type <= CSSPrimitiveValue::CSS_REMS) && view && view->part()) {
lineHeight = Length(primitiveValue->computeLength(style, m_rootStyle, logicalDpiY) * view->part()->fontScaleFactor() / 100, Fixed);
} else {
lineHeight = Length(primitiveValue->computeLength(style, logicalDpiY), Fixed);
lineHeight = Length(primitiveValue->computeLength(style, m_rootStyle, logicalDpiY), Fixed);
}
} else if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
lineHeight = Length( ( style->font().pixelSize() * int(primitiveValue->floatValue(CSSPrimitiveValue::CSS_PERCENTAGE)) ) / 100, Fixed );
......@@ -3611,16 +3623,16 @@ void CSSStyleSelector::applyRule( int id, DOM::CSSValueImpl *value )
hasClip = true;
// As a convention, we pass in auto as Length(Auto). See RenderBox::clipRect
top = rect->top()->getIdent() == CSS_VAL_AUTO ? Length(Auto)
: convertToLength( rect->top(), style, logicalDpiY );
: convertToLength(rect->top(), style, m_rootStyle, logicalDpiY);
right = rect->right()->getIdent() == CSS_VAL_AUTO ? Length(Auto)
: convertToLength( rect->right(), style, logicalDpiY );
: convertToLength(rect->right(), style, m_rootStyle, logicalDpiY);
bottom = rect->bottom()->getIdent() == CSS_VAL_AUTO ? Length(Auto)
: convertToLength( rect->bottom(), style, logicalDpiY );
: convertToLength(rect->bottom(), style, m_rootStyle, logicalDpiY);
left = rect->left()->getIdent() == CSS_VAL_AUTO ? Length(Auto)
: convertToLength( rect->left(), style, logicalDpiY );
: convertToLength(rect->left(), style, m_rootStyle, logicalDpiY);
}
}
......@@ -4103,7 +4115,7 @@ void CSSStyleSelector::applyRule( int id, DOM::CSSValueImpl *value )
case CSS_PROP_OUTLINE_OFFSET: {
HANDLE_INITIAL_AND_INHERIT_ON_NONINHERITED_PROPERTY(outlineOffset, OutlineOffset)
int offset = primitiveValue->computeLength(style, logicalDpiY);
int offset = primitiveValue->computeLength(style, m_rootStyle, logicalDpiY);
if (offset < 0) return;
style->setOutlineOffset(offset);
......@@ -4130,9 +4142,9 @@ void CSSStyleSelector::applyRule( int id, DOM::CSSValueImpl *value )
for (int i = 0; i < len; i++) {
ShadowValueImpl *item = static_cast<ShadowValueImpl*>(list->item(i));
int x = item->x->computeLength(style, logicalDpiY);
int y = item->y->computeLength(style, logicalDpiY);
int blur = item->blur ? item->blur->computeLength(style, logicalDpiY) : 0;
int x = item->x->computeLength(style, m_rootStyle, logicalDpiY);
int y = item->y->computeLength(style, m_rootStyle, logicalDpiY);
int blur = item->blur ? item->blur->computeLength(style, m_rootStyle, logicalDpiY) : 0;
QColor col = khtml::transparentColor;
if (item->color) {
int ident = item->color->getIdent();
......@@ -4216,7 +4228,7 @@ void CSSStyleSelector::applyRule( int id, DOM::CSSValueImpl *value )
}
else {
bool ok = true;
Length l = convertToLength(primitiveValue, style, logicalDpiY, &ok);
Length l = convertToLength(primitiveValue, style, m_rootStyle, logicalDpiY, &ok);
if (ok)
style->setMarqueeIncrement(l);
}
......@@ -4447,10 +4459,10 @@ void CSSStyleSelector::mapBackgroundSize(BackgroundLayer* layer, CSSValueImpl* v
if (first->getIdent() == CSS_VAL_AUTO) {
firstLength = Length(Auto);
} else {
const unsigned short firstType = first->primitiveType();
if (firstType > CSSPrimitiveValue::CSS_PERCENTAGE && firstType < CSSPrimitiveValue::CSS_DEG) {
firstLength = Length(first->computeLength(style, logicalDpiY), Fixed);
} else if (firstType == CSSPrimitiveValue::CSS_PERCENTAGE) {
const int type = first->primitiveType();
if (type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG) {
firstLength = Length(first->computeLength(style, m_rootStyle, logicalDpiY), Fixed);
} else if (type == CSSPrimitiveValue::CSS_PERCENTAGE) {
firstLength = Length(first->floatValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent);
} else {
return;
......@@ -4460,10 +4472,10 @@ void CSSStyleSelector::mapBackgroundSize(BackgroundLayer* layer, CSSValueImpl* v
if (second->getIdent() == CSS_VAL_AUTO) {
secondLength = Length(Auto);
} else {
const unsigned short secondType = second->primitiveType();
if (secondType > CSSPrimitiveValue::CSS_PERCENTAGE && secondType < CSSPrimitiveValue::CSS_DEG) {
secondLength = Length(second->computeLength(style, logicalDpiY), Fixed);
} else if (secondType == CSSPrimitiveValue::CSS_PERCENTAGE) {
const int type = second->primitiveType();
if (type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG) {
secondLength = Length(second->computeLength(style, m_rootStyle, logicalDpiY), Fixed);
} else if (type == CSSPrimitiveValue::CSS_PERCENTAGE) {
secondLength = Length(second->floatValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent);
} else {
return;
......@@ -4487,7 +4499,7 @@ void CSSStyleSelector::mapBackgroundXPosition(BackgroundLayer* layer, DOM::CSSVa
Length l;
int type = primitiveValue->primitiveType();
if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
l = Length(primitiveValue->computeLength(style, logicalDpiY), Fixed);
l = Length(primitiveValue->computeLength(style, m_rootStyle, logicalDpiY), Fixed);
else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
l = Length(primitiveValue->floatValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent);
else
......@@ -4507,7 +4519,7 @@ void CSSStyleSelector::mapBackgroundYPosition(BackgroundLayer* layer, DOM::CSSVa
Length l;
int type = primitiveValue->primitiveType();
if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
l = Length(primitiveValue->computeLength(style, logicalDpiY), Fixed);
l = Length(primitiveValue->computeLength(style, m_rootStyle, logicalDpiY), Fixed);
else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
l = Length(primitiveValue->floatValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent);
else
......
......@@ -321,6 +321,7 @@ public:
RenderStyle *style;
RenderStyle *parentStyle;
RenderStyle *m_rootStyle; // needed to compute 'rem' lengths
DOM::ElementImpl *element;
DOM::NodeImpl *parentNode;
KHTMLView *view;
......
This diff is collapsed.
......@@ -69,29 +69,30 @@
EMS = 287,
EXS = 288,
CHS = 289,
PXS = 290,
CMS = 291,
MMS = 292,
INS = 293,
PTS = 294,
PCS = 295,
DEGS = 296,
RADS = 297,
GRADS = 298,
MSECS = 299,
SECS = 300,
HERZ = 301,
KHERZ = 302,
DPI = 303,
DPCM = 304,
DIMEN = 305,
PERCENTAGE = 306,
FLOAT = 307,
INTEGER = 308,
URI = 309,
FUNCTION = 310,
NOTFUNCTION = 311,
UNICODERANGE = 312
REMS = 290,
PXS = 291,
CMS = 292,
MMS = 293,
INS = 294,
PTS = 295,
PCS = 296,
DEGS = 297,
RADS = 298,
GRADS = 299,
MSECS = 300,
SECS = 301,
HERZ = 302,
KHERZ = 303,
DPI = 304,
DPCM = 305,
DIMEN = 306,
PERCENTAGE = 307,
FLOAT = 308,
INTEGER = 309,
URI = 310,
FUNCTION = 311,
NOTFUNCTION = 312,
UNICODERANGE = 313
};
#endif
......
......@@ -108,7 +108,7 @@ int DOM::getValueID(const char *tagStr, int len)
#define YYLTYPE_IS_TRIVIAL 1
%}
%expect 40
%expect 41
%pure_parser
......@@ -215,6 +215,7 @@ static int cssyylex( YYSTYPE *yylval ) {
%token <val> EMS
%token <val> EXS
%token <val> CHS
%token <val> REMS
%token <val> PXS
%token <val> CMS
%token <val> MMS
......@@ -1233,6 +1234,7 @@ unary_term:
| QEMS maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = Value::Q_EMS; }
| EXS maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_EXS; }
| CHS maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_CHS; }
| REMS maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_REMS; }
| DPI maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_DPI; }
| DPCM maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_DPCM; }
;
......
This diff is collapsed.
......@@ -68,6 +68,7 @@ nth ([\+-]?[0-9]*n[ \t\r\n\f]*[\+-][ \t\r\n\f]*[0-9]+)|([\+-]?[0-9]*
{num}__qem {yyTok = QEMS; return yyTok;} /* quirky ems */
{num}ex {yyTok = EXS; return yyTok;}
{num}ch {yyTok = CHS; return yyTok;}
{num}rem {yyTok = REMS; return yyTok;}
{num}px {yyTok = PXS; return yyTok;}
{num}cm {yyTok = CMS; return yyTok;}
{num}mm {yyTok = MMS; return yyTok;}
......
......@@ -393,29 +393,30 @@ public:
CSS_EMS = 3,
CSS_EXS = 4,
CSS_CHS = 5,
CSS_PX = 6,
CSS_CM = 7,
CSS_MM = 8,
CSS_IN = 9,
CSS_PT = 10,
CSS_PC = 11,
CSS_DEG = 12,
CSS_RAD = 13,
CSS_GRAD = 14,
CSS_MS = 15,
CSS_S = 16,
CSS_HZ = 17,
CSS_KHZ = 18,
CSS_DIMENSION = 19,
CSS_STRING = 20,
CSS_URI = 21,
CSS_IDENT = 22,
CSS_ATTR = 23,
CSS_COUNTER = 24,
CSS_RECT = 25,
CSS_RGBCOLOR = 26,
CSS_DPI = 27,
CSS_DPCM = 28,
CSS_REMS = 6,
CSS_PX = 7,
CSS_CM = 8,
CSS_MM = 9,
CSS_IN = 10,
CSS_PT = 11,
CSS_PC = 12,
CSS_DEG = 13,
CSS_RAD = 14,
CSS_GRAD = 15,
CSS_MS = 16,
CSS_S = 17,
CSS_HZ = 18,
CSS_KHZ = 19,
CSS_DIMENSION = 20,
CSS_STRING = 21,
CSS_URI = 22,
CSS_IDENT = 23,
CSS_ATTR = 24,
CSS_COUNTER = 25,
CSS_RECT = 26,
CSS_RGBCOLOR = 27,
CSS_DPI = 28,
CSS_DPCM = 29,
CSS_PAIR = 100, // We envision this being exposed as a means of getting computed style values for pairs
CSS_HTML_RELATIVE = 255
};
......
......@@ -1206,13 +1206,14 @@ JSValue *DOMCSSPrimitiveValueProtoFunc::callAsFunction(ExecState *exec, JSObject
const ClassInfo CSSPrimitiveValueConstructor::info = { "CSSPrimitiveValueConstructor", 0, &CSSPrimitiveValueConstructorTable, 0 };
/*
@begin CSSPrimitiveValueConstructorTable 27
@begin CSSPrimitiveValueConstructorTable 28
CSS_UNKNOWN DOM::CSSPrimitiveValue::CSS_UNKNOWN DontDelete|ReadOnly
CSS_NUMBER DOM::CSSPrimitiveValue::CSS_NUMBER DontDelete|ReadOnly
CSS_PERCENTAGE DOM::CSSPrimitiveValue::CSS_PERCENTAGE DontDelete|ReadOnly
CSS_EMS DOM::CSSPrimitiveValue::CSS_EMS DontDelete|ReadOnly
CSS_EXS DOM::CSSPrimitiveValue::CSS_EXS DontDelete|ReadOnly
CSS_CHS DOM::CSSPrimitiveValue::CSS_CHS DontDelete|ReadOnly
CSS_REMS DOM::CSSPrimitiveValue::CSS_REMS DontDelete|ReadOnly
CSS_PX DOM::CSSPrimitiveValue::CSS_PX DontDelete|ReadOnly
CSS_CM DOM::CSSPrimitiveValue::CSS_CM DontDelete|ReadOnly
CSS_MM DOM::CSSPrimitiveValue::CSS_MM DontDelete|ReadOnly
......
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