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 Apple Inc. All rights reserved.
6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
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.
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.
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.
28 #include "TransformationMatrix.h"
29 #include "AnimationList.h"
30 #include "BorderData.h"
31 #include "BorderValue.h"
32 #include "CSSHelper.h"
33 #include "CSSImageGeneratorValue.h"
34 #include "CSSPrimitiveValue.h"
35 #include "CSSReflectionDirection.h"
36 #include "CSSValueList.h"
37 #include "CachedImage.h"
38 #include "CollapsedBorderValue.h"
40 #include "ColorSpace.h"
41 #include "ContentData.h"
42 #include "CounterDirectives.h"
43 #include "CursorList.h"
45 #include "FillLayer.h"
46 #include "FloatPoint.h"
48 #include "GraphicsTypes.h"
51 #include "LengthBox.h"
52 #include "LengthSize.h"
53 #include "LineClampValue.h"
54 #include "NinePieceImage.h"
55 #include "OutlineValue.h"
57 #include "RenderStyleConstants.h"
58 #include "ShadowData.h"
59 #include "StyleBackgroundData.h"
60 #include "StyleBoxData.h"
61 #include "StyleFlexibleBoxData.h"
62 #include "StyleInheritedData.h"
63 #include "StyleMarqueeData.h"
64 #include "StyleMultiColData.h"
65 #include "StyleRareInheritedData.h"
66 #include "StyleRareNonInheritedData.h"
67 #include "StyleReflection.h"
68 #include "StyleSurroundData.h"
69 #include "StyleTransformData.h"
70 #include "StyleVisualData.h"
71 #include "TextDirection.h"
72 #include "ThemeTypes.h"
73 #include "TimingFunction.h"
74 #include "TransformOperations.h"
75 #include <wtf/OwnPtr.h>
76 #include <wtf/RefCounted.h>
77 #include <wtf/StdLibExtras.h>
78 #include <wtf/Vector.h>
80 #if ENABLE(DASHBOARD_SUPPORT)
81 #include "StyleDashboardRegion.h"
85 #include "SVGRenderStyle.h"
89 #include "BindingURI.h"
93 #define compareEqual(t, u) ((t) == (u))
95 template<typename T, typename U> inline bool compareEqual(const T& t, const U& u) { return t == static_cast<T>(u); }
98 #define SET_VAR(group, variable, value) \
99 if (!compareEqual(group->variable, value)) \
100 group.access()->variable = value;
106 class CSSStyleSelector;
113 class RenderStyle: public RefCounted<RenderStyle> {
114 friend class CSSStyleSelector;
117 // The following bitfield is 32-bits long, which optimizes padding with the
118 // int refCount in the base class. Beware when adding more bits.
119 unsigned m_pseudoState : 3; // PseudoState
120 bool m_affectedByAttributeSelectors : 1;
123 // Bits for dynamic child matching.
124 bool m_affectedByEmpty : 1;
125 bool m_emptyState : 1;
127 // We optimize for :first-child and :last-child. The other positional child selectors like nth-child or
128 // *-child-of-type, we will just give up and re-evaluate whenever children change at all.
129 bool m_childrenAffectedByFirstChildRules : 1;
130 bool m_childrenAffectedByLastChildRules : 1;
131 bool m_childrenAffectedByDirectAdjacentRules : 1;
132 bool m_childrenAffectedByForwardPositionalRules : 1;
133 bool m_childrenAffectedByBackwardPositionalRules : 1;
134 bool m_firstChildState : 1;
135 bool m_lastChildState : 1;
136 unsigned m_childIndex : 18; // Plenty of bits to cache an index.
138 // non-inherited attributes
139 DataRef<StyleBoxData> box;
140 DataRef<StyleVisualData> visual;
141 DataRef<StyleBackgroundData> background;
142 DataRef<StyleSurroundData> surround;
143 DataRef<StyleRareNonInheritedData> rareNonInheritedData;
145 // inherited attributes
146 DataRef<StyleRareInheritedData> rareInheritedData;
147 DataRef<StyleInheritedData> inherited;
149 // list of associated pseudo styles
150 RefPtr<RenderStyle> m_cachedPseudoStyle;
153 DataRef<SVGRenderStyle> m_svgStyle;
156 // !START SYNC!: Keep this in sync with the copy constructor in RenderStyle.cpp
159 struct InheritedFlags {
160 bool operator==(const InheritedFlags& other) const
162 return (_empty_cells == other._empty_cells) &&
163 (_caption_side == other._caption_side) &&
164 (_list_style_type == other._list_style_type) &&
165 (_list_style_position == other._list_style_position) &&
166 (_visibility == other._visibility) &&
167 (_text_align == other._text_align) &&
168 (_text_transform == other._text_transform) &&
169 (_text_decorations == other._text_decorations) &&
170 (_text_transform == other._text_transform) &&
171 (_cursor_style == other._cursor_style) &&
172 (_direction == other._direction) &&
173 (_border_collapse == other._border_collapse) &&
174 (_white_space == other._white_space) &&
175 (_box_direction == other._box_direction) &&
176 (_visuallyOrdered == other._visuallyOrdered) &&
177 (_htmlHacks == other._htmlHacks) &&
178 (_force_backgrounds_to_white == other._force_backgrounds_to_white) &&
179 (_pointerEvents == other._pointerEvents);
182 bool operator!=(const InheritedFlags& other) const { return !(*this == other); }
184 unsigned _empty_cells : 1; // EEmptyCell
185 unsigned _caption_side : 2; // ECaptionSide
186 unsigned _list_style_type : 7; // EListStyleType
187 unsigned _list_style_position : 1; // EListStylePosition
188 unsigned _visibility : 2; // EVisibility
189 unsigned _text_align : 3; // ETextAlign
190 unsigned _text_transform : 2; // ETextTransform
191 unsigned _text_decorations : 4;
192 unsigned _cursor_style : 6; // ECursor
193 unsigned _direction : 1; // TextDirection
194 bool _border_collapse : 1 ;
195 unsigned _white_space : 3; // EWhiteSpace
196 unsigned _box_direction : 1; // EBoxDirection (CSS3 box_direction property, flexible box layout module)
199 // non CSS2 inherited
200 bool _visuallyOrdered : 1;
202 bool _force_backgrounds_to_white : 1;
203 unsigned _pointerEvents : 4; // EPointerEvents
208 struct NonInheritedFlags {
209 bool operator==(const NonInheritedFlags& other) const
211 return _effectiveDisplay == other._effectiveDisplay
212 && _originalDisplay == other._originalDisplay
213 && _overflowX == other._overflowX
214 && _overflowY == other._overflowY
215 && _vertical_align == other._vertical_align
216 && _clear == other._clear
217 && _position == other._position
218 && _floating == other._floating
219 && _table_layout == other._table_layout
220 && _page_break_before == other._page_break_before
221 && _page_break_after == other._page_break_after
222 && _page_break_inside == other._page_break_inside
223 && _styleType == other._styleType
224 && _affectedByHover == other._affectedByHover
225 && _affectedByActive == other._affectedByActive
226 && _affectedByDrag == other._affectedByDrag
227 && _pseudoBits == other._pseudoBits
228 && _unicodeBidi == other._unicodeBidi;
231 bool operator!=(const NonInheritedFlags& other) const { return !(*this == other); }
233 unsigned _effectiveDisplay : 5; // EDisplay
234 unsigned _originalDisplay : 5; // EDisplay
235 unsigned _overflowX : 3; // EOverflow
236 unsigned _overflowY : 3; // EOverflow
237 unsigned _vertical_align : 4; // EVerticalAlign
238 unsigned _clear : 2; // EClear
239 unsigned _position : 2; // EPosition
240 unsigned _floating : 2; // EFloat
241 unsigned _table_layout : 1; // ETableLayout
243 unsigned _page_break_before : 2; // EPageBreak
244 unsigned _page_break_after : 2; // EPageBreak
245 unsigned _page_break_inside : 2; // EPageBreak
247 unsigned _styleType : 5; // PseudoId
248 bool _affectedByHover : 1;
249 bool _affectedByActive : 1;
250 bool _affectedByDrag : 1;
251 unsigned _pseudoBits : 7;
252 unsigned _unicodeBidi : 2; // EUnicodeBidi
254 } noninherited_flags;
259 void setBitDefaults()
261 inherited_flags._empty_cells = initialEmptyCells();
262 inherited_flags._caption_side = initialCaptionSide();
263 inherited_flags._list_style_type = initialListStyleType();
264 inherited_flags._list_style_position = initialListStylePosition();
265 inherited_flags._visibility = initialVisibility();
266 inherited_flags._text_align = initialTextAlign();
267 inherited_flags._text_transform = initialTextTransform();
268 inherited_flags._text_decorations = initialTextDecoration();
269 inherited_flags._cursor_style = initialCursor();
270 inherited_flags._direction = initialDirection();
271 inherited_flags._border_collapse = initialBorderCollapse();
272 inherited_flags._white_space = initialWhiteSpace();
273 inherited_flags._visuallyOrdered = initialVisuallyOrdered();
274 inherited_flags._htmlHacks=false;
275 inherited_flags._box_direction = initialBoxDirection();
276 inherited_flags._force_backgrounds_to_white = false;
277 inherited_flags._pointerEvents = initialPointerEvents();
279 noninherited_flags._effectiveDisplay = noninherited_flags._originalDisplay = initialDisplay();
280 noninherited_flags._overflowX = initialOverflowX();
281 noninherited_flags._overflowY = initialOverflowY();
282 noninherited_flags._vertical_align = initialVerticalAlign();
283 noninherited_flags._clear = initialClear();
284 noninherited_flags._position = initialPosition();
285 noninherited_flags._floating = initialFloating();
286 noninherited_flags._table_layout = initialTableLayout();
287 noninherited_flags._page_break_before = initialPageBreak();
288 noninherited_flags._page_break_after = initialPageBreak();
289 noninherited_flags._page_break_inside = initialPageBreak();
290 noninherited_flags._styleType = NOPSEUDO;
291 noninherited_flags._affectedByHover = false;
292 noninherited_flags._affectedByActive = false;
293 noninherited_flags._affectedByDrag = false;
294 noninherited_flags._pseudoBits = 0;
295 noninherited_flags._unicodeBidi = initialUnicodeBidi();
300 // used to create the default style.
302 RenderStyle(const RenderStyle&);
305 static PassRefPtr<RenderStyle> create();
306 static PassRefPtr<RenderStyle> createDefaultStyle();
307 static PassRefPtr<RenderStyle> clone(const RenderStyle*);
311 void inheritFrom(const RenderStyle* inheritParent);
313 PseudoId styleType() const { return static_cast<PseudoId>(noninherited_flags._styleType); }
314 void setStyleType(PseudoId styleType) { noninherited_flags._styleType = styleType; }
316 RenderStyle* getCachedPseudoStyle(PseudoId) const;
317 RenderStyle* addCachedPseudoStyle(PassRefPtr<RenderStyle>);
319 typedef Vector<RenderStyle*, 10> PseudoStyleCache;
320 void getPseudoStyleCache(PseudoStyleCache&) const;
322 bool affectedByHoverRules() const { return noninherited_flags._affectedByHover; }
323 bool affectedByActiveRules() const { return noninherited_flags._affectedByActive; }
324 bool affectedByDragRules() const { return noninherited_flags._affectedByDrag; }
326 void setAffectedByHoverRules(bool b) { noninherited_flags._affectedByHover = b; }
327 void setAffectedByActiveRules(bool b) { noninherited_flags._affectedByActive = b; }
328 void setAffectedByDragRules(bool b) { noninherited_flags._affectedByDrag = b; }
330 bool operator==(const RenderStyle& other) const;
331 bool operator!=(const RenderStyle& other) const { return !(*this == other); }
332 bool isFloating() const { return !(noninherited_flags._floating == FNONE); }
333 bool hasMargin() const { return surround->margin.nonZero(); }
334 bool hasBorder() const { return surround->border.hasBorder(); }
335 bool hasPadding() const { return surround->padding.nonZero(); }
336 bool hasOffset() const { return surround->offset.nonZero(); }
338 bool hasBackground() const
340 if (backgroundColor().isValid() && backgroundColor().alpha() > 0)
342 return background->m_background.hasImage();
344 bool hasBackgroundImage() const { return background->m_background.hasImage(); }
345 bool hasFixedBackgroundImage() const { return background->m_background.hasFixedImage(); }
346 bool hasAppearance() const { return appearance() != NoControlPart; }
348 bool visuallyOrdered() const { return inherited_flags._visuallyOrdered; }
349 void setVisuallyOrdered(bool b) { inherited_flags._visuallyOrdered = b; }
351 bool isStyleAvailable() const;
353 bool hasPseudoStyle(PseudoId pseudo) const;
354 void setHasPseudoStyle(PseudoId pseudo);
356 // attribute getter methods
358 EDisplay display() const { return static_cast<EDisplay>(noninherited_flags._effectiveDisplay); }
359 EDisplay originalDisplay() const { return static_cast<EDisplay>(noninherited_flags._originalDisplay); }
361 Length left() const { return surround->offset.left(); }
362 Length right() const { return surround->offset.right(); }
363 Length top() const { return surround->offset.top(); }
364 Length bottom() const { return surround->offset.bottom(); }
366 // Whether or not a positioned element requires normal flow x/y to be computed
367 // to determine its position.
368 bool hasStaticX() const { return (left().isAuto() && right().isAuto()) || left().isStatic() || right().isStatic(); }
369 bool hasStaticY() const { return (top().isAuto() && bottom().isAuto()) || top().isStatic(); }
371 EPosition position() const { return static_cast<EPosition>(noninherited_flags._position); }
372 EFloat floating() const { return static_cast<EFloat>(noninherited_flags._floating); }
374 Length width() const { return box->width; }
375 Length height() const { return box->height; }
376 Length minWidth() const { return box->min_width; }
377 Length maxWidth() const { return box->max_width; }
378 Length minHeight() const { return box->min_height; }
379 Length maxHeight() const { return box->max_height; }
381 const BorderData& border() const { return surround->border; }
382 const BorderValue& borderLeft() const { return surround->border.left; }
383 const BorderValue& borderRight() const { return surround->border.right; }
384 const BorderValue& borderTop() const { return surround->border.top; }
385 const BorderValue& borderBottom() const { return surround->border.bottom; }
387 const NinePieceImage& borderImage() const { return surround->border.image; }
389 const IntSize& borderTopLeftRadius() const { return surround->border.topLeft; }
390 const IntSize& borderTopRightRadius() const { return surround->border.topRight; }
391 const IntSize& borderBottomLeftRadius() const { return surround->border.bottomLeft; }
392 const IntSize& borderBottomRightRadius() const { return surround->border.bottomRight; }
393 bool hasBorderRadius() const { return surround->border.hasBorderRadius(); }
395 unsigned short borderLeftWidth() const { return surround->border.borderLeftWidth(); }
396 EBorderStyle borderLeftStyle() const { return surround->border.left.style(); }
397 const Color& borderLeftColor() const { return surround->border.left.color; }
398 bool borderLeftIsTransparent() const { return surround->border.left.isTransparent(); }
399 unsigned short borderRightWidth() const { return surround->border.borderRightWidth(); }
400 EBorderStyle borderRightStyle() const { return surround->border.right.style(); }
401 const Color& borderRightColor() const { return surround->border.right.color; }
402 bool borderRightIsTransparent() const { return surround->border.right.isTransparent(); }
403 unsigned short borderTopWidth() const { return surround->border.borderTopWidth(); }
404 EBorderStyle borderTopStyle() const { return surround->border.top.style(); }
405 const Color& borderTopColor() const { return surround->border.top.color; }
406 bool borderTopIsTransparent() const { return surround->border.top.isTransparent(); }
407 unsigned short borderBottomWidth() const { return surround->border.borderBottomWidth(); }
408 EBorderStyle borderBottomStyle() const { return surround->border.bottom.style(); }
409 const Color& borderBottomColor() const { return surround->border.bottom.color; }
410 bool borderBottomIsTransparent() const { return surround->border.bottom.isTransparent(); }
412 unsigned short outlineSize() const { return max(0, outlineWidth() + outlineOffset()); }
413 unsigned short outlineWidth() const
415 if (background->m_outline.style() == BNONE)
417 return background->m_outline.width;
419 bool hasOutline() const { return outlineWidth() > 0 && outlineStyle() > BHIDDEN; }
420 EBorderStyle outlineStyle() const { return background->m_outline.style(); }
421 bool outlineStyleIsAuto() const { return background->m_outline._auto; }
422 const Color& outlineColor() const { return background->m_outline.color; }
424 EOverflow overflowX() const { return static_cast<EOverflow>(noninherited_flags._overflowX); }
425 EOverflow overflowY() const { return static_cast<EOverflow>(noninherited_flags._overflowY); }
427 EVisibility visibility() const { return static_cast<EVisibility>(inherited_flags._visibility); }
428 EVerticalAlign verticalAlign() const { return static_cast<EVerticalAlign>(noninherited_flags._vertical_align); }
429 Length verticalAlignLength() const { return box->vertical_align; }
431 Length clipLeft() const { return visual->clip.left(); }
432 Length clipRight() const { return visual->clip.right(); }
433 Length clipTop() const { return visual->clip.top(); }
434 Length clipBottom() const { return visual->clip.bottom(); }
435 LengthBox clip() const { return visual->clip; }
436 bool hasClip() const { return visual->hasClip; }
438 EUnicodeBidi unicodeBidi() const { return static_cast<EUnicodeBidi>(noninherited_flags._unicodeBidi); }
440 EClear clear() const { return static_cast<EClear>(noninherited_flags._clear); }
441 ETableLayout tableLayout() const { return static_cast<ETableLayout>(noninherited_flags._table_layout); }
443 const Font& font() const { return inherited->font; }
444 const FontDescription& fontDescription() const { return inherited->font.fontDescription(); }
445 int fontSize() const { return inherited->font.pixelSize(); }
447 const Color& color() const { return inherited->color; }
448 Length textIndent() const { return inherited->indent; }
449 ETextAlign textAlign() const { return static_cast<ETextAlign>(inherited_flags._text_align); }
450 ETextTransform textTransform() const { return static_cast<ETextTransform>(inherited_flags._text_transform); }
451 int textDecorationsInEffect() const { return inherited_flags._text_decorations; }
452 int textDecoration() const { return visual->textDecoration; }
453 int wordSpacing() const { return inherited->font.wordSpacing(); }
454 int letterSpacing() const { return inherited->font.letterSpacing(); }
456 float zoom() const { return visual->m_zoom; }
457 float effectiveZoom() const { return inherited->m_effectiveZoom; }
459 TextDirection direction() const { return static_cast<TextDirection>(inherited_flags._direction); }
460 Length lineHeight() const { return inherited->line_height; }
461 int computedLineHeight() const
463 Length lh = lineHeight();
465 // Negative value means the line height is not set. Use the font's built-in spacing.
467 return font().lineSpacing();
470 return lh.calcMinValue(fontSize());
475 EWhiteSpace whiteSpace() const { return static_cast<EWhiteSpace>(inherited_flags._white_space); }
476 static bool autoWrap(EWhiteSpace ws)
478 // Nowrap and pre don't automatically wrap.
479 return ws != NOWRAP && ws != PRE;
482 bool autoWrap() const
484 return autoWrap(whiteSpace());
487 static bool preserveNewline(EWhiteSpace ws)
489 // Normal and nowrap do not preserve newlines.
490 return ws != NORMAL && ws != NOWRAP;
493 bool preserveNewline() const
495 return preserveNewline(whiteSpace());
498 static bool collapseWhiteSpace(EWhiteSpace ws)
500 // Pre and prewrap do not collapse whitespace.
501 return ws != PRE && ws != PRE_WRAP;
504 bool collapseWhiteSpace() const
506 return collapseWhiteSpace(whiteSpace());
509 bool isCollapsibleWhiteSpace(UChar c) const
514 return collapseWhiteSpace();
516 return !preserveNewline();
521 bool breakOnlyAfterWhiteSpace() const
523 return whiteSpace() == PRE_WRAP || khtmlLineBreak() == AFTER_WHITE_SPACE;
526 bool breakWords() const
528 return wordBreak() == BreakWordBreak || wordWrap() == BreakWordWrap;
531 const Color& backgroundColor() const { return background->m_color; }
532 StyleImage* backgroundImage() const { return background->m_background.m_image.get(); }
533 EFillRepeat backgroundRepeatX() const { return static_cast<EFillRepeat>(background->m_background.m_repeatX); }
534 EFillRepeat backgroundRepeatY() const { return static_cast<EFillRepeat>(background->m_background.m_repeatY); }
535 CompositeOperator backgroundComposite() const { return static_cast<CompositeOperator>(background->m_background.m_composite); }
536 EFillAttachment backgroundAttachment() const { return static_cast<EFillAttachment>(background->m_background.m_attachment); }
537 EFillBox backgroundClip() const { return static_cast<EFillBox>(background->m_background.m_clip); }
538 EFillBox backgroundOrigin() const { return static_cast<EFillBox>(background->m_background.m_origin); }
539 Length backgroundXPosition() const { return background->m_background.m_xPosition; }
540 Length backgroundYPosition() const { return background->m_background.m_yPosition; }
541 EFillSizeType backgroundSizeType() const { return static_cast<EFillSizeType>(background->m_background.m_sizeType); }
542 LengthSize backgroundSizeLength() const { return background->m_background.m_sizeLength; }
543 FillLayer* accessBackgroundLayers() { return &(background.access()->m_background); }
544 const FillLayer* backgroundLayers() const { return &(background->m_background); }
546 StyleImage* maskImage() const { return rareNonInheritedData->m_mask.m_image.get(); }
547 EFillRepeat maskRepeatX() const { return static_cast<EFillRepeat>(rareNonInheritedData->m_mask.m_repeatX); }
548 EFillRepeat maskRepeatY() const { return static_cast<EFillRepeat>(rareNonInheritedData->m_mask.m_repeatY); }
549 CompositeOperator maskComposite() const { return static_cast<CompositeOperator>(rareNonInheritedData->m_mask.m_composite); }
550 EFillAttachment maskAttachment() const { return static_cast<EFillAttachment>(rareNonInheritedData->m_mask.m_attachment); }
551 EFillBox maskClip() const { return static_cast<EFillBox>(rareNonInheritedData->m_mask.m_clip); }
552 EFillBox maskOrigin() const { return static_cast<EFillBox>(rareNonInheritedData->m_mask.m_origin); }
553 Length maskXPosition() const { return rareNonInheritedData->m_mask.m_xPosition; }
554 Length maskYPosition() const { return rareNonInheritedData->m_mask.m_yPosition; }
555 LengthSize maskSize() const { return rareNonInheritedData->m_mask.m_sizeLength; }
556 FillLayer* accessMaskLayers() { return &(rareNonInheritedData.access()->m_mask); }
557 const FillLayer* maskLayers() const { return &(rareNonInheritedData->m_mask); }
558 const NinePieceImage& maskBoxImage() const { return rareNonInheritedData->m_maskBoxImage; }
560 // returns true for collapsing borders, false for separate borders
561 bool borderCollapse() const { return inherited_flags._border_collapse; }
562 short horizontalBorderSpacing() const { return inherited->horizontal_border_spacing; }
563 short verticalBorderSpacing() const { return inherited->vertical_border_spacing; }
564 EEmptyCell emptyCells() const { return static_cast<EEmptyCell>(inherited_flags._empty_cells); }
565 ECaptionSide captionSide() const { return static_cast<ECaptionSide>(inherited_flags._caption_side); }
567 short counterIncrement() const { return visual->counterIncrement; }
568 short counterReset() const { return visual->counterReset; }
570 EListStyleType listStyleType() const { return static_cast<EListStyleType>(inherited_flags._list_style_type); }
571 StyleImage* listStyleImage() const { return inherited->list_style_image.get(); }
572 EListStylePosition listStylePosition() const { return static_cast<EListStylePosition>(inherited_flags._list_style_position); }
574 Length marginTop() const { return surround->margin.top(); }
575 Length marginBottom() const { return surround->margin.bottom(); }
576 Length marginLeft() const { return surround->margin.left(); }
577 Length marginRight() const { return surround->margin.right(); }
579 LengthBox paddingBox() const { return surround->padding; }
580 Length paddingTop() const { return surround->padding.top(); }
581 Length paddingBottom() const { return surround->padding.bottom(); }
582 Length paddingLeft() const { return surround->padding.left(); }
583 Length paddingRight() const { return surround->padding.right(); }
585 ECursor cursor() const { return static_cast<ECursor>(inherited_flags._cursor_style); }
587 CursorList* cursors() const { return inherited->cursorData.get(); }
589 short widows() const { return inherited->widows; }
590 short orphans() const { return inherited->orphans; }
591 EPageBreak pageBreakInside() const { return static_cast<EPageBreak>(noninherited_flags._page_break_inside); }
592 EPageBreak pageBreakBefore() const { return static_cast<EPageBreak>(noninherited_flags._page_break_before); }
593 EPageBreak pageBreakAfter() const { return static_cast<EPageBreak>(noninherited_flags._page_break_after); }
595 // CSS3 Getter Methods
597 BindingURI* bindingURIs() const { return rareNonInheritedData->bindingURI; }
600 int outlineOffset() const
602 if (background->m_outline.style() == BNONE)
604 return background->m_outline._offset;
607 ShadowData* textShadow() const { return rareInheritedData->textShadow; }
608 const Color& textStrokeColor() const { return rareInheritedData->textStrokeColor; }
609 float textStrokeWidth() const { return rareInheritedData->textStrokeWidth; }
610 const Color& textFillColor() const { return rareInheritedData->textFillColor; }
611 ColorSpace colorSpace() const { return static_cast<ColorSpace>(rareInheritedData->colorSpace); }
612 float opacity() const { return rareNonInheritedData->opacity; }
613 ControlPart appearance() const { return static_cast<ControlPart>(rareNonInheritedData->m_appearance); }
614 EBoxAlignment boxAlign() const { return static_cast<EBoxAlignment>(rareNonInheritedData->flexibleBox->align); }
615 EBoxDirection boxDirection() const { return static_cast<EBoxDirection>(inherited_flags._box_direction); }
616 float boxFlex() { return rareNonInheritedData->flexibleBox->flex; }
617 unsigned int boxFlexGroup() const { return rareNonInheritedData->flexibleBox->flex_group; }
618 EBoxLines boxLines() { return static_cast<EBoxLines>(rareNonInheritedData->flexibleBox->lines); }
619 unsigned int boxOrdinalGroup() const { return rareNonInheritedData->flexibleBox->ordinal_group; }
620 EBoxOrient boxOrient() const { return static_cast<EBoxOrient>(rareNonInheritedData->flexibleBox->orient); }
621 EBoxAlignment boxPack() const { return static_cast<EBoxAlignment>(rareNonInheritedData->flexibleBox->pack); }
623 ShadowData* boxShadow() const { return rareNonInheritedData->m_boxShadow.get(); }
624 void getBoxShadowExtent(int &top, int &right, int &bottom, int &left) const;
625 void getBoxShadowHorizontalExtent(int &left, int &right) const;
626 void getBoxShadowVerticalExtent(int &top, int &bottom) const;
628 StyleReflection* boxReflect() const { return rareNonInheritedData->m_boxReflect.get(); }
629 EBoxSizing boxSizing() const { return static_cast<EBoxSizing>(box->boxSizing); }
630 Length marqueeIncrement() const { return rareNonInheritedData->marquee->increment; }
631 int marqueeSpeed() const { return rareNonInheritedData->marquee->speed; }
632 int marqueeLoopCount() const { return rareNonInheritedData->marquee->loops; }
633 EMarqueeBehavior marqueeBehavior() const { return static_cast<EMarqueeBehavior>(rareNonInheritedData->marquee->behavior); }
634 EMarqueeDirection marqueeDirection() const { return static_cast<EMarqueeDirection>(rareNonInheritedData->marquee->direction); }
635 EUserModify userModify() const { return static_cast<EUserModify>(rareInheritedData->userModify); }
636 EUserDrag userDrag() const { return static_cast<EUserDrag>(rareNonInheritedData->userDrag); }
637 EUserSelect userSelect() const { return static_cast<EUserSelect>(rareInheritedData->userSelect); }
638 bool textOverflow() const { return rareNonInheritedData->textOverflow; }
639 EMarginCollapse marginTopCollapse() const { return static_cast<EMarginCollapse>(rareNonInheritedData->marginTopCollapse); }
640 EMarginCollapse marginBottomCollapse() const { return static_cast<EMarginCollapse>(rareNonInheritedData->marginBottomCollapse); }
641 EWordBreak wordBreak() const { return static_cast<EWordBreak>(rareInheritedData->wordBreak); }
642 EWordWrap wordWrap() const { return static_cast<EWordWrap>(rareInheritedData->wordWrap); }
643 ENBSPMode nbspMode() const { return static_cast<ENBSPMode>(rareInheritedData->nbspMode); }
644 EKHTMLLineBreak khtmlLineBreak() const { return static_cast<EKHTMLLineBreak>(rareInheritedData->khtmlLineBreak); }
645 EMatchNearestMailBlockquoteColor matchNearestMailBlockquoteColor() const { return static_cast<EMatchNearestMailBlockquoteColor>(rareNonInheritedData->matchNearestMailBlockquoteColor); }
646 const AtomicString& highlight() const { return rareInheritedData->highlight; }
647 EBorderFit borderFit() const { return static_cast<EBorderFit>(rareNonInheritedData->m_borderFit); }
648 EResize resize() const { return static_cast<EResize>(rareInheritedData->resize); }
649 float columnWidth() const { return rareNonInheritedData->m_multiCol->m_width; }
650 bool hasAutoColumnWidth() const { return rareNonInheritedData->m_multiCol->m_autoWidth; }
651 unsigned short columnCount() const { return rareNonInheritedData->m_multiCol->m_count; }
652 bool hasAutoColumnCount() const { return rareNonInheritedData->m_multiCol->m_autoCount; }
653 float columnGap() const { return rareNonInheritedData->m_multiCol->m_gap; }
654 bool hasNormalColumnGap() const { return rareNonInheritedData->m_multiCol->m_normalGap; }
655 const Color& columnRuleColor() const { return rareNonInheritedData->m_multiCol->m_rule.color; }
656 EBorderStyle columnRuleStyle() const { return rareNonInheritedData->m_multiCol->m_rule.style(); }
657 unsigned short columnRuleWidth() const { return rareNonInheritedData->m_multiCol->ruleWidth(); }
658 bool columnRuleIsTransparent() const { return rareNonInheritedData->m_multiCol->m_rule.isTransparent(); }
659 EPageBreak columnBreakBefore() const { return static_cast<EPageBreak>(rareNonInheritedData->m_multiCol->m_breakBefore); }
660 EPageBreak columnBreakInside() const { return static_cast<EPageBreak>(rareNonInheritedData->m_multiCol->m_breakInside); }
661 EPageBreak columnBreakAfter() const { return static_cast<EPageBreak>(rareNonInheritedData->m_multiCol->m_breakAfter); }
662 const TransformOperations& transform() const { return rareNonInheritedData->m_transform->m_operations; }
663 Length transformOriginX() const { return rareNonInheritedData->m_transform->m_x; }
664 Length transformOriginY() const { return rareNonInheritedData->m_transform->m_y; }
665 float transformOriginZ() const { return rareNonInheritedData->m_transform->m_z; }
666 bool hasTransform() const { return !rareNonInheritedData->m_transform->m_operations.operations().isEmpty(); }
668 // Return true if any transform related property (currently transform, transformStyle3D or perspective)
669 // indicates that we are transforming
670 bool hasTransformRelatedProperty() const { return hasTransform() || preserves3D() || hasPerspective(); }
672 enum ApplyTransformOrigin { IncludeTransformOrigin, ExcludeTransformOrigin };
673 void applyTransform(TransformationMatrix&, const IntSize& borderBoxSize, ApplyTransformOrigin = IncludeTransformOrigin) const;
675 bool hasMask() const { return rareNonInheritedData->m_mask.hasImage() || rareNonInheritedData->m_maskBoxImage.hasImage(); }
678 // Apple-specific property getter methods
679 EPointerEvents pointerEvents() const { return static_cast<EPointerEvents>(inherited_flags._pointerEvents); }
680 const AnimationList* animations() const { return rareNonInheritedData->m_animations.get(); }
681 const AnimationList* transitions() const { return rareNonInheritedData->m_transitions.get(); }
683 AnimationList* accessAnimations();
684 AnimationList* accessTransitions();
686 bool hasAnimations() const { return rareNonInheritedData->m_animations && rareNonInheritedData->m_animations->size() > 0; }
687 bool hasTransitions() const { return rareNonInheritedData->m_transitions && rareNonInheritedData->m_transitions->size() > 0; }
689 // return the first found Animation (including 'all' transitions)
690 const Animation* transitionForProperty(int property) const;
692 ETransformStyle3D transformStyle3D() const { return rareNonInheritedData->m_transformStyle3D; }
693 bool preserves3D() const { return rareNonInheritedData->m_transformStyle3D == TransformStyle3DPreserve3D; }
695 EBackfaceVisibility backfaceVisibility() const { return rareNonInheritedData->m_backfaceVisibility; }
696 float perspective() const { return rareNonInheritedData->m_perspective; }
697 bool hasPerspective() const { return rareNonInheritedData->m_perspective > 0; }
698 Length perspectiveOriginX() const { return rareNonInheritedData->m_perspectiveOriginX; }
699 Length perspectiveOriginY() const { return rareNonInheritedData->m_perspectiveOriginY; }
701 #if USE(ACCELERATED_COMPOSITING)
702 // When set, this ensures that styles compare as different. Used during accelerated animations.
703 bool isRunningAcceleratedAnimation() const { return rareNonInheritedData->m_runningAcceleratedAnimation; }
706 const LineClampValue& lineClamp() const { return rareNonInheritedData->lineClamp; }
707 bool textSizeAdjust() const { return rareInheritedData->textSizeAdjust; }
708 ETextSecurity textSecurity() const { return static_cast<ETextSecurity>(rareInheritedData->textSecurity); }
710 #ifdef ANDROID_CSS_TAP_HIGHLIGHT_COLOR
711 Color tapHighlightColor() const { return rareInheritedData->tapHighlightColor; }
714 // attribute setter methods
716 void setDisplay(EDisplay v) { noninherited_flags._effectiveDisplay = v; }
717 void setOriginalDisplay(EDisplay v) { noninherited_flags._originalDisplay = v; }
718 void setPosition(EPosition v) { noninherited_flags._position = v; }
719 void setFloating(EFloat v) { noninherited_flags._floating = v; }
721 void setLeft(Length v) { SET_VAR(surround, offset.m_left, v) }
722 void setRight(Length v) { SET_VAR(surround, offset.m_right, v) }
723 void setTop(Length v) { SET_VAR(surround, offset.m_top, v) }
724 void setBottom(Length v) { SET_VAR(surround, offset.m_bottom, v) }
726 void setWidth(Length v) { SET_VAR(box, width, v) }
727 void setHeight(Length v) { SET_VAR(box, height, v) }
729 void setMinWidth(Length v) { SET_VAR(box, min_width, v) }
730 void setMaxWidth(Length v) { SET_VAR(box, max_width, v) }
731 void setMinHeight(Length v) { SET_VAR(box, min_height, v) }
732 void setMaxHeight(Length v) { SET_VAR(box, max_height, v) }
734 #if ENABLE(DASHBOARD_SUPPORT)
735 Vector<StyleDashboardRegion> dashboardRegions() const { return rareNonInheritedData->m_dashboardRegions; }
736 void setDashboardRegions(Vector<StyleDashboardRegion> regions) { SET_VAR(rareNonInheritedData, m_dashboardRegions, regions); }
738 void setDashboardRegion(int type, const String& label, Length t, Length r, Length b, Length l, bool append)
740 StyleDashboardRegion region;
741 region.label = label;
742 region.offset.m_top = t;
743 region.offset.m_right = r;
744 region.offset.m_bottom = b;
745 region.offset.m_left = l;
748 rareNonInheritedData.access()->m_dashboardRegions.clear();
749 rareNonInheritedData.access()->m_dashboardRegions.append(region);
753 void resetBorder() { resetBorderImage(); resetBorderTop(); resetBorderRight(); resetBorderBottom(); resetBorderLeft(); resetBorderRadius(); }
754 void resetBorderTop() { SET_VAR(surround, border.top, BorderValue()) }
755 void resetBorderRight() { SET_VAR(surround, border.right, BorderValue()) }
756 void resetBorderBottom() { SET_VAR(surround, border.bottom, BorderValue()) }
757 void resetBorderLeft() { SET_VAR(surround, border.left, BorderValue()) }
758 void resetBorderImage() { SET_VAR(surround, border.image, NinePieceImage()) }
759 void resetBorderRadius() { resetBorderTopLeftRadius(); resetBorderTopRightRadius(); resetBorderBottomLeftRadius(); resetBorderBottomRightRadius(); }
760 void resetBorderTopLeftRadius() { SET_VAR(surround, border.topLeft, initialBorderRadius()) }
761 void resetBorderTopRightRadius() { SET_VAR(surround, border.topRight, initialBorderRadius()) }
762 void resetBorderBottomLeftRadius() { SET_VAR(surround, border.bottomLeft, initialBorderRadius()) }
763 void resetBorderBottomRightRadius() { SET_VAR(surround, border.bottomRight, initialBorderRadius()) }
765 void resetOutline() { SET_VAR(background, m_outline, OutlineValue()) }
767 void setBackgroundColor(const Color& v) { SET_VAR(background, m_color, v) }
769 void setBackgroundXPosition(Length l) { SET_VAR(background, m_background.m_xPosition, l) }
770 void setBackgroundYPosition(Length l) { SET_VAR(background, m_background.m_yPosition, l) }
771 void setBackgroundSize(EFillSizeType b) { SET_VAR(background, m_background.m_sizeType, b) }
772 void setBackgroundSizeLength(LengthSize l) { SET_VAR(background, m_background.m_sizeLength, l) }
774 void setBorderImage(const NinePieceImage& b) { SET_VAR(surround, border.image, b) }
776 void setBorderTopLeftRadius(const IntSize& s) { SET_VAR(surround, border.topLeft, s) }
777 void setBorderTopRightRadius(const IntSize& s) { SET_VAR(surround, border.topRight, s) }
778 void setBorderBottomLeftRadius(const IntSize& s) { SET_VAR(surround, border.bottomLeft, s) }
779 void setBorderBottomRightRadius(const IntSize& s) { SET_VAR(surround, border.bottomRight, s) }
781 void setBorderRadius(const IntSize& s)
783 setBorderTopLeftRadius(s);
784 setBorderTopRightRadius(s);
785 setBorderBottomLeftRadius(s);
786 setBorderBottomRightRadius(s);
789 void getBorderRadiiForRect(const IntRect&, IntSize& topLeft, IntSize& topRight, IntSize& bottomLeft, IntSize& bottomRight) const;
791 void setBorderLeftWidth(unsigned short v) { SET_VAR(surround, border.left.width, v) }
792 void setBorderLeftStyle(EBorderStyle v) { SET_VAR(surround, border.left.m_style, v) }
793 void setBorderLeftColor(const Color& v) { SET_VAR(surround, border.left.color, v) }
794 void setBorderRightWidth(unsigned short v) { SET_VAR(surround, border.right.width, v) }
795 void setBorderRightStyle(EBorderStyle v) { SET_VAR(surround, border.right.m_style, v) }
796 void setBorderRightColor(const Color& v) { SET_VAR(surround, border.right.color, v) }
797 void setBorderTopWidth(unsigned short v) { SET_VAR(surround, border.top.width, v) }
798 void setBorderTopStyle(EBorderStyle v) { SET_VAR(surround, border.top.m_style, v) }
799 void setBorderTopColor(const Color& v) { SET_VAR(surround, border.top.color, v) }
800 void setBorderBottomWidth(unsigned short v) { SET_VAR(surround, border.bottom.width, v) }
801 void setBorderBottomStyle(EBorderStyle v) { SET_VAR(surround, border.bottom.m_style, v) }
802 void setBorderBottomColor(const Color& v) { SET_VAR(surround, border.bottom.color, v) }
803 void setOutlineWidth(unsigned short v) { SET_VAR(background, m_outline.width, v) }
805 void setOutlineStyle(EBorderStyle v, bool isAuto = false)
807 SET_VAR(background, m_outline.m_style, v)
808 SET_VAR(background, m_outline._auto, isAuto)
811 void setOutlineColor(const Color& v) { SET_VAR(background, m_outline.color, v) }
813 void setOverflowX(EOverflow v) { noninherited_flags._overflowX = v; }
814 void setOverflowY(EOverflow v) { noninherited_flags._overflowY = v; }
815 void setVisibility(EVisibility v) { inherited_flags._visibility = v; }
816 void setVerticalAlign(EVerticalAlign v) { noninherited_flags._vertical_align = v; }
817 void setVerticalAlignLength(Length l) { SET_VAR(box, vertical_align, l) }
819 void setHasClip(bool b = true) { SET_VAR(visual, hasClip, b) }
820 void setClipLeft(Length v) { SET_VAR(visual, clip.m_left, v) }
821 void setClipRight(Length v) { SET_VAR(visual, clip.m_right, v) }
822 void setClipTop(Length v) { SET_VAR(visual, clip.m_top, v) }
823 void setClipBottom(Length v) { SET_VAR(visual, clip.m_bottom, v) }
824 void setClip(Length top, Length right, Length bottom, Length left);
826 void setUnicodeBidi(EUnicodeBidi b) { noninherited_flags._unicodeBidi = b; }
828 void setClear(EClear v) { noninherited_flags._clear = v; }
829 void setTableLayout(ETableLayout v) { noninherited_flags._table_layout = v; }
831 bool setFontDescription(const FontDescription& v)
833 if (inherited->font.fontDescription() != v) {
834 inherited.access()->font = Font(v, inherited->font.letterSpacing(), inherited->font.wordSpacing());
840 // Only used for blending font sizes when animating.
841 void setBlendedFontSize(int);
843 void setColor(const Color& v) { SET_VAR(inherited, color, v) }
844 void setTextIndent(Length v) { SET_VAR(inherited, indent, v) }
845 void setTextAlign(ETextAlign v) { inherited_flags._text_align = v; }
846 void setTextTransform(ETextTransform v) { inherited_flags._text_transform = v; }
847 void addToTextDecorationsInEffect(int v) { inherited_flags._text_decorations |= v; }
848 void setTextDecorationsInEffect(int v) { inherited_flags._text_decorations = v; }
849 void setTextDecoration(int v) { SET_VAR(visual, textDecoration, v); }
850 void setDirection(TextDirection v) { inherited_flags._direction = v; }
851 void setLineHeight(Length v) { SET_VAR(inherited, line_height, v) }
852 void setZoom(float f) { SET_VAR(visual, m_zoom, f); setEffectiveZoom(effectiveZoom() * zoom()); }
853 void setEffectiveZoom(float f) { SET_VAR(inherited, m_effectiveZoom, f) }
855 void setWhiteSpace(EWhiteSpace v) { inherited_flags._white_space = v; }
857 void setWordSpacing(int v) { inherited.access()->font.setWordSpacing(v); }
858 void setLetterSpacing(int v) { inherited.access()->font.setLetterSpacing(v); }
860 void clearBackgroundLayers() { background.access()->m_background = FillLayer(BackgroundFillLayer); }
861 void inheritBackgroundLayers(const FillLayer& parent) { background.access()->m_background = parent; }
863 void adjustBackgroundLayers()
865 if (backgroundLayers()->next()) {
866 accessBackgroundLayers()->cullEmptyLayers();
867 accessBackgroundLayers()->fillUnsetProperties();
871 void clearMaskLayers() { rareNonInheritedData.access()->m_mask = FillLayer(MaskFillLayer); }
872 void inheritMaskLayers(const FillLayer& parent) { rareNonInheritedData.access()->m_mask = parent; }
874 void adjustMaskLayers()
876 if (maskLayers()->next()) {
877 accessMaskLayers()->cullEmptyLayers();
878 accessMaskLayers()->fillUnsetProperties();
882 void setMaskBoxImage(const NinePieceImage& b) { SET_VAR(rareNonInheritedData, m_maskBoxImage, b) }
883 void setMaskXPosition(Length l) { SET_VAR(rareNonInheritedData, m_mask.m_xPosition, l) }
884 void setMaskYPosition(Length l) { SET_VAR(rareNonInheritedData, m_mask.m_yPosition, l) }
885 void setMaskSize(LengthSize l) { SET_VAR(rareNonInheritedData, m_mask.m_sizeLength, l) }
887 void setBorderCollapse(bool collapse) { inherited_flags._border_collapse = collapse; }
888 void setHorizontalBorderSpacing(short v) { SET_VAR(inherited, horizontal_border_spacing, v) }
889 void setVerticalBorderSpacing(short v) { SET_VAR(inherited, vertical_border_spacing, v) }
890 void setEmptyCells(EEmptyCell v) { inherited_flags._empty_cells = v; }
891 void setCaptionSide(ECaptionSide v) { inherited_flags._caption_side = v; }
893 void setCounterIncrement(short v) { SET_VAR(visual, counterIncrement, v) }
894 void setCounterReset(short v) { SET_VAR(visual, counterReset, v) }
896 void setListStyleType(EListStyleType v) { inherited_flags._list_style_type = v; }
897 void setListStyleImage(StyleImage* v) { if (inherited->list_style_image != v) inherited.access()->list_style_image = v; }
898 void setListStylePosition(EListStylePosition v) { inherited_flags._list_style_position = v; }
900 void resetMargin() { SET_VAR(surround, margin, LengthBox(Fixed)) }
901 void setMarginTop(Length v) { SET_VAR(surround, margin.m_top, v) }
902 void setMarginBottom(Length v) { SET_VAR(surround, margin.m_bottom, v) }
903 void setMarginLeft(Length v) { SET_VAR(surround, margin.m_left, v) }
904 void setMarginRight(Length v) { SET_VAR(surround, margin.m_right, v) }
906 void resetPadding() { SET_VAR(surround, padding, LengthBox(Auto)) }
907 void setPaddingBox(const LengthBox& b) { SET_VAR(surround, padding, b) }
908 void setPaddingTop(Length v) { SET_VAR(surround, padding.m_top, v) }
909 void setPaddingBottom(Length v) { SET_VAR(surround, padding.m_bottom, v) }
910 void setPaddingLeft(Length v) { SET_VAR(surround, padding.m_left, v) }
911 void setPaddingRight(Length v) { SET_VAR(surround, padding.m_right, v) }
913 void setCursor(ECursor c) { inherited_flags._cursor_style = c; }
914 void addCursor(CachedImage*, const IntPoint& = IntPoint());
915 void setCursorList(PassRefPtr<CursorList>);
916 void clearCursorList();
918 bool forceBackgroundsToWhite() const { return inherited_flags._force_backgrounds_to_white; }
919 void setForceBackgroundsToWhite(bool b=true) { inherited_flags._force_backgrounds_to_white = b; }
921 bool htmlHacks() const { return inherited_flags._htmlHacks; }
922 void setHtmlHacks(bool b=true) { inherited_flags._htmlHacks = b; }
924 bool hasAutoZIndex() const { return box->z_auto; }
925 void setHasAutoZIndex() { SET_VAR(box, z_auto, true); SET_VAR(box, z_index, 0) }
926 int zIndex() const { return box->z_index; }
927 void setZIndex(int v) { SET_VAR(box, z_auto, false); SET_VAR(box, z_index, v) }
929 void setWidows(short w) { SET_VAR(inherited, widows, w); }
930 void setOrphans(short o) { SET_VAR(inherited, orphans, o); }
931 void setPageBreakInside(EPageBreak b) { noninherited_flags._page_break_inside = b; }
932 void setPageBreakBefore(EPageBreak b) { noninherited_flags._page_break_before = b; }
933 void setPageBreakAfter(EPageBreak b) { noninherited_flags._page_break_after = b; }
937 void deleteBindingURIs() { SET_VAR(rareNonInheritedData, bindingURI, static_cast<BindingURI*>(0)); }
938 void inheritBindingURIs(BindingURI* other) { SET_VAR(rareNonInheritedData, bindingURI, other->copy()); }
939 void addBindingURI(StringImpl* uri);
942 void setOutlineOffset(int v) { SET_VAR(background, m_outline._offset, v) }
943 void setTextShadow(ShadowData* val, bool add=false);
944 void setTextStrokeColor(const Color& c) { SET_VAR(rareInheritedData, textStrokeColor, c) }
945 void setTextStrokeWidth(float w) { SET_VAR(rareInheritedData, textStrokeWidth, w) }
946 void setTextFillColor(const Color& c) { SET_VAR(rareInheritedData, textFillColor, c) }
947 void setColorSpace(ColorSpace space) { SET_VAR(rareInheritedData, colorSpace, space) }
948 void setOpacity(float f) { SET_VAR(rareNonInheritedData, opacity, f); }
949 void setAppearance(ControlPart a) { SET_VAR(rareNonInheritedData, m_appearance, a); }
950 void setBoxAlign(EBoxAlignment a) { SET_VAR(rareNonInheritedData.access()->flexibleBox, align, a); }
951 void setBoxDirection(EBoxDirection d) { inherited_flags._box_direction = d; }
952 void setBoxFlex(float f) { SET_VAR(rareNonInheritedData.access()->flexibleBox, flex, f); }
953 void setBoxFlexGroup(unsigned int fg) { SET_VAR(rareNonInheritedData.access()->flexibleBox, flex_group, fg); }
954 void setBoxLines(EBoxLines l) { SET_VAR(rareNonInheritedData.access()->flexibleBox, lines, l); }
955 void setBoxOrdinalGroup(unsigned int og) { SET_VAR(rareNonInheritedData.access()->flexibleBox, ordinal_group, og); }
956 void setBoxOrient(EBoxOrient o) { SET_VAR(rareNonInheritedData.access()->flexibleBox, orient, o); }
957 void setBoxPack(EBoxAlignment p) { SET_VAR(rareNonInheritedData.access()->flexibleBox, pack, p); }
958 void setBoxShadow(ShadowData* val, bool add=false);
959 void setBoxReflect(PassRefPtr<StyleReflection> reflect) { if (rareNonInheritedData->m_boxReflect != reflect) rareNonInheritedData.access()->m_boxReflect = reflect; }
960 void setBoxSizing(EBoxSizing s) { SET_VAR(box, boxSizing, s); }
961 void setMarqueeIncrement(const Length& f) { SET_VAR(rareNonInheritedData.access()->marquee, increment, f); }
962 void setMarqueeSpeed(int f) { SET_VAR(rareNonInheritedData.access()->marquee, speed, f); }
963 void setMarqueeDirection(EMarqueeDirection d) { SET_VAR(rareNonInheritedData.access()->marquee, direction, d); }
964 void setMarqueeBehavior(EMarqueeBehavior b) { SET_VAR(rareNonInheritedData.access()->marquee, behavior, b); }
965 void setMarqueeLoopCount(int i) { SET_VAR(rareNonInheritedData.access()->marquee, loops, i); }
966 void setUserModify(EUserModify u) { SET_VAR(rareInheritedData, userModify, u); }
967 void setUserDrag(EUserDrag d) { SET_VAR(rareNonInheritedData, userDrag, d); }
968 void setUserSelect(EUserSelect s) { SET_VAR(rareInheritedData, userSelect, s); }
969 void setTextOverflow(bool b) { SET_VAR(rareNonInheritedData, textOverflow, b); }
970 void setMarginTopCollapse(EMarginCollapse c) { SET_VAR(rareNonInheritedData, marginTopCollapse, c); }
971 void setMarginBottomCollapse(EMarginCollapse c) { SET_VAR(rareNonInheritedData, marginBottomCollapse, c); }
972 void setWordBreak(EWordBreak b) { SET_VAR(rareInheritedData, wordBreak, b); }
973 void setWordWrap(EWordWrap b) { SET_VAR(rareInheritedData, wordWrap, b); }
974 void setNBSPMode(ENBSPMode b) { SET_VAR(rareInheritedData, nbspMode, b); }
975 void setKHTMLLineBreak(EKHTMLLineBreak b) { SET_VAR(rareInheritedData, khtmlLineBreak, b); }
976 void setMatchNearestMailBlockquoteColor(EMatchNearestMailBlockquoteColor c) { SET_VAR(rareNonInheritedData, matchNearestMailBlockquoteColor, c); }
977 void setHighlight(const AtomicString& h) { SET_VAR(rareInheritedData, highlight, h); }
978 void setBorderFit(EBorderFit b) { SET_VAR(rareNonInheritedData, m_borderFit, b); }
979 void setResize(EResize r) { SET_VAR(rareInheritedData, resize, r); }
980 void setColumnWidth(float f) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_autoWidth, false); SET_VAR(rareNonInheritedData.access()->m_multiCol, m_width, f); }
981 void setHasAutoColumnWidth() { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_autoWidth, true); SET_VAR(rareNonInheritedData.access()->m_multiCol, m_width, 0); }
982 void setColumnCount(unsigned short c) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_autoCount, false); SET_VAR(rareNonInheritedData.access()->m_multiCol, m_count, c); }
983 void setHasAutoColumnCount() { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_autoCount, true); SET_VAR(rareNonInheritedData.access()->m_multiCol, m_count, 0); }
984 void setColumnGap(float f) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_normalGap, false); SET_VAR(rareNonInheritedData.access()->m_multiCol, m_gap, f); }
985 void setHasNormalColumnGap() { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_normalGap, true); SET_VAR(rareNonInheritedData.access()->m_multiCol, m_gap, 0); }
986 void setColumnRuleColor(const Color& c) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_rule.color, c); }
987 void setColumnRuleStyle(EBorderStyle b) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_rule.m_style, b); }
988 void setColumnRuleWidth(unsigned short w) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_rule.width, w); }
989 void resetColumnRule() { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_rule, BorderValue()) }
990 void setColumnBreakBefore(EPageBreak p) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_breakBefore, p); }
991 void setColumnBreakInside(EPageBreak p) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_breakInside, p); }
992 void setColumnBreakAfter(EPageBreak p) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_breakAfter, p); }
993 void setTransform(const TransformOperations& ops) { SET_VAR(rareNonInheritedData.access()->m_transform, m_operations, ops); }
994 void setTransformOriginX(Length l) { SET_VAR(rareNonInheritedData.access()->m_transform, m_x, l); }
995 void setTransformOriginY(Length l) { SET_VAR(rareNonInheritedData.access()->m_transform, m_y, l); }
996 void setTransformOriginZ(float f) { SET_VAR(rareNonInheritedData.access()->m_transform, m_z, f); }
999 // Apple-specific property setters
1000 void setPointerEvents(EPointerEvents p) { inherited_flags._pointerEvents = p; }
1002 void clearAnimations()
1004 rareNonInheritedData.access()->m_animations.clear();
1007 void clearTransitions()
1009 rareNonInheritedData.access()->m_transitions.clear();
1012 void inheritAnimations(const AnimationList* parent) { rareNonInheritedData.access()->m_animations.set(parent ? new AnimationList(*parent) : 0); }
1013 void inheritTransitions(const AnimationList* parent) { rareNonInheritedData.access()->m_transitions.set(parent ? new AnimationList(*parent) : 0); }
1014 void adjustAnimations();
1015 void adjustTransitions();
1017 void setTransformStyle3D(ETransformStyle3D b) { SET_VAR(rareNonInheritedData, m_transformStyle3D, b); }
1018 void setBackfaceVisibility(EBackfaceVisibility b) { SET_VAR(rareNonInheritedData, m_backfaceVisibility, b); }
1019 void setPerspective(float p) { SET_VAR(rareNonInheritedData, m_perspective, p); }
1020 void setPerspectiveOriginX(Length l) { SET_VAR(rareNonInheritedData, m_perspectiveOriginX, l); }
1021 void setPerspectiveOriginY(Length l) { SET_VAR(rareNonInheritedData, m_perspectiveOriginY, l); }
1023 #if USE(ACCELERATED_COMPOSITING)
1024 void setIsRunningAcceleratedAnimation(bool b = true) { SET_VAR(rareNonInheritedData, m_runningAcceleratedAnimation, b); }
1027 void setLineClamp(LineClampValue c) { SET_VAR(rareNonInheritedData, lineClamp, c); }
1028 void setTextSizeAdjust(bool b) { SET_VAR(rareInheritedData, textSizeAdjust, b); }
1029 void setTextSecurity(ETextSecurity aTextSecurity) { SET_VAR(rareInheritedData, textSecurity, aTextSecurity); }
1031 #ifdef ANDROID_CSS_TAP_HIGHLIGHT_COLOR
1032 void setTapHighlightColor(const Color& v) { SET_VAR(rareInheritedData, tapHighlightColor, v); }
1036 const SVGRenderStyle* svgStyle() const { return m_svgStyle.get(); }
1037 SVGRenderStyle* accessSVGStyle() { return m_svgStyle.access(); }
1039 float fillOpacity() const { return svgStyle()->fillOpacity(); }
1040 void setFillOpacity(float f) { accessSVGStyle()->setFillOpacity(f); }
1042 float strokeOpacity() const { return svgStyle()->strokeOpacity(); }
1043 void setStrokeOpacity(float f) { accessSVGStyle()->setStrokeOpacity(f); }
1045 float floodOpacity() const { return svgStyle()->floodOpacity(); }
1046 void setFloodOpacity(float f) { accessSVGStyle()->setFloodOpacity(f); }
1049 const ContentData* contentData() const { return rareNonInheritedData->m_content.get(); }
1050 bool contentDataEquivalent(const RenderStyle* otherStyle) const { return const_cast<RenderStyle*>(this)->rareNonInheritedData->contentDataEquivalent(*const_cast<RenderStyle*>(otherStyle)->rareNonInheritedData); }
1051 void clearContent();
1052 void setContent(PassRefPtr<StringImpl>, bool add = false);
1053 void setContent(PassRefPtr<StyleImage>, bool add = false);
1054 void setContent(CounterContent*, bool add = false);
1056 const CounterDirectiveMap* counterDirectives() const;
1057 CounterDirectiveMap& accessCounterDirectives();
1059 bool inheritedNotEqual(const RenderStyle*) const;
1061 StyleDifference diff(const RenderStyle*, unsigned& changedContextSensitiveProperties) const;
1063 bool isDisplayReplacedType() const
1065 return display() == INLINE_BLOCK || display() == INLINE_BOX || display() == INLINE_TABLE;
1068 bool isDisplayInlineType() const
1070 return display() == INLINE || isDisplayReplacedType();
1073 bool isOriginalDisplayInlineType() const
1075 return originalDisplay() == INLINE || originalDisplay() == INLINE_BLOCK ||
1076 originalDisplay() == INLINE_BOX || originalDisplay() == INLINE_TABLE;
1079 // To obtain at any time the pseudo state for a given link.
1080 PseudoState pseudoState() const { return static_cast<PseudoState>(m_pseudoState); }
1081 void setPseudoState(PseudoState s) { m_pseudoState = s; }
1083 // To tell if this style matched attribute selectors. This makes it impossible to share.
1084 bool affectedByAttributeSelectors() const { return m_affectedByAttributeSelectors; }
1085 void setAffectedByAttributeSelectors() { m_affectedByAttributeSelectors = true; }
1087 bool unique() const { return m_unique; }
1088 void setUnique() { m_unique = true; }
1090 // Methods for indicating the style is affected by dynamic updates (e.g., children changing, our position changing in our sibling list, etc.)
1091 bool affectedByEmpty() const { return m_affectedByEmpty; }
1092 bool emptyState() const { return m_emptyState; }
1093 void setEmptyState(bool b) { m_affectedByEmpty = true; m_unique = true; m_emptyState = b; }
1094 bool childrenAffectedByPositionalRules() const { return childrenAffectedByForwardPositionalRules() || childrenAffectedByBackwardPositionalRules(); }
1095 bool childrenAffectedByFirstChildRules() const { return m_childrenAffectedByFirstChildRules; }
1096 void setChildrenAffectedByFirstChildRules() { m_childrenAffectedByFirstChildRules = true; }
1097 bool childrenAffectedByLastChildRules() const { return m_childrenAffectedByLastChildRules; }
1098 void setChildrenAffectedByLastChildRules() { m_childrenAffectedByLastChildRules = true; }
1099 bool childrenAffectedByDirectAdjacentRules() const { return m_childrenAffectedByDirectAdjacentRules; }
1100 void setChildrenAffectedByDirectAdjacentRules() { m_childrenAffectedByDirectAdjacentRules = true; }
1101 bool childrenAffectedByForwardPositionalRules() const { return m_childrenAffectedByForwardPositionalRules; }
1102 void setChildrenAffectedByForwardPositionalRules() { m_childrenAffectedByForwardPositionalRules = true; }
1103 bool childrenAffectedByBackwardPositionalRules() const { return m_childrenAffectedByBackwardPositionalRules; }
1104 void setChildrenAffectedByBackwardPositionalRules() { m_childrenAffectedByBackwardPositionalRules = true; }
1105 bool firstChildState() const { return m_firstChildState; }
1106 void setFirstChildState() { m_firstChildState = true; }
1107 bool lastChildState() const { return m_lastChildState; }
1108 void setLastChildState() { m_lastChildState = true; }
1109 unsigned childIndex() const { return m_childIndex; }
1110 void setChildIndex(unsigned index) { m_childIndex = index; }
1112 // Initial values for all the properties
1113 static bool initialBorderCollapse() { return false; }
1114 static EBorderStyle initialBorderStyle() { return BNONE; }
1115 static NinePieceImage initialNinePieceImage() { return NinePieceImage(); }
1116 static IntSize initialBorderRadius() { return IntSize(0, 0); }
1117 static ECaptionSide initialCaptionSide() { return CAPTOP; }
1118 static EClear initialClear() { return CNONE; }
1119 static TextDirection initialDirection() { return LTR; }
1120 static EDisplay initialDisplay() { return INLINE; }
1121 static EEmptyCell initialEmptyCells() { return SHOW; }
1122 static EFloat initialFloating() { return FNONE; }
1123 static EListStylePosition initialListStylePosition() { return OUTSIDE; }
1124 static EListStyleType initialListStyleType() { return Disc; }
1125 static EOverflow initialOverflowX() { return OVISIBLE; }
1126 static EOverflow initialOverflowY() { return OVISIBLE; }
1127 static EPageBreak initialPageBreak() { return PBAUTO; }
1128 static EPosition initialPosition() { return StaticPosition; }
1129 static ETableLayout initialTableLayout() { return TAUTO; }
1130 static EUnicodeBidi initialUnicodeBidi() { return UBNormal; }
1131 static ETextTransform initialTextTransform() { return TTNONE; }
1132 static EVisibility initialVisibility() { return VISIBLE; }
1133 static EWhiteSpace initialWhiteSpace() { return NORMAL; }
1134 static short initialHorizontalBorderSpacing() { return 0; }
1135 static short initialVerticalBorderSpacing() { return 0; }
1136 static ECursor initialCursor() { return CURSOR_AUTO; }
1137 static Color initialColor() { return Color::black; }
1138 static StyleImage* initialListStyleImage() { return 0; }
1139 static unsigned short initialBorderWidth() { return 3; }
1140 static int initialLetterWordSpacing() { return 0; }
1141 static Length initialSize() { return Length(); }
1142 static Length initialMinSize() { return Length(0, Fixed); }
1143 static Length initialMaxSize() { return Length(undefinedLength, Fixed); }
1144 static Length initialOffset() { return Length(); }
1145 static Length initialMargin() { return Length(Fixed); }
1146 static Length initialPadding() { return Length(Fixed); }
1147 static Length initialTextIndent() { return Length(Fixed); }
1148 static EVerticalAlign initialVerticalAlign() { return BASELINE; }
1149 static int initialWidows() { return 2; }
1150 static int initialOrphans() { return 2; }
1151 static Length initialLineHeight() { return Length(-100.0, Percent); }
1152 static ETextAlign initialTextAlign() { return TAAUTO; }
1153 static ETextDecoration initialTextDecoration() { return TDNONE; }
1154 static float initialZoom() { return 1.0f; }
1155 static int initialOutlineOffset() { return 0; }
1156 static float initialOpacity() { return 1.0f; }
1157 static EBoxAlignment initialBoxAlign() { return BSTRETCH; }
1158 static EBoxDirection initialBoxDirection() { return BNORMAL; }
1159 static EBoxLines initialBoxLines() { return SINGLE; }
1160 static EBoxOrient initialBoxOrient() { return HORIZONTAL; }
1161 static EBoxAlignment initialBoxPack() { return BSTART; }
1162 static float initialBoxFlex() { return 0.0f; }
1163 static int initialBoxFlexGroup() { return 1; }
1164 static int initialBoxOrdinalGroup() { return 1; }
1165 static EBoxSizing initialBoxSizing() { return CONTENT_BOX; }
1166 static StyleReflection* initialBoxReflect() { return 0; }
1167 static int initialMarqueeLoopCount() { return -1; }
1168 static int initialMarqueeSpeed() { return 85; }
1169 static Length initialMarqueeIncrement() { return Length(6, Fixed); }
1170 static EMarqueeBehavior initialMarqueeBehavior() { return MSCROLL; }
1171 static EMarqueeDirection initialMarqueeDirection() { return MAUTO; }
1172 static EUserModify initialUserModify() { return READ_ONLY; }
1173 static EUserDrag initialUserDrag() { return DRAG_AUTO; }
1174 static EUserSelect initialUserSelect() { return SELECT_TEXT; }
1175 static bool initialTextOverflow() { return false; }
1176 static EMarginCollapse initialMarginTopCollapse() { return MCOLLAPSE; }
1177 static EMarginCollapse initialMarginBottomCollapse() { return MCOLLAPSE; }
1178 static EWordBreak initialWordBreak() { return NormalWordBreak; }
1179 static EWordWrap initialWordWrap() { return NormalWordWrap; }
1180 static ENBSPMode initialNBSPMode() { return NBNORMAL; }
1181 static EKHTMLLineBreak initialKHTMLLineBreak() { return LBNORMAL; }
1182 static EMatchNearestMailBlockquoteColor initialMatchNearestMailBlockquoteColor() { return BCNORMAL; }
1183 static const AtomicString& initialHighlight() { return nullAtom; }
1184 static EBorderFit initialBorderFit() { return BorderFitBorder; }
1185 static EResize initialResize() { return RESIZE_NONE; }
1186 static ControlPart initialAppearance() { return NoControlPart; }
1187 static bool initialVisuallyOrdered() { return false; }
1188 static float initialTextStrokeWidth() { return 0; }
1189 static unsigned short initialColumnCount() { return 1; }
1190 static const TransformOperations& initialTransform() { DEFINE_STATIC_LOCAL(TransformOperations, ops, ()); return ops; }
1191 static Length initialTransformOriginX() { return Length(50.0, Percent); }
1192 static Length initialTransformOriginY() { return Length(50.0, Percent); }
1193 static EPointerEvents initialPointerEvents() { return PE_AUTO; }
1194 static float initialTransformOriginZ() { return 0; }
1195 static ETransformStyle3D initialTransformStyle3D() { return TransformStyle3DFlat; }
1196 static EBackfaceVisibility initialBackfaceVisibility() { return BackfaceVisibilityVisible; }
1197 static float initialPerspective() { return 0; }
1198 static Length initialPerspectiveOriginX() { return Length(50.0, Percent); }
1199 static Length initialPerspectiveOriginY() { return Length(50.0, Percent); }
1200 static Color initialBackgroundColor() { return Color::transparent; }
1202 // Keep these at the end.
1203 static LineClampValue initialLineClamp() { return LineClampValue(); }
1204 static bool initialTextSizeAdjust() { return true; }
1205 static ETextSecurity initialTextSecurity() { return TSNONE; }
1206 #if ENABLE(DASHBOARD_SUPPORT)
1207 static const Vector<StyleDashboardRegion>& initialDashboardRegions();
1208 static const Vector<StyleDashboardRegion>& noneDashboardRegions();
1211 #ifdef ANDROID_CSS_TAP_HIGHLIGHT_COLOR
1212 static Color initialTapHighlightColor() { return Color::tap; }
1216 } // namespace WebCore
1218 #endif // RenderStyle_h