File indexing completed on 2024-11-10 09:39:06

0001 /*
0002  * This file is part of the DOM implementation for KDE.
0003  *
0004  * Copyright (C) 2000-2003 Lars Knoll (knoll@kde.org)
0005  *           (C) 2000 Antti Koivisto (koivisto@kde.org)
0006  *           (C) 2000-2003 Dirk Mueller (mueller@kde.org)
0007  *           (C) 2003-2007 Apple Computer, Inc.
0008  *           (C) 2004-2006 Allan Sandfeld Jensen (kde@carewolf.com)
0009  *
0010  * This library is free software; you can redistribute it and/or
0011  * modify it under the terms of the GNU Library General Public
0012  * License as published by the Free Software Foundation; either
0013  * version 2 of the License, or (at your option) any later version.
0014  *
0015  * This library is distributed in the hope that it will be useful,
0016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0018  * Library General Public License for more details.
0019  *
0020  * You should have received a copy of the GNU Library General Public License
0021  * along with this library; see the file COPYING.LIB.  If not, write to
0022  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0023  * Boston, MA 02110-1301, USA.
0024  *
0025  */
0026 #ifndef RENDERSTYLE_H
0027 #define RENDERSTYLE_H
0028 
0029 /*
0030  * WARNING:
0031  * --------
0032  *
0033  * The order of the values in the enums have to agree with the order specified
0034  * in cssvalues.in, otherwise some optimizations in the parser will fail,
0035  * and produce invaliud results.
0036  */
0037 
0038 #include <QColor>
0039 #include <QFont>
0040 #include <QFontMetrics>
0041 #include <QPalette>
0042 #include <QApplication>
0043 
0044 #include "dom/dom_misc.h"
0045 #include "dom/dom_string.h"
0046 #include "misc/khtmllayout.h"
0047 #include "misc/shared.h"
0048 #include "rendering/DataRef.h"
0049 #include "rendering/font.h"
0050 #include "rendering/SVGRenderStyle.h"
0051 
0052 #include <assert.h>
0053 
0054 #define SET_VAR(group,variable,value) \
0055     if (!(group->variable == value)) \
0056         group.access()->variable = value;
0057 
0058 #ifndef ENABLE_DUMP
0059 #ifndef NDEBUG
0060 #define ENABLE_DUMP 1
0061 #endif
0062 #endif
0063 
0064 namespace DOM
0065 {
0066 class DOMStringImpl;
0067 class QuotesValueImpl;
0068 class CounterImpl;
0069 class CSSValueListImpl;
0070 }
0071 
0072 namespace khtml
0073 {
0074 
0075 class CachedImage;
0076 class CachedObject;
0077 
0078 //------------------------------------------------
0079 
0080 //------------------------------------------------
0081 // Box model attributes. Not inherited.
0082 
0083 struct LengthBox {
0084     LengthBox()
0085     {
0086     }
0087     LengthBox(LengthType t)
0088         : left(t), right(t), top(t), bottom(t) {}
0089 
0090     Length left;
0091     Length right;
0092     Length top;
0093     Length bottom;
0094     Length &operator=(Length &len)
0095     {
0096         left = len;
0097         right = len;
0098         top = len;
0099         bottom = len;
0100         return len;
0101     }
0102 
0103     bool operator==(const LengthBox &o) const
0104     {
0105         return left == o.left && right == o.right && top == o.top && bottom == o.bottom;
0106     }
0107 
0108     bool nonZero() const
0109     {
0110         return !(left.isZero() && right.isZero() && top.isZero() && bottom.isZero());
0111     }
0112 };
0113 
0114 enum EPosition {
0115     PSTATIC, PRELATIVE, PABSOLUTE, PFIXED
0116 };
0117 
0118 enum EFloat {
0119     FNONE = 0, FLEFT = 0x01, FRIGHT = 0x02, FLEFT_ALIGN = 0x05, FRIGHT_ALIGN = 0x06
0120 };
0121 
0122 enum EWordWrap {
0123     WWNORMAL = 0, WWBREAKWORD = 0x01
0124 };
0125 
0126 //------------------------------------------------
0127 // Border attributes. Not inherited.
0128 
0129 // These have been defined in the order of their precedence for border-collapsing. Do
0130 // not change this order!
0131 enum EBorderStyle {
0132     BNATIVE, BNONE, BHIDDEN, INSET, GROOVE, RIDGE, OUTSET, DOTTED, DASHED, SOLID, DOUBLE
0133 };
0134 
0135 class BorderValue
0136 {
0137 public:
0138     BorderValue() : width(3), style(BNONE) {}
0139 
0140     QColor color;
0141     unsigned short width : 12;
0142     EBorderStyle style : 6;
0143 
0144     bool nonZero(bool checkStyle = true) const
0145     {
0146         return width != 0 && !(checkStyle && style == BNONE);
0147     }
0148 
0149     bool isTransparent() const
0150     {
0151         return color.isValid() && color.alpha() == 0;
0152     }
0153 
0154     bool operator==(const BorderValue &o) const
0155     {
0156         return width == o.width && style == o.style && color == o.color;
0157     }
0158 
0159     bool operator!=(const BorderValue &o) const
0160     {
0161         return !(*this == o);
0162     }
0163 };
0164 
0165 class OutlineValue : public BorderValue
0166 {
0167 public:
0168     OutlineValue() : _offset(0), _auto(false) {}
0169 
0170     bool operator==(const OutlineValue &o) const
0171     {
0172         return width == o.width && style == o.style && color == o.color && _offset == o._offset && _auto == o._auto;
0173     }
0174 
0175     bool operator!=(const OutlineValue &o) const
0176     {
0177         return !(*this == o);
0178     }
0179 
0180     int _offset;
0181     bool _auto;
0182 };
0183 
0184 enum EBorderPrecedence { BOFF, BTABLE, BCOLGROUP, BCOL, BROWGROUP, BROW, BCELL };
0185 
0186 struct CollapsedBorderValue {
0187     CollapsedBorderValue() : border(nullptr), precedence(BOFF) {}
0188     CollapsedBorderValue(const BorderValue *b, EBorderPrecedence p) : border(b), precedence(p) {}
0189 
0190     int width() const
0191     {
0192         return border && border->nonZero() ? border->width : 0;
0193     }
0194     EBorderStyle style() const
0195     {
0196         return border ? border->style : BHIDDEN;
0197     }
0198     bool exists() const
0199     {
0200         return border;
0201     }
0202     QColor color() const
0203     {
0204         return border ? border->color : QColor();
0205     }
0206     bool isTransparent() const
0207     {
0208         return border ? border->isTransparent() : true;
0209     }
0210 
0211     bool operator==(const CollapsedBorderValue &o) const
0212     {
0213         if (!border) {
0214             return !o.border;
0215         }
0216         if (!o.border) {
0217             return false;
0218         }
0219         return *border == *o.border && precedence == o.precedence;
0220     }
0221 
0222     const BorderValue *border;
0223     EBorderPrecedence precedence;
0224 };
0225 
0226 class BorderData : public Shared<BorderData>
0227 {
0228 public:
0229     BorderData() : Shared< khtml::BorderData >() {};
0230     BorderData(const khtml::BorderData &other) : Shared<khtml::BorderData>()
0231     {
0232         this->left = other.left;
0233         this->right = other.right;
0234         this->top = other.top;
0235         this->bottom = other.bottom;
0236     }
0237 
0238     BorderValue left;
0239     BorderValue right;
0240     BorderValue top;
0241     BorderValue bottom;
0242 
0243     bool hasBorder() const
0244     {
0245         return left.nonZero() || right.nonZero() || top.nonZero() || bottom.nonZero();
0246     }
0247 
0248     unsigned short borderLeftWidth() const
0249     {
0250         if (left.style == BNONE || left.style == BHIDDEN || left.style == BNATIVE) {
0251             return 0;
0252         }
0253         return left.width;
0254     }
0255 
0256     unsigned short borderRightWidth() const
0257     {
0258         if (right.style == BNONE || right.style == BHIDDEN || right.style == BNATIVE) {
0259             return 0;
0260         }
0261         return right.width;
0262     }
0263 
0264     unsigned short borderTopWidth() const
0265     {
0266         if (top.style == BNONE || top.style == BHIDDEN || top.style == BNATIVE) {
0267             return 0;
0268         }
0269         return top.width;
0270     }
0271 
0272     unsigned short borderBottomWidth() const
0273     {
0274         if (bottom.style == BNONE || bottom.style == BHIDDEN || bottom.style == BNATIVE) {
0275             return 0;
0276         }
0277         return bottom.width;
0278     }
0279 
0280     bool operator==(const BorderData &o) const
0281     {
0282         return left == o.left && right == o.right && top == o.top && bottom == o.bottom;
0283     }
0284 
0285 };
0286 
0287 class StyleSurroundData : public Shared<StyleSurroundData>
0288 {
0289 public:
0290     StyleSurroundData();
0291 
0292     StyleSurroundData(const StyleSurroundData &o);
0293     bool operator==(const StyleSurroundData &o) const;
0294     bool operator!=(const StyleSurroundData &o) const
0295     {
0296         return !(*this == o);
0297     }
0298     bool hasSamePBMData(const StyleSurroundData &o) const
0299     {
0300         return (margin == o.margin) && (padding == o.padding) && (border == o.border);
0301     }
0302 
0303     LengthBox offset;
0304     LengthBox margin;
0305     LengthBox padding;
0306     BorderData border;
0307 };
0308 
0309 //------------------------------------------------
0310 // Box attributes. Not inherited.
0311 
0312 enum EBoxSizing {
0313     BORDER_BOX, CONTENT_BOX
0314 };
0315 
0316 class StyleBoxData : public Shared<StyleBoxData>
0317 {
0318 public:
0319     StyleBoxData();
0320 
0321     StyleBoxData(const StyleBoxData &o);
0322 
0323     // copy and assignment
0324 //    StyleBoxData(const StyleBoxData &other);
0325 //    const StyleBoxData &operator = (const StyleBoxData &other);
0326 
0327     bool operator==(const StyleBoxData &o) const;
0328     bool operator!=(const StyleBoxData &o) const
0329     {
0330         return !(*this == o);
0331     }
0332 
0333     Length width;
0334     Length height;
0335 
0336     Length min_width;
0337     Length max_width;
0338 
0339     Length min_height;
0340     Length max_height;
0341 
0342     Length vertical_align;
0343 
0344     EBoxSizing box_sizing;
0345 
0346     int z_index;
0347     bool z_auto;
0348 };
0349 
0350 //------------------------------------------------
0351 // Random visual rendering model attributes. Not inherited.
0352 
0353 enum EOverflow {
0354     OVISIBLE, OHIDDEN, OSCROLL, OAUTO, OMARQUEE
0355 };
0356 
0357 enum EVerticalAlign {
0358     BASELINE, MIDDLE, SUB, SUPER, TEXT_TOP,
0359     TEXT_BOTTOM, TOP, BOTTOM, BASELINE_MIDDLE, LENGTH
0360 };
0361 
0362 enum EClear {
0363     CNONE = 0, CLEFT = 1, CRIGHT = 2, CBOTH = 3
0364 };
0365 
0366 enum ETableLayout {
0367     TAUTO, TFIXED
0368 };
0369 
0370 enum EUnicodeBidi {
0371     UBNormal, Embed, Override
0372 };
0373 
0374 class StyleVisualData : public Shared<StyleVisualData>
0375 {
0376 public:
0377     StyleVisualData();
0378 
0379     ~StyleVisualData();
0380 
0381     StyleVisualData(const StyleVisualData &o);
0382 
0383     bool operator==(const StyleVisualData &o) const
0384     {
0385         return (clip == o.clip && textDecoration == o.textDecoration &&
0386                 palette == o.palette);
0387     }
0388     bool operator!=(const StyleVisualData &o) const
0389     {
0390         return !(*this == o);
0391     }
0392 
0393     LengthBox clip;
0394     unsigned textDecoration : 4; // Text decorations defined *only* by this element.
0395 
0396     QPalette palette;      //widget styling with IE attributes
0397 
0398 };
0399 
0400 //------------------------------------------------
0401 enum EBackgroundBox {
0402     BGBORDER, BGPADDING, BGCONTENT
0403 };
0404 
0405 enum EBackgroundRepeat {
0406     REPEAT, REPEAT_X, REPEAT_Y, NO_REPEAT
0407 };
0408 
0409 enum EBackgroundSizeType {
0410     BGSLENGTH, BGSCONTAIN, BGSCOVER
0411 };
0412 
0413 enum EBackgroundAttachment {
0414     BGASCROLL, BGAFIXED, BGALOCAL
0415 };
0416 
0417 struct BGSize {
0418     BGSize() : type(BGSLENGTH), width(Length()), height(Length()) {}
0419     // Use to set BGSCONTAIN|BGSCOVER
0420     BGSize(EBackgroundSizeType t) : type(t), width(Length()), height(Length())
0421     {
0422         Q_ASSERT(t != BGSLENGTH);
0423     }
0424     // Use to set lenghts
0425     BGSize(Length w, Length h) : type(BGSLENGTH), width(w), height(h) {}
0426 
0427     bool operator==(const BGSize &o) const
0428     {
0429         return type == o.type && width == o.width && height == o.height;
0430     }
0431 
0432     EBackgroundSizeType type : 2;
0433     Length width;
0434     Length height;
0435 };
0436 
0437 struct BackgroundLayer {
0438 public:
0439     BackgroundLayer();
0440     ~BackgroundLayer();
0441 
0442     CachedImage *backgroundImage() const
0443     {
0444         return m_image;
0445     }
0446     Length backgroundXPosition() const
0447     {
0448         return m_xPosition;
0449     }
0450     Length backgroundYPosition() const
0451     {
0452         return m_yPosition;
0453     }
0454     EBackgroundAttachment backgroundAttachment() const
0455     {
0456         return KDE_CAST_BF_ENUM(EBackgroundAttachment, m_bgAttachment);
0457     }
0458     EBackgroundBox backgroundClip() const
0459     {
0460         return KDE_CAST_BF_ENUM(EBackgroundBox, m_bgClip);
0461     }
0462     EBackgroundBox backgroundOrigin() const
0463     {
0464         return KDE_CAST_BF_ENUM(EBackgroundBox, m_bgOrigin);
0465     }
0466     EBackgroundRepeat backgroundRepeat() const
0467     {
0468         return KDE_CAST_BF_ENUM(EBackgroundRepeat, m_bgRepeat);
0469     }
0470     BGSize backgroundSize() const
0471     {
0472         return m_backgroundSize;
0473     }
0474 
0475     BackgroundLayer *next() const
0476     {
0477         return m_next;
0478     }
0479     BackgroundLayer *next()
0480     {
0481         return m_next;
0482     }
0483 
0484     bool isBackgroundImageSet() const
0485     {
0486         return m_imageSet;
0487     }
0488     bool isBackgroundXPositionSet() const
0489     {
0490         return m_xPosSet;
0491     }
0492     bool isBackgroundYPositionSet() const
0493     {
0494         return m_yPosSet;
0495     }
0496     bool isBackgroundAttachmentSet() const
0497     {
0498         return m_attachmentSet;
0499     }
0500     bool isBackgroundClipSet() const
0501     {
0502         return m_clipSet;
0503     }
0504     bool isBackgroundOriginSet() const
0505     {
0506         return m_originSet;
0507     }
0508     bool isBackgroundRepeatSet() const
0509     {
0510         return m_repeatSet;
0511     }
0512     bool isBackgroundSizeSet() const
0513     {
0514         return m_backgroundSizeSet;
0515     }
0516 
0517     void setBackgroundImage(CachedImage *i)
0518     {
0519         m_image = i;
0520         m_imageSet = true;
0521     }
0522     void setBackgroundXPosition(const Length &l)
0523     {
0524         m_xPosition = l;
0525         m_xPosSet = true;
0526     }
0527     void setBackgroundYPosition(const Length &l)
0528     {
0529         m_yPosition = l;
0530         m_yPosSet = true;
0531     }
0532     void setBackgroundAttachment(EBackgroundAttachment b)
0533     {
0534         m_bgAttachment = b;
0535         m_attachmentSet = true;
0536     }
0537     void setBackgroundClip(EBackgroundBox b)
0538     {
0539         m_bgClip = b;
0540         m_clipSet = true;
0541     }
0542     void setBackgroundOrigin(EBackgroundBox b)
0543     {
0544         m_bgOrigin = b;
0545         m_originSet = true;
0546     }
0547     void setBackgroundRepeat(EBackgroundRepeat r)
0548     {
0549         m_bgRepeat = r;
0550         m_repeatSet = true;
0551     }
0552     void setBackgroundSize(const BGSize &b)
0553     {
0554         m_backgroundSize = b;
0555         m_backgroundSizeSet = true;
0556     }
0557 
0558     void clearBackgroundImage()
0559     {
0560         m_imageSet = false;
0561     }
0562     void clearBackgroundXPosition()
0563     {
0564         m_xPosSet = false;
0565     }
0566     void clearBackgroundYPosition()
0567     {
0568         m_yPosSet = false;
0569     }
0570     void clearBackgroundAttachment()
0571     {
0572         m_attachmentSet = false;
0573     }
0574     void clearBackgroundClip()
0575     {
0576         m_clipSet = false;
0577     }
0578     void clearBackgroundOrigin()
0579     {
0580         m_originSet = false;
0581     }
0582     void clearBackgroundRepeat()
0583     {
0584         m_repeatSet = false;
0585     }
0586     void clearBackgroundSize()
0587     {
0588         m_backgroundSizeSet = false;
0589     }
0590 
0591     void setNext(BackgroundLayer *n)
0592     {
0593         if (m_next != n) {
0594             delete m_next;
0595             m_next = n;
0596         }
0597     }
0598 
0599     BackgroundLayer &operator=(const BackgroundLayer &o);
0600     BackgroundLayer(const BackgroundLayer &o);
0601 
0602     bool operator==(const BackgroundLayer &o) const;
0603     bool operator!=(const BackgroundLayer &o) const
0604     {
0605         return !(*this == o);
0606     }
0607 
0608     bool containsImage(CachedImage *c) const
0609     {
0610         if (c == m_image) {
0611             return true;
0612         } if (m_next) {
0613             return m_next->containsImage(c);
0614         } return false;
0615     }
0616 
0617     bool hasImage() const
0618     {
0619         if (m_image) {
0620             return true;
0621         }
0622         return m_next ? m_next->hasImage() : false;
0623     }
0624     bool hasFixedImage() const
0625     {
0626         if (m_image && m_bgAttachment == BGAFIXED) {
0627             return true;
0628         }
0629         return m_next ? m_next->hasFixedImage() : false;
0630     }
0631 
0632     void fillUnsetProperties();
0633     void cullEmptyLayers();
0634 
0635     CachedImage *m_image;
0636 
0637     Length m_xPosition;
0638     Length m_yPosition;
0639 
0640     KDE_BF_ENUM(EBackgroundAttachment) m_bgAttachment : 2;
0641     KDE_BF_ENUM(EBackgroundBox) m_bgClip : 2;
0642     KDE_BF_ENUM(EBackgroundBox) m_bgOrigin : 2;
0643     KDE_BF_ENUM(EBackgroundRepeat) m_bgRepeat : 2;
0644 
0645     BGSize m_backgroundSize;
0646 
0647     bool m_imageSet : 1;
0648     bool m_attachmentSet : 1;
0649     bool m_clipSet : 1;
0650     bool m_originSet : 1;
0651     bool m_repeatSet : 1;
0652     bool m_xPosSet : 1;
0653     bool m_yPosSet : 1;
0654     bool m_backgroundSizeSet : 1;
0655 
0656     BackgroundLayer *m_next;
0657 };
0658 
0659 class StyleBackgroundData : public Shared<StyleBackgroundData>
0660 {
0661 public:
0662     StyleBackgroundData();
0663     ~StyleBackgroundData() {}
0664     StyleBackgroundData(const StyleBackgroundData &o);
0665 
0666     bool operator==(const StyleBackgroundData &o) const;
0667     bool operator!=(const StyleBackgroundData &o) const
0668     {
0669         return !(*this == o);
0670     }
0671 
0672     BackgroundLayer m_background;
0673     QColor m_color;
0674     OutlineValue m_outline;
0675 };
0676 
0677 enum EQuoteContent {
0678     NO_QUOTE = 0, OPEN_QUOTE, CLOSE_QUOTE, NO_OPEN_QUOTE, NO_CLOSE_QUOTE
0679 };
0680 
0681 enum ContentType {
0682     CONTENT_NONE = 0, CONTENT_NORMAL, CONTENT_OBJECT,
0683     CONTENT_TEXT, CONTENT_COUNTER, CONTENT_QUOTE
0684 };
0685 
0686 struct ContentData {
0687     ContentData() : _contentType(CONTENT_NONE), _nextContent(nullptr) {}
0688     ContentData(const ContentData &o);
0689     ~ContentData();
0690     void clearContent();
0691 
0692     DOM::DOMStringImpl *contentText()
0693     {
0694         if (_contentType == CONTENT_TEXT) {
0695             return _content.text;
0696         } return nullptr;
0697     }
0698     CachedObject *contentObject()
0699     {
0700         if (_contentType == CONTENT_OBJECT) {
0701             return _content.object;
0702         } return nullptr;
0703     }
0704     DOM::CounterImpl *contentCounter()
0705     {
0706         if (_contentType == CONTENT_COUNTER) {
0707             return _content.counter;
0708         } return nullptr;
0709     }
0710     EQuoteContent contentQuote()
0711     {
0712         if (_contentType == CONTENT_QUOTE) {
0713             return _content.quote;
0714         } return NO_QUOTE;
0715     }
0716 
0717     ContentType _contentType;
0718 
0719     union {
0720         CachedObject *object;
0721         DOM::DOMStringImpl *text;
0722         DOM::CounterImpl *counter;
0723         EQuoteContent quote;
0724     } _content;
0725 
0726     ContentData *_nextContent;
0727 };
0728 
0729 class StyleGeneratedData : public Shared<StyleGeneratedData>
0730 {
0731 public:
0732     StyleGeneratedData();
0733     ~StyleGeneratedData();
0734     StyleGeneratedData(const StyleGeneratedData &o);
0735 
0736     bool operator==(const StyleGeneratedData &o) const;
0737     bool operator!=(const StyleGeneratedData &o) const
0738     {
0739         return !(*this == o);
0740     }
0741 
0742     bool contentDataEquivalent(const StyleGeneratedData *otherStyle) const;
0743     bool counterDataEquivalent(const StyleGeneratedData *otherStyle) const;
0744 
0745     ContentData *content;
0746     DOM::CSSValueListImpl *counter_reset;
0747     DOM::CSSValueListImpl *counter_increment;
0748 };
0749 
0750 //------------------------------------------------
0751 // CSS3 Marquee Properties
0752 
0753 enum EMarqueeBehavior { MNONE, MSCROLL, MSLIDE, MALTERNATE, MUNFURL };
0754 enum EMarqueeDirection { MAUTO = 0, MLEFT = 1, MRIGHT = -1, MUP = 2, MDOWN = -2, MFORWARD = 3, MBACKWARD = -3 };
0755 
0756 class StyleMarqueeData : public Shared<StyleMarqueeData>
0757 {
0758 public:
0759     StyleMarqueeData();
0760     StyleMarqueeData(const StyleMarqueeData &o);
0761 
0762     bool operator==(const StyleMarqueeData &o) const;
0763     bool operator!=(const StyleMarqueeData &o) const
0764     {
0765         return !(*this == o);
0766     }
0767 
0768     Length increment;
0769     int speed;
0770 
0771     int loops; // -1 means infinite.
0772 
0773     EMarqueeBehavior behavior : 3;
0774     EMarqueeDirection direction : 3;
0775 };
0776 
0777 struct BorderRadii {
0778     Length horizontal;
0779     Length vertical;
0780 
0781     BorderRadii(): horizontal(Length(0, Fixed)), vertical(Length(0, Fixed)) {}
0782 
0783     bool hasBorderRadius() const
0784     {
0785         return (!horizontal.isZero() && !vertical.isZero());
0786     }
0787 
0788     bool operator==(const BorderRadii &o) const;
0789     bool operator!=(const BorderRadii &o) const
0790     {
0791         return !(*this == o);
0792     }
0793 };
0794 
0795 class BorderRadiusData : public Shared<BorderRadiusData>
0796 {
0797 public:
0798     BorderRadiusData();
0799     BorderRadiusData(const BorderRadiusData &other) : Shared<BorderRadiusData>(),
0800         topRight(other.topRight),
0801         bottomRight(other.bottomRight),
0802         bottomLeft(other.bottomLeft),
0803         topLeft(other.topLeft)
0804     {}
0805 
0806     bool operator==(const BorderRadiusData &o) const;
0807     bool operator!=(const BorderRadiusData &o) const
0808     {
0809         return !(*this == o);
0810     }
0811 
0812     bool hasBorderRadius() const;
0813 
0814     BorderRadii topRight, bottomRight, bottomLeft, topLeft;
0815 };
0816 
0817 // This struct holds information about shadows for the text-shadow and box-shadow properties.
0818 struct ShadowData {
0819     ShadowData(int _x, int _y, int _blur, const QColor &_color)
0820         : x(_x), y(_y), blur(_blur), color(_color), next(nullptr) {}
0821     ShadowData(const ShadowData &o);
0822 
0823     ~ShadowData()
0824     {
0825         delete next;
0826     }
0827 
0828     bool operator==(const ShadowData &o) const;
0829     bool operator!=(const ShadowData &o) const
0830     {
0831         return !(*this == o);
0832     }
0833 
0834     int x;
0835     int y;
0836     int blur;
0837     QColor color;
0838     ShadowData *next;
0839 };
0840 
0841 // This struct is for rarely used non-inherited CSS3 properties.  By grouping them together,
0842 // we save space, and only allocate this object when someone actually uses
0843 // a non-inherited CSS3 property.
0844 class StyleCSS3NonInheritedData : public Shared<StyleCSS3NonInheritedData>
0845 {
0846 public:
0847     StyleCSS3NonInheritedData();
0848     ~StyleCSS3NonInheritedData() {}
0849     StyleCSS3NonInheritedData(const StyleCSS3NonInheritedData &o);
0850 
0851     bool operator==(const StyleCSS3NonInheritedData &o) const;
0852     bool operator!=(const StyleCSS3NonInheritedData &o) const
0853     {
0854         return !(*this == o);
0855     }
0856 
0857     float opacity;         // Whether or not we're transparent.
0858 #ifdef APPLE_CHANGES    // ### we don't have those (yet)
0859     DataRef<StyleFlexibleBoxData> flexibleBox; // Flexible box properties
0860 #endif
0861     DataRef<StyleMarqueeData> marquee; // Marquee properties
0862     DataRef<BorderRadiusData> borderRadius;
0863 };
0864 
0865 // This struct is for rarely used inherited CSS3 properties.  By grouping them together,
0866 // we save space, and only allocate this object when someone actually uses
0867 // an inherited CSS3 property.
0868 class StyleCSS3InheritedData : public Shared<StyleCSS3InheritedData>
0869 {
0870 public:
0871     StyleCSS3InheritedData();
0872     ~StyleCSS3InheritedData();
0873     StyleCSS3InheritedData(const StyleCSS3InheritedData &o);
0874 
0875     bool operator==(const StyleCSS3InheritedData &o) const;
0876     bool operator!=(const StyleCSS3InheritedData &o) const
0877     {
0878         return !(*this == o);
0879     }
0880     bool shadowDataEquivalent(const StyleCSS3InheritedData &o) const;
0881 
0882     ShadowData *textShadow;  // Our text shadow information for shadowed text drawing.
0883 #ifdef APPLE_CHANGES
0884     EUserModify userModify : 2; // Flag used for editing state
0885     bool textSizeAdjust : 1;    // An Apple extension.  Not really CSS3 but not worth making a new struct over.
0886 #endif
0887     KDE_BF_ENUM(EWordWrap) wordWrap : 1;
0888 private:
0889     StyleCSS3InheritedData &operator=(const StyleCSS3InheritedData &);
0890 };
0891 
0892 //------------------------------------------------
0893 // Inherited attributes.
0894 //
0895 // the inherited-decoration and inherited-shadow attributes
0896 // are inherited from the
0897 // first parent which is block level
0898 //
0899 
0900 enum EWhiteSpace {
0901     NORMAL, PRE, NOWRAP, PRE_WRAP, PRE_LINE, KHTML_NOWRAP
0902 };
0903 
0904 enum ETextAlign {
0905     TAAUTO, LEFT, RIGHT, CENTER, JUSTIFY, KHTML_LEFT, KHTML_RIGHT, KHTML_CENTER
0906 };
0907 
0908 enum ETextTransform {
0909     CAPITALIZE, UPPERCASE, LOWERCASE, TTNONE
0910 };
0911 
0912 enum EDirection {
0913     LTR, RTL
0914 };
0915 
0916 enum ETextDecoration {
0917     TDNONE = 0x0, UNDERLINE = 0x1, OVERLINE = 0x2, LINE_THROUGH = 0x4, BLINK = 0x8
0918 };
0919 
0920 enum EPageBreak {
0921     PBAUTO, PBALWAYS, PBAVOID,
0922     /* reserved for later use: */
0923     PBLEFT, PBRIGHT
0924 };
0925 
0926 class StyleInheritedData : public Shared<StyleInheritedData>
0927 {
0928     StyleInheritedData &operator=(const StyleInheritedData &);
0929 public:
0930     StyleInheritedData();
0931     ~StyleInheritedData();
0932     StyleInheritedData(const StyleInheritedData &o);
0933 
0934     bool operator==(const StyleInheritedData &o) const;
0935     bool operator != (const StyleInheritedData &o) const
0936     {
0937         return !(*this == o);
0938     }
0939 
0940     Length indent;
0941     // could be packed in a short but doesn't
0942     // make a difference currently because of padding
0943     Length line_height;
0944 
0945     CachedImage *style_image;
0946 
0947     khtml::Font font;
0948     QColor color;
0949 
0950     short border_hspacing;
0951     short border_vspacing;
0952 
0953     // Paged media properties.
0954     short widows;
0955     short orphans;
0956 
0957     DOM::QuotesValueImpl *quotes;
0958 };
0959 
0960 enum EEmptyCell {
0961     SHOW, HIDE
0962 };
0963 
0964 enum ECaptionSide {
0965     CAPTOP, CAPBOTTOM, CAPLEFT, CAPRIGHT
0966 };
0967 
0968 enum EListStyleType {
0969     // Symbols:
0970     LDISC, LCIRCLE, LSQUARE, LBOX, LDIAMOND,
0971     // Numeric:
0972     LDECIMAL, DECIMAL_LEADING_ZERO, ARABIC_INDIC, LAO, PERSIAN, URDU, THAI, TIBETAN,
0973     // Algorithmic:
0974     LOWER_ROMAN, UPPER_ROMAN, HEBREW, ARMENIAN, GEORGIAN,
0975     // Ideographic:
0976     CJK_IDEOGRAPHIC, JAPANESE_FORMAL, JAPANESE_INFORMAL,
0977     SIMP_CHINESE_FORMAL, SIMP_CHINESE_INFORMAL, TRAD_CHINESE_FORMAL, TRAD_CHINESE_INFORMAL,
0978     // Alphabetic:
0979     LOWER_GREEK, UPPER_GREEK, LOWER_ALPHA, LOWER_LATIN, UPPER_ALPHA, UPPER_LATIN,
0980     HIRAGANA, KATAKANA, HIRAGANA_IROHA, KATAKANA_IROHA,
0981     // Special:
0982     LNONE
0983 };
0984 
0985 inline bool isListStyleCounted(EListStyleType type)
0986 {
0987     switch (type) {
0988     case LDISC: case LCIRCLE: case LSQUARE: case LBOX: case LDIAMOND:
0989     case LNONE:
0990         return false;
0991     default:
0992         return true;
0993     }
0994 }
0995 
0996 enum EListStylePosition { OUTSIDE, INSIDE };
0997 
0998 enum EVisibility { VISIBLE, HIDDEN, COLLAPSE };
0999 
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:
1148     RenderStyle(const RenderStyle *) {}
1149 
1150 protected:
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 
1206     PseudoId styleType() const
1207     {
1208         return KDE_CAST_BF_ENUM(PseudoId, noninherited_flags.f._styleType);
1209     }
1210     void setStyleType(PseudoId pi)
1211     {
1212         noninherited_flags.f._styleType = pi;
1213     }
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;
1230     bool        isFloating() const
1231     {
1232         return !(noninherited_flags.f._floating == FNONE);
1233     }
1234     bool        hasMargin() const
1235     {
1236         return surround->margin.nonZero();
1237     }
1238     bool        hasBorder() const
1239     {
1240         return surround->border.hasBorder();
1241     }
1242     bool        hasPadding() const
1243     {
1244         return surround->padding.nonZero();
1245     }
1246     bool        hasOffset() const
1247     {
1248         return surround->offset.nonZero();
1249     }
1250 
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     }
1259     bool hasFixedBackgroundImage() const
1260     {
1261         return background->m_background.hasFixedImage();
1262     }
1263     bool hasBackgroundImage()  const
1264     {
1265         return background->m_background.hasImage();
1266     }
1267 
1268     bool visuallyOrdered() const
1269     {
1270         return inherited_flags.f._visuallyOrdered;
1271     }
1272     void setVisuallyOrdered(bool b)
1273     {
1274         inherited_flags.f._visuallyOrdered = b;
1275     }
1276 
1277 // attribute getter methods
1278 
1279     EDisplay    display() const
1280     {
1281         return KDE_CAST_BF_ENUM(EDisplay, noninherited_flags.f._display);
1282     }
1283     EDisplay    originalDisplay() const
1284     {
1285         return KDE_CAST_BF_ENUM(EDisplay, noninherited_flags.f._originalDisplay);
1286     }
1287 
1288     Length      left() const
1289     {
1290         return surround->offset.left;
1291     }
1292     Length      right() const
1293     {
1294         return surround->offset.right;
1295     }
1296     Length      top() const
1297     {
1298         return surround->offset.top;
1299     }
1300     Length      bottom() const
1301     {
1302         return surround->offset.bottom;
1303     }
1304 
1305     EPosition   position() const
1306     {
1307         return KDE_CAST_BF_ENUM(EPosition, noninherited_flags.f._position);
1308     }
1309     EFloat      floating() const
1310     {
1311         return KDE_CAST_BF_ENUM(EFloat, noninherited_flags.f._floating);
1312     }
1313 
1314     Length      width() const
1315     {
1316         return box->width;
1317     }
1318     Length      height() const
1319     {
1320         return box->height;
1321     }
1322     Length      minWidth() const
1323     {
1324         return box->min_width;
1325     }
1326     Length      maxWidth() const
1327     {
1328         return box->max_width;
1329     }
1330     Length      minHeight() const
1331     {
1332         return box->min_height;
1333     }
1334     Length      maxHeight() const
1335     {
1336         return box->max_height;
1337     }
1338 
1339     const BorderData &border() const
1340     {
1341         return surround->border;
1342     }
1343     const BorderValue &borderLeft() const
1344     {
1345         return surround->border.left;
1346     }
1347     const BorderValue &borderRight() const
1348     {
1349         return surround->border.right;
1350     }
1351     const BorderValue &borderTop() const
1352     {
1353         return surround->border.top;
1354     }
1355     const BorderValue &borderBottom() const
1356     {
1357         return surround->border.bottom;
1358     }
1359 
1360     unsigned short  borderLeftWidth() const
1361     {
1362         return surround->border.borderLeftWidth();
1363     }
1364     EBorderStyle    borderLeftStyle() const
1365     {
1366         return surround->border.left.style;
1367     }
1368     const QColor  &borderLeftColor() const
1369     {
1370         return surround->border.left.color;
1371     }
1372     bool borderLeftIsTransparent() const
1373     {
1374         return surround->border.left.isTransparent();
1375     }
1376     unsigned short  borderRightWidth() const
1377     {
1378         return surround->border.borderRightWidth();
1379     }
1380     EBorderStyle    borderRightStyle() const
1381     {
1382         return surround->border.right.style;
1383     }
1384     const QColor   &borderRightColor() const
1385     {
1386         return surround->border.right.color;
1387     }
1388     bool borderRightIsTransparent() const
1389     {
1390         return surround->border.right.isTransparent();
1391     }
1392     unsigned short  borderTopWidth() const
1393     {
1394         return surround->border.borderTopWidth();
1395     }
1396     EBorderStyle    borderTopStyle() const
1397     {
1398         return surround->border.top.style;
1399     }
1400     const QColor  &borderTopColor() const
1401     {
1402         return surround->border.top.color;
1403     }
1404     bool borderTopIsTransparent() const
1405     {
1406         return surround->border.top.isTransparent();
1407     }
1408     unsigned short  borderBottomWidth() const
1409     {
1410         return surround->border.borderBottomWidth();
1411     }
1412     EBorderStyle    borderBottomStyle() const
1413     {
1414         return surround->border.bottom.style;
1415     }
1416     const QColor   &borderBottomColor() const
1417     {
1418         return surround->border.bottom.color;
1419     }
1420     bool borderBottomIsTransparent() const
1421     {
1422         return surround->border.bottom.isTransparent();
1423     }
1424 
1425     unsigned short  outlineSize() const
1426     {
1427         return outlineWidth() + outlineOffset();
1428     }
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     }
1437     EBorderStyle    outlineStyle() const
1438     {
1439         return background->m_outline.style;
1440     }
1441     bool outlineStyleIsAuto() const
1442     {
1443         return background->m_outline._auto;
1444     }
1445     const QColor   &outlineColor() const
1446     {
1447         return background->m_outline.color;
1448     }
1449 
1450     EOverflow overflowX() const
1451     {
1452         return KDE_CAST_BF_ENUM(EOverflow, noninherited_flags.f._overflowX);
1453     }
1454     EOverflow overflowY() const
1455     {
1456         return KDE_CAST_BF_ENUM(EOverflow, noninherited_flags.f._overflowY);
1457     }
1458     bool hidesOverflow() const
1459     {
1460         // either both overflow are visible or none are
1461         return overflowX() != OVISIBLE;
1462     }
1463 
1464     EVisibility visibility() const
1465     {
1466         return KDE_CAST_BF_ENUM(EVisibility, inherited_flags.f._visibility);
1467     }
1468     EVerticalAlign verticalAlign() const
1469     {
1470         return  KDE_CAST_BF_ENUM(EVerticalAlign, noninherited_flags.f._vertical_align);
1471     }
1472     Length verticalAlignLength() const
1473     {
1474         return box->vertical_align;
1475     }
1476 
1477     Length clipLeft() const
1478     {
1479         return visual->clip.left;
1480     }
1481     Length clipRight() const
1482     {
1483         return visual->clip.right;
1484     }
1485     Length clipTop() const
1486     {
1487         return visual->clip.top;
1488     }
1489     Length clipBottom() const
1490     {
1491         return visual->clip.bottom;
1492     }
1493     LengthBox clip() const
1494     {
1495         return visual->clip;
1496     }
1497     bool hasClip() const
1498     {
1499         return noninherited_flags.f._hasClip;
1500     }
1501 
1502     EUnicodeBidi unicodeBidi() const
1503     {
1504         return KDE_CAST_BF_ENUM(EUnicodeBidi, noninherited_flags.f._unicodeBidi);
1505     }
1506 
1507     EClear clear() const
1508     {
1509         return KDE_CAST_BF_ENUM(EClear, noninherited_flags.f._clear);
1510     }
1511     ETableLayout tableLayout() const
1512     {
1513         return KDE_CAST_BF_ENUM(ETableLayout, noninherited_flags.f._table_layout);
1514     }
1515 
1516     const QFont &font() const
1517     {
1518         return inherited->font.cfi->f;
1519     }
1520     // use with care. call font->update() after modifications
1521     const Font &htmlFont()
1522     {
1523         return inherited->font;
1524     }
1525     const QFontMetrics &fontMetrics() const
1526     {
1527         return inherited->font.cfi->fm;
1528     }
1529 
1530     const QColor &color() const
1531     {
1532         return inherited->color;
1533     }
1534     Length textIndent() const
1535     {
1536         return inherited->indent;
1537     }
1538     ETextAlign textAlign() const
1539     {
1540         return KDE_CAST_BF_ENUM(ETextAlign, inherited_flags.f._text_align);
1541     }
1542     ETextTransform textTransform() const
1543     {
1544         return KDE_CAST_BF_ENUM(ETextTransform, inherited_flags.f._text_transform);
1545     }
1546     int textDecorationsInEffect() const
1547     {
1548         return inherited_flags.f._text_decorations;
1549     }
1550     int textDecoration() const
1551     {
1552         return visual->textDecoration;
1553     }
1554     int wordSpacing() const
1555     {
1556         return inherited->font.wordSpacing;
1557     }
1558     int letterSpacing() const
1559     {
1560         return inherited->font.letterSpacing;
1561     }
1562 
1563     EDirection direction() const
1564     {
1565         return KDE_CAST_BF_ENUM(EDirection, inherited_flags.f._direction);
1566     }
1567     Length lineHeight() const
1568     {
1569         return inherited->line_height;
1570     }
1571 
1572     EWhiteSpace whiteSpace() const
1573     {
1574         return KDE_CAST_BF_ENUM(EWhiteSpace, inherited_flags.f._white_space);
1575     }
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     }
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     }
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 
1601     const QColor &backgroundColor() const
1602     {
1603         return background->m_color;
1604     }
1605     CachedImage *backgroundImage() const
1606     {
1607         return background->m_background.m_image;
1608     }
1609     EBackgroundRepeat backgroundRepeat() const
1610     {
1611         return static_cast<EBackgroundRepeat>(background->m_background.m_bgRepeat);
1612     }
1613     EBackgroundAttachment backgroundAttachment() const
1614     {
1615         return KDE_CAST_BF_ENUM(EBackgroundAttachment, background->m_background.m_bgAttachment);
1616     }
1617     Length backgroundXPosition() const
1618     {
1619         return background->m_background.m_xPosition;
1620     }
1621     Length backgroundYPosition() const
1622     {
1623         return background->m_background.m_yPosition;
1624     }
1625     BackgroundLayer *accessBackgroundLayers()
1626     {
1627         return &(background.access()->m_background);
1628     }
1629     const BackgroundLayer *backgroundLayers() const
1630     {
1631         return &(background->m_background);
1632     }
1633 
1634     // returns true for collapsing borders, false for separate borders
1635     bool borderCollapse() const
1636     {
1637         return inherited_flags.f._border_collapse;
1638     }
1639     short borderHorizontalSpacing() const
1640     {
1641         return inherited->border_hspacing;
1642     }
1643     short borderVerticalSpacing() const
1644     {
1645         return inherited->border_vspacing;
1646     }
1647     EEmptyCell emptyCells() const
1648     {
1649         return KDE_CAST_BF_ENUM(EEmptyCell, inherited_flags.f._empty_cells);
1650     }
1651     ECaptionSide captionSide() const
1652     {
1653         return KDE_CAST_BF_ENUM(ECaptionSide, inherited_flags.f._caption_side);
1654     }
1655 
1656     EListStyleType listStyleType() const
1657     {
1658         return KDE_CAST_BF_ENUM(EListStyleType, inherited_flags.f._list_style_type);
1659     }
1660     CachedImage *listStyleImage() const
1661     {
1662         return inherited->style_image;
1663     }
1664     EListStylePosition listStylePosition() const
1665     {
1666         return KDE_CAST_BF_ENUM(EListStylePosition, inherited_flags.f._list_style_position);
1667     }
1668 
1669     Length marginTop() const
1670     {
1671         return surround->margin.top;
1672     }
1673     Length marginBottom() const
1674     {
1675         return surround->margin.bottom;
1676     }
1677     Length marginLeft() const
1678     {
1679         return surround->margin.left;
1680     }
1681     Length marginRight() const
1682     {
1683         return surround->margin.right;
1684     }
1685 
1686     Length paddingTop() const
1687     {
1688         return surround->padding.top;
1689     }
1690     Length paddingBottom() const
1691     {
1692         return surround->padding.bottom;
1693     }
1694     Length paddingLeft() const
1695     {
1696         return surround->padding.left;
1697     }
1698     Length paddingRight() const
1699     {
1700         return surround->padding.right;
1701     }
1702 
1703     ECursor cursor() const
1704     {
1705         return KDE_CAST_BF_ENUM(ECursor, inherited_flags.f._cursor_style);
1706     }
1707 
1708     short widows() const
1709     {
1710         return inherited->widows;
1711     }
1712     short orphans() const
1713     {
1714         return inherited->orphans;
1715     }
1716     bool pageBreakInside() const
1717     {
1718         return inherited_flags.f._page_break_inside;
1719     }
1720     EPageBreak pageBreakBefore() const
1721     {
1722         return KDE_CAST_BF_ENUM(EPageBreak, noninherited_flags.f._page_break_before);
1723     }
1724     EPageBreak pageBreakAfter() const
1725     {
1726         return KDE_CAST_BF_ENUM(EPageBreak, noninherited_flags.f._page_break_after);
1727     }
1728 
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
1737     EBoxSizing boxSizing() const
1738     {
1739         return box->box_sizing;
1740     }
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     }
1748     ShadowData *textShadow() const
1749     {
1750         return css3InheritedData->textShadow;
1751     }
1752     EWordWrap wordWrap() const
1753     {
1754         return KDE_CAST_BF_ENUM(EWordWrap, css3InheritedData->wordWrap);
1755     }
1756     float opacity() const
1757     {
1758         return css3NonInheritedData->opacity;
1759     }
1760     EUserInput userInput() const
1761     {
1762         return KDE_CAST_BF_ENUM(EUserInput, inherited_flags.f._user_input);
1763     }
1764 
1765     Length marqueeIncrement() const
1766     {
1767         return css3NonInheritedData->marquee->increment;
1768     }
1769     int marqueeSpeed() const
1770     {
1771         return css3NonInheritedData->marquee->speed;
1772     }
1773     int marqueeLoopCount() const
1774     {
1775         return css3NonInheritedData->marquee->loops;
1776     }
1777     EMarqueeBehavior marqueeBehavior() const
1778     {
1779         return css3NonInheritedData->marquee->behavior;
1780     }
1781     EMarqueeDirection marqueeDirection() const
1782     {
1783         return css3NonInheritedData->marquee->direction;
1784     }
1785     bool textOverflow() const
1786     {
1787         return noninherited_flags.f._textOverflow;
1788     }
1789 
1790     bool hasBorderRadius() const
1791     {
1792         return css3NonInheritedData->borderRadius->hasBorderRadius();
1793     }
1794     BorderRadii borderTopRightRadius() const
1795     {
1796         return css3NonInheritedData->borderRadius->topRight;
1797     }
1798     BorderRadii borderTopLeftRadius() const
1799     {
1800         return css3NonInheritedData->borderRadius->topLeft;
1801     }
1802     BorderRadii borderBottomRightRadius() const
1803     {
1804         return css3NonInheritedData->borderRadius->bottomRight;
1805     }
1806     BorderRadii borderBottomLeftRadius() const
1807     {
1808         return css3NonInheritedData->borderRadius->bottomLeft;
1809     }
1810     // End CSS3 Getters
1811 
1812 // attribute setter methods
1813 
1814     void setDisplay(EDisplay v)
1815     {
1816         noninherited_flags.f._display = v;
1817     }
1818     void setOriginalDisplay(EDisplay v)
1819     {
1820         noninherited_flags.f._originalDisplay = v;
1821     }
1822     void setPosition(EPosition v)
1823     {
1824         noninherited_flags.f._position = v;
1825     }
1826     void setFloating(EFloat v)
1827     {
1828         noninherited_flags.f._floating = v;
1829     }
1830 
1831     void setLeft(Length v)
1832     {
1833         SET_VAR(surround, offset.left, v)
1834     }
1835     void setRight(Length v)
1836     {
1837         SET_VAR(surround, offset.right, v)
1838     }
1839     void setTop(Length v)
1840     {
1841         SET_VAR(surround, offset.top, v)
1842     }
1843     void setBottom(Length v)
1844     {
1845         SET_VAR(surround, offset.bottom, v)
1846     }
1847 
1848     void setWidth(Length v)
1849     {
1850         SET_VAR(box, width, v)
1851     }
1852     void setHeight(Length v)
1853     {
1854         SET_VAR(box, height, v)
1855     }
1856 
1857     void setMinWidth(Length v)
1858     {
1859         SET_VAR(box, min_width, v)
1860     }
1861     void setMaxWidth(Length v)
1862     {
1863         SET_VAR(box, max_width, v)
1864     }
1865     void setMinHeight(Length v)
1866     {
1867         SET_VAR(box, min_height, v)
1868     }
1869     void setMaxHeight(Length v)
1870     {
1871         SET_VAR(box, max_height, v)
1872     }
1873 
1874     void resetBorderTop()
1875     {
1876         SET_VAR(surround, border.top, BorderValue())
1877     }
1878     void resetBorderRight()
1879     {
1880         SET_VAR(surround, border.right, BorderValue())
1881     }
1882     void resetBorderBottom()
1883     {
1884         SET_VAR(surround, border.bottom, BorderValue())
1885     }
1886     void resetBorderLeft()
1887     {
1888         SET_VAR(surround, border.left, BorderValue())
1889     }
1890     void resetOutline()
1891     {
1892         SET_VAR(background, m_outline, OutlineValue())
1893     }
1894 
1895     void setBackgroundColor(const QColor &v)
1896     {
1897         SET_VAR(background, m_color, v)
1898     }
1899 
1900     void setBorderLeftWidth(unsigned short v)
1901     {
1902         SET_VAR(surround, border.left.width, v)
1903     }
1904     void setBorderLeftStyle(EBorderStyle v)
1905     {
1906         SET_VAR(surround, border.left.style, v)
1907     }
1908     void setBorderLeftColor(const QColor &v)
1909     {
1910         SET_VAR(surround, border.left.color, v)
1911     }
1912     void setBorderRightWidth(unsigned short v)
1913     {
1914         SET_VAR(surround, border.right.width, v)
1915     }
1916     void setBorderRightStyle(EBorderStyle v)
1917     {
1918         SET_VAR(surround, border.right.style, v)
1919     }
1920     void setBorderRightColor(const QColor &v)
1921     {
1922         SET_VAR(surround, border.right.color, v)
1923     }
1924     void setBorderTopWidth(unsigned short v)
1925     {
1926         SET_VAR(surround, border.top.width, v)
1927     }
1928     void setBorderTopStyle(EBorderStyle v)
1929     {
1930         SET_VAR(surround, border.top.style, v)
1931     }
1932     void setBorderTopColor(const QColor &v)
1933     {
1934         SET_VAR(surround, border.top.color, v)
1935     }
1936     void setBorderBottomWidth(unsigned short v)
1937     {
1938         SET_VAR(surround, border.bottom.width, v)
1939     }
1940     void setBorderBottomStyle(EBorderStyle v)
1941     {
1942         SET_VAR(surround, border.bottom.style, v)
1943     }
1944     void setBorderBottomColor(const QColor &v)
1945     {
1946         SET_VAR(surround, border.bottom.color, v)
1947     }
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     }
1957     void setOutlineColor(const QColor &v)
1958     {
1959         SET_VAR(background, m_outline.color, v)
1960     }
1961 
1962     void setOverflowX(EOverflow v)
1963     {
1964         noninherited_flags.f._overflowX = v;
1965     }
1966     void setOverflowY(EOverflow v)
1967     {
1968         noninherited_flags.f._overflowY = v;
1969     }
1970     void setVisibility(EVisibility v)
1971     {
1972         inherited_flags.f._visibility = v;
1973     }
1974     void setVerticalAlign(EVerticalAlign v)
1975     {
1976         noninherited_flags.f._vertical_align = v;
1977     }
1978     void setVerticalAlignLength(Length l)
1979     {
1980         SET_VAR(box, vertical_align, l)
1981     }
1982 
1983     void setClipLeft(Length v)
1984     {
1985         SET_VAR(visual, clip.left, v)
1986     }
1987     void setClipRight(Length v)
1988     {
1989         SET_VAR(visual, clip.right, v)
1990     }
1991     void setClipTop(Length v)
1992     {
1993         SET_VAR(visual, clip.top, v)
1994     }
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);
2000     void setHasClip(bool b)
2001     {
2002         noninherited_flags.f._hasClip = b;
2003     }
2004 
2005     void setUnicodeBidi(EUnicodeBidi b)
2006     {
2007         noninherited_flags.f._unicodeBidi = b;
2008     }
2009 
2010     void setClear(EClear v)
2011     {
2012         noninherited_flags.f._clear = v;
2013     }
2014     void setTableLayout(ETableLayout v)
2015     {
2016         noninherited_flags.f._table_layout = v;
2017     }
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 
2028     void setColor(const QColor &v)
2029     {
2030         SET_VAR(inherited, color, v)
2031     }
2032     void setTextIndent(Length v)
2033     {
2034         SET_VAR(inherited, indent, v)
2035     }
2036     void setTextAlign(ETextAlign v)
2037     {
2038         inherited_flags.f._text_align = v;
2039     }
2040     void setTextTransform(ETextTransform v)
2041     {
2042         inherited_flags.f._text_transform = v;
2043     }
2044     void addToTextDecorationsInEffect(int v)
2045     {
2046         inherited_flags.f._text_decorations |= v;
2047     }
2048     void setTextDecorationsInEffect(int v)
2049     {
2050         inherited_flags.f._text_decorations = v;
2051     }
2052     void setTextDecoration(unsigned v)
2053     {
2054         SET_VAR(visual, textDecoration, v);
2055     }
2056     void setDirection(EDirection v)
2057     {
2058         inherited_flags.f._direction = v;
2059     }
2060     void setLineHeight(Length v)
2061     {
2062         SET_VAR(inherited, line_height, v)
2063     }
2064 
2065     void setWhiteSpace(EWhiteSpace v)
2066     {
2067         inherited_flags.f._white_space = v;
2068     }
2069 
2070     void setWordSpacing(int v)
2071     {
2072         SET_VAR(inherited, font.wordSpacing, v)
2073     }
2074     void setLetterSpacing(int v)
2075     {
2076         SET_VAR(inherited, font.letterSpacing, v)
2077     }
2078 
2079     void clearBackgroundLayers()
2080     {
2081         background.access()->m_background = BackgroundLayer();
2082     }
2083     void inheritBackgroundLayers(const BackgroundLayer &parent)
2084     {
2085         background.access()->m_background = parent;
2086     }
2087     void adjustBackgroundLayers();
2088 
2089     void setBorderCollapse(bool collapse)
2090     {
2091         inherited_flags.f._border_collapse = collapse;
2092     }
2093     void setBorderHorizontalSpacing(short v)
2094     {
2095         SET_VAR(inherited, border_hspacing, v)
2096     }
2097     void setBorderVerticalSpacing(short v)
2098     {
2099         SET_VAR(inherited, border_vspacing, v)
2100     }
2101 
2102     void setEmptyCells(EEmptyCell v)
2103     {
2104         inherited_flags.f._empty_cells = v;
2105     }
2106     void setCaptionSide(ECaptionSide v)
2107     {
2108         inherited_flags.f._caption_side = v;
2109     }
2110 
2111     void setListStyleType(EListStyleType v)
2112     {
2113         inherited_flags.f._list_style_type = v;
2114     }
2115     void setListStyleImage(CachedImage *v)
2116     {
2117         SET_VAR(inherited, style_image, v)
2118     }
2119     void setListStylePosition(EListStylePosition v)
2120     {
2121         inherited_flags.f._list_style_position = v;
2122     }
2123 
2124     void resetMargin()
2125     {
2126         SET_VAR(surround, margin, LengthBox(Fixed))
2127     }
2128     void setMarginTop(Length v)
2129     {
2130         SET_VAR(surround, margin.top, v)
2131     }
2132     void setMarginBottom(Length v)
2133     {
2134         SET_VAR(surround, margin.bottom, v)
2135     }
2136     void setMarginLeft(Length v)
2137     {
2138         SET_VAR(surround, margin.left, v)
2139     }
2140     void setMarginRight(Length v)
2141     {
2142         SET_VAR(surround, margin.right, v)
2143     }
2144 
2145     void resetPadding()
2146     {
2147         SET_VAR(surround, padding, LengthBox(Auto))
2148     }
2149     void setPaddingTop(Length v)
2150     {
2151         SET_VAR(surround, padding.top, v)
2152     }
2153     void setPaddingBottom(Length v)
2154     {
2155         SET_VAR(surround, padding.bottom, v)
2156     }
2157     void setPaddingLeft(Length v)
2158     {
2159         SET_VAR(surround, padding.left, v)
2160     }
2161     void setPaddingRight(Length v)
2162     {
2163         SET_VAR(surround, padding.right, v)
2164     }
2165 
2166     void setCursor(ECursor c)
2167     {
2168         inherited_flags.f._cursor_style = c;
2169     }
2170 
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 
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 
2189     int zIndex() const
2190     {
2191         return box->z_index;
2192     }
2193     void setZIndex(int v)
2194     {
2195         SET_VAR(box, z_auto, false);
2196         SET_VAR(box, z_index, v);
2197     }
2198     bool hasAutoZIndex() const
2199     {
2200         return box->z_auto;
2201     }
2202     void setHasAutoZIndex()
2203     {
2204         SET_VAR(box, z_auto, true);
2205         SET_VAR(box, z_index, 0);
2206     }
2207 
2208     void setWidows(short w)
2209     {
2210         SET_VAR(inherited, widows, w);
2211     }
2212     void setOrphans(short o)
2213     {
2214         SET_VAR(inherited, orphans, o);
2215     }
2216     void setPageBreakInside(bool b)
2217     {
2218         inherited_flags.f._page_break_inside = b;
2219     }
2220     void setPageBreakBefore(EPageBreak b)
2221     {
2222         noninherited_flags.f._page_break_before = b;
2223     }
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
2232     void setBoxSizing(EBoxSizing b)
2233     {
2234         SET_VAR(box, box_sizing, b);
2235     }
2236     void setOutlineOffset(unsigned short v)
2237     {
2238         SET_VAR(background, m_outline._offset, v)
2239     }
2240     void setWordWrap(EWordWrap w)
2241     {
2242         SET_VAR(css3InheritedData, wordWrap, w);
2243     }
2244     void setTextShadow(ShadowData *val, bool add = false);
2245     void setOpacity(float f)
2246     {
2247         SET_VAR(css3NonInheritedData, opacity, f);
2248     }
2249     void setUserInput(EUserInput ui)
2250     {
2251         inherited_flags.f._user_input = ui;
2252     }
2253 
2254     void setMarqueeIncrement(const Length &f)
2255     {
2256         SET_VAR(css3NonInheritedData.access()->marquee, increment, f);
2257     }
2258     void setMarqueeSpeed(int f)
2259     {
2260         SET_VAR(css3NonInheritedData.access()->marquee, speed, f);
2261     }
2262     void setMarqueeDirection(EMarqueeDirection d)
2263     {
2264         SET_VAR(css3NonInheritedData.access()->marquee, direction, d);
2265     }
2266     void setMarqueeBehavior(EMarqueeBehavior b)
2267     {
2268         SET_VAR(css3NonInheritedData.access()->marquee, behavior, b);
2269     }
2270     void setMarqueeLoopCount(int i)
2271     {
2272         SET_VAR(css3NonInheritedData.access()->marquee, loops, i);
2273     }
2274     void setTextOverflow(bool b)
2275     {
2276         noninherited_flags.f._textOverflow = b;
2277     }
2278 
2279     void setBorderTopRightRadius(const BorderRadii &r)
2280     {
2281         SET_VAR(css3NonInheritedData.access()->borderRadius, topRight, r);
2282     }
2283 
2284     void setBorderTopLeftRadius(const BorderRadii &r)
2285     {
2286         SET_VAR(css3NonInheritedData.access()->borderRadius, topLeft, r);
2287     }
2288 
2289     void setBorderBottomRightRadius(const BorderRadii &r)
2290     {
2291         SET_VAR(css3NonInheritedData.access()->borderRadius, bottomRight, r);
2292     }
2293 
2294     void setBorderBottomLeftRadius(const BorderRadii &r)
2295     {
2296         SET_VAR(css3NonInheritedData.access()->borderRadius, bottomLeft, r);
2297     }
2298 
2299     // End CSS3 Setters
2300 
2301     QPalette palette() const
2302     {
2303         return visual->palette;
2304     }
2305     void setPaletteColor(QPalette::ColorGroup g, QPalette::ColorRole r, const QColor &c);
2306     void resetPalette() // Called when the desktop color scheme changes.
2307     {
2308         const_cast<StyleVisualData *>(visual.get())->palette = QApplication::palette();
2309     }
2310 
2311     bool useNormalContent() const
2312     {
2313         return generated->content == nullptr;
2314     }
2315     ContentData *contentData() const
2316     {
2317         return generated->content;
2318     }
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 
2331     DOM::CSSValueListImpl *counterReset() const
2332     {
2333         return generated->counter_reset;
2334     }
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 
2351     bool isDisplayReplacedType()
2352     {
2353         return display() == INLINE_BLOCK ||/* display() == INLINE_BOX ||*/ display() == INLINE_TABLE;
2354     }
2355     bool isDisplayInlineType()
2356     {
2357         return display() == INLINE || isDisplayReplacedType();
2358     }
2359     bool isOriginalDisplayInlineType()
2360     {
2361         return originalDisplay() == INLINE || originalDisplay() == INLINE_BLOCK ||
2362                /*originalDisplay() == INLINE_BOX ||*/ originalDisplay() == INLINE_TABLE;
2363     }
2364 
2365     bool inheritedNoninherited() const
2366     {
2367         return noninherited_flags.f._inherited_noninherited;
2368     }
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
2379     static EBackgroundAttachment initialBackgroundAttachment()
2380     {
2381         return BGASCROLL;
2382     }
2383     static EBackgroundBox initialBackgroundClip()
2384     {
2385         return BGBORDER;
2386     }
2387     static EBackgroundBox initialBackgroundOrigin()
2388     {
2389         return BGPADDING;
2390     }
2391     static EBackgroundRepeat initialBackgroundRepeat()
2392     {
2393         return REPEAT;
2394     }
2395     static BGSize initialBackgroundSize()
2396     {
2397         return BGSize();
2398     }
2399     static bool initialBorderCollapse()
2400     {
2401         return false;
2402     }
2403     static EBorderStyle initialBorderStyle()
2404     {
2405         return BNONE;
2406     }
2407     static ECaptionSide initialCaptionSide()
2408     {
2409         return CAPTOP;
2410     }
2411     static EClear initialClear()
2412     {
2413         return CNONE;
2414     }
2415     static EDirection initialDirection()
2416     {
2417         return LTR;
2418     }
2419     static EDisplay initialDisplay()
2420     {
2421         return INLINE;
2422     }
2423     static EEmptyCell initialEmptyCells()
2424     {
2425         return SHOW;
2426     }
2427     static EFloat initialFloating()
2428     {
2429         return FNONE;
2430     }
2431     static EWordWrap initialWordWrap()
2432     {
2433         return WWNORMAL;
2434     }
2435     static EListStylePosition initialListStylePosition()
2436     {
2437         return OUTSIDE;
2438     }
2439     static EListStyleType initialListStyleType()
2440     {
2441         return LDISC;
2442     }
2443     static EOverflow initialOverflowX()
2444     {
2445         return OVISIBLE;
2446     }
2447     static EOverflow initialOverflowY()
2448     {
2449         return OVISIBLE;
2450     }
2451     static EPageBreak initialPageBreak()
2452     {
2453         return PBAUTO;
2454     }
2455     static bool initialPageBreakInside()
2456     {
2457         return true;
2458     }
2459     static EPosition initialPosition()
2460     {
2461         return PSTATIC;
2462     }
2463     static ETableLayout initialTableLayout()
2464     {
2465         return TAUTO;
2466     }
2467     static EUnicodeBidi initialUnicodeBidi()
2468     {
2469         return UBNormal;
2470     }
2471     static DOM::QuotesValueImpl *initialQuotes()
2472     {
2473         return nullptr;
2474     }
2475     static EBoxSizing initialBoxSizing()
2476     {
2477         return CONTENT_BOX;
2478     }
2479     static ETextTransform initialTextTransform()
2480     {
2481         return TTNONE;
2482     }
2483     static EVisibility initialVisibility()
2484     {
2485         return VISIBLE;
2486     }
2487     static EWhiteSpace initialWhiteSpace()
2488     {
2489         return NORMAL;
2490     }
2491     static Length initialBackgroundXPosition()
2492     {
2493         return Length(0.0, Percent);
2494     }
2495     static Length initialBackgroundYPosition()
2496     {
2497         return Length(0.0, Percent);
2498     }
2499     static short initialBorderHorizontalSpacing()
2500     {
2501         return 0;
2502     }
2503     static short initialBorderVerticalSpacing()
2504     {
2505         return 0;
2506     }
2507     static ECursor initialCursor()
2508     {
2509         return CURSOR_AUTO;
2510     }
2511     static QColor initialColor()
2512     {
2513         return Qt::black;
2514     }
2515     static CachedImage *initialBackgroundImage()
2516     {
2517         return nullptr;
2518     }
2519     static CachedImage *initialListStyleImage()
2520     {
2521         return nullptr;
2522     }
2523     static unsigned short initialBorderWidth()
2524     {
2525         return 3;
2526     }
2527     static BorderRadii initialBorderRadius()
2528     {
2529         return BorderRadii();
2530     }
2531     static int initialLetterWordSpacing()
2532     {
2533         return 0;
2534     }
2535     static Length initialSize()
2536     {
2537         return Length();
2538     }
2539     static Length initialMinSize()
2540     {
2541         return Length(0, Fixed);
2542     }
2543     static Length initialMaxSize()
2544     {
2545         return Length(UNDEFINED, Fixed);
2546     }
2547     static Length initialOffset()
2548     {
2549         return Length();
2550     }
2551     static Length initialMargin()
2552     {
2553         return Length(Fixed);
2554     }
2555     static Length initialPadding()
2556     {
2557         return Length(Auto);
2558     }
2559     static Length initialTextIndent()
2560     {
2561         return Length(Fixed);
2562     }
2563     static EVerticalAlign initialVerticalAlign()
2564     {
2565         return BASELINE;
2566     }
2567     static int initialWidows()
2568     {
2569         return 2;
2570     }
2571     static int initialOrphans()
2572     {
2573         return 2;
2574     }
2575     static Length initialLineHeight()
2576     {
2577         return Length(-100.0, Percent);
2578     }
2579     static ETextAlign initialTextAlign()
2580     {
2581         return TAAUTO;
2582     }
2583     static ETextDecoration initialTextDecoration()
2584     {
2585         return TDNONE;
2586     }
2587     static bool initialFlowAroundFloats()
2588     {
2589         return false;
2590     }
2591     static int initialOutlineOffset()
2592     {
2593         return 0;
2594     }
2595     static float initialOpacity()
2596     {
2597         return 1.0f;
2598     }
2599     static int initialMarqueeLoopCount()
2600     {
2601         return -1;
2602     }
2603     static int initialMarqueeSpeed()
2604     {
2605         return 85;
2606     }
2607     static Length initialMarqueeIncrement()
2608     {
2609         return Length(6, Fixed);
2610     }
2611     static EMarqueeBehavior initialMarqueeBehavior()
2612     {
2613         return MSCROLL;
2614     }
2615     static EMarqueeDirection initialMarqueeDirection()
2616     {
2617         return MAUTO;
2618     }
2619     static bool initialTextOverflow()
2620     {
2621         return false;
2622     }
2623 
2624     // SVG
2625     const khtml::SVGRenderStyle *svgStyle() const
2626     {
2627         return m_svgStyle.get();
2628     }
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 
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 
2653     Length marginTop()    const
2654     {
2655         return margin.top;
2656     }
2657     Length marginBottom() const
2658     {
2659         return margin.bottom;
2660     }
2661     Length marginLeft()   const
2662     {
2663         return margin.left;
2664     }
2665     Length marginRight()  const
2666     {
2667         return margin.right;
2668     }
2669 
2670     Length pageWidth()  const
2671     {
2672         return m_pageWidth;
2673     }
2674     Length pageHeight() const
2675     {
2676         return m_pageHeight;
2677     }
2678 
2679     void setMarginTop(Length v)
2680     {
2681         margin.top = v;
2682     }
2683     void setMarginBottom(Length v)
2684     {
2685         margin.bottom = v;
2686     }
2687     void setMarginLeft(Length v)
2688     {
2689         margin.left = v;
2690     }
2691     void setMarginRight(Length v)
2692     {
2693         margin.right = v;
2694     }
2695 
2696     void setPageWidth(Length v)
2697     {
2698         m_pageWidth = v;
2699     }
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