| # khtml Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# render_style.h

    00001 /*
    00002  * This file is part of the DOM implementation for KDE.
    00003  *
    00004  * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
    00005  *           (C) 2000 Antti Koivisto (koivisto@kde.org)
    00006  *           (C) 2000 Dirk Mueller (mueller@kde.org)
    00007  *
    00008  * This library is free software; you can redistribute it and/or
    00009  * modify it under the terms of the GNU Library General Public
    00010  * License as published by the Free Software Foundation; either
    00011  * version 2 of the License, or (at your option) any later version.
    00012  *
    00013  * This library is distributed in the hope that it will be useful,
    00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00016  * Library General Public License for more details.
    00017  *
    00018  * You should have received a copy of the GNU Library General Public License
    00019  * along with this library; see the file COPYING.LIB.  If not, write to
    00020  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00021  * Boston, MA 02111-1307, USA.
    00022  *
    00023  * $Id: render_style.h,v 1.78.2.4 2003/08/17 14:38:51 mueller Exp $
    00024  */
    00025 #ifndef RENDERSTYLE_H
    00026 #define RENDERSTYLE_H
    00027
    00028 /*
    00029  * WARNING:
    00030  * --------
    00031  *
    00032  * The order of the values in the enums have to agree with the order specified
    00033  * in cssvalues.in, otherwise some optimizations in the parser will fail,
    00034  * and produce invaliud results.
    00035  */
    00036
    00037 #include <qcolor.h>
    00038 #include <qfont.h>
    00039 #include <qfontmetrics.h>
    00040 #include <qptrlist.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 // Box model attributes. Not inherited.
    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() || right.value() || top.value() || bottom.value(); }
    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 // Border attributes. Not inherited.
    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; // medium is default value
    00198         style = BNONE;
    00199     }
    00200     QColor color;
    00201     unsigned short width : 12;
    00202     EBorderStyle style : 4;
    00203
    00204     bool nonZero() const
    00205     {
    00206       // rikkus: workaround for gcc 2.95.3
    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 // Box attributes. Not inherited.
    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     // copy and assignment
    00270 //    StyleBoxData(const StyleBoxData &other);
    00271 //    const StyleBoxData &operator = (const StyleBoxData &other);
    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 // Random visual rendering model attributes. Not inherited.
    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; // for html, not a css2 attribute
    00339
    00340     short counter_increment; //ok, so these are not visual mode spesific
    00341     short counter_reset;     //can't go to inherited, since these are not inherited
    00342
    00343     QPalette palette;      //widget styling with IE attributes
    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 // Inherited attributes.
    00377 //
    00378 // the inherited-decoration and inherited-shadow attributes
    00379 // are inherited from the
    00380 // first parent which is block level
    00381 //
    00382 // this applies to decoration_color too
    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     // could be packed in a short but doesn't
    00418     // make a difference currently because of padding
    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         // counters...
    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     // static pseudo styles. Dynamic ones are produced on the fly.
    00498     enum PseudoId { NOPSEUDO, FIRST_LINE, FIRST_LETTER, BEFORE, AFTER };
    00499
    00500 protected:
    00501
    00502 // !START SYNC!: Keep this in sync with the copy constructor in render_style.cpp
    00503
    00504     // inherit
    00505     struct InheritedFlags {
    00506     // 32 bit inherited, don't add to the struct, or the operator will break.
    00507         bool operator==( const InheritedFlags &other ) const
    00508         {   return _iflags == other._iflags;   }
    00509         bool operator!=( const InheritedFlags &other ) const
    00510         {   return _iflags != other._iflags;   }
    00511
    00512         union {
    00513             struct {
    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                 unsigned _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                 // non CSS2 inherited
    00530                 bool _visuallyOrdered : 1;
    00531                 bool _htmlHacks :1;
    00532                 unsigned _unused : 1;
    00533             } f;
    00534             Q_UINT32 _iflags;
    00535         };
    00536     } inherited_flags;
    00537
    00538 // don't inherit
    00539     struct NonInheritedFlags {
    00540         bool operator==( const NonInheritedFlags &other ) const
    00541         {   return _niflags == other._niflags;   }
    00542         bool operator!=( const NonInheritedFlags &other ) const
    00543         {   return _niflags != other._niflags;   }
    00544
    00545         union {
    00546             struct {
    00547                 EDisplay _display : 4;
    00548                 EBackgroundRepeat _bg_repeat : 2;
    00549                 bool _bg_attachment : 1;
    00550                 EOverflow _overflow : 4 ;
    00551                 EVerticalAlign _vertical_align : 4;
    00552                 EClear _clear : 2;
    00553                 EPosition _position : 2;
    00554                 EFloat _floating : 2;
    00555                 ETableLayout _table_layout : 1;
    00556                 bool _flowAroundFloats :1;
    00557
    00558                 PseudoId _styleType : 3;
    00559                 bool _hasHover : 1;
    00560                 bool _hasActive : 1;
    00561                 bool _clipSpecified : 1;
    00562                 EUnicodeBidi _unicodeBidi : 2;
    00563                 unsigned _unused : 1;
    00564             } f;
    00565             Q_UINT32 _niflags;
    00566         };
    00567     } noninherited_flags;
    00568
    00569 // non-inherited attributes
    00570     DataRef<StyleBoxData> box;
    00571     DataRef<StyleVisualData> visual;
    00572     DataRef<StyleBackgroundData> background;
    00573     DataRef<StyleSurroundData> surround;
    00574
    00575 // inherited attributes
    00576     DataRef<StyleInheritedData> inherited;
    00577
    00578 // list of associated pseudo styles
    00579     RenderStyle* pseudoStyle;
    00580
    00581     // added this here, so we can get rid of the vptr in this class.
    00582     // makes up for the same size.
    00583     ContentData *content;
    00584 // !END SYNC!
    00585
    00586 // static default style
    00587     static RenderStyle* _default;
    00588
    00589 private:
    00590     RenderStyle(const RenderStyle*) {}
    00591
    00592 protected:
    00593     void setBitDefaults()
    00594     {
    00595         inherited_flags.f._empty_cells = SHOW;
    00596         inherited_flags.f._caption_side = CAPTOP;
    00597         inherited_flags.f._list_style_type = DISC;
    00598         inherited_flags.f._list_style_position = OUTSIDE;
    00599         inherited_flags.f._visibility = VISIBLE;
    00600         inherited_flags.f._text_align = TAAUTO;
    00601         inherited_flags.f._text_transform = TTNONE;
    00602         inherited_flags.f._text_decoration = TDNONE;
    00603         inherited_flags.f._cursor_style = CURSOR_AUTO;
    00604         inherited_flags.f._direction = LTR;
    00605         inherited_flags.f._border_collapse = true;
    00606         inherited_flags.f._white_space = NORMAL;
    00607         inherited_flags.f._font_variant = FVNORMAL;
    00608         inherited_flags.f._visuallyOrdered = false;
    00609         inherited_flags.f._htmlHacks=false;
    00610         inherited_flags.f._unused = 0;
    00611
    00612         noninherited_flags.f._display = INLINE;
    00613         noninherited_flags.f._bg_repeat = REPEAT;
    00614         noninherited_flags.f._bg_attachment = SCROLL;
    00615         noninherited_flags.f._overflow = OVISIBLE;
    00616         noninherited_flags.f._vertical_align = BASELINE;
    00617         noninherited_flags.f._clear = CNONE;
    00618         noninherited_flags.f._position = STATIC;
    00619         noninherited_flags.f._floating = FNONE;
    00620         noninherited_flags.f._table_layout = TAUTO;
    00621         noninherited_flags.f._flowAroundFloats=false;
    00622         noninherited_flags.f._styleType = NOPSEUDO;
    00623         noninherited_flags.f._hasHover = false;
    00624         noninherited_flags.f._hasActive = false;
    00625         noninherited_flags.f._clipSpecified = false;
    00626         noninherited_flags.f._unicodeBidi = UBNormal;
    00627         noninherited_flags.f._unused = 0;
    00628     }
    00629
    00630 public:
    00631
    00632     RenderStyle();
    00633     // used to create the default style.
    00634     RenderStyle(bool);
    00635     RenderStyle(const RenderStyle&);
    00636
    00637     ~RenderStyle();
    00638
    00639     void inheritFrom(const RenderStyle* inheritParent);
    00640
    00641     PseudoId styleType() { return  noninherited_flags.f._styleType; }
    00642
    00643     RenderStyle* getPseudoStyle(PseudoId pi);
    00644     RenderStyle* addPseudoStyle(PseudoId pi);
    00645     void removePseudoStyle(PseudoId pi);
    00646
    00647     bool hasHover() const { return  noninherited_flags.f._hasHover; }
    00648     bool hasActive() const { return  noninherited_flags.f._hasActive; }
    00649
    00650     void setHasHover() {  noninherited_flags.f._hasHover = true; }
    00651     void setHasActive() {  noninherited_flags.f._hasActive = true; }
    00652
    00653     bool operator==(const RenderStyle& other) const;
    00654     bool        isFloating() const { return !(noninherited_flags.f._floating == FNONE); }
    00655     bool        hasMargin() const { return surround->margin.nonZero(); }
    00656     bool        hasPadding() const { return surround->padding.nonZero(); }
    00657     bool        hasBorder() const { return surround->border.hasBorder(); }
    00658     bool        hasOffset() const { return surround->offset.nonZero(); }
    00659
    00660     bool visuallyOrdered() const { return inherited_flags.f._visuallyOrdered; }
    00661     void setVisuallyOrdered(bool b) {  inherited_flags.f._visuallyOrdered = b; }
    00662
    00663 // attribute getter methods
    00664
    00665     EDisplay    display() const { return noninherited_flags.f._display; }
    00666
    00667     Length      left() const {  return surround->offset.left; }
    00668     Length      right() const {  return surround->offset.right; }
    00669     Length      top() const {  return surround->offset.top; }
    00670     Length      bottom() const {  return surround->offset.bottom; }
    00671
    00672     EPosition   position() const { return  noninherited_flags.f._position; }
    00673     EFloat      floating() const { return  noninherited_flags.f._floating; }
    00674
    00675     Length      width() const { return box->width; }
    00676     Length      height() const { return box->height; }
    00677     Length      minWidth() const { return box->min_width; }
    00678     Length      maxWidth() const { return box->max_width; }
    00679     Length      minHeight() const { return box->min_height; }
    00680     Length      maxHeight() const { return box->max_height; }
    00681
    00682     unsigned short  borderLeftWidth() const
    00683     { if( surround->border.left.style == BNONE) return 0; return surround->border.left.width; }
    00684     EBorderStyle    borderLeftStyle() const { return surround->border.left.style; }
    00685     const QColor &  borderLeftColor() const { return surround->border.left.color; }
    00686     unsigned short  borderRightWidth() const
    00687     { if (surround->border.right.style == BNONE) return 0; return surround->border.right.width; }
    00688     EBorderStyle    borderRightStyle() const {  return surround->border.right.style; }
    00689     const QColor &          borderRightColor() const {  return surround->border.right.color; }
    00690     unsigned short  borderTopWidth() const
    00691     { if(surround->border.top.style == BNONE) return 0; return surround->border.top.width; }
    00692     EBorderStyle    borderTopStyle() const {return surround->border.top.style; }
    00693     const QColor &  borderTopColor() const {  return surround->border.top.color; }
    00694     unsigned short  borderBottomWidth() const
    00695     { if(surround->border.bottom.style == BNONE) return 0; return surround->border.bottom.width; }
    00696     EBorderStyle    borderBottomStyle() const {  return surround->border.bottom.style; }
    00697     const QColor &          borderBottomColor() const {  return surround->border.bottom.color; }
    00698
    00699     unsigned short  outlineWidth() const
    00700     { if(background->outline.style == BNONE) return 0; return background->outline.width; }
    00701     EBorderStyle    outlineStyle() const {  return background->outline.style; }
    00702     const QColor &          outlineColor() const {  return background->outline.color; }
    00703
    00704     EOverflow overflow() const { return  noninherited_flags.f._overflow; }
    00705     EVisibility visibility() const { return inherited_flags.f._visibility; }
    00706     EVerticalAlign verticalAlign() const { return  noninherited_flags.f._vertical_align; }
    00707     Length verticalAlignLength() const { return box->vertical_align; }
    00708
    00709     Length clipLeft() const { return visual->clip.left; }
    00710     Length clipRight() const { return visual->clip.right; }
    00711     Length clipTop() const { return visual->clip.top; }
    00712     Length clipBottom() const { return visual->clip.bottom; }
    00713     bool clipSpecified() const { return noninherited_flags.f._clipSpecified; }
    00714
    00715     EUnicodeBidi unicodeBidi() const { return noninherited_flags.f._unicodeBidi; }
    00716
    00717     EClear clear() const { return  noninherited_flags.f._clear; }
    00718     ETableLayout tableLayout() const { return  noninherited_flags.f._table_layout; }
    00719
    00720     short colSpan() const { return visual->colspan; }
    00721
    00722     const QFont & font() const { return inherited->font.f; }
    00723     // use with care. call font->update() after modifications
    00724     const Font &htmlFont() { return inherited->font; }
    00725     const QFontMetrics & fontMetrics() const { return inherited->font.fm; }
    00726
    00727     const QColor & color() const { return inherited->color; }
    00728     Length textIndent() const { return inherited->indent; }
    00729     ETextAlign textAlign() const { return inherited_flags.f._text_align; }
    00730     ETextTransform textTransform() const { return inherited_flags.f._text_transform; }
    00731     unsigned textDecoration() const { return inherited_flags.f._text_decoration; }
    00732     const QColor &textDecorationColor() const { return inherited->decoration_color; }
    00733     int wordSpacing() const { return inherited->font.wordSpacing; }
    00734     int letterSpacing() const { return inherited->font.letterSpacing; }
    00735
    00736     EDirection direction() const { return inherited_flags.f._direction; }
    00737     Length lineHeight() const { return inherited->line_height; }
    00738
    00739     EWhiteSpace whiteSpace() const { return inherited_flags.f._white_space; }
    00740
    00741
    00742     const QColor & backgroundColor() const { return background->color; }
    00743     CachedImage *backgroundImage() const { return background->image; }
    00744     EBackgroundRepeat backgroundRepeat() const { return  noninherited_flags.f._bg_repeat; }
    00745     bool backgroundAttachment() const { return  noninherited_flags.f._bg_attachment; }
    00746     Length backgroundXPosition() const { return background->x_position; }
    00747     Length backgroundYPosition() const { return background->y_position; }
    00748
    00749     // returns true for collapsing borders, false for separate borders
    00750     bool borderCollapse() const { return inherited_flags.f._border_collapse; }
    00751     short borderSpacing() const { return inherited->border_spacing; }
    00752     EEmptyCell emptyCells() const { return inherited_flags.f._empty_cells; }
    00753     ECaptionSide captionSide() const { return inherited_flags.f._caption_side; }
    00754
    00755     short counterIncrement() const { return visual->counter_increment; }
    00756     short counterReset() const { return visual->counter_reset; }
    00757
    00758     EListStyleType listStyleType() const { return inherited_flags.f._list_style_type; }
    00759     CachedImage *listStyleImage() const { return inherited->style_image; }
    00760     EListStylePosition listStylePosition() const { return inherited_flags.f._list_style_position; }
    00761
    00762     Length marginTop() const { return surround->margin.top; }
    00763     Length marginBottom() const {  return surround->margin.bottom; }
    00764     Length marginLeft() const {  return surround->margin.left; }
    00765     Length marginRight() const {  return surround->margin.right; }
    00766
    00767     Length paddingTop() const {  return surround->padding.top; }
    00768     Length paddingBottom() const {  return surround->padding.bottom; }
    00769     Length paddingLeft() const { return surround->padding.left; }
    00770     Length paddingRight() const {  return surround->padding.right; }
    00771
    00772     ECursor cursor() const { return inherited_flags.f._cursor_style; }
    00773     EFontVariant fontVariant() { return inherited_flags.f._font_variant; }
    00774
    00775 // attribute setter methods
    00776
    00777     void setDisplay(EDisplay v) {  noninherited_flags.f._display = v; }
    00778     void setPosition(EPosition v) {  noninherited_flags.f._position = v; }
    00779     void setFloating(EFloat v) {  noninherited_flags.f._floating = v; }
    00780
    00781     void setLeft(Length v)  {  SET_VAR(surround,offset.left,v) }
    00782     void setRight(Length v) {  SET_VAR(surround,offset.right,v) }
    00783     void setTop(Length v)   {  SET_VAR(surround,offset.top,v) }
    00784     void setBottom(Length v){  SET_VAR(surround,offset.bottom,v) }
    00785
    00786     void setWidth(Length v)  { SET_VAR(box,width,v) }
    00787     void setHeight(Length v) { SET_VAR(box,height,v) }
    00788
    00789     void setMinWidth(Length v)  { SET_VAR(box,min_width,v) }
    00790     void setMaxWidth(Length v)  { SET_VAR(box,max_width,v) }
    00791     void setMinHeight(Length v) { SET_VAR(box,min_height,v) }
    00792     void setMaxHeight(Length v) { SET_VAR(box,max_height,v) }
    00793
    00794     void setBorderLeftWidth(unsigned short v)   {  SET_VAR(surround,border.left.width,v) }
    00795     void setBorderLeftStyle(EBorderStyle v)     {  SET_VAR(surround,border.left.style,v) }
    00796     void setBorderLeftColor(const QColor & v)   {  SET_VAR(surround,border.left.color,v) }
    00797     void setBorderRightWidth(unsigned short v)  {  SET_VAR(surround,border.right.width,v) }
    00798     void setBorderRightStyle(EBorderStyle v)    {  SET_VAR(surround,border.right.style,v) }
    00799     void setBorderRightColor(const QColor & v)  {  SET_VAR(surround,border.right.color,v) }
    00800     void setBorderTopWidth(unsigned short v)    {  SET_VAR(surround,border.top.width,v) }
    00801     void setBorderTopStyle(EBorderStyle v)      {  SET_VAR(surround,border.top.style,v) }
    00802     void setBorderTopColor(const QColor & v)    {  SET_VAR(surround,border.top.color,v) }
    00803     void setBorderBottomWidth(unsigned short v) {  SET_VAR(surround,border.bottom.width,v) }
    00804     void setBorderBottomStyle(EBorderStyle v)   {  SET_VAR(surround,border.bottom.style,v) }
    00805     void setBorderBottomColor(const QColor & v) {  SET_VAR(surround,border.bottom.color,v) }
    00806     void setOutlineWidth(unsigned short v) {  SET_VAR(background,outline.width,v) }
    00807     void setOutlineStyle(EBorderStyle v)   {  SET_VAR(background,outline.style,v) }
    00808     void setOutlineColor(const QColor & v) {  SET_VAR(background,outline.color,v) }
    00809
    00810     void setOverflow(EOverflow v) {  noninherited_flags.f._overflow = v; }
    00811     void setVisibility(EVisibility v) { inherited_flags.f._visibility = v; }
    00812     void setVerticalAlign(EVerticalAlign v) { noninherited_flags.f._vertical_align = v; }
    00813     void setVerticalAlignLength(Length l) { SET_VAR(box, vertical_align, l ) }
    00814
    00815     void setClipLeft(Length v) { SET_VAR(visual,clip.left,v) }
    00816     void setClipRight(Length v) { SET_VAR(visual,clip.right,v) }
    00817     void setClipTop(Length v) { SET_VAR(visual,clip.top,v) }
    00818     void setClipBottom(Length v) { SET_VAR(visual,clip.bottom,v) }
    00819     void setClip( Length top, Length right, Length bottom, Length left );
    00820     void setClipSpecified( bool b ) { noninherited_flags.f._clipSpecified = b; }
    00821
    00822     void setUnicodeBidi( EUnicodeBidi b ) { noninherited_flags.f._unicodeBidi = b; }
    00823
    00824     void setClear(EClear v) {  noninherited_flags.f._clear = v; }
    00825     void setTableLayout(ETableLayout v) {  noninherited_flags.f._table_layout = v; }
    00826     void ssetColSpan(short v) { SET_VAR(visual,colspan,v) }
    00827
    00828     bool setFontDef(const khtml::FontDef & v) {
    00829         // bah, this doesn't compare pointers. broken! (Dirk)
    00830         if (!(inherited->font.fontDef == v)) {
    00831             inherited.access()->font = Font( v );
    00832             return true;
    00833         }
    00834         return false;
    00835     }
    00836
    00837     void setColor(const QColor & v) { SET_VAR(inherited,color,v) }
    00838     void setTextIndent(Length v) { SET_VAR(inherited,indent,v) }
    00839     void setTextAlign(ETextAlign v) { inherited_flags.f._text_align = v; }
    00840     void setTextTransform(ETextTransform v) { inherited_flags.f._text_transform = v; }
    00841     void setTextDecoration(unsigned v) { inherited_flags.f._text_decoration = v; }
    00842     void setTextDecorationColor(const QColor &v) { SET_VAR(inherited,decoration_color,v) }
    00843     void setDirection(EDirection v) { inherited_flags.f._direction = v; }
    00844     void setLineHeight(Length v) { SET_VAR(inherited,line_height,v) }
    00845
    00846     void setWhiteSpace(EWhiteSpace v) { inherited_flags.f._white_space = v; }
    00847
    00848     void setWordSpacing(int v) { SET_VAR(inherited,font.wordSpacing,v) }
    00849     void setLetterSpacing(int v) { SET_VAR(inherited,font.letterSpacing,v) }
    00850
    00851     void setBackgroundColor(const QColor & v) {  SET_VAR(background,color,v) }
    00852     void setBackgroundImage(CachedImage *v) {  SET_VAR(background,image,v) }
    00853     void setBackgroundRepeat(EBackgroundRepeat v) {  noninherited_flags.f._bg_repeat = v; }
    00854     void setBackgroundAttachment(bool scroll) {  noninherited_flags.f._bg_attachment = scroll; }
    00855     void setBackgroundXPosition(Length v) {  SET_VAR(background,x_position,v) }
    00856     void setBackgroundYPosition(Length v) {  SET_VAR(background,y_position,v) }
    00857
    00858     void setBorderCollapse(bool collapse) { inherited_flags.f._border_collapse = collapse; }
    00859     void setBorderSpacing(short v) { SET_VAR(inherited,border_spacing,v) }
    00860     void setEmptyCells(EEmptyCell v) { inherited_flags.f._empty_cells = v; }
    00861     void setCaptionSide(ECaptionSide v) { inherited_flags.f._caption_side = v; }
    00862
    00863
    00864     void setCounterIncrement(short v) {  SET_VAR(visual,counter_increment,v) }
    00865     void setCounterReset(short v) {  SET_VAR(visual,counter_reset,v) }
    00866
    00867     void setListStyleType(EListStyleType v) { inherited_flags.f._list_style_type = v; }
    00868     void setListStyleImage(CachedImage *v) {  SET_VAR(inherited,style_image,v)}
    00869     void setListStylePosition(EListStylePosition v) { inherited_flags.f._list_style_position = v; }
    00870
    00871     void setMarginTop(Length v)     {  SET_VAR(surround,margin.top,v) }
    00872     void setMarginBottom(Length v)  {  SET_VAR(surround,margin.bottom,v) }
    00873     void setMarginLeft(Length v)    {  SET_VAR(surround,margin.left,v) }
    00874     void setMarginRight(Length v)   {  SET_VAR(surround,margin.right,v) }
    00875
    00876     void setPaddingTop(Length v)    {  SET_VAR(surround,padding.top,v) }
    00877     void setPaddingBottom(Length v) {  SET_VAR(surround,padding.bottom,v) }
    00878     void setPaddingLeft(Length v)   {  SET_VAR(surround,padding.left,v) }
    00879     void setPaddingRight(Length v)  {  SET_VAR(surround,padding.right,v) }
    00880
    00881     void setCursor( ECursor c ) { inherited_flags.f._cursor_style = c; }
    00882     void setFontVariant( EFontVariant f ) { inherited_flags.f._font_variant = f; }
    00883
    00884     bool htmlHacks() const { return inherited_flags.f._htmlHacks; }
    00885     void setHtmlHacks(bool b=true) { inherited_flags.f._htmlHacks = b; }
    00886
    00887     bool flowAroundFloats() const { return  noninherited_flags.f._flowAroundFloats; }
    00888     void setFlowAroundFloats(bool b=true) {  noninherited_flags.f._flowAroundFloats = b; }
    00889
    00890     int zIndex() const { return box->z_index; }
    00891     void setZIndex(int v) { SET_VAR(box,z_index,v) }
    00892
    00893     QPalette palette() const { return visual->palette; }
    00894     void setPaletteColor(QPalette::ColorGroup g, QColorGroup::ColorRole r, const QColor& c);
    00895     void resetPalette() // Called when the desktop color scheme changes.
    00896     {
    00897         const_cast<StyleVisualData *>(visual.get())->palette = QApplication::palette();
    00898     }
    00899
    00900
    00901     ContentType contentType() { return content ? content->_contentType : CONTENT_NONE; }
    00902
    00903     DOM::DOMStringImpl* contentText()
    00904     {
    00905         if (content && content->_contentType==CONTENT_TEXT)
    00906             return content->_content.text;
    00907         else
    00908             return 0;
    00909     }
    00910
    00911     CachedObject* contentObject()
    00912     {
    00913         if (content && content->_contentType==CONTENT_OBJECT)
    00914             return content->_content.object;
    00915         else
    00916             return 0;
    00917     }
    00918
    00919     void setContent(DOM::DOMStringImpl* s);
    00920     void setContent(CachedObject* o);
    00921
    00922     bool inheritedNotEqual( RenderStyle *other ) const;
    00923
    00924     enum Diff { Equal, NonVisible = Equal, Visible, Position, Layout, CbLayout };
    00925     Diff diff( const RenderStyle *other ) const;
    00926 };
    00927
    00928
    00929 } // namespace
    00930
    00931 #endif
    00932

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:34:42 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001