Fixing shorthand properties in CSS
David Hyatt
hyatt at apple.com
Wed Nov 12 11:07:40 CET 2003
This was a two-stage patch. First I macro-ized 'inherit', and then I
added support for the CSS3 'initial' value. Handling the parsing of
all shorthands is then as simple as filling in the unspecified values
with 'initial'.
dave
-------------- next part --------------
Index: khtml/css/cssparser.cpp
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/css/cssparser.cpp,v
retrieving revision 1.50
diff -u -p -r1.50 khtml/css/cssparser.cpp
--- khtml/css/cssparser.cpp 2003/11/03 22:43:22 1.50
+++ khtml/css/cssparser.cpp 2003/11/10 21:21:40
@@ -796,13 +796,6 @@ bool CSSParser::parseValue( int propId,
valid_primitive = ( validUnit( value, FLength, strict&(!nonCSSHint) ) );
break;
- case CSS_PROP_MARKER_OFFSET: // <length> | auto | inherit
- if ( id == CSS_VAL_AUTO )
- valid_primitive = true;
- else
- valid_primitive = validUnit( value, FLength, strict&(!nonCSSHint) );
- break;
-
case CSS_PROP_LETTER_SPACING: // normal | <length> | inherit
case CSS_PROP_WORD_SPACING: // normal | <length> | inherit
if ( id == CSS_VAL_NORMAL )
Index: khtml/css/cssproperties.in
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/css/cssproperties.in,v
retrieving revision 1.11
diff -u -p -r1.11 khtml/css/cssproperties.in
--- khtml/css/cssproperties.in 2003/11/03 05:53:27 1.11
+++ khtml/css/cssproperties.in 2003/11/10 21:21:40
@@ -9,8 +9,6 @@
# Mircosoft extensions are documented here:
# http://msdn.microsoft.com/workshop/author/css/reference/attributes.asp
#
-#azimuth
-#
# CSS_PROP_BACKGROUND_COLOR:
#
background-color
@@ -54,12 +52,9 @@ color
content
counter-increment
counter-reset
-#cue-after
-#cue-before
cursor
direction
display
-#elevation
empty-cells
float
font-family
@@ -80,7 +75,6 @@ margin-top
margin-right
margin-bottom
margin-left
-marker-offset
-khtml-marquee
-khtml-marquee-direction
-khtml-marquee-increment
@@ -106,22 +100,10 @@ page
page-break-after
page-break-before
page-break-inside
-#pause-after
-#pause-before
-#pitch
-#pitch-range
-#play-during
position
quotes
-#richness
right
size
-#speak
-#speak-header
-#speak-numeral
-#speak-punctuation
-#speech-rate
-#stress
table-layout
text-align
text-decoration
@@ -133,8 +115,6 @@ top
unicode-bidi
vertical-align
visibility
-#voice-family
-#volume
white-space
widows
width
@@ -149,13 +129,11 @@ border-right
border-bottom
border-left
border-width
-#cue
font
list-style
margin
outline
padding
-#pause
scrollbar-face-color
scrollbar-shadow-color
scrollbar-highlight-color
Index: khtml/css/cssstyleselector.cpp
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/css/cssstyleselector.cpp,v
retrieving revision 1.110
diff -u -p -r1.110 khtml/css/cssstyleselector.cpp
--- khtml/css/cssstyleselector.cpp 2003/11/03 18:35:52 1.110
+++ khtml/css/cssstyleselector.cpp 2003/11/10 21:21:40
@@ -67,6 +67,22 @@ using namespace DOM;
#include <qintcache.h>
#include <stdlib.h>
+#define HANDLE_INHERIT(prop, Prop) \
+if (value->cssValueType() == CSSValue::CSS_INHERIT) \
+{\
+ if (!parentNode) return;\
+ style->set##Prop(parentStyle->prop());\
+ return;\
+}
+
+#define HANDLE_INHERIT_COND(propID, prop, Prop) \
+if (id == propID) \
+{\
+ if (!parentNode) return;\
+ style->set##Prop(parentStyle->prop());\
+ return;\
+}
+
namespace khtml {
CSSStyleSelectorList *CSSStyleSelector::defaultStyle = 0;
@@ -1612,12 +1628,7 @@ void CSSStyleSelector::applyRule( int id
{
// ident only properties
case CSS_PROP_BACKGROUND_ATTACHMENT:
- if(value->cssValueType() == CSSValue::CSS_INHERIT)
- {
- if( !parentNode ) return;
- style->setBackgroundAttachment(parentStyle->backgroundAttachment());
- return;
- }
+ HANDLE_INHERIT(backgroundAttachment, BackgroundAttachment)
if(!primitiveValue) break;
switch(primitiveValue->getIdent())
{
@@ -1637,11 +1648,7 @@ void CSSStyleSelector::applyRule( int id
}
case CSS_PROP_BACKGROUND_REPEAT:
{
- if(value->cssValueType() == CSSValue::CSS_INHERIT) {
- if(!parentNode) return;
- style->setBackgroundRepeat(parentStyle->backgroundRepeat());
- return;
- }
+ HANDLE_INHERIT(backgroundRepeat, BackgroundRepeat)
if(!primitiveValue) return;
switch(primitiveValue->getIdent())
{
@@ -1662,84 +1669,49 @@ void CSSStyleSelector::applyRule( int id
}
}
case CSS_PROP_BORDER_COLLAPSE:
- if(value->cssValueType() == CSSValue::CSS_INHERIT)
- {
- if(!parentNode) return;
- style->setBorderCollapse(parentStyle->borderCollapse());
- break;
- }
+ HANDLE_INHERIT(borderCollapse, BorderCollapse)
if(!primitiveValue) break;
switch(primitiveValue->getIdent())
{
case CSS_VAL_COLLAPSE:
style->setBorderCollapse(true);
break;
- case CSS_VAL_SCROLL:
+ case CSS_VAL_SEPARATE:
style->setBorderCollapse(false);
break;
default:
return;
}
-
+ break;
+
case CSS_PROP_BORDER_TOP_STYLE:
+ HANDLE_INHERIT(borderTopStyle, BorderTopStyle)
+ if (!primitiveValue) return;
+ style->setBorderTopStyle((EBorderStyle)(primitiveValue->getIdent() - CSS_VAL_NONE));
+ break;
case CSS_PROP_BORDER_RIGHT_STYLE:
+ HANDLE_INHERIT(borderRightStyle, BorderRightStyle)
+ if (!primitiveValue) return;
+ style->setBorderRightStyle((EBorderStyle)(primitiveValue->getIdent() - CSS_VAL_NONE));
+ break;
case CSS_PROP_BORDER_BOTTOM_STYLE:
+ HANDLE_INHERIT(borderBottomStyle, BorderBottomStyle)
+ if (!primitiveValue) return;
+ style->setBorderBottomStyle((EBorderStyle)(primitiveValue->getIdent() - CSS_VAL_NONE));
+ break;
case CSS_PROP_BORDER_LEFT_STYLE:
+ HANDLE_INHERIT(borderLeftStyle, BorderLeftStyle)
+ if (!primitiveValue) return;
+ style->setBorderLeftStyle((EBorderStyle)(primitiveValue->getIdent() - CSS_VAL_NONE));
+ break;
case CSS_PROP_OUTLINE_STYLE:
- {
- EBorderStyle s;
- if(value->cssValueType() == CSSValue::CSS_INHERIT)
- {
- if(!parentNode) return;
- switch(id)
- {
- case CSS_PROP_BORDER_TOP_STYLE:
- s = parentStyle->borderTopStyle();
- break;
- case CSS_PROP_BORDER_RIGHT_STYLE:
- s = parentStyle->borderRightStyle();
- break;
- case CSS_PROP_BORDER_BOTTOM_STYLE:
- s = parentStyle->borderBottomStyle();
- break;
- case CSS_PROP_BORDER_LEFT_STYLE:
- s = parentStyle->borderLeftStyle();
- break;
- case CSS_PROP_OUTLINE_STYLE:
- s = parentStyle->outlineStyle();
- break;
- default:
- return;
- }
- } else {
- if(!primitiveValue) return;
- s = (EBorderStyle) (primitiveValue->getIdent() - CSS_VAL_NONE);
- }
- switch(id)
- {
- case CSS_PROP_BORDER_TOP_STYLE:
- style->setBorderTopStyle(s); return;
- case CSS_PROP_BORDER_RIGHT_STYLE:
- style->setBorderRightStyle(s); return;
- case CSS_PROP_BORDER_BOTTOM_STYLE:
- style->setBorderBottomStyle(s); return;
- case CSS_PROP_BORDER_LEFT_STYLE:
- style->setBorderLeftStyle(s); return;
- case CSS_PROP_OUTLINE_STYLE:
- style->setOutlineStyle(s); return;
- default:
- return;
- }
- return;
- }
+ HANDLE_INHERIT(outlineStyle, OutlineStyle)
+ if (!primitiveValue) return;
+ style->setOutlineStyle((EBorderStyle)(primitiveValue->getIdent() - CSS_VAL_NONE));
+ break;
case CSS_PROP_CAPTION_SIDE:
{
- if(value->cssValueType() == CSSValue::CSS_INHERIT)
- {
- if(!parentNode) return;
- style->setCaptionSide(parentStyle->captionSide());
- break;
- }
+ HANDLE_INHERIT(captionSide, CaptionSide)
if(!primitiveValue) break;
ECaptionSide c = CAPTOP;
switch(primitiveValue->getIdent())
@@ -1760,12 +1732,7 @@ void CSSStyleSelector::applyRule( int id
}
case CSS_PROP_CLEAR:
{
- if(value->cssValueType() == CSSValue::CSS_INHERIT)
- {
- if(!parentNode) return;
- style->setClear(parentStyle->clear());
- break;
- }
+ HANDLE_INHERIT(clear, Clear)
if(!primitiveValue) break;
EClear c = CNONE;
switch(primitiveValue->getIdent())
@@ -1784,24 +1751,14 @@ void CSSStyleSelector::applyRule( int id
}
case CSS_PROP_DIRECTION:
{
- if(value->cssValueType() == CSSValue::CSS_INHERIT)
- {
- if(!parentNode) return;
- style->setDirection(parentStyle->direction());
- break;
- }
+ HANDLE_INHERIT(direction, Direction)
if(!primitiveValue) break;
style->setDirection( (EDirection) (primitiveValue->getIdent() - CSS_VAL_LTR) );
return;
}
case CSS_PROP_DISPLAY:
{
- if(value->cssValueType() == CSSValue::CSS_INHERIT)
- {
- if(!parentNode) return;
- style->setDisplay(parentStyle->display());
- break;
- }
+ HANDLE_INHERIT(display, Display)
if(!primitiveValue) break;
int id = primitiveValue->getIdent();
EDisplay d;
@@ -1818,12 +1775,7 @@ void CSSStyleSelector::applyRule( int id
case CSS_PROP_EMPTY_CELLS:
{
- if (value->cssValueType() == CSSValue::CSS_INHERIT)
- {
- if(!parentNode) return;
- style->setEmptyCells(parentStyle->emptyCells());
- break;
- }
+ HANDLE_INHERIT(emptyCells, EmptyCells)
if (!primitiveValue) break;
int id = primitiveValue->getIdent();
if (id == CSS_VAL_SHOW)
@@ -1834,12 +1786,7 @@ void CSSStyleSelector::applyRule( int id
}
case CSS_PROP_FLOAT:
{
- if(value->cssValueType() == CSSValue::CSS_INHERIT)
- {
- if(!parentNode) return;
- style->setFloating(parentStyle->floating());
- return;
- }
+ HANDLE_INHERIT(floating, Floating)
if(!primitiveValue) return;
EFloat f;
switch(primitiveValue->getIdent())
@@ -1861,7 +1808,7 @@ void CSSStyleSelector::applyRule( int id
break;
case CSS_PROP_FONT_STRETCH:
- break;
+ break; /* Not supported. */
case CSS_PROP_FONT_STYLE:
{
@@ -1957,28 +1904,18 @@ void CSSStyleSelector::applyRule( int id
case CSS_PROP_LIST_STYLE_POSITION:
{
- if(value->cssValueType() == CSSValue::CSS_INHERIT)
- {
- if(!parentNode) return;
- style->setListStylePosition(parentStyle->listStylePosition());
- return;
- }
- if(!primitiveValue) return;
- if(primitiveValue->getIdent())
+ HANDLE_INHERIT(listStylePosition, ListStylePosition)
+ if (!primitiveValue) return;
+ if (primitiveValue->getIdent())
style->setListStylePosition( (EListStylePosition) (primitiveValue->getIdent() - CSS_VAL_OUTSIDE) );
return;
}
case CSS_PROP_LIST_STYLE_TYPE:
{
- if(value->cssValueType() == CSSValue::CSS_INHERIT)
- {
- if(!parentNode) return;
- style->setListStyleType(parentStyle->listStyleType());
- return;
- }
- if(!primitiveValue) return;
- if(primitiveValue->getIdent())
+ HANDLE_INHERIT(listStyleType, ListStyleType)
+ if (!primitiveValue) return;
+ if (primitiveValue->getIdent())
{
EListStyleType t;
int id = primitiveValue->getIdent();
@@ -1994,13 +1931,8 @@ void CSSStyleSelector::applyRule( int id
case CSS_PROP_OVERFLOW:
{
- if(value->cssValueType() == CSSValue::CSS_INHERIT)
- {
- if(!parentNode) return;
- style->setOverflow(parentStyle->overflow());
- return;
- }
- if(!primitiveValue) return;
+ HANDLE_INHERIT(overflow, Overflow)
+ if (!primitiveValue) return;
EOverflow o;
switch(primitiveValue->getIdent())
{
@@ -2023,13 +1955,8 @@ void CSSStyleSelector::applyRule( int id
case CSS_PROP_PAGE_BREAK_BEFORE:
{
- if(value->cssValueType() == CSSValue::CSS_INHERIT)
- {
- if(!parentNode) return;
- style->setPageBreakBefore(parentStyle->pageBreakBefore());
- return;
- }
- if(!primitiveValue) return;
+ HANDLE_INHERIT(pageBreakBefore, PageBreakBefore)
+ if (!primitiveValue) return;
switch (primitiveValue->getIdent()) {
case CSS_VAL_AUTO:
style->setPageBreakBefore(PBAUTO);
@@ -2040,7 +1967,7 @@ void CSSStyleSelector::applyRule( int id
style->setPageBreakBefore(PBALWAYS); // CSS2.1: "Conforming user agents may map left/right to always."
break;
case CSS_VAL_AVOID:
- style->setPageBreakInside(PBAVOID);
+ style->setPageBreakBefore(PBAVOID);
break;
}
break;
@@ -2048,13 +1975,8 @@ void CSSStyleSelector::applyRule( int id
case CSS_PROP_PAGE_BREAK_AFTER:
{
- if(value->cssValueType() == CSSValue::CSS_INHERIT)
- {
- if(!parentNode) return;
- style->setPageBreakAfter(parentStyle->pageBreakAfter());
- return;
- }
- if(!primitiveValue) return;
+ HANDLE_INHERIT(pageBreakAfter, PageBreakAfter)
+ if (!primitiveValue) return;
switch (primitiveValue->getIdent()) {
case CSS_VAL_AUTO:
style->setPageBreakAfter(PBAUTO);
@@ -2072,13 +1994,8 @@ void CSSStyleSelector::applyRule( int id
}
case CSS_PROP_PAGE_BREAK_INSIDE: {
- if(value->cssValueType() == CSSValue::CSS_INHERIT)
- {
- if(!parentNode) return;
- style->setPageBreakInside(parentStyle->pageBreakInside());
- return;
- }
- if(!primitiveValue) return;
+ HANDLE_INHERIT(pageBreakInside, PageBreakInside)
+ if (!primitiveValue) return;
if (primitiveValue->getIdent() == CSS_VAL_AUTO)
style->setPageBreakInside(PBAUTO);
else if (primitiveValue->getIdent() == CSS_VAL_AVOID)
@@ -2087,19 +2004,11 @@ void CSSStyleSelector::applyRule( int id
}
case CSS_PROP_PAGE:
+ break; /* FIXME: Not even sure what this is... -dwh */
-// case CSS_PROP_PAUSE_AFTER:
-// case CSS_PROP_PAUSE_BEFORE:
- break;
-
case CSS_PROP_POSITION:
{
- if(value->cssValueType() == CSSValue::CSS_INHERIT)
- {
- if(!parentNode) return;
- style->setPosition(parentStyle->position());
- return;
- }
+ HANDLE_INHERIT(position, Position)
if(!primitiveValue) return;
EPosition p;
switch(primitiveValue->getIdent())
@@ -2123,16 +2032,8 @@ void CSSStyleSelector::applyRule( int id
return;
}
-// case CSS_PROP_SPEAK:
-// case CSS_PROP_SPEAK_HEADER:
-// case CSS_PROP_SPEAK_NUMERAL:
-// case CSS_PROP_SPEAK_PUNCTUATION:
- case CSS_PROP_TABLE_LAYOUT: {
- if(value->cssValueType() == CSSValue::CSS_INHERIT) {
- if(!parentNode) return;
- style->setTableLayout(parentStyle->tableLayout());
- return;
- }
+ case CSS_PROP_TABLE_LAYOUT: {
+ HANDLE_INHERIT(tableLayout, TableLayout)
if ( !primitiveValue->getIdent() )
return;
@@ -2151,33 +2052,25 @@ void CSSStyleSelector::applyRule( int id
}
case CSS_PROP_UNICODE_BIDI: {
- EUnicodeBidi b = UBNormal;
- if(value->cssValueType() == CSSValue::CSS_INHERIT) {
- if(!parentNode) return;
- b = parentStyle->unicodeBidi();
- } else {
- switch( primitiveValue->getIdent() ) {
- case CSS_VAL_NORMAL:
- b = UBNormal; break;
- case CSS_VAL_EMBED:
- b = Embed; break;
- case CSS_VAL_BIDI_OVERRIDE:
- b = Override; break;
- default:
- return;
- }
- }
- style->setUnicodeBidi( b );
- break;
- }
- case CSS_PROP_TEXT_TRANSFORM:
- {
- if(value->cssValueType() == CSSValue::CSS_INHERIT) {
- if(!parentNode) return;
- style->setTextTransform(parentStyle->textTransform());
- return;
+ HANDLE_INHERIT(unicodeBidi, UnicodeBidi)
+ switch (primitiveValue->getIdent()) {
+ case CSS_VAL_NORMAL:
+ style->setUnicodeBidi(UBNormal);
+ break;
+ case CSS_VAL_EMBED:
+ style->setUnicodeBidi(Embed);
+ break;
+ case CSS_VAL_BIDI_OVERRIDE:
+ style->setUnicodeBidi(Override);
+ break;
+ default:
+ return;
}
-
+ break;
+ }
+ case CSS_PROP_TEXT_TRANSFORM: {
+ HANDLE_INHERIT(textTransform, TextTransform)
+
if(!primitiveValue->getIdent()) return;
ETextTransform tt;
@@ -2194,11 +2087,7 @@ void CSSStyleSelector::applyRule( int id
case CSS_PROP_VISIBILITY:
{
- if(value->cssValueType() == CSSValue::CSS_INHERIT) {
- if(!parentNode) return;
- style->setVisibility(parentStyle->visibility());
- return;
- }
+ HANDLE_INHERIT(visibility, Visibility)
switch( primitiveValue->getIdent() ) {
case CSS_VAL_HIDDEN:
@@ -2215,11 +2104,7 @@ void CSSStyleSelector::applyRule( int id
break;
}
case CSS_PROP_WHITE_SPACE:
- if(value->cssValueType() == CSSValue::CSS_INHERIT) {
- if(!parentNode) return;
- style->setWhiteSpace(parentStyle->whiteSpace());
- return;
- }
+ HANDLE_INHERIT(whiteSpace, WhiteSpace)
if(!primitiveValue->getIdent()) return;
@@ -2242,41 +2127,39 @@ void CSSStyleSelector::applyRule( int id
style->setWhiteSpace(s);
break;
-
-// special properties (css_extensions)
-// case CSS_PROP_AZIMUTH:
- // CSS2Azimuth
case CSS_PROP_BACKGROUND_POSITION:
- // CSS2BackgroundPosition
+ if(value->cssValueType() != CSSValue::CSS_INHERIT || !parentNode) return;
+ style->setBackgroundXPosition(parentStyle->backgroundXPosition());
+ style->setBackgroundYPosition(parentStyle->backgroundYPosition());
break;
- case CSS_PROP_BACKGROUND_POSITION_X:
- {
- if(!primitiveValue) break;
- Length l;
- int type = primitiveValue->primitiveType();
- if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
- l = Length(primitiveValue->computeLength(style, paintDeviceMetrics), Fixed);
- else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
- l = Length((int)primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent);
- else
- return;
- style->setBackgroundXPosition(l);
- break;
- }
- case CSS_PROP_BACKGROUND_POSITION_Y:
- {
- if(!primitiveValue) break;
- Length l;
- int type = primitiveValue->primitiveType();
- if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
- l = Length(primitiveValue->computeLength(style, paintDeviceMetrics), Fixed);
- else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
- l = Length((int)primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent);
- else
- return;
- style->setBackgroundYPosition(l);
- break;
- }
+ case CSS_PROP_BACKGROUND_POSITION_X: {
+ HANDLE_INHERIT(backgroundXPosition, BackgroundXPosition)
+ if(!primitiveValue) break;
+ Length l;
+ int type = primitiveValue->primitiveType();
+ if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
+ l = Length(primitiveValue->computeLength(style, paintDeviceMetrics), Fixed);
+ else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
+ l = Length((int)primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent);
+ else
+ return;
+ style->setBackgroundXPosition(l);
+ break;
+ }
+ case CSS_PROP_BACKGROUND_POSITION_Y: {
+ HANDLE_INHERIT(backgroundYPosition, BackgroundYPosition)
+ if(!primitiveValue) break;
+ Length l;
+ int type = primitiveValue->primitiveType();
+ if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
+ l = Length(primitiveValue->computeLength(style, paintDeviceMetrics), Fixed);
+ else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
+ l = Length((int)primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent);
+ else
+ return;
+ style->setBackgroundYPosition(l);
+ break;
+ }
case CSS_PROP_BORDER_SPACING: {
if(value->cssValueType() != CSSValue::CSS_INHERIT || !parentNode) return;
style->setHorizontalBorderSpacing(parentStyle->horizontalBorderSpacing());
@@ -2284,29 +2167,24 @@ void CSSStyleSelector::applyRule( int id
break;
}
case CSS_PROP__KHTML_BORDER_HORIZONTAL_SPACING: {
+ HANDLE_INHERIT(horizontalBorderSpacing, HorizontalBorderSpacing)
if (!primitiveValue) break;
short spacing = primitiveValue->computeLength(style, paintDeviceMetrics);
style->setHorizontalBorderSpacing(spacing);
break;
}
case CSS_PROP__KHTML_BORDER_VERTICAL_SPACING: {
+ HANDLE_INHERIT(verticalBorderSpacing, VerticalBorderSpacing)
if (!primitiveValue) break;
short spacing = primitiveValue->computeLength(style, paintDeviceMetrics);
style->setVerticalBorderSpacing(spacing);
break;
}
case CSS_PROP_CURSOR:
- // CSS2Cursor
- if(value->cssValueType() == CSSValue::CSS_INHERIT) {
- if(!parentNode) return;
- style->setCursor(parentStyle->cursor());
- return;
- } else if(primitiveValue) {
+ HANDLE_INHERIT(cursor, Cursor)
+ if (primitiveValue)
style->setCursor( (ECursor) (primitiveValue->getIdent() - CSS_VAL_AUTO) );
- }
break;
-// case CSS_PROP_PLAY_DURING:
- // CSS2PlayDuring
// colors || inherit
case CSS_PROP_BACKGROUND_COLOR:
case CSS_PROP_BORDER_TOP_COLOR:
@@ -2316,8 +2194,7 @@ void CSSStyleSelector::applyRule( int id
case CSS_PROP_COLOR:
case CSS_PROP_OUTLINE_COLOR:
// this property is an extension used to get HTML4 <font> right.
- case CSS_PROP_TEXT_DECORATION_COLOR:
- // ie scrollbar styling
+#if !APPLE_CHANGES
case CSS_PROP_SCROLLBAR_FACE_COLOR:
case CSS_PROP_SCROLLBAR_SHADOW_COLOR:
case CSS_PROP_SCROLLBAR_HIGHLIGHT_COLOR:
@@ -2325,35 +2202,20 @@ void CSSStyleSelector::applyRule( int id
case CSS_PROP_SCROLLBAR_DARKSHADOW_COLOR:
case CSS_PROP_SCROLLBAR_TRACK_COLOR:
case CSS_PROP_SCROLLBAR_ARROW_COLOR:
-
+#endif
{
QColor col;
- if(value->cssValueType() == CSSValue::CSS_INHERIT)
- {
- switch(id)
- {
- case CSS_PROP_BACKGROUND_COLOR:
- col = parentStyle->backgroundColor(); break;
- case CSS_PROP_BORDER_TOP_COLOR:
- col = parentStyle->borderTopColor();
- break;
- case CSS_PROP_BORDER_RIGHT_COLOR:
- col = parentStyle->borderRightColor();
- break;
- case CSS_PROP_BORDER_BOTTOM_COLOR:
- col = parentStyle->borderBottomColor();
- break;
- case CSS_PROP_BORDER_LEFT_COLOR:
- col = parentStyle->borderLeftColor();
- break;
- case CSS_PROP_COLOR:
- col = parentStyle->color(); break;
- case CSS_PROP_OUTLINE_COLOR:
- col = parentStyle->outlineColor(); break;
- default:
+ if (value->cssValueType() == CSSValue::CSS_INHERIT) {
+ HANDLE_INHERIT_COND(CSS_PROP_BACKGROUND_COLOR, backgroundColor, BackgroundColor)
+ HANDLE_INHERIT_COND(CSS_PROP_BORDER_TOP_COLOR, borderTopColor, BorderTopColor)
+ HANDLE_INHERIT_COND(CSS_PROP_BORDER_BOTTOM_COLOR, borderBottomColor, BorderBottomColor)
+ HANDLE_INHERIT_COND(CSS_PROP_BORDER_RIGHT_COLOR, borderRightColor, BorderRightColor)
+ HANDLE_INHERIT_COND(CSS_PROP_BORDER_LEFT_COLOR, borderLeftColor, BorderLeftColor)
+ HANDLE_INHERIT_COND(CSS_PROP_COLOR, color, Color)
+ HANDLE_INHERIT_COND(CSS_PROP_OUTLINE_COLOR, outlineColor, OutlineColor)
return;
}
- } else {
+ else {
if(!primitiveValue )
return;
int ident = primitiveValue->getIdent();
@@ -2385,6 +2247,7 @@ void CSSStyleSelector::applyRule( int id
style->setColor(col); break;
case CSS_PROP_OUTLINE_COLOR:
style->setOutlineColor(col); break;
+#if !APPLE_CHANGES
case CSS_PROP_SCROLLBAR_FACE_COLOR:
style->setPaletteColor(QPalette::Active, QColorGroup::Button, col);
style->setPaletteColor(QPalette::Inactive, QColorGroup::Button, col);
@@ -2415,6 +2278,7 @@ void CSSStyleSelector::applyRule( int id
style->setPaletteColor(QPalette::Active, QColorGroup::ButtonText, col);
style->setPaletteColor(QPalette::Inactive, QColorGroup::ButtonText, col);
break;
+#endif
default:
return;
}
@@ -2424,34 +2288,18 @@ void CSSStyleSelector::applyRule( int id
// uri || inherit
case CSS_PROP_BACKGROUND_IMAGE:
{
- khtml::CachedImage *image = 0;
- if(value->cssValueType() == CSSValue::CSS_INHERIT)
- {
- if(!parentNode) return;
- image = parentStyle->backgroundImage();
- } else {
- if(!primitiveValue) return;
- image = static_cast<CSSImageValueImpl *>(primitiveValue)->image();
- }
- style->setBackgroundImage(image);
+ HANDLE_INHERIT(backgroundImage, BackgroundImage)
+ if (!primitiveValue) return;
+ style->setBackgroundImage(static_cast<CSSImageValueImpl *>(primitiveValue)->image());
//kdDebug( 6080 ) << "setting image in style to " << image->image() << endl;
break;
}
-// case CSS_PROP_CUE_AFTER:
-// case CSS_PROP_CUE_BEFORE:
-// break;
case CSS_PROP_LIST_STYLE_IMAGE:
{
- khtml::CachedImage *image = 0;
- if(value->cssValueType() == CSSValue::CSS_INHERIT)
- {
- if(!parentNode) return;
- image = parentStyle->listStyleImage();
- } else {
- if(!primitiveValue) return;
- image = static_cast<CSSImageValueImpl *>(primitiveValue)->image();
- }
- style->setListStyleImage(image);
+ HANDLE_INHERIT(listStyleImage, ListStyleImage)
+ if (!primitiveValue) return;
+ if(!primitiveValue) return;
+ style->setListStyleImage(static_cast<CSSImageValueImpl *>(primitiveValue)->image());
//kdDebug( 6080 ) << "setting image in list to " << image->image() << endl;
break;
}
@@ -2463,27 +2311,17 @@ void CSSStyleSelector::applyRule( int id
case CSS_PROP_BORDER_LEFT_WIDTH:
case CSS_PROP_OUTLINE_WIDTH:
{
- short width = 3;
- if(value->cssValueType() == CSSValue::CSS_INHERIT)
- {
- switch(id)
- {
- case CSS_PROP_BORDER_TOP_WIDTH:
- width = parentStyle->borderTopWidth(); break;
- case CSS_PROP_BORDER_RIGHT_WIDTH:
- width = parentStyle->borderRightWidth(); break;
- case CSS_PROP_BORDER_BOTTOM_WIDTH:
- width = parentStyle->borderBottomWidth(); break;
- case CSS_PROP_BORDER_LEFT_WIDTH:
- width = parentStyle->borderLeftWidth(); break;
- case CSS_PROP_OUTLINE_WIDTH:
- width = parentStyle->outlineWidth(); break;
- default:
+ if (value->cssValueType() == CSSValue::CSS_INHERIT) {
+ HANDLE_INHERIT_COND(CSS_PROP_BORDER_TOP_WIDTH, borderTopWidth, BorderTopWidth)
+ HANDLE_INHERIT_COND(CSS_PROP_BORDER_RIGHT_WIDTH, borderRightWidth, BorderRightWidth)
+ HANDLE_INHERIT_COND(CSS_PROP_BORDER_BOTTOM_WIDTH, borderBottomWidth, BorderBottomWidth)
+ HANDLE_INHERIT_COND(CSS_PROP_BORDER_LEFT_WIDTH, borderLeftWidth, BorderLeftWidth)
+ HANDLE_INHERIT_COND(CSS_PROP_OUTLINE_WIDTH, outlineWidth, OutlineWidth)
return;
}
- return;
- } else {
+
if(!primitiveValue) break;
+ short width = 3;
switch(primitiveValue->getIdent())
{
case CSS_VAL_THIN:
@@ -2501,7 +2339,7 @@ void CSSStyleSelector::applyRule( int id
default:
return;
}
- }
+
if(width < 0) return;
switch(id)
{
@@ -2526,28 +2364,18 @@ void CSSStyleSelector::applyRule( int id
return;
}
- case CSS_PROP_MARKER_OFFSET:
case CSS_PROP_LETTER_SPACING:
case CSS_PROP_WORD_SPACING:
{
- int width = 0;
+
+ if (value->cssValueType() == CSSValue::CSS_INHERIT) {
+ HANDLE_INHERIT_COND(CSS_PROP_LETTER_SPACING, letterSpacing, LetterSpacing)
+ HANDLE_INHERIT_COND(CSS_PROP_WORD_SPACING, wordSpacing, WordSpacing)
+ return;
+ }
- if(value->cssValueType() == CSSValue::CSS_INHERIT)
- {
- if(!parentNode) return;
- switch(id)
- {
- case CSS_PROP_MARKER_OFFSET:
- // ###
- return;
- case CSS_PROP_LETTER_SPACING:
- width = parentStyle->letterSpacing(); break;
- case CSS_PROP_WORD_SPACING:
- width = parentStyle->wordSpacing(); break;
- default:
- return;
- }
- } else if(primitiveValue && primitiveValue->getIdent() == CSS_VAL_NORMAL){
+ int width = 0;
+ if (primitiveValue && primitiveValue->getIdent() == CSS_VAL_NORMAL){
width = 0;
} else {
if(!primitiveValue) return;
@@ -2562,7 +2390,6 @@ void CSSStyleSelector::applyRule( int id
style->setWordSpacing(width);
break;
// ### needs the definitions in renderstyle
- case CSS_PROP_MARKER_OFFSET:
default: break;
}
return;
@@ -2597,47 +2424,27 @@ void CSSStyleSelector::applyRule( int id
case CSS_PROP_TEXT_INDENT:
// +inherit
{
- if(value->cssValueType() == CSSValue::CSS_INHERIT) {
- if(!parentNode) return;
- apply = true;
- switch(id)
- {
- case CSS_PROP_MAX_WIDTH:
- l = parentStyle->maxWidth(); break;
- case CSS_PROP_BOTTOM:
- l = parentStyle->bottom(); break;
- case CSS_PROP_TOP:
- l = parentStyle->top(); break;
- case CSS_PROP_LEFT:
- l = parentStyle->left(); break;
- case CSS_PROP_RIGHT:
- l = parentStyle->right(); break;
- case CSS_PROP_WIDTH:
- l = parentStyle->width(); break;
- case CSS_PROP_MIN_WIDTH:
- l = parentStyle->minWidth(); break;
- case CSS_PROP_PADDING_TOP:
- l = parentStyle->paddingTop(); break;
- case CSS_PROP_PADDING_RIGHT:
- l = parentStyle->paddingRight(); break;
- case CSS_PROP_PADDING_BOTTOM:
- l = parentStyle->paddingBottom(); break;
- case CSS_PROP_PADDING_LEFT:
- l = parentStyle->paddingLeft(); break;
- case CSS_PROP_MARGIN_TOP:
- l = parentStyle->marginTop(); break;
- case CSS_PROP_MARGIN_RIGHT:
- l = parentStyle->marginRight(); break;
- case CSS_PROP_MARGIN_BOTTOM:
- l = parentStyle->marginBottom(); break;
- case CSS_PROP_MARGIN_LEFT:
- l = parentStyle->marginLeft(); break;
- case CSS_PROP_TEXT_INDENT:
- l = parentStyle->textIndent(); break;
- default:
- return;
- }
- } else if(primitiveValue && !apply) {
+ if (value->cssValueType() == CSSValue::CSS_INHERIT) {
+ HANDLE_INHERIT_COND(CSS_PROP_MAX_WIDTH, maxWidth, MaxWidth)
+ HANDLE_INHERIT_COND(CSS_PROP_BOTTOM, bottom, Bottom)
+ HANDLE_INHERIT_COND(CSS_PROP_TOP, top, Top)
+ HANDLE_INHERIT_COND(CSS_PROP_LEFT, left, Left)
+ HANDLE_INHERIT_COND(CSS_PROP_RIGHT, right, Right)
+ HANDLE_INHERIT_COND(CSS_PROP_WIDTH, width, Width)
+ HANDLE_INHERIT_COND(CSS_PROP_MIN_WIDTH, minWidth, MinWidth)
+ HANDLE_INHERIT_COND(CSS_PROP_PADDING_TOP, paddingTop, PaddingTop)
+ HANDLE_INHERIT_COND(CSS_PROP_PADDING_RIGHT, paddingRight, PaddingRight)
+ HANDLE_INHERIT_COND(CSS_PROP_PADDING_BOTTOM, paddingBottom, PaddingBottom)
+ HANDLE_INHERIT_COND(CSS_PROP_PADDING_LEFT, paddingLeft, PaddingLeft)
+ HANDLE_INHERIT_COND(CSS_PROP_MARGIN_TOP, marginTop, MarginTop)
+ HANDLE_INHERIT_COND(CSS_PROP_MARGIN_RIGHT, marginRight, MarginRight)
+ HANDLE_INHERIT_COND(CSS_PROP_MARGIN_BOTTOM, marginBottom, MarginBottom)
+ HANDLE_INHERIT_COND(CSS_PROP_MARGIN_LEFT, marginLeft, MarginLeft)
+ HANDLE_INHERIT_COND(CSS_PROP_TEXT_INDENT, textIndent, TextIndent)
+ return;
+ }
+
+ if(primitiveValue && !apply) {
int type = primitiveValue->primitiveType();
if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
// Handle our quirky margin units if we have them.
@@ -2697,33 +2504,20 @@ void CSSStyleSelector::applyRule( int id
}
case CSS_PROP_MAX_HEIGHT:
- // +inherit +none !can be calculted directly!
if(primitiveValue && primitiveValue->getIdent() == CSS_VAL_NONE)
apply = true;
case CSS_PROP_HEIGHT:
case CSS_PROP_MIN_HEIGHT:
- // +inherit +auto !can be calculted directly!
if(id != CSS_PROP_MAX_HEIGHT && primitiveValue &&
primitiveValue->getIdent() == CSS_VAL_AUTO)
apply = true;
- if(value->cssValueType() == CSSValue::CSS_INHERIT)
- {
- if(!parentNode) return;
- apply = true;
- switch(id)
- {
- case CSS_PROP_MAX_HEIGHT:
- l = parentStyle->maxHeight(); break;
- case CSS_PROP_HEIGHT:
- l = parentStyle->height(); break;
- case CSS_PROP_MIN_HEIGHT:
- l = parentStyle->minHeight(); break;
- default:
- return;
- }
+ if (value->cssValueType() == CSSValue::CSS_INHERIT) {
+ HANDLE_INHERIT_COND(CSS_PROP_MAX_HEIGHT, maxHeight, MaxHeight)
+ HANDLE_INHERIT_COND(CSS_PROP_HEIGHT, height, Height)
+ HANDLE_INHERIT_COND(CSS_PROP_MIN_HEIGHT, minHeight, MinHeight)
return;
}
- if(primitiveValue && !apply)
+ if (primitiveValue && !apply)
{
int type = primitiveValue->primitiveType();
if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
@@ -2754,13 +2548,8 @@ void CSSStyleSelector::applyRule( int id
break;
case CSS_PROP_VERTICAL_ALIGN:
- if(value->cssValueType() == CSSValue::CSS_INHERIT)
- {
- if(!parentNode) return;
- style->setVerticalAlign(parentStyle->verticalAlign());
- return;
- }
- if(!primitiveValue) return;
+ HANDLE_INHERIT(verticalAlign, VerticalAlign)
+ if (!primitiveValue) return;
if(primitiveValue->getIdent()) {
khtml::EVerticalAlign align;
@@ -2868,120 +2657,78 @@ void CSSStyleSelector::applyRule( int id
fontDirty = true;
return;
}
-
-// angle
-// case CSS_PROP_ELEVATION:
-
-// number
-// case CSS_PROP_FONT_SIZE_ADJUST:
-// case CSS_PROP_ORPHANS:
-// case CSS_PROP_PITCH_RANGE:
-// case CSS_PROP_RICHNESS:
-// case CSS_PROP_SPEECH_RATE:
-// case CSS_PROP_STRESS:
-// case CSS_PROP_WIDOWS:
break;
case CSS_PROP_Z_INDEX:
{
- int z_index = 0;
- if(value->cssValueType() == CSSValue::CSS_INHERIT) {
- if(!parentNode) return;
- z_index = parentStyle->zIndex();
- } else {
- if (!primitiveValue)
- return;
+ HANDLE_INHERIT(zIndex, ZIndex)
- if (primitiveValue->getIdent() == CSS_VAL_AUTO) {
- style->setHasAutoZIndex();
- return;
- }
-
- if (primitiveValue->primitiveType() != CSSPrimitiveValue::CSS_NUMBER)
- return; // Error case.
-
- z_index = (int)primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_NUMBER);
+ if (!primitiveValue)
+ return;
+
+ if (primitiveValue->getIdent() == CSS_VAL_AUTO) {
+ style->setHasAutoZIndex();
+ return;
}
+
+ if (primitiveValue->primitiveType() != CSSPrimitiveValue::CSS_NUMBER)
+ return; // Error case.
- style->setZIndex(z_index);
+ style->setZIndex((int)primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_NUMBER));
+
return;
}
case CSS_PROP_WIDOWS:
{
- if (value->cssValueType() == CSSValue::CSS_INHERIT) {
- if(!parentNode) return;
- style->setWidows(parentStyle->widows());
- } else {
- if (!primitiveValue || primitiveValue->primitiveType() != CSSPrimitiveValue::CSS_NUMBER)
- return;
- style->setWidows((int)primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_NUMBER));
- }
+ HANDLE_INHERIT(widows, Widows)
+ if (!primitiveValue || primitiveValue->primitiveType() != CSSPrimitiveValue::CSS_NUMBER)
+ return;
+ style->setWidows((int)primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_NUMBER));
break;
}
case CSS_PROP_ORPHANS:
{
- if (value->cssValueType() == CSSValue::CSS_INHERIT) {
- if(!parentNode) return;
- style->setOrphans(parentStyle->orphans());
- } else {
- if (!primitiveValue || primitiveValue->primitiveType() != CSSPrimitiveValue::CSS_NUMBER)
- return;
- style->setOrphans((int)primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_NUMBER));
- }
+ HANDLE_INHERIT(orphans, Orphans)
+ if (!primitiveValue || primitiveValue->primitiveType() != CSSPrimitiveValue::CSS_NUMBER)
+ return;
+ style->setOrphans((int)primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_NUMBER));
break;
}
// length, percent, number
case CSS_PROP_LINE_HEIGHT:
{
+ HANDLE_INHERIT(lineHeight, LineHeight)
+ if(!primitiveValue) return;
Length lineHeight;
- if(value->cssValueType() == CSSValue::CSS_INHERIT)
- {
- if(!parentNode) return;
- lineHeight = parentStyle->lineHeight();
- } else {
- if(!primitiveValue) return;
- int type = primitiveValue->primitiveType();
- if(primitiveValue->getIdent() == CSS_VAL_NORMAL)
- lineHeight = Length( -100, Percent );
- else if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG) {
- double multiplier = 1.0;
- // Scale for the font zoom factor only for types other than "em" and "ex", since those are
- // already based on the font size.
- if (type != CSSPrimitiveValue::CSS_EMS && type != CSSPrimitiveValue::CSS_EXS && view && view->part()) {
- multiplier = view->part()->zoomFactor() / 100.0;
- }
- lineHeight = Length(primitiveValue->computeLength(style, paintDeviceMetrics, multiplier), Fixed);
- } else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
- lineHeight = Length( ( style->font().pixelSize() * int(primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_PERCENTAGE)) ) / 100, Fixed );
- else if(type == CSSPrimitiveValue::CSS_NUMBER)
- lineHeight = Length(int(primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_NUMBER)*100), Percent);
- else
- return;
- }
+ int type = primitiveValue->primitiveType();
+ if(primitiveValue->getIdent() == CSS_VAL_NORMAL)
+ lineHeight = Length( -100, Percent );
+ else if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG) {
+ double multiplier = 1.0;
+ // Scale for the font zoom factor only for types other than "em" and "ex", since those are
+ // already based on the font size.
+ if (type != CSSPrimitiveValue::CSS_EMS && type != CSSPrimitiveValue::CSS_EXS && view && view->part()) {
+ multiplier = view->part()->zoomFactor() / 100.0;
+ }
+ lineHeight = Length(primitiveValue->computeLength(style, paintDeviceMetrics, multiplier), Fixed);
+ } else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
+ lineHeight = Length( ( style->font().pixelSize() * int(primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_PERCENTAGE)) ) / 100, Fixed );
+ else if(type == CSSPrimitiveValue::CSS_NUMBER)
+ lineHeight = Length(int(primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_NUMBER)*100), Percent);
+ else
+ return;
style->setLineHeight(lineHeight);
return;
}
-// number, percent
-// case CSS_PROP_VOLUME:
-
-// frequency
-// case CSS_PROP_PITCH:
-// break;
-
// string
case CSS_PROP_TEXT_ALIGN:
{
- if(value->cssValueType() == CSSValue::CSS_INHERIT)
- {
- if(!parentNode) return;
- style->setTextAlign(parentStyle->textAlign());
- return;
- }
- if(!primitiveValue) return;
- if(primitiveValue->getIdent())
+ HANDLE_INHERIT(textAlign, TextAlign)
+ if (!primitiveValue) return;
+ if (primitiveValue->getIdent())
style->setTextAlign( (ETextAlign) (primitiveValue->getIdent() - CSS_VAL__KHTML_AUTO) );
return;
}
@@ -3017,7 +2764,7 @@ void CSSStyleSelector::applyRule( int id
// qDebug("setting clip bottom to %d", bottom.value );
// qDebug("setting clip left to %d", left.value );
style->setClip( top, right, bottom, left );
- style->setHasClip();
+ style->setHasClip();
// rect, ident
break;
@@ -3027,6 +2774,8 @@ void CSSStyleSelector::applyRule( int id
case CSS_PROP_CONTENT:
// list of string, uri, counter, attr, i
{
+ // FIXME: In CSS3, it will be possible to inherit content. In CSS2 it is not. This
+ // note is a reminder that eventually "inherit" needs to be supported.
if (!(style->styleType()==RenderStyle::BEFORE ||
style->styleType()==RenderStyle::AFTER))
break;
@@ -3070,7 +2819,18 @@ void CSSStyleSelector::applyRule( int id
case CSS_PROP_FONT_FAMILY:
// list of strings and ids
{
- if(!value->isValueList()) return;
+ if(value->cssValueType() == CSSValue::CSS_INHERIT) {
+ if (!parentNode) return;
+ FontDef parentFontDef = parentStyle->htmlFont().fontDef;
+ FontDef fontDef = style->htmlFont().fontDef;
+ fontDef.genericFamily = parentFontDef.genericFamily;
+ fontDef.family = parentFontDef.family;
+ if (style->setFontDef(fontDef))
+ fontDirty = true;
+ return;
+ }
+
+ if (!value->isValueList()) return;
FontDef fontDef = style->htmlFont().fontDef;
CSSValueListImpl *list = static_cast<CSSValueListImpl *>(value);
int len = list->length();
@@ -3138,16 +2898,9 @@ void CSSStyleSelector::applyRule( int id
case CSS_PROP_SIZE:
// ### look up
break;
- case CSS_PROP_TEXT_DECORATION:
+ case CSS_PROP_TEXT_DECORATION: {
// list of ident
- // ### no list at the moment
- {
- if(value->cssValueType() == CSSValue::CSS_INHERIT)
- {
- if(!parentNode) return;
- style->setTextDecoration(parentStyle->textDecoration());
- return;
- }
+ HANDLE_INHERIT(textDecoration, TextDecoration)
int t = TDNONE;
if(primitiveValue && primitiveValue->getIdent() == CSS_VAL_NONE) {
// do nothing
@@ -3182,32 +2935,23 @@ void CSSStyleSelector::applyRule( int id
break;
}
case CSS_PROP__KHTML_FLOW_MODE:
- if(value->cssValueType() == CSSValue::CSS_INHERIT)
- {
- if(!parentNode) return;
- style->setFlowAroundFloats(parentStyle->flowAroundFloats());
- return;
- }
- if(!primitiveValue) return;
- if(primitiveValue->getIdent())
- {
+ HANDLE_INHERIT(flowAroundFloats, FlowAroundFloats)
+ if (!primitiveValue) return;
+ if (primitiveValue->getIdent()) {
style->setFlowAroundFloats( primitiveValue->getIdent() == CSS_VAL__KHTML_AROUND_FLOATS );
return;
}
break;
-// case CSS_PROP_VOICE_FAMILY:
-// // list of strings and i
-// break;
// shorthand properties
case CSS_PROP_BACKGROUND:
- if(value->cssValueType() != CSSValue::CSS_INHERIT || !parentNode) return;
+ if (value->cssValueType() != CSSValue::CSS_INHERIT || !parentNode) return;
style->setBackgroundColor(parentStyle->backgroundColor());
style->setBackgroundImage(parentStyle->backgroundImage());
style->setBackgroundRepeat(parentStyle->backgroundRepeat());
style->setBackgroundAttachment(parentStyle->backgroundAttachment());
-// style->setBackgroundPosition(parentStyle->backgroundPosition());
-
+ style->setBackgroundXPosition(parentStyle->backgroundXPosition());
+ style->setBackgroundYPosition(parentStyle->backgroundYPosition());
break;
case CSS_PROP_BORDER:
case CSS_PROP_BORDER_STYLE:
@@ -3276,7 +3020,6 @@ void CSSStyleSelector::applyRule( int id
style->setPaddingRight(parentStyle->paddingRight());
return;
-// case CSS_PROP_CUE:
case CSS_PROP_FONT:
if ( value->cssValueType() == CSSValue::CSS_INHERIT ) {
if ( !parentNode )
@@ -3307,18 +3050,22 @@ void CSSStyleSelector::applyRule( int id
return;
case CSS_PROP_LIST_STYLE:
+ if (value->cssValueType() != CSSValue::CSS_INHERIT || !parentNode) return;
+ style->setListStyleType(parentStyle->listStyleType());
+ style->setListStyleImage(parentStyle->listStyleImage());
+ style->setListStylePosition(parentStyle->listStylePosition());
+ break;
case CSS_PROP_OUTLINE:
-// case CSS_PROP_PAUSE:
+ if (value->cssValueType() != CSSValue::CSS_INHERIT || !parentNode) return;
+ style->setOutlineWidth(parentStyle->outlineWidth());
+ style->setOutlineColor(parentStyle->outlineColor());
+ style->setOutlineStyle(parentStyle->outlineStyle());
break;
// CSS3 Properties
case CSS_PROP_OUTLINE_OFFSET: {
- if (value->cssValueType() == CSSValue::CSS_INHERIT) {
- if (!parentNode) return;
- style->setOutlineOffset(parentStyle->outlineOffset());
- return;
- }
-
+ HANDLE_INHERIT(outlineOffset, OutlineOffset)
+
int offset = primitiveValue->computeLength(style, paintDeviceMetrics);
if (offset < 0) return;
@@ -3362,22 +3109,15 @@ void CSSStyleSelector::applyRule( int id
return;
}
case CSS_PROP_OPACITY:
- if (value->cssValueType() == CSSValue::CSS_INHERIT) {
- if (!parentNode) return;
- style->setOpacity(parentStyle->opacity());
- }
+ HANDLE_INHERIT(opacity, Opacity)
if (!primitiveValue || primitiveValue->primitiveType() != CSSPrimitiveValue::CSS_NUMBER)
return; // Error case.
// Clamp opacity to the range 0-1
- style->setOpacity(QMIN(1.0f, QMAX(0, primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_NUMBER))));
+ style->setOpacity(kMin(1.0f, kMax(0, primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_NUMBER))));
return;
case CSS_PROP__KHTML_BOX_ALIGN:
- if (value->cssValueType() == CSSValue::CSS_INHERIT) {
- if(!parentNode) return;
- style->setBoxAlign(parentStyle->boxAlign());
- return;
- }
+ HANDLE_INHERIT(boxAlign, BoxAlign)
if (!primitiveValue) return;
switch (primitiveValue->getIdent()) {
case CSS_VAL_STRETCH:
@@ -3400,11 +3140,7 @@ void CSSStyleSelector::applyRule( int id
}
return;
case CSS_PROP__KHTML_BOX_DIRECTION:
- if (value->cssValueType() == CSSValue::CSS_INHERIT) {
- if(!parentNode) return;
- style->setBoxDirection(parentStyle->boxDirection());
- return;
- }
+ HANDLE_INHERIT(boxDirection, BoxDirection)
if (!primitiveValue) return;
if (primitiveValue->getIdent() == CSS_VAL_NORMAL)
style->setBoxDirection(BNORMAL);
@@ -3412,11 +3148,7 @@ void CSSStyleSelector::applyRule( int id
style->setBoxDirection(BREVERSE);
return;
case CSS_PROP__KHTML_BOX_LINES:
- if (value->cssValueType() == CSSValue::CSS_INHERIT) {
- if(!parentNode) return;
- style->setBoxLines(parentStyle->boxLines());
- return;
- }
+ HANDLE_INHERIT(boxLines, BoxLines)
if(!primitiveValue) return;
if (primitiveValue->getIdent() == CSS_VAL_SINGLE)
style->setBoxLines(SINGLE);
@@ -3424,11 +3156,7 @@ void CSSStyleSelector::applyRule( int id
style->setBoxLines(MULTIPLE);
return;
case CSS_PROP__KHTML_BOX_ORIENT:
- if (value->cssValueType() == CSSValue::CSS_INHERIT) {
- if(!parentNode) return;
- style->setBoxOrient(parentStyle->boxOrient());
- return;
- }
+ HANDLE_INHERIT(boxOrient, BoxOrient)
if (!primitiveValue) return;
if (primitiveValue->getIdent() == CSS_VAL_HORIZONTAL ||
primitiveValue->getIdent() == CSS_VAL_INLINE_AXIS)
@@ -3437,11 +3165,7 @@ void CSSStyleSelector::applyRule( int id
style->setBoxOrient(VERTICAL);
return;
case CSS_PROP__KHTML_BOX_PACK:
- if (value->cssValueType() == CSSValue::CSS_INHERIT) {
- if(!parentNode) return;
- style->setBoxPack(parentStyle->boxPack());
- return;
- }
+ HANDLE_INHERIT(boxPack, BoxPack)
if (!primitiveValue) return;
switch (primitiveValue->getIdent()) {
case CSS_VAL_START:
@@ -3461,31 +3185,19 @@ void CSSStyleSelector::applyRule( int id
}
return;
case CSS_PROP__KHTML_BOX_FLEX:
- if (value->cssValueType() == CSSValue::CSS_INHERIT) {
- if(!parentNode) return;
- style->setBoxFlex(parentStyle->boxFlex());
- return;
- }
+ HANDLE_INHERIT(boxFlex, BoxFlex)
if (!primitiveValue || primitiveValue->primitiveType() != CSSPrimitiveValue::CSS_NUMBER)
return; // Error case.
style->setBoxFlex(primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_NUMBER));
return;
case CSS_PROP__KHTML_BOX_FLEX_GROUP:
- if (value->cssValueType() == CSSValue::CSS_INHERIT) {
- if(!parentNode) return;
- style->setBoxFlexGroup(parentStyle->boxFlexGroup());
- return;
- }
+ HANDLE_INHERIT(boxFlexGroup, BoxFlexGroup)
if (!primitiveValue || primitiveValue->primitiveType() != CSSPrimitiveValue::CSS_NUMBER)
return; // Error case.
style->setBoxFlexGroup((unsigned int)(primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_NUMBER)));
return;
case CSS_PROP__KHTML_BOX_ORDINAL_GROUP:
- if (value->cssValueType() == CSSValue::CSS_INHERIT) {
- if(!parentNode) return;
- style->setBoxOrdinalGroup(parentStyle->boxOrdinalGroup());
- return;
- }
+ HANDLE_INHERIT(boxOrdinalGroup, BoxOrdinalGroup)
if (!primitiveValue || primitiveValue->primitiveType() != CSSPrimitiveValue::CSS_NUMBER)
return; // Error case.
style->setBoxOrdinalGroup((unsigned int)(primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_NUMBER)));
@@ -3499,11 +3211,7 @@ void CSSStyleSelector::applyRule( int id
style->setMarqueeBehavior(parentStyle->marqueeBehavior());
break;
case CSS_PROP__KHTML_MARQUEE_REPETITION: {
- if (value->cssValueType() == CSSValue::CSS_INHERIT) {
- if(!parentNode) return;
- style->setMarqueeLoopCount(parentStyle->marqueeLoopCount());
- return;
- }
+ HANDLE_INHERIT(marqueeLoopCount, MarqueeLoopCount)
if (!primitiveValue) return;
if (primitiveValue->getIdent() == CSS_VAL_INFINITE)
style->setMarqueeLoopCount(-1); // -1 means repeat forever.
@@ -3512,11 +3220,7 @@ void CSSStyleSelector::applyRule( int id
break;
}
case CSS_PROP__KHTML_MARQUEE_SPEED: {
- if (value->cssValueType() == CSSValue::CSS_INHERIT) {
- if(!parentNode) return;
- style->setMarqueeSpeed(parentStyle->marqueeSpeed());
- return;
- }
+ HANDLE_INHERIT(marqueeSpeed, MarqueeSpeed)
if (!primitiveValue) return;
if (primitiveValue->getIdent()) {
switch (primitiveValue->getIdent())
@@ -3541,11 +3245,7 @@ void CSSStyleSelector::applyRule( int id
break;
}
case CSS_PROP__KHTML_MARQUEE_INCREMENT: {
- if (value->cssValueType() == CSSValue::CSS_INHERIT) {
- if(!parentNode) return;
- style->setMarqueeIncrement(parentStyle->marqueeIncrement());
- return;
- }
+ HANDLE_INHERIT(marqueeIncrement, MarqueeIncrement)
if (!primitiveValue) return;
if (primitiveValue->getIdent()) {
switch (primitiveValue->getIdent())
-------------- next part --------------
Index: ChangeLog
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/ChangeLog,v
retrieving revision 1.2246
diff -u -p -r1.2246 ChangeLog
--- ChangeLog 2003/11/12 01:30:11 1.2246
+++ ChangeLog 2003/11/12 08:45:13
@@ -1,3 +1,55 @@
+2003-11-11 David Hyatt <hyatt at apple.com>
+
+ Fix for 3481134, shorthand parsing in CSS does not fill in omitted values. The fix is to implement
+ the CSS3 'initial' value for all properties (covered by 3481323), and then to fill in the omitted
+ values with the 'initial' value.
+
+ This patch also fixes two bugs in the style system: 3481324, collapsed borders with border-style: none
+ should always return a width of 0, and 3481322, 'clip' not inheriting properly in CSS when explicit
+ inheritance is used.
+
+ Reviewed by mjs
+
+ * khtml/css/css_valueimpl.cpp:
+ (CSSInitialValueImpl::cssText):
+ * khtml/css/css_valueimpl.h:
+ (DOM::CSSInitialValueImpl::cssValueType):
+ * khtml/css/cssparser.cpp:
+ (CSSParser::parseValue):
+ (CSSParser::parseShortHand):
+ * khtml/css/cssstyleselector.cpp:
+ (khtml::CSSStyleSelector::applyRule):
+ * khtml/css/cssvalues.c:
+ (hash_val):
+ (findValue):
+ * khtml/css/cssvalues.h:
+ * khtml/css/cssvalues.in:
+ * khtml/dom/css_value.h:
+ (DOM::CSSValue::):
+ * khtml/rendering/render_style.cpp:
+ (StyleBoxData::StyleBoxData):
+ (StyleVisualData::StyleVisualData):
+ (StyleBackgroundData::StyleBackgroundData):
+ (StyleMarqueeData::StyleMarqueeData):
+ (StyleFlexibleBoxData::StyleFlexibleBoxData):
+ (opacity):
+ (StyleInheritedData::StyleInheritedData):
+ (RenderStyle::diff):
+ * khtml/rendering/render_style.h:
+ (khtml::BorderValue::BorderValue):
+ (khtml::CollapsedBorderValue::width):
+ (khtml::RenderStyle::InheritedFlags::operator==):
+ (khtml::RenderStyle::setBitDefaults):
+ (khtml::RenderStyle::resetBorderTop):
+ (khtml::RenderStyle::resetBorderRight):
+ (khtml::RenderStyle::resetBorderBottom):
+ (khtml::RenderStyle::resetBorderLeft):
+ (khtml::RenderStyle::resetOutline):
+ (khtml::RenderStyle::setHasClip):
+ (khtml::RenderStyle::resetMargin):
+ (khtml::RenderStyle::resetPadding):
+ (khtml::RenderStyle::setCursor):
+
2003-11-11 Maciej Stachowiak <mjs at apple.com>
Reviewed by John.
Index: khtml/css/css_valueimpl.cpp
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/css/css_valueimpl.cpp,v
retrieving revision 1.23
diff -u -p -r1.23 khtml/css/css_valueimpl.cpp
--- khtml/css/css_valueimpl.cpp 2003/07/23 22:36:07 1.23
+++ khtml/css/css_valueimpl.cpp 2003/11/12 08:45:22
@@ -388,10 +388,26 @@ void CSSValueImpl::setCssText(DOM::DOMSt
// ###
}
+unsigned short CSSInheritedValueImpl::cssValueType() const
+{
+ return CSSValue::CSS_INHERIT;
+}
+
DOM::DOMString CSSInheritedValueImpl::cssText() const
{
return DOMString("inherited");
}
+
+unsigned short CSSInitialValueImpl::cssValueType() const
+{
+ return CSSValue::CSS_INITIAL;
+}
+
+DOM::DOMString CSSInitialValueImpl::cssText() const
+{
+ return DOMString("initial");
+}
+
// ----------------------------------------------------------------------------------------
CSSValueListImpl::CSSValueListImpl()
Index: khtml/css/css_valueimpl.h
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/css/css_valueimpl.h,v
retrieving revision 1.16
diff -u -p -r1.16 khtml/css/css_valueimpl.h
--- khtml/css/css_valueimpl.h 2003/07/23 22:36:07 1.16
+++ khtml/css/css_valueimpl.h 2003/11/12 08:45:23
@@ -116,10 +116,16 @@ public:
CSSInheritedValueImpl() : CSSValueImpl() {}
virtual ~CSSInheritedValueImpl() {}
- virtual unsigned short cssValueType() const { return CSSValue::CSS_INHERIT; }
+ virtual unsigned short cssValueType() const;
virtual DOM::DOMString cssText() const;
};
+class CSSInitialValueImpl : public CSSValueImpl
+{
+public:
+ virtual unsigned short cssValueType() const;
+ virtual DOM::DOMString cssText() const;
+};
class CSSValueListImpl : public CSSValueImpl
{
Index: khtml/css/cssparser.cpp
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/css/cssparser.cpp,v
retrieving revision 1.51
diff -u -p -r1.51 khtml/css/cssparser.cpp
--- khtml/css/cssparser.cpp 2003/11/10 23:52:24 1.51
+++ khtml/css/cssparser.cpp 2003/11/12 08:45:25
@@ -406,10 +406,14 @@ bool CSSParser::parseValue( int propId,
int id = 0;
id = value->id;
- if ( id == CSS_VAL_INHERIT ) {
- addProperty( propId, new CSSInheritedValueImpl(), important );
+ if (id == CSS_VAL_INHERIT) {
+ addProperty(propId, new CSSInheritedValueImpl(), important);
return true;
}
+ else if (id == CSS_VAL_INITIAL) {
+ addProperty(propId, new CSSInitialValueImpl(), important);
+ return true;
+ }
bool valid_primitive = false;
CSSValueImpl *parsedValue = 0;
@@ -1233,6 +1237,13 @@ bool CSSParser::parseShortHand( const in
return false;
}
}
+
+ // Fill in any remaining properties with the initial value.
+ for (int i = 0; i < numProperties; ++i) {
+ if (!fnd[i])
+ addProperty(properties[i], new CSSInitialValueImpl(), important);
+ }
+
inParseShortHand = false;
#ifdef CSS_DEBUG
kdDebug( 6080 ) << "parsed shorthand" << endl;
Index: khtml/css/cssstyleselector.cpp
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/css/cssstyleselector.cpp,v
retrieving revision 1.111
diff -u -p -r1.111 khtml/css/cssstyleselector.cpp
--- khtml/css/cssstyleselector.cpp 2003/11/10 23:52:24 1.111
+++ khtml/css/cssstyleselector.cpp 2003/11/12 08:45:30
@@ -68,21 +68,43 @@ using namespace DOM;
#include <stdlib.h>
#define HANDLE_INHERIT(prop, Prop) \
-if (value->cssValueType() == CSSValue::CSS_INHERIT) \
+if (isInherit) \
{\
- if (!parentNode) return;\
style->set##Prop(parentStyle->prop());\
return;\
}
+#define HANDLE_INHERIT_AND_INITIAL(prop, Prop) \
+HANDLE_INHERIT(prop, Prop) \
+else if (isInitial) \
+ style->set##Prop(RenderStyle::initial##Prop());
+
+#define HANDLE_INHERIT_AND_INITIAL_WITH_VALUE(prop, Prop, Value) \
+HANDLE_INHERIT(prop, Prop) \
+else if (isInitial) \
+ style->set##Prop(RenderStyle::initial##Value());
+
#define HANDLE_INHERIT_COND(propID, prop, Prop) \
if (id == propID) \
{\
- if (!parentNode) return;\
style->set##Prop(parentStyle->prop());\
return;\
}
+#define HANDLE_INITIAL_COND(propID, Prop) \
+if (id == propID) \
+{\
+ style->set##Prop(RenderStyle::initial##Prop());\
+ return;\
+}
+
+#define HANDLE_INITIAL_COND_WITH_VALUE(propID, Prop, Value) \
+if (id == propID) \
+{\
+ style->set##Prop(RenderStyle::initial##Value());\
+ return;\
+}
+
namespace khtml {
CSSStyleSelectorList *CSSStyleSelector::defaultStyle = 0;
@@ -1622,13 +1644,18 @@ void CSSStyleSelector::applyRule( int id
Length l;
bool apply = false;
- // here follows a long list, defining how to aplly certain properties to the style object.
- // rather boring stuff...
+ bool isInherit = (parentNode && value->cssValueType() == CSSValue::CSS_INHERIT);
+ bool isInitial = (value->cssValueType() == CSSValue::CSS_INITIAL) ||
+ (!parentNode && value->cssValueType() == CSSValue::CSS_INHERIT);
+
+ // What follows is a list that maps the CSS properties into their corresponding front-end
+ // RenderStyle values. Shorthands (e.g. border, background) occur in this list as well and
+ // are only hit when mapping "inherit" or "initial" into front-end values.
switch(id)
{
// ident only properties
case CSS_PROP_BACKGROUND_ATTACHMENT:
- HANDLE_INHERIT(backgroundAttachment, BackgroundAttachment)
+ HANDLE_INHERIT_AND_INITIAL(backgroundAttachment, BackgroundAttachment)
if(!primitiveValue) break;
switch(primitiveValue->getIdent())
{
@@ -1648,7 +1675,7 @@ void CSSStyleSelector::applyRule( int id
}
case CSS_PROP_BACKGROUND_REPEAT:
{
- HANDLE_INHERIT(backgroundRepeat, BackgroundRepeat)
+ HANDLE_INHERIT_AND_INITIAL(backgroundRepeat, BackgroundRepeat)
if(!primitiveValue) return;
switch(primitiveValue->getIdent())
{
@@ -1669,7 +1696,7 @@ void CSSStyleSelector::applyRule( int id
}
}
case CSS_PROP_BORDER_COLLAPSE:
- HANDLE_INHERIT(borderCollapse, BorderCollapse)
+ HANDLE_INHERIT_AND_INITIAL(borderCollapse, BorderCollapse)
if(!primitiveValue) break;
switch(primitiveValue->getIdent())
{
@@ -1685,35 +1712,35 @@ void CSSStyleSelector::applyRule( int id
break;
case CSS_PROP_BORDER_TOP_STYLE:
- HANDLE_INHERIT(borderTopStyle, BorderTopStyle)
+ HANDLE_INHERIT_AND_INITIAL_WITH_VALUE(borderTopStyle, BorderTopStyle, BorderStyle)
if (!primitiveValue) return;
style->setBorderTopStyle((EBorderStyle)(primitiveValue->getIdent() - CSS_VAL_NONE));
break;
case CSS_PROP_BORDER_RIGHT_STYLE:
- HANDLE_INHERIT(borderRightStyle, BorderRightStyle)
+ HANDLE_INHERIT_AND_INITIAL_WITH_VALUE(borderRightStyle, BorderRightStyle, BorderStyle)
if (!primitiveValue) return;
style->setBorderRightStyle((EBorderStyle)(primitiveValue->getIdent() - CSS_VAL_NONE));
break;
case CSS_PROP_BORDER_BOTTOM_STYLE:
- HANDLE_INHERIT(borderBottomStyle, BorderBottomStyle)
+ HANDLE_INHERIT_AND_INITIAL_WITH_VALUE(borderBottomStyle, BorderBottomStyle, BorderStyle)
if (!primitiveValue) return;
style->setBorderBottomStyle((EBorderStyle)(primitiveValue->getIdent() - CSS_VAL_NONE));
break;
case CSS_PROP_BORDER_LEFT_STYLE:
- HANDLE_INHERIT(borderLeftStyle, BorderLeftStyle)
+ HANDLE_INHERIT_AND_INITIAL_WITH_VALUE(borderLeftStyle, BorderLeftStyle, BorderStyle)
if (!primitiveValue) return;
style->setBorderLeftStyle((EBorderStyle)(primitiveValue->getIdent() - CSS_VAL_NONE));
break;
case CSS_PROP_OUTLINE_STYLE:
- HANDLE_INHERIT(outlineStyle, OutlineStyle)
+ HANDLE_INHERIT_AND_INITIAL_WITH_VALUE(outlineStyle, OutlineStyle, BorderStyle)
if (!primitiveValue) return;
style->setOutlineStyle((EBorderStyle)(primitiveValue->getIdent() - CSS_VAL_NONE));
break;
case CSS_PROP_CAPTION_SIDE:
{
- HANDLE_INHERIT(captionSide, CaptionSide)
+ HANDLE_INHERIT_AND_INITIAL(captionSide, CaptionSide)
if(!primitiveValue) break;
- ECaptionSide c = CAPTOP;
+ ECaptionSide c = RenderStyle::initialCaptionSide();
switch(primitiveValue->getIdent())
{
case CSS_VAL_LEFT:
@@ -1732,7 +1759,7 @@ void CSSStyleSelector::applyRule( int id
}
case CSS_PROP_CLEAR:
{
- HANDLE_INHERIT(clear, Clear)
+ HANDLE_INHERIT_AND_INITIAL(clear, Clear)
if(!primitiveValue) break;
EClear c = CNONE;
switch(primitiveValue->getIdent())
@@ -1751,14 +1778,14 @@ void CSSStyleSelector::applyRule( int id
}
case CSS_PROP_DIRECTION:
{
- HANDLE_INHERIT(direction, Direction)
+ HANDLE_INHERIT_AND_INITIAL(direction, Direction)
if(!primitiveValue) break;
style->setDirection( (EDirection) (primitiveValue->getIdent() - CSS_VAL_LTR) );
return;
}
case CSS_PROP_DISPLAY:
{
- HANDLE_INHERIT(display, Display)
+ HANDLE_INHERIT_AND_INITIAL(display, Display)
if(!primitiveValue) break;
int id = primitiveValue->getIdent();
EDisplay d;
@@ -1775,7 +1802,7 @@ void CSSStyleSelector::applyRule( int id
case CSS_PROP_EMPTY_CELLS:
{
- HANDLE_INHERIT(emptyCells, EmptyCells)
+ HANDLE_INHERIT_AND_INITIAL(emptyCells, EmptyCells)
if (!primitiveValue) break;
int id = primitiveValue->getIdent();
if (id == CSS_VAL_SHOW)
@@ -1786,7 +1813,7 @@ void CSSStyleSelector::applyRule( int id
}
case CSS_PROP_FLOAT:
{
- HANDLE_INHERIT(floating, Floating)
+ HANDLE_INHERIT_AND_INITIAL(floating, Floating)
if(!primitiveValue) return;
EFloat f;
switch(primitiveValue->getIdent())
@@ -1813,10 +1840,11 @@ void CSSStyleSelector::applyRule( int id
case CSS_PROP_FONT_STYLE:
{
FontDef fontDef = style->htmlFont().fontDef;
- if(value->cssValueType() == CSSValue::CSS_INHERIT) {
- if(!parentNode) return;
+ if (isInherit)
fontDef.italic = parentStyle->htmlFont().fontDef.italic;
- } else {
+ else if (isInitial)
+ fontDef.italic = false;
+ else {
if(!primitiveValue) return;
switch(primitiveValue->getIdent()) {
case CSS_VAL_OBLIQUE:
@@ -1840,10 +1868,11 @@ void CSSStyleSelector::applyRule( int id
case CSS_PROP_FONT_VARIANT:
{
FontDef fontDef = style->htmlFont().fontDef;
- if(value->cssValueType() == CSSValue::CSS_INHERIT) {
- if(!parentNode) return;
+ if (isInherit)
fontDef.smallCaps = parentStyle->htmlFont().fontDef.smallCaps;
- } else {
+ else if (isInitial)
+ fontDef.smallCaps = false;
+ else {
if(!primitiveValue) return;
int id = primitiveValue->getIdent();
if ( id == CSS_VAL_NORMAL )
@@ -1861,10 +1890,11 @@ void CSSStyleSelector::applyRule( int id
case CSS_PROP_FONT_WEIGHT:
{
FontDef fontDef = style->htmlFont().fontDef;
- if(value->cssValueType() == CSSValue::CSS_INHERIT) {
- if(!parentNode) return;
+ if (isInherit)
fontDef.weight = parentStyle->htmlFont().fontDef.weight;
- } else {
+ else if (isInitial)
+ fontDef.weight = QFont::Normal;
+ else {
if(!primitiveValue) return;
if(primitiveValue->getIdent())
{
@@ -1904,7 +1934,7 @@ void CSSStyleSelector::applyRule( int id
case CSS_PROP_LIST_STYLE_POSITION:
{
- HANDLE_INHERIT(listStylePosition, ListStylePosition)
+ HANDLE_INHERIT_AND_INITIAL(listStylePosition, ListStylePosition)
if (!primitiveValue) return;
if (primitiveValue->getIdent())
style->setListStylePosition( (EListStylePosition) (primitiveValue->getIdent() - CSS_VAL_OUTSIDE) );
@@ -1913,7 +1943,7 @@ void CSSStyleSelector::applyRule( int id
case CSS_PROP_LIST_STYLE_TYPE:
{
- HANDLE_INHERIT(listStyleType, ListStyleType)
+ HANDLE_INHERIT_AND_INITIAL(listStyleType, ListStyleType)
if (!primitiveValue) return;
if (primitiveValue->getIdent())
{
@@ -1931,7 +1961,7 @@ void CSSStyleSelector::applyRule( int id
case CSS_PROP_OVERFLOW:
{
- HANDLE_INHERIT(overflow, Overflow)
+ HANDLE_INHERIT_AND_INITIAL(overflow, Overflow)
if (!primitiveValue) return;
EOverflow o;
switch(primitiveValue->getIdent())
@@ -1955,7 +1985,7 @@ void CSSStyleSelector::applyRule( int id
case CSS_PROP_PAGE_BREAK_BEFORE:
{
- HANDLE_INHERIT(pageBreakBefore, PageBreakBefore)
+ HANDLE_INHERIT_AND_INITIAL_WITH_VALUE(pageBreakBefore, PageBreakBefore, PageBreak)
if (!primitiveValue) return;
switch (primitiveValue->getIdent()) {
case CSS_VAL_AUTO:
@@ -1975,7 +2005,7 @@ void CSSStyleSelector::applyRule( int id
case CSS_PROP_PAGE_BREAK_AFTER:
{
- HANDLE_INHERIT(pageBreakAfter, PageBreakAfter)
+ HANDLE_INHERIT_AND_INITIAL_WITH_VALUE(pageBreakAfter, PageBreakAfter, PageBreak)
if (!primitiveValue) return;
switch (primitiveValue->getIdent()) {
case CSS_VAL_AUTO:
@@ -1994,7 +2024,7 @@ void CSSStyleSelector::applyRule( int id
}
case CSS_PROP_PAGE_BREAK_INSIDE: {
- HANDLE_INHERIT(pageBreakInside, PageBreakInside)
+ HANDLE_INHERIT_AND_INITIAL_WITH_VALUE(pageBreakInside, PageBreakInside, PageBreak)
if (!primitiveValue) return;
if (primitiveValue->getIdent() == CSS_VAL_AUTO)
style->setPageBreakInside(PBAUTO);
@@ -2008,7 +2038,7 @@ void CSSStyleSelector::applyRule( int id
case CSS_PROP_POSITION:
{
- HANDLE_INHERIT(position, Position)
+ HANDLE_INHERIT_AND_INITIAL(position, Position)
if(!primitiveValue) return;
EPosition p;
switch(primitiveValue->getIdent())
@@ -2033,12 +2063,12 @@ void CSSStyleSelector::applyRule( int id
}
case CSS_PROP_TABLE_LAYOUT: {
- HANDLE_INHERIT(tableLayout, TableLayout)
+ HANDLE_INHERIT_AND_INITIAL(tableLayout, TableLayout)
if ( !primitiveValue->getIdent() )
return;
- ETableLayout l = TAUTO;
+ ETableLayout l = RenderStyle::initialTableLayout();
switch( primitiveValue->getIdent() ) {
case CSS_VAL_FIXED:
l = TFIXED;
@@ -2052,7 +2082,7 @@ void CSSStyleSelector::applyRule( int id
}
case CSS_PROP_UNICODE_BIDI: {
- HANDLE_INHERIT(unicodeBidi, UnicodeBidi)
+ HANDLE_INHERIT_AND_INITIAL(unicodeBidi, UnicodeBidi)
switch (primitiveValue->getIdent()) {
case CSS_VAL_NORMAL:
style->setUnicodeBidi(UBNormal);
@@ -2069,7 +2099,7 @@ void CSSStyleSelector::applyRule( int id
break;
}
case CSS_PROP_TEXT_TRANSFORM: {
- HANDLE_INHERIT(textTransform, TextTransform)
+ HANDLE_INHERIT_AND_INITIAL(textTransform, TextTransform)
if(!primitiveValue->getIdent()) return;
@@ -2087,7 +2117,7 @@ void CSSStyleSelector::applyRule( int id
case CSS_PROP_VISIBILITY:
{
- HANDLE_INHERIT(visibility, Visibility)
+ HANDLE_INHERIT_AND_INITIAL(visibility, Visibility)
switch( primitiveValue->getIdent() ) {
case CSS_VAL_HIDDEN:
@@ -2104,7 +2134,7 @@ void CSSStyleSelector::applyRule( int id
break;
}
case CSS_PROP_WHITE_SPACE:
- HANDLE_INHERIT(whiteSpace, WhiteSpace)
+ HANDLE_INHERIT_AND_INITIAL(whiteSpace, WhiteSpace)
if(!primitiveValue->getIdent()) return;
@@ -2128,12 +2158,17 @@ void CSSStyleSelector::applyRule( int id
break;
case CSS_PROP_BACKGROUND_POSITION:
- if(value->cssValueType() != CSSValue::CSS_INHERIT || !parentNode) return;
- style->setBackgroundXPosition(parentStyle->backgroundXPosition());
- style->setBackgroundYPosition(parentStyle->backgroundYPosition());
+ if (isInherit) {
+ style->setBackgroundXPosition(parentStyle->backgroundXPosition());
+ style->setBackgroundYPosition(parentStyle->backgroundYPosition());
+ }
+ else if (isInitial) {
+ style->setBackgroundXPosition(RenderStyle::initialBackgroundXPosition());
+ style->setBackgroundYPosition(RenderStyle::initialBackgroundYPosition());
+ }
break;
case CSS_PROP_BACKGROUND_POSITION_X: {
- HANDLE_INHERIT(backgroundXPosition, BackgroundXPosition)
+ HANDLE_INHERIT_AND_INITIAL(backgroundXPosition, BackgroundXPosition)
if(!primitiveValue) break;
Length l;
int type = primitiveValue->primitiveType();
@@ -2147,7 +2182,7 @@ void CSSStyleSelector::applyRule( int id
break;
}
case CSS_PROP_BACKGROUND_POSITION_Y: {
- HANDLE_INHERIT(backgroundYPosition, BackgroundYPosition)
+ HANDLE_INHERIT_AND_INITIAL(backgroundYPosition, BackgroundYPosition)
if(!primitiveValue) break;
Length l;
int type = primitiveValue->primitiveType();
@@ -2167,21 +2202,21 @@ void CSSStyleSelector::applyRule( int id
break;
}
case CSS_PROP__KHTML_BORDER_HORIZONTAL_SPACING: {
- HANDLE_INHERIT(horizontalBorderSpacing, HorizontalBorderSpacing)
+ HANDLE_INHERIT_AND_INITIAL(horizontalBorderSpacing, HorizontalBorderSpacing)
if (!primitiveValue) break;
short spacing = primitiveValue->computeLength(style, paintDeviceMetrics);
style->setHorizontalBorderSpacing(spacing);
break;
}
case CSS_PROP__KHTML_BORDER_VERTICAL_SPACING: {
- HANDLE_INHERIT(verticalBorderSpacing, VerticalBorderSpacing)
+ HANDLE_INHERIT_AND_INITIAL(verticalBorderSpacing, VerticalBorderSpacing)
if (!primitiveValue) break;
short spacing = primitiveValue->computeLength(style, paintDeviceMetrics);
style->setVerticalBorderSpacing(spacing);
break;
}
case CSS_PROP_CURSOR:
- HANDLE_INHERIT(cursor, Cursor)
+ HANDLE_INHERIT_AND_INITIAL(cursor, Cursor)
if (primitiveValue)
style->setCursor( (ECursor) (primitiveValue->getIdent() - CSS_VAL_AUTO) );
break;
@@ -2205,7 +2240,7 @@ void CSSStyleSelector::applyRule( int id
#endif
{
QColor col;
- if (value->cssValueType() == CSSValue::CSS_INHERIT) {
+ if (isInherit) {
HANDLE_INHERIT_COND(CSS_PROP_BACKGROUND_COLOR, backgroundColor, BackgroundColor)
HANDLE_INHERIT_COND(CSS_PROP_BORDER_TOP_COLOR, borderTopColor, BorderTopColor)
HANDLE_INHERIT_COND(CSS_PROP_BORDER_BOTTOM_COLOR, borderBottomColor, BorderBottomColor)
@@ -2215,6 +2250,13 @@ void CSSStyleSelector::applyRule( int id
HANDLE_INHERIT_COND(CSS_PROP_OUTLINE_COLOR, outlineColor, OutlineColor)
return;
}
+ else if (isInitial) {
+ // The border/outline colors will just map to the invalid color |col| above. This will have the
+ // effect of forcing the use of the currentColor when it comes time to draw the borders (and of
+ // not painting the background since the color won't be valid).
+ if (id == CSS_PROP_COLOR)
+ col = RenderStyle::initialColor();
+ }
else {
if(!primitiveValue )
return;
@@ -2288,7 +2330,7 @@ void CSSStyleSelector::applyRule( int id
// uri || inherit
case CSS_PROP_BACKGROUND_IMAGE:
{
- HANDLE_INHERIT(backgroundImage, BackgroundImage)
+ HANDLE_INHERIT_AND_INITIAL(backgroundImage, BackgroundImage)
if (!primitiveValue) return;
style->setBackgroundImage(static_cast<CSSImageValueImpl *>(primitiveValue)->image());
//kdDebug( 6080 ) << "setting image in style to " << image->image() << endl;
@@ -2296,9 +2338,8 @@ void CSSStyleSelector::applyRule( int id
}
case CSS_PROP_LIST_STYLE_IMAGE:
{
- HANDLE_INHERIT(listStyleImage, ListStyleImage)
+ HANDLE_INHERIT_AND_INITIAL(listStyleImage, ListStyleImage)
if (!primitiveValue) return;
- if(!primitiveValue) return;
style->setListStyleImage(static_cast<CSSImageValueImpl *>(primitiveValue)->image());
//kdDebug( 6080 ) << "setting image in list to " << image->image() << endl;
break;
@@ -2311,7 +2352,7 @@ void CSSStyleSelector::applyRule( int id
case CSS_PROP_BORDER_LEFT_WIDTH:
case CSS_PROP_OUTLINE_WIDTH:
{
- if (value->cssValueType() == CSSValue::CSS_INHERIT) {
+ if (isInherit) {
HANDLE_INHERIT_COND(CSS_PROP_BORDER_TOP_WIDTH, borderTopWidth, BorderTopWidth)
HANDLE_INHERIT_COND(CSS_PROP_BORDER_RIGHT_WIDTH, borderRightWidth, BorderRightWidth)
HANDLE_INHERIT_COND(CSS_PROP_BORDER_BOTTOM_WIDTH, borderBottomWidth, BorderBottomWidth)
@@ -2319,6 +2360,14 @@ void CSSStyleSelector::applyRule( int id
HANDLE_INHERIT_COND(CSS_PROP_OUTLINE_WIDTH, outlineWidth, OutlineWidth)
return;
}
+ else if (isInitial) {
+ HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_BORDER_TOP_WIDTH, BorderTopWidth, BorderWidth)
+ HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_BORDER_RIGHT_WIDTH, BorderRightWidth, BorderWidth)
+ HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_BORDER_BOTTOM_WIDTH, BorderBottomWidth, BorderWidth)
+ HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_BORDER_LEFT_WIDTH, BorderLeftWidth, BorderWidth)
+ HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_OUTLINE_WIDTH, OutlineWidth, BorderWidth)
+ return;
+ }
if(!primitiveValue) break;
short width = 3;
@@ -2368,11 +2417,16 @@ void CSSStyleSelector::applyRule( int id
case CSS_PROP_WORD_SPACING:
{
- if (value->cssValueType() == CSSValue::CSS_INHERIT) {
+ if (isInherit) {
HANDLE_INHERIT_COND(CSS_PROP_LETTER_SPACING, letterSpacing, LetterSpacing)
HANDLE_INHERIT_COND(CSS_PROP_WORD_SPACING, wordSpacing, WordSpacing)
return;
}
+ else if (isInitial) {
+ HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_LETTER_SPACING, LetterSpacing, LetterWordSpacing)
+ HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_WORD_SPACING, WordSpacing, LetterWordSpacing)
+ return;
+ }
int width = 0;
if (primitiveValue && primitiveValue->getIdent() == CSS_VAL_NORMAL){
@@ -2424,7 +2478,7 @@ void CSSStyleSelector::applyRule( int id
case CSS_PROP_TEXT_INDENT:
// +inherit
{
- if (value->cssValueType() == CSSValue::CSS_INHERIT) {
+ if (isInherit) {
HANDLE_INHERIT_COND(CSS_PROP_MAX_WIDTH, maxWidth, MaxWidth)
HANDLE_INHERIT_COND(CSS_PROP_BOTTOM, bottom, Bottom)
HANDLE_INHERIT_COND(CSS_PROP_TOP, top, Top)
@@ -2442,9 +2496,28 @@ void CSSStyleSelector::applyRule( int id
HANDLE_INHERIT_COND(CSS_PROP_MARGIN_LEFT, marginLeft, MarginLeft)
HANDLE_INHERIT_COND(CSS_PROP_TEXT_INDENT, textIndent, TextIndent)
return;
+ }
+ else if (isInitial) {
+ HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_MAX_WIDTH, MaxWidth, MaxSize)
+ HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_BOTTOM, Bottom, Offset)
+ HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_TOP, Top, Offset)
+ HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_LEFT, Left, Offset)
+ HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_RIGHT, Right, Offset)
+ HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_WIDTH, Width, Size)
+ HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_MIN_WIDTH, MinWidth, MinSize)
+ HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_PADDING_TOP, PaddingTop, Padding)
+ HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_PADDING_RIGHT, PaddingRight, Padding)
+ HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_PADDING_BOTTOM, PaddingBottom, Padding)
+ HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_PADDING_LEFT, PaddingLeft, Padding)
+ HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_MARGIN_TOP, MarginTop, Margin)
+ HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_MARGIN_RIGHT, MarginRight, Margin)
+ HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_MARGIN_BOTTOM, MarginBottom, Margin)
+ HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_MARGIN_LEFT, MarginLeft, Margin)
+ HANDLE_INITIAL_COND(CSS_PROP_TEXT_INDENT, TextIndent)
+ return;
}
-
- if(primitiveValue && !apply) {
+
+ if (primitiveValue && !apply) {
int type = primitiveValue->primitiveType();
if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
// Handle our quirky margin units if we have them.
@@ -2511,12 +2584,19 @@ void CSSStyleSelector::applyRule( int id
if(id != CSS_PROP_MAX_HEIGHT && primitiveValue &&
primitiveValue->getIdent() == CSS_VAL_AUTO)
apply = true;
- if (value->cssValueType() == CSSValue::CSS_INHERIT) {
+ if (isInherit) {
HANDLE_INHERIT_COND(CSS_PROP_MAX_HEIGHT, maxHeight, MaxHeight)
HANDLE_INHERIT_COND(CSS_PROP_HEIGHT, height, Height)
HANDLE_INHERIT_COND(CSS_PROP_MIN_HEIGHT, minHeight, MinHeight)
return;
}
+ else if (isInitial) {
+ HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_MAX_HEIGHT, MaxHeight, MaxSize)
+ HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_HEIGHT, Height, Size)
+ HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_MIN_HEIGHT, MinHeight, MinSize)
+ return;
+ }
+
if (primitiveValue && !apply)
{
int type = primitiveValue->primitiveType();
@@ -2548,10 +2628,9 @@ void CSSStyleSelector::applyRule( int id
break;
case CSS_PROP_VERTICAL_ALIGN:
- HANDLE_INHERIT(verticalAlign, VerticalAlign)
+ HANDLE_INHERIT_AND_INITIAL(verticalAlign, VerticalAlign)
if (!primitiveValue) return;
- if(primitiveValue->getIdent()) {
-
+ if (primitiveValue->getIdent()) {
khtml::EVerticalAlign align;
switch(primitiveValue->getIdent())
@@ -2606,8 +2685,10 @@ void CSSStyleSelector::applyRule( int id
else
oldSize = m_fontSizes[3];
- if (value->cssValueType() == CSSValue::CSS_INHERIT)
+ if (isInherit)
size = oldSize;
+ else if (isInitial)
+ size = m_fontSizes[3];
else if (primitiveValue->getIdent()) {
// keywords are being used. Pick the correct default
// based off the font family.
@@ -2661,7 +2742,12 @@ void CSSStyleSelector::applyRule( int id
case CSS_PROP_Z_INDEX:
{
HANDLE_INHERIT(zIndex, ZIndex)
-
+ else if (isInitial) {
+ style->setHasAutoZIndex();
+ style->setZIndex(0);
+ return;
+ }
+
if (!primitiveValue)
return;
@@ -2680,7 +2766,7 @@ void CSSStyleSelector::applyRule( int id
case CSS_PROP_WIDOWS:
{
- HANDLE_INHERIT(widows, Widows)
+ HANDLE_INHERIT_AND_INITIAL(widows, Widows)
if (!primitiveValue || primitiveValue->primitiveType() != CSSPrimitiveValue::CSS_NUMBER)
return;
style->setWidows((int)primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_NUMBER));
@@ -2689,7 +2775,7 @@ void CSSStyleSelector::applyRule( int id
case CSS_PROP_ORPHANS:
{
- HANDLE_INHERIT(orphans, Orphans)
+ HANDLE_INHERIT_AND_INITIAL(orphans, Orphans)
if (!primitiveValue || primitiveValue->primitiveType() != CSSPrimitiveValue::CSS_NUMBER)
return;
style->setOrphans((int)primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_NUMBER));
@@ -2699,13 +2785,13 @@ void CSSStyleSelector::applyRule( int id
// length, percent, number
case CSS_PROP_LINE_HEIGHT:
{
- HANDLE_INHERIT(lineHeight, LineHeight)
+ HANDLE_INHERIT_AND_INITIAL(lineHeight, LineHeight)
if(!primitiveValue) return;
Length lineHeight;
int type = primitiveValue->primitiveType();
- if(primitiveValue->getIdent() == CSS_VAL_NORMAL)
+ if (primitiveValue->getIdent() == CSS_VAL_NORMAL)
lineHeight = Length( -100, Percent );
- else if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG) {
+ else if (type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG) {
double multiplier = 1.0;
// Scale for the font zoom factor only for types other than "em" and "ex", since those are
// already based on the font size.
@@ -2713,9 +2799,9 @@ void CSSStyleSelector::applyRule( int id
multiplier = view->part()->zoomFactor() / 100.0;
}
lineHeight = Length(primitiveValue->computeLength(style, paintDeviceMetrics, multiplier), Fixed);
- } else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
+ } else if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
lineHeight = Length( ( style->font().pixelSize() * int(primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_PERCENTAGE)) ) / 100, Fixed );
- else if(type == CSSPrimitiveValue::CSS_NUMBER)
+ else if (type == CSSPrimitiveValue::CSS_NUMBER)
lineHeight = Length(int(primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_NUMBER)*100), Percent);
else
return;
@@ -2726,7 +2812,7 @@ void CSSStyleSelector::applyRule( int id
// string
case CSS_PROP_TEXT_ALIGN:
{
- HANDLE_INHERIT(textAlign, TextAlign)
+ HANDLE_INHERIT_AND_INITIAL(textAlign, TextAlign)
if (!primitiveValue) return;
if (primitiveValue->getIdent())
style->setTextAlign( (ETextAlign) (primitiveValue->getIdent() - CSS_VAL__KHTML_AUTO) );
@@ -2740,12 +2826,22 @@ void CSSStyleSelector::applyRule( int id
Length right;
Length bottom;
Length left;
- if ( value->cssValueType() == CSSValue::CSS_INHERIT ) {
- top = parentStyle->clipTop();
- right = parentStyle->clipRight();
- bottom = parentStyle->clipBottom();
- left = parentStyle->clipLeft();
- } else if ( !primitiveValue ) {
+ bool hasClip = true;
+ if (isInherit) {
+ if (parentStyle->hasClip()) {
+ top = parentStyle->clipTop();
+ right = parentStyle->clipRight();
+ bottom = parentStyle->clipBottom();
+ left = parentStyle->clipLeft();
+ }
+ else {
+ hasClip = false;
+ top = right = bottom = left = Length();
+ }
+ } else if (isInitial) {
+ hasClip = false;
+ top = right = bottom = left = Length();
+ } else if ( !primitiveValue ) {
break;
} else if ( primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_RECT ) {
RectImpl *rect = primitiveValue->getRectValue();
@@ -2763,8 +2859,8 @@ void CSSStyleSelector::applyRule( int id
// qDebug("setting clip right to %d", right.value );
// qDebug("setting clip bottom to %d", bottom.value );
// qDebug("setting clip left to %d", left.value );
- style->setClip( top, right, bottom, left );
- style->setHasClip();
+ style->setClip(top, right, bottom, left);
+ style->setHasClip(hasClip);
// rect, ident
break;
@@ -2780,6 +2876,12 @@ void CSSStyleSelector::applyRule( int id
style->styleType()==RenderStyle::AFTER))
break;
+ if (isInitial) {
+ if (style->contentData())
+ style->contentData()->clearContent();
+ return;
+ }
+
if(!value->isValueList()) return;
CSSValueListImpl *list = static_cast<CSSValueListImpl *>(value);
int len = list->length();
@@ -2819,8 +2921,7 @@ void CSSStyleSelector::applyRule( int id
case CSS_PROP_FONT_FAMILY:
// list of strings and ids
{
- if(value->cssValueType() == CSSValue::CSS_INHERIT) {
- if (!parentNode) return;
+ if (isInherit) {
FontDef parentFontDef = parentStyle->htmlFont().fontDef;
FontDef fontDef = style->htmlFont().fontDef;
fontDef.genericFamily = parentFontDef.genericFamily;
@@ -2829,6 +2930,15 @@ void CSSStyleSelector::applyRule( int id
fontDirty = true;
return;
}
+ else if (isInitial) {
+ FontDef fontDef = style->htmlFont().fontDef;
+ FontDef initialDef = FontDef();
+ fontDef.genericFamily = initialDef.genericFamily;
+ fontDef.family = initialDef.firstFamily();
+ if (style->setFontDef(fontDef))
+ fontDirty = true;
+ return;
+ }
if (!value->isValueList()) return;
FontDef fontDef = style->htmlFont().fontDef;
@@ -2900,8 +3010,8 @@ void CSSStyleSelector::applyRule( int id
break;
case CSS_PROP_TEXT_DECORATION: {
// list of ident
- HANDLE_INHERIT(textDecoration, TextDecoration)
- int t = TDNONE;
+ HANDLE_INHERIT_AND_INITIAL(textDecoration, TextDecoration)
+ int t = RenderStyle::initialTextDecoration();
if(primitiveValue && primitiveValue->getIdent() == CSS_VAL_NONE) {
// do nothing
} else {
@@ -2935,7 +3045,7 @@ void CSSStyleSelector::applyRule( int id
break;
}
case CSS_PROP__KHTML_FLOW_MODE:
- HANDLE_INHERIT(flowAroundFloats, FlowAroundFloats)
+ HANDLE_INHERIT_AND_INITIAL(flowAroundFloats, FlowAroundFloats)
if (!primitiveValue) return;
if (primitiveValue->getIdent()) {
style->setFlowAroundFloats( primitiveValue->getIdent() == CSS_VAL__KHTML_AROUND_FLOATS );
@@ -2945,89 +3055,140 @@ void CSSStyleSelector::applyRule( int id
// shorthand properties
case CSS_PROP_BACKGROUND:
- if (value->cssValueType() != CSSValue::CSS_INHERIT || !parentNode) return;
- style->setBackgroundColor(parentStyle->backgroundColor());
- style->setBackgroundImage(parentStyle->backgroundImage());
- style->setBackgroundRepeat(parentStyle->backgroundRepeat());
- style->setBackgroundAttachment(parentStyle->backgroundAttachment());
- style->setBackgroundXPosition(parentStyle->backgroundXPosition());
- style->setBackgroundYPosition(parentStyle->backgroundYPosition());
+ if (isInherit) {
+ style->setBackgroundColor(parentStyle->backgroundColor());
+ style->setBackgroundImage(parentStyle->backgroundImage());
+ style->setBackgroundRepeat(parentStyle->backgroundRepeat());
+ style->setBackgroundAttachment(parentStyle->backgroundAttachment());
+ style->setBackgroundXPosition(parentStyle->backgroundXPosition());
+ style->setBackgroundYPosition(parentStyle->backgroundYPosition());
+ }
+ else if (isInitial) {
+ style->setBackgroundColor(QColor());
+ style->setBackgroundImage(RenderStyle::initialBackgroundImage());
+ style->setBackgroundRepeat(RenderStyle::initialBackgroundRepeat());
+ style->setBackgroundAttachment(RenderStyle::initialBackgroundAttachment());
+ style->setBackgroundXPosition(RenderStyle::initialBackgroundXPosition());
+ style->setBackgroundYPosition(RenderStyle::initialBackgroundYPosition());
+ }
break;
case CSS_PROP_BORDER:
case CSS_PROP_BORDER_STYLE:
case CSS_PROP_BORDER_WIDTH:
case CSS_PROP_BORDER_COLOR:
- if(value->cssValueType() != CSSValue::CSS_INHERIT || !parentNode) return;
-
- if(id == CSS_PROP_BORDER || id == CSS_PROP_BORDER_COLOR)
+ if (id == CSS_PROP_BORDER || id == CSS_PROP_BORDER_COLOR)
{
- style->setBorderTopColor(parentStyle->borderTopColor());
- style->setBorderBottomColor(parentStyle->borderBottomColor());
- style->setBorderLeftColor(parentStyle->borderLeftColor());
- style->setBorderRightColor(parentStyle->borderRightColor());
+ if (isInherit) {
+ style->setBorderTopColor(parentStyle->borderTopColor());
+ style->setBorderBottomColor(parentStyle->borderBottomColor());
+ style->setBorderLeftColor(parentStyle->borderLeftColor());
+ style->setBorderRightColor(parentStyle->borderRightColor());
+ }
+ else if (isInitial) {
+ style->setBorderTopColor(QColor()); // Reset to invalid color so currentColor is used instead.
+ style->setBorderBottomColor(QColor());
+ style->setBorderLeftColor(QColor());
+ style->setBorderRightColor(QColor());
+ }
+ }
+ if (id == CSS_PROP_BORDER || id == CSS_PROP_BORDER_STYLE)
+ {
+ if (isInherit) {
+ style->setBorderTopStyle(parentStyle->borderTopStyle());
+ style->setBorderBottomStyle(parentStyle->borderBottomStyle());
+ style->setBorderLeftStyle(parentStyle->borderLeftStyle());
+ style->setBorderRightStyle(parentStyle->borderRightStyle());
+ }
+ else if (isInitial) {
+ style->setBorderTopStyle(RenderStyle::initialBorderStyle());
+ style->setBorderBottomStyle(RenderStyle::initialBorderStyle());
+ style->setBorderLeftStyle(RenderStyle::initialBorderStyle());
+ style->setBorderRightStyle(RenderStyle::initialBorderStyle());
+ }
+ }
+ if (id == CSS_PROP_BORDER || id == CSS_PROP_BORDER_WIDTH)
+ {
+ if (isInherit) {
+ style->setBorderTopWidth(parentStyle->borderTopWidth());
+ style->setBorderBottomWidth(parentStyle->borderBottomWidth());
+ style->setBorderLeftWidth(parentStyle->borderLeftWidth());
+ style->setBorderRightWidth(parentStyle->borderRightWidth());
+ }
+ else if (isInitial) {
+ style->setBorderTopWidth(RenderStyle::initialBorderWidth());
+ style->setBorderBottomWidth(RenderStyle::initialBorderWidth());
+ style->setBorderLeftWidth(RenderStyle::initialBorderWidth());
+ style->setBorderRightWidth(RenderStyle::initialBorderWidth());
+ }
}
- if(id == CSS_PROP_BORDER || id == CSS_PROP_BORDER_STYLE)
- {
+ return;
+ case CSS_PROP_BORDER_TOP:
+ if (isInherit) {
+ style->setBorderTopColor(parentStyle->borderTopColor());
style->setBorderTopStyle(parentStyle->borderTopStyle());
- style->setBorderBottomStyle(parentStyle->borderBottomStyle());
- style->setBorderLeftStyle(parentStyle->borderLeftStyle());
- style->setBorderRightStyle(parentStyle->borderRightStyle());
- }
- if(id == CSS_PROP_BORDER || id == CSS_PROP_BORDER_WIDTH)
- {
style->setBorderTopWidth(parentStyle->borderTopWidth());
- style->setBorderBottomWidth(parentStyle->borderBottomWidth());
- style->setBorderLeftWidth(parentStyle->borderLeftWidth());
- style->setBorderRightWidth(parentStyle->borderRightWidth());
}
- return;
- case CSS_PROP_BORDER_TOP:
- if(value->cssValueType() != CSSValue::CSS_INHERIT || !parentNode) return;
- style->setBorderTopColor(parentStyle->borderTopColor());
- style->setBorderTopStyle(parentStyle->borderTopStyle());
- style->setBorderTopWidth(parentStyle->borderTopWidth());
+ else if (isInitial)
+ style->resetBorderTop();
return;
case CSS_PROP_BORDER_RIGHT:
- if(value->cssValueType() != CSSValue::CSS_INHERIT || !parentNode) return;
- style->setBorderRightColor(parentStyle->borderRightColor());
- style->setBorderRightStyle(parentStyle->borderRightStyle());
- style->setBorderRightWidth(parentStyle->borderRightWidth());
+ if (isInherit) {
+ style->setBorderRightColor(parentStyle->borderRightColor());
+ style->setBorderRightStyle(parentStyle->borderRightStyle());
+ style->setBorderRightWidth(parentStyle->borderRightWidth());
+ }
+ else if (isInitial)
+ style->resetBorderRight();
return;
case CSS_PROP_BORDER_BOTTOM:
- if(value->cssValueType() != CSSValue::CSS_INHERIT || !parentNode) return;
- style->setBorderBottomColor(parentStyle->borderBottomColor());
- style->setBorderBottomStyle(parentStyle->borderBottomStyle());
- style->setBorderBottomWidth(parentStyle->borderBottomWidth());
+ if (isInherit) {
+ style->setBorderBottomColor(parentStyle->borderBottomColor());
+ style->setBorderBottomStyle(parentStyle->borderBottomStyle());
+ style->setBorderBottomWidth(parentStyle->borderBottomWidth());
+ }
+ else if (isInitial)
+ style->resetBorderBottom();
return;
case CSS_PROP_BORDER_LEFT:
- if(value->cssValueType() != CSSValue::CSS_INHERIT || !parentNode) return;
- style->setBorderLeftColor(parentStyle->borderLeftColor());
- style->setBorderLeftStyle(parentStyle->borderLeftStyle());
- style->setBorderLeftWidth(parentStyle->borderLeftWidth());
+ if (isInherit) {
+ style->setBorderLeftColor(parentStyle->borderLeftColor());
+ style->setBorderLeftStyle(parentStyle->borderLeftStyle());
+ style->setBorderLeftWidth(parentStyle->borderLeftWidth());
+ }
+ else if (isInitial)
+ style->resetBorderLeft();
return;
case CSS_PROP_MARGIN:
- if(value->cssValueType() != CSSValue::CSS_INHERIT || !parentNode) return;
- style->setMarginTop(parentStyle->marginTop());
- style->setMarginBottom(parentStyle->marginBottom());
- style->setMarginLeft(parentStyle->marginLeft());
- style->setMarginRight(parentStyle->marginRight());
+ if (isInherit) {
+ style->setMarginTop(parentStyle->marginTop());
+ style->setMarginBottom(parentStyle->marginBottom());
+ style->setMarginLeft(parentStyle->marginLeft());
+ style->setMarginRight(parentStyle->marginRight());
+ }
+ else if (isInitial)
+ style->resetMargin();
return;
case CSS_PROP_PADDING:
- if(value->cssValueType() != CSSValue::CSS_INHERIT || !parentNode) return;
- style->setPaddingTop(parentStyle->paddingTop());
- style->setPaddingBottom(parentStyle->paddingBottom());
- style->setPaddingLeft(parentStyle->paddingLeft());
- style->setPaddingRight(parentStyle->paddingRight());
+ if (isInherit) {
+ style->setPaddingTop(parentStyle->paddingTop());
+ style->setPaddingBottom(parentStyle->paddingBottom());
+ style->setPaddingLeft(parentStyle->paddingLeft());
+ style->setPaddingRight(parentStyle->paddingRight());
+ }
+ else if (isInitial)
+ style->resetPadding();
return;
-
case CSS_PROP_FONT:
- if ( value->cssValueType() == CSSValue::CSS_INHERIT ) {
- if ( !parentNode )
- return;
+ if (isInherit) {
FontDef fontDef = parentStyle->htmlFont().fontDef;
style->setLineHeight( parentStyle->lineHeight() );
if (style->setFontDef( fontDef ))
fontDirty = true;
+ } else if (isInitial) {
+ FontDef fontDef;
+ style->setLineHeight(RenderStyle::initialLineHeight());
+ if (style->setFontDef( fontDef ))
+ fontDirty = true;
} else if ( value->isFontValue() ) {
FontValueImpl *font = static_cast<FontValueImpl *>(value);
if ( !font->style || !font->variant || !font->weight ||
@@ -3050,21 +3211,30 @@ void CSSStyleSelector::applyRule( int id
return;
case CSS_PROP_LIST_STYLE:
- if (value->cssValueType() != CSSValue::CSS_INHERIT || !parentNode) return;
- style->setListStyleType(parentStyle->listStyleType());
- style->setListStyleImage(parentStyle->listStyleImage());
- style->setListStylePosition(parentStyle->listStylePosition());
+ if (isInherit) {
+ style->setListStyleType(parentStyle->listStyleType());
+ style->setListStyleImage(parentStyle->listStyleImage());
+ style->setListStylePosition(parentStyle->listStylePosition());
+ }
+ else if (isInitial) {
+ style->setListStyleType(RenderStyle::initialListStyleType());
+ style->setListStyleImage(RenderStyle::initialListStyleImage());
+ style->setListStylePosition(RenderStyle::initialListStylePosition());
+ }
break;
case CSS_PROP_OUTLINE:
- if (value->cssValueType() != CSSValue::CSS_INHERIT || !parentNode) return;
- style->setOutlineWidth(parentStyle->outlineWidth());
- style->setOutlineColor(parentStyle->outlineColor());
- style->setOutlineStyle(parentStyle->outlineStyle());
+ if (isInherit) {
+ style->setOutlineWidth(parentStyle->outlineWidth());
+ style->setOutlineColor(parentStyle->outlineColor());
+ style->setOutlineStyle(parentStyle->outlineStyle());
+ }
+ else if (isInitial)
+ style->resetOutline();
break;
// CSS3 Properties
case CSS_PROP_OUTLINE_OFFSET: {
- HANDLE_INHERIT(outlineOffset, OutlineOffset)
+ HANDLE_INHERIT_AND_INITIAL(outlineOffset, OutlineOffset)
int offset = primitiveValue->computeLength(style, paintDeviceMetrics);
if (offset < 0) return;
@@ -3074,11 +3244,14 @@ void CSSStyleSelector::applyRule( int id
}
case CSS_PROP_TEXT_SHADOW: {
- if (value->cssValueType() == CSSValue::CSS_INHERIT) {
- if (!parentNode) return;
+ if (isInherit) {
style->setTextShadow(parentStyle->textShadow() ? new ShadowData(*parentStyle->textShadow()) : 0);
return;
}
+ else if (isInitial) {
+ style->setTextShadow(0);
+ return;
+ }
if (primitiveValue) { // none
style->setTextShadow(0);
@@ -3109,7 +3282,7 @@ void CSSStyleSelector::applyRule( int id
return;
}
case CSS_PROP_OPACITY:
- HANDLE_INHERIT(opacity, Opacity)
+ HANDLE_INHERIT_AND_INITIAL(opacity, Opacity)
if (!primitiveValue || primitiveValue->primitiveType() != CSSPrimitiveValue::CSS_NUMBER)
return; // Error case.
@@ -3117,7 +3290,7 @@ void CSSStyleSelector::applyRule( int id
style->setOpacity(kMin(1.0f, kMax(0, primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_NUMBER))));
return;
case CSS_PROP__KHTML_BOX_ALIGN:
- HANDLE_INHERIT(boxAlign, BoxAlign)
+ HANDLE_INHERIT_AND_INITIAL(boxAlign, BoxAlign)
if (!primitiveValue) return;
switch (primitiveValue->getIdent()) {
case CSS_VAL_STRETCH:
@@ -3140,7 +3313,7 @@ void CSSStyleSelector::applyRule( int id
}
return;
case CSS_PROP__KHTML_BOX_DIRECTION:
- HANDLE_INHERIT(boxDirection, BoxDirection)
+ HANDLE_INHERIT_AND_INITIAL(boxDirection, BoxDirection)
if (!primitiveValue) return;
if (primitiveValue->getIdent() == CSS_VAL_NORMAL)
style->setBoxDirection(BNORMAL);
@@ -3148,7 +3321,7 @@ void CSSStyleSelector::applyRule( int id
style->setBoxDirection(BREVERSE);
return;
case CSS_PROP__KHTML_BOX_LINES:
- HANDLE_INHERIT(boxLines, BoxLines)
+ HANDLE_INHERIT_AND_INITIAL(boxLines, BoxLines)
if(!primitiveValue) return;
if (primitiveValue->getIdent() == CSS_VAL_SINGLE)
style->setBoxLines(SINGLE);
@@ -3156,7 +3329,7 @@ void CSSStyleSelector::applyRule( int id
style->setBoxLines(MULTIPLE);
return;
case CSS_PROP__KHTML_BOX_ORIENT:
- HANDLE_INHERIT(boxOrient, BoxOrient)
+ HANDLE_INHERIT_AND_INITIAL(boxOrient, BoxOrient)
if (!primitiveValue) return;
if (primitiveValue->getIdent() == CSS_VAL_HORIZONTAL ||
primitiveValue->getIdent() == CSS_VAL_INLINE_AXIS)
@@ -3165,7 +3338,7 @@ void CSSStyleSelector::applyRule( int id
style->setBoxOrient(VERTICAL);
return;
case CSS_PROP__KHTML_BOX_PACK:
- HANDLE_INHERIT(boxPack, BoxPack)
+ HANDLE_INHERIT_AND_INITIAL(boxPack, BoxPack)
if (!primitiveValue) return;
switch (primitiveValue->getIdent()) {
case CSS_VAL_START:
@@ -3185,19 +3358,19 @@ void CSSStyleSelector::applyRule( int id
}
return;
case CSS_PROP__KHTML_BOX_FLEX:
- HANDLE_INHERIT(boxFlex, BoxFlex)
+ HANDLE_INHERIT_AND_INITIAL(boxFlex, BoxFlex)
if (!primitiveValue || primitiveValue->primitiveType() != CSSPrimitiveValue::CSS_NUMBER)
return; // Error case.
style->setBoxFlex(primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_NUMBER));
return;
case CSS_PROP__KHTML_BOX_FLEX_GROUP:
- HANDLE_INHERIT(boxFlexGroup, BoxFlexGroup)
+ HANDLE_INHERIT_AND_INITIAL(boxFlexGroup, BoxFlexGroup)
if (!primitiveValue || primitiveValue->primitiveType() != CSSPrimitiveValue::CSS_NUMBER)
return; // Error case.
style->setBoxFlexGroup((unsigned int)(primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_NUMBER)));
return;
case CSS_PROP__KHTML_BOX_ORDINAL_GROUP:
- HANDLE_INHERIT(boxOrdinalGroup, BoxOrdinalGroup)
+ HANDLE_INHERIT_AND_INITIAL(boxOrdinalGroup, BoxOrdinalGroup)
if (!primitiveValue || primitiveValue->primitiveType() != CSSPrimitiveValue::CSS_NUMBER)
return; // Error case.
style->setBoxOrdinalGroup((unsigned int)(primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_NUMBER)));
@@ -3211,7 +3384,7 @@ void CSSStyleSelector::applyRule( int id
style->setMarqueeBehavior(parentStyle->marqueeBehavior());
break;
case CSS_PROP__KHTML_MARQUEE_REPETITION: {
- HANDLE_INHERIT(marqueeLoopCount, MarqueeLoopCount)
+ HANDLE_INHERIT_AND_INITIAL(marqueeLoopCount, MarqueeLoopCount)
if (!primitiveValue) return;
if (primitiveValue->getIdent() == CSS_VAL_INFINITE)
style->setMarqueeLoopCount(-1); // -1 means repeat forever.
@@ -3220,7 +3393,7 @@ void CSSStyleSelector::applyRule( int id
break;
}
case CSS_PROP__KHTML_MARQUEE_SPEED: {
- HANDLE_INHERIT(marqueeSpeed, MarqueeSpeed)
+ HANDLE_INHERIT_AND_INITIAL(marqueeSpeed, MarqueeSpeed)
if (!primitiveValue) return;
if (primitiveValue->getIdent()) {
switch (primitiveValue->getIdent())
@@ -3245,7 +3418,7 @@ void CSSStyleSelector::applyRule( int id
break;
}
case CSS_PROP__KHTML_MARQUEE_INCREMENT: {
- HANDLE_INHERIT(marqueeIncrement, MarqueeIncrement)
+ HANDLE_INHERIT_AND_INITIAL(marqueeIncrement, MarqueeIncrement)
if (!primitiveValue) return;
if (primitiveValue->getIdent()) {
switch (primitiveValue->getIdent())
@@ -3270,11 +3443,7 @@ void CSSStyleSelector::applyRule( int id
break;
}
case CSS_PROP__KHTML_MARQUEE_STYLE: {
- if (value->cssValueType() == CSSValue::CSS_INHERIT) {
- if(!parentNode) return;
- style->setMarqueeBehavior(parentStyle->marqueeBehavior());
- return;
- }
+ HANDLE_INHERIT_AND_INITIAL(marqueeBehavior, MarqueeBehavior)
if (!primitiveValue || !primitiveValue->getIdent()) return;
switch (primitiveValue->getIdent())
{
@@ -3294,11 +3463,7 @@ void CSSStyleSelector::applyRule( int id
break;
}
case CSS_PROP__KHTML_MARQUEE_DIRECTION: {
- if (value->cssValueType() == CSSValue::CSS_INHERIT) {
- if(!parentNode) return;
- style->setMarqueeDirection(parentStyle->marqueeDirection());
- return;
- }
+ HANDLE_INHERIT_AND_INITIAL(marqueeDirection, MarqueeDirection)
if (!primitiveValue || !primitiveValue->getIdent()) return;
switch (primitiveValue->getIdent())
{
Index: khtml/css/cssvalues.in
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/css/cssvalues.in,v
retrieving revision 1.14
diff -u -p -r1.14 khtml/css/cssvalues.in
--- khtml/css/cssvalues.in 2003/11/03 18:22:29 1.14
+++ khtml/css/cssvalues.in 2003/11/12 08:45:31
@@ -10,6 +10,7 @@
# and produce incorrect results.
#
inherit
+initial
#
# CSS_PROP_OUTLINE_STYLE
# CSS_PROP_BORDER_TOP_STYLE
Index: khtml/dom/css_value.h
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/dom/css_value.h,v
retrieving revision 1.4
diff -u -p -r1.4 khtml/dom/css_value.h
--- khtml/dom/css_value.h 2003/02/25 20:00:15 1.4
+++ khtml/dom/css_value.h 2003/11/12 08:45:32
@@ -256,7 +256,8 @@ public:
CSS_INHERIT = 0,
CSS_PRIMITIVE_VALUE = 1,
CSS_VALUE_LIST = 2,
- CSS_CUSTOM = 3
+ CSS_CUSTOM = 3,
+ CSS_INITIAL = 4
};
/**
Index: khtml/rendering/render_style.cpp
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/rendering/render_style.cpp,v
retrieving revision 1.36
diff -u -p -r1.36 khtml/rendering/render_style.cpp
--- khtml/rendering/render_style.cpp 2003/10/31 01:51:46 1.36
+++ khtml/rendering/render_style.cpp 2003/11/12 08:45:35
@@ -55,14 +55,8 @@ StyleBoxData::StyleBoxData()
: z_index( 0 ), z_auto(true)
{
// Initialize our min/max widths/heights.
- min_width.type = Fixed;
- min_width.value = 0;
- min_height.type = Fixed;
- min_height.value = 0;
- max_width.type = Fixed;
- max_width.value = UNDEFINED;
- max_height.type = Fixed;
- max_height.value = UNDEFINED;
+ min_width = min_height = RenderStyle::initialMinSize();
+ max_width = max_height = RenderStyle::initialMaxSize();
}
StyleBoxData::StyleBoxData(const StyleBoxData& o )
@@ -88,7 +82,9 @@ bool StyleBoxData::operator==(const Styl
}
StyleVisualData::StyleVisualData()
- : hasClip(false), textDecoration(TDNONE), colspan( 1 ), counter_increment( 0 ), counter_reset( 0 ),
+ : hasClip(false),
+ textDecoration(RenderStyle::initialTextDecoration()),
+ colspan( 1 ), counter_increment( 0 ), counter_reset( 0 ),
palette( QApplication::palette() )
{
}
@@ -107,7 +103,7 @@ StyleVisualData::StyleVisualData(const S
StyleBackgroundData::StyleBackgroundData()
- : image( 0 )
+ : image( RenderStyle::initialBackgroundImage() )
{
}
@@ -131,12 +127,11 @@ bool StyleBackgroundData::operator==(con
StyleMarqueeData::StyleMarqueeData()
{
- increment.type = Fixed;
- increment.value = 6; // 6 pixels is the WinIE default.
- speed = 85; // 85msec is the WinIE default.
- direction = MAUTO; // Direction is auto-determined by overflow by default.
- behavior = MSCROLL; // Scrolling marquee is the default.
- loops = -1; // Loop forever by default. Matches WinIE.
+ increment = RenderStyle::initialMarqueeIncrement();
+ speed = RenderStyle::initialMarqueeSpeed();
+ direction = RenderStyle::initialMarqueeDirection();
+ behavior = RenderStyle::initialMarqueeBehavior();
+ loops = RenderStyle::initialMarqueeLoopCount();
}
StyleMarqueeData::StyleMarqueeData(const StyleMarqueeData& o)
@@ -153,13 +148,13 @@ bool StyleMarqueeData::operator==(const
StyleFlexibleBoxData::StyleFlexibleBoxData()
: Shared<StyleFlexibleBoxData>()
{
- flex = 0.0f;
- flex_group = 1;
- ordinal_group = 1;
- align = BSTRETCH;
- pack = BSTART;
- orient = HORIZONTAL;
- lines = SINGLE;
+ flex = RenderStyle::initialBoxFlex();
+ flex_group = RenderStyle::initialBoxFlexGroup();
+ ordinal_group = RenderStyle::initialBoxOrdinalGroup();
+ align = RenderStyle::initialBoxAlign();
+ pack = RenderStyle::initialBoxPack();
+ orient = RenderStyle::initialBoxOrient();
+ lines = RenderStyle::initialBoxLines();
flexed_height = -1;
}
@@ -185,7 +180,7 @@ bool StyleFlexibleBoxData::operator==(co
}
StyleCSS3NonInheritedData::StyleCSS3NonInheritedData()
-:Shared<StyleCSS3NonInheritedData>(), opacity(1.0f)
+:Shared<StyleCSS3NonInheritedData>(), opacity(RenderStyle::initialOpacity())
{
}
@@ -226,10 +221,13 @@ bool StyleCSS3InheritedData::shadowDataE
}
StyleInheritedData::StyleInheritedData()
- : indent( Fixed ), line_height( -100, Percent ), style_image( 0 ),
- cursor_image( 0 ), font(), color( Qt::black ),
- horizontal_border_spacing( 0 ), vertical_border_spacing( 0 ), widows( 2 ), orphans( 2 ),
- page_break_inside(PBAUTO)
+ : indent( RenderStyle::initialTextIndent() ), line_height( RenderStyle::initialLineHeight() ),
+ style_image( RenderStyle::initialListStyleImage() ),
+ cursor_image( 0 ), font(), color( RenderStyle::initialColor() ),
+ horizontal_border_spacing( RenderStyle::initialHorizontalBorderSpacing() ),
+ vertical_border_spacing( RenderStyle::initialVerticalBorderSpacing() ),
+ widows( RenderStyle::initialWidows() ), orphans( RenderStyle::initialOrphans() ),
+ page_break_inside( RenderStyle::initialPageBreak() )
{
}
@@ -532,7 +530,6 @@ RenderStyle::Diff RenderStyle::diff( con
!(inherited_flags._text_transform == other->inherited_flags._text_transform) ||
!(inherited_flags._direction == other->inherited_flags._direction) ||
!(inherited_flags._white_space == other->inherited_flags._white_space) ||
- !(inherited_flags._font_variant == other->inherited_flags._font_variant) ||
!(noninherited_flags._clear == other->noninherited_flags._clear)
)
return Layout;
@@ -576,6 +573,7 @@ RenderStyle::Diff RenderStyle::diff( con
!(noninherited_flags._bg_repeat == other->noninherited_flags._bg_repeat) ||
!(noninherited_flags._bg_attachment == other->noninherited_flags._bg_attachment) ||
!(inherited_flags._text_decorations == other->inherited_flags._text_decorations) ||
+ !(inherited_flags._should_correct_text_color == other->inherited_flags._should_correct_text_color) ||
!(surround->border == other->surround->border) ||
*background.get() != *other->background.get() ||
!(visual->clip == other->visual->clip) ||
Index: khtml/rendering/render_style.h
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/rendering/render_style.h,v
retrieving revision 1.43
diff -u -p -r1.43 khtml/rendering/render_style.h
--- khtml/rendering/render_style.h 2003/11/09 23:41:24 1.43
+++ khtml/rendering/render_style.h 2003/11/12 08:45:37
@@ -200,7 +200,7 @@ public:
BorderValue()
{
width = 3; // medium is default value
- style = BNONE;
+ style = BNONE;
}
QColor color;
unsigned short width : 12;
@@ -241,7 +241,7 @@ struct CollapsedBorderValue
CollapsedBorderValue() :border(0), precedence(BOFF) {}
CollapsedBorderValue(const BorderValue* b, EBorderPrecedence p) :border(b), precedence(p) {}
- int width() const { return border ? border->width : 0; }
+ int width() const { return border && border->nonZero() ? border->width : 0; }
EBorderStyle style() const { return border ? border->style : BHIDDEN; }
bool exists() const { return border; }
QColor color() const { return border ? border->color : QColor(); }
@@ -620,10 +620,6 @@ enum ECursor {
CURSOR_S_RESIZE, CURSOR_W_RESIZE, CURSOR_TEXT, CURSOR_WAIT, CURSOR_HELP
};
-enum EFontVariant {
- FVNORMAL, SMALL_CAPS
-};
-
enum ContentType {
CONTENT_NONE, CONTENT_OBJECT, CONTENT_TEXT, CONTENT_COUNTER
};
@@ -688,11 +684,12 @@ protected:
(_direction == other._direction) &&
(_border_collapse == other._border_collapse) &&
(_white_space == other._white_space) &&
- (_font_variant == other._font_variant) &&
(_box_direction == other._box_direction) &&
(_visuallyOrdered == other._visuallyOrdered) &&
- (_htmlHacks == other._htmlHacks);
+ (_htmlHacks == other._htmlHacks) &&
+ (_should_correct_text_color == other._should_correct_text_color);
}
+
bool operator!=( const InheritedFlags &other ) const {
return !(*this == other);
}
@@ -709,8 +706,7 @@ protected:
EDirection _direction : 1;
bool _border_collapse : 1 ;
EWhiteSpace _white_space : 2;
- EFontVariant _font_variant : 1;
- EBoxDirection _box_direction : 1; // CSS3 box_direction property (flexible box layout module)
+ EBoxDirection _box_direction : 1; // CSS3 box_direction property (flexible box layout module)
// non CSS2 inherited
bool _visuallyOrdered : 1;
bool _htmlHacks :1;
@@ -791,41 +787,40 @@ protected:
protected:
void setBitDefaults()
{
- inherited_flags._empty_cells = SHOW;
- inherited_flags._caption_side = CAPTOP;
- inherited_flags._list_style_type = DISC;
- inherited_flags._list_style_position = OUTSIDE;
- inherited_flags._visibility = VISIBLE;
- inherited_flags._text_align = TAAUTO;
- inherited_flags._text_transform = TTNONE;
- inherited_flags._text_decorations = TDNONE;
- inherited_flags._cursor_style = CURSOR_AUTO;
- inherited_flags._direction = LTR;
- inherited_flags._border_collapse = false;
- inherited_flags._white_space = NORMAL;
- inherited_flags._font_variant = FVNORMAL;
+ inherited_flags._empty_cells = initialEmptyCells();
+ inherited_flags._caption_side = initialCaptionSide();
+ inherited_flags._list_style_type = initialListStyleType();
+ inherited_flags._list_style_position = initialListStylePosition();
+ inherited_flags._visibility = initialVisibility();
+ inherited_flags._text_align = initialTextAlign();
+ inherited_flags._text_transform = initialTextTransform();
+ inherited_flags._text_decorations = initialTextDecoration();
+ inherited_flags._cursor_style = initialCursor();
+ inherited_flags._direction = initialDirection();
+ inherited_flags._border_collapse = initialBorderCollapse();
+ inherited_flags._white_space = initialWhiteSpace();
inherited_flags._visuallyOrdered = false;
inherited_flags._htmlHacks=false;
- inherited_flags._box_direction = BNORMAL;
+ inherited_flags._box_direction = initialBoxDirection();
inherited_flags._should_correct_text_color = false;
-
- noninherited_flags._effectiveDisplay = noninherited_flags._originalDisplay = INLINE;
- noninherited_flags._bg_repeat = REPEAT;
- noninherited_flags._bg_attachment = true;
- noninherited_flags._overflow = OVISIBLE;
- noninherited_flags._vertical_align = BASELINE;
- noninherited_flags._clear = CNONE;
- noninherited_flags._position = STATIC;
- noninherited_flags._floating = FNONE;
- noninherited_flags._table_layout = TAUTO;
- noninherited_flags._page_break_before = PBAUTO;
- noninherited_flags._page_break_after = PBAUTO;
- noninherited_flags._flowAroundFloats=false;
+
+ noninherited_flags._effectiveDisplay = noninherited_flags._originalDisplay = initialDisplay();
+ noninherited_flags._bg_repeat = initialBackgroundRepeat();
+ noninherited_flags._bg_attachment = initialBackgroundAttachment();
+ noninherited_flags._overflow = initialOverflow();
+ noninherited_flags._vertical_align = initialVerticalAlign();
+ noninherited_flags._clear = initialClear();
+ noninherited_flags._position = initialPosition();
+ noninherited_flags._floating = initialFloating();
+ noninherited_flags._table_layout = initialTableLayout();
+ noninherited_flags._page_break_before = initialPageBreak();
+ noninherited_flags._page_break_after = initialPageBreak();
+ noninherited_flags._flowAroundFloats = initialFlowAroundFloats();
noninherited_flags._styleType = NOPSEUDO;
noninherited_flags._affectedByHover = false;
noninherited_flags._affectedByActive = false;
noninherited_flags._pseudoBits = 0;
- noninherited_flags._unicodeBidi = UBNormal;
+ noninherited_flags._unicodeBidi = initialUnicodeBidi();
}
public:
@@ -889,7 +884,7 @@ public:
const BorderValue& borderRight() const { return surround->border.right; }
const BorderValue& borderTop() const { return surround->border.top; }
const BorderValue& borderBottom() const { return surround->border.bottom; }
-
+
unsigned short borderLeftWidth() const
{ if( surround->border.left.style == BNONE) return 0; return surround->border.left.width; }
EBorderStyle borderLeftStyle() const { return surround->border.left.style; }
@@ -989,8 +984,7 @@ public:
Length paddingRight() const { return surround->padding.right; }
ECursor cursor() const { return inherited_flags._cursor_style; }
- EFontVariant fontVariant() { return inherited_flags._font_variant; }
-
+
CachedImage *cursorImage() const { return inherited->cursor_image; }
short widows() const { return inherited->widows; }
@@ -1041,6 +1035,12 @@ public:
void setMinHeight(Length v) { SET_VAR(box,min_height,v) }
void setMaxHeight(Length v) { SET_VAR(box,max_height,v) }
+ void resetBorderTop() { SET_VAR(surround, border.top, BorderValue()) }
+ void resetBorderRight() { SET_VAR(surround, border.right, BorderValue()) }
+ void resetBorderBottom() { SET_VAR(surround, border.bottom, BorderValue()) }
+ void resetBorderLeft() { SET_VAR(surround, border.left, BorderValue()) }
+ void resetOutline() { SET_VAR(background, outline, OutlineValue()) }
+
void setBorderLeftWidth(unsigned short v) { SET_VAR(surround,border.left.width,v) }
void setBorderLeftStyle(EBorderStyle v) { SET_VAR(surround,border.left.style,v) }
void setBorderLeftColor(const QColor & v) { SET_VAR(surround,border.left.color,v) }
@@ -1062,7 +1062,7 @@ public:
void setVerticalAlign(EVerticalAlign v) { noninherited_flags._vertical_align = v; }
void setVerticalAlignLength(Length l) { SET_VAR(box, vertical_align, l ) }
- void setHasClip() { SET_VAR(visual,hasClip,true) }
+ void setHasClip(bool b = true) { SET_VAR(visual,hasClip,b) }
void setClipLeft(Length v) { SET_VAR(visual,clip.left,v) }
void setClipRight(Length v) { SET_VAR(visual,clip.right,v) }
void setClipTop(Length v) { SET_VAR(visual,clip.top,v) }
@@ -1120,18 +1120,19 @@ public:
void setListStyleImage(CachedImage *v) { SET_VAR(inherited,style_image,v)}
void setListStylePosition(EListStylePosition v) { inherited_flags._list_style_position = v; }
+ void resetMargin() { SET_VAR(surround, margin, LengthBox(Fixed)) }
void setMarginTop(Length v) { SET_VAR(surround,margin.top,v) }
void setMarginBottom(Length v) { SET_VAR(surround,margin.bottom,v) }
void setMarginLeft(Length v) { SET_VAR(surround,margin.left,v) }
void setMarginRight(Length v) { SET_VAR(surround,margin.right,v) }
+ void resetPadding() { SET_VAR(surround, padding, LengthBox(Variable)) }
void setPaddingTop(Length v) { SET_VAR(surround,padding.top,v) }
void setPaddingBottom(Length v) { SET_VAR(surround,padding.bottom,v) }
void setPaddingLeft(Length v) { SET_VAR(surround,padding.left,v) }
void setPaddingRight(Length v) { SET_VAR(surround,padding.right,v) }
void setCursor( ECursor c ) { inherited_flags._cursor_style = c; }
- void setFontVariant( EFontVariant f ) { inherited_flags._font_variant = f; }
void setCursorImage( CachedImage *v ) { SET_VAR(inherited,cursor_image,v) }
bool shouldCorrectTextColor() const { return inherited_flags._should_correct_text_color; }
@@ -1199,6 +1200,67 @@ public:
return originalDisplay() == INLINE || originalDisplay() == INLINE_BLOCK ||
originalDisplay() == INLINE_BOX || originalDisplay() == INLINE_TABLE;
}
+
+ // Initial values for all the properties
+ static bool initialBackgroundAttachment() { return true; }
+ static EBackgroundRepeat initialBackgroundRepeat() { return REPEAT; }
+ static bool initialBorderCollapse() { return false; }
+ static EBorderStyle initialBorderStyle() { return BNONE; }
+ static ECaptionSide initialCaptionSide() { return CAPTOP; }
+ static EClear initialClear() { return CNONE; }
+ static EDirection initialDirection() { return LTR; }
+ static EDisplay initialDisplay() { return INLINE; }
+ static EEmptyCell initialEmptyCells() { return SHOW; }
+ static EFloat initialFloating() { return FNONE; }
+ static EListStylePosition initialListStylePosition() { return OUTSIDE; }
+ static EListStyleType initialListStyleType() { return DISC; }
+ static EOverflow initialOverflow() { return OVISIBLE; }
+ static EPageBreak initialPageBreak() { return PBAUTO; }
+ static EPosition initialPosition() { return STATIC; }
+ static ETableLayout initialTableLayout() { return TAUTO; }
+ static EUnicodeBidi initialUnicodeBidi() { return UBNormal; }
+ static ETextTransform initialTextTransform() { return TTNONE; }
+ static EVisibility initialVisibility() { return VISIBLE; }
+ static EWhiteSpace initialWhiteSpace() { return NORMAL; }
+ static Length initialBackgroundXPosition() { return Length(); }
+ static Length initialBackgroundYPosition() { return Length(); }
+ static short initialHorizontalBorderSpacing() { return 0; }
+ static short initialVerticalBorderSpacing() { return 0; }
+ static ECursor initialCursor() { return CURSOR_AUTO; }
+ static QColor initialColor() { return Qt::black; }
+ static CachedImage* initialBackgroundImage() { return 0; }
+ static CachedImage* initialListStyleImage() { return 0; }
+ static unsigned short initialBorderWidth() { return 3; }
+ static int initialLetterWordSpacing() { return 0; }
+ static Length initialSize() { return Length(); }
+ static Length initialMinSize() { return Length(0, Fixed); }
+ static Length initialMaxSize() { return Length(UNDEFINED, Fixed); }
+ static Length initialOffset() { return Length(); }
+ static Length initialMargin() { return Length(Fixed); }
+ static Length initialPadding() { return Length(Variable); }
+ static Length initialTextIndent() { return Length(Fixed); }
+ static EVerticalAlign initialVerticalAlign() { return BASELINE; }
+ static int initialWidows() { return 2; }
+ static int initialOrphans() { return 2; }
+ static Length initialLineHeight() { return Length(-100, Percent); }
+ static ETextAlign initialTextAlign() { return TAAUTO; }
+ static ETextDecoration initialTextDecoration() { return TDNONE; }
+ static bool initialFlowAroundFloats() { return false; }
+ static int initialOutlineOffset() { return 0; }
+ static float initialOpacity() { return 1.0f; }
+ static EBoxAlignment initialBoxAlign() { return BSTRETCH; }
+ static EBoxDirection initialBoxDirection() { return BNORMAL; }
+ static EBoxLines initialBoxLines() { return SINGLE; }
+ static EBoxOrient initialBoxOrient() { return HORIZONTAL; }
+ static EBoxAlignment initialBoxPack() { return BSTART; }
+ static float initialBoxFlex() { return 0.0f; }
+ static int initialBoxFlexGroup() { return 1; }
+ static int initialBoxOrdinalGroup() { return 1; }
+ static int initialMarqueeLoopCount() { return -1; }
+ static int initialMarqueeSpeed() { return 85; }
+ static Length initialMarqueeIncrement() { return Length(6, Fixed); }
+ static EMarqueeBehavior initialMarqueeBehavior() { return MSCROLL; }
+ static EMarqueeDirection initialMarqueeDirection() { return MAUTO; }
};
-------------- next part --------------
More information about the Khtml-devel
mailing list