]> git.saurik.com Git - iphone-api.git/blob - WebCore/RenderStyle.h
Add support for new WinterBoard Settings features.
[iphone-api.git] / WebCore / RenderStyle.h
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 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 "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"
39 #include "Color.h"
40 #include "ContentData.h"
41 #include "CounterDirectives.h"
42 #include "CursorList.h"
43 #include "DataRef.h"
44 #include "FillLayer.h"
45 #include "FloatPoint.h"
46 #include "Font.h"
47 #include "GraphicsTypes.h"
48 #include "IntRect.h"
49 #include "Length.h"
50 #include "LengthBox.h"
51 #include "LengthSize.h"
52 #include "NinePieceImage.h"
53 #include "OutlineValue.h"
54 #include "Pair.h"
55 #include "RenderStyleConstants.h"
56 #include "ShadowData.h"
57 #include "StyleBackgroundData.h"
58 #include "StyleBoxData.h"
59 #include "StyleFlexibleBoxData.h"
60 #include "StyleInheritedData.h"
61 #include "StyleMarqueeData.h"
62 #include "StyleMultiColData.h"
63 #include "StyleRareInheritedData.h"
64 #include "StyleRareNonInheritedData.h"
65 #include "StyleReflection.h"
66 #include "StyleSurroundData.h"
67 #include "StyleTransformData.h"
68 #include "StyleVisualData.h"
69 #include "TextDirection.h"
70 #include "ThemeTypes.h"
71 #include "TimingFunction.h"
72 #include "TransformOperations.h"
73 #include <wtf/OwnPtr.h>
74 #include <wtf/RefCounted.h>
75 #include <wtf/StdLibExtras.h>
76 #include <wtf/Vector.h>
77
78 #if ENABLE(DASHBOARD_SUPPORT)
79 #include "StyleDashboardRegion.h"
80 #endif
81
82 #include "TextSizeAdjustment.h"
83
84 #if ENABLE(SVG)
85 #include "SVGRenderStyle.h"
86 #endif
87
88 #if ENABLE(XBL)
89 #include "BindingURI.h"
90 #endif
91
92 template<typename T, typename U> inline bool compareEqual(const T& t, const U& u) { return t == static_cast<T>(u); }
93
94 #define SET_VAR(group, variable, value) \
95 if (!compareEqual(group->variable, value)) \
96 group.access()->variable = value;
97
98 namespace WebCore {
99
100 using std::max;
101
102 class CSSStyleSelector;
103 class CSSValueList;
104 class CachedImage;
105 class Pair;
106 class StringImpl;
107 class StyleImage;
108
109 class RenderStyle: public RefCounted<RenderStyle> {
110 friend class CSSStyleSelector;
111
112 public:
113 // static pseudo styles. Dynamic ones are produced on the fly.
114 enum PseudoId { NOPSEUDO, FIRST_LINE, FIRST_LETTER, BEFORE, AFTER, SELECTION, FIRST_LINE_INHERITED, SCROLLBAR, FILE_UPLOAD_BUTTON, INPUT_PLACEHOLDER,
115 SLIDER_THUMB, SEARCH_CANCEL_BUTTON, SEARCH_DECORATION, SEARCH_RESULTS_DECORATION, SEARCH_RESULTS_BUTTON, MEDIA_CONTROLS_PANEL,
116 MEDIA_CONTROLS_PLAY_BUTTON, MEDIA_CONTROLS_MUTE_BUTTON, MEDIA_CONTROLS_TIMELINE, MEDIA_CONTROLS_TIMELINE_CONTAINER,
117 MEDIA_CONTROLS_CURRENT_TIME_DISPLAY, MEDIA_CONTROLS_TIME_REMAINING_DISPLAY, MEDIA_CONTROLS_SEEK_BACK_BUTTON,
118 MEDIA_CONTROLS_SEEK_FORWARD_BUTTON, MEDIA_CONTROLS_FULLSCREEN_BUTTON,
119 SCROLLBAR_THUMB, SCROLLBAR_BUTTON, SCROLLBAR_TRACK, SCROLLBAR_TRACK_PIECE, SCROLLBAR_CORNER, RESIZER };
120 static const int FIRST_INTERNAL_PSEUDOID = FILE_UPLOAD_BUTTON;
121
122 protected:
123
124 // !START SYNC!: Keep this in sync with the copy constructor in RenderStyle.cpp
125
126 // inherit
127 struct InheritedFlags {
128 bool operator==(const InheritedFlags& other) const
129 {
130 return (_empty_cells == other._empty_cells) &&
131 (_caption_side == other._caption_side) &&
132 (_list_style_type == other._list_style_type) &&
133 (_list_style_position == other._list_style_position) &&
134 (_visibility == other._visibility) &&
135 (_text_align == other._text_align) &&
136 (_text_transform == other._text_transform) &&
137 (_text_decorations == other._text_decorations) &&
138 (_text_transform == other._text_transform) &&
139 (_cursor_style == other._cursor_style) &&
140 (_direction == other._direction) &&
141 (_border_collapse == other._border_collapse) &&
142 (_white_space == other._white_space) &&
143 (_box_direction == other._box_direction) &&
144 (_visuallyOrdered == other._visuallyOrdered) &&
145 (_htmlHacks == other._htmlHacks) &&
146 (_force_backgrounds_to_white == other._force_backgrounds_to_white) &&
147 (_pointerEvents == other._pointerEvents);
148 }
149
150 bool operator!=(const InheritedFlags& other) const { return !(*this == other); }
151
152 unsigned _empty_cells : 1; // EEmptyCell
153 unsigned _caption_side : 2; // ECaptionSide
154 unsigned _list_style_type : 5 ; // EListStyleType
155 unsigned _list_style_position : 1; // EListStylePosition
156 unsigned _visibility : 2; // EVisibility
157 unsigned _text_align : 3; // ETextAlign
158 unsigned _text_transform : 2; // ETextTransform
159 unsigned _text_decorations : 4;
160 unsigned _cursor_style : 6; // ECursor
161 unsigned _direction : 1; // TextDirection
162 bool _border_collapse : 1 ;
163 unsigned _white_space : 3; // EWhiteSpace
164 unsigned _box_direction : 1; // EBoxDirection (CSS3 box_direction property, flexible box layout module)
165
166 // non CSS2 inherited
167 bool _visuallyOrdered : 1;
168 bool _htmlHacks :1;
169 bool _force_backgrounds_to_white : 1;
170 unsigned _pointerEvents : 4; // EPointerEvents
171 } inherited_flags;
172
173 // don't inherit
174 struct NonInheritedFlags {
175 bool operator==(const NonInheritedFlags& other) const
176 {
177 return (_effectiveDisplay == other._effectiveDisplay) &&
178 (_originalDisplay == other._originalDisplay) &&
179 (_overflowX == other._overflowX) &&
180 (_overflowY == other._overflowY) &&
181 (_vertical_align == other._vertical_align) &&
182 (_clear == other._clear) &&
183 (_position == other._position) &&
184 (_floating == other._floating) &&
185 (_table_layout == other._table_layout) &&
186 (_page_break_before == other._page_break_before) &&
187 (_page_break_after == other._page_break_after) &&
188 (_styleType == other._styleType) &&
189 (_affectedByHover == other._affectedByHover) &&
190 (_affectedByActive == other._affectedByActive) &&
191 (_affectedByDrag == other._affectedByDrag) &&
192 (_pseudoBits == other._pseudoBits) &&
193 (_unicodeBidi == other._unicodeBidi);
194 }
195
196 bool operator!=(const NonInheritedFlags& other) const { return !(*this == other); }
197
198 unsigned _effectiveDisplay : 5; // EDisplay
199 unsigned _originalDisplay : 5; // EDisplay
200 unsigned _overflowX : 3; // EOverflow
201 unsigned _overflowY : 3; // EOverflow
202 unsigned _vertical_align : 4; // EVerticalAlign
203 unsigned _clear : 2; // EClear
204 unsigned _position : 2; // EPosition
205 unsigned _floating : 2; // EFloat
206 unsigned _table_layout : 1; // ETableLayout
207
208 unsigned _page_break_before : 2; // EPageBreak
209 unsigned _page_break_after : 2; // EPageBreak
210
211 unsigned _styleType : 5; // PseudoId
212 bool _affectedByHover : 1;
213 bool _affectedByActive : 1;
214 bool _affectedByDrag : 1;
215 unsigned _pseudoBits : 7;
216 unsigned _unicodeBidi : 2; // EUnicodeBidi
217 } noninherited_flags;
218
219 // non-inherited attributes
220 DataRef<StyleBoxData> box;
221 DataRef<StyleVisualData> visual;
222 DataRef<StyleBackgroundData> background;
223 DataRef<StyleSurroundData> surround;
224 DataRef<StyleRareNonInheritedData> rareNonInheritedData;
225
226 // inherited attributes
227 DataRef<StyleRareInheritedData> rareInheritedData;
228 DataRef<StyleInheritedData> inherited;
229
230 // list of associated pseudo styles
231 RefPtr<RenderStyle> m_cachedPseudoStyle;
232
233 unsigned m_pseudoState : 3; // PseudoState
234 bool m_affectedByAttributeSelectors : 1;
235 bool m_unique : 1;
236
237 // Bits for dynamic child matching.
238 bool m_affectedByEmpty : 1;
239 bool m_emptyState : 1;
240
241 // We optimize for :first-child and :last-child. The other positional child selectors like nth-child or
242 // *-child-of-type, we will just give up and re-evaluate whenever children change at all.
243 bool m_childrenAffectedByFirstChildRules : 1;
244 bool m_childrenAffectedByLastChildRules : 1;
245 bool m_childrenAffectedByDirectAdjacentRules : 1;
246 bool m_childrenAffectedByForwardPositionalRules : 1;
247 bool m_childrenAffectedByBackwardPositionalRules : 1;
248 bool m_firstChildState : 1;
249 bool m_lastChildState : 1;
250 unsigned m_childIndex : 18; // Plenty of bits to cache an index.
251
252 #if ENABLE(SVG)
253 DataRef<SVGRenderStyle> m_svgStyle;
254 #endif
255
256 // !END SYNC!
257
258 protected:
259 void setBitDefaults()
260 {
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();
278
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._styleType = NOPSEUDO;
290 noninherited_flags._affectedByHover = false;
291 noninherited_flags._affectedByActive = false;
292 noninherited_flags._affectedByDrag = false;
293 noninherited_flags._pseudoBits = 0;
294 noninherited_flags._unicodeBidi = initialUnicodeBidi();
295 }
296
297 protected:
298 RenderStyle();
299 // used to create the default style.
300 RenderStyle(bool);
301 RenderStyle(const RenderStyle&);
302
303 public:
304 static PassRefPtr<RenderStyle> create();
305 static PassRefPtr<RenderStyle> createDefaultStyle();
306 static PassRefPtr<RenderStyle> clone(const RenderStyle*);
307
308 ~RenderStyle();
309
310 void inheritFrom(const RenderStyle* inheritParent);
311
312 PseudoId styleType() { return static_cast<PseudoId>(noninherited_flags._styleType); }
313 void setStyleType(PseudoId styleType) { noninherited_flags._styleType = styleType; }
314
315 RenderStyle* getCachedPseudoStyle(PseudoId);
316 RenderStyle* addCachedPseudoStyle(PassRefPtr<RenderStyle>);
317
318 bool affectedByHoverRules() const { return noninherited_flags._affectedByHover; }
319 bool affectedByActiveRules() const { return noninherited_flags._affectedByActive; }
320 bool affectedByDragRules() const { return noninherited_flags._affectedByDrag; }
321
322 void setAffectedByHoverRules(bool b) { noninherited_flags._affectedByHover = b; }
323 void setAffectedByActiveRules(bool b) { noninherited_flags._affectedByActive = b; }
324 void setAffectedByDragRules(bool b) { noninherited_flags._affectedByDrag = b; }
325
326 bool operator==(const RenderStyle& other) const;
327 bool operator!=(const RenderStyle& other) const { return !(*this == other); }
328 bool isFloating() const { return !(noninherited_flags._floating == FNONE); }
329 bool hasMargin() const { return surround->margin.nonZero(); }
330 bool hasBorder() const { return surround->border.hasBorder(); }
331 bool hasPadding() const { return surround->padding.nonZero(); }
332 bool hasOffset() const { return surround->offset.nonZero(); }
333
334 bool hasBackground() const
335 {
336 if (backgroundColor().isValid() && backgroundColor().alpha() > 0)
337 return true;
338 return background->m_background.hasImage();
339 }
340 bool hasBackgroundImage() const { return background->m_background.hasImage(); }
341 bool hasFixedBackgroundImage() const { return background->m_background.hasFixedImage(); }
342 bool hasAppearance() const { return appearance() != NoControlPart; }
343
344 bool visuallyOrdered() const { return inherited_flags._visuallyOrdered; }
345 void setVisuallyOrdered(bool b) { inherited_flags._visuallyOrdered = b; }
346
347 bool isStyleAvailable() const;
348
349 bool hasPseudoStyle(PseudoId pseudo) const;
350 void setHasPseudoStyle(PseudoId pseudo);
351
352 // attribute getter methods
353
354 EDisplay display() const { return static_cast<EDisplay>(noninherited_flags._effectiveDisplay); }
355 EDisplay originalDisplay() const { return static_cast<EDisplay>(noninherited_flags._originalDisplay); }
356
357 Length left() const { return surround->offset.left(); }
358 Length right() const { return surround->offset.right(); }
359 Length top() const { return surround->offset.top(); }
360 Length bottom() const { return surround->offset.bottom(); }
361
362 EPosition position() const { return static_cast<EPosition>(noninherited_flags._position); }
363 EFloat floating() const { return static_cast<EFloat>(noninherited_flags._floating); }
364
365 Length width() const { return box->width; }
366 Length height() const { return box->height; }
367 Length minWidth() const { return box->min_width; }
368 Length maxWidth() const { return box->max_width; }
369 Length minHeight() const { return box->min_height; }
370 Length maxHeight() const { return box->max_height; }
371
372 const BorderData& border() const { return surround->border; }
373 const BorderValue& borderLeft() const { return surround->border.left; }
374 const BorderValue& borderRight() const { return surround->border.right; }
375 const BorderValue& borderTop() const { return surround->border.top; }
376 const BorderValue& borderBottom() const { return surround->border.bottom; }
377
378 const NinePieceImage& borderImage() const { return surround->border.image; }
379
380 const IntSize& borderTopLeftRadius() const { return surround->border.topLeft; }
381 const IntSize& borderTopRightRadius() const { return surround->border.topRight; }
382 const IntSize& borderBottomLeftRadius() const { return surround->border.bottomLeft; }
383 const IntSize& borderBottomRightRadius() const { return surround->border.bottomRight; }
384 bool hasBorderRadius() const { return surround->border.hasBorderRadius(); }
385
386 unsigned short borderLeftWidth() const { return surround->border.borderLeftWidth(); }
387 EBorderStyle borderLeftStyle() const { return surround->border.left.style(); }
388 const Color& borderLeftColor() const { return surround->border.left.color; }
389 bool borderLeftIsTransparent() const { return surround->border.left.isTransparent(); }
390 unsigned short borderRightWidth() const { return surround->border.borderRightWidth(); }
391 EBorderStyle borderRightStyle() const { return surround->border.right.style(); }
392 const Color& borderRightColor() const { return surround->border.right.color; }
393 bool borderRightIsTransparent() const { return surround->border.right.isTransparent(); }
394 unsigned short borderTopWidth() const { return surround->border.borderTopWidth(); }
395 EBorderStyle borderTopStyle() const { return surround->border.top.style(); }
396 const Color& borderTopColor() const { return surround->border.top.color; }
397 bool borderTopIsTransparent() const { return surround->border.top.isTransparent(); }
398 unsigned short borderBottomWidth() const { return surround->border.borderBottomWidth(); }
399 EBorderStyle borderBottomStyle() const { return surround->border.bottom.style(); }
400 const Color& borderBottomColor() const { return surround->border.bottom.color; }
401 bool borderBottomIsTransparent() const { return surround->border.bottom.isTransparent(); }
402
403 unsigned short outlineSize() const { return max(0, outlineWidth() + outlineOffset()); }
404 unsigned short outlineWidth() const
405 {
406 if (background->m_outline.style() == BNONE)
407 return 0;
408 return background->m_outline.width;
409 }
410 bool hasOutline() const { return outlineWidth() > 0 && outlineStyle() > BHIDDEN; }
411 EBorderStyle outlineStyle() const { return background->m_outline.style(); }
412 bool outlineStyleIsAuto() const { return background->m_outline._auto; }
413 const Color& outlineColor() const { return background->m_outline.color; }
414
415 EOverflow overflowX() const { return static_cast<EOverflow>(noninherited_flags._overflowX); }
416 EOverflow overflowY() const { return static_cast<EOverflow>(noninherited_flags._overflowY); }
417
418 EVisibility visibility() const { return static_cast<EVisibility>(inherited_flags._visibility); }
419 EVerticalAlign verticalAlign() const { return static_cast<EVerticalAlign>(noninherited_flags._vertical_align); }
420 Length verticalAlignLength() const { return box->vertical_align; }
421
422 Length clipLeft() const { return visual->clip.left(); }
423 Length clipRight() const { return visual->clip.right(); }
424 Length clipTop() const { return visual->clip.top(); }
425 Length clipBottom() const { return visual->clip.bottom(); }
426 LengthBox clip() const { return visual->clip; }
427 bool hasClip() const { return visual->hasClip; }
428
429 EUnicodeBidi unicodeBidi() const { return static_cast<EUnicodeBidi>(noninherited_flags._unicodeBidi); }
430
431 EClear clear() const { return static_cast<EClear>(noninherited_flags._clear); }
432 ETableLayout tableLayout() const { return static_cast<ETableLayout>(noninherited_flags._table_layout); }
433
434 const Font& font() const { return inherited->font; }
435 const FontDescription& fontDescription() const { return inherited->font.fontDescription(); }
436 int fontSize() const { return inherited->font.pixelSize(); }
437
438 const Color& color() const { return inherited->color; }
439 Length textIndent() const { return inherited->indent; }
440 ETextAlign textAlign() const { return static_cast<ETextAlign>(inherited_flags._text_align); }
441 ETextTransform textTransform() const { return static_cast<ETextTransform>(inherited_flags._text_transform); }
442 int textDecorationsInEffect() const { return inherited_flags._text_decorations; }
443 int textDecoration() const { return visual->textDecoration; }
444 int wordSpacing() const { return inherited->font.wordSpacing(); }
445 float letterSpacing() const { return inherited->font.letterSpacing(); }
446
447 float zoom() const { return visual->m_zoom; }
448 float effectiveZoom() const { return inherited->m_effectiveZoom; }
449
450 TextDirection direction() const { return static_cast<TextDirection>(inherited_flags._direction); }
451 Length lineHeight() const { return inherited->line_height; }
452
453 Length specifiedLineHeight() const { return inherited->specified_line_height; }
454 EWhiteSpace whiteSpace() const { return static_cast<EWhiteSpace>(inherited_flags._white_space); }
455 static bool autoWrap(EWhiteSpace ws)
456 {
457 // Nowrap and pre don't automatically wrap.
458 return ws != NOWRAP && ws != PRE;
459 }
460
461 bool autoWrap() const
462 {
463 return autoWrap(whiteSpace());
464 }
465
466 static bool preserveNewline(EWhiteSpace ws)
467 {
468 // Normal and nowrap do not preserve newlines.
469 return ws != NORMAL && ws != NOWRAP;
470 }
471
472 bool preserveNewline() const
473 {
474 return preserveNewline(whiteSpace());
475 }
476
477 static bool collapseWhiteSpace(EWhiteSpace ws)
478 {
479 // Pre and prewrap do not collapse whitespace.
480 return ws != PRE && ws != PRE_WRAP;
481 }
482
483 bool collapseWhiteSpace() const
484 {
485 return collapseWhiteSpace(whiteSpace());
486 }
487
488 bool isCollapsibleWhiteSpace(UChar c) const
489 {
490 switch (c) {
491 case ' ':
492 case '\t':
493 return collapseWhiteSpace();
494 case '\n':
495 return !preserveNewline();
496 }
497 return false;
498 }
499
500 bool breakOnlyAfterWhiteSpace() const
501 {
502 return whiteSpace() == PRE_WRAP || khtmlLineBreak() == AFTER_WHITE_SPACE;
503 }
504
505 bool breakWords() const
506 {
507 return wordBreak() == BreakWordBreak || wordWrap() == BreakWordWrap;
508 }
509
510 const Color& backgroundColor() const { return background->m_color; }
511 StyleImage* backgroundImage() const { return background->m_background.m_image.get(); }
512 EFillRepeat backgroundRepeat() const { return static_cast<EFillRepeat>(background->m_background.m_repeat); }
513 CompositeOperator backgroundComposite() const { return static_cast<CompositeOperator>(background->m_background.m_composite); }
514 bool backgroundAttachment() const { return background->m_background.m_attachment; }
515 EFillBox backgroundClip() const { return static_cast<EFillBox>(background->m_background.m_clip); }
516 EFillBox backgroundOrigin() const { return static_cast<EFillBox>(background->m_background.m_origin); }
517 Length backgroundXPosition() const { return background->m_background.m_xPosition; }
518 Length backgroundYPosition() const { return background->m_background.m_yPosition; }
519 LengthSize backgroundSize() const { return background->m_background.m_size; }
520 FillLayer* accessBackgroundLayers() { return &(background.access()->m_background); }
521 const FillLayer* backgroundLayers() const { return &(background->m_background); }
522
523 StyleImage* maskImage() const { return rareNonInheritedData->m_mask.m_image.get(); }
524 EFillRepeat maskRepeat() const { return static_cast<EFillRepeat>(rareNonInheritedData->m_mask.m_repeat); }
525 CompositeOperator maskComposite() const { return static_cast<CompositeOperator>(rareNonInheritedData->m_mask.m_composite); }
526 bool maskAttachment() const { return rareNonInheritedData->m_mask.m_attachment; }
527 EFillBox maskClip() const { return static_cast<EFillBox>(rareNonInheritedData->m_mask.m_clip); }
528 EFillBox maskOrigin() const { return static_cast<EFillBox>(rareNonInheritedData->m_mask.m_origin); }
529 Length maskXPosition() const { return rareNonInheritedData->m_mask.m_xPosition; }
530 Length maskYPosition() const { return rareNonInheritedData->m_mask.m_yPosition; }
531 LengthSize maskSize() const { return rareNonInheritedData->m_mask.m_size; }
532 FillLayer* accessMaskLayers() { return &(rareNonInheritedData.access()->m_mask); }
533 const FillLayer* maskLayers() const { return &(rareNonInheritedData->m_mask); }
534 const NinePieceImage& maskBoxImage() const { return rareNonInheritedData->m_maskBoxImage; }
535
536 // returns true for collapsing borders, false for separate borders
537 bool borderCollapse() const { return inherited_flags._border_collapse; }
538 short horizontalBorderSpacing() const { return inherited->horizontal_border_spacing; }
539 short verticalBorderSpacing() const { return inherited->vertical_border_spacing; }
540 EEmptyCell emptyCells() const { return static_cast<EEmptyCell>(inherited_flags._empty_cells); }
541 ECaptionSide captionSide() const { return static_cast<ECaptionSide>(inherited_flags._caption_side); }
542
543 short counterIncrement() const { return visual->counterIncrement; }
544 short counterReset() const { return visual->counterReset; }
545
546 EListStyleType listStyleType() const { return static_cast<EListStyleType>(inherited_flags._list_style_type); }
547 StyleImage* listStyleImage() const { return inherited->list_style_image.get(); }
548 EListStylePosition listStylePosition() const { return static_cast<EListStylePosition>(inherited_flags._list_style_position); }
549
550 Length marginTop() const { return surround->margin.top(); }
551 Length marginBottom() const { return surround->margin.bottom(); }
552 Length marginLeft() const { return surround->margin.left(); }
553 Length marginRight() const { return surround->margin.right(); }
554
555 LengthBox paddingBox() const { return surround->padding; }
556 Length paddingTop() const { return surround->padding.top(); }
557 Length paddingBottom() const { return surround->padding.bottom(); }
558 Length paddingLeft() const { return surround->padding.left(); }
559 Length paddingRight() const { return surround->padding.right(); }
560
561 ECursor cursor() const { return static_cast<ECursor>(inherited_flags._cursor_style); }
562
563 CursorList* cursors() const { return inherited->cursorData.get(); }
564
565 short widows() const { return inherited->widows; }
566 short orphans() const { return inherited->orphans; }
567 EPageBreak pageBreakInside() const { return static_cast<EPageBreak>(inherited->page_break_inside); }
568 EPageBreak pageBreakBefore() const { return static_cast<EPageBreak>(noninherited_flags._page_break_before); }
569 EPageBreak pageBreakAfter() const { return static_cast<EPageBreak>(noninherited_flags._page_break_after); }
570
571 // CSS3 Getter Methods
572 #if ENABLE(XBL)
573 BindingURI* bindingURIs() const { return rareNonInheritedData->bindingURI; }
574 #endif
575
576 int outlineOffset() const
577 {
578 if (background->m_outline.style() == BNONE)
579 return 0;
580 return background->m_outline._offset;
581 }
582
583 ShadowData* textShadow() const { return rareInheritedData->textShadow; }
584 const Color& textStrokeColor() const { return rareInheritedData->textStrokeColor; }
585 float textStrokeWidth() const { return rareInheritedData->textStrokeWidth; }
586 const Color& textFillColor() const { return rareInheritedData->textFillColor; }
587 float opacity() const { return rareNonInheritedData->opacity; }
588 ControlPart appearance() const { return static_cast<ControlPart>(rareNonInheritedData->m_appearance); }
589 EImageLoadingBorder imageLoadingBorder() { return static_cast<EImageLoadingBorder>(rareNonInheritedData->m_imageLoadingBorder); }
590 EBoxAlignment boxAlign() const { return static_cast<EBoxAlignment>(rareNonInheritedData->flexibleBox->align); }
591 EBoxDirection boxDirection() const { return static_cast<EBoxDirection>(inherited_flags._box_direction); }
592 float boxFlex() { return rareNonInheritedData->flexibleBox->flex; }
593 unsigned int boxFlexGroup() const { return rareNonInheritedData->flexibleBox->flex_group; }
594 EBoxLines boxLines() { return static_cast<EBoxLines>(rareNonInheritedData->flexibleBox->lines); }
595 unsigned int boxOrdinalGroup() const { return rareNonInheritedData->flexibleBox->ordinal_group; }
596 EBoxOrient boxOrient() const { return static_cast<EBoxOrient>(rareNonInheritedData->flexibleBox->orient); }
597 EBoxAlignment boxPack() const { return static_cast<EBoxAlignment>(rareNonInheritedData->flexibleBox->pack); }
598 ShadowData* boxShadow() const { return rareNonInheritedData->m_boxShadow.get(); }
599 StyleReflection* boxReflect() const { return rareNonInheritedData->m_boxReflect.get(); }
600 EBoxSizing boxSizing() const { return static_cast<EBoxSizing>(box->boxSizing); }
601 Length marqueeIncrement() const { return rareNonInheritedData->marquee->increment; }
602 int marqueeSpeed() const { return rareNonInheritedData->marquee->speed; }
603 int marqueeLoopCount() const { return rareNonInheritedData->marquee->loops; }
604 EMarqueeBehavior marqueeBehavior() const { return static_cast<EMarqueeBehavior>(rareNonInheritedData->marquee->behavior); }
605 EMarqueeDirection marqueeDirection() const { return static_cast<EMarqueeDirection>(rareNonInheritedData->marquee->direction); }
606 EUserModify userModify() const { return static_cast<EUserModify>(rareInheritedData->userModify); }
607 EUserDrag userDrag() const { return static_cast<EUserDrag>(rareNonInheritedData->userDrag); }
608 EUserSelect userSelect() const { return static_cast<EUserSelect>(rareInheritedData->userSelect); }
609 bool textOverflow() const { return rareNonInheritedData->textOverflow; }
610 EMarginCollapse marginTopCollapse() const { return static_cast<EMarginCollapse>(rareNonInheritedData->marginTopCollapse); }
611 EMarginCollapse marginBottomCollapse() const { return static_cast<EMarginCollapse>(rareNonInheritedData->marginBottomCollapse); }
612 EWordBreak wordBreak() const { return static_cast<EWordBreak>(rareInheritedData->wordBreak); }
613 EWordWrap wordWrap() const { return static_cast<EWordWrap>(rareInheritedData->wordWrap); }
614 ENBSPMode nbspMode() const { return static_cast<ENBSPMode>(rareInheritedData->nbspMode); }
615 EKHTMLLineBreak khtmlLineBreak() const { return static_cast<EKHTMLLineBreak>(rareInheritedData->khtmlLineBreak); }
616 EMatchNearestMailBlockquoteColor matchNearestMailBlockquoteColor() const { return static_cast<EMatchNearestMailBlockquoteColor>(rareNonInheritedData->matchNearestMailBlockquoteColor); }
617 const AtomicString& highlight() const { return rareInheritedData->highlight; }
618 EBorderFit borderFit() const { return static_cast<EBorderFit>(rareNonInheritedData->m_borderFit); }
619 EResize resize() const { return static_cast<EResize>(rareInheritedData->resize); }
620 float columnWidth() const { return rareNonInheritedData->m_multiCol->m_width; }
621 bool hasAutoColumnWidth() const { return rareNonInheritedData->m_multiCol->m_autoWidth; }
622 unsigned short columnCount() const { return rareNonInheritedData->m_multiCol->m_count; }
623 bool hasAutoColumnCount() const { return rareNonInheritedData->m_multiCol->m_autoCount; }
624 float columnGap() const { return rareNonInheritedData->m_multiCol->m_gap; }
625 bool hasNormalColumnGap() const { return rareNonInheritedData->m_multiCol->m_normalGap; }
626 const Color& columnRuleColor() const { return rareNonInheritedData->m_multiCol->m_rule.color; }
627 EBorderStyle columnRuleStyle() const { return rareNonInheritedData->m_multiCol->m_rule.style(); }
628 unsigned short columnRuleWidth() const { return rareNonInheritedData->m_multiCol->ruleWidth(); }
629 bool columnRuleIsTransparent() const { return rareNonInheritedData->m_multiCol->m_rule.isTransparent(); }
630 EPageBreak columnBreakBefore() const { return static_cast<EPageBreak>(rareNonInheritedData->m_multiCol->m_breakBefore); }
631 EPageBreak columnBreakInside() const { return static_cast<EPageBreak>(rareNonInheritedData->m_multiCol->m_breakInside); }
632 EPageBreak columnBreakAfter() const { return static_cast<EPageBreak>(rareNonInheritedData->m_multiCol->m_breakAfter); }
633 const TransformOperations& transform() const { return rareNonInheritedData->m_transform->m_operations; }
634 Length transformOriginX() const { return rareNonInheritedData->m_transform->m_x; }
635 Length transformOriginY() const { return rareNonInheritedData->m_transform->m_y; }
636 float transformOriginZ() const { return rareNonInheritedData->m_transform->m_z; }
637 bool hasTransform() const { return !rareNonInheritedData->m_transform->m_operations.operations().isEmpty(); }
638
639 // Return true if any transform related property (currently transform, transformStyle3D or perspective)
640 // indicates that we are transforming
641 bool hasTransformRelatedProperty() const { return hasTransform() || preserves3D() || hasPerspective(); }
642
643 enum ApplyTransformOrigin { IncludeTransformOrigin, ExcludeTransformOrigin };
644 void applyTransform(TransformationMatrix&, const IntSize& borderBoxSize, ApplyTransformOrigin = IncludeTransformOrigin) const;
645
646 bool hasMask() const { return rareNonInheritedData->m_mask.hasImage() || rareNonInheritedData->m_maskBoxImage.hasImage(); }
647 // End CSS3 Getters
648
649 // Apple-specific property getter methods
650 EPointerEvents pointerEvents() const { return static_cast<EPointerEvents>(inherited_flags._pointerEvents); }
651 const AnimationList* animations() const { return rareNonInheritedData->m_animations.get(); }
652 const AnimationList* transitions() const { return rareNonInheritedData->m_transitions.get(); }
653
654 AnimationList* accessAnimations();
655 AnimationList* accessTransitions();
656
657 bool hasAnimations() const { return rareNonInheritedData->m_animations && rareNonInheritedData->m_animations->size() > 0; }
658 bool hasTransitions() const { return rareNonInheritedData->m_transitions && rareNonInheritedData->m_transitions->size() > 0; }
659
660 // return the first found Animation (including 'all' transitions)
661 const Animation* transitionForProperty(int property) const;
662
663 ETransformStyle3D transformStyle3D() const { return rareNonInheritedData->m_transformStyle3D; }
664 bool preserves3D() const { return rareNonInheritedData->m_transformStyle3D == TransformStyle3DPreserve3D; }
665
666 EBackfaceVisibility backfaceVisibility() const { return rareNonInheritedData->m_backfaceVisibility; }
667 float perspective() const { return rareNonInheritedData->m_perspective; }
668 bool hasPerspective() const { return rareNonInheritedData->m_perspective > 0; }
669 Length perspectiveOriginX() const { return rareNonInheritedData->m_perspectiveOriginX; }
670 Length perspectiveOriginY() const { return rareNonInheritedData->m_perspectiveOriginY; }
671
672 #if USE(ACCELERATED_COMPOSITING)
673 // When set, this ensures that styles compare as different. Used during accelerated animations.
674 bool isRunningAcceleratedAnimation() const { return rareNonInheritedData->m_runningAcceleratedAnimation; }
675 #endif
676
677 int lineClamp() const { return rareNonInheritedData->lineClamp; }
678 TextSizeAdjustment textSizeAdjust() const { return rareInheritedData->textSizeAdjust; }
679 Color tapHighlightColor() const { return rareInheritedData->tapHighlightColor; }
680 bool touchCalloutEnabled() const { return rareInheritedData->touchCalloutEnabled; }
681 Color compositionFillColor() const { return rareInheritedData->compositionFillColor; }
682 Color compositionFrameColor() const { return rareInheritedData->compositionFrameColor; }
683 ETextSecurity textSecurity() const { return static_cast<ETextSecurity>(rareInheritedData->textSecurity); }
684
685 // attribute setter methods
686
687 void setDisplay(EDisplay v) { noninherited_flags._effectiveDisplay = v; }
688 void setOriginalDisplay(EDisplay v) { noninherited_flags._originalDisplay = v; }
689 void setPosition(EPosition v) { noninherited_flags._position = v; }
690 void setFloating(EFloat v) { noninherited_flags._floating = v; }
691
692 void setLeft(Length v) { SET_VAR(surround, offset.m_left, v) }
693 void setRight(Length v) { SET_VAR(surround, offset.m_right, v) }
694 void setTop(Length v) { SET_VAR(surround, offset.m_top, v) }
695 void setBottom(Length v) { SET_VAR(surround, offset.m_bottom, v) }
696
697 void setWidth(Length v) { SET_VAR(box, width, v) }
698 void setHeight(Length v) { SET_VAR(box, height, v) }
699
700 void setMinWidth(Length v) { SET_VAR(box, min_width, v) }
701 void setMaxWidth(Length v) { SET_VAR(box, max_width, v) }
702 void setMinHeight(Length v) { SET_VAR(box, min_height, v) }
703 void setMaxHeight(Length v) { SET_VAR(box, max_height, v) }
704
705 #if ENABLE(DASHBOARD_SUPPORT)
706 Vector<StyleDashboardRegion> dashboardRegions() const { return rareNonInheritedData->m_dashboardRegions; }
707 void setDashboardRegions(Vector<StyleDashboardRegion> regions) { SET_VAR(rareNonInheritedData, m_dashboardRegions, regions); }
708
709 void setDashboardRegion(int type, const String& label, Length t, Length r, Length b, Length l, bool append)
710 {
711 StyleDashboardRegion region;
712 region.label = label;
713 region.offset.m_top = t;
714 region.offset.m_right = r;
715 region.offset.m_bottom = b;
716 region.offset.m_left = l;
717 region.type = type;
718 if (!append)
719 rareNonInheritedData.access()->m_dashboardRegions.clear();
720 rareNonInheritedData.access()->m_dashboardRegions.append(region);
721 }
722 #endif
723
724 void resetBorder() { resetBorderImage(); resetBorderTop(); resetBorderRight(); resetBorderBottom(); resetBorderLeft(); resetBorderRadius(); }
725 void resetBorderTop() { SET_VAR(surround, border.top, BorderValue()) }
726 void resetBorderRight() { SET_VAR(surround, border.right, BorderValue()) }
727 void resetBorderBottom() { SET_VAR(surround, border.bottom, BorderValue()) }
728 void resetBorderLeft() { SET_VAR(surround, border.left, BorderValue()) }
729 void resetBorderImage() { SET_VAR(surround, border.image, NinePieceImage()) }
730 void resetBorderRadius() { resetBorderTopLeftRadius(); resetBorderTopRightRadius(); resetBorderBottomLeftRadius(); resetBorderBottomRightRadius(); }
731 void resetBorderTopLeftRadius() { SET_VAR(surround, border.topLeft, initialBorderRadius()) }
732 void resetBorderTopRightRadius() { SET_VAR(surround, border.topRight, initialBorderRadius()) }
733 void resetBorderBottomLeftRadius() { SET_VAR(surround, border.bottomLeft, initialBorderRadius()) }
734 void resetBorderBottomRightRadius() { SET_VAR(surround, border.bottomRight, initialBorderRadius()) }
735
736 void resetOutline() { SET_VAR(background, m_outline, OutlineValue()) }
737
738 void setBackgroundColor(const Color& v) { SET_VAR(background, m_color, v) }
739
740 void setBorderImage(const NinePieceImage& b) { SET_VAR(surround, border.image, b) }
741
742 void setBorderTopLeftRadius(const IntSize& s) { SET_VAR(surround, border.topLeft, s) }
743 void setBorderTopRightRadius(const IntSize& s) { SET_VAR(surround, border.topRight, s) }
744 void setBorderBottomLeftRadius(const IntSize& s) { SET_VAR(surround, border.bottomLeft, s) }
745 void setBorderBottomRightRadius(const IntSize& s) { SET_VAR(surround, border.bottomRight, s) }
746
747 void setBorderRadius(const IntSize& s)
748 {
749 setBorderTopLeftRadius(s);
750 setBorderTopRightRadius(s);
751 setBorderBottomLeftRadius(s);
752 setBorderBottomRightRadius(s);
753 }
754
755 void setBorderLeftWidth(unsigned short v) { SET_VAR(surround, border.left.width, v) }
756 void setBorderLeftStyle(EBorderStyle v) { SET_VAR(surround, border.left.m_style, v) }
757 void setBorderLeftColor(const Color& v) { SET_VAR(surround, border.left.color, v) }
758 void setBorderRightWidth(unsigned short v) { SET_VAR(surround, border.right.width, v) }
759 void setBorderRightStyle(EBorderStyle v) { SET_VAR(surround, border.right.m_style, v) }
760 void setBorderRightColor(const Color& v) { SET_VAR(surround, border.right.color, v) }
761 void setBorderTopWidth(unsigned short v) { SET_VAR(surround, border.top.width, v) }
762 void setBorderTopStyle(EBorderStyle v) { SET_VAR(surround, border.top.m_style, v) }
763 void setBorderTopColor(const Color& v) { SET_VAR(surround, border.top.color, v) }
764 void setBorderBottomWidth(unsigned short v) { SET_VAR(surround, border.bottom.width, v) }
765 void setBorderBottomStyle(EBorderStyle v) { SET_VAR(surround, border.bottom.m_style, v) }
766 void setBorderBottomColor(const Color& v) { SET_VAR(surround, border.bottom.color, v) }
767 void setOutlineWidth(unsigned short v) { SET_VAR(background, m_outline.width, v) }
768
769 void setOutlineStyle(EBorderStyle v, bool isAuto = false)
770 {
771 SET_VAR(background, m_outline.m_style, v)
772 SET_VAR(background, m_outline._auto, isAuto)
773 }
774
775 void setOutlineColor(const Color& v) { SET_VAR(background, m_outline.color, v) }
776
777 void setOverflowX(EOverflow v) { noninherited_flags._overflowX = v; }
778 void setOverflowY(EOverflow v) { noninherited_flags._overflowY = v; }
779 void setVisibility(EVisibility v) { inherited_flags._visibility = v; }
780 void setVerticalAlign(EVerticalAlign v) { noninherited_flags._vertical_align = v; }
781 void setVerticalAlignLength(Length l) { SET_VAR(box, vertical_align, l ) }
782
783 void setHasClip(bool b = true) { SET_VAR(visual, hasClip, b) }
784 void setClipLeft(Length v) { SET_VAR(visual, clip.m_left, v) }
785 void setClipRight(Length v) { SET_VAR(visual, clip.m_right, v) }
786 void setClipTop(Length v) { SET_VAR(visual, clip.m_top, v) }
787 void setClipBottom(Length v) { SET_VAR(visual, clip.m_bottom, v) }
788 void setClip(Length top, Length right, Length bottom, Length left);
789
790 void setUnicodeBidi( EUnicodeBidi b ) { noninherited_flags._unicodeBidi = b; }
791
792 void setClear(EClear v) { noninherited_flags._clear = v; }
793 void setTableLayout(ETableLayout v) { noninherited_flags._table_layout = v; }
794
795 bool setFontDescription(const FontDescription& v)
796 {
797 if (inherited->font.fontDescription() != v) {
798 inherited.access()->font = Font(v, inherited->font.letterSpacing(), inherited->font.wordSpacing());
799 return true;
800 }
801 return false;
802 }
803
804 // Only used for blending font sizes when animating.
805 void setBlendedFontSize(int);
806
807 void setColor(const Color& v) { SET_VAR(inherited, color, v) }
808 void setTextIndent(Length v) { SET_VAR(inherited, indent, v) }
809 void setTextAlign(ETextAlign v) { inherited_flags._text_align = v; }
810 void setTextTransform(ETextTransform v) { inherited_flags._text_transform = v; }
811 void addToTextDecorationsInEffect(int v) { inherited_flags._text_decorations |= v; }
812 void setTextDecorationsInEffect(int v) { inherited_flags._text_decorations = v; }
813 void setTextDecoration(int v) { SET_VAR(visual, textDecoration, v); }
814 void setDirection(TextDirection v) { inherited_flags._direction = v; }
815 void setLineHeight(Length v) { SET_VAR(inherited, line_height, v) }
816 void setSpecifiedLineHeight(Length v) { SET_VAR(inherited, specified_line_height, v) }
817 void setZoom(float f) { SET_VAR(visual, m_zoom, f); setEffectiveZoom(effectiveZoom() * zoom()); }
818 void setEffectiveZoom(float f) { SET_VAR(inherited, m_effectiveZoom, f) }
819
820 void setWhiteSpace(EWhiteSpace v) { inherited_flags._white_space = v; }
821
822 void setWordSpacing(int v) { inherited.access()->font.setWordSpacing(v); }
823 void setLetterSpacing(float v) { inherited.access()->font.setLetterSpacing(v); }
824
825 void clearBackgroundLayers() { background.access()->m_background = FillLayer(BackgroundFillLayer); }
826 void inheritBackgroundLayers(const FillLayer& parent) { background.access()->m_background = parent; }
827
828 void adjustBackgroundLayers()
829 {
830 if (backgroundLayers()->next()) {
831 accessBackgroundLayers()->cullEmptyLayers();
832 accessBackgroundLayers()->fillUnsetProperties();
833 }
834 }
835
836 void clearMaskLayers() { rareNonInheritedData.access()->m_mask = FillLayer(MaskFillLayer); }
837 void inheritMaskLayers(const FillLayer& parent) { rareNonInheritedData.access()->m_mask = parent; }
838
839 void adjustMaskLayers()
840 {
841 if (maskLayers()->next()) {
842 accessMaskLayers()->cullEmptyLayers();
843 accessMaskLayers()->fillUnsetProperties();
844 }
845 }
846
847 void setMaskBoxImage(const NinePieceImage& b) { SET_VAR(rareNonInheritedData, m_maskBoxImage, b) }
848
849 void setBorderCollapse(bool collapse) { inherited_flags._border_collapse = collapse; }
850 void setHorizontalBorderSpacing(short v) { SET_VAR(inherited, horizontal_border_spacing, v) }
851 void setVerticalBorderSpacing(short v) { SET_VAR(inherited, vertical_border_spacing, v) }
852 void setEmptyCells(EEmptyCell v) { inherited_flags._empty_cells = v; }
853 void setCaptionSide(ECaptionSide v) { inherited_flags._caption_side = v; }
854
855 void setCounterIncrement(short v) { SET_VAR(visual, counterIncrement, v) }
856 void setCounterReset(short v) { SET_VAR(visual, counterReset, v) }
857
858 void setListStyleType(EListStyleType v) { inherited_flags._list_style_type = v; }
859 void setListStyleImage(StyleImage* v) { if (inherited->list_style_image != v) inherited.access()->list_style_image = v; }
860 void setListStylePosition(EListStylePosition v) { inherited_flags._list_style_position = v; }
861
862 void resetMargin() { SET_VAR(surround, margin, LengthBox(Fixed)) }
863 void setMarginTop(Length v) { SET_VAR(surround, margin.m_top, v) }
864 void setMarginBottom(Length v) { SET_VAR(surround, margin.m_bottom, v) }
865 void setMarginLeft(Length v) { SET_VAR(surround, margin.m_left, v) }
866 void setMarginRight(Length v) { SET_VAR(surround, margin.m_right, v) }
867
868 void resetPadding() { SET_VAR(surround, padding, LengthBox(Auto)) }
869 void setPaddingBox(const LengthBox& b) { SET_VAR(surround, padding, b) }
870 void setPaddingTop(Length v) { SET_VAR(surround, padding.m_top, v) }
871 void setPaddingBottom(Length v) { SET_VAR(surround, padding.m_bottom, v) }
872 void setPaddingLeft(Length v) { SET_VAR(surround, padding.m_left, v) }
873 void setPaddingRight(Length v) { SET_VAR(surround, padding.m_right, v) }
874
875 void setCursor( ECursor c ) { inherited_flags._cursor_style = c; }
876 void addCursor(CachedImage*, const IntPoint& = IntPoint());
877 void setCursorList(PassRefPtr<CursorList>);
878 void clearCursorList();
879
880 bool forceBackgroundsToWhite() const { return inherited_flags._force_backgrounds_to_white; }
881 void setForceBackgroundsToWhite(bool b=true) { inherited_flags._force_backgrounds_to_white = b; }
882
883 bool htmlHacks() const { return inherited_flags._htmlHacks; }
884 void setHtmlHacks(bool b=true) { inherited_flags._htmlHacks = b; }
885
886 bool hasAutoZIndex() const { return box->z_auto; }
887 void setHasAutoZIndex() { SET_VAR(box, z_auto, true); SET_VAR(box, z_index, 0) }
888 int zIndex() const { return box->z_index; }
889 void setZIndex(int v) { SET_VAR(box, z_auto, false); SET_VAR(box, z_index, v) }
890
891 void setWidows(short w) { SET_VAR(inherited, widows, w); }
892 void setOrphans(short o) { SET_VAR(inherited, orphans, o); }
893 void setPageBreakInside(EPageBreak b) { SET_VAR(inherited, page_break_inside, b); }
894 void setPageBreakBefore(EPageBreak b) { noninherited_flags._page_break_before = b; }
895 void setPageBreakAfter(EPageBreak b) { noninherited_flags._page_break_after = b; }
896
897 // CSS3 Setters
898 #if ENABLE(XBL)
899 void deleteBindingURIs() { SET_VAR(rareNonInheritedData, bindingURI, static_cast<BindingURI*>(0)); }
900 void inheritBindingURIs(BindingURI* other) { SET_VAR(rareNonInheritedData, bindingURI, other->copy()); }
901 void addBindingURI(StringImpl* uri);
902 #endif
903
904 void setOutlineOffset(int v) { SET_VAR(background, m_outline._offset, v) }
905 void setTextShadow(ShadowData* val, bool add=false);
906 void setTextStrokeColor(const Color& c) { SET_VAR(rareInheritedData, textStrokeColor, c) }
907 void setTextStrokeWidth(float w) { SET_VAR(rareInheritedData, textStrokeWidth, w) }
908 void setTextFillColor(const Color& c) { SET_VAR(rareInheritedData, textFillColor, c) }
909 void setOpacity(float f) { SET_VAR(rareNonInheritedData, opacity, f); }
910 void setAppearance(ControlPart a) { SET_VAR(rareNonInheritedData, m_appearance, a); }
911 void setImageLoadingBorder(EImageLoadingBorder anImageLoadingBorder) { SET_VAR(rareNonInheritedData, m_imageLoadingBorder, anImageLoadingBorder); }
912 void setBoxAlign(EBoxAlignment a) { SET_VAR(rareNonInheritedData.access()->flexibleBox, align, a); }
913 void setBoxDirection(EBoxDirection d) { inherited_flags._box_direction = d; }
914 void setBoxFlex(float f) { SET_VAR(rareNonInheritedData.access()->flexibleBox, flex, f); }
915 void setBoxFlexGroup(unsigned int fg) { SET_VAR(rareNonInheritedData.access()->flexibleBox, flex_group, fg); }
916 void setBoxLines(EBoxLines l) { SET_VAR(rareNonInheritedData.access()->flexibleBox, lines, l); }
917 void setBoxOrdinalGroup(unsigned int og) { SET_VAR(rareNonInheritedData.access()->flexibleBox, ordinal_group, og); }
918 void setBoxOrient(EBoxOrient o) { SET_VAR(rareNonInheritedData.access()->flexibleBox, orient, o); }
919 void setBoxPack(EBoxAlignment p) { SET_VAR(rareNonInheritedData.access()->flexibleBox, pack, p); }
920 void setBoxShadow(ShadowData* val, bool add=false);
921 void setBoxReflect(PassRefPtr<StyleReflection> reflect) { if (rareNonInheritedData->m_boxReflect != reflect) rareNonInheritedData.access()->m_boxReflect = reflect; }
922 void setBoxSizing(EBoxSizing s) { SET_VAR(box, boxSizing, s); }
923 void setMarqueeIncrement(const Length& f) { SET_VAR(rareNonInheritedData.access()->marquee, increment, f); }
924 void setMarqueeSpeed(int f) { SET_VAR(rareNonInheritedData.access()->marquee, speed, f); }
925 void setMarqueeDirection(EMarqueeDirection d) { SET_VAR(rareNonInheritedData.access()->marquee, direction, d); }
926 void setMarqueeBehavior(EMarqueeBehavior b) { SET_VAR(rareNonInheritedData.access()->marquee, behavior, b); }
927 void setMarqueeLoopCount(int i) { SET_VAR(rareNonInheritedData.access()->marquee, loops, i); }
928 void setUserModify(EUserModify u) { SET_VAR(rareInheritedData, userModify, u); }
929 void setUserDrag(EUserDrag d) { SET_VAR(rareNonInheritedData, userDrag, d); }
930 void setUserSelect(EUserSelect s) { SET_VAR(rareInheritedData, userSelect, s); }
931 void setTextOverflow(bool b) { SET_VAR(rareNonInheritedData, textOverflow, b); }
932 void setMarginTopCollapse(EMarginCollapse c) { SET_VAR(rareNonInheritedData, marginTopCollapse, c); }
933 void setMarginBottomCollapse(EMarginCollapse c) { SET_VAR(rareNonInheritedData, marginBottomCollapse, c); }
934 void setWordBreak(EWordBreak b) { SET_VAR(rareInheritedData, wordBreak, b); }
935 void setWordWrap(EWordWrap b) { SET_VAR(rareInheritedData, wordWrap, b); }
936 void setNBSPMode(ENBSPMode b) { SET_VAR(rareInheritedData, nbspMode, b); }
937 void setKHTMLLineBreak(EKHTMLLineBreak b) { SET_VAR(rareInheritedData, khtmlLineBreak, b); }
938 void setMatchNearestMailBlockquoteColor(EMatchNearestMailBlockquoteColor c) { SET_VAR(rareNonInheritedData, matchNearestMailBlockquoteColor, c); }
939 void setHighlight(const AtomicString& h) { SET_VAR(rareInheritedData, highlight, h); }
940 void setBorderFit(EBorderFit b) { SET_VAR(rareNonInheritedData, m_borderFit, b); }
941 void setResize(EResize r) { SET_VAR(rareInheritedData, resize, r); }
942 void setColumnWidth(float f) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_autoWidth, false); SET_VAR(rareNonInheritedData.access()->m_multiCol, m_width, f); }
943 void setHasAutoColumnWidth() { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_autoWidth, true); SET_VAR(rareNonInheritedData.access()->m_multiCol, m_width, 0); }
944 void setColumnCount(unsigned short c) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_autoCount, false); SET_VAR(rareNonInheritedData.access()->m_multiCol, m_count, c); }
945 void setHasAutoColumnCount() { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_autoCount, true); SET_VAR(rareNonInheritedData.access()->m_multiCol, m_count, 0); }
946 void setColumnGap(float f) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_normalGap, false); SET_VAR(rareNonInheritedData.access()->m_multiCol, m_gap, f); }
947 void setHasNormalColumnGap() { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_normalGap, true); SET_VAR(rareNonInheritedData.access()->m_multiCol, m_gap, 0); }
948 void setColumnRuleColor(const Color& c) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_rule.color, c); }
949 void setColumnRuleStyle(EBorderStyle b) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_rule.m_style, b); }
950 void setColumnRuleWidth(unsigned short w) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_rule.width, w); }
951 void resetColumnRule() { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_rule, BorderValue()) }
952 void setColumnBreakBefore(EPageBreak p) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_breakBefore, p); }
953 void setColumnBreakInside(EPageBreak p) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_breakInside, p); }
954 void setColumnBreakAfter(EPageBreak p) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_breakAfter, p); }
955 void setTransform(const TransformOperations& ops) { SET_VAR(rareNonInheritedData.access()->m_transform, m_operations, ops); }
956 void setTransformOriginX(Length l) { SET_VAR(rareNonInheritedData.access()->m_transform, m_x, l); }
957 void setTransformOriginY(Length l) { SET_VAR(rareNonInheritedData.access()->m_transform, m_y, l); }
958 void setTransformOriginZ(float f) { SET_VAR(rareNonInheritedData.access()->m_transform, m_z, f); }
959 // End CSS3 Setters
960
961 // Apple-specific property setters
962 void setPointerEvents(EPointerEvents p) { inherited_flags._pointerEvents = p; }
963
964 void clearAnimations()
965 {
966 rareNonInheritedData.access()->m_animations.clear();
967 }
968
969 void clearTransitions()
970 {
971 rareNonInheritedData.access()->m_transitions.clear();
972 }
973
974 void inheritAnimations(const AnimationList* parent) { rareNonInheritedData.access()->m_animations.set(parent ? new AnimationList(*parent) : 0); }
975 void inheritTransitions(const AnimationList* parent) { rareNonInheritedData.access()->m_transitions.set(parent ? new AnimationList(*parent) : 0); }
976 void adjustAnimations();
977 void adjustTransitions();
978
979 void setTransformStyle3D(ETransformStyle3D b) { SET_VAR(rareNonInheritedData, m_transformStyle3D, b); }
980 void setBackfaceVisibility(EBackfaceVisibility b) { SET_VAR(rareNonInheritedData, m_backfaceVisibility, b); }
981 void setPerspective(float p) { SET_VAR(rareNonInheritedData, m_perspective, p); }
982 void setPerspectiveOriginX(Length l) { SET_VAR(rareNonInheritedData, m_perspectiveOriginX, l); }
983 void setPerspectiveOriginY(Length l) { SET_VAR(rareNonInheritedData, m_perspectiveOriginY, l); }
984
985 #if USE(ACCELERATED_COMPOSITING)
986 void setIsRunningAcceleratedAnimation(bool b = true) { SET_VAR(rareNonInheritedData, m_runningAcceleratedAnimation, b); }
987 #endif
988
989 void setLineClamp(int c) { SET_VAR(rareNonInheritedData, lineClamp, c); }
990 void setTextSizeAdjust(TextSizeAdjustment anAdjustment) { SET_VAR(rareInheritedData, textSizeAdjust, anAdjustment); }
991 void setTapHighlightColor(const Color & v) { SET_VAR(rareInheritedData, tapHighlightColor, v); }
992 void setTouchCalloutEnabled(bool v) { SET_VAR(rareInheritedData, touchCalloutEnabled, v); }
993 void setCompositionFillColor(const Color & v) { SET_VAR(rareInheritedData, compositionFillColor, v); }
994 void setCompositionFrameColor(const Color & v) { SET_VAR(rareInheritedData, compositionFrameColor, v); }
995 void setTextSecurity(ETextSecurity aTextSecurity) { SET_VAR(rareInheritedData, textSecurity, aTextSecurity); }
996
997 #if ENABLE(SVG)
998 const SVGRenderStyle* svgStyle() const { return m_svgStyle.get(); }
999 SVGRenderStyle* accessSVGStyle() { return m_svgStyle.access(); }
1000
1001 float fillOpacity() const { return svgStyle()->fillOpacity(); }
1002 void setFillOpacity(float f) { accessSVGStyle()->setFillOpacity(f); }
1003
1004 float strokeOpacity() const { return svgStyle()->strokeOpacity(); }
1005 void setStrokeOpacity(float f) { accessSVGStyle()->setStrokeOpacity(f); }
1006
1007 float floodOpacity() const { return svgStyle()->floodOpacity(); }
1008 void setFloodOpacity(float f) { accessSVGStyle()->setFloodOpacity(f); }
1009 #endif
1010
1011 const ContentData* contentData() const { return rareNonInheritedData->m_content.get(); }
1012 bool contentDataEquivalent(const RenderStyle* otherStyle) const;
1013 void clearContent();
1014 void setContent(StringImpl*, bool add = false);
1015 void setContent(PassRefPtr<StyleImage>, bool add = false);
1016 void setContent(CounterContent*, bool add = false);
1017
1018 const CounterDirectiveMap* counterDirectives() const;
1019 CounterDirectiveMap& accessCounterDirectives();
1020
1021 bool inheritedNotEqual(RenderStyle*) const;
1022
1023 uint32_t hashForTextAutosizing() const;
1024 bool equalForTextAutosizing(const RenderStyle *other) const;
1025
1026 StyleDifference diff(const RenderStyle*, unsigned& changedContextSensitiveProperties) const;
1027
1028 bool isDisplayReplacedType() const
1029 {
1030 return display() == INLINE_BLOCK || display() == INLINE_BOX || display() == INLINE_TABLE;
1031 }
1032
1033 bool isDisplayInlineType() const
1034 {
1035 return display() == INLINE || isDisplayReplacedType();
1036 }
1037
1038 bool isOriginalDisplayInlineType() const
1039 {
1040 return originalDisplay() == INLINE || originalDisplay() == INLINE_BLOCK ||
1041 originalDisplay() == INLINE_BOX || originalDisplay() == INLINE_TABLE;
1042 }
1043
1044 // To obtain at any time the pseudo state for a given link.
1045 PseudoState pseudoState() const { return static_cast<PseudoState>(m_pseudoState); }
1046 void setPseudoState(PseudoState s) { m_pseudoState = s; }
1047
1048 // To tell if this style matched attribute selectors. This makes it impossible to share.
1049 bool affectedByAttributeSelectors() const { return m_affectedByAttributeSelectors; }
1050 void setAffectedByAttributeSelectors() { m_affectedByAttributeSelectors = true; }
1051
1052 bool unique() const { return m_unique; }
1053 void setUnique() { m_unique = true; }
1054
1055 // Methods for indicating the style is affected by dynamic updates (e.g., children changing, our position changing in our sibling list, etc.)
1056 bool affectedByEmpty() const { return m_affectedByEmpty; }
1057 bool emptyState() const { return m_emptyState; }
1058 void setEmptyState(bool b) { m_affectedByEmpty = true; m_unique = true; m_emptyState = b; }
1059 bool childrenAffectedByPositionalRules() const { return childrenAffectedByForwardPositionalRules() || childrenAffectedByBackwardPositionalRules(); }
1060 bool childrenAffectedByFirstChildRules() const { return m_childrenAffectedByFirstChildRules; }
1061 void setChildrenAffectedByFirstChildRules() { m_childrenAffectedByFirstChildRules = true; }
1062 bool childrenAffectedByLastChildRules() const { return m_childrenAffectedByLastChildRules; }
1063 void setChildrenAffectedByLastChildRules() { m_childrenAffectedByLastChildRules = true; }
1064 bool childrenAffectedByDirectAdjacentRules() const { return m_childrenAffectedByDirectAdjacentRules; }
1065 void setChildrenAffectedByDirectAdjacentRules() { m_childrenAffectedByDirectAdjacentRules = true; }
1066 bool childrenAffectedByForwardPositionalRules() const { return m_childrenAffectedByForwardPositionalRules; }
1067 void setChildrenAffectedByForwardPositionalRules() { m_childrenAffectedByForwardPositionalRules = true; }
1068 bool childrenAffectedByBackwardPositionalRules() const { return m_childrenAffectedByBackwardPositionalRules; }
1069 void setChildrenAffectedByBackwardPositionalRules() { m_childrenAffectedByBackwardPositionalRules = true; }
1070 bool firstChildState() const { return m_firstChildState; }
1071 void setFirstChildState() { m_firstChildState = true; }
1072 bool lastChildState() const { return m_lastChildState; }
1073 void setLastChildState() { m_lastChildState = true; }
1074 unsigned childIndex() const { return m_childIndex; }
1075 void setChildIndex(unsigned index) { m_childIndex = index; }
1076
1077 // Initial values for all the properties
1078 static bool initialBorderCollapse() { return false; }
1079 static EBorderStyle initialBorderStyle() { return BNONE; }
1080 static NinePieceImage initialNinePieceImage() { return NinePieceImage(); }
1081 static IntSize initialBorderRadius() { return IntSize(0, 0); }
1082 static ECaptionSide initialCaptionSide() { return CAPTOP; }
1083 static EClear initialClear() { return CNONE; }
1084 static TextDirection initialDirection() { return LTR; }
1085 static EDisplay initialDisplay() { return INLINE; }
1086 static EEmptyCell initialEmptyCells() { return SHOW; }
1087 static EFloat initialFloating() { return FNONE; }
1088 static EListStylePosition initialListStylePosition() { return OUTSIDE; }
1089 static EListStyleType initialListStyleType() { return DISC; }
1090 static EOverflow initialOverflowX() { return OVISIBLE; }
1091 static EOverflow initialOverflowY() { return OVISIBLE; }
1092 static EPageBreak initialPageBreak() { return PBAUTO; }
1093 static EPosition initialPosition() { return StaticPosition; }
1094 static ETableLayout initialTableLayout() { return TAUTO; }
1095 static EUnicodeBidi initialUnicodeBidi() { return UBNormal; }
1096 static ETextTransform initialTextTransform() { return TTNONE; }
1097 static EVisibility initialVisibility() { return VISIBLE; }
1098 static EWhiteSpace initialWhiteSpace() { return NORMAL; }
1099 static short initialHorizontalBorderSpacing() { return 0; }
1100 static short initialVerticalBorderSpacing() { return 0; }
1101 static ECursor initialCursor() { return CURSOR_AUTO; }
1102 static Color initialColor() { return Color::black; }
1103 static StyleImage* initialListStyleImage() { return 0; }
1104 static unsigned short initialBorderWidth() { return 3; }
1105 static int initialLetterWordSpacing() { return 0; }
1106 static Length initialSize() { return Length(); }
1107 static Length initialMinSize() { return Length(0, Fixed); }
1108 static Length initialMaxSize() { return Length(undefinedLength, Fixed); }
1109 static Length initialOffset() { return Length(); }
1110 static Length initialMargin() { return Length(Fixed); }
1111 static Length initialPadding() { return Length(Fixed); }
1112 static Length initialTextIndent() { return Length(Fixed); }
1113 static EVerticalAlign initialVerticalAlign() { return BASELINE; }
1114 static int initialWidows() { return 2; }
1115 static int initialOrphans() { return 2; }
1116 static Length initialLineHeight() { return Length(-100.0, Percent); }
1117 static Length initialSpecifiedLineHeight() { return Length(-100, Percent); }
1118 static ETextAlign initialTextAlign() { return TAAUTO; }
1119 static ETextDecoration initialTextDecoration() { return TDNONE; }
1120 static float initialZoom() { return 1.0f; }
1121 static int initialOutlineOffset() { return 0; }
1122 static float initialOpacity() { return 1.0f; }
1123 static EBoxAlignment initialBoxAlign() { return BSTRETCH; }
1124 static EBoxDirection initialBoxDirection() { return BNORMAL; }
1125 static EBoxLines initialBoxLines() { return SINGLE; }
1126 static EBoxOrient initialBoxOrient() { return HORIZONTAL; }
1127 static EBoxAlignment initialBoxPack() { return BSTART; }
1128 static float initialBoxFlex() { return 0.0f; }
1129 static int initialBoxFlexGroup() { return 1; }
1130 static int initialBoxOrdinalGroup() { return 1; }
1131 static EBoxSizing initialBoxSizing() { return CONTENT_BOX; }
1132 static StyleReflection* initialBoxReflect() { return 0; }
1133 static int initialMarqueeLoopCount() { return -1; }
1134 static int initialMarqueeSpeed() { return 85; }
1135 static Length initialMarqueeIncrement() { return Length(6, Fixed); }
1136 static EMarqueeBehavior initialMarqueeBehavior() { return MSCROLL; }
1137 static EMarqueeDirection initialMarqueeDirection() { return MAUTO; }
1138 static EUserModify initialUserModify() { return READ_ONLY; }
1139 static EUserDrag initialUserDrag() { return DRAG_AUTO; }
1140 static EUserSelect initialUserSelect() { return SELECT_TEXT; }
1141 static bool initialTextOverflow() { return false; }
1142 static EMarginCollapse initialMarginTopCollapse() { return MCOLLAPSE; }
1143 static EMarginCollapse initialMarginBottomCollapse() { return MCOLLAPSE; }
1144 static EWordBreak initialWordBreak() { return NormalWordBreak; }
1145 static EWordWrap initialWordWrap() { return NormalWordWrap; }
1146 static ENBSPMode initialNBSPMode() { return NBNORMAL; }
1147 static EKHTMLLineBreak initialKHTMLLineBreak() { return LBNORMAL; }
1148 static EMatchNearestMailBlockquoteColor initialMatchNearestMailBlockquoteColor() { return BCNORMAL; }
1149 static const AtomicString& initialHighlight() { return nullAtom; }
1150 static EBorderFit initialBorderFit() { return BorderFitBorder; }
1151 static EResize initialResize() { return RESIZE_NONE; }
1152 static ControlPart initialAppearance() { return NoControlPart; }
1153 static EImageLoadingBorder initialImageLoadingBorder() { return IMAGE_LOADING_BORDER_OUTLINE; }
1154 static bool initialVisuallyOrdered() { return false; }
1155 static float initialTextStrokeWidth() { return 0; }
1156 static unsigned short initialColumnCount() { return 1; }
1157 static const TransformOperations& initialTransform() { DEFINE_STATIC_LOCAL(TransformOperations, ops, ()); return ops; }
1158 static Length initialTransformOriginX() { return Length(50.0, Percent); }
1159 static Length initialTransformOriginY() { return Length(50.0, Percent); }
1160 static EPointerEvents initialPointerEvents() { return PE_AUTO; }
1161 static float initialTransformOriginZ() { return 0; }
1162 static ETransformStyle3D initialTransformStyle3D() { return TransformStyle3DFlat; }
1163 static EBackfaceVisibility initialBackfaceVisibility() { return BackfaceVisibilityVisible; }
1164 static float initialPerspective() { return 0; }
1165 static Length initialPerspectiveOriginX() { return Length(50.0, Percent); }
1166 static Length initialPerspectiveOriginY() { return Length(50.0, Percent); }
1167
1168 // Keep these at the end.
1169 static int initialLineClamp() { return -1; }
1170 static TextSizeAdjustment initialTextSizeAdjust() { return TextSizeAdjustment(); }
1171 static Color initialTapHighlightColor() { return Color::tap; }
1172 static bool initialTouchCalloutEnabled() { return true; }
1173 static Color initialCompositionFillColor() { return Color::compositionFill; }
1174 static Color initialCompositionFrameColor() { return Color::compositionFrame; }
1175 static ETextSecurity initialTextSecurity() { return TSNONE; }
1176 #if ENABLE(DASHBOARD_SUPPORT)
1177 static const Vector<StyleDashboardRegion>& initialDashboardRegions();
1178 static const Vector<StyleDashboardRegion>& noneDashboardRegions();
1179 #endif
1180 };
1181
1182 } // namespace WebCore
1183
1184 #endif // RenderStyle_h