1/*
2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
3 *           (C) 2000 Antti Koivisto (koivisto@kde.org)
4 *           (C) 2000 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2003, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 * Library General Public License for more details.
17 *
18 * You should have received a copy of the GNU Library General Public License
19 * along with this library; see the file COPYING.LIB.  If not, write to
20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22 *
23 */
24
25#ifndef RenderStyle_h
26#define RenderStyle_h
27
28#include "AnimationList.h"
29#include "BorderValue.h"
30#include "CSSLineBoxContainValue.h"
31#include "CSSPrimitiveValue.h"
32#include "CSSPropertyNames.h"
33#include "Color.h"
34#include "ColorSpace.h"
35#include "CounterDirectives.h"
36#include "DataRef.h"
37#include "FillLayer.h"
38#include "Font.h"
39#include "GraphicsTypes.h"
40#include "Length.h"
41#include "LengthBox.h"
42#include "LengthSize.h"
43#include "LineClampValue.h"
44#include "NinePieceImage.h"
45#include "OutlineValue.h"
46#include "RenderStyleConstants.h"
47#include "RoundedIntRect.h"
48#include "ShadowData.h"
49#include "StyleBackgroundData.h"
50#include "StyleBoxData.h"
51#include "StyleFlexibleBoxData.h"
52#include "StyleInheritedData.h"
53#include "StyleMarqueeData.h"
54#include "StyleMultiColData.h"
55#include "StyleRareInheritedData.h"
56#include "StyleRareNonInheritedData.h"
57#include "StyleReflection.h"
58#include "StyleSurroundData.h"
59#include "StyleTransformData.h"
60#include "StyleVisualData.h"
61#include "TextDirection.h"
62#include "TextOrientation.h"
63#include "ThemeTypes.h"
64#include "TransformOperations.h"
65#include "UnicodeBidi.h"
66#include <wtf/Forward.h>
67#include <wtf/OwnPtr.h>
68#include <wtf/RefCounted.h>
69#include <wtf/StdLibExtras.h>
70#include <wtf/Vector.h>
71
72#if ENABLE(DASHBOARD_SUPPORT)
73#include "StyleDashboardRegion.h"
74#endif
75
76#if ENABLE(SVG)
77#include "SVGRenderStyle.h"
78#endif
79
80#if COMPILER(WINSCW)
81#define compareEqual(t, u)      ((t) == (u))
82#else
83template<typename T, typename U> inline bool compareEqual(const T& t, const U& u) { return t == static_cast<T>(u); }
84#endif
85
86#define SET_VAR(group, variable, value) \
87    if (!compareEqual(group->variable, value)) \
88        group.access()->variable = value;
89
90namespace WebCore {
91
92using std::max;
93
94class BorderData;
95class CSSStyleSelector;
96class CounterContent;
97class CursorList;
98class IntRect;
99class Pair;
100class ShadowData;
101class StyleImage;
102class TransformationMatrix;
103
104struct ContentData;
105
106typedef Vector<RefPtr<RenderStyle>, 4> PseudoStyleCache;
107
108class RenderStyle: public RefCounted<RenderStyle> {
109    friend class AnimationBase; // Used by CSS animations. We can't allow them to animate based off visited colors.
110    friend class ApplyStyleCommand; // Editing has to only reveal unvisited info.
111    friend class EditingStyle; // Editing has to only reveal unvisited info.
112    friend class CSSStyleApplyProperty; // Sets members directly.
113    friend class CSSStyleSelector; // Sets members directly.
114    friend class CSSComputedStyleDeclaration; // Ignores visited styles, so needs to be able to see unvisited info.
115    friend class PropertyWrapperMaybeInvalidColor; // Used by CSS animations. We can't allow them to animate based off visited colors.
116    friend class RenderSVGResource; // FIXME: Needs to alter the visited state by hand. Should clean the SVG code up and move it into RenderStyle perhaps.
117    friend class RenderTreeAsText; // FIXME: Only needed so the render tree can keep lying and dump the wrong colors.  Rebaselining would allow this to be yanked.
118protected:
119
120    // The following bitfield is 32-bits long, which optimizes padding with the
121    // int refCount in the base class. Beware when adding more bits.
122    bool m_affectedByAttributeSelectors : 1;
123    bool m_unique : 1;
124
125    // Bits for dynamic child matching.
126    bool m_affectedByEmpty : 1;
127    bool m_emptyState : 1;
128
129    // We optimize for :first-child and :last-child.  The other positional child selectors like nth-child or
130    // *-child-of-type, we will just give up and re-evaluate whenever children change at all.
131    bool m_childrenAffectedByFirstChildRules : 1;
132    bool m_childrenAffectedByLastChildRules : 1;
133    bool m_childrenAffectedByDirectAdjacentRules : 1;
134    bool m_childrenAffectedByForwardPositionalRules : 1;
135    bool m_childrenAffectedByBackwardPositionalRules : 1;
136    bool m_firstChildState : 1;
137    bool m_lastChildState : 1;
138    unsigned m_childIndex : 21; // Plenty of bits to cache an index.
139
140    // non-inherited attributes
141    DataRef<StyleBoxData> m_box;
142    DataRef<StyleVisualData> visual;
143    DataRef<StyleBackgroundData> m_background;
144    DataRef<StyleSurroundData> surround;
145    DataRef<StyleRareNonInheritedData> rareNonInheritedData;
146
147    // inherited attributes
148    DataRef<StyleRareInheritedData> rareInheritedData;
149    DataRef<StyleInheritedData> inherited;
150
151    // list of associated pseudo styles
152    OwnPtr<PseudoStyleCache> m_cachedPseudoStyles;
153
154#if ENABLE(SVG)
155    DataRef<SVGRenderStyle> m_svgStyle;
156#endif
157
158// !START SYNC!: Keep this in sync with the copy constructor in RenderStyle.cpp
159
160    // inherit
161    struct InheritedFlags {
162        bool operator==(const InheritedFlags& other) const
163        {
164            return (_empty_cells == other._empty_cells)
165                && (_caption_side == other._caption_side)
166                && (_list_style_type == other._list_style_type)
167                && (_list_style_position == other._list_style_position)
168                && (_visibility == other._visibility)
169                && (_text_align == other._text_align)
170                && (_text_transform == other._text_transform)
171                && (_text_decorations == other._text_decorations)
172                && (_cursor_style == other._cursor_style)
173                && (_direction == other._direction)
174                && (_border_collapse == other._border_collapse)
175                && (_white_space == other._white_space)
176                && (_box_direction == other._box_direction)
177                && (_visuallyOrdered == other._visuallyOrdered)
178                && (_force_backgrounds_to_white == other._force_backgrounds_to_white)
179                && (_pointerEvents == other._pointerEvents)
180                && (_insideLink == other._insideLink)
181                && (m_writingMode == other.m_writingMode);
182        }
183
184        bool operator!=(const InheritedFlags& other) const { return !(*this == other); }
185
186        unsigned _empty_cells : 1; // EEmptyCell
187        unsigned _caption_side : 2; // ECaptionSide
188        unsigned _list_style_type : 7; // EListStyleType
189        unsigned _list_style_position : 1; // EListStylePosition
190        unsigned _visibility : 2; // EVisibility
191        unsigned _text_align : 4; // ETextAlign
192        unsigned _text_transform : 2; // ETextTransform
193        unsigned _text_decorations : 4;
194        unsigned _cursor_style : 6; // ECursor
195        unsigned _direction : 1; // TextDirection
196        bool _border_collapse : 1 ;
197        unsigned _white_space : 3; // EWhiteSpace
198        unsigned _box_direction : 1; // EBoxDirection (CSS3 box_direction property, flexible box layout module)
199        // 34 bits
200
201        // non CSS2 inherited
202        bool _visuallyOrdered : 1;
203        bool _force_backgrounds_to_white : 1;
204        unsigned _pointerEvents : 4; // EPointerEvents
205        unsigned _insideLink : 2; // EInsideLink
206        // 43 bits
207
208        // CSS Text Layout Module Level 3: Vertical writing support
209        unsigned m_writingMode : 2; // WritingMode
210        // 45 bits
211    } inherited_flags;
212
213// don't inherit
214    struct NonInheritedFlags {
215        bool operator==(const NonInheritedFlags& other) const
216        {
217            return _effectiveDisplay == other._effectiveDisplay
218                && _originalDisplay == other._originalDisplay
219                && _overflowX == other._overflowX
220                && _overflowY == other._overflowY
221                && _vertical_align == other._vertical_align
222                && _clear == other._clear
223                && _position == other._position
224                && _floating == other._floating
225                && _table_layout == other._table_layout
226                && _page_break_before == other._page_break_before
227                && _page_break_after == other._page_break_after
228                && _page_break_inside == other._page_break_inside
229                && _styleType == other._styleType
230                && _affectedByHover == other._affectedByHover
231                && _affectedByActive == other._affectedByActive
232                && _affectedByDrag == other._affectedByDrag
233                && _pseudoBits == other._pseudoBits
234                && _unicodeBidi == other._unicodeBidi
235                && _isLink == other._isLink;
236        }
237
238        bool operator!=(const NonInheritedFlags& other) const { return !(*this == other); }
239
240        unsigned _effectiveDisplay : 5; // EDisplay
241        unsigned _originalDisplay : 5; // EDisplay
242        unsigned _overflowX : 3; // EOverflow
243        unsigned _overflowY : 3; // EOverflow
244        unsigned _vertical_align : 4; // EVerticalAlign
245        unsigned _clear : 2; // EClear
246        unsigned _position : 2; // EPosition
247        unsigned _floating : 2; // EFloat
248        unsigned _table_layout : 1; // ETableLayout
249
250        unsigned _page_break_before : 2; // EPageBreak
251        unsigned _page_break_after : 2; // EPageBreak
252        unsigned _page_break_inside : 2; // EPageBreak
253
254        unsigned _styleType : 6; // PseudoId
255        bool _affectedByHover : 1;
256        bool _affectedByActive : 1;
257        bool _affectedByDrag : 1;
258        unsigned _pseudoBits : 7;
259        unsigned _unicodeBidi : 2; // EUnicodeBidi
260        bool _isLink : 1;
261        // 50 bits
262    } noninherited_flags;
263
264// !END SYNC!
265
266protected:
267    void setBitDefaults()
268    {
269        inherited_flags._empty_cells = initialEmptyCells();
270        inherited_flags._caption_side = initialCaptionSide();
271        inherited_flags._list_style_type = initialListStyleType();
272        inherited_flags._list_style_position = initialListStylePosition();
273        inherited_flags._visibility = initialVisibility();
274        inherited_flags._text_align = initialTextAlign();
275        inherited_flags._text_transform = initialTextTransform();
276        inherited_flags._text_decorations = initialTextDecoration();
277        inherited_flags._cursor_style = initialCursor();
278        inherited_flags._direction = initialDirection();
279        inherited_flags._border_collapse = initialBorderCollapse();
280        inherited_flags._white_space = initialWhiteSpace();
281        inherited_flags._visuallyOrdered = initialVisuallyOrdered();
282        inherited_flags._box_direction = initialBoxDirection();
283        inherited_flags._force_backgrounds_to_white = false;
284        inherited_flags._pointerEvents = initialPointerEvents();
285        inherited_flags._insideLink = NotInsideLink;
286        inherited_flags.m_writingMode = initialWritingMode();
287
288        noninherited_flags._effectiveDisplay = noninherited_flags._originalDisplay = initialDisplay();
289        noninherited_flags._overflowX = initialOverflowX();
290        noninherited_flags._overflowY = initialOverflowY();
291        noninherited_flags._vertical_align = initialVerticalAlign();
292        noninherited_flags._clear = initialClear();
293        noninherited_flags._position = initialPosition();
294        noninherited_flags._floating = initialFloating();
295        noninherited_flags._table_layout = initialTableLayout();
296        noninherited_flags._page_break_before = initialPageBreak();
297        noninherited_flags._page_break_after = initialPageBreak();
298        noninherited_flags._page_break_inside = initialPageBreak();
299        noninherited_flags._styleType = NOPSEUDO;
300        noninherited_flags._affectedByHover = false;
301        noninherited_flags._affectedByActive = false;
302        noninherited_flags._affectedByDrag = false;
303        noninherited_flags._pseudoBits = 0;
304        noninherited_flags._unicodeBidi = initialUnicodeBidi();
305        noninherited_flags._isLink = false;
306    }
307
308private:
309    ALWAYS_INLINE RenderStyle();
310    // used to create the default style.
311    ALWAYS_INLINE RenderStyle(bool);
312    ALWAYS_INLINE RenderStyle(const RenderStyle&);
313
314public:
315    static PassRefPtr<RenderStyle> create();
316    static PassRefPtr<RenderStyle> createDefaultStyle();
317    static PassRefPtr<RenderStyle> createAnonymousStyle(const RenderStyle* parentStyle);
318    static PassRefPtr<RenderStyle> clone(const RenderStyle*);
319
320    ~RenderStyle();
321
322    void inheritFrom(const RenderStyle* inheritParent);
323
324    PseudoId styleType() const { return static_cast<PseudoId>(noninherited_flags._styleType); }
325    void setStyleType(PseudoId styleType) { noninherited_flags._styleType = styleType; }
326
327    RenderStyle* getCachedPseudoStyle(PseudoId) const;
328    RenderStyle* addCachedPseudoStyle(PassRefPtr<RenderStyle>);
329    void removeCachedPseudoStyle(PseudoId);
330
331    const PseudoStyleCache* cachedPseudoStyles() const { return m_cachedPseudoStyles.get(); }
332
333    bool affectedByHoverRules() const { return noninherited_flags._affectedByHover; }
334    bool affectedByActiveRules() const { return noninherited_flags._affectedByActive; }
335    bool affectedByDragRules() const { return noninherited_flags._affectedByDrag; }
336
337    void setAffectedByHoverRules(bool b) { noninherited_flags._affectedByHover = b; }
338    void setAffectedByActiveRules(bool b) { noninherited_flags._affectedByActive = b; }
339    void setAffectedByDragRules(bool b) { noninherited_flags._affectedByDrag = b; }
340
341    bool operator==(const RenderStyle& other) const;
342    bool operator!=(const RenderStyle& other) const { return !(*this == other); }
343    bool isFloating() const { return !(noninherited_flags._floating == FNONE); }
344    bool hasMargin() const { return surround->margin.nonZero(); }
345    bool hasBorder() const { return surround->border.hasBorder(); }
346    bool hasPadding() const { return surround->padding.nonZero(); }
347    bool hasOffset() const { return surround->offset.nonZero(); }
348
349    bool hasBackgroundImage() const { return m_background->background().hasImage(); }
350    bool hasFixedBackgroundImage() const { return m_background->background().hasFixedImage(); }
351    bool hasAppearance() const { return appearance() != NoControlPart; }
352
353    bool hasBackground() const
354    {
355        Color color = visitedDependentColor(CSSPropertyBackgroundColor);
356        if (color.isValid() && color.alpha() > 0)
357            return true;
358        return hasBackgroundImage();
359    }
360
361    bool visuallyOrdered() const { return inherited_flags._visuallyOrdered; }
362    void setVisuallyOrdered(bool b) { inherited_flags._visuallyOrdered = b; }
363
364    bool isStyleAvailable() const;
365
366    bool hasAnyPublicPseudoStyles() const;
367    bool hasPseudoStyle(PseudoId pseudo) const;
368    void setHasPseudoStyle(PseudoId pseudo);
369
370    // attribute getter methods
371
372    EDisplay display() const { return static_cast<EDisplay>(noninherited_flags._effectiveDisplay); }
373    EDisplay originalDisplay() const { return static_cast<EDisplay>(noninherited_flags._originalDisplay); }
374
375    Length left() const { return surround->offset.left(); }
376    Length right() const { return surround->offset.right(); }
377    Length top() const { return surround->offset.top(); }
378    Length bottom() const { return surround->offset.bottom(); }
379
380    // Accessors for positioned object edges that take into account writing mode.
381    Length logicalLeft() const { return isHorizontalWritingMode() ? left() : top(); }
382    Length logicalRight() const { return isHorizontalWritingMode() ? right() : bottom(); }
383    Length logicalTop() const { return isHorizontalWritingMode() ? (isFlippedBlocksWritingMode() ? bottom() : top()) : (isFlippedBlocksWritingMode() ? right() : left()); }
384    Length logicalBottom() const { return isHorizontalWritingMode() ? (isFlippedBlocksWritingMode() ? top() : bottom()) : (isFlippedBlocksWritingMode() ? left() : right()); }
385
386    // Whether or not a positioned element requires normal flow x/y to be computed
387    // to determine its position.
388    bool hasAutoLeftAndRight() const { return left().isAuto() && right().isAuto(); }
389    bool hasAutoTopAndBottom() const { return top().isAuto() && bottom().isAuto(); }
390    bool hasStaticInlinePosition(bool horizontal) const { return horizontal ? hasAutoLeftAndRight() : hasAutoTopAndBottom(); }
391    bool hasStaticBlockPosition(bool horizontal) const { return horizontal ? hasAutoTopAndBottom() : hasAutoLeftAndRight(); }
392
393    EPosition position() const { return static_cast<EPosition>(noninherited_flags._position); }
394    EFloat floating() const { return static_cast<EFloat>(noninherited_flags._floating); }
395
396    Length width() const { return m_box->width(); }
397    Length height() const { return m_box->height(); }
398    Length minWidth() const { return m_box->minWidth(); }
399    Length maxWidth() const { return m_box->maxWidth(); }
400    Length minHeight() const { return m_box->minHeight(); }
401    Length maxHeight() const { return m_box->maxHeight(); }
402
403    Length logicalWidth() const;
404    Length logicalHeight() const;
405    Length logicalMinWidth() const;
406    Length logicalMaxWidth() const;
407    Length logicalMinHeight() const;
408    Length logicalMaxHeight() const;
409
410    const BorderData& border() const { return surround->border; }
411    const BorderValue& borderLeft() const { return surround->border.left(); }
412    const BorderValue& borderRight() const { return surround->border.right(); }
413    const BorderValue& borderTop() const { return surround->border.top(); }
414    const BorderValue& borderBottom() const { return surround->border.bottom(); }
415
416    const BorderValue& borderBefore() const;
417    const BorderValue& borderAfter() const;
418    const BorderValue& borderStart() const;
419    const BorderValue& borderEnd() const;
420
421    const NinePieceImage& borderImage() const { return surround->border.image(); }
422
423    const LengthSize& borderTopLeftRadius() const { return surround->border.topLeft(); }
424    const LengthSize& borderTopRightRadius() const { return surround->border.topRight(); }
425    const LengthSize& borderBottomLeftRadius() const { return surround->border.bottomLeft(); }
426    const LengthSize& borderBottomRightRadius() const { return surround->border.bottomRight(); }
427    bool hasBorderRadius() const { return surround->border.hasBorderRadius(); }
428
429    unsigned short borderLeftWidth() const { return surround->border.borderLeftWidth(); }
430    EBorderStyle borderLeftStyle() const { return surround->border.left().style(); }
431    bool borderLeftIsTransparent() const { return surround->border.left().isTransparent(); }
432    unsigned short borderRightWidth() const { return surround->border.borderRightWidth(); }
433    EBorderStyle borderRightStyle() const { return surround->border.right().style(); }
434    bool borderRightIsTransparent() const { return surround->border.right().isTransparent(); }
435    unsigned short borderTopWidth() const { return surround->border.borderTopWidth(); }
436    EBorderStyle borderTopStyle() const { return surround->border.top().style(); }
437    bool borderTopIsTransparent() const { return surround->border.top().isTransparent(); }
438    unsigned short borderBottomWidth() const { return surround->border.borderBottomWidth(); }
439    EBorderStyle borderBottomStyle() const { return surround->border.bottom().style(); }
440    bool borderBottomIsTransparent() const { return surround->border.bottom().isTransparent(); }
441
442    unsigned short borderBeforeWidth() const;
443    unsigned short borderAfterWidth() const;
444    unsigned short borderStartWidth() const;
445    unsigned short borderEndWidth() const;
446
447    unsigned short outlineSize() const { return max(0, outlineWidth() + outlineOffset()); }
448    unsigned short outlineWidth() const
449    {
450        if (m_background->outline().style() == BNONE)
451            return 0;
452        return m_background->outline().width();
453    }
454    bool hasOutline() const { return outlineWidth() > 0 && outlineStyle() > BHIDDEN; }
455    EBorderStyle outlineStyle() const { return m_background->outline().style(); }
456    bool outlineStyleIsAuto() const { return m_background->outline().isAuto(); }
457
458    EOverflow overflowX() const { return static_cast<EOverflow>(noninherited_flags._overflowX); }
459    EOverflow overflowY() const { return static_cast<EOverflow>(noninherited_flags._overflowY); }
460
461    EVisibility visibility() const { return static_cast<EVisibility>(inherited_flags._visibility); }
462    EVerticalAlign verticalAlign() const { return static_cast<EVerticalAlign>(noninherited_flags._vertical_align); }
463    Length verticalAlignLength() const { return m_box->verticalAlign(); }
464
465    Length clipLeft() const { return visual->clip.left(); }
466    Length clipRight() const { return visual->clip.right(); }
467    Length clipTop() const { return visual->clip.top(); }
468    Length clipBottom() const { return visual->clip.bottom(); }
469    LengthBox clip() const { return visual->clip; }
470    bool hasClip() const { return visual->hasClip; }
471
472    EUnicodeBidi unicodeBidi() const { return static_cast<EUnicodeBidi>(noninherited_flags._unicodeBidi); }
473
474    EClear clear() const { return static_cast<EClear>(noninherited_flags._clear); }
475    ETableLayout tableLayout() const { return static_cast<ETableLayout>(noninherited_flags._table_layout); }
476
477    const Font& font() const { return inherited->font; }
478    const FontMetrics& fontMetrics() const { return inherited->font.fontMetrics(); }
479    const FontDescription& fontDescription() const { return inherited->font.fontDescription(); }
480    int fontSize() const { return inherited->font.pixelSize(); }
481
482    Length textIndent() const { return rareInheritedData->indent; }
483    ETextAlign textAlign() const { return static_cast<ETextAlign>(inherited_flags._text_align); }
484    ETextTransform textTransform() const { return static_cast<ETextTransform>(inherited_flags._text_transform); }
485    int textDecorationsInEffect() const { return inherited_flags._text_decorations; }
486    int textDecoration() const { return visual->textDecoration; }
487    int wordSpacing() const { return inherited->font.wordSpacing(); }
488    int letterSpacing() const { return inherited->font.letterSpacing(); }
489
490    float zoom() const { return visual->m_zoom; }
491    float effectiveZoom() const { return rareInheritedData->m_effectiveZoom; }
492
493    TextDirection direction() const { return static_cast<TextDirection>(inherited_flags._direction); }
494    bool isLeftToRightDirection() const { return direction() == LTR; }
495
496    Length lineHeight() const { return inherited->line_height; }
497    int computedLineHeight() const
498    {
499        Length lh = lineHeight();
500
501        // Negative value means the line height is not set.  Use the font's built-in spacing.
502        if (lh.isNegative())
503            return fontMetrics().lineSpacing();
504
505        if (lh.isPercent())
506            return lh.calcMinValue(fontSize());
507
508        return lh.value();
509    }
510
511    EWhiteSpace whiteSpace() const { return static_cast<EWhiteSpace>(inherited_flags._white_space); }
512    static bool autoWrap(EWhiteSpace ws)
513    {
514        // Nowrap and pre don't automatically wrap.
515        return ws != NOWRAP && ws != PRE;
516    }
517
518    bool autoWrap() const
519    {
520        return autoWrap(whiteSpace());
521    }
522
523    static bool preserveNewline(EWhiteSpace ws)
524    {
525        // Normal and nowrap do not preserve newlines.
526        return ws != NORMAL && ws != NOWRAP;
527    }
528
529    bool preserveNewline() const
530    {
531        return preserveNewline(whiteSpace());
532    }
533
534    static bool collapseWhiteSpace(EWhiteSpace ws)
535    {
536        // Pre and prewrap do not collapse whitespace.
537        return ws != PRE && ws != PRE_WRAP;
538    }
539
540    bool collapseWhiteSpace() const
541    {
542        return collapseWhiteSpace(whiteSpace());
543    }
544
545    bool isCollapsibleWhiteSpace(UChar c) const
546    {
547        switch (c) {
548            case ' ':
549            case '\t':
550                return collapseWhiteSpace();
551            case '\n':
552                return !preserveNewline();
553        }
554        return false;
555    }
556
557    bool breakOnlyAfterWhiteSpace() const
558    {
559        return whiteSpace() == PRE_WRAP || khtmlLineBreak() == AFTER_WHITE_SPACE;
560    }
561
562    bool breakWords() const
563    {
564        return wordBreak() == BreakWordBreak || wordWrap() == BreakWordWrap;
565    }
566
567    EFillRepeat backgroundRepeatX() const { return static_cast<EFillRepeat>(m_background->background().repeatX()); }
568    EFillRepeat backgroundRepeatY() const { return static_cast<EFillRepeat>(m_background->background().repeatY()); }
569    CompositeOperator backgroundComposite() const { return static_cast<CompositeOperator>(m_background->background().composite()); }
570    EFillAttachment backgroundAttachment() const { return static_cast<EFillAttachment>(m_background->background().attachment()); }
571    EFillBox backgroundClip() const { return static_cast<EFillBox>(m_background->background().clip()); }
572    EFillBox backgroundOrigin() const { return static_cast<EFillBox>(m_background->background().origin()); }
573    Length backgroundXPosition() const { return m_background->background().xPosition(); }
574    Length backgroundYPosition() const { return m_background->background().yPosition(); }
575    EFillSizeType backgroundSizeType() const { return m_background->background().sizeType(); }
576    LengthSize backgroundSizeLength() const { return m_background->background().sizeLength(); }
577    FillLayer* accessBackgroundLayers() { return &(m_background.access()->m_background); }
578    const FillLayer* backgroundLayers() const { return &(m_background->background()); }
579
580    StyleImage* maskImage() const { return rareNonInheritedData->m_mask.image(); }
581    EFillRepeat maskRepeatX() const { return static_cast<EFillRepeat>(rareNonInheritedData->m_mask.repeatX()); }
582    EFillRepeat maskRepeatY() const { return static_cast<EFillRepeat>(rareNonInheritedData->m_mask.repeatY()); }
583    CompositeOperator maskComposite() const { return static_cast<CompositeOperator>(rareNonInheritedData->m_mask.composite()); }
584    EFillAttachment maskAttachment() const { return static_cast<EFillAttachment>(rareNonInheritedData->m_mask.attachment()); }
585    EFillBox maskClip() const { return static_cast<EFillBox>(rareNonInheritedData->m_mask.clip()); }
586    EFillBox maskOrigin() const { return static_cast<EFillBox>(rareNonInheritedData->m_mask.origin()); }
587    Length maskXPosition() const { return rareNonInheritedData->m_mask.xPosition(); }
588    Length maskYPosition() const { return rareNonInheritedData->m_mask.yPosition(); }
589    EFillSizeType maskSizeType() const { return rareNonInheritedData->m_mask.sizeType(); }
590    LengthSize maskSizeLength() const { return rareNonInheritedData->m_mask.sizeLength(); }
591    FillLayer* accessMaskLayers() { return &(rareNonInheritedData.access()->m_mask); }
592    const FillLayer* maskLayers() const { return &(rareNonInheritedData->m_mask); }
593    const NinePieceImage& maskBoxImage() const { return rareNonInheritedData->m_maskBoxImage; }
594
595    // returns true for collapsing borders, false for separate borders
596    bool borderCollapse() const { return inherited_flags._border_collapse; }
597    short horizontalBorderSpacing() const { return inherited->horizontal_border_spacing; }
598    short verticalBorderSpacing() const { return inherited->vertical_border_spacing; }
599    EEmptyCell emptyCells() const { return static_cast<EEmptyCell>(inherited_flags._empty_cells); }
600    ECaptionSide captionSide() const { return static_cast<ECaptionSide>(inherited_flags._caption_side); }
601
602    short counterIncrement() const { return rareNonInheritedData->m_counterIncrement; }
603    short counterReset() const { return rareNonInheritedData->m_counterReset; }
604
605    EListStyleType listStyleType() const { return static_cast<EListStyleType>(inherited_flags._list_style_type); }
606    StyleImage* listStyleImage() const { return inherited->list_style_image.get(); }
607    EListStylePosition listStylePosition() const { return static_cast<EListStylePosition>(inherited_flags._list_style_position); }
608
609    Length marginTop() const { return surround->margin.top(); }
610    Length marginBottom() const { return surround->margin.bottom(); }
611    Length marginLeft() const { return surround->margin.left(); }
612    Length marginRight() const { return surround->margin.right(); }
613    Length marginBefore() const;
614    Length marginAfter() const;
615    Length marginStart() const;
616    Length marginEnd() const;
617    Length marginStartUsing(const RenderStyle* otherStyle) const;
618    Length marginEndUsing(const RenderStyle* otherStyle) const;
619    Length marginBeforeUsing(const RenderStyle* otherStyle) const;
620    Length marginAfterUsing(const RenderStyle* otherStyle) const;
621
622    LengthBox paddingBox() const { return surround->padding; }
623    Length paddingTop() const { return surround->padding.top(); }
624    Length paddingBottom() const { return surround->padding.bottom(); }
625    Length paddingLeft() const { return surround->padding.left(); }
626    Length paddingRight() const { return surround->padding.right(); }
627    Length paddingBefore() const;
628    Length paddingAfter() const;
629    Length paddingStart() const;
630    Length paddingEnd() const;
631
632    ECursor cursor() const { return static_cast<ECursor>(inherited_flags._cursor_style); }
633
634    CursorList* cursors() const { return rareInheritedData->cursorData.get(); }
635
636    EInsideLink insideLink() const { return static_cast<EInsideLink>(inherited_flags._insideLink); }
637    bool isLink() const { return noninherited_flags._isLink; }
638
639    short widows() const { return rareInheritedData->widows; }
640    short orphans() const { return rareInheritedData->orphans; }
641    EPageBreak pageBreakInside() const { return static_cast<EPageBreak>(noninherited_flags._page_break_inside); }
642    EPageBreak pageBreakBefore() const { return static_cast<EPageBreak>(noninherited_flags._page_break_before); }
643    EPageBreak pageBreakAfter() const { return static_cast<EPageBreak>(noninherited_flags._page_break_after); }
644
645    // CSS3 Getter Methods
646
647    int outlineOffset() const
648    {
649        if (m_background->outline().style() == BNONE)
650            return 0;
651        return m_background->outline().offset();
652    }
653
654    const ShadowData* textShadow() const { return rareInheritedData->textShadow; }
655    void getTextShadowExtent(int& top, int& right, int& bottom, int& left) const { getShadowExtent(textShadow(), top, right, bottom, left); }
656    void getTextShadowHorizontalExtent(int& left, int& right) const { getShadowHorizontalExtent(textShadow(), left, right); }
657    void getTextShadowVerticalExtent(int& top, int& bottom) const { getShadowVerticalExtent(textShadow(), top, bottom); }
658    void getTextShadowInlineDirectionExtent(int& logicalLeft, int& logicalRight) { getShadowInlineDirectionExtent(textShadow(), logicalLeft, logicalRight); }
659    void getTextShadowBlockDirectionExtent(int& logicalTop, int& logicalBottom) { getShadowBlockDirectionExtent(textShadow(), logicalTop, logicalBottom); }
660
661    float textStrokeWidth() const { return rareInheritedData->textStrokeWidth; }
662    ColorSpace colorSpace() const { return static_cast<ColorSpace>(rareInheritedData->colorSpace); }
663    float opacity() const { return rareNonInheritedData->opacity; }
664    ControlPart appearance() const { return static_cast<ControlPart>(rareNonInheritedData->m_appearance); }
665    EBoxAlignment boxAlign() const { return static_cast<EBoxAlignment>(rareNonInheritedData->flexibleBox->align); }
666    EBoxDirection boxDirection() const { return static_cast<EBoxDirection>(inherited_flags._box_direction); }
667    float boxFlex() { return rareNonInheritedData->flexibleBox->flex; }
668    unsigned int boxFlexGroup() const { return rareNonInheritedData->flexibleBox->flex_group; }
669    EBoxLines boxLines() { return static_cast<EBoxLines>(rareNonInheritedData->flexibleBox->lines); }
670    unsigned int boxOrdinalGroup() const { return rareNonInheritedData->flexibleBox->ordinal_group; }
671    EBoxOrient boxOrient() const { return static_cast<EBoxOrient>(rareNonInheritedData->flexibleBox->orient); }
672    EBoxAlignment boxPack() const { return static_cast<EBoxAlignment>(rareNonInheritedData->flexibleBox->pack); }
673
674    const ShadowData* boxShadow() const { return rareNonInheritedData->m_boxShadow.get(); }
675    void getBoxShadowExtent(int& top, int& right, int& bottom, int& left) const { getShadowExtent(boxShadow(), top, right, bottom, left); }
676    void getBoxShadowHorizontalExtent(int& left, int& right) const { getShadowHorizontalExtent(boxShadow(), left, right); }
677    void getBoxShadowVerticalExtent(int& top, int& bottom) const { getShadowVerticalExtent(boxShadow(), top, bottom); }
678    void getBoxShadowInlineDirectionExtent(int& logicalLeft, int& logicalRight) { getShadowInlineDirectionExtent(boxShadow(), logicalLeft, logicalRight); }
679    void getBoxShadowBlockDirectionExtent(int& logicalTop, int& logicalBottom) { getShadowBlockDirectionExtent(boxShadow(), logicalTop, logicalBottom); }
680
681    StyleReflection* boxReflect() const { return rareNonInheritedData->m_boxReflect.get(); }
682    EBoxSizing boxSizing() const { return m_box->boxSizing(); }
683    Length marqueeIncrement() const { return rareNonInheritedData->marquee->increment; }
684    int marqueeSpeed() const { return rareNonInheritedData->marquee->speed; }
685    int marqueeLoopCount() const { return rareNonInheritedData->marquee->loops; }
686    EMarqueeBehavior marqueeBehavior() const { return static_cast<EMarqueeBehavior>(rareNonInheritedData->marquee->behavior); }
687    EMarqueeDirection marqueeDirection() const { return static_cast<EMarqueeDirection>(rareNonInheritedData->marquee->direction); }
688    EUserModify userModify() const { return static_cast<EUserModify>(rareInheritedData->userModify); }
689    EUserDrag userDrag() const { return static_cast<EUserDrag>(rareNonInheritedData->userDrag); }
690    EUserSelect userSelect() const { return static_cast<EUserSelect>(rareInheritedData->userSelect); }
691    bool textOverflow() const { return rareNonInheritedData->textOverflow; }
692    EMarginCollapse marginBeforeCollapse() const { return static_cast<EMarginCollapse>(rareNonInheritedData->marginBeforeCollapse); }
693    EMarginCollapse marginAfterCollapse() const { return static_cast<EMarginCollapse>(rareNonInheritedData->marginAfterCollapse); }
694    EWordBreak wordBreak() const { return static_cast<EWordBreak>(rareInheritedData->wordBreak); }
695    EWordWrap wordWrap() const { return static_cast<EWordWrap>(rareInheritedData->wordWrap); }
696    ENBSPMode nbspMode() const { return static_cast<ENBSPMode>(rareInheritedData->nbspMode); }
697    EKHTMLLineBreak khtmlLineBreak() const { return static_cast<EKHTMLLineBreak>(rareInheritedData->khtmlLineBreak); }
698    EMatchNearestMailBlockquoteColor matchNearestMailBlockquoteColor() const { return static_cast<EMatchNearestMailBlockquoteColor>(rareNonInheritedData->matchNearestMailBlockquoteColor); }
699    const AtomicString& highlight() const { return rareInheritedData->highlight; }
700    Hyphens hyphens() const { return static_cast<Hyphens>(rareInheritedData->hyphens); }
701    short hyphenationLimitBefore() const { return rareInheritedData->hyphenationLimitBefore; }
702    short hyphenationLimitAfter() const { return rareInheritedData->hyphenationLimitAfter; }
703    const AtomicString& hyphenationString() const { return rareInheritedData->hyphenationString; }
704    const AtomicString& locale() const { return rareInheritedData->locale; }
705    EBorderFit borderFit() const { return static_cast<EBorderFit>(rareNonInheritedData->m_borderFit); }
706    EResize resize() const { return static_cast<EResize>(rareInheritedData->resize); }
707    float columnWidth() const { return rareNonInheritedData->m_multiCol->m_width; }
708    bool hasAutoColumnWidth() const { return rareNonInheritedData->m_multiCol->m_autoWidth; }
709    unsigned short columnCount() const { return rareNonInheritedData->m_multiCol->m_count; }
710    bool hasAutoColumnCount() const { return rareNonInheritedData->m_multiCol->m_autoCount; }
711    bool specifiesColumns() const { return !hasAutoColumnCount() || !hasAutoColumnWidth(); }
712    float columnGap() const { return rareNonInheritedData->m_multiCol->m_gap; }
713    bool hasNormalColumnGap() const { return rareNonInheritedData->m_multiCol->m_normalGap; }
714    EBorderStyle columnRuleStyle() const { return rareNonInheritedData->m_multiCol->m_rule.style(); }
715    unsigned short columnRuleWidth() const { return rareNonInheritedData->m_multiCol->ruleWidth(); }
716    bool columnRuleIsTransparent() const { return rareNonInheritedData->m_multiCol->m_rule.isTransparent(); }
717    bool columnSpan() const { return rareNonInheritedData->m_multiCol->m_columnSpan; }
718    EPageBreak columnBreakBefore() const { return static_cast<EPageBreak>(rareNonInheritedData->m_multiCol->m_breakBefore); }
719    EPageBreak columnBreakInside() const { return static_cast<EPageBreak>(rareNonInheritedData->m_multiCol->m_breakInside); }
720    EPageBreak columnBreakAfter() const { return static_cast<EPageBreak>(rareNonInheritedData->m_multiCol->m_breakAfter); }
721    const TransformOperations& transform() const { return rareNonInheritedData->m_transform->m_operations; }
722    Length transformOriginX() const { return rareNonInheritedData->m_transform->m_x; }
723    Length transformOriginY() const { return rareNonInheritedData->m_transform->m_y; }
724    float transformOriginZ() const { return rareNonInheritedData->m_transform->m_z; }
725    bool hasTransform() const { return !rareNonInheritedData->m_transform->m_operations.operations().isEmpty(); }
726
727    TextEmphasisFill textEmphasisFill() const { return static_cast<TextEmphasisFill>(rareInheritedData->textEmphasisFill); }
728    TextEmphasisMark textEmphasisMark() const;
729    const AtomicString& textEmphasisCustomMark() const { return rareInheritedData->textEmphasisCustomMark; }
730    TextEmphasisPosition textEmphasisPosition() const { return static_cast<TextEmphasisPosition>(rareInheritedData->textEmphasisPosition); }
731    const AtomicString& textEmphasisMarkString() const;
732
733    // Return true if any transform related property (currently transform, transformStyle3D or perspective)
734    // indicates that we are transforming
735    bool hasTransformRelatedProperty() const { return hasTransform() || preserves3D() || hasPerspective(); }
736
737    enum ApplyTransformOrigin { IncludeTransformOrigin, ExcludeTransformOrigin };
738    void applyTransform(TransformationMatrix&, const IntSize& borderBoxSize, ApplyTransformOrigin = IncludeTransformOrigin) const;
739    void setPageScaleTransform(float);
740
741    bool hasMask() const { return rareNonInheritedData->m_mask.hasImage() || rareNonInheritedData->m_maskBoxImage.hasImage(); }
742
743    TextCombine textCombine() const { return static_cast<TextCombine>(rareNonInheritedData->m_textCombine); }
744    bool hasTextCombine() const { return textCombine() != TextCombineNone; }
745    // End CSS3 Getters
746
747    // Apple-specific property getter methods
748    EPointerEvents pointerEvents() const { return static_cast<EPointerEvents>(inherited_flags._pointerEvents); }
749    const AnimationList* animations() const { return rareNonInheritedData->m_animations.get(); }
750    const AnimationList* transitions() const { return rareNonInheritedData->m_transitions.get(); }
751
752    AnimationList* accessAnimations();
753    AnimationList* accessTransitions();
754
755    bool hasAnimations() const { return rareNonInheritedData->m_animations && rareNonInheritedData->m_animations->size() > 0; }
756    bool hasTransitions() const { return rareNonInheritedData->m_transitions && rareNonInheritedData->m_transitions->size() > 0; }
757
758    // return the first found Animation (including 'all' transitions)
759    const Animation* transitionForProperty(int property) const;
760
761    ETransformStyle3D transformStyle3D() const { return rareNonInheritedData->m_transformStyle3D; }
762    bool preserves3D() const { return rareNonInheritedData->m_transformStyle3D == TransformStyle3DPreserve3D; }
763
764    EBackfaceVisibility backfaceVisibility() const { return rareNonInheritedData->m_backfaceVisibility; }
765    float perspective() const { return rareNonInheritedData->m_perspective; }
766    bool hasPerspective() const { return rareNonInheritedData->m_perspective > 0; }
767    Length perspectiveOriginX() const { return rareNonInheritedData->m_perspectiveOriginX; }
768    Length perspectiveOriginY() const { return rareNonInheritedData->m_perspectiveOriginY; }
769    LengthSize pageSize() const { return rareNonInheritedData->m_pageSize; }
770    PageSizeType pageSizeType() const { return rareNonInheritedData->m_pageSizeType; }
771
772#if USE(ACCELERATED_COMPOSITING)
773    // When set, this ensures that styles compare as different. Used during accelerated animations.
774    bool isRunningAcceleratedAnimation() const { return rareNonInheritedData->m_runningAcceleratedAnimation; }
775#endif
776
777    LineBoxContain lineBoxContain() const { return rareInheritedData->m_lineBoxContain; }
778    const LineClampValue& lineClamp() const { return rareNonInheritedData->lineClamp; }
779    bool textSizeAdjust() const { return rareInheritedData->textSizeAdjust; }
780    ETextSecurity textSecurity() const { return static_cast<ETextSecurity>(rareInheritedData->textSecurity); }
781
782    WritingMode writingMode() const { return static_cast<WritingMode>(inherited_flags.m_writingMode); }
783    bool isHorizontalWritingMode() const { return writingMode() == TopToBottomWritingMode || writingMode() == BottomToTopWritingMode; }
784    bool isFlippedLinesWritingMode() const { return writingMode() == LeftToRightWritingMode || writingMode() == BottomToTopWritingMode; }
785    bool isFlippedBlocksWritingMode() const { return writingMode() == RightToLeftWritingMode || writingMode() == BottomToTopWritingMode; }
786
787    ESpeak speak() { return static_cast<ESpeak>(rareInheritedData->speak); }
788
789#ifdef ANDROID_CSS_TAP_HIGHLIGHT_COLOR
790    Color tapHighlightColor() const { return rareInheritedData->tapHighlightColor; }
791#endif
792// attribute setter methods
793
794    void setDisplay(EDisplay v) { noninherited_flags._effectiveDisplay = v; }
795    void setOriginalDisplay(EDisplay v) { noninherited_flags._originalDisplay = v; }
796    void setPosition(EPosition v) { noninherited_flags._position = v; }
797    void setFloating(EFloat v) { noninherited_flags._floating = v; }
798
799    void setLeft(Length v) { SET_VAR(surround, offset.m_left, v) }
800    void setRight(Length v) { SET_VAR(surround, offset.m_right, v) }
801    void setTop(Length v) { SET_VAR(surround, offset.m_top, v) }
802    void setBottom(Length v) { SET_VAR(surround, offset.m_bottom, v) }
803
804    void setWidth(Length v) { SET_VAR(m_box, m_width, v) }
805    void setHeight(Length v) { SET_VAR(m_box, m_height, v) }
806
807    void setMinWidth(Length v) { SET_VAR(m_box, m_minWidth, v) }
808    void setMaxWidth(Length v) { SET_VAR(m_box, m_maxWidth, v) }
809    void setMinHeight(Length v) { SET_VAR(m_box, m_minHeight, v) }
810    void setMaxHeight(Length v) { SET_VAR(m_box, m_maxHeight, v) }
811
812#if ENABLE(DASHBOARD_SUPPORT)
813    Vector<StyleDashboardRegion> dashboardRegions() const { return rareNonInheritedData->m_dashboardRegions; }
814    void setDashboardRegions(Vector<StyleDashboardRegion> regions) { SET_VAR(rareNonInheritedData, m_dashboardRegions, regions); }
815
816    void setDashboardRegion(int type, const String& label, Length t, Length r, Length b, Length l, bool append)
817    {
818        StyleDashboardRegion region;
819        region.label = label;
820        region.offset.m_top = t;
821        region.offset.m_right = r;
822        region.offset.m_bottom = b;
823        region.offset.m_left = l;
824        region.type = type;
825        if (!append)
826            rareNonInheritedData.access()->m_dashboardRegions.clear();
827        rareNonInheritedData.access()->m_dashboardRegions.append(region);
828    }
829#endif
830
831    void resetBorder() { resetBorderImage(); resetBorderTop(); resetBorderRight(); resetBorderBottom(); resetBorderLeft(); resetBorderRadius(); }
832    void resetBorderTop() { SET_VAR(surround, border.m_top, BorderValue()) }
833    void resetBorderRight() { SET_VAR(surround, border.m_right, BorderValue()) }
834    void resetBorderBottom() { SET_VAR(surround, border.m_bottom, BorderValue()) }
835    void resetBorderLeft() { SET_VAR(surround, border.m_left, BorderValue()) }
836    void resetBorderImage() { SET_VAR(surround, border.m_image, NinePieceImage()) }
837    void resetBorderRadius() { resetBorderTopLeftRadius(); resetBorderTopRightRadius(); resetBorderBottomLeftRadius(); resetBorderBottomRightRadius(); }
838    void resetBorderTopLeftRadius() { SET_VAR(surround, border.m_topLeft, initialBorderRadius()) }
839    void resetBorderTopRightRadius() { SET_VAR(surround, border.m_topRight, initialBorderRadius()) }
840    void resetBorderBottomLeftRadius() { SET_VAR(surround, border.m_bottomLeft, initialBorderRadius()) }
841    void resetBorderBottomRightRadius() { SET_VAR(surround, border.m_bottomRight, initialBorderRadius()) }
842
843    void resetOutline() { SET_VAR(m_background, m_outline, OutlineValue()) }
844
845    void setBackgroundColor(const Color& v) { SET_VAR(m_background, m_color, v) }
846
847    void setBackgroundXPosition(Length l) { SET_VAR(m_background, m_background.m_xPosition, l) }
848    void setBackgroundYPosition(Length l) { SET_VAR(m_background, m_background.m_yPosition, l) }
849    void setBackgroundSize(EFillSizeType b) { SET_VAR(m_background, m_background.m_sizeType, b) }
850    void setBackgroundSizeLength(LengthSize l) { SET_VAR(m_background, m_background.m_sizeLength, l) }
851
852    void setBorderImage(const NinePieceImage& b) { SET_VAR(surround, border.m_image, b) }
853
854    void setBorderTopLeftRadius(const LengthSize& s) { SET_VAR(surround, border.m_topLeft, s) }
855    void setBorderTopRightRadius(const LengthSize& s) { SET_VAR(surround, border.m_topRight, s) }
856    void setBorderBottomLeftRadius(const LengthSize& s) { SET_VAR(surround, border.m_bottomLeft, s) }
857    void setBorderBottomRightRadius(const LengthSize& s) { SET_VAR(surround, border.m_bottomRight, s) }
858
859    void setBorderRadius(const LengthSize& s)
860    {
861        setBorderTopLeftRadius(s);
862        setBorderTopRightRadius(s);
863        setBorderBottomLeftRadius(s);
864        setBorderBottomRightRadius(s);
865    }
866    void setBorderRadius(const IntSize& s)
867    {
868        setBorderRadius(LengthSize(Length(s.width(), Fixed), Length(s.height(), Fixed)));
869    }
870
871    RoundedIntRect getRoundedBorderFor(const IntRect& borderRect, bool includeLogicalLeftEdge = true, bool includeLogicalRightEdge = true) const;
872    RoundedIntRect getRoundedInnerBorderFor(const IntRect& borderRect, bool includeLogicalLeftEdge = true, bool includeLogicalRightEdge = true) const;
873
874    RoundedIntRect getRoundedInnerBorderFor(const IntRect& borderRect,
875        int topWidth, int bottomWidth, int leftWidth, int rightWidth, bool includeLogicalLeftEdge, bool includeLogicalRightEdge) const;
876
877    void setBorderLeftWidth(unsigned short v) { SET_VAR(surround, border.m_left.m_width, v) }
878    void setBorderLeftStyle(EBorderStyle v) { SET_VAR(surround, border.m_left.m_style, v) }
879    void setBorderLeftColor(const Color& v) { SET_VAR(surround, border.m_left.m_color, v) }
880    void setBorderRightWidth(unsigned short v) { SET_VAR(surround, border.m_right.m_width, v) }
881    void setBorderRightStyle(EBorderStyle v) { SET_VAR(surround, border.m_right.m_style, v) }
882    void setBorderRightColor(const Color& v) { SET_VAR(surround, border.m_right.m_color, v) }
883    void setBorderTopWidth(unsigned short v) { SET_VAR(surround, border.m_top.m_width, v) }
884    void setBorderTopStyle(EBorderStyle v) { SET_VAR(surround, border.m_top.m_style, v) }
885    void setBorderTopColor(const Color& v) { SET_VAR(surround, border.m_top.m_color, v) }
886    void setBorderBottomWidth(unsigned short v) { SET_VAR(surround, border.m_bottom.m_width, v) }
887    void setBorderBottomStyle(EBorderStyle v) { SET_VAR(surround, border.m_bottom.m_style, v) }
888    void setBorderBottomColor(const Color& v) { SET_VAR(surround, border.m_bottom.m_color, v) }
889    void setOutlineWidth(unsigned short v) { SET_VAR(m_background, m_outline.m_width, v) }
890
891    void setOutlineStyle(EBorderStyle v, bool isAuto = false)
892    {
893        SET_VAR(m_background, m_outline.m_style, v)
894        SET_VAR(m_background, m_outline.m_isAuto, isAuto)
895    }
896
897    void setOutlineColor(const Color& v) { SET_VAR(m_background, m_outline.m_color, v) }
898
899    void setOverflowX(EOverflow v) { noninherited_flags._overflowX = v; }
900    void setOverflowY(EOverflow v) { noninherited_flags._overflowY = v; }
901    void setVisibility(EVisibility v) { inherited_flags._visibility = v; }
902    void setVerticalAlign(EVerticalAlign v) { noninherited_flags._vertical_align = v; }
903    void setVerticalAlignLength(Length l) { SET_VAR(m_box, m_verticalAlign, l) }
904
905    void setHasClip(bool b = true) { SET_VAR(visual, hasClip, b) }
906    void setClipLeft(Length v) { SET_VAR(visual, clip.m_left, v) }
907    void setClipRight(Length v) { SET_VAR(visual, clip.m_right, v) }
908    void setClipTop(Length v) { SET_VAR(visual, clip.m_top, v) }
909    void setClipBottom(Length v) { SET_VAR(visual, clip.m_bottom, v) }
910    void setClip(Length top, Length right, Length bottom, Length left);
911    void setClip(LengthBox box) { SET_VAR(visual, clip, box) }
912
913    void setUnicodeBidi(EUnicodeBidi b) { noninherited_flags._unicodeBidi = b; }
914
915    void setClear(EClear v) { noninherited_flags._clear = v; }
916    void setTableLayout(ETableLayout v) { noninherited_flags._table_layout = v; }
917
918    bool setFontDescription(const FontDescription& v)
919    {
920        if (inherited->font.fontDescription() != v) {
921            inherited.access()->font = Font(v, inherited->font.letterSpacing(), inherited->font.wordSpacing());
922            return true;
923        }
924        return false;
925    }
926
927    // Only used for blending font sizes when animating.
928    void setBlendedFontSize(int);
929
930    void setColor(const Color& v) { SET_VAR(inherited, color, v) }
931    void setTextIndent(Length v) { SET_VAR(rareInheritedData, indent, v) }
932    void setTextAlign(ETextAlign v) { inherited_flags._text_align = v; }
933    void setTextTransform(ETextTransform v) { inherited_flags._text_transform = v; }
934    void addToTextDecorationsInEffect(int v) { inherited_flags._text_decorations |= v; }
935    void setTextDecorationsInEffect(int v) { inherited_flags._text_decorations = v; }
936    void setTextDecoration(int v) { SET_VAR(visual, textDecoration, v); }
937    void setDirection(TextDirection v) { inherited_flags._direction = v; }
938    void setLineHeight(Length v) { SET_VAR(inherited, line_height, v) }
939    void setZoom(float f) { SET_VAR(visual, m_zoom, f); setEffectiveZoom(effectiveZoom() * zoom()); }
940    void setEffectiveZoom(float f) { SET_VAR(rareInheritedData, m_effectiveZoom, f) }
941
942    void setWhiteSpace(EWhiteSpace v) { inherited_flags._white_space = v; }
943
944    void setWordSpacing(int v) { inherited.access()->font.setWordSpacing(v); }
945    void setLetterSpacing(int v) { inherited.access()->font.setLetterSpacing(v); }
946
947    void clearBackgroundLayers() { m_background.access()->m_background = FillLayer(BackgroundFillLayer); }
948    void inheritBackgroundLayers(const FillLayer& parent) { m_background.access()->m_background = parent; }
949
950    void adjustBackgroundLayers()
951    {
952        if (backgroundLayers()->next()) {
953            accessBackgroundLayers()->cullEmptyLayers();
954            accessBackgroundLayers()->fillUnsetProperties();
955        }
956    }
957
958    void clearMaskLayers() { rareNonInheritedData.access()->m_mask = FillLayer(MaskFillLayer); }
959    void inheritMaskLayers(const FillLayer& parent) { rareNonInheritedData.access()->m_mask = parent; }
960
961    void adjustMaskLayers()
962    {
963        if (maskLayers()->next()) {
964            accessMaskLayers()->cullEmptyLayers();
965            accessMaskLayers()->fillUnsetProperties();
966        }
967    }
968
969    void setMaskBoxImage(const NinePieceImage& b) { SET_VAR(rareNonInheritedData, m_maskBoxImage, b) }
970    void setMaskXPosition(Length l) { SET_VAR(rareNonInheritedData, m_mask.m_xPosition, l) }
971    void setMaskYPosition(Length l) { SET_VAR(rareNonInheritedData, m_mask.m_yPosition, l) }
972    void setMaskSize(LengthSize l) { SET_VAR(rareNonInheritedData, m_mask.m_sizeLength, l) }
973
974    void setBorderCollapse(bool collapse) { inherited_flags._border_collapse = collapse; }
975    void setHorizontalBorderSpacing(short v) { SET_VAR(inherited, horizontal_border_spacing, v) }
976    void setVerticalBorderSpacing(short v) { SET_VAR(inherited, vertical_border_spacing, v) }
977    void setEmptyCells(EEmptyCell v) { inherited_flags._empty_cells = v; }
978    void setCaptionSide(ECaptionSide v) { inherited_flags._caption_side = v; }
979
980    void setCounterIncrement(short v) { SET_VAR(rareNonInheritedData, m_counterIncrement, v) }
981    void setCounterReset(short v) { SET_VAR(rareNonInheritedData, m_counterReset, v) }
982
983    void setListStyleType(EListStyleType v) { inherited_flags._list_style_type = v; }
984    void setListStyleImage(PassRefPtr<StyleImage> v) { if (inherited->list_style_image != v) inherited.access()->list_style_image = v; }
985    void setListStylePosition(EListStylePosition v) { inherited_flags._list_style_position = v; }
986
987    void resetMargin() { SET_VAR(surround, margin, LengthBox(Fixed)) }
988    void setMarginTop(Length v) { SET_VAR(surround, margin.m_top, v) }
989    void setMarginBottom(Length v) { SET_VAR(surround, margin.m_bottom, v) }
990    void setMarginLeft(Length v) { SET_VAR(surround, margin.m_left, v) }
991    void setMarginRight(Length v) { SET_VAR(surround, margin.m_right, v) }
992    void setMarginStart(Length);
993    void setMarginEnd(Length);
994
995    void resetPadding() { SET_VAR(surround, padding, LengthBox(Auto)) }
996    void setPaddingBox(const LengthBox& b) { SET_VAR(surround, padding, b) }
997    void setPaddingTop(Length v) { SET_VAR(surround, padding.m_top, v) }
998    void setPaddingBottom(Length v) { SET_VAR(surround, padding.m_bottom, v) }
999    void setPaddingLeft(Length v) { SET_VAR(surround, padding.m_left, v) }
1000    void setPaddingRight(Length v) { SET_VAR(surround, padding.m_right, v) }
1001
1002    void setCursor(ECursor c) { inherited_flags._cursor_style = c; }
1003    void addCursor(PassRefPtr<StyleImage>, const IntPoint& hotSpot = IntPoint());
1004    void setCursorList(PassRefPtr<CursorList>);
1005    void clearCursorList();
1006
1007    void setInsideLink(EInsideLink insideLink) { inherited_flags._insideLink = insideLink; }
1008    void setIsLink(bool b) { noninherited_flags._isLink = b; }
1009
1010    bool forceBackgroundsToWhite() const { return inherited_flags._force_backgrounds_to_white; }
1011    void setForceBackgroundsToWhite(bool b=true) { inherited_flags._force_backgrounds_to_white = b; }
1012
1013    bool hasAutoZIndex() const { return m_box->hasAutoZIndex(); }
1014    void setHasAutoZIndex() { SET_VAR(m_box, m_hasAutoZIndex, true); SET_VAR(m_box, m_zIndex, 0) }
1015    int zIndex() const { return m_box->zIndex(); }
1016    void setZIndex(int v) { SET_VAR(m_box, m_hasAutoZIndex, false); SET_VAR(m_box, m_zIndex, v) }
1017
1018    void setWidows(short w) { SET_VAR(rareInheritedData, widows, w); }
1019    void setOrphans(short o) { SET_VAR(rareInheritedData, orphans, o); }
1020    void setPageBreakInside(EPageBreak b) { noninherited_flags._page_break_inside = b; }
1021    void setPageBreakBefore(EPageBreak b) { noninherited_flags._page_break_before = b; }
1022    void setPageBreakAfter(EPageBreak b) { noninherited_flags._page_break_after = b; }
1023
1024    // CSS3 Setters
1025    void setOutlineOffset(int v) { SET_VAR(m_background, m_outline.m_offset, v) }
1026    void setTextShadow(ShadowData* val, bool add=false);
1027    void setTextStrokeColor(const Color& c) { SET_VAR(rareInheritedData, textStrokeColor, c) }
1028    void setTextStrokeWidth(float w) { SET_VAR(rareInheritedData, textStrokeWidth, w) }
1029    void setTextFillColor(const Color& c) { SET_VAR(rareInheritedData, textFillColor, c) }
1030    void setColorSpace(ColorSpace space) { SET_VAR(rareInheritedData, colorSpace, space) }
1031    void setOpacity(float f) { SET_VAR(rareNonInheritedData, opacity, f); }
1032    void setAppearance(ControlPart a) { SET_VAR(rareNonInheritedData, m_appearance, a); }
1033    void setBoxAlign(EBoxAlignment a) { SET_VAR(rareNonInheritedData.access()->flexibleBox, align, a); }
1034    void setBoxDirection(EBoxDirection d) { inherited_flags._box_direction = d; }
1035    void setBoxFlex(float f) { SET_VAR(rareNonInheritedData.access()->flexibleBox, flex, f); }
1036    void setBoxFlexGroup(unsigned int fg) { SET_VAR(rareNonInheritedData.access()->flexibleBox, flex_group, fg); }
1037    void setBoxLines(EBoxLines l) { SET_VAR(rareNonInheritedData.access()->flexibleBox, lines, l); }
1038    void setBoxOrdinalGroup(unsigned int og) { SET_VAR(rareNonInheritedData.access()->flexibleBox, ordinal_group, og); }
1039    void setBoxOrient(EBoxOrient o) { SET_VAR(rareNonInheritedData.access()->flexibleBox, orient, o); }
1040    void setBoxPack(EBoxAlignment p) { SET_VAR(rareNonInheritedData.access()->flexibleBox, pack, p); }
1041    void setBoxShadow(ShadowData* val, bool add=false);
1042    void setBoxReflect(PassRefPtr<StyleReflection> reflect) { if (rareNonInheritedData->m_boxReflect != reflect) rareNonInheritedData.access()->m_boxReflect = reflect; }
1043    void setBoxSizing(EBoxSizing s) { SET_VAR(m_box, m_boxSizing, s); }
1044    void setMarqueeIncrement(const Length& f) { SET_VAR(rareNonInheritedData.access()->marquee, increment, f); }
1045    void setMarqueeSpeed(int f) { SET_VAR(rareNonInheritedData.access()->marquee, speed, f); }
1046    void setMarqueeDirection(EMarqueeDirection d) { SET_VAR(rareNonInheritedData.access()->marquee, direction, d); }
1047    void setMarqueeBehavior(EMarqueeBehavior b) { SET_VAR(rareNonInheritedData.access()->marquee, behavior, b); }
1048    void setMarqueeLoopCount(int i) { SET_VAR(rareNonInheritedData.access()->marquee, loops, i); }
1049    void setUserModify(EUserModify u) { SET_VAR(rareInheritedData, userModify, u); }
1050    void setUserDrag(EUserDrag d) { SET_VAR(rareNonInheritedData, userDrag, d); }
1051    void setUserSelect(EUserSelect s) { SET_VAR(rareInheritedData, userSelect, s); }
1052    void setTextOverflow(bool b) { SET_VAR(rareNonInheritedData, textOverflow, b); }
1053    void setMarginBeforeCollapse(EMarginCollapse c) { SET_VAR(rareNonInheritedData, marginBeforeCollapse, c); }
1054    void setMarginAfterCollapse(EMarginCollapse c) { SET_VAR(rareNonInheritedData, marginAfterCollapse, c); }
1055    void setWordBreak(EWordBreak b) { SET_VAR(rareInheritedData, wordBreak, b); }
1056    void setWordWrap(EWordWrap b) { SET_VAR(rareInheritedData, wordWrap, b); }
1057    void setNBSPMode(ENBSPMode b) { SET_VAR(rareInheritedData, nbspMode, b); }
1058    void setKHTMLLineBreak(EKHTMLLineBreak b) { SET_VAR(rareInheritedData, khtmlLineBreak, b); }
1059    void setMatchNearestMailBlockquoteColor(EMatchNearestMailBlockquoteColor c) { SET_VAR(rareNonInheritedData, matchNearestMailBlockquoteColor, c); }
1060    void setHighlight(const AtomicString& h) { SET_VAR(rareInheritedData, highlight, h); }
1061    void setHyphens(Hyphens h) { SET_VAR(rareInheritedData, hyphens, h); }
1062    void setHyphenationLimitBefore(short limit) { SET_VAR(rareInheritedData, hyphenationLimitBefore, limit); }
1063    void setHyphenationLimitAfter(short limit) { SET_VAR(rareInheritedData, hyphenationLimitAfter, limit); }
1064    void setHyphenationString(const AtomicString& h) { SET_VAR(rareInheritedData, hyphenationString, h); }
1065    void setLocale(const AtomicString& locale) { SET_VAR(rareInheritedData, locale, locale); }
1066    void setBorderFit(EBorderFit b) { SET_VAR(rareNonInheritedData, m_borderFit, b); }
1067    void setResize(EResize r) { SET_VAR(rareInheritedData, resize, r); }
1068    void setColumnWidth(float f) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_autoWidth, false); SET_VAR(rareNonInheritedData.access()->m_multiCol, m_width, f); }
1069    void setHasAutoColumnWidth() { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_autoWidth, true); SET_VAR(rareNonInheritedData.access()->m_multiCol, m_width, 0); }
1070    void setColumnCount(unsigned short c) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_autoCount, false); SET_VAR(rareNonInheritedData.access()->m_multiCol, m_count, c); }
1071    void setHasAutoColumnCount() { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_autoCount, true); SET_VAR(rareNonInheritedData.access()->m_multiCol, m_count, 0); }
1072    void setColumnGap(float f) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_normalGap, false); SET_VAR(rareNonInheritedData.access()->m_multiCol, m_gap, f); }
1073    void setHasNormalColumnGap() { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_normalGap, true); SET_VAR(rareNonInheritedData.access()->m_multiCol, m_gap, 0); }
1074    void setColumnRuleColor(const Color& c) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_rule.m_color, c); }
1075    void setColumnRuleStyle(EBorderStyle b) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_rule.m_style, b); }
1076    void setColumnRuleWidth(unsigned short w) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_rule.m_width, w); }
1077    void resetColumnRule() { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_rule, BorderValue()) }
1078    void setColumnSpan(bool b) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_columnSpan, b); }
1079    void setColumnBreakBefore(EPageBreak p) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_breakBefore, p); }
1080    void setColumnBreakInside(EPageBreak p) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_breakInside, p); }
1081    void setColumnBreakAfter(EPageBreak p) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_breakAfter, p); }
1082    void inheritColumnPropertiesFrom(RenderStyle* parent) { rareNonInheritedData.access()->m_multiCol = parent->rareNonInheritedData->m_multiCol; }
1083    void setTransform(const TransformOperations& ops) { SET_VAR(rareNonInheritedData.access()->m_transform, m_operations, ops); }
1084    void setTransformOriginX(Length l) { SET_VAR(rareNonInheritedData.access()->m_transform, m_x, l); }
1085    void setTransformOriginY(Length l) { SET_VAR(rareNonInheritedData.access()->m_transform, m_y, l); }
1086    void setTransformOriginZ(float f) { SET_VAR(rareNonInheritedData.access()->m_transform, m_z, f); }
1087    void setSpeak(ESpeak s) { SET_VAR(rareInheritedData, speak, s); }
1088    void setTextCombine(TextCombine v) { SET_VAR(rareNonInheritedData, m_textCombine, v); }
1089    void setTextEmphasisColor(const Color& c) { SET_VAR(rareInheritedData, textEmphasisColor, c) }
1090    void setTextEmphasisFill(TextEmphasisFill fill) { SET_VAR(rareInheritedData, textEmphasisFill, fill); }
1091    void setTextEmphasisMark(TextEmphasisMark mark) { SET_VAR(rareInheritedData, textEmphasisMark, mark); }
1092    void setTextEmphasisCustomMark(const AtomicString& mark) { SET_VAR(rareInheritedData, textEmphasisCustomMark, mark); }
1093    void setTextEmphasisPosition(TextEmphasisPosition position) { SET_VAR(rareInheritedData, textEmphasisPosition, position); }
1094    // End CSS3 Setters
1095
1096    // Apple-specific property setters
1097    void setPointerEvents(EPointerEvents p) { inherited_flags._pointerEvents = p; }
1098
1099    void clearAnimations()
1100    {
1101        rareNonInheritedData.access()->m_animations.clear();
1102    }
1103
1104    void clearTransitions()
1105    {
1106        rareNonInheritedData.access()->m_transitions.clear();
1107    }
1108
1109    void inheritAnimations(const AnimationList* parent) { rareNonInheritedData.access()->m_animations = parent ? adoptPtr(new AnimationList(*parent)) : PassOwnPtr<AnimationList>(); }
1110    void inheritTransitions(const AnimationList* parent) { rareNonInheritedData.access()->m_transitions = parent ? adoptPtr(new AnimationList(*parent)) : PassOwnPtr<AnimationList>(); }
1111    void adjustAnimations();
1112    void adjustTransitions();
1113
1114    void setTransformStyle3D(ETransformStyle3D b) { SET_VAR(rareNonInheritedData, m_transformStyle3D, b); }
1115    void setBackfaceVisibility(EBackfaceVisibility b) { SET_VAR(rareNonInheritedData, m_backfaceVisibility, b); }
1116    void setPerspective(float p) { SET_VAR(rareNonInheritedData, m_perspective, p); }
1117    void setPerspectiveOriginX(Length l) { SET_VAR(rareNonInheritedData, m_perspectiveOriginX, l); }
1118    void setPerspectiveOriginY(Length l) { SET_VAR(rareNonInheritedData, m_perspectiveOriginY, l); }
1119    void setPageSize(LengthSize s) { SET_VAR(rareNonInheritedData, m_pageSize, s); }
1120    void setPageSizeType(PageSizeType t) { SET_VAR(rareNonInheritedData, m_pageSizeType, t); }
1121    void resetPageSizeType() { SET_VAR(rareNonInheritedData, m_pageSizeType, PAGE_SIZE_AUTO); }
1122
1123#if USE(ACCELERATED_COMPOSITING)
1124    void setIsRunningAcceleratedAnimation(bool b = true) { SET_VAR(rareNonInheritedData, m_runningAcceleratedAnimation, b); }
1125#endif
1126
1127    void setLineBoxContain(LineBoxContain c) { SET_VAR(rareInheritedData, m_lineBoxContain, c); }
1128    void setLineClamp(LineClampValue c) { SET_VAR(rareNonInheritedData, lineClamp, c); }
1129    void setTextSizeAdjust(bool b) { SET_VAR(rareInheritedData, textSizeAdjust, b); }
1130    void setTextSecurity(ETextSecurity aTextSecurity) { SET_VAR(rareInheritedData, textSecurity, aTextSecurity); }
1131
1132#ifdef ANDROID_CSS_TAP_HIGHLIGHT_COLOR
1133    void setTapHighlightColor(const Color& v) { SET_VAR(rareInheritedData, tapHighlightColor, v); }
1134#endif
1135
1136#if ENABLE(SVG)
1137    const SVGRenderStyle* svgStyle() const { return m_svgStyle.get(); }
1138    SVGRenderStyle* accessSVGStyle() { return m_svgStyle.access(); }
1139
1140    float fillOpacity() const { return svgStyle()->fillOpacity(); }
1141    void setFillOpacity(float f) { accessSVGStyle()->setFillOpacity(f); }
1142
1143    float strokeOpacity() const { return svgStyle()->strokeOpacity(); }
1144    void setStrokeOpacity(float f) { accessSVGStyle()->setStrokeOpacity(f); }
1145
1146    float floodOpacity() const { return svgStyle()->floodOpacity(); }
1147    void setFloodOpacity(float f) { accessSVGStyle()->setFloodOpacity(f); }
1148#endif
1149
1150    const ContentData* contentData() const { return rareNonInheritedData->m_content.get(); }
1151    bool contentDataEquivalent(const RenderStyle* otherStyle) const { return const_cast<RenderStyle*>(this)->rareNonInheritedData->contentDataEquivalent(*const_cast<RenderStyle*>(otherStyle)->rareNonInheritedData); }
1152    void clearContent();
1153    void setContent(PassRefPtr<StringImpl>, bool add = false);
1154    void setContent(PassRefPtr<StyleImage>, bool add = false);
1155    void setContent(PassOwnPtr<CounterContent>, bool add = false);
1156    void setContent(QuoteType, bool add = false);
1157
1158    const CounterDirectiveMap* counterDirectives() const;
1159    CounterDirectiveMap& accessCounterDirectives();
1160
1161    QuotesData* quotes() const { return rareInheritedData->quotes.get(); }
1162    void setQuotes(PassRefPtr<QuotesData>);
1163
1164    const AtomicString& hyphenString() const;
1165
1166    bool inheritedNotEqual(const RenderStyle*) const;
1167
1168    StyleDifference diff(const RenderStyle*, unsigned& changedContextSensitiveProperties) const;
1169
1170    bool isDisplayReplacedType() const
1171    {
1172        return display() == INLINE_BLOCK || display() == INLINE_BOX || display() == INLINE_TABLE;
1173    }
1174
1175    bool isDisplayInlineType() const
1176    {
1177        return display() == INLINE || isDisplayReplacedType();
1178    }
1179
1180    bool isOriginalDisplayInlineType() const
1181    {
1182        return originalDisplay() == INLINE || originalDisplay() == INLINE_BLOCK
1183            || originalDisplay() == INLINE_BOX || originalDisplay() == INLINE_TABLE;
1184    }
1185
1186    void setWritingMode(WritingMode v) { inherited_flags.m_writingMode = v; }
1187
1188    // To tell if this style matched attribute selectors. This makes it impossible to share.
1189    bool affectedByAttributeSelectors() const { return m_affectedByAttributeSelectors; }
1190    void setAffectedByAttributeSelectors() { m_affectedByAttributeSelectors = true; }
1191
1192    bool unique() const { return m_unique; }
1193    void setUnique() { m_unique = true; }
1194
1195    // Methods for indicating the style is affected by dynamic updates (e.g., children changing, our position changing in our sibling list, etc.)
1196    bool affectedByEmpty() const { return m_affectedByEmpty; }
1197    bool emptyState() const { return m_emptyState; }
1198    void setEmptyState(bool b) { m_affectedByEmpty = true; m_unique = true; m_emptyState = b; }
1199    bool childrenAffectedByPositionalRules() const { return childrenAffectedByForwardPositionalRules() || childrenAffectedByBackwardPositionalRules(); }
1200    bool childrenAffectedByFirstChildRules() const { return m_childrenAffectedByFirstChildRules; }
1201    void setChildrenAffectedByFirstChildRules() { m_childrenAffectedByFirstChildRules = true; }
1202    bool childrenAffectedByLastChildRules() const { return m_childrenAffectedByLastChildRules; }
1203    void setChildrenAffectedByLastChildRules() { m_childrenAffectedByLastChildRules = true; }
1204    bool childrenAffectedByDirectAdjacentRules() const { return m_childrenAffectedByDirectAdjacentRules; }
1205    void setChildrenAffectedByDirectAdjacentRules() { m_childrenAffectedByDirectAdjacentRules = true; }
1206    bool childrenAffectedByForwardPositionalRules() const { return m_childrenAffectedByForwardPositionalRules; }
1207    void setChildrenAffectedByForwardPositionalRules() { m_childrenAffectedByForwardPositionalRules = true; }
1208    bool childrenAffectedByBackwardPositionalRules() const { return m_childrenAffectedByBackwardPositionalRules; }
1209    void setChildrenAffectedByBackwardPositionalRules() { m_childrenAffectedByBackwardPositionalRules = true; }
1210    bool firstChildState() const { return m_firstChildState; }
1211    void setFirstChildState() { m_unique = true; m_firstChildState = true; }
1212    bool lastChildState() const { return m_lastChildState; }
1213    void setLastChildState() { m_unique = true; m_lastChildState = true; }
1214    unsigned childIndex() const { return m_childIndex; }
1215    void setChildIndex(unsigned index) { m_unique = true; m_childIndex = index; }
1216
1217    const Color visitedDependentColor(int colorProperty) const;
1218
1219    // Initial values for all the properties
1220    static bool initialBorderCollapse() { return false; }
1221    static EBorderStyle initialBorderStyle() { return BNONE; }
1222    static NinePieceImage initialNinePieceImage() { return NinePieceImage(); }
1223    static LengthSize initialBorderRadius() { return LengthSize(Length(0, Fixed), Length(0, Fixed)); }
1224    static ECaptionSide initialCaptionSide() { return CAPTOP; }
1225    static EClear initialClear() { return CNONE; }
1226    static TextDirection initialDirection() { return LTR; }
1227    static WritingMode initialWritingMode() { return TopToBottomWritingMode; }
1228    static TextCombine initialTextCombine() { return TextCombineNone; }
1229    static TextOrientation initialTextOrientation() { return TextOrientationVerticalRight; }
1230    static EDisplay initialDisplay() { return INLINE; }
1231    static EEmptyCell initialEmptyCells() { return SHOW; }
1232    static EFloat initialFloating() { return FNONE; }
1233    static EListStylePosition initialListStylePosition() { return OUTSIDE; }
1234    static EListStyleType initialListStyleType() { return Disc; }
1235    static EOverflow initialOverflowX() { return OVISIBLE; }
1236    static EOverflow initialOverflowY() { return OVISIBLE; }
1237    static EPageBreak initialPageBreak() { return PBAUTO; }
1238    static EPosition initialPosition() { return StaticPosition; }
1239    static ETableLayout initialTableLayout() { return TAUTO; }
1240    static EUnicodeBidi initialUnicodeBidi() { return UBNormal; }
1241    static ETextTransform initialTextTransform() { return TTNONE; }
1242    static EVisibility initialVisibility() { return VISIBLE; }
1243    static EWhiteSpace initialWhiteSpace() { return NORMAL; }
1244    static short initialHorizontalBorderSpacing() { return 0; }
1245    static short initialVerticalBorderSpacing() { return 0; }
1246    static ECursor initialCursor() { return CURSOR_AUTO; }
1247    static Color initialColor() { return Color::black; }
1248    static StyleImage* initialListStyleImage() { return 0; }
1249    static unsigned short initialBorderWidth() { return 3; }
1250    static int initialLetterWordSpacing() { return 0; }
1251    static Length initialSize() { return Length(); }
1252    static Length initialMinSize() { return Length(0, Fixed); }
1253    static Length initialMaxSize() { return Length(undefinedLength, Fixed); }
1254    static Length initialOffset() { return Length(); }
1255    static Length initialMargin() { return Length(Fixed); }
1256    static Length initialPadding() { return Length(Fixed); }
1257    static Length initialTextIndent() { return Length(Fixed); }
1258    static EVerticalAlign initialVerticalAlign() { return BASELINE; }
1259    static int initialWidows() { return 2; }
1260    static int initialOrphans() { return 2; }
1261    static Length initialLineHeight() { return Length(-100.0, Percent); }
1262    static ETextAlign initialTextAlign() { return TAAUTO; }
1263    static ETextDecoration initialTextDecoration() { return TDNONE; }
1264    static float initialZoom() { return 1.0f; }
1265    static int initialOutlineOffset() { return 0; }
1266    static float initialOpacity() { return 1.0f; }
1267    static EBoxAlignment initialBoxAlign() { return BSTRETCH; }
1268    static EBoxDirection initialBoxDirection() { return BNORMAL; }
1269    static EBoxLines initialBoxLines() { return SINGLE; }
1270    static EBoxOrient initialBoxOrient() { return HORIZONTAL; }
1271    static EBoxAlignment initialBoxPack() { return BSTART; }
1272    static float initialBoxFlex() { return 0.0f; }
1273    static int initialBoxFlexGroup() { return 1; }
1274    static int initialBoxOrdinalGroup() { return 1; }
1275    static EBoxSizing initialBoxSizing() { return CONTENT_BOX; }
1276    static StyleReflection* initialBoxReflect() { return 0; }
1277    static int initialMarqueeLoopCount() { return -1; }
1278    static int initialMarqueeSpeed() { return 85; }
1279    static Length initialMarqueeIncrement() { return Length(6, Fixed); }
1280    static EMarqueeBehavior initialMarqueeBehavior() { return MSCROLL; }
1281    static EMarqueeDirection initialMarqueeDirection() { return MAUTO; }
1282    static EUserModify initialUserModify() { return READ_ONLY; }
1283    static EUserDrag initialUserDrag() { return DRAG_AUTO; }
1284    static EUserSelect initialUserSelect() { return SELECT_TEXT; }
1285    static bool initialTextOverflow() { return false; }
1286    static EMarginCollapse initialMarginBeforeCollapse() { return MCOLLAPSE; }
1287    static EMarginCollapse initialMarginAfterCollapse() { return MCOLLAPSE; }
1288    static EWordBreak initialWordBreak() { return NormalWordBreak; }
1289    static EWordWrap initialWordWrap() { return NormalWordWrap; }
1290    static ENBSPMode initialNBSPMode() { return NBNORMAL; }
1291    static EKHTMLLineBreak initialKHTMLLineBreak() { return LBNORMAL; }
1292    static EMatchNearestMailBlockquoteColor initialMatchNearestMailBlockquoteColor() { return BCNORMAL; }
1293    static const AtomicString& initialHighlight() { return nullAtom; }
1294    static ESpeak initialSpeak() { return SpeakNormal; }
1295    static Hyphens initialHyphens() { return HyphensManual; }
1296    static short initialHyphenationLimitBefore() { return -1; }
1297    static short initialHyphenationLimitAfter() { return -1; }
1298    static const AtomicString& initialHyphenationString() { return nullAtom; }
1299    static const AtomicString& initialLocale() { return nullAtom; }
1300    static EBorderFit initialBorderFit() { return BorderFitBorder; }
1301    static EResize initialResize() { return RESIZE_NONE; }
1302    static ControlPart initialAppearance() { return NoControlPart; }
1303    static bool initialVisuallyOrdered() { return false; }
1304    static float initialTextStrokeWidth() { return 0; }
1305    static unsigned short initialColumnCount() { return 1; }
1306    static bool initialColumnSpan() { return false; }
1307    static const TransformOperations& initialTransform() { DEFINE_STATIC_LOCAL(TransformOperations, ops, ()); return ops; }
1308    static Length initialTransformOriginX() { return Length(50.0, Percent); }
1309    static Length initialTransformOriginY() { return Length(50.0, Percent); }
1310    static EPointerEvents initialPointerEvents() { return PE_AUTO; }
1311    static float initialTransformOriginZ() { return 0; }
1312    static ETransformStyle3D initialTransformStyle3D() { return TransformStyle3DFlat; }
1313    static EBackfaceVisibility initialBackfaceVisibility() { return BackfaceVisibilityVisible; }
1314    static float initialPerspective() { return 0; }
1315    static Length initialPerspectiveOriginX() { return Length(50.0, Percent); }
1316    static Length initialPerspectiveOriginY() { return Length(50.0, Percent); }
1317    static Color initialBackgroundColor() { return Color::transparent; }
1318    static Color initialTextEmphasisColor() { return TextEmphasisFillFilled; }
1319    static TextEmphasisFill initialTextEmphasisFill() { return TextEmphasisFillFilled; }
1320    static TextEmphasisMark initialTextEmphasisMark() { return TextEmphasisMarkNone; }
1321    static const AtomicString& initialTextEmphasisCustomMark() { return nullAtom; }
1322    static TextEmphasisPosition initialTextEmphasisPosition() { return TextEmphasisPositionOver; }
1323    static LineBoxContain initialLineBoxContain() { return LineBoxContainBlock | LineBoxContainInline | LineBoxContainReplaced; }
1324
1325    // Keep these at the end.
1326    static LineClampValue initialLineClamp() { return LineClampValue(); }
1327    static bool initialTextSizeAdjust() { return true; }
1328    static ETextSecurity initialTextSecurity() { return TSNONE; }
1329#if ENABLE(DASHBOARD_SUPPORT)
1330    static const Vector<StyleDashboardRegion>& initialDashboardRegions();
1331    static const Vector<StyleDashboardRegion>& noneDashboardRegions();
1332#endif
1333
1334#ifdef ANDROID_CSS_TAP_HIGHLIGHT_COLOR
1335    static Color initialTapHighlightColor() { return Color::tap; }
1336#endif
1337
1338private:
1339    void inheritUnicodeBidiFrom(const RenderStyle* parent) { noninherited_flags._unicodeBidi = parent->noninherited_flags._unicodeBidi; }
1340    void getShadowExtent(const ShadowData*, int& top, int& right, int& bottom, int& left) const;
1341    void getShadowHorizontalExtent(const ShadowData*, int& left, int& right) const;
1342    void getShadowVerticalExtent(const ShadowData*, int& top, int& bottom) const;
1343    void getShadowInlineDirectionExtent(const ShadowData* shadow, int& logicalLeft, int& logicalRight) const
1344    {
1345        return isHorizontalWritingMode() ? getShadowHorizontalExtent(shadow, logicalLeft, logicalRight) : getShadowVerticalExtent(shadow, logicalLeft, logicalRight);
1346    }
1347    void getShadowBlockDirectionExtent(const ShadowData* shadow, int& logicalTop, int& logicalBottom) const
1348    {
1349        return isHorizontalWritingMode() ? getShadowVerticalExtent(shadow, logicalTop, logicalBottom) : getShadowHorizontalExtent(shadow, logicalTop, logicalBottom);
1350    }
1351
1352    // Color accessors are all private to make sure callers use visitedDependentColor instead to access them.
1353    const Color& borderLeftColor() const { return surround->border.left().color(); }
1354    const Color& borderRightColor() const { return surround->border.right().color(); }
1355    const Color& borderTopColor() const { return surround->border.top().color(); }
1356    const Color& borderBottomColor() const { return surround->border.bottom().color(); }
1357    const Color& backgroundColor() const { return m_background->color(); }
1358    const Color& color() const { return inherited->color; }
1359    const Color& columnRuleColor() const { return rareNonInheritedData->m_multiCol->m_rule.color(); }
1360    const Color& outlineColor() const { return m_background->outline().color(); }
1361    const Color& textEmphasisColor() const { return rareInheritedData->textEmphasisColor; }
1362    const Color& textFillColor() const { return rareInheritedData->textFillColor; }
1363    const Color& textStrokeColor() const { return rareInheritedData->textStrokeColor; }
1364
1365    const Color colorIncludingFallback(int colorProperty, EBorderStyle borderStyle) const;
1366
1367    ContentData* prepareToSetContent(StringImpl*, bool add);
1368};
1369
1370inline int adjustForAbsoluteZoom(int value, const RenderStyle* style)
1371{
1372    double zoomFactor = style->effectiveZoom();
1373    if (zoomFactor == 1)
1374        return value;
1375    // Needed because computeLengthInt truncates (rather than rounds) when scaling up.
1376    if (zoomFactor > 1) {
1377        if (value < 0)
1378            value--;
1379        else
1380            value++;
1381    }
1382
1383    return roundForImpreciseConversion<int, INT_MAX, INT_MIN>(value / zoomFactor);
1384}
1385
1386inline float adjustFloatForAbsoluteZoom(float value, const RenderStyle* style)
1387{
1388    return value / style->effectiveZoom();
1389}
1390
1391} // namespace WebCore
1392
1393#endif // RenderStyle_h
1394