00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef RENDERSTYLE_H
00026 #define RENDERSTYLE_H
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #include <qcolor.h>
00038 #include <qfont.h>
00039 #include <qfontmetrics.h>
00040 #include <qlist.h>
00041 #include <qpalette.h>
00042 #include <qapplication.h>
00043
00044 #include "dom/dom_misc.h"
00045 #include "misc/khtmllayout.h"
00046 #include "misc/shared.h"
00047 #include "rendering/font.h"
00048
00049 #include <assert.h>
00050
00051 #define SET_VAR(group,variable,value) \
00052 if (!(group->variable == value)) \
00053 group.access()->variable = value;
00054
00055 namespace DOM {
00056 class DOMStringImpl;
00057 }
00058
00059 namespace khtml {
00060
00061 class CachedImage;
00062 class CachedObject;
00063
00064 template <class DATA>
00065 class DataRef
00066 {
00067 public:
00068
00069 DataRef()
00070 {
00071 data=0;
00072 }
00073 DataRef( const DataRef<DATA> &d )
00074 {
00075 data = d.data;
00076 data->ref();
00077 }
00078
00079 ~DataRef()
00080 {
00081 if(data) data->deref();
00082 }
00083
00084 const DATA* operator->() const
00085 {
00086 return data;
00087 }
00088
00089 const DATA* get() const
00090 {
00091 return data;
00092 }
00093
00094
00095 DATA* access()
00096 {
00097 if (!data->hasOneRef())
00098 {
00099 data->deref();
00100 data = new DATA(*data);
00101 data->ref();
00102 }
00103 return data;
00104 }
00105
00106 void init()
00107 {
00108 data = new DATA;
00109 data->ref();
00110 }
00111
00112 DataRef<DATA>& operator=(const DataRef<DATA>& d)
00113 {
00114 if (data==d.data)
00115 return *this;
00116 if (data)
00117 data->deref();
00118 data = d.data;
00119
00120 data->ref();
00121
00122 return *this;
00123 }
00124
00125 bool operator == ( const DataRef<DATA> &o ) const {
00126 return (*data == *(o.data) );
00127 }
00128 bool operator != ( const DataRef<DATA> &o ) const {
00129 return (*data != *(o.data) );
00130 }
00131
00132 private:
00133 DATA* data;
00134 };
00135
00136
00137
00138
00139
00140
00141
00142 struct LengthBox
00143 {
00144 LengthBox()
00145 {
00146 }
00147 LengthBox( LengthType t )
00148 : left( t ), right ( t ), top( t ), bottom( t ) {}
00149
00150 Length left;
00151 Length right;
00152 Length top;
00153 Length bottom;
00154 Length& operator=(Length& len)
00155 {
00156 left=len;
00157 right=len;
00158 top=len;
00159 bottom=len;
00160 return len;
00161 }
00162
00163 bool operator==(const LengthBox& o) const
00164 {
00165 return left==o.left && right==o.right && top==o.top && bottom==o.bottom;
00166 }
00167
00168
00169 bool nonZero() const { return left.value!=0 || right.value!=0 || top.value!=0 || bottom.value!=0; }
00170 };
00171
00172
00173
00174 enum EPosition {
00175 STATIC, RELATIVE, ABSOLUTE, FIXED
00176 };
00177
00178 enum EFloat {
00179 FNONE = 0, FLEFT, FRIGHT
00180 };
00181
00182
00183
00184
00185
00186
00187 enum EBorderStyle {
00188 BNONE, BHIDDEN, DOTTED, DASHED, DOUBLE, SOLID,
00189 OUTSET, INSET, GROOVE, RIDGE
00190 };
00191
00192 class BorderValue
00193 {
00194 public:
00195 BorderValue()
00196 {
00197 width = 3;
00198 style = BNONE;
00199 }
00200 QColor color;
00201 unsigned short width : 12;
00202 EBorderStyle style : 4;
00203
00204 bool nonZero() const
00205 {
00206
00207 return width!=0 && !(style==BNONE);
00208 }
00209
00210 bool operator==(const BorderValue& o) const
00211 {
00212 return width==o.width && style==o.style && color==o.color;
00213 }
00214
00215 };
00216
00217 class BorderData : public Shared<BorderData>
00218 {
00219 public:
00220 BorderValue left;
00221 BorderValue right;
00222 BorderValue top;
00223 BorderValue bottom;
00224
00225 bool hasBorder() const
00226 {
00227 return left.nonZero() || right.nonZero() || top.nonZero() || bottom.nonZero();
00228 }
00229
00230 bool operator==(const BorderData& o) const
00231 {
00232 return left==o.left && right==o.right && top==o.top && bottom==o.bottom;
00233 }
00234
00235 };
00236
00237 class StyleSurroundData : public Shared<StyleSurroundData>
00238 {
00239 public:
00240 StyleSurroundData();
00241
00242 StyleSurroundData(const StyleSurroundData& o );
00243 bool operator==(const StyleSurroundData& o) const;
00244 bool operator!=(const StyleSurroundData& o) const {
00245 return !(*this == o);
00246 }
00247
00248 LengthBox offset;
00249 LengthBox margin;
00250 LengthBox padding;
00251 BorderData border;
00252 };
00253
00254
00255
00256
00257
00258
00259 const int ZAUTO=0;
00260
00261 class StyleBoxData : public Shared<StyleBoxData>
00262 {
00263 public:
00264 StyleBoxData();
00265
00266 StyleBoxData(const StyleBoxData& o );
00267
00268
00269
00270
00271
00272
00273 bool operator==(const StyleBoxData& o) const;
00274 bool operator!=(const StyleBoxData& o) const {
00275 return !(*this == o);
00276 }
00277
00278 Length width;
00279 Length height;
00280
00281 Length min_width;
00282 Length max_width;
00283
00284 Length min_height;
00285 Length max_height;
00286
00287 Length vertical_align;
00288
00289 int z_index;
00290 };
00291
00292
00293
00294
00295 enum EOverflow {
00296 OVISIBLE, OHIDDEN, SCROLL, AUTO
00297 };
00298
00299 enum EVerticalAlign {
00300 BASELINE, MIDDLE, SUB, SUPER, TEXT_TOP,
00301 TEXT_BOTTOM, TOP, BOTTOM, BASELINE_MIDDLE, LENGTH
00302 };
00303
00304 enum EClear{
00305 CNONE = 0, CLEFT = 1, CRIGHT = 2, CBOTH = 3
00306 };
00307
00308 enum ETableLayout {
00309 TAUTO, TFIXED
00310 };
00311
00312 enum EUnicodeBidi {
00313 UBNormal, Embed, Override
00314 };
00315
00316 class StyleVisualData : public Shared<StyleVisualData>
00317 {
00318 public:
00319 StyleVisualData();
00320
00321 ~StyleVisualData();
00322
00323 StyleVisualData(const StyleVisualData& o );
00324
00325 bool operator==( const StyleVisualData &o ) const {
00326 return ( clip == o.clip &&
00327 colspan == o.colspan &&
00328 counter_increment == o.counter_increment &&
00329 counter_reset == o.counter_reset &&
00330 palette == o.palette );
00331 }
00332 bool operator!=( const StyleVisualData &o ) const {
00333 return !(*this == o);
00334 }
00335
00336 LengthBox clip;
00337
00338 short colspan;
00339
00340 short counter_increment;
00341 short counter_reset;
00342
00343 QPalette palette;
00344
00345 };
00346
00347
00348 enum EBackgroundRepeat {
00349 REPEAT, REPEAT_X, REPEAT_Y, NO_REPEAT
00350 };
00351
00352
00353
00354 class StyleBackgroundData : public Shared<StyleBackgroundData>
00355 {
00356 public:
00357 StyleBackgroundData();
00358 ~StyleBackgroundData() {}
00359 StyleBackgroundData(const StyleBackgroundData& o );
00360
00361 bool operator==(const StyleBackgroundData& o) const;
00362 bool operator!=(const StyleBackgroundData &o) const {
00363 return !(*this == o);
00364 }
00365
00366 QColor color;
00367 CachedImage *image;
00368
00369 Length x_position;
00370 Length y_position;
00371 BorderValue outline;
00372 };
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384 enum EWhiteSpace {
00385 NORMAL, PRE, NOWRAP
00386 };
00387
00388 enum ETextAlign {
00389 TAAUTO, LEFT, RIGHT, CENTER, JUSTIFY, KONQ_CENTER
00390 };
00391
00392 enum ETextTransform {
00393 CAPITALIZE, UPPERCASE, LOWERCASE, TTNONE
00394 };
00395
00396 enum EDirection {
00397 LTR, RTL
00398 };
00399
00400 enum ETextDecoration {
00401 TDNONE = 0x0 , UNDERLINE = 0x1, OVERLINE = 0x2, LINE_THROUGH= 0x4, BLINK = 0x8
00402 };
00403
00404 class StyleInheritedData : public Shared<StyleInheritedData>
00405 {
00406 public:
00407 StyleInheritedData();
00408 ~StyleInheritedData();
00409 StyleInheritedData(const StyleInheritedData& o );
00410
00411 bool operator==(const StyleInheritedData& o) const;
00412 bool operator != ( const StyleInheritedData &o ) const {
00413 return !(*this == o);
00414 }
00415
00416 Length indent;
00417
00418
00419 Length line_height;
00420
00421 CachedImage *style_image;
00422
00423 khtml::Font font;
00424 QColor color;
00425 QColor decoration_color;
00426
00427 short border_spacing;
00428 };
00429
00430
00431 enum EEmptyCell {
00432 SHOW, HIDE
00433 };
00434
00435 enum ECaptionSide
00436 {
00437 CAPTOP, CAPBOTTOM
00438 };
00439
00440
00441 enum EListStyleType {
00442 DISC, CIRCLE, SQUARE, LDECIMAL, DECIMAL_LEADING_ZERO,
00443 LOWER_ROMAN, UPPER_ROMAN, LOWER_GREEK,
00444 LOWER_ALPHA, LOWER_LATIN, UPPER_ALPHA, UPPER_LATIN,
00445 HEBREW, ARMENIAN, GEORGIAN, CJK_IDEOGRAPHIC,
00446 HIRAGANA, KATAKANA, HIRAGANA_IROHA, KATAKANA_IROHA, LNONE
00447 };
00448
00449 enum EListStylePosition { OUTSIDE, INSIDE };
00450
00451 enum EVisibility { VISIBLE, HIDDEN, COLLAPSE };
00452
00453 enum ECursor {
00454 CURSOR_AUTO, CURSOR_CROSS, CURSOR_DEFAULT, CURSOR_POINTER, CURSOR_PROGRESS, CURSOR_MOVE,
00455 CURSOR_E_RESIZE, CURSOR_NE_RESIZE, CURSOR_NW_RESIZE, CURSOR_N_RESIZE, CURSOR_SE_RESIZE, CURSOR_SW_RESIZE,
00456 CURSOR_S_RESIZE, CURSOR_W_RESIZE, CURSOR_TEXT, CURSOR_WAIT, CURSOR_HELP
00457 };
00458
00459 enum EFontVariant {
00460 FVNORMAL, SMALL_CAPS
00461 };
00462
00463 enum ContentType {
00464 CONTENT_NONE, CONTENT_OBJECT, CONTENT_TEXT,
00465 CONTENT_ATTR
00466 };
00467
00468 struct ContentData {
00469 ~ContentData();
00470 void clearContent();
00471
00472 ContentType _contentType;
00473
00474 union {
00475 CachedObject* object;
00476 DOM::DOMStringImpl* text;
00477
00478 } _content ;
00479 };
00480
00481
00482
00483 enum EDisplay {
00484 INLINE, BLOCK, LIST_ITEM, RUN_IN, INLINE_BLOCK,
00485 TABLE, INLINE_TABLE, TABLE_ROW_GROUP,
00486 TABLE_HEADER_GROUP, TABLE_FOOTER_GROUP, TABLE_ROW,
00487 TABLE_COLUMN_GROUP, TABLE_COLUMN, TABLE_CELL,
00488 TABLE_CAPTION, NONE
00489 };
00490
00491 class RenderStyle : public Shared<RenderStyle>
00492 {
00493 friend class CSSStyleSelector;
00494 public:
00495 static void cleanup();
00496
00497
00498 enum PseudoId { NOPSEUDO, FIRST_LINE, FIRST_LETTER, BEFORE, AFTER };
00499
00500 protected:
00501
00502
00503
00504
00505 struct InheritedFlags {
00506
00507 bool operator==( const InheritedFlags &other ) const {
00508 return *((Q_UINT32 *)this) == *((Q_UINT32 *)&other);
00509 }
00510 bool operator!=( const InheritedFlags &other ) const {
00511 return *((Q_UINT32 *)this) != *((Q_UINT32 *)&other);
00512 }
00513
00514 EEmptyCell _empty_cells : 1 ;
00515 ECaptionSide _caption_side : 1;
00516 EListStyleType _list_style_type : 5 ;
00517 EListStylePosition _list_style_position :1;
00518
00519 EVisibility _visibility : 2;
00520 ETextAlign _text_align : 3;
00521 ETextTransform _text_transform : 2;
00522 int _text_decoration : 4;
00523 ECursor _cursor_style : 5;
00524
00525 EDirection _direction : 1;
00526 bool _border_collapse : 1 ;
00527 EWhiteSpace _white_space : 2;
00528 EFontVariant _font_variant : 1;
00529
00530 bool _visuallyOrdered : 1;
00531 bool _htmlHacks :1;
00532 int _unused : 1;
00533 } inherited_flags;
00534
00535
00536 struct NonInheritedFlags {
00537
00538 bool operator==( const NonInheritedFlags &other ) const {
00539 return *((Q_UINT32 *)this) == *((Q_UINT32 *)&other);
00540 }
00541 bool operator!=( const NonInheritedFlags &other ) const {
00542 return *((Q_UINT32 *)this) != *((Q_UINT32 *)&other);
00543 }
00544
00545 EDisplay _display : 4;
00546 EBackgroundRepeat _bg_repeat : 2;
00547 bool _bg_attachment : 1;
00548 EOverflow _overflow : 4 ;
00549 EVerticalAlign _vertical_align : 4;
00550 EClear _clear : 2;
00551 EPosition _position : 2;
00552 EFloat _floating : 2;
00553 ETableLayout _table_layout : 1;
00554 bool _flowAroundFloats :1;
00555
00556 PseudoId _styleType : 3;
00557 bool _hasHover : 1;
00558 bool _hasActive : 1;
00559 bool _clipSpecified : 1;
00560 EUnicodeBidi _unicodeBidi : 2;
00561 int _unused : 1;
00562 } noninherited_flags;
00563
00564
00565 DataRef<StyleBoxData> box;
00566 DataRef<StyleVisualData> visual;
00567 DataRef<StyleBackgroundData> background;
00568 DataRef<StyleSurroundData> surround;
00569
00570
00571 DataRef<StyleInheritedData> inherited;
00572
00573
00574 RenderStyle* pseudoStyle;
00575
00576
00577
00578 ContentData *content;
00579
00580
00581
00582 static RenderStyle* _default;
00583
00584 private:
00585 RenderStyle(const RenderStyle*) {}
00586
00587 protected:
00588 void setBitDefaults()
00589 {
00590 inherited_flags._empty_cells = SHOW;
00591 inherited_flags._caption_side = CAPTOP;
00592 inherited_flags._list_style_type = DISC;
00593 inherited_flags._list_style_position = OUTSIDE;
00594 inherited_flags._visibility = VISIBLE;
00595 inherited_flags._text_align = TAAUTO;
00596 inherited_flags._text_transform = TTNONE;
00597 inherited_flags._text_decoration = TDNONE;
00598 inherited_flags._cursor_style = CURSOR_AUTO;
00599 inherited_flags._direction = LTR;
00600 inherited_flags._border_collapse = true;
00601 inherited_flags._white_space = NORMAL;
00602 inherited_flags._font_variant = FVNORMAL;
00603 inherited_flags._visuallyOrdered = false;
00604 inherited_flags._htmlHacks=false;
00605 inherited_flags._unused = 0;
00606
00607 noninherited_flags._display = INLINE;
00608 noninherited_flags._bg_repeat = REPEAT;
00609 noninherited_flags._bg_attachment = SCROLL;
00610 noninherited_flags._overflow = OVISIBLE;
00611 noninherited_flags._vertical_align = BASELINE;
00612 noninherited_flags._clear = CNONE;
00613 noninherited_flags._position = STATIC;
00614 noninherited_flags._floating = FNONE;
00615 noninherited_flags._table_layout = TAUTO;
00616 noninherited_flags._flowAroundFloats=false;
00617 noninherited_flags._styleType = NOPSEUDO;
00618 noninherited_flags._hasHover = false;
00619 noninherited_flags._hasActive = false;
00620 noninherited_flags._clipSpecified = false;
00621 noninherited_flags._unicodeBidi = UBNormal;
00622 noninherited_flags._unused = 0;
00623 }
00624
00625 public:
00626
00627 RenderStyle();
00628
00629 RenderStyle(bool);
00630 RenderStyle(const RenderStyle&);
00631
00632 ~RenderStyle();
00633
00634 void inheritFrom(const RenderStyle* inheritParent);
00635
00636 PseudoId styleType() { return noninherited_flags._styleType; }
00637
00638 RenderStyle* getPseudoStyle(PseudoId pi);
00639 RenderStyle* addPseudoStyle(PseudoId pi);
00640 void removePseudoStyle(PseudoId pi);
00641
00642 bool hasHover() const { return noninherited_flags._hasHover; }
00643 bool hasActive() const { return noninherited_flags._hasActive; }
00644
00645 void setHasHover() { noninherited_flags._hasHover = true; }
00646 void setHasActive() { noninherited_flags._hasActive = true; }
00647
00648 bool operator==(const RenderStyle& other) const;
00649 bool isFloating() const { return !(noninherited_flags._floating == FNONE); }
00650 bool hasMargin() const { return surround->margin.nonZero(); }
00651 bool hasPadding() const { return surround->padding.nonZero(); }
00652 bool hasBorder() const { return surround->border.hasBorder(); }
00653 bool hasOffset() const { return surround->offset.nonZero(); }
00654
00655 bool visuallyOrdered() const { return inherited_flags._visuallyOrdered; }
00656 void setVisuallyOrdered(bool b) { inherited_flags._visuallyOrdered = b; }
00657
00658
00659
00660 EDisplay display() const { return noninherited_flags._display; }
00661
00662 Length left() const { return surround->offset.left; }
00663 Length right() const { return surround->offset.right; }
00664 Length top() const { return surround->offset.top; }
00665 Length bottom() const { return surround->offset.bottom; }
00666
00667 EPosition position() const { return noninherited_flags._position; }
00668 EFloat floating() const { return noninherited_flags._floating; }
00669
00670 Length width() const { return box->width; }
00671 Length height() const { return box->height; }
00672 Length minWidth() const { return box->min_width; }
00673 Length maxWidth() const { return box->max_width; }
00674 Length minHeight() const { return box->min_height; }
00675 Length maxHeight() const { return box->max_height; }
00676
00677 unsigned short borderLeftWidth() const
00678 { if( surround->border.left.style == BNONE) return 0; return surround->border.left.width; }
00679 EBorderStyle borderLeftStyle() const { return surround->border.left.style; }
00680 const QColor & borderLeftColor() const { return surround->border.left.color; }
00681 unsigned short borderRightWidth() const
00682 { if (surround->border.right.style == BNONE) return 0; return surround->border.right.width; }
00683 EBorderStyle borderRightStyle() const { return surround->border.right.style; }
00684 const QColor & borderRightColor() const { return surround->border.right.color; }
00685 unsigned short borderTopWidth() const
00686 { if(surround->border.top.style == BNONE) return 0; return surround->border.top.width; }
00687 EBorderStyle borderTopStyle() const {return surround->border.top.style; }
00688 const QColor & borderTopColor() const { return surround->border.top.color; }
00689 unsigned short borderBottomWidth() const
00690 { if(surround->border.bottom.style == BNONE) return 0; return surround->border.bottom.width; }
00691 EBorderStyle borderBottomStyle() const { return surround->border.bottom.style; }
00692 const QColor & borderBottomColor() const { return surround->border.bottom.color; }
00693
00694 unsigned short outlineWidth() const
00695 { if(background->outline.style == BNONE) return 0; return background->outline.width; }
00696 EBorderStyle outlineStyle() const { return background->outline.style; }
00697 const QColor & outlineColor() const { return background->outline.color; }
00698
00699 EOverflow overflow() const { return noninherited_flags._overflow; }
00700 EVisibility visibility() const { return inherited_flags._visibility; }
00701 EVerticalAlign verticalAlign() const { return noninherited_flags._vertical_align; }
00702 Length verticalAlignLength() const { return box->vertical_align; }
00703
00704 Length clipLeft() const { return visual->clip.left; }
00705 Length clipRight() const { return visual->clip.right; }
00706 Length clipTop() const { return visual->clip.top; }
00707 Length clipBottom() const { return visual->clip.bottom; }
00708 bool clipSpecified() const { return noninherited_flags._clipSpecified; }
00709
00710 EUnicodeBidi unicodeBidi() const { return noninherited_flags._unicodeBidi; }
00711
00712 EClear clear() const { return noninherited_flags._clear; }
00713 ETableLayout tableLayout() const { return noninherited_flags._table_layout; }
00714
00715 short colSpan() const { return visual->colspan; }
00716
00717 const QFont & font() const { return inherited->font.f; }
00718
00719 const Font &htmlFont() { return inherited->font; }
00720 const QFontMetrics & fontMetrics() const { return inherited->font.fm; }
00721
00722 const QColor & color() const { return inherited->color; }
00723 Length textIndent() const { return inherited->indent; }
00724 ETextAlign textAlign() const { return inherited_flags._text_align; }
00725 ETextTransform textTransform() const { return inherited_flags._text_transform; }
00726 int textDecoration() const { return inherited_flags._text_decoration; }
00727 const QColor &textDecorationColor() const { return inherited->decoration_color; }
00728 int wordSpacing() const { return inherited->font.wordSpacing; }
00729 int letterSpacing() const { return inherited->font.letterSpacing; }
00730
00731 EDirection direction() const { return inherited_flags._direction; }
00732 Length lineHeight() const { return inherited->line_height; }
00733
00734 EWhiteSpace whiteSpace() const { return inherited_flags._white_space; }
00735
00736
00737 const QColor & backgroundColor() const { return background->color; }
00738 CachedImage *backgroundImage() const { return background->image; }
00739 EBackgroundRepeat backgroundRepeat() const { return noninherited_flags._bg_repeat; }
00740 bool backgroundAttachment() const { return noninherited_flags._bg_attachment; }
00741 Length backgroundXPosition() const { return background->x_position; }
00742 Length backgroundYPosition() const { return background->y_position; }
00743
00744
00745 bool borderCollapse() const { return inherited_flags._border_collapse; }
00746 short borderSpacing() const { return inherited->border_spacing; }
00747 EEmptyCell emptyCells() const { return inherited_flags._empty_cells; }
00748 ECaptionSide captionSide() const { return inherited_flags._caption_side; }
00749
00750 short counterIncrement() const { return visual->counter_increment; }
00751 short counterReset() const { return visual->counter_reset; }
00752
00753 EListStyleType listStyleType() const { return inherited_flags._list_style_type; }
00754 CachedImage *listStyleImage() const { return inherited->style_image; }
00755 EListStylePosition listStylePosition() const { return inherited_flags._list_style_position; }
00756
00757 Length marginTop() const { return surround->margin.top; }
00758 Length marginBottom() const { return surround->margin.bottom; }
00759 Length marginLeft() const { return surround->margin.left; }
00760 Length marginRight() const { return surround->margin.right; }
00761
00762 Length paddingTop() const { return surround->padding.top; }
00763 Length paddingBottom() const { return surround->padding.bottom; }
00764 Length paddingLeft() const { return surround->padding.left; }
00765 Length paddingRight() const { return surround->padding.right; }
00766
00767 ECursor cursor() const { return inherited_flags._cursor_style; }
00768 EFontVariant fontVariant() { return inherited_flags._font_variant; }
00769
00770
00771
00772 void setDisplay(EDisplay v) { noninherited_flags._display = v; }
00773 void setPosition(EPosition v) { noninherited_flags._position = v; }
00774 void setFloating(EFloat v) { noninherited_flags._floating = v; }
00775
00776 void setLeft(Length v) { SET_VAR(surround,offset.left,v) }
00777 void setRight(Length v) { SET_VAR(surround,offset.right,v) }
00778 void setTop(Length v) { SET_VAR(surround,offset.top,v) }
00779 void setBottom(Length v){ SET_VAR(surround,offset.bottom,v) }
00780
00781 void setWidth(Length v) { SET_VAR(box,width,v) }
00782 void setHeight(Length v) { SET_VAR(box,height,v) }
00783
00784 void setMinWidth(Length v) { SET_VAR(box,min_width,v) }
00785 void setMaxWidth(Length v) { SET_VAR(box,max_width,v) }
00786 void setMinHeight(Length v) { SET_VAR(box,min_height,v) }
00787 void setMaxHeight(Length v) { SET_VAR(box,max_height,v) }
00788
00789 void setBorderLeftWidth(unsigned short v) { SET_VAR(surround,border.left.width,v) }
00790 void setBorderLeftStyle(EBorderStyle v) { SET_VAR(surround,border.left.style,v) }
00791 void setBorderLeftColor(const QColor & v) { SET_VAR(surround,border.left.color,v) }
00792 void setBorderRightWidth(unsigned short v) { SET_VAR(surround,border.right.width,v) }
00793 void setBorderRightStyle(EBorderStyle v) { SET_VAR(surround,border.right.style,v) }
00794 void setBorderRightColor(const QColor & v) { SET_VAR(surround,border.right.color,v) }
00795 void setBorderTopWidth(unsigned short v) { SET_VAR(surround,border.top.width,v) }
00796 void setBorderTopStyle(EBorderStyle v) { SET_VAR(surround,border.top.style,v) }
00797 void setBorderTopColor(const QColor & v) { SET_VAR(surround,border.top.color,v) }
00798 void setBorderBottomWidth(unsigned short v) { SET_VAR(surround,border.bottom.width,v) }
00799 void setBorderBottomStyle(EBorderStyle v) { SET_VAR(surround,border.bottom.style,v) }
00800 void setBorderBottomColor(const QColor & v) { SET_VAR(surround,border.bottom.color,v) }
00801 void setOutlineWidth(unsigned short v) { SET_VAR(background,outline.width,v) }
00802 void setOutlineStyle(EBorderStyle v) { SET_VAR(background,outline.style,v) }
00803 void setOutlineColor(const QColor & v) { SET_VAR(background,outline.color,v) }
00804
00805 void setOverflow(EOverflow v) { noninherited_flags._overflow = v; }
00806 void setVisibility(EVisibility v) { inherited_flags._visibility = v; }
00807 void setVerticalAlign(EVerticalAlign v) { noninherited_flags._vertical_align = v; }
00808 void setVerticalAlignLength(Length l) { SET_VAR(box, vertical_align, l ) }
00809
00810 void setClipLeft(Length v) { SET_VAR(visual,clip.left,v) }
00811 void setClipRight(Length v) { SET_VAR(visual,clip.right,v) }
00812 void setClipTop(Length v) { SET_VAR(visual,clip.top,v) }
00813 void setClipBottom(Length v) { SET_VAR(visual,clip.bottom,v) }
00814 void setClip( Length top, Length right, Length bottom, Length left );
00815 void setClipSpecified( bool b ) { noninherited_flags._clipSpecified = b; }
00816
00817 void setUnicodeBidi( EUnicodeBidi b ) { noninherited_flags._unicodeBidi = b; }
00818
00819 void setClear(EClear v) { noninherited_flags._clear = v; }
00820 void setTableLayout(ETableLayout v) { noninherited_flags._table_layout = v; }
00821 void ssetColSpan(short v) { SET_VAR(visual,colspan,v) }
00822
00823 bool setFontDef(const khtml::FontDef & v) {
00824
00825 if (!(inherited->font.fontDef == v)) {
00826 inherited.access()->font = Font( v );
00827 return true;
00828 }
00829 return false;
00830 }
00831
00832 void setColor(const QColor & v) { SET_VAR(inherited,color,v) }
00833 void setTextIndent(Length v) { SET_VAR(inherited,indent,v) }
00834 void setTextAlign(ETextAlign v) { inherited_flags._text_align = v; }
00835 void setTextTransform(ETextTransform v) { inherited_flags._text_transform = v; }
00836 void setTextDecoration(int v) { inherited_flags._text_decoration = v; }
00837 void setTextDecorationColor(const QColor &v) { SET_VAR(inherited,decoration_color,v) }
00838 void setDirection(EDirection v) { inherited_flags._direction = v; }
00839 void setLineHeight(Length v) { SET_VAR(inherited,line_height,v) }
00840
00841 void setWhiteSpace(EWhiteSpace v) { inherited_flags._white_space = v; }
00842
00843 void setWordSpacing(int v) { SET_VAR(inherited,font.wordSpacing,v) }
00844 void setLetterSpacing(int v) { SET_VAR(inherited,font.letterSpacing,v) }
00845
00846 void setBackgroundColor(const QColor & v) { SET_VAR(background,color,v) }
00847 void setBackgroundImage(CachedImage *v) { SET_VAR(background,image,v) }
00848 void setBackgroundRepeat(EBackgroundRepeat v) { noninherited_flags._bg_repeat = v; }
00849 void setBackgroundAttachment(bool scroll) { noninherited_flags._bg_attachment = scroll; }
00850 void setBackgroundXPosition(Length v) { SET_VAR(background,x_position,v) }
00851 void setBackgroundYPosition(Length v) { SET_VAR(background,y_position,v) }
00852
00853 void setBorderCollapse(bool collapse) { inherited_flags._border_collapse = collapse; }
00854 void setBorderSpacing(short v) { SET_VAR(inherited,border_spacing,v) }
00855 void setEmptyCells(EEmptyCell v) { inherited_flags._empty_cells = v; }
00856 void setCaptionSide(ECaptionSide v) { inherited_flags._caption_side = v; }
00857
00858
00859 void setCounterIncrement(short v) { SET_VAR(visual,counter_increment,v) }
00860 void setCounterReset(short v) { SET_VAR(visual,counter_reset,v) }
00861
00862 void setListStyleType(EListStyleType v) { inherited_flags._list_style_type = v; }
00863 void setListStyleImage(CachedImage *v) { SET_VAR(inherited,style_image,v)}
00864 void setListStylePosition(EListStylePosition v) { inherited_flags._list_style_position = v; }
00865
00866 void setMarginTop(Length v) { SET_VAR(surround,margin.top,v) }
00867 void setMarginBottom(Length v) { SET_VAR(surround,margin.bottom,v) }
00868 void setMarginLeft(Length v) { SET_VAR(surround,margin.left,v) }
00869 void setMarginRight(Length v) { SET_VAR(surround,margin.right,v) }
00870
00871 void setPaddingTop(Length v) { SET_VAR(surround,padding.top,v) }
00872 void setPaddingBottom(Length v) { SET_VAR(surround,padding.bottom,v) }
00873 void setPaddingLeft(Length v) { SET_VAR(surround,padding.left,v) }
00874 void setPaddingRight(Length v) { SET_VAR(surround,padding.right,v) }
00875
00876 void setCursor( ECursor c ) { inherited_flags._cursor_style = c; }
00877 void setFontVariant( EFontVariant f ) { inherited_flags._font_variant = f; }
00878
00879 bool htmlHacks() const { return inherited_flags._htmlHacks; }
00880 void setHtmlHacks(bool b=true) { inherited_flags._htmlHacks = b; }
00881
00882 bool flowAroundFloats() const { return noninherited_flags._flowAroundFloats; }
00883 void setFlowAroundFloats(bool b=true) { noninherited_flags._flowAroundFloats = b; }
00884
00885 int zIndex() const { return box->z_index; }
00886 void setZIndex(int v) { SET_VAR(box,z_index,v) }
00887
00888 QPalette palette() const { return visual->palette; }
00889 void setPaletteColor(QPalette::ColorGroup g, QColorGroup::ColorRole r, const QColor& c);
00890 void resetPalette()
00891 {
00892 const_cast<StyleVisualData *>(visual.get())->palette = QApplication::palette();
00893 }
00894
00895
00896 ContentType contentType() { return content ? content->_contentType : CONTENT_NONE; }
00897
00898 DOM::DOMStringImpl* contentText()
00899 {
00900 if (content && content->_contentType==CONTENT_TEXT)
00901 return content->_content.text;
00902 else
00903 return 0;
00904 }
00905
00906 CachedObject* contentObject()
00907 {
00908 if (content && content->_contentType==CONTENT_OBJECT)
00909 return content->_content.object;
00910 else
00911 return 0;
00912 }
00913
00914 void setContent(DOM::DOMStringImpl* s);
00915 void setContent(CachedObject* o);
00916
00917 bool inheritedNotEqual( RenderStyle *other ) const;
00918
00919 enum Diff { Equal, NonVisible = Equal, Visible, Position, Layout, CbLayout };
00920 Diff diff( const RenderStyle *other ) const;
00921 };
00922
00923
00924 }
00925
00926 #endif
00927