1 /*
2  * This file is part of the DOM implementation for KDE.
3  *
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)
9  *
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.
14  *
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.
19  *
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.
24  *
25  */
26 #ifndef RENDERSTYLE_H
27 #define RENDERSTYLE_H
28 
29 /*
30  * WARNING:
31  * --------
32  *
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.
36  */
37 
38 #include <QColor>
39 #include <QFont>
40 #include <QFontMetrics>
41 #include <QPalette>
42 #include <QApplication>
43 
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/DataRef.h"
49 #include "rendering/font.h"
50 #include "rendering/SVGRenderStyle.h"
51 
52 #include <assert.h>
53 
54 #define SET_VAR(group,variable,value) \
55     if (!(group->variable == value)) \
56         group.access()->variable = value;
57 
58 #ifndef ENABLE_DUMP
59 #ifndef NDEBUG
60 #define ENABLE_DUMP 1
61 #endif
62 #endif
63 
64 namespace DOM
65 {
66 class DOMStringImpl;
67 class QuotesValueImpl;
68 class CounterImpl;
69 class CSSValueListImpl;
70 }
71 
72 namespace khtml
73 {
74 
75 class CachedImage;
76 class CachedObject;
77 
78 //------------------------------------------------
79 
80 //------------------------------------------------
81 // Box model attributes. Not inherited.
82 
83 struct LengthBox {
LengthBoxLengthBox84     LengthBox()
85     {
86     }
LengthBoxLengthBox87     LengthBox(LengthType t)
88         : left(t), right(t), top(t), bottom(t) {}
89 
90     Length left;
91     Length right;
92     Length top;
93     Length bottom;
94     Length &operator=(Length &len)
95     {
96         left = len;
97         right = len;
98         top = len;
99         bottom = len;
100         return len;
101     }
102 
103     bool operator==(const LengthBox &o) const
104     {
105         return left == o.left && right == o.right && top == o.top && bottom == o.bottom;
106     }
107 
nonZeroLengthBox108     bool nonZero() const
109     {
110         return !(left.isZero() && right.isZero() && top.isZero() && bottom.isZero());
111     }
112 };
113 
114 enum EPosition {
115     PSTATIC, PRELATIVE, PABSOLUTE, PFIXED
116 };
117 
118 enum EFloat {
119     FNONE = 0, FLEFT = 0x01, FRIGHT = 0x02, FLEFT_ALIGN = 0x05, FRIGHT_ALIGN = 0x06
120 };
121 
122 enum EWordWrap {
123     WWNORMAL = 0, WWBREAKWORD = 0x01
124 };
125 
126 //------------------------------------------------
127 // Border attributes. Not inherited.
128 
129 // These have been defined in the order of their precedence for border-collapsing. Do
130 // not change this order!
131 enum EBorderStyle {
132     BNATIVE, BNONE, BHIDDEN, INSET, GROOVE, RIDGE, OUTSET, DOTTED, DASHED, SOLID, DOUBLE
133 };
134 
135 class BorderValue
136 {
137 public:
BorderValue()138     BorderValue() : width(3), style(BNONE) {}
139 
140     QColor color;
141     unsigned short width : 12;
142     EBorderStyle style : 6;
143 
144     bool nonZero(bool checkStyle = true) const
145     {
146         return width != 0 && !(checkStyle && style == BNONE);
147     }
148 
isTransparent()149     bool isTransparent() const
150     {
151         return color.isValid() && color.alpha() == 0;
152     }
153 
154     bool operator==(const BorderValue &o) const
155     {
156         return width == o.width && style == o.style && color == o.color;
157     }
158 
159     bool operator!=(const BorderValue &o) const
160     {
161         return !(*this == o);
162     }
163 };
164 
165 class OutlineValue : public BorderValue
166 {
167 public:
OutlineValue()168     OutlineValue() : _offset(0), _auto(false) {}
169 
170     bool operator==(const OutlineValue &o) const
171     {
172         return width == o.width && style == o.style && color == o.color && _offset == o._offset && _auto == o._auto;
173     }
174 
175     bool operator!=(const OutlineValue &o) const
176     {
177         return !(*this == o);
178     }
179 
180     int _offset;
181     bool _auto;
182 };
183 
184 enum EBorderPrecedence { BOFF, BTABLE, BCOLGROUP, BCOL, BROWGROUP, BROW, BCELL };
185 
186 struct CollapsedBorderValue {
CollapsedBorderValueCollapsedBorderValue187     CollapsedBorderValue() : border(nullptr), precedence(BOFF) {}
CollapsedBorderValueCollapsedBorderValue188     CollapsedBorderValue(const BorderValue *b, EBorderPrecedence p) : border(b), precedence(p) {}
189 
widthCollapsedBorderValue190     int width() const
191     {
192         return border && border->nonZero() ? border->width : 0;
193     }
styleCollapsedBorderValue194     EBorderStyle style() const
195     {
196         return border ? border->style : BHIDDEN;
197     }
existsCollapsedBorderValue198     bool exists() const
199     {
200         return border;
201     }
colorCollapsedBorderValue202     QColor color() const
203     {
204         return border ? border->color : QColor();
205     }
isTransparentCollapsedBorderValue206     bool isTransparent() const
207     {
208         return border ? border->isTransparent() : true;
209     }
210 
211     bool operator==(const CollapsedBorderValue &o) const
212     {
213         if (!border) {
214             return !o.border;
215         }
216         if (!o.border) {
217             return false;
218         }
219         return *border == *o.border && precedence == o.precedence;
220     }
221 
222     const BorderValue *border;
223     EBorderPrecedence precedence;
224 };
225 
226 class BorderData : public Shared<BorderData>
227 {
228 public:
BorderData()229     BorderData() : Shared< khtml::BorderData >() {};
BorderData(const khtml::BorderData & other)230     BorderData(const khtml::BorderData &other) : Shared<khtml::BorderData>()
231     {
232         this->left = other.left;
233         this->right = other.right;
234         this->top = other.top;
235         this->bottom = other.bottom;
236     }
237 
238     BorderValue left;
239     BorderValue right;
240     BorderValue top;
241     BorderValue bottom;
242 
hasBorder()243     bool hasBorder() const
244     {
245         return left.nonZero() || right.nonZero() || top.nonZero() || bottom.nonZero();
246     }
247 
borderLeftWidth()248     unsigned short borderLeftWidth() const
249     {
250         if (left.style == BNONE || left.style == BHIDDEN || left.style == BNATIVE) {
251             return 0;
252         }
253         return left.width;
254     }
255 
borderRightWidth()256     unsigned short borderRightWidth() const
257     {
258         if (right.style == BNONE || right.style == BHIDDEN || right.style == BNATIVE) {
259             return 0;
260         }
261         return right.width;
262     }
263 
borderTopWidth()264     unsigned short borderTopWidth() const
265     {
266         if (top.style == BNONE || top.style == BHIDDEN || top.style == BNATIVE) {
267             return 0;
268         }
269         return top.width;
270     }
271 
borderBottomWidth()272     unsigned short borderBottomWidth() const
273     {
274         if (bottom.style == BNONE || bottom.style == BHIDDEN || bottom.style == BNATIVE) {
275             return 0;
276         }
277         return bottom.width;
278     }
279 
280     bool operator==(const BorderData &o) const
281     {
282         return left == o.left && right == o.right && top == o.top && bottom == o.bottom;
283     }
284 
285 };
286 
287 class StyleSurroundData : public Shared<StyleSurroundData>
288 {
289 public:
290     StyleSurroundData();
291 
292     StyleSurroundData(const StyleSurroundData &o);
293     bool operator==(const StyleSurroundData &o) const;
294     bool operator!=(const StyleSurroundData &o) const
295     {
296         return !(*this == o);
297     }
hasSamePBMData(const StyleSurroundData & o)298     bool hasSamePBMData(const StyleSurroundData &o) const
299     {
300         return (margin == o.margin) && (padding == o.padding) && (border == o.border);
301     }
302 
303     LengthBox offset;
304     LengthBox margin;
305     LengthBox padding;
306     BorderData border;
307 };
308 
309 //------------------------------------------------
310 // Box attributes. Not inherited.
311 
312 enum EBoxSizing {
313     BORDER_BOX, CONTENT_BOX
314 };
315 
316 class StyleBoxData : public Shared<StyleBoxData>
317 {
318 public:
319     StyleBoxData();
320 
321     StyleBoxData(const StyleBoxData &o);
322 
323     // copy and assignment
324 //    StyleBoxData(const StyleBoxData &other);
325 //    const StyleBoxData &operator = (const StyleBoxData &other);
326 
327     bool operator==(const StyleBoxData &o) const;
328     bool operator!=(const StyleBoxData &o) const
329     {
330         return !(*this == o);
331     }
332 
333     Length width;
334     Length height;
335 
336     Length min_width;
337     Length max_width;
338 
339     Length min_height;
340     Length max_height;
341 
342     Length vertical_align;
343 
344     EBoxSizing box_sizing;
345 
346     int z_index;
347     bool z_auto;
348 };
349 
350 //------------------------------------------------
351 // Random visual rendering model attributes. Not inherited.
352 
353 enum EOverflow {
354     OVISIBLE, OHIDDEN, OSCROLL, OAUTO, OMARQUEE
355 };
356 
357 enum EVerticalAlign {
358     BASELINE, MIDDLE, SUB, SUPER, TEXT_TOP,
359     TEXT_BOTTOM, TOP, BOTTOM, BASELINE_MIDDLE, LENGTH
360 };
361 
362 enum EClear {
363     CNONE = 0, CLEFT = 1, CRIGHT = 2, CBOTH = 3
364 };
365 
366 enum ETableLayout {
367     TAUTO, TFIXED
368 };
369 
370 enum EUnicodeBidi {
371     UBNormal, Embed, Override
372 };
373 
374 class StyleVisualData : public Shared<StyleVisualData>
375 {
376 public:
377     StyleVisualData();
378 
379     ~StyleVisualData();
380 
381     StyleVisualData(const StyleVisualData &o);
382 
383     bool operator==(const StyleVisualData &o) const
384     {
385         return (clip == o.clip && textDecoration == o.textDecoration &&
386                 palette == o.palette);
387     }
388     bool operator!=(const StyleVisualData &o) const
389     {
390         return !(*this == o);
391     }
392 
393     LengthBox clip;
394     unsigned textDecoration : 4; // Text decorations defined *only* by this element.
395 
396     QPalette palette;      //widget styling with IE attributes
397 
398 };
399 
400 //------------------------------------------------
401 enum EBackgroundBox {
402     BGBORDER, BGPADDING, BGCONTENT
403 };
404 
405 enum EBackgroundRepeat {
406     REPEAT, REPEAT_X, REPEAT_Y, NO_REPEAT
407 };
408 
409 enum EBackgroundSizeType {
410     BGSLENGTH, BGSCONTAIN, BGSCOVER
411 };
412 
413 enum EBackgroundAttachment {
414     BGASCROLL, BGAFIXED, BGALOCAL
415 };
416 
417 struct BGSize {
BGSizeBGSize418     BGSize() : type(BGSLENGTH), width(Length()), height(Length()) {}
419     // Use to set BGSCONTAIN|BGSCOVER
BGSizeBGSize420     BGSize(EBackgroundSizeType t) : type(t), width(Length()), height(Length())
421     {
422         Q_ASSERT(t != BGSLENGTH);
423     }
424     // Use to set lenghts
BGSizeBGSize425     BGSize(Length w, Length h) : type(BGSLENGTH), width(w), height(h) {}
426 
427     bool operator==(const BGSize &o) const
428     {
429         return type == o.type && width == o.width && height == o.height;
430     }
431 
432     EBackgroundSizeType type : 2;
433     Length width;
434     Length height;
435 };
436 
437 struct BackgroundLayer {
438 public:
439     BackgroundLayer();
440     ~BackgroundLayer();
441 
backgroundImageBackgroundLayer442     CachedImage *backgroundImage() const
443     {
444         return m_image;
445     }
backgroundXPositionBackgroundLayer446     Length backgroundXPosition() const
447     {
448         return m_xPosition;
449     }
backgroundYPositionBackgroundLayer450     Length backgroundYPosition() const
451     {
452         return m_yPosition;
453     }
backgroundAttachmentBackgroundLayer454     EBackgroundAttachment backgroundAttachment() const
455     {
456         return KDE_CAST_BF_ENUM(EBackgroundAttachment, m_bgAttachment);
457     }
backgroundClipBackgroundLayer458     EBackgroundBox backgroundClip() const
459     {
460         return KDE_CAST_BF_ENUM(EBackgroundBox, m_bgClip);
461     }
backgroundOriginBackgroundLayer462     EBackgroundBox backgroundOrigin() const
463     {
464         return KDE_CAST_BF_ENUM(EBackgroundBox, m_bgOrigin);
465     }
backgroundRepeatBackgroundLayer466     EBackgroundRepeat backgroundRepeat() const
467     {
468         return KDE_CAST_BF_ENUM(EBackgroundRepeat, m_bgRepeat);
469     }
backgroundSizeBackgroundLayer470     BGSize backgroundSize() const
471     {
472         return m_backgroundSize;
473     }
474 
nextBackgroundLayer475     BackgroundLayer *next() const
476     {
477         return m_next;
478     }
nextBackgroundLayer479     BackgroundLayer *next()
480     {
481         return m_next;
482     }
483 
isBackgroundImageSetBackgroundLayer484     bool isBackgroundImageSet() const
485     {
486         return m_imageSet;
487     }
isBackgroundXPositionSetBackgroundLayer488     bool isBackgroundXPositionSet() const
489     {
490         return m_xPosSet;
491     }
isBackgroundYPositionSetBackgroundLayer492     bool isBackgroundYPositionSet() const
493     {
494         return m_yPosSet;
495     }
isBackgroundAttachmentSetBackgroundLayer496     bool isBackgroundAttachmentSet() const
497     {
498         return m_attachmentSet;
499     }
isBackgroundClipSetBackgroundLayer500     bool isBackgroundClipSet() const
501     {
502         return m_clipSet;
503     }
isBackgroundOriginSetBackgroundLayer504     bool isBackgroundOriginSet() const
505     {
506         return m_originSet;
507     }
isBackgroundRepeatSetBackgroundLayer508     bool isBackgroundRepeatSet() const
509     {
510         return m_repeatSet;
511     }
isBackgroundSizeSetBackgroundLayer512     bool isBackgroundSizeSet() const
513     {
514         return m_backgroundSizeSet;
515     }
516 
setBackgroundImageBackgroundLayer517     void setBackgroundImage(CachedImage *i)
518     {
519         m_image = i;
520         m_imageSet = true;
521     }
setBackgroundXPositionBackgroundLayer522     void setBackgroundXPosition(const Length &l)
523     {
524         m_xPosition = l;
525         m_xPosSet = true;
526     }
setBackgroundYPositionBackgroundLayer527     void setBackgroundYPosition(const Length &l)
528     {
529         m_yPosition = l;
530         m_yPosSet = true;
531     }
setBackgroundAttachmentBackgroundLayer532     void setBackgroundAttachment(EBackgroundAttachment b)
533     {
534         m_bgAttachment = b;
535         m_attachmentSet = true;
536     }
setBackgroundClipBackgroundLayer537     void setBackgroundClip(EBackgroundBox b)
538     {
539         m_bgClip = b;
540         m_clipSet = true;
541     }
setBackgroundOriginBackgroundLayer542     void setBackgroundOrigin(EBackgroundBox b)
543     {
544         m_bgOrigin = b;
545         m_originSet = true;
546     }
setBackgroundRepeatBackgroundLayer547     void setBackgroundRepeat(EBackgroundRepeat r)
548     {
549         m_bgRepeat = r;
550         m_repeatSet = true;
551     }
setBackgroundSizeBackgroundLayer552     void setBackgroundSize(const BGSize &b)
553     {
554         m_backgroundSize = b;
555         m_backgroundSizeSet = true;
556     }
557 
clearBackgroundImageBackgroundLayer558     void clearBackgroundImage()
559     {
560         m_imageSet = false;
561     }
clearBackgroundXPositionBackgroundLayer562     void clearBackgroundXPosition()
563     {
564         m_xPosSet = false;
565     }
clearBackgroundYPositionBackgroundLayer566     void clearBackgroundYPosition()
567     {
568         m_yPosSet = false;
569     }
clearBackgroundAttachmentBackgroundLayer570     void clearBackgroundAttachment()
571     {
572         m_attachmentSet = false;
573     }
clearBackgroundClipBackgroundLayer574     void clearBackgroundClip()
575     {
576         m_clipSet = false;
577     }
clearBackgroundOriginBackgroundLayer578     void clearBackgroundOrigin()
579     {
580         m_originSet = false;
581     }
clearBackgroundRepeatBackgroundLayer582     void clearBackgroundRepeat()
583     {
584         m_repeatSet = false;
585     }
clearBackgroundSizeBackgroundLayer586     void clearBackgroundSize()
587     {
588         m_backgroundSizeSet = false;
589     }
590 
setNextBackgroundLayer591     void setNext(BackgroundLayer *n)
592     {
593         if (m_next != n) {
594             delete m_next;
595             m_next = n;
596         }
597     }
598 
599     BackgroundLayer &operator=(const BackgroundLayer &o);
600     BackgroundLayer(const BackgroundLayer &o);
601 
602     bool operator==(const BackgroundLayer &o) const;
603     bool operator!=(const BackgroundLayer &o) const
604     {
605         return !(*this == o);
606     }
607 
containsImageBackgroundLayer608     bool containsImage(CachedImage *c) const
609     {
610         if (c == m_image) {
611             return true;
612         } if (m_next) {
613             return m_next->containsImage(c);
614         } return false;
615     }
616 
hasImageBackgroundLayer617     bool hasImage() const
618     {
619         if (m_image) {
620             return true;
621         }
622         return m_next ? m_next->hasImage() : false;
623     }
hasFixedImageBackgroundLayer624     bool hasFixedImage() const
625     {
626         if (m_image && m_bgAttachment == BGAFIXED) {
627             return true;
628         }
629         return m_next ? m_next->hasFixedImage() : false;
630     }
631 
632     void fillUnsetProperties();
633     void cullEmptyLayers();
634 
635     CachedImage *m_image;
636 
637     Length m_xPosition;
638     Length m_yPosition;
639 
640     KDE_BF_ENUM(EBackgroundAttachment) m_bgAttachment : 2;
641     KDE_BF_ENUM(EBackgroundBox) m_bgClip : 2;
642     KDE_BF_ENUM(EBackgroundBox) m_bgOrigin : 2;
643     KDE_BF_ENUM(EBackgroundRepeat) m_bgRepeat : 2;
644 
645     BGSize m_backgroundSize;
646 
647     bool m_imageSet : 1;
648     bool m_attachmentSet : 1;
649     bool m_clipSet : 1;
650     bool m_originSet : 1;
651     bool m_repeatSet : 1;
652     bool m_xPosSet : 1;
653     bool m_yPosSet : 1;
654     bool m_backgroundSizeSet : 1;
655 
656     BackgroundLayer *m_next;
657 };
658 
659 class StyleBackgroundData : public Shared<StyleBackgroundData>
660 {
661 public:
662     StyleBackgroundData();
~StyleBackgroundData()663     ~StyleBackgroundData() {}
664     StyleBackgroundData(const StyleBackgroundData &o);
665 
666     bool operator==(const StyleBackgroundData &o) const;
667     bool operator!=(const StyleBackgroundData &o) const
668     {
669         return !(*this == o);
670     }
671 
672     BackgroundLayer m_background;
673     QColor m_color;
674     OutlineValue m_outline;
675 };
676 
677 enum EQuoteContent {
678     NO_QUOTE = 0, OPEN_QUOTE, CLOSE_QUOTE, NO_OPEN_QUOTE, NO_CLOSE_QUOTE
679 };
680 
681 enum ContentType {
682     CONTENT_NONE = 0, CONTENT_NORMAL, CONTENT_OBJECT,
683     CONTENT_TEXT, CONTENT_COUNTER, CONTENT_QUOTE
684 };
685 
686 struct ContentData {
ContentDataContentData687     ContentData() : _contentType(CONTENT_NONE), _nextContent(nullptr) {}
688     ContentData(const ContentData &o);
689     ~ContentData();
690     void clearContent();
691 
contentTextContentData692     DOM::DOMStringImpl *contentText()
693     {
694         if (_contentType == CONTENT_TEXT) {
695             return _content.text;
696         } return nullptr;
697     }
contentObjectContentData698     CachedObject *contentObject()
699     {
700         if (_contentType == CONTENT_OBJECT) {
701             return _content.object;
702         } return nullptr;
703     }
contentCounterContentData704     DOM::CounterImpl *contentCounter()
705     {
706         if (_contentType == CONTENT_COUNTER) {
707             return _content.counter;
708         } return nullptr;
709     }
contentQuoteContentData710     EQuoteContent contentQuote()
711     {
712         if (_contentType == CONTENT_QUOTE) {
713             return _content.quote;
714         } return NO_QUOTE;
715     }
716 
717     ContentType _contentType;
718 
719     union {
720         CachedObject *object;
721         DOM::DOMStringImpl *text;
722         DOM::CounterImpl *counter;
723         EQuoteContent quote;
724     } _content;
725 
726     ContentData *_nextContent;
727 };
728 
729 class StyleGeneratedData : public Shared<StyleGeneratedData>
730 {
731 public:
732     StyleGeneratedData();
733     ~StyleGeneratedData();
734     StyleGeneratedData(const StyleGeneratedData &o);
735 
736     bool operator==(const StyleGeneratedData &o) const;
737     bool operator!=(const StyleGeneratedData &o) const
738     {
739         return !(*this == o);
740     }
741 
742     bool contentDataEquivalent(const StyleGeneratedData *otherStyle) const;
743     bool counterDataEquivalent(const StyleGeneratedData *otherStyle) const;
744 
745     ContentData *content;
746     DOM::CSSValueListImpl *counter_reset;
747     DOM::CSSValueListImpl *counter_increment;
748 };
749 
750 //------------------------------------------------
751 // CSS3 Marquee Properties
752 
753 enum EMarqueeBehavior { MNONE, MSCROLL, MSLIDE, MALTERNATE, MUNFURL };
754 enum EMarqueeDirection { MAUTO = 0, MLEFT = 1, MRIGHT = -1, MUP = 2, MDOWN = -2, MFORWARD = 3, MBACKWARD = -3 };
755 
756 class StyleMarqueeData : public Shared<StyleMarqueeData>
757 {
758 public:
759     StyleMarqueeData();
760     StyleMarqueeData(const StyleMarqueeData &o);
761 
762     bool operator==(const StyleMarqueeData &o) const;
763     bool operator!=(const StyleMarqueeData &o) const
764     {
765         return !(*this == o);
766     }
767 
768     Length increment;
769     int speed;
770 
771     int loops; // -1 means infinite.
772 
773     EMarqueeBehavior behavior : 3;
774     EMarqueeDirection direction : 3;
775 };
776 
777 struct BorderRadii {
778     Length horizontal;
779     Length vertical;
780 
BorderRadiiBorderRadii781     BorderRadii(): horizontal(Length(0, Fixed)), vertical(Length(0, Fixed)) {}
782 
hasBorderRadiusBorderRadii783     bool hasBorderRadius() const
784     {
785         return (!horizontal.isZero() && !vertical.isZero());
786     }
787 
788     bool operator==(const BorderRadii &o) const;
789     bool operator!=(const BorderRadii &o) const
790     {
791         return !(*this == o);
792     }
793 };
794 
795 class BorderRadiusData : public Shared<BorderRadiusData>
796 {
797 public:
798     BorderRadiusData();
BorderRadiusData(const BorderRadiusData & other)799     BorderRadiusData(const BorderRadiusData &other) : Shared<BorderRadiusData>(),
800         topRight(other.topRight),
801         bottomRight(other.bottomRight),
802         bottomLeft(other.bottomLeft),
803         topLeft(other.topLeft)
804     {}
805 
806     bool operator==(const BorderRadiusData &o) const;
807     bool operator!=(const BorderRadiusData &o) const
808     {
809         return !(*this == o);
810     }
811 
812     bool hasBorderRadius() const;
813 
814     BorderRadii topRight, bottomRight, bottomLeft, topLeft;
815 };
816 
817 // This struct holds information about shadows for the text-shadow and box-shadow properties.
818 struct ShadowData {
ShadowDataShadowData819     ShadowData(int _x, int _y, int _blur, const QColor &_color)
820         : x(_x), y(_y), blur(_blur), color(_color), next(nullptr) {}
821     ShadowData(const ShadowData &o);
822 
~ShadowDataShadowData823     ~ShadowData()
824     {
825         delete next;
826     }
827 
828     bool operator==(const ShadowData &o) const;
829     bool operator!=(const ShadowData &o) const
830     {
831         return !(*this == o);
832     }
833 
834     int x;
835     int y;
836     int blur;
837     QColor color;
838     ShadowData *next;
839 };
840 
841 // This struct is for rarely used non-inherited CSS3 properties.  By grouping them together,
842 // we save space, and only allocate this object when someone actually uses
843 // a non-inherited CSS3 property.
844 class StyleCSS3NonInheritedData : public Shared<StyleCSS3NonInheritedData>
845 {
846 public:
847     StyleCSS3NonInheritedData();
~StyleCSS3NonInheritedData()848     ~StyleCSS3NonInheritedData() {}
849     StyleCSS3NonInheritedData(const StyleCSS3NonInheritedData &o);
850 
851     bool operator==(const StyleCSS3NonInheritedData &o) const;
852     bool operator!=(const StyleCSS3NonInheritedData &o) const
853     {
854         return !(*this == o);
855     }
856 
857     float opacity;         // Whether or not we're transparent.
858 #ifdef APPLE_CHANGES    // ### we don't have those (yet)
859     DataRef<StyleFlexibleBoxData> flexibleBox; // Flexible box properties
860 #endif
861     DataRef<StyleMarqueeData> marquee; // Marquee properties
862     DataRef<BorderRadiusData> borderRadius;
863 };
864 
865 // This struct is for rarely used inherited CSS3 properties.  By grouping them together,
866 // we save space, and only allocate this object when someone actually uses
867 // an inherited CSS3 property.
868 class StyleCSS3InheritedData : public Shared<StyleCSS3InheritedData>
869 {
870 public:
871     StyleCSS3InheritedData();
872     ~StyleCSS3InheritedData();
873     StyleCSS3InheritedData(const StyleCSS3InheritedData &o);
874 
875     bool operator==(const StyleCSS3InheritedData &o) const;
876     bool operator!=(const StyleCSS3InheritedData &o) const
877     {
878         return !(*this == o);
879     }
880     bool shadowDataEquivalent(const StyleCSS3InheritedData &o) const;
881 
882     ShadowData *textShadow;  // Our text shadow information for shadowed text drawing.
883 #ifdef APPLE_CHANGES
884     EUserModify userModify : 2; // Flag used for editing state
885     bool textSizeAdjust : 1;    // An Apple extension.  Not really CSS3 but not worth making a new struct over.
886 #endif
887     KDE_BF_ENUM(EWordWrap) wordWrap : 1;
888 private:
889     StyleCSS3InheritedData &operator=(const StyleCSS3InheritedData &);
890 };
891 
892 //------------------------------------------------
893 // Inherited attributes.
894 //
895 // the inherited-decoration and inherited-shadow attributes
896 // are inherited from the
897 // first parent which is block level
898 //
899 
900 enum EWhiteSpace {
901     NORMAL, PRE, NOWRAP, PRE_WRAP, PRE_LINE, KHTML_NOWRAP
902 };
903 
904 enum ETextAlign {
905     TAAUTO, LEFT, RIGHT, CENTER, JUSTIFY, KHTML_LEFT, KHTML_RIGHT, KHTML_CENTER
906 };
907 
908 enum ETextTransform {
909     CAPITALIZE, UPPERCASE, LOWERCASE, TTNONE
910 };
911 
912 enum EDirection {
913     LTR, RTL
914 };
915 
916 enum ETextDecoration {
917     TDNONE = 0x0, UNDERLINE = 0x1, OVERLINE = 0x2, LINE_THROUGH = 0x4, BLINK = 0x8
918 };
919 
920 enum EPageBreak {
921     PBAUTO, PBALWAYS, PBAVOID,
922     /* reserved for later use: */
923     PBLEFT, PBRIGHT
924 };
925 
926 class StyleInheritedData : public Shared<StyleInheritedData>
927 {
928     StyleInheritedData &operator=(const StyleInheritedData &);
929 public:
930     StyleInheritedData();
931     ~StyleInheritedData();
932     StyleInheritedData(const StyleInheritedData &o);
933 
934     bool operator==(const StyleInheritedData &o) const;
935     bool operator != (const StyleInheritedData &o) const
936     {
937         return !(*this == o);
938     }
939 
940     Length indent;
941     // could be packed in a short but doesn't
942     // make a difference currently because of padding
943     Length line_height;
944 
945     CachedImage *style_image;
946 
947     khtml::Font font;
948     QColor color;
949 
950     short border_hspacing;
951     short border_vspacing;
952 
953     // Paged media properties.
954     short widows;
955     short orphans;
956 
957     DOM::QuotesValueImpl *quotes;
958 };
959 
960 enum EEmptyCell {
961     SHOW, HIDE
962 };
963 
964 enum ECaptionSide {
965     CAPTOP, CAPBOTTOM, CAPLEFT, CAPRIGHT
966 };
967 
968 enum EListStyleType {
969     // Symbols:
970     LDISC, LCIRCLE, LSQUARE, LBOX, LDIAMOND,
971     // Numeric:
972     LDECIMAL, DECIMAL_LEADING_ZERO, ARABIC_INDIC, LAO, PERSIAN, URDU, THAI, TIBETAN,
973     // Algorithmic:
974     LOWER_ROMAN, UPPER_ROMAN, HEBREW, ARMENIAN, GEORGIAN,
975     // Ideographic:
976     CJK_IDEOGRAPHIC, JAPANESE_FORMAL, JAPANESE_INFORMAL,
977     SIMP_CHINESE_FORMAL, SIMP_CHINESE_INFORMAL, TRAD_CHINESE_FORMAL, TRAD_CHINESE_INFORMAL,
978     // Alphabetic:
979     LOWER_GREEK, UPPER_GREEK, LOWER_ALPHA, LOWER_LATIN, UPPER_ALPHA, UPPER_LATIN,
980     HIRAGANA, KATAKANA, HIRAGANA_IROHA, KATAKANA_IROHA,
981     // Special:
982     LNONE
983 };
984 
isListStyleCounted(EListStyleType type)985 inline bool isListStyleCounted(EListStyleType type)
986 {
987     switch (type) {
988     case LDISC: case LCIRCLE: case LSQUARE: case LBOX: case LDIAMOND:
989     case LNONE:
990         return false;
991     default:
992         return true;
993     }
994 }
995 
996 enum EListStylePosition { OUTSIDE, INSIDE };
997 
998 enum EVisibility { VISIBLE, HIDDEN, COLLAPSE };
999 
1000 enum ECursor {
1001     CURSOR_AUTO, CURSOR_DEFAULT, CURSOR_CONTEXT_MENU, CURSOR_HELP, CURSOR_POINTER,
1002     CURSOR_PROGRESS, CURSOR_WAIT, CURSOR_CELL, CURSOR_CROSS, CURSOR_TEXT, CURSOR_VERTICAL_TEXT,
1003     CURSOR_ALIAS, CURSOR_COPY, CURSOR_MOVE, CURSOR_NO_DROP, CURSOR_NOT_ALLOWED,
1004     CURSOR_E_RESIZE, CURSOR_N_RESIZE, CURSOR_NE_RESIZE, CURSOR_NW_RESIZE, CURSOR_S_RESIZE, CURSOR_SE_RESIZE,
1005     CURSOR_SW_RESIZE, CURSOR_W_RESIZE, CURSOR_EW_RESIZE, CURSOR_NS_RESIZE, CURSOR_NESW_RESIZE, CURSOR_NWSE_RESIZE,
1006     CURSOR_COL_RESIZE, CURSOR_ROW_RESIZE, CURSOR_ALL_SCROLL, CURSOR_NONE
1007 };
1008 
1009 enum EUserInput {
1010     UI_ENABLED, UI_DISABLED, UI_NONE
1011 };
1012 
1013 //------------------------------------------------
1014 
1015 enum EDisplay {
1016     INLINE, BLOCK, LIST_ITEM, RUN_IN,
1017     COMPACT, INLINE_BLOCK, TABLE, INLINE_TABLE,
1018     TABLE_ROW_GROUP, TABLE_HEADER_GROUP, TABLE_FOOTER_GROUP, TABLE_ROW,
1019     TABLE_COLUMN_GROUP, TABLE_COLUMN, TABLE_CELL,
1020     TABLE_CAPTION, NONE
1021 };
1022 
1023 class RenderStyle : public Shared<RenderStyle>
1024 {
1025     friend class CSSStyleSelector;
1026 public:
1027     KHTML_EXPORT static void cleanup();
1028 
1029     // pseudo elements
1030     enum PseudoId {
1031         NOPSEUDO, FIRST_LINE, FIRST_LETTER, SELECTION,
1032         BEFORE, AFTER, REPLACED, MARKER
1033     };
1034 
1035 protected:
1036 
1037 // !START SYNC!: Keep this in sync with the copy constructor in render_style.cpp
1038 
1039     // inherit
1040     struct InheritedFlags {
1041         // 64 bit inherited, update unused when adding to the struct, or the operator will break.
1042         bool operator==(const InheritedFlags &other) const
1043         {
1044             return _iflags == other._iflags;
1045         }
1046         bool operator!=(const InheritedFlags &other) const
1047         {
1048             return _iflags != other._iflags;
1049         }
1050 
1051         union {
1052             struct {
1053                 KDE_BF_ENUM(EEmptyCell) _empty_cells : 1;
1054                 KDE_BF_ENUM(ECaptionSide) _caption_side : 2;
1055                 KDE_BF_ENUM(EListStyleType) _list_style_type : 6;
1056                 KDE_BF_ENUM(EListStylePosition) _list_style_position : 1;
1057 
1058                 KDE_BF_ENUM(EVisibility) _visibility : 2;
1059                 KDE_BF_ENUM(ETextAlign) _text_align : 4;
1060                 KDE_BF_ENUM(ETextTransform) _text_transform : 2;
1061                 unsigned _text_decorations : 4;
1062                 KDE_BF_ENUM(ECursor) _cursor_style : 5;
1063 
1064                 KDE_BF_ENUM(EDirection) _direction : 1;
1065                 unsigned _border_collapse : 1;
1066                 KDE_BF_ENUM(EWhiteSpace) _white_space : 3;
1067                 // non CSS2 inherited
1068                 unsigned _visuallyOrdered : 1;
1069                 unsigned _htmlHacks : 1;
1070                 KDE_BF_ENUM(EUserInput) _user_input : 2;
1071 
1072                 unsigned _page_break_inside : 1; // AUTO/AVOID
1073 
1074                 unsigned int unused : 27;
1075             } f;
1076             quint64 _iflags;
1077         };
1078     } inherited_flags;
1079 
1080 // don't inherit
1081     struct NonInheritedFlags {
1082         // 64 bit non-inherited, update unused when adding to the struct, or the operator will break.
1083         bool operator==(const NonInheritedFlags &other) const
1084         {
1085             return _niflags == other._niflags;
1086         }
1087         bool operator!=(const NonInheritedFlags &other) const
1088         {
1089             return _niflags != other._niflags;
1090         }
1091 
1092         union {
1093             struct {
1094                 KDE_BF_ENUM(EDisplay) _display : 5;
1095                 KDE_BF_ENUM(EDisplay) _originalDisplay : 5;
1096                 KDE_BF_ENUM(EOverflow) _overflowX : 4;
1097                 KDE_BF_ENUM(EOverflow) _overflowY : 4;
1098                 KDE_BF_ENUM(EVerticalAlign) _vertical_align : 4;
1099                 KDE_BF_ENUM(EClear) _clear : 2;
1100                 KDE_BF_ENUM(EPosition) _position : 2;
1101                 KDE_BF_ENUM(EFloat) _floating : 3;
1102                 KDE_BF_ENUM(ETableLayout) _table_layout : 1;
1103                 unsigned _flowAroundFloats : 1;
1104 
1105                 KDE_BF_ENUM(EPageBreak) _page_break_before : 3;
1106                 KDE_BF_ENUM(EPageBreak) _page_break_after : 3;
1107 
1108                 KDE_BF_ENUM(PseudoId) _styleType : 4;
1109                 unsigned _hasClip : 1;
1110                 unsigned _pseudoBits : 8;
1111                 KDE_BF_ENUM(EUnicodeBidi) _unicodeBidi : 2;
1112 
1113                 // non CSS2 non-inherited
1114                 unsigned _textOverflow : 1; // Whether or not lines that spill out should be truncated with "..."
1115 
1116                 unsigned _inherited_noninherited : 1;
1117 
1118                 unsigned int unused : 10;
1119             } f;
1120             quint64 _niflags;
1121         };
1122     } noninherited_flags;
1123 
1124 // non-inherited attributes
1125     DataRef<StyleBoxData> box;
1126     DataRef<StyleVisualData> visual;
1127     DataRef<StyleBackgroundData> background;
1128     DataRef<StyleSurroundData> surround;
1129     DataRef<StyleGeneratedData> generated;
1130     DataRef<StyleCSS3NonInheritedData> css3NonInheritedData;
1131 
1132 // inherited attributes
1133     DataRef<StyleCSS3InheritedData> css3InheritedData;
1134     DataRef<StyleInheritedData> inherited;
1135 
1136 // list of associated pseudo styles
1137     RenderStyle *pseudoStyle;
1138 
1139 // SVG Style
1140     DataRef<khtml::SVGRenderStyle> m_svgStyle;
1141 
1142 // !END SYNC!
1143 
1144 // static default style
1145     static RenderStyle *_default;
1146 
1147 private:
RenderStyle(const RenderStyle *)1148     RenderStyle(const RenderStyle *) {}
1149 
1150 protected:
setBitDefaults()1151     void setBitDefaults()
1152     {
1153         inherited_flags.f._empty_cells = initialEmptyCells();
1154         inherited_flags.f._caption_side = initialCaptionSide();
1155         inherited_flags.f._list_style_type = initialListStyleType();
1156         inherited_flags.f._list_style_position = initialListStylePosition();
1157         inherited_flags.f._visibility = initialVisibility();
1158         inherited_flags.f._text_align = initialTextAlign();
1159         inherited_flags.f._text_transform = initialTextTransform();
1160         inherited_flags.f._text_decorations = initialTextDecoration();
1161         inherited_flags.f._cursor_style = initialCursor();
1162         inherited_flags.f._direction = initialDirection();
1163         inherited_flags.f._border_collapse = initialBorderCollapse();
1164         inherited_flags.f._white_space = initialWhiteSpace();
1165         inherited_flags.f._visuallyOrdered = false;
1166         inherited_flags.f._htmlHacks = false;
1167         inherited_flags.f._user_input = UI_NONE;
1168         inherited_flags.f._page_break_inside = true;
1169         inherited_flags.f.unused = 0;
1170 
1171         noninherited_flags._niflags = 0L; // for safety: without this, the equality method sometimes
1172         // makes use of uninitialised bits according to valgrind
1173 
1174         noninherited_flags.f._display = noninherited_flags.f._originalDisplay = initialDisplay();
1175         noninherited_flags.f._overflowX = initialOverflowX();
1176         noninherited_flags.f._overflowY = initialOverflowY();
1177         noninherited_flags.f._vertical_align = initialVerticalAlign();
1178         noninherited_flags.f._clear = initialClear();
1179         noninherited_flags.f._position = initialPosition();
1180         noninherited_flags.f._floating = initialFloating();
1181         noninherited_flags.f._table_layout = initialTableLayout();
1182         noninherited_flags.f._flowAroundFloats = initialFlowAroundFloats();
1183         noninherited_flags.f._page_break_before = initialPageBreak();
1184         noninherited_flags.f._page_break_after = initialPageBreak();
1185         noninherited_flags.f._styleType = NOPSEUDO;
1186         noninherited_flags.f._hasClip = false;
1187         noninherited_flags.f._pseudoBits = 0;
1188         noninherited_flags.f._unicodeBidi = initialUnicodeBidi();
1189         noninherited_flags.f._textOverflow = initialTextOverflow();
1190         noninherited_flags.f._inherited_noninherited = false;
1191         noninherited_flags.f.unused = 0;
1192     }
1193 
1194 public:
1195 
1196     RenderStyle();
1197     // used to create the default style.
1198     RenderStyle(bool);
1199     RenderStyle(const RenderStyle &);
1200 
1201     ~RenderStyle();
1202 
1203     void inheritFrom(const RenderStyle *inheritParent);
1204     void compactWith(const RenderStyle *similarStyle);
1205 
styleType()1206     PseudoId styleType() const
1207     {
1208         return KDE_CAST_BF_ENUM(PseudoId, noninherited_flags.f._styleType);
1209     }
setStyleType(PseudoId pi)1210     void setStyleType(PseudoId pi)
1211     {
1212         noninherited_flags.f._styleType = pi;
1213     }
isGenerated()1214     bool isGenerated() const
1215     {
1216         if (styleType() == AFTER || styleType() == BEFORE || styleType() == MARKER || styleType() == REPLACED) {
1217             return true;
1218         } else {
1219             return false;
1220         }
1221     }
1222 
1223     bool hasPseudoStyle(PseudoId pi) const;
1224     void setHasPseudoStyle(PseudoId pi, bool b = true);
1225     RenderStyle *getPseudoStyle(PseudoId pi) const;
1226     RenderStyle *addPseudoStyle(PseudoId pi);
1227     void removePseudoStyle(PseudoId pi);
1228 
1229     bool operator==(const RenderStyle &other) const;
isFloating()1230     bool        isFloating() const
1231     {
1232         return !(noninherited_flags.f._floating == FNONE);
1233     }
hasMargin()1234     bool        hasMargin() const
1235     {
1236         return surround->margin.nonZero();
1237     }
hasBorder()1238     bool        hasBorder() const
1239     {
1240         return surround->border.hasBorder();
1241     }
hasPadding()1242     bool        hasPadding() const
1243     {
1244         return surround->padding.nonZero();
1245     }
hasOffset()1246     bool        hasOffset() const
1247     {
1248         return surround->offset.nonZero();
1249     }
1250 
hasBackground()1251     bool hasBackground() const
1252     {
1253         if (backgroundColor().isValid() && backgroundColor().alpha() > 0) {
1254             return true;
1255         } else {
1256             return background->m_background.hasImage();
1257         }
1258     }
hasFixedBackgroundImage()1259     bool hasFixedBackgroundImage() const
1260     {
1261         return background->m_background.hasFixedImage();
1262     }
hasBackgroundImage()1263     bool hasBackgroundImage()  const
1264     {
1265         return background->m_background.hasImage();
1266     }
1267 
visuallyOrdered()1268     bool visuallyOrdered() const
1269     {
1270         return inherited_flags.f._visuallyOrdered;
1271     }
setVisuallyOrdered(bool b)1272     void setVisuallyOrdered(bool b)
1273     {
1274         inherited_flags.f._visuallyOrdered = b;
1275     }
1276 
1277 // attribute getter methods
1278 
display()1279     EDisplay    display() const
1280     {
1281         return KDE_CAST_BF_ENUM(EDisplay, noninherited_flags.f._display);
1282     }
originalDisplay()1283     EDisplay    originalDisplay() const
1284     {
1285         return KDE_CAST_BF_ENUM(EDisplay, noninherited_flags.f._originalDisplay);
1286     }
1287 
left()1288     Length      left() const
1289     {
1290         return surround->offset.left;
1291     }
right()1292     Length      right() const
1293     {
1294         return surround->offset.right;
1295     }
top()1296     Length      top() const
1297     {
1298         return surround->offset.top;
1299     }
bottom()1300     Length      bottom() const
1301     {
1302         return surround->offset.bottom;
1303     }
1304 
position()1305     EPosition   position() const
1306     {
1307         return KDE_CAST_BF_ENUM(EPosition, noninherited_flags.f._position);
1308     }
floating()1309     EFloat      floating() const
1310     {
1311         return KDE_CAST_BF_ENUM(EFloat, noninherited_flags.f._floating);
1312     }
1313 
width()1314     Length      width() const
1315     {
1316         return box->width;
1317     }
height()1318     Length      height() const
1319     {
1320         return box->height;
1321     }
minWidth()1322     Length      minWidth() const
1323     {
1324         return box->min_width;
1325     }
maxWidth()1326     Length      maxWidth() const
1327     {
1328         return box->max_width;
1329     }
minHeight()1330     Length      minHeight() const
1331     {
1332         return box->min_height;
1333     }
maxHeight()1334     Length      maxHeight() const
1335     {
1336         return box->max_height;
1337     }
1338 
border()1339     const BorderData &border() const
1340     {
1341         return surround->border;
1342     }
borderLeft()1343     const BorderValue &borderLeft() const
1344     {
1345         return surround->border.left;
1346     }
borderRight()1347     const BorderValue &borderRight() const
1348     {
1349         return surround->border.right;
1350     }
borderTop()1351     const BorderValue &borderTop() const
1352     {
1353         return surround->border.top;
1354     }
borderBottom()1355     const BorderValue &borderBottom() const
1356     {
1357         return surround->border.bottom;
1358     }
1359 
borderLeftWidth()1360     unsigned short  borderLeftWidth() const
1361     {
1362         return surround->border.borderLeftWidth();
1363     }
borderLeftStyle()1364     EBorderStyle    borderLeftStyle() const
1365     {
1366         return surround->border.left.style;
1367     }
borderLeftColor()1368     const QColor  &borderLeftColor() const
1369     {
1370         return surround->border.left.color;
1371     }
borderLeftIsTransparent()1372     bool borderLeftIsTransparent() const
1373     {
1374         return surround->border.left.isTransparent();
1375     }
borderRightWidth()1376     unsigned short  borderRightWidth() const
1377     {
1378         return surround->border.borderRightWidth();
1379     }
borderRightStyle()1380     EBorderStyle    borderRightStyle() const
1381     {
1382         return surround->border.right.style;
1383     }
borderRightColor()1384     const QColor   &borderRightColor() const
1385     {
1386         return surround->border.right.color;
1387     }
borderRightIsTransparent()1388     bool borderRightIsTransparent() const
1389     {
1390         return surround->border.right.isTransparent();
1391     }
borderTopWidth()1392     unsigned short  borderTopWidth() const
1393     {
1394         return surround->border.borderTopWidth();
1395     }
borderTopStyle()1396     EBorderStyle    borderTopStyle() const
1397     {
1398         return surround->border.top.style;
1399     }
borderTopColor()1400     const QColor  &borderTopColor() const
1401     {
1402         return surround->border.top.color;
1403     }
borderTopIsTransparent()1404     bool borderTopIsTransparent() const
1405     {
1406         return surround->border.top.isTransparent();
1407     }
borderBottomWidth()1408     unsigned short  borderBottomWidth() const
1409     {
1410         return surround->border.borderBottomWidth();
1411     }
borderBottomStyle()1412     EBorderStyle    borderBottomStyle() const
1413     {
1414         return surround->border.bottom.style;
1415     }
borderBottomColor()1416     const QColor   &borderBottomColor() const
1417     {
1418         return surround->border.bottom.color;
1419     }
borderBottomIsTransparent()1420     bool borderBottomIsTransparent() const
1421     {
1422         return surround->border.bottom.isTransparent();
1423     }
1424 
outlineSize()1425     unsigned short  outlineSize() const
1426     {
1427         return outlineWidth() + outlineOffset();
1428     }
outlineWidth()1429     unsigned short  outlineWidth() const
1430     {
1431         if (background->m_outline.style == BNONE || background->m_outline.style == BHIDDEN) {
1432             return 0;
1433         } else {
1434             return background->m_outline.width;
1435         }
1436     }
outlineStyle()1437     EBorderStyle    outlineStyle() const
1438     {
1439         return background->m_outline.style;
1440     }
outlineStyleIsAuto()1441     bool outlineStyleIsAuto() const
1442     {
1443         return background->m_outline._auto;
1444     }
outlineColor()1445     const QColor   &outlineColor() const
1446     {
1447         return background->m_outline.color;
1448     }
1449 
overflowX()1450     EOverflow overflowX() const
1451     {
1452         return KDE_CAST_BF_ENUM(EOverflow, noninherited_flags.f._overflowX);
1453     }
overflowY()1454     EOverflow overflowY() const
1455     {
1456         return KDE_CAST_BF_ENUM(EOverflow, noninherited_flags.f._overflowY);
1457     }
hidesOverflow()1458     bool hidesOverflow() const
1459     {
1460         // either both overflow are visible or none are
1461         return overflowX() != OVISIBLE;
1462     }
1463 
visibility()1464     EVisibility visibility() const
1465     {
1466         return KDE_CAST_BF_ENUM(EVisibility, inherited_flags.f._visibility);
1467     }
verticalAlign()1468     EVerticalAlign verticalAlign() const
1469     {
1470         return  KDE_CAST_BF_ENUM(EVerticalAlign, noninherited_flags.f._vertical_align);
1471     }
verticalAlignLength()1472     Length verticalAlignLength() const
1473     {
1474         return box->vertical_align;
1475     }
1476 
clipLeft()1477     Length clipLeft() const
1478     {
1479         return visual->clip.left;
1480     }
clipRight()1481     Length clipRight() const
1482     {
1483         return visual->clip.right;
1484     }
clipTop()1485     Length clipTop() const
1486     {
1487         return visual->clip.top;
1488     }
clipBottom()1489     Length clipBottom() const
1490     {
1491         return visual->clip.bottom;
1492     }
clip()1493     LengthBox clip() const
1494     {
1495         return visual->clip;
1496     }
hasClip()1497     bool hasClip() const
1498     {
1499         return noninherited_flags.f._hasClip;
1500     }
1501 
unicodeBidi()1502     EUnicodeBidi unicodeBidi() const
1503     {
1504         return KDE_CAST_BF_ENUM(EUnicodeBidi, noninherited_flags.f._unicodeBidi);
1505     }
1506 
clear()1507     EClear clear() const
1508     {
1509         return KDE_CAST_BF_ENUM(EClear, noninherited_flags.f._clear);
1510     }
tableLayout()1511     ETableLayout tableLayout() const
1512     {
1513         return KDE_CAST_BF_ENUM(ETableLayout, noninherited_flags.f._table_layout);
1514     }
1515 
font()1516     const QFont &font() const
1517     {
1518         return inherited->font.cfi->f;
1519     }
1520     // use with care. call font->update() after modifications
htmlFont()1521     const Font &htmlFont()
1522     {
1523         return inherited->font;
1524     }
fontMetrics()1525     const QFontMetrics &fontMetrics() const
1526     {
1527         return inherited->font.cfi->fm;
1528     }
1529 
color()1530     const QColor &color() const
1531     {
1532         return inherited->color;
1533     }
textIndent()1534     Length textIndent() const
1535     {
1536         return inherited->indent;
1537     }
textAlign()1538     ETextAlign textAlign() const
1539     {
1540         return KDE_CAST_BF_ENUM(ETextAlign, inherited_flags.f._text_align);
1541     }
textTransform()1542     ETextTransform textTransform() const
1543     {
1544         return KDE_CAST_BF_ENUM(ETextTransform, inherited_flags.f._text_transform);
1545     }
textDecorationsInEffect()1546     int textDecorationsInEffect() const
1547     {
1548         return inherited_flags.f._text_decorations;
1549     }
textDecoration()1550     int textDecoration() const
1551     {
1552         return visual->textDecoration;
1553     }
wordSpacing()1554     int wordSpacing() const
1555     {
1556         return inherited->font.wordSpacing;
1557     }
letterSpacing()1558     int letterSpacing() const
1559     {
1560         return inherited->font.letterSpacing;
1561     }
1562 
direction()1563     EDirection direction() const
1564     {
1565         return KDE_CAST_BF_ENUM(EDirection, inherited_flags.f._direction);
1566     }
lineHeight()1567     Length lineHeight() const
1568     {
1569         return inherited->line_height;
1570     }
1571 
whiteSpace()1572     EWhiteSpace whiteSpace() const
1573     {
1574         return KDE_CAST_BF_ENUM(EWhiteSpace, inherited_flags.f._white_space);
1575     }
autoWrap()1576     bool autoWrap() const
1577     {
1578         if (whiteSpace() == NORMAL || whiteSpace() == PRE_WRAP || whiteSpace() == PRE_LINE) {
1579             return true;
1580         }
1581         // nowrap | pre
1582         return false;
1583     }
preserveLF()1584     bool preserveLF() const
1585     {
1586         if (whiteSpace() == PRE || whiteSpace() == PRE_WRAP || whiteSpace() == PRE_LINE) {
1587             return true;
1588         }
1589         // normal | nowrap
1590         return false;
1591     }
preserveWS()1592     bool preserveWS() const
1593     {
1594         if (whiteSpace() == PRE || whiteSpace() == PRE_WRAP) {
1595             return true;
1596         }
1597         // normal | nowrap | pre-line
1598         return false;
1599     }
1600 
backgroundColor()1601     const QColor &backgroundColor() const
1602     {
1603         return background->m_color;
1604     }
backgroundImage()1605     CachedImage *backgroundImage() const
1606     {
1607         return background->m_background.m_image;
1608     }
backgroundRepeat()1609     EBackgroundRepeat backgroundRepeat() const
1610     {
1611         return static_cast<EBackgroundRepeat>(background->m_background.m_bgRepeat);
1612     }
backgroundAttachment()1613     EBackgroundAttachment backgroundAttachment() const
1614     {
1615         return KDE_CAST_BF_ENUM(EBackgroundAttachment, background->m_background.m_bgAttachment);
1616     }
backgroundXPosition()1617     Length backgroundXPosition() const
1618     {
1619         return background->m_background.m_xPosition;
1620     }
backgroundYPosition()1621     Length backgroundYPosition() const
1622     {
1623         return background->m_background.m_yPosition;
1624     }
accessBackgroundLayers()1625     BackgroundLayer *accessBackgroundLayers()
1626     {
1627         return &(background.access()->m_background);
1628     }
backgroundLayers()1629     const BackgroundLayer *backgroundLayers() const
1630     {
1631         return &(background->m_background);
1632     }
1633 
1634     // returns true for collapsing borders, false for separate borders
borderCollapse()1635     bool borderCollapse() const
1636     {
1637         return inherited_flags.f._border_collapse;
1638     }
borderHorizontalSpacing()1639     short borderHorizontalSpacing() const
1640     {
1641         return inherited->border_hspacing;
1642     }
borderVerticalSpacing()1643     short borderVerticalSpacing() const
1644     {
1645         return inherited->border_vspacing;
1646     }
emptyCells()1647     EEmptyCell emptyCells() const
1648     {
1649         return KDE_CAST_BF_ENUM(EEmptyCell, inherited_flags.f._empty_cells);
1650     }
captionSide()1651     ECaptionSide captionSide() const
1652     {
1653         return KDE_CAST_BF_ENUM(ECaptionSide, inherited_flags.f._caption_side);
1654     }
1655 
listStyleType()1656     EListStyleType listStyleType() const
1657     {
1658         return KDE_CAST_BF_ENUM(EListStyleType, inherited_flags.f._list_style_type);
1659     }
listStyleImage()1660     CachedImage *listStyleImage() const
1661     {
1662         return inherited->style_image;
1663     }
listStylePosition()1664     EListStylePosition listStylePosition() const
1665     {
1666         return KDE_CAST_BF_ENUM(EListStylePosition, inherited_flags.f._list_style_position);
1667     }
1668 
marginTop()1669     Length marginTop() const
1670     {
1671         return surround->margin.top;
1672     }
marginBottom()1673     Length marginBottom() const
1674     {
1675         return surround->margin.bottom;
1676     }
marginLeft()1677     Length marginLeft() const
1678     {
1679         return surround->margin.left;
1680     }
marginRight()1681     Length marginRight() const
1682     {
1683         return surround->margin.right;
1684     }
1685 
paddingTop()1686     Length paddingTop() const
1687     {
1688         return surround->padding.top;
1689     }
paddingBottom()1690     Length paddingBottom() const
1691     {
1692         return surround->padding.bottom;
1693     }
paddingLeft()1694     Length paddingLeft() const
1695     {
1696         return surround->padding.left;
1697     }
paddingRight()1698     Length paddingRight() const
1699     {
1700         return surround->padding.right;
1701     }
1702 
cursor()1703     ECursor cursor() const
1704     {
1705         return KDE_CAST_BF_ENUM(ECursor, inherited_flags.f._cursor_style);
1706     }
1707 
widows()1708     short widows() const
1709     {
1710         return inherited->widows;
1711     }
orphans()1712     short orphans() const
1713     {
1714         return inherited->orphans;
1715     }
pageBreakInside()1716     bool pageBreakInside() const
1717     {
1718         return inherited_flags.f._page_break_inside;
1719     }
pageBreakBefore()1720     EPageBreak pageBreakBefore() const
1721     {
1722         return KDE_CAST_BF_ENUM(EPageBreak, noninherited_flags.f._page_break_before);
1723     }
pageBreakAfter()1724     EPageBreak pageBreakAfter() const
1725     {
1726         return KDE_CAST_BF_ENUM(EPageBreak, noninherited_flags.f._page_break_after);
1727     }
1728 
quotes()1729     DOM::QuotesValueImpl *quotes() const
1730     {
1731         return inherited->quotes;
1732     }
1733     QString openQuote(int level) const;
1734     QString closeQuote(int level) const;
1735 
1736     // CSS3 Getter Methods
boxSizing()1737     EBoxSizing boxSizing() const
1738     {
1739         return box->box_sizing;
1740     }
outlineOffset()1741     int outlineOffset() const
1742     {
1743         if (background->m_outline.style == BNONE || background->m_outline.style == BHIDDEN) {
1744             return 0;
1745         }
1746         return background->m_outline._offset;
1747     }
textShadow()1748     ShadowData *textShadow() const
1749     {
1750         return css3InheritedData->textShadow;
1751     }
wordWrap()1752     EWordWrap wordWrap() const
1753     {
1754         return KDE_CAST_BF_ENUM(EWordWrap, css3InheritedData->wordWrap);
1755     }
opacity()1756     float opacity() const
1757     {
1758         return css3NonInheritedData->opacity;
1759     }
userInput()1760     EUserInput userInput() const
1761     {
1762         return KDE_CAST_BF_ENUM(EUserInput, inherited_flags.f._user_input);
1763     }
1764 
marqueeIncrement()1765     Length marqueeIncrement() const
1766     {
1767         return css3NonInheritedData->marquee->increment;
1768     }
marqueeSpeed()1769     int marqueeSpeed() const
1770     {
1771         return css3NonInheritedData->marquee->speed;
1772     }
marqueeLoopCount()1773     int marqueeLoopCount() const
1774     {
1775         return css3NonInheritedData->marquee->loops;
1776     }
marqueeBehavior()1777     EMarqueeBehavior marqueeBehavior() const
1778     {
1779         return css3NonInheritedData->marquee->behavior;
1780     }
marqueeDirection()1781     EMarqueeDirection marqueeDirection() const
1782     {
1783         return css3NonInheritedData->marquee->direction;
1784     }
textOverflow()1785     bool textOverflow() const
1786     {
1787         return noninherited_flags.f._textOverflow;
1788     }
1789 
hasBorderRadius()1790     bool hasBorderRadius() const
1791     {
1792         return css3NonInheritedData->borderRadius->hasBorderRadius();
1793     }
borderTopRightRadius()1794     BorderRadii borderTopRightRadius() const
1795     {
1796         return css3NonInheritedData->borderRadius->topRight;
1797     }
borderTopLeftRadius()1798     BorderRadii borderTopLeftRadius() const
1799     {
1800         return css3NonInheritedData->borderRadius->topLeft;
1801     }
borderBottomRightRadius()1802     BorderRadii borderBottomRightRadius() const
1803     {
1804         return css3NonInheritedData->borderRadius->bottomRight;
1805     }
borderBottomLeftRadius()1806     BorderRadii borderBottomLeftRadius() const
1807     {
1808         return css3NonInheritedData->borderRadius->bottomLeft;
1809     }
1810     // End CSS3 Getters
1811 
1812 // attribute setter methods
1813 
setDisplay(EDisplay v)1814     void setDisplay(EDisplay v)
1815     {
1816         noninherited_flags.f._display = v;
1817     }
setOriginalDisplay(EDisplay v)1818     void setOriginalDisplay(EDisplay v)
1819     {
1820         noninherited_flags.f._originalDisplay = v;
1821     }
setPosition(EPosition v)1822     void setPosition(EPosition v)
1823     {
1824         noninherited_flags.f._position = v;
1825     }
setFloating(EFloat v)1826     void setFloating(EFloat v)
1827     {
1828         noninherited_flags.f._floating = v;
1829     }
1830 
setLeft(Length v)1831     void setLeft(Length v)
1832     {
1833         SET_VAR(surround, offset.left, v)
1834     }
setRight(Length v)1835     void setRight(Length v)
1836     {
1837         SET_VAR(surround, offset.right, v)
1838     }
setTop(Length v)1839     void setTop(Length v)
1840     {
1841         SET_VAR(surround, offset.top, v)
1842     }
setBottom(Length v)1843     void setBottom(Length v)
1844     {
1845         SET_VAR(surround, offset.bottom, v)
1846     }
1847 
setWidth(Length v)1848     void setWidth(Length v)
1849     {
1850         SET_VAR(box, width, v)
1851     }
setHeight(Length v)1852     void setHeight(Length v)
1853     {
1854         SET_VAR(box, height, v)
1855     }
1856 
setMinWidth(Length v)1857     void setMinWidth(Length v)
1858     {
1859         SET_VAR(box, min_width, v)
1860     }
setMaxWidth(Length v)1861     void setMaxWidth(Length v)
1862     {
1863         SET_VAR(box, max_width, v)
1864     }
setMinHeight(Length v)1865     void setMinHeight(Length v)
1866     {
1867         SET_VAR(box, min_height, v)
1868     }
setMaxHeight(Length v)1869     void setMaxHeight(Length v)
1870     {
1871         SET_VAR(box, max_height, v)
1872     }
1873 
resetBorderTop()1874     void resetBorderTop()
1875     {
1876         SET_VAR(surround, border.top, BorderValue())
1877     }
resetBorderRight()1878     void resetBorderRight()
1879     {
1880         SET_VAR(surround, border.right, BorderValue())
1881     }
resetBorderBottom()1882     void resetBorderBottom()
1883     {
1884         SET_VAR(surround, border.bottom, BorderValue())
1885     }
resetBorderLeft()1886     void resetBorderLeft()
1887     {
1888         SET_VAR(surround, border.left, BorderValue())
1889     }
resetOutline()1890     void resetOutline()
1891     {
1892         SET_VAR(background, m_outline, OutlineValue())
1893     }
1894 
setBackgroundColor(const QColor & v)1895     void setBackgroundColor(const QColor &v)
1896     {
1897         SET_VAR(background, m_color, v)
1898     }
1899 
setBorderLeftWidth(unsigned short v)1900     void setBorderLeftWidth(unsigned short v)
1901     {
1902         SET_VAR(surround, border.left.width, v)
1903     }
setBorderLeftStyle(EBorderStyle v)1904     void setBorderLeftStyle(EBorderStyle v)
1905     {
1906         SET_VAR(surround, border.left.style, v)
1907     }
setBorderLeftColor(const QColor & v)1908     void setBorderLeftColor(const QColor &v)
1909     {
1910         SET_VAR(surround, border.left.color, v)
1911     }
setBorderRightWidth(unsigned short v)1912     void setBorderRightWidth(unsigned short v)
1913     {
1914         SET_VAR(surround, border.right.width, v)
1915     }
setBorderRightStyle(EBorderStyle v)1916     void setBorderRightStyle(EBorderStyle v)
1917     {
1918         SET_VAR(surround, border.right.style, v)
1919     }
setBorderRightColor(const QColor & v)1920     void setBorderRightColor(const QColor &v)
1921     {
1922         SET_VAR(surround, border.right.color, v)
1923     }
setBorderTopWidth(unsigned short v)1924     void setBorderTopWidth(unsigned short v)
1925     {
1926         SET_VAR(surround, border.top.width, v)
1927     }
setBorderTopStyle(EBorderStyle v)1928     void setBorderTopStyle(EBorderStyle v)
1929     {
1930         SET_VAR(surround, border.top.style, v)
1931     }
setBorderTopColor(const QColor & v)1932     void setBorderTopColor(const QColor &v)
1933     {
1934         SET_VAR(surround, border.top.color, v)
1935     }
setBorderBottomWidth(unsigned short v)1936     void setBorderBottomWidth(unsigned short v)
1937     {
1938         SET_VAR(surround, border.bottom.width, v)
1939     }
setBorderBottomStyle(EBorderStyle v)1940     void setBorderBottomStyle(EBorderStyle v)
1941     {
1942         SET_VAR(surround, border.bottom.style, v)
1943     }
setBorderBottomColor(const QColor & v)1944     void setBorderBottomColor(const QColor &v)
1945     {
1946         SET_VAR(surround, border.bottom.color, v)
1947     }
setOutlineWidth(unsigned short v)1948     void setOutlineWidth(unsigned short v)
1949     {
1950         SET_VAR(background, m_outline.width, v)
1951     }
1952     void setOutlineStyle(EBorderStyle v, bool isAuto = false)
1953     {
1954         SET_VAR(background, m_outline.style, v)
1955         SET_VAR(background, m_outline._auto, isAuto)
1956     }
setOutlineColor(const QColor & v)1957     void setOutlineColor(const QColor &v)
1958     {
1959         SET_VAR(background, m_outline.color, v)
1960     }
1961 
setOverflowX(EOverflow v)1962     void setOverflowX(EOverflow v)
1963     {
1964         noninherited_flags.f._overflowX = v;
1965     }
setOverflowY(EOverflow v)1966     void setOverflowY(EOverflow v)
1967     {
1968         noninherited_flags.f._overflowY = v;
1969     }
setVisibility(EVisibility v)1970     void setVisibility(EVisibility v)
1971     {
1972         inherited_flags.f._visibility = v;
1973     }
setVerticalAlign(EVerticalAlign v)1974     void setVerticalAlign(EVerticalAlign v)
1975     {
1976         noninherited_flags.f._vertical_align = v;
1977     }
setVerticalAlignLength(Length l)1978     void setVerticalAlignLength(Length l)
1979     {
1980         SET_VAR(box, vertical_align, l)
1981     }
1982 
setClipLeft(Length v)1983     void setClipLeft(Length v)
1984     {
1985         SET_VAR(visual, clip.left, v)
1986     }
setClipRight(Length v)1987     void setClipRight(Length v)
1988     {
1989         SET_VAR(visual, clip.right, v)
1990     }
setClipTop(Length v)1991     void setClipTop(Length v)
1992     {
1993         SET_VAR(visual, clip.top, v)
1994     }
setClipBottom(Length v)1995     void setClipBottom(Length v)
1996     {
1997         SET_VAR(visual, clip.bottom, v)
1998     }
1999     void setClip(Length top, Length right, Length bottom, Length left);
setHasClip(bool b)2000     void setHasClip(bool b)
2001     {
2002         noninherited_flags.f._hasClip = b;
2003     }
2004 
setUnicodeBidi(EUnicodeBidi b)2005     void setUnicodeBidi(EUnicodeBidi b)
2006     {
2007         noninherited_flags.f._unicodeBidi = b;
2008     }
2009 
setClear(EClear v)2010     void setClear(EClear v)
2011     {
2012         noninherited_flags.f._clear = v;
2013     }
setTableLayout(ETableLayout v)2014     void setTableLayout(ETableLayout v)
2015     {
2016         noninherited_flags.f._table_layout = v;
2017     }
setFontDef(const khtml::FontDef & v)2018     bool setFontDef(const khtml::FontDef &v)
2019     {
2020         // bah, this doesn't compare pointers. broken! (Dirk)
2021         if (!(inherited->font.fontDef == v)) {
2022             inherited.access()->font = Font(v);
2023             return true;
2024         }
2025         return false;
2026     }
2027 
setColor(const QColor & v)2028     void setColor(const QColor &v)
2029     {
2030         SET_VAR(inherited, color, v)
2031     }
setTextIndent(Length v)2032     void setTextIndent(Length v)
2033     {
2034         SET_VAR(inherited, indent, v)
2035     }
setTextAlign(ETextAlign v)2036     void setTextAlign(ETextAlign v)
2037     {
2038         inherited_flags.f._text_align = v;
2039     }
setTextTransform(ETextTransform v)2040     void setTextTransform(ETextTransform v)
2041     {
2042         inherited_flags.f._text_transform = v;
2043     }
addToTextDecorationsInEffect(int v)2044     void addToTextDecorationsInEffect(int v)
2045     {
2046         inherited_flags.f._text_decorations |= v;
2047     }
setTextDecorationsInEffect(int v)2048     void setTextDecorationsInEffect(int v)
2049     {
2050         inherited_flags.f._text_decorations = v;
2051     }
setTextDecoration(unsigned v)2052     void setTextDecoration(unsigned v)
2053     {
2054         SET_VAR(visual, textDecoration, v);
2055     }
setDirection(EDirection v)2056     void setDirection(EDirection v)
2057     {
2058         inherited_flags.f._direction = v;
2059     }
setLineHeight(Length v)2060     void setLineHeight(Length v)
2061     {
2062         SET_VAR(inherited, line_height, v)
2063     }
2064 
setWhiteSpace(EWhiteSpace v)2065     void setWhiteSpace(EWhiteSpace v)
2066     {
2067         inherited_flags.f._white_space = v;
2068     }
2069 
setWordSpacing(int v)2070     void setWordSpacing(int v)
2071     {
2072         SET_VAR(inherited, font.wordSpacing, v)
2073     }
setLetterSpacing(int v)2074     void setLetterSpacing(int v)
2075     {
2076         SET_VAR(inherited, font.letterSpacing, v)
2077     }
2078 
clearBackgroundLayers()2079     void clearBackgroundLayers()
2080     {
2081         background.access()->m_background = BackgroundLayer();
2082     }
inheritBackgroundLayers(const BackgroundLayer & parent)2083     void inheritBackgroundLayers(const BackgroundLayer &parent)
2084     {
2085         background.access()->m_background = parent;
2086     }
2087     void adjustBackgroundLayers();
2088 
setBorderCollapse(bool collapse)2089     void setBorderCollapse(bool collapse)
2090     {
2091         inherited_flags.f._border_collapse = collapse;
2092     }
setBorderHorizontalSpacing(short v)2093     void setBorderHorizontalSpacing(short v)
2094     {
2095         SET_VAR(inherited, border_hspacing, v)
2096     }
setBorderVerticalSpacing(short v)2097     void setBorderVerticalSpacing(short v)
2098     {
2099         SET_VAR(inherited, border_vspacing, v)
2100     }
2101 
setEmptyCells(EEmptyCell v)2102     void setEmptyCells(EEmptyCell v)
2103     {
2104         inherited_flags.f._empty_cells = v;
2105     }
setCaptionSide(ECaptionSide v)2106     void setCaptionSide(ECaptionSide v)
2107     {
2108         inherited_flags.f._caption_side = v;
2109     }
2110 
setListStyleType(EListStyleType v)2111     void setListStyleType(EListStyleType v)
2112     {
2113         inherited_flags.f._list_style_type = v;
2114     }
setListStyleImage(CachedImage * v)2115     void setListStyleImage(CachedImage *v)
2116     {
2117         SET_VAR(inherited, style_image, v)
2118     }
setListStylePosition(EListStylePosition v)2119     void setListStylePosition(EListStylePosition v)
2120     {
2121         inherited_flags.f._list_style_position = v;
2122     }
2123 
resetMargin()2124     void resetMargin()
2125     {
2126         SET_VAR(surround, margin, LengthBox(Fixed))
2127     }
setMarginTop(Length v)2128     void setMarginTop(Length v)
2129     {
2130         SET_VAR(surround, margin.top, v)
2131     }
setMarginBottom(Length v)2132     void setMarginBottom(Length v)
2133     {
2134         SET_VAR(surround, margin.bottom, v)
2135     }
setMarginLeft(Length v)2136     void setMarginLeft(Length v)
2137     {
2138         SET_VAR(surround, margin.left, v)
2139     }
setMarginRight(Length v)2140     void setMarginRight(Length v)
2141     {
2142         SET_VAR(surround, margin.right, v)
2143     }
2144 
resetPadding()2145     void resetPadding()
2146     {
2147         SET_VAR(surround, padding, LengthBox(Auto))
2148     }
setPaddingTop(Length v)2149     void setPaddingTop(Length v)
2150     {
2151         SET_VAR(surround, padding.top, v)
2152     }
setPaddingBottom(Length v)2153     void setPaddingBottom(Length v)
2154     {
2155         SET_VAR(surround, padding.bottom, v)
2156     }
setPaddingLeft(Length v)2157     void setPaddingLeft(Length v)
2158     {
2159         SET_VAR(surround, padding.left, v)
2160     }
setPaddingRight(Length v)2161     void setPaddingRight(Length v)
2162     {
2163         SET_VAR(surround, padding.right, v)
2164     }
2165 
setCursor(ECursor c)2166     void setCursor(ECursor c)
2167     {
2168         inherited_flags.f._cursor_style = c;
2169     }
2170 
htmlHacks()2171     bool htmlHacks() const
2172     {
2173         return inherited_flags.f._htmlHacks;
2174     }
2175     void setHtmlHacks(bool b = true)
2176     {
2177         inherited_flags.f._htmlHacks = b;
2178     }
2179 
flowAroundFloats()2180     bool flowAroundFloats() const
2181     {
2182         return  noninherited_flags.f._flowAroundFloats;
2183     }
2184     void setFlowAroundFloats(bool b = true)
2185     {
2186         noninherited_flags.f._flowAroundFloats = b;
2187     }
2188 
zIndex()2189     int zIndex() const
2190     {
2191         return box->z_index;
2192     }
setZIndex(int v)2193     void setZIndex(int v)
2194     {
2195         SET_VAR(box, z_auto, false);
2196         SET_VAR(box, z_index, v);
2197     }
hasAutoZIndex()2198     bool hasAutoZIndex() const
2199     {
2200         return box->z_auto;
2201     }
setHasAutoZIndex()2202     void setHasAutoZIndex()
2203     {
2204         SET_VAR(box, z_auto, true);
2205         SET_VAR(box, z_index, 0);
2206     }
2207 
setWidows(short w)2208     void setWidows(short w)
2209     {
2210         SET_VAR(inherited, widows, w);
2211     }
setOrphans(short o)2212     void setOrphans(short o)
2213     {
2214         SET_VAR(inherited, orphans, o);
2215     }
setPageBreakInside(bool b)2216     void setPageBreakInside(bool b)
2217     {
2218         inherited_flags.f._page_break_inside = b;
2219     }
setPageBreakBefore(EPageBreak b)2220     void setPageBreakBefore(EPageBreak b)
2221     {
2222         noninherited_flags.f._page_break_before = b;
2223     }
setPageBreakAfter(EPageBreak b)2224     void setPageBreakAfter(EPageBreak b)
2225     {
2226         noninherited_flags.f._page_break_after = b;
2227     }
2228 
2229     void setQuotes(DOM::QuotesValueImpl *q);
2230 
2231     // CSS3 Setters
setBoxSizing(EBoxSizing b)2232     void setBoxSizing(EBoxSizing b)
2233     {
2234         SET_VAR(box, box_sizing, b);
2235     }
setOutlineOffset(unsigned short v)2236     void setOutlineOffset(unsigned short v)
2237     {
2238         SET_VAR(background, m_outline._offset, v)
2239     }
setWordWrap(EWordWrap w)2240     void setWordWrap(EWordWrap w)
2241     {
2242         SET_VAR(css3InheritedData, wordWrap, w);
2243     }
2244     void setTextShadow(ShadowData *val, bool add = false);
setOpacity(float f)2245     void setOpacity(float f)
2246     {
2247         SET_VAR(css3NonInheritedData, opacity, f);
2248     }
setUserInput(EUserInput ui)2249     void setUserInput(EUserInput ui)
2250     {
2251         inherited_flags.f._user_input = ui;
2252     }
2253 
setMarqueeIncrement(const Length & f)2254     void setMarqueeIncrement(const Length &f)
2255     {
2256         SET_VAR(css3NonInheritedData.access()->marquee, increment, f);
2257     }
setMarqueeSpeed(int f)2258     void setMarqueeSpeed(int f)
2259     {
2260         SET_VAR(css3NonInheritedData.access()->marquee, speed, f);
2261     }
setMarqueeDirection(EMarqueeDirection d)2262     void setMarqueeDirection(EMarqueeDirection d)
2263     {
2264         SET_VAR(css3NonInheritedData.access()->marquee, direction, d);
2265     }
setMarqueeBehavior(EMarqueeBehavior b)2266     void setMarqueeBehavior(EMarqueeBehavior b)
2267     {
2268         SET_VAR(css3NonInheritedData.access()->marquee, behavior, b);
2269     }
setMarqueeLoopCount(int i)2270     void setMarqueeLoopCount(int i)
2271     {
2272         SET_VAR(css3NonInheritedData.access()->marquee, loops, i);
2273     }
setTextOverflow(bool b)2274     void setTextOverflow(bool b)
2275     {
2276         noninherited_flags.f._textOverflow = b;
2277     }
2278 
setBorderTopRightRadius(const BorderRadii & r)2279     void setBorderTopRightRadius(const BorderRadii &r)
2280     {
2281         SET_VAR(css3NonInheritedData.access()->borderRadius, topRight, r);
2282     }
2283 
setBorderTopLeftRadius(const BorderRadii & r)2284     void setBorderTopLeftRadius(const BorderRadii &r)
2285     {
2286         SET_VAR(css3NonInheritedData.access()->borderRadius, topLeft, r);
2287     }
2288 
setBorderBottomRightRadius(const BorderRadii & r)2289     void setBorderBottomRightRadius(const BorderRadii &r)
2290     {
2291         SET_VAR(css3NonInheritedData.access()->borderRadius, bottomRight, r);
2292     }
2293 
setBorderBottomLeftRadius(const BorderRadii & r)2294     void setBorderBottomLeftRadius(const BorderRadii &r)
2295     {
2296         SET_VAR(css3NonInheritedData.access()->borderRadius, bottomLeft, r);
2297     }
2298 
2299     // End CSS3 Setters
2300 
palette()2301     QPalette palette() const
2302     {
2303         return visual->palette;
2304     }
2305     void setPaletteColor(QPalette::ColorGroup g, QPalette::ColorRole r, const QColor &c);
resetPalette()2306     void resetPalette() // Called when the desktop color scheme changes.
2307     {
2308         const_cast<StyleVisualData *>(visual.get())->palette = QApplication::palette();
2309     }
2310 
useNormalContent()2311     bool useNormalContent() const
2312     {
2313         return generated->content == nullptr;
2314     }
contentData()2315     ContentData *contentData() const
2316     {
2317         return generated->content;
2318     }
contentDataEquivalent(const RenderStyle * otherStyle)2319     bool contentDataEquivalent(const RenderStyle *otherStyle) const
2320     {
2321         return generated->contentDataEquivalent(otherStyle->generated.get());
2322     }
2323     void addContent(DOM::DOMStringImpl *s);
2324     void addContent(CachedObject *o);
2325     void addContent(DOM::CounterImpl *c);
2326     void addContent(EQuoteContent q);
2327     void setContentNone();
2328     void setContentNormal();
2329     void setContentData(ContentData *content);
2330 
counterReset()2331     DOM::CSSValueListImpl *counterReset() const
2332     {
2333         return generated->counter_reset;
2334     }
counterIncrement()2335     DOM::CSSValueListImpl *counterIncrement() const
2336     {
2337         return generated->counter_increment;
2338     }
2339     void setCounterReset(DOM::CSSValueListImpl *v);
2340     void setCounterIncrement(DOM::CSSValueListImpl *v);
2341     bool hasCounterReset(const DOM::DOMString &c) const;
2342     bool hasCounterIncrement(const DOM::DOMString &c) const;
2343     short counterReset(const DOM::DOMString &c) const;
2344     short counterIncrement(const DOM::DOMString &c) const;
2345 
2346     bool inheritedNotEqual(RenderStyle *other) const;
2347 
2348     enum Diff { Equal, NonVisible = Equal, Visible, Position, Layout, CbLayout };
2349     Diff diff(const RenderStyle *other) const;
2350 
isDisplayReplacedType()2351     bool isDisplayReplacedType()
2352     {
2353         return display() == INLINE_BLOCK ||/* display() == INLINE_BOX ||*/ display() == INLINE_TABLE;
2354     }
isDisplayInlineType()2355     bool isDisplayInlineType()
2356     {
2357         return display() == INLINE || isDisplayReplacedType();
2358     }
isOriginalDisplayInlineType()2359     bool isOriginalDisplayInlineType()
2360     {
2361         return originalDisplay() == INLINE || originalDisplay() == INLINE_BLOCK ||
2362                /*originalDisplay() == INLINE_BOX ||*/ originalDisplay() == INLINE_TABLE;
2363     }
2364 
inheritedNoninherited()2365     bool inheritedNoninherited() const
2366     {
2367         return noninherited_flags.f._inherited_noninherited;
2368     }
setInheritedNoninherited(bool b)2369     void setInheritedNoninherited(bool b)
2370     {
2371         noninherited_flags.f._inherited_noninherited = b;
2372     }
2373 
2374 #ifdef ENABLE_DUMP
2375     QString createDiff(const RenderStyle &parent) const;
2376 #endif
2377 
2378     // Initial values for all the properties
initialBackgroundAttachment()2379     static EBackgroundAttachment initialBackgroundAttachment()
2380     {
2381         return BGASCROLL;
2382     }
initialBackgroundClip()2383     static EBackgroundBox initialBackgroundClip()
2384     {
2385         return BGBORDER;
2386     }
initialBackgroundOrigin()2387     static EBackgroundBox initialBackgroundOrigin()
2388     {
2389         return BGPADDING;
2390     }
initialBackgroundRepeat()2391     static EBackgroundRepeat initialBackgroundRepeat()
2392     {
2393         return REPEAT;
2394     }
initialBackgroundSize()2395     static BGSize initialBackgroundSize()
2396     {
2397         return BGSize();
2398     }
initialBorderCollapse()2399     static bool initialBorderCollapse()
2400     {
2401         return false;
2402     }
initialBorderStyle()2403     static EBorderStyle initialBorderStyle()
2404     {
2405         return BNONE;
2406     }
initialCaptionSide()2407     static ECaptionSide initialCaptionSide()
2408     {
2409         return CAPTOP;
2410     }
initialClear()2411     static EClear initialClear()
2412     {
2413         return CNONE;
2414     }
initialDirection()2415     static EDirection initialDirection()
2416     {
2417         return LTR;
2418     }
initialDisplay()2419     static EDisplay initialDisplay()
2420     {
2421         return INLINE;
2422     }
initialEmptyCells()2423     static EEmptyCell initialEmptyCells()
2424     {
2425         return SHOW;
2426     }
initialFloating()2427     static EFloat initialFloating()
2428     {
2429         return FNONE;
2430     }
initialWordWrap()2431     static EWordWrap initialWordWrap()
2432     {
2433         return WWNORMAL;
2434     }
initialListStylePosition()2435     static EListStylePosition initialListStylePosition()
2436     {
2437         return OUTSIDE;
2438     }
initialListStyleType()2439     static EListStyleType initialListStyleType()
2440     {
2441         return LDISC;
2442     }
initialOverflowX()2443     static EOverflow initialOverflowX()
2444     {
2445         return OVISIBLE;
2446     }
initialOverflowY()2447     static EOverflow initialOverflowY()
2448     {
2449         return OVISIBLE;
2450     }
initialPageBreak()2451     static EPageBreak initialPageBreak()
2452     {
2453         return PBAUTO;
2454     }
initialPageBreakInside()2455     static bool initialPageBreakInside()
2456     {
2457         return true;
2458     }
initialPosition()2459     static EPosition initialPosition()
2460     {
2461         return PSTATIC;
2462     }
initialTableLayout()2463     static ETableLayout initialTableLayout()
2464     {
2465         return TAUTO;
2466     }
initialUnicodeBidi()2467     static EUnicodeBidi initialUnicodeBidi()
2468     {
2469         return UBNormal;
2470     }
initialQuotes()2471     static DOM::QuotesValueImpl *initialQuotes()
2472     {
2473         return nullptr;
2474     }
initialBoxSizing()2475     static EBoxSizing initialBoxSizing()
2476     {
2477         return CONTENT_BOX;
2478     }
initialTextTransform()2479     static ETextTransform initialTextTransform()
2480     {
2481         return TTNONE;
2482     }
initialVisibility()2483     static EVisibility initialVisibility()
2484     {
2485         return VISIBLE;
2486     }
initialWhiteSpace()2487     static EWhiteSpace initialWhiteSpace()
2488     {
2489         return NORMAL;
2490     }
initialBackgroundXPosition()2491     static Length initialBackgroundXPosition()
2492     {
2493         return Length(0.0, Percent);
2494     }
initialBackgroundYPosition()2495     static Length initialBackgroundYPosition()
2496     {
2497         return Length(0.0, Percent);
2498     }
initialBorderHorizontalSpacing()2499     static short initialBorderHorizontalSpacing()
2500     {
2501         return 0;
2502     }
initialBorderVerticalSpacing()2503     static short initialBorderVerticalSpacing()
2504     {
2505         return 0;
2506     }
initialCursor()2507     static ECursor initialCursor()
2508     {
2509         return CURSOR_AUTO;
2510     }
initialColor()2511     static QColor initialColor()
2512     {
2513         return Qt::black;
2514     }
initialBackgroundImage()2515     static CachedImage *initialBackgroundImage()
2516     {
2517         return nullptr;
2518     }
initialListStyleImage()2519     static CachedImage *initialListStyleImage()
2520     {
2521         return nullptr;
2522     }
initialBorderWidth()2523     static unsigned short initialBorderWidth()
2524     {
2525         return 3;
2526     }
initialBorderRadius()2527     static BorderRadii initialBorderRadius()
2528     {
2529         return BorderRadii();
2530     }
initialLetterWordSpacing()2531     static int initialLetterWordSpacing()
2532     {
2533         return 0;
2534     }
initialSize()2535     static Length initialSize()
2536     {
2537         return Length();
2538     }
initialMinSize()2539     static Length initialMinSize()
2540     {
2541         return Length(0, Fixed);
2542     }
initialMaxSize()2543     static Length initialMaxSize()
2544     {
2545         return Length(UNDEFINED, Fixed);
2546     }
initialOffset()2547     static Length initialOffset()
2548     {
2549         return Length();
2550     }
initialMargin()2551     static Length initialMargin()
2552     {
2553         return Length(Fixed);
2554     }
initialPadding()2555     static Length initialPadding()
2556     {
2557         return Length(Auto);
2558     }
initialTextIndent()2559     static Length initialTextIndent()
2560     {
2561         return Length(Fixed);
2562     }
initialVerticalAlign()2563     static EVerticalAlign initialVerticalAlign()
2564     {
2565         return BASELINE;
2566     }
initialWidows()2567     static int initialWidows()
2568     {
2569         return 2;
2570     }
initialOrphans()2571     static int initialOrphans()
2572     {
2573         return 2;
2574     }
initialLineHeight()2575     static Length initialLineHeight()
2576     {
2577         return Length(-100.0, Percent);
2578     }
initialTextAlign()2579     static ETextAlign initialTextAlign()
2580     {
2581         return TAAUTO;
2582     }
initialTextDecoration()2583     static ETextDecoration initialTextDecoration()
2584     {
2585         return TDNONE;
2586     }
initialFlowAroundFloats()2587     static bool initialFlowAroundFloats()
2588     {
2589         return false;
2590     }
initialOutlineOffset()2591     static int initialOutlineOffset()
2592     {
2593         return 0;
2594     }
initialOpacity()2595     static float initialOpacity()
2596     {
2597         return 1.0f;
2598     }
initialMarqueeLoopCount()2599     static int initialMarqueeLoopCount()
2600     {
2601         return -1;
2602     }
initialMarqueeSpeed()2603     static int initialMarqueeSpeed()
2604     {
2605         return 85;
2606     }
initialMarqueeIncrement()2607     static Length initialMarqueeIncrement()
2608     {
2609         return Length(6, Fixed);
2610     }
initialMarqueeBehavior()2611     static EMarqueeBehavior initialMarqueeBehavior()
2612     {
2613         return MSCROLL;
2614     }
initialMarqueeDirection()2615     static EMarqueeDirection initialMarqueeDirection()
2616     {
2617         return MAUTO;
2618     }
initialTextOverflow()2619     static bool initialTextOverflow()
2620     {
2621         return false;
2622     }
2623 
2624     // SVG
svgStyle()2625     const khtml::SVGRenderStyle *svgStyle() const
2626     {
2627         return m_svgStyle.get();
2628     }
accessSVGStyle()2629     khtml::SVGRenderStyle *accessSVGStyle()
2630     {
2631         return m_svgStyle.access();
2632     }
2633 };
2634 
2635 class RenderPageStyle
2636 {
2637     friend class CSSStyleSelector;
2638 public:
2639     enum PageType { NO_PAGE = 0, ANY_PAGE, FIRST_PAGE, LEFT_PAGES, RIGHT_PAGES };
2640 
2641     RenderPageStyle();
2642     ~RenderPageStyle();
2643 
pageType()2644     PageType pageType()
2645     {
2646         return m_pageType;
2647     }
2648 
2649     RenderPageStyle *getPageStyle(PageType type);
2650     RenderPageStyle *addPageStyle(PageType type);
2651     void removePageStyle(PageType type);
2652 
marginTop()2653     Length marginTop()    const
2654     {
2655         return margin.top;
2656     }
marginBottom()2657     Length marginBottom() const
2658     {
2659         return margin.bottom;
2660     }
marginLeft()2661     Length marginLeft()   const
2662     {
2663         return margin.left;
2664     }
marginRight()2665     Length marginRight()  const
2666     {
2667         return margin.right;
2668     }
2669 
pageWidth()2670     Length pageWidth()  const
2671     {
2672         return m_pageWidth;
2673     }
pageHeight()2674     Length pageHeight() const
2675     {
2676         return m_pageHeight;
2677     }
2678 
setMarginTop(Length v)2679     void setMarginTop(Length v)
2680     {
2681         margin.top = v;
2682     }
setMarginBottom(Length v)2683     void setMarginBottom(Length v)
2684     {
2685         margin.bottom = v;
2686     }
setMarginLeft(Length v)2687     void setMarginLeft(Length v)
2688     {
2689         margin.left = v;
2690     }
setMarginRight(Length v)2691     void setMarginRight(Length v)
2692     {
2693         margin.right = v;
2694     }
2695 
setPageWidth(Length v)2696     void setPageWidth(Length v)
2697     {
2698         m_pageWidth = v;
2699     }
setPageHeight(Length v)2700     void setPageHeight(Length v)
2701     {
2702         m_pageHeight = v;
2703     }
2704 
2705 protected:
2706     RenderPageStyle *next;
2707     PageType m_pageType;
2708 
2709     LengthBox margin;
2710     Length m_pageWidth;
2711     Length m_pageHeight;
2712 };
2713 
2714 } // namespace
2715 
2716 #endif
2717 
2718