paged media
David Hyatt
hyatt at apple.com
Wed Oct 29 21:16:20 CET 2003
This patch adds all the paged media properties to the RenderStyle. I
don't do anything with the properties yet, but this patch gets them
mapped into the RenderStyle properly. I also removed some extraneous
copy constructors, destructors, and calls to base class default
constructors.
-------------- next part --------------
Index: ChangeLog
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/ChangeLog,v
retrieving revision 1.2149
diff -u -p -r1.2149 ChangeLog
--- ChangeLog 2003/10/29 21:47:10 1.2149
+++ ChangeLog 2003/10/29 23:01:24
@@ -1,5 +1,33 @@
2003-10-29 David Hyatt <hyatt at apple.com>
+ Reviewed by NOBODY (OOPS!).
+
+ * khtml/css/cssstyleselector.cpp:
+ (khtml::CSSStyleSelector::applyRule):
+ * khtml/rendering/render_style.cpp:
+ (StyleBoxData::operator==):
+ (StyleFlexibleBoxData::StyleFlexibleBoxData):
+ (:opacity):
+ (:textShadow):
+ (StyleInheritedData::StyleInheritedData):
+ (StyleInheritedData::operator==):
+ * khtml/rendering/render_style.h:
+ (khtml::):
+ (khtml::RenderStyle::NonInheritedFlags::operator==):
+ (khtml::RenderStyle::setBitDefaults):
+ (khtml::RenderStyle::widows):
+ (khtml::RenderStyle::orphans):
+ (khtml::RenderStyle::pageBreakInside):
+ (khtml::RenderStyle::pageBreakBefore):
+ (khtml::RenderStyle::pageBreakAfter):
+ (khtml::RenderStyle::setWidows):
+ (khtml::RenderStyle::setOrphans):
+ (khtml::RenderStyle::setPageBreakInside):
+ (khtml::RenderStyle::setPageBreakBefore):
+ (khtml::RenderStyle::setPageBreakAfter):
+
+2003-10-29 David Hyatt <hyatt at apple.com>
+
Refine the fix to updateLayout.
updateStyleSelector would get called over and over again when you queried for layout properties from
JS. If no stylesheets are pending, this isn't necessary (and is quite expensive, since updateStyleSelector
Index: khtml/css/cssstyleselector.cpp
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/css/cssstyleselector.cpp,v
retrieving revision 1.103
diff -u -p -r1.103 khtml/css/cssstyleselector.cpp
--- khtml/css/cssstyleselector.cpp 2003/10/29 08:57:20 1.103
+++ khtml/css/cssstyleselector.cpp 2003/10/29 23:01:24
@@ -2014,11 +2014,74 @@ void CSSStyleSelector::applyRule( int id
style->setOverflow(o);
return;
}
- break;
- case CSS_PROP_PAGE:
- case CSS_PROP_PAGE_BREAK_AFTER:
+
case CSS_PROP_PAGE_BREAK_BEFORE:
- case CSS_PROP_PAGE_BREAK_INSIDE:
+ {
+ if(value->cssValueType() == CSSValue::CSS_INHERIT)
+ {
+ if(!parentNode) return;
+ style->setPageBreakBefore(parentStyle->pageBreakBefore());
+ return;
+ }
+ if(!primitiveValue) return;
+ switch (primitiveValue->getIdent()) {
+ case CSS_VAL_AUTO:
+ style->setPageBreakBefore(PBAUTO);
+ break;
+ case CSS_VAL_LEFT:
+ case CSS_VAL_RIGHT:
+ case CSS_VAL_ALWAYS:
+ style->setPageBreakBefore(PBALWAYS); // CSS2.1: "Conforming user agents may map left/right to always."
+ break;
+ case CSS_VAL_AVOID:
+ style->setPageBreakInside(PBAVOID);
+ break;
+ }
+ break;
+ }
+
+ case CSS_PROP_PAGE_BREAK_AFTER:
+ {
+ if(value->cssValueType() == CSSValue::CSS_INHERIT)
+ {
+ if(!parentNode) return;
+ style->setPageBreakAfter(parentStyle->pageBreakAfter());
+ return;
+ }
+ if(!primitiveValue) return;
+ switch (primitiveValue->getIdent()) {
+ case CSS_VAL_AUTO:
+ style->setPageBreakAfter(PBAUTO);
+ break;
+ case CSS_VAL_LEFT:
+ case CSS_VAL_RIGHT:
+ case CSS_VAL_ALWAYS:
+ style->setPageBreakAfter(PBALWAYS); // CSS2.1: "Conforming user agents may map left/right to always."
+ break;
+ case CSS_VAL_AVOID:
+ style->setPageBreakAfter(PBAVOID);
+ break;
+ }
+ break;
+ }
+
+ case CSS_PROP_PAGE_BREAK_INSIDE: {
+ if(value->cssValueType() == CSSValue::CSS_INHERIT)
+ {
+ if(!parentNode) return;
+ style->setPageBreakInside(parentStyle->pageBreakInside());
+ return;
+ }
+ if(!primitiveValue) return;
+ if (primitiveValue->getIdent() == CSS_VAL_AUTO)
+ style->setPageBreakInside(PBAUTO);
+ else if (primitiveValue->getIdent() == CSS_VAL_AVOID)
+ style->setPageBreakInside(PBAVOID);
+ return;
+ }
+
+ case CSS_PROP_PAGE:
+
// case CSS_PROP_PAUSE_AFTER:
// case CSS_PROP_PAUSE_BEFORE:
break;
@@ -2845,6 +2908,32 @@ void CSSStyleSelector::applyRule( int id
style->setZIndex(z_index);
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));
+ }
+ 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));
+ }
+ break;
+ }
// length, percent, number
case CSS_PROP_LINE_HEIGHT:
Index: khtml/rendering/render_style.cpp
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/rendering/render_style.cpp,v
retrieving revision 1.32
diff -u -p -r1.32 khtml/rendering/render_style.cpp
--- khtml/rendering/render_style.cpp 2003/10/29 08:57:20 1.32
+++ khtml/rendering/render_style.cpp 2003/10/29 23:01:24
@@ -38,13 +38,6 @@ StyleSurroundData::StyleSurroundData()
{
}
-StyleSurroundData::StyleSurroundData(const StyleSurroundData& o )
- : Shared<StyleSurroundData>(),
- offset( o.offset ), margin( o.margin ), padding( o.padding ),
- border( o.border )
-{
-}
-
bool StyleSurroundData::operator==(const StyleSurroundData& o) const
{
return offset==o.offset && margin==o.margin &&
@@ -65,15 +58,6 @@ StyleBoxData::StyleBoxData()
max_height.value = UNDEFINED;
}
-StyleBoxData::StyleBoxData(const StyleBoxData& o )
- : Shared<StyleBoxData>(),
- width( o.width ), height( o.height ),
- min_width( o.min_width ), max_width( o.max_width ),
- min_height ( o.min_height ), max_height( o.max_height ),
- z_index( o.z_index ), z_auto( o.z_auto )
-{
-}
-
bool StyleBoxData::operator==(const StyleBoxData& o) const
{
return
@@ -84,7 +68,7 @@ bool StyleBoxData::operator==(const Styl
min_height == o.min_height &&
max_height == o.max_height &&
z_index == o.z_index &&
- z_auto == o.z_auto;
+ z_auto == o.z_auto;
}
StyleVisualData::StyleVisualData()
@@ -93,32 +77,11 @@ StyleVisualData::StyleVisualData()
{
}
-StyleVisualData::~StyleVisualData() {
-}
-
-StyleVisualData::StyleVisualData(const StyleVisualData& o )
- : Shared<StyleVisualData>(),
- clip( o.clip ), hasClip( o.hasClip ), textDecoration(o.textDecoration), colspan( o.colspan ),
- counter_increment( o.counter_increment ), counter_reset( o.counter_reset ),
- palette( o.palette )
-{
-}
-
-
-
StyleBackgroundData::StyleBackgroundData()
: image( 0 )
{
}
-StyleBackgroundData::StyleBackgroundData(const StyleBackgroundData& o )
- : Shared<StyleBackgroundData>(),
- color( o.color ), image( o.image ),
- x_position( o.x_position ), y_position( o.y_position ),
- outline( o.outline )
-{
-}
-
bool StyleBackgroundData::operator==(const StyleBackgroundData& o) const
{
return
@@ -146,7 +109,6 @@ bool StyleMarqueeData::operator==(const
}
StyleFlexibleBoxData::StyleFlexibleBoxData()
-: Shared<StyleFlexibleBoxData>()
{
flex = 0.0f;
flex_group = 1;
@@ -158,19 +120,6 @@ StyleFlexibleBoxData::StyleFlexibleBoxDa
flexed_height = -1;
}
-StyleFlexibleBoxData::StyleFlexibleBoxData(const StyleFlexibleBoxData& o)
-: Shared<StyleFlexibleBoxData>()
-{
- flex = o.flex;
- flex_group = o.flex_group;
- ordinal_group = o.ordinal_group;
- align = o.align;
- pack = o.pack;
- orient = o.orient;
- lines = o.lines;
- flexed_height = o.flexed_height;
-}
-
bool StyleFlexibleBoxData::operator==(const StyleFlexibleBoxData& o) const
{
return flex == o.flex && flex_group == o.flex_group &&
@@ -180,7 +129,7 @@ bool StyleFlexibleBoxData::operator==(co
}
StyleCSS3NonInheritedData::StyleCSS3NonInheritedData()
-:Shared<StyleCSS3NonInheritedData>(), opacity(1.0f)
+:opacity(1.0f)
{
}
@@ -195,7 +144,7 @@ bool StyleCSS3NonInheritedData::operator
}
StyleCSS3InheritedData::StyleCSS3InheritedData()
-:Shared<StyleCSS3InheritedData>(), textShadow(0)
+:textShadow(0)
{
}
@@ -223,24 +172,11 @@ 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 )
+ horizontal_border_spacing( 0 ), vertical_border_spacing( 0 ), widows( 2 ), orphans( 2 ),
+ pageBreakInside( PBAUTO )
{
}
-StyleInheritedData::~StyleInheritedData()
-{
-}
-
-StyleInheritedData::StyleInheritedData(const StyleInheritedData& o )
- : Shared<StyleInheritedData>(),
- indent( o.indent ), line_height( o.line_height ), style_image( o.style_image ),
- cursor_image( o.cursor_image ), font( o.font ),
- color( o.color ),
- horizontal_border_spacing( o.horizontal_border_spacing ),
- vertical_border_spacing( o.vertical_border_spacing )
-{
-}
-
bool StyleInheritedData::operator==(const StyleInheritedData& o) const
{
return
@@ -251,10 +187,10 @@ bool StyleInheritedData::operator==(cons
font == o.font &&
color == o.color &&
horizontal_border_spacing == o.horizontal_border_spacing &&
- vertical_border_spacing == o.vertical_border_spacing;
-
- // doesn't work because structs are not packed
- //return memcmp(this, &o, sizeof(*this))==0;
+ vertical_border_spacing == o.vertical_border_spacing &&
+ widows == o.widows &&
+ orphans == o.orphans &&
+ pageBreakInside == o.pageBreakInside;
}
RenderStyle::RenderStyle()
Index: khtml/rendering/render_style.h
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/rendering/render_style.h,v
retrieving revision 1.35
diff -u -p -r1.35 khtml/rendering/render_style.h
--- khtml/rendering/render_style.h 2003/10/29 08:57:20 1.35
+++ khtml/rendering/render_style.h 2003/10/29 23:01:24
@@ -271,7 +271,6 @@ class StyleSurroundData : public Shared<
public:
StyleSurroundData();
- StyleSurroundData(const StyleSurroundData& o );
bool operator==(const StyleSurroundData& o) const;
bool operator!=(const StyleSurroundData& o) const {
return !(*this == o);
@@ -292,13 +291,6 @@ class StyleBoxData : public Shared<Style
public:
StyleBoxData();
- StyleBoxData(const StyleBoxData& o );
-
-
- // copy and assignment
-// StyleBoxData(const StyleBoxData &other);
-// const StyleBoxData &operator = (const StyleBoxData &other);
-
bool operator==(const StyleBoxData& o) const;
bool operator!=(const StyleBoxData& o) const {
return !(*this == o);
@@ -348,10 +340,6 @@ class StyleVisualData : public Shared<St
public:
StyleVisualData();
- ~StyleVisualData();
-
- StyleVisualData(const StyleVisualData& o );
-
bool operator==( const StyleVisualData &o ) const {
return ( clip == o.clip &&
hasClip == o.hasClip &&
@@ -387,8 +375,6 @@ class StyleBackgroundData : public Share
{
public:
StyleBackgroundData();
- ~StyleBackgroundData() {}
- StyleBackgroundData(const StyleBackgroundData& o );
bool operator==(const StyleBackgroundData& o) const;
bool operator!=(const StyleBackgroundData &o) const {
@@ -440,8 +426,6 @@ class StyleFlexibleBoxData : public Shar
{
public:
StyleFlexibleBoxData();
- ~StyleFlexibleBoxData() {}
- StyleFlexibleBoxData(const StyleFlexibleBoxData& o);
bool operator==(const StyleFlexibleBoxData& o) const;
bool operator!=(const StyleFlexibleBoxData &o) const {
@@ -542,12 +526,14 @@ enum ETextDecoration {
TDNONE = 0x0 , UNDERLINE = 0x1, OVERLINE = 0x2, LINE_THROUGH= 0x4, BLINK = 0x8
};
+enum EPageBreak {
+ PBAUTO, PBALWAYS, PBAVOID
+};
+
class StyleInheritedData : public Shared<StyleInheritedData>
{
public:
StyleInheritedData();
- ~StyleInheritedData();
- StyleInheritedData(const StyleInheritedData& o );
bool operator==(const StyleInheritedData& o) const;
bool operator != ( const StyleInheritedData &o ) const {
@@ -567,6 +553,11 @@ public:
short horizontal_border_spacing;
short vertical_border_spacing;
+
+ // Paged media properties.
+ short widows;
+ short orphans;
+ EPageBreak pageBreakInside : 2;
};
@@ -706,7 +697,9 @@ protected:
(_clear == other._clear) &&
(_position == other._position) &&
(_floating == other._floating) &&
- (_table_layout == other._table_layout) &&
+ (_table_layout == other._table_layout) &&
+ (_page_break_before == other._page_break_before) &&
+ (_page_break_after == other._page_break_after) &&
(_flowAroundFloats == other._flowAroundFloats) &&
(_styleType == other._styleType) &&
(_affectedByHover == other._affectedByHover) &&
@@ -729,6 +722,10 @@ protected:
EPosition _position : 2;
EFloat _floating : 2;
ETableLayout _table_layout : 1;
+
+ EPageBreak _page_break_before : 2;
+ EPageBreak _page_break_after : 2;
+
bool _flowAroundFloats :1;
PseudoId _styleType : 3;
@@ -790,6 +787,8 @@ protected:
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._styleType = NOPSEUDO;
noninherited_flags._affectedByHover = false;
@@ -963,6 +962,12 @@ public:
CachedImage *cursorImage() const { return inherited->cursor_image; }
+ short widows() const { return inherited->widows; }
+ short orphans() const { return inherited->orphans; }
+ EPageBreak pageBreakInside() const { return inherited->pageBreakInside; }
+ EPageBreak pageBreakBefore() const { return noninherited_flags._page_break_before; }
+ EPageBreak pageBreakAfter() const { return noninherited_flags._page_break_after; }
+
// CSS3 Getter Methods
ShadowData* textShadow() const { return css3InheritedData->textShadow; }
float opacity() { return css3NonInheritedData->opacity; }
@@ -1125,6 +1130,12 @@ public:
int zIndex() const { return box->z_index; }
void setZIndex(int v) { SET_VAR(box, z_auto, false); SET_VAR(box,z_index,v) }
+ void setWidows(short w) { SET_VAR(inherited, widows, w); }
+ void setOrphans(short o) { SET_VAR(inherited, orphans, o); }
+ void setPageBreakInside(EPageBreak b) { SET_VAR(inherited, pageBreakInside, b); }
+ void setPageBreakBefore(EPageBreak b) { noninherited_flags._page_break_before = b; }
+ void setPageBreakAfter(EPageBreak b) { noninherited_flags._page_break_after = b; }
+
// CSS3 Setters
void setTextShadow(ShadowData* val, bool add=false);
void setOpacity(float f) { SET_VAR(css3NonInheritedData, opacity, f); }
-------------- next part --------------
dave
More information about the Khtml-devel
mailing list