fix logic
[personal-kdelibs.git] / khtml / rendering / render_style.h
blob5f1503d2c9633b652b0fde077e8852ca7049faec
1 /*
2 * This file is part of the DOM implementation for KDE.
4 * Copyright (C) 2000-2003 Lars Knoll (knoll@kde.org)
5 * (C) 2000 Antti Koivisto (koivisto@kde.org)
6 * (C) 2000-2003 Dirk Mueller (mueller@kde.org)
7 * (C) 2003-2007 Apple Computer, Inc.
8 * (C) 2004-2006 Allan Sandfeld Jensen (kde@carewolf.com)
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Library General Public
12 * License as published by the Free Software Foundation; either
13 * version 2 of the License, or (at your option) any later version.
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Library General Public License for more details.
20 * You should have received a copy of the GNU Library General Public License
21 * along with this library; see the file COPYING.LIB. If not, write to
22 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 * Boston, MA 02110-1301, USA.
26 #ifndef RENDERSTYLE_H
27 #define RENDERSTYLE_H
30 * WARNING:
31 * --------
33 * The order of the values in the enums have to agree with the order specified
34 * in cssvalues.in, otherwise some optimizations in the parser will fail,
35 * and produce invaliud results.
38 #include <QtGui/QColor>
39 #include <QtGui/QFont>
40 #include <QtGui/QFontMetrics>
41 #include <QtGui/QColorGroup>
42 #include <QtGui/QApplication>
44 #include "dom/dom_misc.h"
45 #include "dom/dom_string.h"
46 #include "misc/khtmllayout.h"
47 #include "misc/shared.h"
48 #include "rendering/font.h"
50 #include <assert.h>
52 #include "SVGRenderStyle.h"
54 #define SET_VAR(group,variable,value) \
55 if (!(group->variable == value)) \
56 group.access()->variable = value;
58 #ifndef ENABLE_DUMP
59 #ifndef NDEBUG
60 #define ENABLE_DUMP 1
61 #endif
62 #endif
64 namespace DOM {
65 class DOMStringImpl;
66 class QuotesValueImpl;
67 class CounterImpl;
68 class CSSValueListImpl;
71 namespace khtml {
73 class CachedImage;
74 class CachedObject;
76 template <class DATA>
77 class DataRef
79 public:
81 DataRef()
83 data=0;
85 DataRef( const DataRef<DATA> &d )
87 data = d.data;
88 data->ref();
91 ~DataRef()
93 if(data) data->deref();
96 const DATA* operator->() const
98 return data;
101 const DATA* get() const
103 return data;
107 DATA* access()
109 if (!data->hasOneRef())
111 data->deref();
112 data = new DATA(*data);
113 data->ref();
115 return data;
118 void init()
120 data = new DATA;
121 data->ref();
124 DataRef<DATA>& operator=(const DataRef<DATA>& d)
126 if (data==d.data)
127 return *this;
128 if (data)
129 data->deref();
130 data = d.data;
132 data->ref();
134 return *this;
137 bool operator == ( const DataRef<DATA> &o ) const {
138 return (*data == *(o.data) );
140 bool operator != ( const DataRef<DATA> &o ) const {
141 return (*data != *(o.data) );
144 private:
145 DATA* data;
149 //------------------------------------------------
151 //------------------------------------------------
152 // Box model attributes. Not inherited.
154 struct LengthBox
156 LengthBox()
159 LengthBox( LengthType t )
160 : left( t ), right ( t ), top( t ), bottom( t ) {}
162 Length left;
163 Length right;
164 Length top;
165 Length bottom;
166 Length& operator=(Length& len)
168 left=len;
169 right=len;
170 top=len;
171 bottom=len;
172 return len;
175 bool operator==(const LengthBox& o) const
177 return left==o.left && right==o.right && top==o.top && bottom==o.bottom;
181 bool nonZero() const { return left.value() || right.value() || top.value() || bottom.value(); }
186 enum EPosition {
187 PSTATIC, PRELATIVE, PABSOLUTE, PFIXED
190 enum EFloat {
191 FNONE = 0, FLEFT = 0x01, FRIGHT = 0x02, FLEFT_ALIGN = 0x05, FRIGHT_ALIGN = 0x06
195 //------------------------------------------------
196 // Border attributes. Not inherited.
199 // These have been defined in the order of their precedence for border-collapsing. Do
200 // not change this order!
201 enum EBorderStyle {
202 BNATIVE, BNONE, BHIDDEN, INSET, GROOVE, RIDGE, OUTSET, DOTTED, DASHED, SOLID, DOUBLE
205 class BorderValue
207 public:
208 BorderValue() : width( 3 ), style( BNONE ) {}
210 QColor color;
211 unsigned short width : 12;
212 EBorderStyle style : 6;
214 bool nonZero(bool checkStyle = true) const {
215 return width != 0 && !(checkStyle && style == BNONE);
218 bool isTransparent() const {
219 return color.isValid() && color.alpha() == 0;
222 bool operator==(const BorderValue& o) const
224 return width==o.width && style==o.style && color==o.color;
227 bool operator!=(const BorderValue& o) const
229 return !(*this == o);
233 class OutlineValue : public BorderValue
235 public:
236 OutlineValue() : _offset(0), _auto(false) {}
238 bool operator==(const OutlineValue& o) const
240 return width==o.width && style==o.style && color==o.color && _offset == o._offset && _auto == o._auto;
243 bool operator!=(const OutlineValue& o) const
245 return !(*this == o);
248 int _offset;
249 bool _auto;
252 enum EBorderPrecedence { BOFF, BTABLE, BCOLGROUP, BCOL, BROWGROUP, BROW, BCELL };
254 struct CollapsedBorderValue
256 CollapsedBorderValue() :border(0), precedence(BOFF) {}
257 CollapsedBorderValue(const BorderValue* b, EBorderPrecedence p) :border(b), precedence(p) {}
259 int width() const { return border && border->nonZero() ? border->width : 0; }
260 EBorderStyle style() const { return border ? border->style : BHIDDEN; }
261 bool exists() const { return border; }
262 QColor color() const { return border ? border->color : QColor(); }
263 bool isTransparent() const { return border ? border->isTransparent() : true; }
265 bool operator==(const CollapsedBorderValue& o) const
267 if (!border) return !o.border;
268 if (!o.border) return false;
269 return *border == *o.border && precedence == o.precedence;
272 const BorderValue* border;
273 EBorderPrecedence precedence;
276 class BorderData : public Shared<BorderData>
278 public:
279 BorderValue left;
280 BorderValue right;
281 BorderValue top;
282 BorderValue bottom;
284 bool hasBorder() const
286 return left.nonZero() || right.nonZero() || top.nonZero() || bottom.nonZero();
289 unsigned short borderLeftWidth() const {
290 if (left.style == BNONE || left.style == BHIDDEN || left.style == BNATIVE)
291 return 0;
292 return left.width;
295 unsigned short borderRightWidth() const {
296 if (right.style == BNONE || right.style == BHIDDEN || right.style == BNATIVE)
297 return 0;
298 return right.width;
301 unsigned short borderTopWidth() const {
302 if (top.style == BNONE || top.style == BHIDDEN || top.style == BNATIVE)
303 return 0;
304 return top.width;
307 unsigned short borderBottomWidth() const {
308 if (bottom.style == BNONE || bottom.style == BHIDDEN || bottom.style == BNATIVE)
309 return 0;
310 return bottom.width;
313 bool operator==(const BorderData& o) const
315 return left==o.left && right==o.right && top==o.top && bottom==o.bottom;
320 class StyleSurroundData : public Shared<StyleSurroundData>
322 public:
323 StyleSurroundData();
325 StyleSurroundData(const StyleSurroundData& o );
326 bool operator==(const StyleSurroundData& o) const;
327 bool operator!=(const StyleSurroundData& o) const {
328 return !(*this == o);
330 bool hasSamePBMData(const StyleSurroundData& o) const {
331 return (margin == o.margin) && (padding == o.padding) && (border == o.border);
334 LengthBox offset;
335 LengthBox margin;
336 LengthBox padding;
337 BorderData border;
341 //------------------------------------------------
342 // Box attributes. Not inherited.
344 enum EBoxSizing {
345 BORDER_BOX, CONTENT_BOX
348 class StyleBoxData : public Shared<StyleBoxData>
350 public:
351 StyleBoxData();
353 StyleBoxData(const StyleBoxData& o );
356 // copy and assignment
357 // StyleBoxData(const StyleBoxData &other);
358 // const StyleBoxData &operator = (const StyleBoxData &other);
360 bool operator==(const StyleBoxData& o) const;
361 bool operator!=(const StyleBoxData& o) const {
362 return !(*this == o);
365 Length width;
366 Length height;
368 Length min_width;
369 Length max_width;
371 Length min_height;
372 Length max_height;
374 Length vertical_align;
376 EBoxSizing box_sizing;
378 signed int z_index :31;
379 bool z_auto : 1;
382 //------------------------------------------------
383 // Random visual rendering model attributes. Not inherited.
385 enum EOverflow {
386 OVISIBLE, OHIDDEN, OSCROLL, OAUTO, OMARQUEE
389 enum EVerticalAlign {
390 BASELINE, MIDDLE, SUB, SUPER, TEXT_TOP,
391 TEXT_BOTTOM, TOP, BOTTOM, BASELINE_MIDDLE, LENGTH
394 enum EClear{
395 CNONE = 0, CLEFT = 1, CRIGHT = 2, CBOTH = 3
398 enum ETableLayout {
399 TAUTO, TFIXED
402 enum EUnicodeBidi {
403 UBNormal, Embed, Override
406 class StyleVisualData : public Shared<StyleVisualData>
408 public:
409 StyleVisualData();
411 ~StyleVisualData();
413 StyleVisualData(const StyleVisualData& o );
415 bool operator==( const StyleVisualData &o ) const {
416 return ( clip == o.clip &&
417 palette == o.palette );
419 bool operator!=( const StyleVisualData &o ) const {
420 return !(*this == o);
423 LengthBox clip;
424 unsigned textDecoration : 4; // Text decorations defined *only* by this element.
426 QPalette palette; //widget styling with IE attributes
430 //------------------------------------------------
431 enum EBackgroundBox {
432 BGBORDER, BGPADDING, BGCONTENT
435 enum EBackgroundRepeat {
436 REPEAT, REPEAT_X, REPEAT_Y, NO_REPEAT
439 struct LengthSize {
440 Length width;
441 Length height;
444 struct BackgroundLayer {
445 public:
446 BackgroundLayer();
447 ~BackgroundLayer();
449 CachedImage* backgroundImage() const { return m_image; }
450 Length backgroundXPosition() const { return m_xPosition; }
451 Length backgroundYPosition() const { return m_yPosition; }
452 bool backgroundAttachment() const { return m_bgAttachment; }
453 EBackgroundBox backgroundClip() const { return KDE_CAST_BF_ENUM(EBackgroundBox, m_bgClip); }
454 EBackgroundBox backgroundOrigin() const { return KDE_CAST_BF_ENUM(EBackgroundBox, m_bgOrigin); }
455 EBackgroundRepeat backgroundRepeat() const { return KDE_CAST_BF_ENUM(EBackgroundRepeat, m_bgRepeat); }
456 LengthSize backgroundSize() const { return m_backgroundSize; }
458 BackgroundLayer* next() const { return m_next; }
459 BackgroundLayer* next() { return m_next; }
461 bool isBackgroundImageSet() const { return m_imageSet; }
462 bool isBackgroundXPositionSet() const { return m_xPosSet; }
463 bool isBackgroundYPositionSet() const { return m_yPosSet; }
464 bool isBackgroundAttachmentSet() const { return m_attachmentSet; }
465 bool isBackgroundClipSet() const { return m_clipSet; }
466 bool isBackgroundOriginSet() const { return m_originSet; }
467 bool isBackgroundRepeatSet() const { return m_repeatSet; }
468 bool isBackgroundSizeSet() const { return m_backgroundSizeSet; }
470 void setBackgroundImage(CachedImage* i) { m_image = i; m_imageSet = true; }
471 void setBackgroundXPosition(const Length& l) { m_xPosition = l; m_xPosSet = true; }
472 void setBackgroundYPosition(const Length& l) { m_yPosition = l; m_yPosSet = true; }
473 void setBackgroundAttachment(bool b) { m_bgAttachment = b; m_attachmentSet = true; }
474 void setBackgroundClip(EBackgroundBox b) { m_bgClip = b; m_clipSet = true; }
475 void setBackgroundOrigin(EBackgroundBox b) { m_bgOrigin = b; m_originSet = true; }
476 void setBackgroundRepeat(EBackgroundRepeat r) { m_bgRepeat = r; m_repeatSet = true; }
477 void setBackgroundSize(const LengthSize& b) { m_backgroundSize = b; m_backgroundSizeSet = true; }
479 void clearBackgroundImage() { m_imageSet = false; }
480 void clearBackgroundXPosition() { m_xPosSet = false; }
481 void clearBackgroundYPosition() { m_yPosSet = false; }
482 void clearBackgroundAttachment() { m_attachmentSet = false; }
483 void clearBackgroundClip() { m_clipSet = false; }
484 void clearBackgroundOrigin() { m_originSet = false; }
485 void clearBackgroundRepeat() { m_repeatSet = false; }
486 void clearBackgroundSize() { m_backgroundSizeSet = false; }
488 void setNext(BackgroundLayer* n) { if (m_next != n) { delete m_next; m_next = n; } }
490 BackgroundLayer& operator=(const BackgroundLayer& o);
491 BackgroundLayer(const BackgroundLayer& o);
493 bool operator==(const BackgroundLayer& o) const;
494 bool operator!=(const BackgroundLayer& o) const {
495 return !(*this == o);
498 bool containsImage(CachedImage* c) const { if (c == m_image) return true; if (m_next) return m_next->containsImage(c); return false; }
500 bool hasImage() const {
501 if (m_image)
502 return true;
503 return m_next ? m_next->hasImage() : false;
505 bool hasFixedImage() const {
506 if (m_image && !m_bgAttachment)
507 return true;
508 return m_next ? m_next->hasFixedImage() : false;
511 void fillUnsetProperties();
512 void cullEmptyLayers();
514 CachedImage* m_image;
516 Length m_xPosition;
517 Length m_yPosition;
519 bool m_bgAttachment : 1;
520 KDE_BF_ENUM(EBackgroundBox) m_bgClip : 2;
521 KDE_BF_ENUM(EBackgroundBox) m_bgOrigin : 2;
522 KDE_BF_ENUM(EBackgroundRepeat) m_bgRepeat : 2;
524 LengthSize m_backgroundSize;
526 bool m_imageSet : 1;
527 bool m_attachmentSet : 1;
528 bool m_clipSet : 1;
529 bool m_originSet : 1;
530 bool m_repeatSet : 1;
531 bool m_xPosSet : 1;
532 bool m_yPosSet : 1;
533 bool m_backgroundSizeSet : 1;
535 BackgroundLayer* m_next;
538 class StyleBackgroundData : public Shared<StyleBackgroundData>
540 public:
541 StyleBackgroundData();
542 ~StyleBackgroundData() {}
543 StyleBackgroundData(const StyleBackgroundData& o );
545 bool operator==(const StyleBackgroundData& o) const;
546 bool operator!=(const StyleBackgroundData &o) const {
547 return !(*this == o);
550 BackgroundLayer m_background;
551 QColor m_color;
552 OutlineValue m_outline;
555 enum EQuoteContent {
556 NO_QUOTE = 0, OPEN_QUOTE, CLOSE_QUOTE, NO_OPEN_QUOTE, NO_CLOSE_QUOTE
559 enum ContentType {
560 CONTENT_NONE = 0, CONTENT_NORMAL, CONTENT_OBJECT,
561 CONTENT_TEXT, CONTENT_COUNTER, CONTENT_QUOTE
564 struct ContentData {
565 ContentData() : _contentType( CONTENT_NONE ), _nextContent(0) {}
566 ContentData(const ContentData& o);
567 ~ContentData();
568 void clearContent();
570 DOM::DOMStringImpl* contentText()
571 { if (_contentType == CONTENT_TEXT) return _content.text; return 0; }
572 CachedObject* contentObject()
573 { if (_contentType == CONTENT_OBJECT) return _content.object; return 0; }
574 DOM::CounterImpl* contentCounter()
575 { if (_contentType == CONTENT_COUNTER) return _content.counter; return 0; }
576 EQuoteContent contentQuote()
577 { if (_contentType == CONTENT_QUOTE) return _content.quote; return NO_QUOTE; }
579 ContentType _contentType;
581 union {
582 CachedObject* object;
583 DOM::DOMStringImpl* text;
584 DOM::CounterImpl* counter;
585 EQuoteContent quote;
586 } _content ;
588 ContentData* _nextContent;
591 class StyleGeneratedData : public Shared<StyleGeneratedData>
593 public:
594 StyleGeneratedData();
595 ~StyleGeneratedData();
596 StyleGeneratedData(const StyleGeneratedData& o );
598 bool operator==(const StyleGeneratedData& o) const;
599 bool operator!=(const StyleGeneratedData &o) const {
600 return !(*this == o);
603 bool contentDataEquivalent(const StyleGeneratedData* otherStyle) const;
604 bool counterDataEquivalent(const StyleGeneratedData* otherStyle) const;
606 ContentData *content;
607 DOM::CSSValueListImpl *counter_reset;
608 DOM::CSSValueListImpl *counter_increment;
611 //------------------------------------------------
612 // CSS3 Marquee Properties
614 enum EMarqueeBehavior { MNONE, MSCROLL, MSLIDE, MALTERNATE, MUNFURL };
615 enum EMarqueeDirection { MAUTO = 0, MLEFT = 1, MRIGHT = -1, MUP = 2, MDOWN = -2, MFORWARD = 3, MBACKWARD = -3 };
617 class StyleMarqueeData : public Shared<StyleMarqueeData>
619 public:
620 StyleMarqueeData();
621 StyleMarqueeData(const StyleMarqueeData& o);
623 bool operator==(const StyleMarqueeData& o) const;
624 bool operator!=(const StyleMarqueeData& o) const {
625 return !(*this == o);
628 Length increment;
629 int speed;
631 int loops; // -1 means infinite.
633 EMarqueeBehavior behavior : 3;
634 EMarqueeDirection direction : 3;
637 struct BorderRadii
639 int horizontal;
640 int vertical;
642 BorderRadii(): horizontal(0), vertical(0) {}
644 bool hasBorderRadius() const {
645 return horizontal > 0 && vertical > 0;
648 bool operator==(const BorderRadii& o) const;
649 bool operator!=(const BorderRadii& o) const {
650 return !(*this == o);
654 class BorderRadiusData : public Shared<BorderRadiusData>
656 public:
657 // default default & copy ctors are fine here.
659 bool operator==(const BorderRadiusData& o) const;
660 bool operator!=(const BorderRadiusData& o) const {
661 return !(*this == o);
664 bool hasBorderRadius() const;
666 BorderRadii topRight, bottomRight, bottomLeft, topLeft;
669 // This struct holds information about shadows for the text-shadow and box-shadow properties.
670 struct ShadowData {
671 ShadowData(int _x, int _y, int _blur, const QColor& _color)
672 :x(_x), y(_y), blur(_blur), color(_color), next(0) {}
673 ShadowData(const ShadowData& o);
675 ~ShadowData() { delete next; }
677 bool operator==(const ShadowData& o) const;
678 bool operator!=(const ShadowData &o) const {
679 return !(*this == o);
682 int x;
683 int y;
684 int blur;
685 QColor color;
686 ShadowData* next;
689 // This struct is for rarely used non-inherited CSS3 properties. By grouping them together,
690 // we save space, and only allocate this object when someone actually uses
691 // a non-inherited CSS3 property.
692 class StyleCSS3NonInheritedData : public Shared<StyleCSS3NonInheritedData>
694 public:
695 StyleCSS3NonInheritedData();
696 ~StyleCSS3NonInheritedData() {}
697 StyleCSS3NonInheritedData(const StyleCSS3NonInheritedData& o);
699 bool operator==(const StyleCSS3NonInheritedData& o) const;
700 bool operator!=(const StyleCSS3NonInheritedData &o) const {
701 return !(*this == o);
704 float opacity; // Whether or not we're transparent.
705 #ifdef APPLE_CHANGES // ### we don't have those (yet)
706 DataRef<StyleFlexibleBoxData> flexibleBox; // Flexible box properties
707 #endif
708 DataRef<StyleMarqueeData> marquee; // Marquee properties
709 DataRef<BorderRadiusData> borderRadius;
712 // This struct is for rarely used inherited CSS3 properties. By grouping them together,
713 // we save space, and only allocate this object when someone actually uses
714 // an inherited CSS3 property.
715 class StyleCSS3InheritedData : public Shared<StyleCSS3InheritedData>
717 public:
718 StyleCSS3InheritedData();
719 ~StyleCSS3InheritedData();
720 StyleCSS3InheritedData(const StyleCSS3InheritedData& o);
722 bool operator==(const StyleCSS3InheritedData& o) const;
723 bool operator!=(const StyleCSS3InheritedData &o) const {
724 return !(*this == o);
726 bool shadowDataEquivalent(const StyleCSS3InheritedData& o) const;
728 ShadowData* textShadow; // Our text shadow information for shadowed text drawing.
729 #ifdef APPLE_CHANGES
730 EUserModify userModify : 2; // Flag used for editing state
731 bool textSizeAdjust : 1; // An Apple extension. Not really CSS3 but not worth making a new struct over.
732 #endif
733 private:
734 StyleCSS3InheritedData &operator=(const StyleCSS3InheritedData &);
737 //------------------------------------------------
738 // Inherited attributes.
740 // the inherited-decoration and inherited-shadow attributes
741 // are inherited from the
742 // first parent which is block level
745 enum EWhiteSpace {
746 NORMAL, PRE, NOWRAP, PRE_WRAP, PRE_LINE, KHTML_NOWRAP
749 enum ETextAlign {
750 TAAUTO, LEFT, RIGHT, CENTER, JUSTIFY, KHTML_LEFT, KHTML_RIGHT, KHTML_CENTER
753 enum ETextTransform {
754 CAPITALIZE, UPPERCASE, LOWERCASE, TTNONE
757 enum EDirection {
758 LTR, RTL
761 enum ETextDecoration {
762 TDNONE = 0x0 , UNDERLINE = 0x1, OVERLINE = 0x2, LINE_THROUGH= 0x4, BLINK = 0x8
765 enum EPageBreak {
766 PBAUTO, PBALWAYS, PBAVOID,
767 /* reserved for later use: */
768 PBLEFT, PBRIGHT
771 class StyleInheritedData : public Shared<StyleInheritedData>
773 StyleInheritedData& operator=(const StyleInheritedData&);
774 public:
775 StyleInheritedData();
776 ~StyleInheritedData();
777 StyleInheritedData(const StyleInheritedData& o );
779 bool operator==(const StyleInheritedData& o) const;
780 bool operator != ( const StyleInheritedData &o ) const {
781 return !(*this == o);
784 Length indent;
785 // could be packed in a short but doesn't
786 // make a difference currently because of padding
787 Length line_height;
789 CachedImage *style_image;
791 khtml::Font font;
792 QColor color;
794 short border_hspacing;
795 short border_vspacing;
797 // Paged media properties.
798 short widows;
799 short orphans;
801 DOM::QuotesValueImpl* quotes;
805 enum EEmptyCell {
806 SHOW, HIDE
809 enum ECaptionSide {
810 CAPTOP, CAPBOTTOM, CAPLEFT, CAPRIGHT
814 enum EListStyleType {
815 // Symbols:
816 LDISC, LCIRCLE, LSQUARE, LBOX, LDIAMOND,
817 // Numeric:
818 LDECIMAL, DECIMAL_LEADING_ZERO, ARABIC_INDIC, LAO, PERSIAN, URDU, THAI, TIBETAN,
819 // Algorithmic:
820 LOWER_ROMAN, UPPER_ROMAN, HEBREW, ARMENIAN, GEORGIAN,
821 // Ideographic:
822 CJK_IDEOGRAPHIC, JAPANESE_FORMAL, JAPANESE_INFORMAL,
823 SIMP_CHINESE_FORMAL, SIMP_CHINESE_INFORMAL, TRAD_CHINESE_FORMAL, TRAD_CHINESE_INFORMAL,
824 // Alphabetic:
825 LOWER_GREEK, UPPER_GREEK, LOWER_ALPHA, LOWER_LATIN, UPPER_ALPHA, UPPER_LATIN,
826 HIRAGANA, KATAKANA, HIRAGANA_IROHA, KATAKANA_IROHA,
827 // Special:
828 LNONE
831 inline bool isListStyleCounted(EListStyleType type)
833 switch(type) {
834 case LDISC: case LCIRCLE: case LSQUARE: case LBOX: case LDIAMOND:
835 case LNONE:
836 return false;
837 default:
838 return true;
842 enum EListStylePosition { OUTSIDE, INSIDE };
844 enum EVisibility { VISIBLE, HIDDEN, COLLAPSE };
846 enum ECursor {
847 CURSOR_AUTO, CURSOR_DEFAULT, CURSOR_CONTEXT_MENU, CURSOR_HELP, CURSOR_POINTER,
848 CURSOR_PROGRESS, CURSOR_WAIT, CURSOR_CELL, CURSOR_CROSS, CURSOR_TEXT, CURSOR_VERTICAL_TEXT,
849 CURSOR_ALIAS, CURSOR_COPY, CURSOR_MOVE, CURSOR_NO_DROP, CURSOR_NOT_ALLOWED,
850 CURSOR_E_RESIZE, CURSOR_N_RESIZE, CURSOR_NE_RESIZE, CURSOR_NW_RESIZE, CURSOR_S_RESIZE, CURSOR_SE_RESIZE,
851 CURSOR_SW_RESIZE, CURSOR_W_RESIZE, CURSOR_EW_RESIZE, CURSOR_NS_RESIZE, CURSOR_NESW_RESIZE, CURSOR_NWSE_RESIZE,
852 CURSOR_COL_RESIZE, CURSOR_ROW_RESIZE, CURSOR_ALL_SCROLL, CURSOR_NONE
855 enum EUserInput {
856 UI_ENABLED, UI_DISABLED, UI_NONE
859 //------------------------------------------------
861 enum EDisplay {
862 INLINE, BLOCK, LIST_ITEM, RUN_IN,
863 COMPACT, INLINE_BLOCK, TABLE, INLINE_TABLE,
864 TABLE_ROW_GROUP, TABLE_HEADER_GROUP, TABLE_FOOTER_GROUP, TABLE_ROW,
865 TABLE_COLUMN_GROUP, TABLE_COLUMN, TABLE_CELL,
866 TABLE_CAPTION, NONE
869 class RenderStyle : public Shared<RenderStyle>
871 friend class CSSStyleSelector;
872 public:
873 KHTML_EXPORT static void cleanup();
875 // pseudo elements
876 enum PseudoId {
877 NOPSEUDO, FIRST_LINE, FIRST_LETTER, SELECTION,
878 BEFORE, AFTER, REPLACED, MARKER
881 protected:
883 // !START SYNC!: Keep this in sync with the copy constructor in render_style.cpp
885 // inherit
886 struct InheritedFlags {
887 // 64 bit inherited, update unused when adding to the struct, or the operator will break.
888 bool operator==( const InheritedFlags &other ) const
889 { return _iflags ==other._iflags; }
890 bool operator!=( const InheritedFlags &other ) const
891 { return _iflags != other._iflags; }
893 union {
894 struct {
895 KDE_BF_ENUM(EEmptyCell) _empty_cells : 1 ;
896 KDE_BF_ENUM(ECaptionSide) _caption_side : 2;
897 KDE_BF_ENUM(EListStyleType) _list_style_type : 6;
898 KDE_BF_ENUM(EListStylePosition) _list_style_position : 1;
900 KDE_BF_ENUM(EVisibility) _visibility : 2;
901 KDE_BF_ENUM(ETextAlign) _text_align : 4;
902 KDE_BF_ENUM(ETextTransform) _text_transform : 2;
903 unsigned _text_decorations : 4;
904 KDE_BF_ENUM(ECursor) _cursor_style : 5;
906 KDE_BF_ENUM(EDirection) _direction : 1;
907 unsigned _border_collapse : 1 ;
908 KDE_BF_ENUM(EWhiteSpace) _white_space : 3;
909 // non CSS2 inherited
910 unsigned _visuallyOrdered : 1;
911 unsigned _htmlHacks : 1;
912 KDE_BF_ENUM(EUserInput) _user_input : 2;
914 unsigned _page_break_inside : 1; // AUTO/AVOID
916 unsigned int unused : 27;
917 } f;
918 quint64 _iflags;
920 } inherited_flags;
922 // don't inherit
923 struct NonInheritedFlags {
924 // 64 bit non-inherited, update unused when adding to the struct, or the operator will break.
925 bool operator==( const NonInheritedFlags &other ) const
926 { return _niflags == other._niflags; }
927 bool operator!=( const NonInheritedFlags &other ) const
928 { return _niflags != other._niflags; }
930 union {
931 struct {
932 KDE_BF_ENUM(EDisplay) _display : 5;
933 KDE_BF_ENUM(EDisplay) _originalDisplay : 5;
934 KDE_BF_ENUM(EOverflow) _overflowX : 4 ;
935 KDE_BF_ENUM(EOverflow) _overflowY : 4 ;
936 KDE_BF_ENUM(EVerticalAlign) _vertical_align : 4;
937 KDE_BF_ENUM(EClear) _clear : 2;
938 KDE_BF_ENUM(EPosition) _position : 2;
939 KDE_BF_ENUM(EFloat) _floating : 3;
940 KDE_BF_ENUM(ETableLayout) _table_layout : 1;
941 unsigned _flowAroundFloats : 1;
943 KDE_BF_ENUM(EPageBreak) _page_break_before : 3;
944 KDE_BF_ENUM(EPageBreak) _page_break_after : 3;
946 KDE_BF_ENUM(PseudoId) _styleType : 4;
947 unsigned _hasClip : 1;
948 unsigned _pseudoBits : 8;
949 KDE_BF_ENUM(EUnicodeBidi) _unicodeBidi : 2;
951 // non CSS2 non-inherited
952 unsigned _textOverflow : 1; // Whether or not lines that spill out should be truncated with "..."
954 unsigned _inherited_noninherited : 1;
956 unsigned int unused : 10;
957 } f;
958 quint64 _niflags;
960 } noninherited_flags;
962 // non-inherited attributes
963 DataRef<StyleBoxData> box;
964 DataRef<StyleVisualData> visual;
965 DataRef<StyleBackgroundData> background;
966 DataRef<StyleSurroundData> surround;
967 DataRef<StyleGeneratedData> generated;
968 DataRef<StyleCSS3NonInheritedData> css3NonInheritedData;
970 // inherited attributes
971 DataRef<StyleCSS3InheritedData> css3InheritedData;
972 DataRef<StyleInheritedData> inherited;
974 // list of associated pseudo styles
975 RenderStyle* pseudoStyle;
977 // SVG Style
978 DataRef<WebCore::SVGRenderStyle> m_svgStyle;
980 // !END SYNC!
982 // static default style
983 static RenderStyle* _default;
985 private:
986 RenderStyle(const RenderStyle*) {}
988 protected:
989 void setBitDefaults()
991 inherited_flags.f._empty_cells = initialEmptyCells();
992 inherited_flags.f._caption_side = initialCaptionSide();
993 inherited_flags.f._list_style_type = initialListStyleType();
994 inherited_flags.f._list_style_position = initialListStylePosition();
995 inherited_flags.f._visibility = initialVisibility();
996 inherited_flags.f._text_align = initialTextAlign();
997 inherited_flags.f._text_transform = initialTextTransform();
998 inherited_flags.f._text_decorations = initialTextDecoration();
999 inherited_flags.f._cursor_style = initialCursor();
1000 inherited_flags.f._direction = initialDirection();
1001 inherited_flags.f._border_collapse = initialBorderCollapse();
1002 inherited_flags.f._white_space = initialWhiteSpace();
1003 inherited_flags.f._visuallyOrdered = false;
1004 inherited_flags.f._htmlHacks=false;
1005 inherited_flags.f._user_input = UI_NONE;
1006 inherited_flags.f._page_break_inside = true;
1007 inherited_flags.f.unused = 0;
1009 noninherited_flags._niflags = 0L; // for safety: without this, the equality method sometimes
1010 // makes use of uninitialised bits according to valgrind
1012 noninherited_flags.f._display = noninherited_flags.f._originalDisplay = initialDisplay();
1013 noninherited_flags.f._overflowX = initialOverflowX();
1014 noninherited_flags.f._overflowY = initialOverflowY();
1015 noninherited_flags.f._vertical_align = initialVerticalAlign();
1016 noninherited_flags.f._clear = initialClear();
1017 noninherited_flags.f._position = initialPosition();
1018 noninherited_flags.f._floating = initialFloating();
1019 noninherited_flags.f._table_layout = initialTableLayout();
1020 noninherited_flags.f._flowAroundFloats= initialFlowAroundFloats();
1021 noninherited_flags.f._page_break_before = initialPageBreak();
1022 noninherited_flags.f._page_break_after = initialPageBreak();
1023 noninherited_flags.f._styleType = NOPSEUDO;
1024 noninherited_flags.f._hasClip = false;
1025 noninherited_flags.f._pseudoBits = 0;
1026 noninherited_flags.f._unicodeBidi = initialUnicodeBidi();
1027 noninherited_flags.f._textOverflow = initialTextOverflow();
1028 noninherited_flags.f._inherited_noninherited = false;
1029 noninherited_flags.f.unused = 0;
1032 public:
1034 RenderStyle();
1035 // used to create the default style.
1036 RenderStyle(bool);
1037 RenderStyle(const RenderStyle&);
1039 ~RenderStyle();
1041 void inheritFrom(const RenderStyle* inheritParent);
1043 PseudoId styleType() const { return KDE_CAST_BF_ENUM(PseudoId, noninherited_flags.f._styleType); }
1044 void setStyleType(PseudoId pi) { noninherited_flags.f._styleType = pi; }
1045 bool isGenerated() const {
1046 if (styleType() == AFTER || styleType() == BEFORE || styleType() == MARKER || styleType() == REPLACED)
1047 return true;
1048 else
1049 return false;
1052 bool hasPseudoStyle(PseudoId pi) const;
1053 void setHasPseudoStyle(PseudoId pi, bool b=true);
1054 RenderStyle* getPseudoStyle(PseudoId pi) const;
1055 RenderStyle* addPseudoStyle(PseudoId pi);
1056 void removePseudoStyle(PseudoId pi);
1058 bool operator==(const RenderStyle& other) const;
1059 bool isFloating() const { return !(noninherited_flags.f._floating == FNONE); }
1060 bool hasMargin() const { return surround->margin.nonZero(); }
1061 bool hasBorder() const { return surround->border.hasBorder(); }
1062 bool hasPadding() const { return surround->padding.nonZero(); }
1063 bool hasOffset() const { return surround->offset.nonZero(); }
1065 bool hasBackground() const {
1066 if (backgroundColor().isValid() && backgroundColor().alpha() > 0)
1067 return true;
1068 else
1069 return background->m_background.hasImage();
1071 bool hasFixedBackgroundImage() const { return background->m_background.hasFixedImage(); }
1072 bool hasBackgroundImage() const { return background->m_background.hasImage(); }
1074 bool visuallyOrdered() const { return inherited_flags.f._visuallyOrdered; }
1075 void setVisuallyOrdered(bool b) { inherited_flags.f._visuallyOrdered = b; }
1077 // attribute getter methods
1079 EDisplay display() const { return KDE_CAST_BF_ENUM(EDisplay, noninherited_flags.f._display); }
1080 EDisplay originalDisplay() const { return KDE_CAST_BF_ENUM(EDisplay, noninherited_flags.f._originalDisplay); }
1082 Length left() const { return surround->offset.left; }
1083 Length right() const { return surround->offset.right; }
1084 Length top() const { return surround->offset.top; }
1085 Length bottom() const { return surround->offset.bottom; }
1087 EPosition position() const { return KDE_CAST_BF_ENUM(EPosition, noninherited_flags.f._position); }
1088 EFloat floating() const { return KDE_CAST_BF_ENUM(EFloat, noninherited_flags.f._floating); }
1090 Length width() const { return box->width; }
1091 Length height() const { return box->height; }
1092 Length minWidth() const { return box->min_width; }
1093 Length maxWidth() const { return box->max_width; }
1094 Length minHeight() const { return box->min_height; }
1095 Length maxHeight() const { return box->max_height; }
1097 const BorderData& border() const { return surround->border; }
1098 const BorderValue& borderLeft() const { return surround->border.left; }
1099 const BorderValue& borderRight() const { return surround->border.right; }
1100 const BorderValue& borderTop() const { return surround->border.top; }
1101 const BorderValue& borderBottom() const { return surround->border.bottom; }
1103 unsigned short borderLeftWidth() const { return surround->border.borderLeftWidth(); }
1104 EBorderStyle borderLeftStyle() const { return surround->border.left.style; }
1105 const QColor& borderLeftColor() const { return surround->border.left.color; }
1106 bool borderLeftIsTransparent() const { return surround->border.left.isTransparent(); }
1107 unsigned short borderRightWidth() const { return surround->border.borderRightWidth(); }
1108 EBorderStyle borderRightStyle() const { return surround->border.right.style; }
1109 const QColor& borderRightColor() const { return surround->border.right.color; }
1110 bool borderRightIsTransparent() const { return surround->border.right.isTransparent(); }
1111 unsigned short borderTopWidth() const { return surround->border.borderTopWidth(); }
1112 EBorderStyle borderTopStyle() const { return surround->border.top.style; }
1113 const QColor& borderTopColor() const { return surround->border.top.color; }
1114 bool borderTopIsTransparent() const { return surround->border.top.isTransparent(); }
1115 unsigned short borderBottomWidth() const { return surround->border.borderBottomWidth(); }
1116 EBorderStyle borderBottomStyle() const { return surround->border.bottom.style; }
1117 const QColor& borderBottomColor() const { return surround->border.bottom.color; }
1118 bool borderBottomIsTransparent() const { return surround->border.bottom.isTransparent(); }
1120 unsigned short outlineSize() const { return outlineWidth() + outlineOffset(); }
1121 unsigned short outlineWidth() const
1122 { if(background->m_outline.style == BNONE || background->m_outline.style == BHIDDEN) return 0;
1123 else return background->m_outline.width; }
1124 EBorderStyle outlineStyle() const { return background->m_outline.style; }
1125 bool outlineStyleIsAuto() const { return background->m_outline._auto; }
1126 const QColor & outlineColor() const { return background->m_outline.color; }
1128 EOverflow overflowX() const { return KDE_CAST_BF_ENUM(EOverflow, noninherited_flags.f._overflowX); }
1129 EOverflow overflowY() const { return KDE_CAST_BF_ENUM(EOverflow, noninherited_flags.f._overflowY); }
1130 bool hidesOverflow() const {
1131 // either both overflow are visible or none are
1132 return overflowX() != OVISIBLE;
1135 EVisibility visibility() const { return KDE_CAST_BF_ENUM(EVisibility, inherited_flags.f._visibility); }
1136 EVerticalAlign verticalAlign() const { return KDE_CAST_BF_ENUM(EVerticalAlign, noninherited_flags.f._vertical_align); }
1137 Length verticalAlignLength() const { return box->vertical_align; }
1139 Length clipLeft() const { return visual->clip.left; }
1140 Length clipRight() const { return visual->clip.right; }
1141 Length clipTop() const { return visual->clip.top; }
1142 Length clipBottom() const { return visual->clip.bottom; }
1143 LengthBox clip() const { return visual->clip; }
1144 bool hasClip() const { return noninherited_flags.f._hasClip; }
1146 EUnicodeBidi unicodeBidi() const { return KDE_CAST_BF_ENUM(EUnicodeBidi, noninherited_flags.f._unicodeBidi); }
1148 EClear clear() const { return KDE_CAST_BF_ENUM(EClear, noninherited_flags.f._clear); }
1149 ETableLayout tableLayout() const { return KDE_CAST_BF_ENUM(ETableLayout, noninherited_flags.f._table_layout); }
1151 const QFont & font() const { return inherited->font.f; }
1152 // use with care. call font->update() after modifications
1153 const Font &htmlFont() { return inherited->font; }
1154 const QFontMetrics & fontMetrics() const { return inherited->font.fm; }
1156 const QColor & color() const { return inherited->color; }
1157 Length textIndent() const { return inherited->indent; }
1158 ETextAlign textAlign() const { return KDE_CAST_BF_ENUM(ETextAlign, inherited_flags.f._text_align); }
1159 ETextTransform textTransform() const { return KDE_CAST_BF_ENUM(ETextTransform, inherited_flags.f._text_transform); }
1160 int textDecorationsInEffect() const { return inherited_flags.f._text_decorations; }
1161 int textDecoration() const { return visual->textDecoration; }
1162 int wordSpacing() const { return inherited->font.wordSpacing; }
1163 int letterSpacing() const { return inherited->font.letterSpacing; }
1165 EDirection direction() const { return KDE_CAST_BF_ENUM(EDirection, inherited_flags.f._direction); }
1166 Length lineHeight() const { return inherited->line_height; }
1168 EWhiteSpace whiteSpace() const { return KDE_CAST_BF_ENUM(EWhiteSpace, inherited_flags.f._white_space); }
1169 bool autoWrap() const {
1170 if (whiteSpace() == NORMAL || whiteSpace() == PRE_WRAP || whiteSpace() == PRE_LINE)
1171 return true;
1172 // nowrap | pre
1173 return false;
1175 bool preserveLF() const {
1176 if (whiteSpace() == PRE || whiteSpace() == PRE_WRAP || whiteSpace() == PRE_LINE)
1177 return true;
1178 // normal | nowrap
1179 return false;
1181 bool preserveWS() const {
1182 if (whiteSpace() == PRE || whiteSpace() == PRE_WRAP)
1183 return true;
1184 // normal | nowrap | pre-line
1185 return false;
1188 const QColor & backgroundColor() const { return background->m_color; }
1189 CachedImage *backgroundImage() const { return background->m_background.m_image; }
1190 EBackgroundRepeat backgroundRepeat() const { return static_cast<EBackgroundRepeat>(background->m_background.m_bgRepeat); }
1191 bool backgroundAttachment() const { return background->m_background.m_bgAttachment; }
1192 Length backgroundXPosition() const { return background->m_background.m_xPosition; }
1193 Length backgroundYPosition() const { return background->m_background.m_yPosition; }
1194 BackgroundLayer* accessBackgroundLayers() { return &(background.access()->m_background); }
1195 const BackgroundLayer* backgroundLayers() const { return &(background->m_background); }
1197 // returns true for collapsing borders, false for separate borders
1198 bool borderCollapse() const { return inherited_flags.f._border_collapse; }
1199 short borderHorizontalSpacing() const { return inherited->border_hspacing; }
1200 short borderVerticalSpacing() const { return inherited->border_vspacing; }
1201 EEmptyCell emptyCells() const { return KDE_CAST_BF_ENUM(EEmptyCell, inherited_flags.f._empty_cells); }
1202 ECaptionSide captionSide() const { return KDE_CAST_BF_ENUM(ECaptionSide, inherited_flags.f._caption_side); }
1204 EListStyleType listStyleType() const { return KDE_CAST_BF_ENUM(EListStyleType, inherited_flags.f._list_style_type); }
1205 CachedImage *listStyleImage() const { return inherited->style_image; }
1206 EListStylePosition listStylePosition() const { return KDE_CAST_BF_ENUM(EListStylePosition, inherited_flags.f._list_style_position); }
1208 Length marginTop() const { return surround->margin.top; }
1209 Length marginBottom() const { return surround->margin.bottom; }
1210 Length marginLeft() const { return surround->margin.left; }
1211 Length marginRight() const { return surround->margin.right; }
1213 Length paddingTop() const { return surround->padding.top; }
1214 Length paddingBottom() const { return surround->padding.bottom; }
1215 Length paddingLeft() const { return surround->padding.left; }
1216 Length paddingRight() const { return surround->padding.right; }
1218 ECursor cursor() const { return KDE_CAST_BF_ENUM(ECursor, inherited_flags.f._cursor_style); }
1220 short widows() const { return inherited->widows; }
1221 short orphans() const { return inherited->orphans; }
1222 bool pageBreakInside() const { return inherited_flags.f._page_break_inside; }
1223 EPageBreak pageBreakBefore() const { return KDE_CAST_BF_ENUM(EPageBreak, noninherited_flags.f._page_break_before); }
1224 EPageBreak pageBreakAfter() const { return KDE_CAST_BF_ENUM(EPageBreak, noninherited_flags.f._page_break_after); }
1226 DOM::QuotesValueImpl* quotes() const { return inherited->quotes; }
1227 QString openQuote(int level) const;
1228 QString closeQuote(int level) const;
1230 // CSS3 Getter Methods
1231 EBoxSizing boxSizing() const { return box->box_sizing; }
1232 int outlineOffset() const {
1233 if (background->m_outline.style == BNONE || background->m_outline.style == BHIDDEN) return 0;
1234 return background->m_outline._offset;
1236 ShadowData* textShadow() const { return css3InheritedData->textShadow; }
1237 float opacity() const { return css3NonInheritedData->opacity; }
1238 EUserInput userInput() const { return KDE_CAST_BF_ENUM(EUserInput, inherited_flags.f._user_input); }
1240 Length marqueeIncrement() const { return css3NonInheritedData->marquee->increment; }
1241 int marqueeSpeed() const { return css3NonInheritedData->marquee->speed; }
1242 int marqueeLoopCount() const { return css3NonInheritedData->marquee->loops; }
1243 EMarqueeBehavior marqueeBehavior() const { return css3NonInheritedData->marquee->behavior; }
1244 EMarqueeDirection marqueeDirection() const { return css3NonInheritedData->marquee->direction; }
1245 bool textOverflow() const { return noninherited_flags.f._textOverflow; }
1247 bool hasBorderRadius() const { return css3NonInheritedData->borderRadius->hasBorderRadius(); }
1248 BorderRadii borderTopRightRadius() const { return css3NonInheritedData->borderRadius->topRight; }
1249 BorderRadii borderTopLeftRadius () const { return css3NonInheritedData->borderRadius->topLeft; }
1250 BorderRadii borderBottomRightRadius() const { return css3NonInheritedData->borderRadius->bottomRight; }
1251 BorderRadii borderBottomLeftRadius () const { return css3NonInheritedData->borderRadius->bottomLeft; }
1252 // End CSS3 Getters
1254 // attribute setter methods
1256 void setDisplay(EDisplay v) { noninherited_flags.f._display = v; }
1257 void setOriginalDisplay(EDisplay v) { noninherited_flags.f._originalDisplay = v; }
1258 void setPosition(EPosition v) { noninherited_flags.f._position = v; }
1259 void setFloating(EFloat v) { noninherited_flags.f._floating = v; }
1261 void setLeft(Length v) { SET_VAR(surround,offset.left,v) }
1262 void setRight(Length v) { SET_VAR(surround,offset.right,v) }
1263 void setTop(Length v) { SET_VAR(surround,offset.top,v) }
1264 void setBottom(Length v){ SET_VAR(surround,offset.bottom,v) }
1266 void setWidth(Length v) { SET_VAR(box,width,v) }
1267 void setHeight(Length v) { SET_VAR(box,height,v) }
1269 void setMinWidth(Length v) { SET_VAR(box,min_width,v) }
1270 void setMaxWidth(Length v) { SET_VAR(box,max_width,v) }
1271 void setMinHeight(Length v) { SET_VAR(box,min_height,v) }
1272 void setMaxHeight(Length v) { SET_VAR(box,max_height,v) }
1274 void resetBorderTop() { SET_VAR(surround, border.top, BorderValue()) }
1275 void resetBorderRight() { SET_VAR(surround, border.right, BorderValue()) }
1276 void resetBorderBottom() { SET_VAR(surround, border.bottom, BorderValue()) }
1277 void resetBorderLeft() { SET_VAR(surround, border.left, BorderValue()) }
1278 void resetOutline() { SET_VAR(background, m_outline, OutlineValue()) }
1280 void setBackgroundColor(const QColor& v) { SET_VAR(background, m_color, v) }
1282 void setBorderLeftWidth(unsigned short v) { SET_VAR(surround,border.left.width,v) }
1283 void setBorderLeftStyle(EBorderStyle v) { SET_VAR(surround,border.left.style,v) }
1284 void setBorderLeftColor(const QColor & v) { SET_VAR(surround,border.left.color,v) }
1285 void setBorderRightWidth(unsigned short v) { SET_VAR(surround,border.right.width,v) }
1286 void setBorderRightStyle(EBorderStyle v) { SET_VAR(surround,border.right.style,v) }
1287 void setBorderRightColor(const QColor & v) { SET_VAR(surround,border.right.color,v) }
1288 void setBorderTopWidth(unsigned short v) { SET_VAR(surround,border.top.width,v) }
1289 void setBorderTopStyle(EBorderStyle v) { SET_VAR(surround,border.top.style,v) }
1290 void setBorderTopColor(const QColor & v) { SET_VAR(surround,border.top.color,v) }
1291 void setBorderBottomWidth(unsigned short v) { SET_VAR(surround,border.bottom.width,v) }
1292 void setBorderBottomStyle(EBorderStyle v) { SET_VAR(surround,border.bottom.style,v) }
1293 void setBorderBottomColor(const QColor & v) { SET_VAR(surround,border.bottom.color,v) }
1294 void setOutlineWidth(unsigned short v) { SET_VAR(background,m_outline.width,v) }
1295 void setOutlineStyle(EBorderStyle v, bool isAuto = false)
1297 SET_VAR(background,m_outline.style,v)
1298 SET_VAR(background,m_outline._auto, isAuto)
1300 void setOutlineColor(const QColor & v) { SET_VAR(background,m_outline.color,v) }
1302 void setOverflowX(EOverflow v) { noninherited_flags.f._overflowX = v; }
1303 void setOverflowY(EOverflow v) { noninherited_flags.f._overflowY = v; }
1304 void setVisibility(EVisibility v) { inherited_flags.f._visibility = v; }
1305 void setVerticalAlign(EVerticalAlign v) { noninherited_flags.f._vertical_align = v; }
1306 void setVerticalAlignLength(Length l) { SET_VAR(box, vertical_align, l ) }
1308 void setClipLeft(Length v) { SET_VAR(visual,clip.left,v) }
1309 void setClipRight(Length v) { SET_VAR(visual,clip.right,v) }
1310 void setClipTop(Length v) { SET_VAR(visual,clip.top,v) }
1311 void setClipBottom(Length v) { SET_VAR(visual,clip.bottom,v) }
1312 void setClip( Length top, Length right, Length bottom, Length left );
1313 void setHasClip( bool b ) { noninherited_flags.f._hasClip = b; }
1315 void setUnicodeBidi( EUnicodeBidi b ) { noninherited_flags.f._unicodeBidi = b; }
1317 void setClear(EClear v) { noninherited_flags.f._clear = v; }
1318 void setTableLayout(ETableLayout v) { noninherited_flags.f._table_layout = v; }
1319 bool setFontDef(const khtml::FontDef & v) {
1320 // bah, this doesn't compare pointers. broken! (Dirk)
1321 if (!(inherited->font.fontDef == v)) {
1322 inherited.access()->font = Font( v );
1323 return true;
1325 return false;
1328 void setColor(const QColor & v) { SET_VAR(inherited,color,v) }
1329 void setTextIndent(Length v) { SET_VAR(inherited,indent,v) }
1330 void setTextAlign(ETextAlign v) { inherited_flags.f._text_align = v; }
1331 void setTextTransform(ETextTransform v) { inherited_flags.f._text_transform = v; }
1332 void addToTextDecorationsInEffect(int v) { inherited_flags.f._text_decorations |= v; }
1333 void setTextDecorationsInEffect(int v) { inherited_flags.f._text_decorations = v; }
1334 void setTextDecoration(unsigned v) { SET_VAR(visual, textDecoration, v); }
1335 void setDirection(EDirection v) { inherited_flags.f._direction = v; }
1336 void setLineHeight(Length v) { SET_VAR(inherited,line_height,v) }
1338 void setWhiteSpace(EWhiteSpace v) { inherited_flags.f._white_space = v; }
1340 void setWordSpacing(int v) { SET_VAR(inherited,font.wordSpacing,v) }
1341 void setLetterSpacing(int v) { SET_VAR(inherited,font.letterSpacing,v) }
1343 void clearBackgroundLayers() { background.access()->m_background = BackgroundLayer(); }
1344 void inheritBackgroundLayers(const BackgroundLayer& parent) { background.access()->m_background = parent; }
1345 void adjustBackgroundLayers();
1347 void setBorderCollapse(bool collapse) { inherited_flags.f._border_collapse = collapse; }
1348 void setBorderHorizontalSpacing(short v) { SET_VAR(inherited,border_hspacing,v) }
1349 void setBorderVerticalSpacing(short v) { SET_VAR(inherited,border_vspacing,v) }
1351 void setEmptyCells(EEmptyCell v) { inherited_flags.f._empty_cells = v; }
1352 void setCaptionSide(ECaptionSide v) { inherited_flags.f._caption_side = v; }
1354 void setListStyleType(EListStyleType v) { inherited_flags.f._list_style_type = v; }
1355 void setListStyleImage(CachedImage *v) { SET_VAR(inherited,style_image,v)}
1356 void setListStylePosition(EListStylePosition v) { inherited_flags.f._list_style_position = v; }
1358 void resetMargin() { SET_VAR(surround, margin, LengthBox(Fixed)) }
1359 void setMarginTop(Length v) { SET_VAR(surround,margin.top,v) }
1360 void setMarginBottom(Length v) { SET_VAR(surround,margin.bottom,v) }
1361 void setMarginLeft(Length v) { SET_VAR(surround,margin.left,v) }
1362 void setMarginRight(Length v) { SET_VAR(surround,margin.right,v) }
1364 void resetPadding() { SET_VAR(surround, padding, LengthBox(Variable)) }
1365 void setPaddingTop(Length v) { SET_VAR(surround,padding.top,v) }
1366 void setPaddingBottom(Length v) { SET_VAR(surround,padding.bottom,v) }
1367 void setPaddingLeft(Length v) { SET_VAR(surround,padding.left,v) }
1368 void setPaddingRight(Length v) { SET_VAR(surround,padding.right,v) }
1370 void setCursor( ECursor c ) { inherited_flags.f._cursor_style = c; }
1372 bool htmlHacks() const { return inherited_flags.f._htmlHacks; }
1373 void setHtmlHacks(bool b=true) { inherited_flags.f._htmlHacks = b; }
1375 bool flowAroundFloats() const { return noninherited_flags.f._flowAroundFloats; }
1376 void setFlowAroundFloats(bool b=true) { noninherited_flags.f._flowAroundFloats = b; }
1378 int zIndex() const { return box->z_auto? 0 : box->z_index; }
1379 void setZIndex(int v) { SET_VAR(box,z_auto,false ); SET_VAR(box, z_index, v); }
1380 bool hasAutoZIndex() const { return box->z_auto; }
1381 void setHasAutoZIndex() { SET_VAR(box, z_auto, true ); }
1383 void setWidows(short w) { SET_VAR(inherited, widows, w); }
1384 void setOrphans(short o) { SET_VAR(inherited, orphans, o); }
1385 void setPageBreakInside(bool b) { inherited_flags.f._page_break_inside = b; }
1386 void setPageBreakBefore(EPageBreak b) { noninherited_flags.f._page_break_before = b; }
1387 void setPageBreakAfter(EPageBreak b) { noninherited_flags.f._page_break_after = b; }
1389 void setQuotes(DOM::QuotesValueImpl* q);
1391 // CSS3 Setters
1392 void setBoxSizing( EBoxSizing b ) { SET_VAR(box,box_sizing,b); }
1393 void setOutlineOffset(unsigned short v) { SET_VAR(background,m_outline._offset,v) }
1394 void setTextShadow(ShadowData* val, bool add=false);
1395 void setOpacity(float f) { SET_VAR(css3NonInheritedData, opacity, f); }
1396 void setUserInput(EUserInput ui) { inherited_flags.f._user_input = ui; }
1398 void setMarqueeIncrement(const Length& f) { SET_VAR(css3NonInheritedData.access()->marquee, increment, f); }
1399 void setMarqueeSpeed(int f) { SET_VAR(css3NonInheritedData.access()->marquee, speed, f); }
1400 void setMarqueeDirection(EMarqueeDirection d) { SET_VAR(css3NonInheritedData.access()->marquee, direction, d); }
1401 void setMarqueeBehavior(EMarqueeBehavior b) { SET_VAR(css3NonInheritedData.access()->marquee, behavior, b); }
1402 void setMarqueeLoopCount(int i) { SET_VAR(css3NonInheritedData.access()->marquee, loops, i); }
1403 void setTextOverflow(bool b) { noninherited_flags.f._textOverflow = b; }
1405 void setBorderTopRightRadius(const BorderRadii& r) {
1406 SET_VAR(css3NonInheritedData.access()->borderRadius, topRight, r);
1409 void setBorderTopLeftRadius(const BorderRadii& r) {
1410 SET_VAR(css3NonInheritedData.access()->borderRadius, topLeft, r);
1413 void setBorderBottomRightRadius(const BorderRadii& r) {
1414 SET_VAR(css3NonInheritedData.access()->borderRadius, bottomRight, r);
1417 void setBorderBottomLeftRadius(const BorderRadii& r) {
1418 SET_VAR(css3NonInheritedData.access()->borderRadius, bottomLeft, r);
1421 // End CSS3 Setters
1423 QPalette palette() const { return visual->palette; }
1424 void setPaletteColor(QPalette::ColorGroup g, QPalette::ColorRole r, const QColor& c);
1425 void resetPalette() // Called when the desktop color scheme changes.
1427 const_cast<StyleVisualData *>(visual.get())->palette = QApplication::palette();
1430 bool useNormalContent() const { return generated->content == 0; }
1431 ContentData* contentData() const { return generated->content; }
1432 bool contentDataEquivalent(const RenderStyle* otherStyle) const
1434 return generated->contentDataEquivalent(otherStyle->generated.get());
1436 void addContent(DOM::DOMStringImpl* s);
1437 void addContent(CachedObject* o);
1438 void addContent(DOM::CounterImpl* c);
1439 void addContent(EQuoteContent q);
1440 void setContentNone();
1441 void setContentNormal();
1442 void setContentData(ContentData* content);
1444 DOM::CSSValueListImpl* counterReset() const { return generated->counter_reset; }
1445 DOM::CSSValueListImpl* counterIncrement() const { return generated->counter_increment; }
1446 void setCounterReset(DOM::CSSValueListImpl* v);
1447 void setCounterIncrement(DOM::CSSValueListImpl* v);
1448 bool hasCounterReset(const DOM::DOMString& c) const;
1449 bool hasCounterIncrement(const DOM::DOMString& c) const;
1450 short counterReset(const DOM::DOMString& c) const;
1451 short counterIncrement(const DOM::DOMString& c) const;
1453 bool inheritedNotEqual( RenderStyle *other ) const;
1455 enum Diff { Equal, NonVisible = Equal, Visible, Position, Layout, CbLayout };
1456 Diff diff( const RenderStyle *other ) const;
1458 bool isDisplayReplacedType() {
1459 return display() == INLINE_BLOCK ||/* display() == INLINE_BOX ||*/ display() == INLINE_TABLE;
1461 bool isDisplayInlineType() {
1462 return display() == INLINE || isDisplayReplacedType();
1464 bool isOriginalDisplayInlineType() {
1465 return originalDisplay() == INLINE || originalDisplay() == INLINE_BLOCK ||
1466 /*originalDisplay() == INLINE_BOX ||*/ originalDisplay() == INLINE_TABLE;
1469 bool inheritedNoninherited() const { return noninherited_flags.f._inherited_noninherited; }
1470 void setInheritedNoninherited(bool b) { noninherited_flags.f._inherited_noninherited = b; }
1472 #ifdef ENABLE_DUMP
1473 QString createDiff( const RenderStyle &parent ) const;
1474 #endif
1476 // Initial values for all the properties
1477 static bool initialBackgroundAttachment() { return true; }
1478 static EBackgroundBox initialBackgroundClip() { return BGBORDER; }
1479 static EBackgroundBox initialBackgroundOrigin() { return BGPADDING; }
1480 static EBackgroundRepeat initialBackgroundRepeat() { return REPEAT; }
1481 static LengthSize initialBackgroundSize() { return LengthSize(); }
1482 static bool initialBorderCollapse() { return false; }
1483 static EBorderStyle initialBorderStyle() { return BNONE; }
1484 static ECaptionSide initialCaptionSide() { return CAPTOP; }
1485 static EClear initialClear() { return CNONE; }
1486 static EDirection initialDirection() { return LTR; }
1487 static EDisplay initialDisplay() { return INLINE; }
1488 static EEmptyCell initialEmptyCells() { return SHOW; }
1489 static EFloat initialFloating() { return FNONE; }
1490 static EListStylePosition initialListStylePosition() { return OUTSIDE; }
1491 static EListStyleType initialListStyleType() { return LDISC; }
1492 static EOverflow initialOverflowX() { return OVISIBLE; }
1493 static EOverflow initialOverflowY() { return OVISIBLE; }
1494 static EPageBreak initialPageBreak() { return PBAUTO; }
1495 static bool initialPageBreakInside() { return true; }
1496 static EPosition initialPosition() { return PSTATIC; }
1497 static ETableLayout initialTableLayout() { return TAUTO; }
1498 static EUnicodeBidi initialUnicodeBidi() { return UBNormal; }
1499 static DOM::QuotesValueImpl* initialQuotes() { return 0; }
1500 static EBoxSizing initialBoxSizing() { return CONTENT_BOX; }
1501 static ETextTransform initialTextTransform() { return TTNONE; }
1502 static EVisibility initialVisibility() { return VISIBLE; }
1503 static EWhiteSpace initialWhiteSpace() { return NORMAL; }
1504 static Length initialBackgroundXPosition() { return Length(); }
1505 static Length initialBackgroundYPosition() { return Length(); }
1506 static short initialBorderHorizontalSpacing() { return 0; }
1507 static short initialBorderVerticalSpacing() { return 0; }
1508 static ECursor initialCursor() { return CURSOR_AUTO; }
1509 static QColor initialColor() { return Qt::black; }
1510 static CachedImage* initialBackgroundImage() { return 0; }
1511 static CachedImage* initialListStyleImage() { return 0; }
1512 static unsigned short initialBorderWidth() { return 3; }
1513 static int initialLetterWordSpacing() { return 0; }
1514 static Length initialSize() { return Length(); }
1515 static Length initialMinSize() { return Length(0, Fixed); }
1516 static Length initialMaxSize() { return Length(UNDEFINED, Fixed); }
1517 static Length initialOffset() { return Length(); }
1518 static Length initialMargin() { return Length(Fixed); }
1519 static Length initialPadding() { return Length(Variable); }
1520 static Length initialTextIndent() { return Length(Fixed); }
1521 static EVerticalAlign initialVerticalAlign() { return BASELINE; }
1522 static int initialWidows() { return 2; }
1523 static int initialOrphans() { return 2; }
1524 static Length initialLineHeight() { return Length(-100, Percent); }
1525 static ETextAlign initialTextAlign() { return TAAUTO; }
1526 static ETextDecoration initialTextDecoration() { return TDNONE; }
1527 static bool initialFlowAroundFloats() { return false; }
1528 static int initialOutlineOffset() { return 0; }
1529 static float initialOpacity() { return 1.0f; }
1530 static int initialMarqueeLoopCount() { return -1; }
1531 static int initialMarqueeSpeed() { return 85; }
1532 static Length initialMarqueeIncrement() { return Length(6, Fixed); }
1533 static EMarqueeBehavior initialMarqueeBehavior() { return MSCROLL; }
1534 static EMarqueeDirection initialMarqueeDirection() { return MAUTO; }
1535 static bool initialTextOverflow() { return false; }
1537 // SVG
1538 const WebCore::SVGRenderStyle* svgStyle() const { return m_svgStyle.get(); }
1539 WebCore::SVGRenderStyle* accessSVGStyle() { return m_svgStyle.access(); }
1542 class RenderPageStyle {
1543 friend class CSSStyleSelector;
1544 public:
1545 enum PageType { NO_PAGE = 0, ANY_PAGE, FIRST_PAGE, LEFT_PAGES, RIGHT_PAGES };
1547 RenderPageStyle();
1548 ~RenderPageStyle();
1550 PageType pageType() { return m_pageType; }
1552 RenderPageStyle* getPageStyle(PageType type);
1553 RenderPageStyle* addPageStyle(PageType type);
1554 void removePageStyle(PageType type);
1556 Length marginTop() const { return margin.top; }
1557 Length marginBottom() const { return margin.bottom; }
1558 Length marginLeft() const { return margin.left; }
1559 Length marginRight() const { return margin.right; }
1561 Length pageWidth() const { return m_pageWidth; }
1562 Length pageHeight() const { return m_pageHeight; }
1564 void setMarginTop(Length v) { margin.top = v; }
1565 void setMarginBottom(Length v) { margin.bottom = v; }
1566 void setMarginLeft(Length v) { margin.left = v; }
1567 void setMarginRight(Length v) { margin.right = v; }
1569 void setPageWidth(Length v) { m_pageWidth = v; }
1570 void setPageHeight(Length v) { m_pageHeight = v; }
1572 protected:
1573 RenderPageStyle *next;
1574 PageType m_pageType;
1576 LengthBox margin;
1577 Length m_pageWidth;
1578 Length m_pageHeight;
1581 } // namespace
1583 #endif