#include "AnimationList.h"
#include "BorderData.h"
#include "BorderValue.h"
-#include "CSSHelper.h"
#include "CSSImageGeneratorValue.h"
#include "CSSPrimitiveValue.h"
#include "CSSPropertyNames.h"
#include "CSSReflectionDirection.h"
#include "CSSValueList.h"
-#include "CachedImage.h"
#include "CollapsedBorderValue.h"
#include "Color.h"
#include "ColorSpace.h"
class CSSStyleSelector;
class CSSValueList;
-class CachedImage;
class Pair;
class StyleImage;
(_white_space == other._white_space) &&
(_box_direction == other._box_direction) &&
(_visuallyOrdered == other._visuallyOrdered) &&
- (_htmlHacks == other._htmlHacks) &&
(_force_backgrounds_to_white == other._force_backgrounds_to_white) &&
(_pointerEvents == other._pointerEvents) &&
- (_insideLink == other._insideLink);
+ (_insideLink == other._insideLink) &&
+ (m_writingMode == other.m_writingMode);
}
bool operator!=(const InheritedFlags& other) const { return !(*this == other); }
// non CSS2 inherited
bool _visuallyOrdered : 1;
- bool _htmlHacks : 1;
bool _force_backgrounds_to_white : 1;
unsigned _pointerEvents : 4; // EPointerEvents
unsigned _insideLink : 2; // EInsideLink
// 43 bits
+
+ // CSS Text Layout Module Level 3: Vertical writing support
+ unsigned m_writingMode : 2; // WritingMode
+ // 45 bits
} inherited_flags;
// don't inherit
inherited_flags._border_collapse = initialBorderCollapse();
inherited_flags._white_space = initialWhiteSpace();
inherited_flags._visuallyOrdered = initialVisuallyOrdered();
- inherited_flags._htmlHacks=false;
inherited_flags._box_direction = initialBoxDirection();
inherited_flags._force_backgrounds_to_white = false;
inherited_flags._pointerEvents = initialPointerEvents();
inherited_flags._insideLink = NotInsideLink;
+ inherited_flags.m_writingMode = initialWritingMode();
noninherited_flags._effectiveDisplay = noninherited_flags._originalDisplay = initialDisplay();
noninherited_flags._overflowX = initialOverflowX();
}
private:
- RenderStyle();
+ ALWAYS_INLINE RenderStyle();
// used to create the default style.
- RenderStyle(bool);
- RenderStyle(const RenderStyle&);
+ ALWAYS_INLINE RenderStyle(bool);
+ ALWAYS_INLINE RenderStyle(const RenderStyle&);
public:
static PassRefPtr<RenderStyle> create();
RenderStyle* getCachedPseudoStyle(PseudoId) const;
RenderStyle* addCachedPseudoStyle(PassRefPtr<RenderStyle>);
+ void removeCachedPseudoStyle(PseudoId);
const PseudoStyleCache* cachedPseudoStyles() const { return m_cachedPseudoStyles.get(); }
bool hasFixedBackgroundImage() const { return m_background->background().hasFixedImage(); }
bool hasAppearance() const { return appearance() != NoControlPart; }
+ bool hasBackground() const
+ {
+ Color color = visitedDependentColor(CSSPropertyBackgroundColor);
+ if (color.isValid() && color.alpha() > 0)
+ return true;
+ return hasBackgroundImage();
+ }
+
bool visuallyOrdered() const { return inherited_flags._visuallyOrdered; }
void setVisuallyOrdered(bool b) { inherited_flags._visuallyOrdered = b; }
Length maxWidth() const { return m_box->maxWidth(); }
Length minHeight() const { return m_box->minHeight(); }
Length maxHeight() const { return m_box->maxHeight(); }
+
+ Length logicalWidth() const;
+ Length logicalHeight() const;
+ Length logicalMinWidth() const;
+ Length logicalMaxWidth() const;
+ Length logicalMinHeight() const;
+ Length logicalMaxHeight() const;
const BorderData& border() const { return surround->border; }
const BorderValue& borderLeft() const { return surround->border.left(); }
const NinePieceImage& borderImage() const { return surround->border.image(); }
- const IntSize& borderTopLeftRadius() const { return surround->border.topLeft(); }
- const IntSize& borderTopRightRadius() const { return surround->border.topRight(); }
- const IntSize& borderBottomLeftRadius() const { return surround->border.bottomLeft(); }
- const IntSize& borderBottomRightRadius() const { return surround->border.bottomRight(); }
+ const LengthSize& borderTopLeftRadius() const { return surround->border.topLeft(); }
+ const LengthSize& borderTopRightRadius() const { return surround->border.topRight(); }
+ const LengthSize& borderBottomLeftRadius() const { return surround->border.bottomLeft(); }
+ const LengthSize& borderBottomRightRadius() const { return surround->border.bottomRight(); }
bool hasBorderRadius() const { return surround->border.hasBorderRadius(); }
unsigned short borderLeftWidth() const { return surround->border.borderLeftWidth(); }
unsigned short borderBottomWidth() const { return surround->border.borderBottomWidth(); }
EBorderStyle borderBottomStyle() const { return surround->border.bottom().style(); }
bool borderBottomIsTransparent() const { return surround->border.bottom().isTransparent(); }
+
+ unsigned short borderBeforeWidth() const;
+ unsigned short borderAfterWidth() const;
+ unsigned short borderStartWidth() const;
+ unsigned short borderEndWidth() const;
unsigned short outlineSize() const { return max(0, outlineWidth() + outlineOffset()); }
unsigned short outlineWidth() const
float effectiveZoom() const { return rareInheritedData->m_effectiveZoom; }
TextDirection direction() const { return static_cast<TextDirection>(inherited_flags._direction); }
+ bool isLeftToRightDirection() const { return direction() == LTR; }
+
Length lineHeight() const { return inherited->line_height; }
int computedLineHeight() const
{
Length marginBottom() const { return surround->margin.bottom(); }
Length marginLeft() const { return surround->margin.left(); }
Length marginRight() const { return surround->margin.right(); }
+ Length marginBefore() const;
+ Length marginAfter() const;
+ Length marginStart() const;
+ Length marginEnd() const;
+ Length marginStartUsing(const RenderStyle* otherStyle) const;
+ Length marginEndUsing(const RenderStyle* otherStyle) const;
+ Length marginBeforeUsing(const RenderStyle* otherStyle) const;
+ Length marginAfterUsing(const RenderStyle* otherStyle) const;
LengthBox paddingBox() const { return surround->padding; }
Length paddingTop() const { return surround->padding.top(); }
Length paddingBottom() const { return surround->padding.bottom(); }
Length paddingLeft() const { return surround->padding.left(); }
Length paddingRight() const { return surround->padding.right(); }
+ Length paddingBefore() const;
+ Length paddingAfter() const;
+ Length paddingStart() const;
+ Length paddingEnd() const;
ECursor cursor() const { return static_cast<ECursor>(inherited_flags._cursor_style); }
}
const ShadowData* textShadow() const { return rareInheritedData->textShadow; }
+ void getTextShadowExtent(int& top, int& right, int& bottom, int& left) const { getShadowExtent(textShadow(), top, right, bottom, left); }
+ void getTextShadowHorizontalExtent(int& left, int& right) const { getShadowHorizontalExtent(textShadow(), left, right); }
+ void getTextShadowVerticalExtent(int& top, int& bottom) const { getShadowVerticalExtent(textShadow(), top, bottom); }
+ void getTextShadowInlineDirectionExtent(int& logicalLeft, int& logicalRight) { getShadowInlineDirectionExtent(textShadow(), logicalLeft, logicalRight); }
+ void getTextShadowBlockDirectionExtent(int& logicalTop, int& logicalBottom) { getShadowBlockDirectionExtent(textShadow(), logicalTop, logicalBottom); }
+
float textStrokeWidth() const { return rareInheritedData->textStrokeWidth; }
ColorSpace colorSpace() const { return static_cast<ColorSpace>(rareInheritedData->colorSpace); }
float opacity() const { return rareNonInheritedData->opacity; }
EBoxAlignment boxPack() const { return static_cast<EBoxAlignment>(rareNonInheritedData->flexibleBox->pack); }
const ShadowData* boxShadow() const { return rareNonInheritedData->m_boxShadow.get(); }
- void getBoxShadowExtent(int &top, int &right, int &bottom, int &left) const;
- void getBoxShadowHorizontalExtent(int &left, int &right) const;
- void getBoxShadowVerticalExtent(int &top, int &bottom) const;
+ void getBoxShadowExtent(int& top, int& right, int& bottom, int& left) const { getShadowExtent(boxShadow(), top, right, bottom, left); }
+ void getBoxShadowHorizontalExtent(int& left, int& right) const { getShadowHorizontalExtent(boxShadow(), left, right); }
+ void getBoxShadowVerticalExtent(int& top, int& bottom) const { getShadowVerticalExtent(boxShadow(), top, bottom); }
+ void getBoxShadowInlineDirectionExtent(int& logicalLeft, int& logicalRight) { getShadowInlineDirectionExtent(boxShadow(), logicalLeft, logicalRight); }
+ void getBoxShadowBlockDirectionExtent(int& logicalTop, int& logicalBottom) { getShadowBlockDirectionExtent(boxShadow(), logicalTop, logicalBottom); }
StyleReflection* boxReflect() const { return rareNonInheritedData->m_boxReflect.get(); }
EBoxSizing boxSizing() const { return m_box->boxSizing(); }
EUserDrag userDrag() const { return static_cast<EUserDrag>(rareNonInheritedData->userDrag); }
EUserSelect userSelect() const { return static_cast<EUserSelect>(rareInheritedData->userSelect); }
bool textOverflow() const { return rareNonInheritedData->textOverflow; }
- EMarginCollapse marginTopCollapse() const { return static_cast<EMarginCollapse>(rareNonInheritedData->marginTopCollapse); }
- EMarginCollapse marginBottomCollapse() const { return static_cast<EMarginCollapse>(rareNonInheritedData->marginBottomCollapse); }
+ EMarginCollapse marginBeforeCollapse() const { return static_cast<EMarginCollapse>(rareNonInheritedData->marginBeforeCollapse); }
+ EMarginCollapse marginAfterCollapse() const { return static_cast<EMarginCollapse>(rareNonInheritedData->marginAfterCollapse); }
EWordBreak wordBreak() const { return static_cast<EWordBreak>(rareInheritedData->wordBreak); }
EWordWrap wordWrap() const { return static_cast<EWordWrap>(rareInheritedData->wordWrap); }
ENBSPMode nbspMode() const { return static_cast<ENBSPMode>(rareInheritedData->nbspMode); }
enum ApplyTransformOrigin { IncludeTransformOrigin, ExcludeTransformOrigin };
void applyTransform(TransformationMatrix&, const IntSize& borderBoxSize, ApplyTransformOrigin = IncludeTransformOrigin) const;
+ void setPageScaleTransform(float);
bool hasMask() const { return rareNonInheritedData->m_mask.hasImage() || rareNonInheritedData->m_maskBoxImage.hasImage(); }
// End CSS3 Getters
bool textSizeAdjust() const { return rareInheritedData->textSizeAdjust; }
ETextSecurity textSecurity() const { return static_cast<ETextSecurity>(rareInheritedData->textSecurity); }
+ WritingMode writingMode() const { return static_cast<WritingMode>(inherited_flags.m_writingMode); }
+ bool isHorizontalWritingMode() const { return writingMode() == TopToBottomWritingMode || writingMode() == BottomToTopWritingMode; }
+ bool isFlippedLinesWritingMode() const { return writingMode() == LeftToRightWritingMode || writingMode() == BottomToTopWritingMode; }
+ bool isFlippedBlocksWritingMode() const { return writingMode() == RightToLeftWritingMode || writingMode() == BottomToTopWritingMode; }
+
+ ESpeak speak() { return static_cast<ESpeak>(rareInheritedData->speak); }
+
#ifdef ANDROID_CSS_RING
// called when building nav cache to determine if the ring data is unchanged
const void* ringData() const { return reinterpret_cast<const void*>(rareInheritedData.get()); }
#ifdef ANDROID_CSS_TAP_HIGHLIGHT_COLOR
Color tapHighlightColor() const { return rareInheritedData->tapHighlightColor; }
#endif
-
// attribute setter methods
void setDisplay(EDisplay v) { noninherited_flags._effectiveDisplay = v; }
void setBorderImage(const NinePieceImage& b) { SET_VAR(surround, border.m_image, b) }
- void setBorderTopLeftRadius(const IntSize& s) { SET_VAR(surround, border.m_topLeft, s) }
- void setBorderTopRightRadius(const IntSize& s) { SET_VAR(surround, border.m_topRight, s) }
- void setBorderBottomLeftRadius(const IntSize& s) { SET_VAR(surround, border.m_bottomLeft, s) }
- void setBorderBottomRightRadius(const IntSize& s) { SET_VAR(surround, border.m_bottomRight, s) }
+ void setBorderTopLeftRadius(const LengthSize& s) { SET_VAR(surround, border.m_topLeft, s) }
+ void setBorderTopRightRadius(const LengthSize& s) { SET_VAR(surround, border.m_topRight, s) }
+ void setBorderBottomLeftRadius(const LengthSize& s) { SET_VAR(surround, border.m_bottomLeft, s) }
+ void setBorderBottomRightRadius(const LengthSize& s) { SET_VAR(surround, border.m_bottomRight, s) }
- void setBorderRadius(const IntSize& s)
+ void setBorderRadius(const LengthSize& s)
{
setBorderTopLeftRadius(s);
setBorderTopRightRadius(s);
setBorderBottomLeftRadius(s);
setBorderBottomRightRadius(s);
}
+ void setBorderRadius(const IntSize& s)
+ {
+ setBorderRadius(LengthSize(Length(s.width(), Fixed), Length(s.height(), Fixed)));
+ }
+
void getBorderRadiiForRect(const IntRect&, IntSize& topLeft, IntSize& topRight, IntSize& bottomLeft, IntSize& bottomRight) const;
void getInnerBorderRadiiForRectWithBorderWidths(const IntRect&, unsigned short topWidth,
void setCounterReset(short v) { SET_VAR(rareNonInheritedData, m_counterReset, v) }
void setListStyleType(EListStyleType v) { inherited_flags._list_style_type = v; }
- void setListStyleImage(StyleImage* v) { if (inherited->list_style_image != v) inherited.access()->list_style_image = v; }
+ void setListStyleImage(PassRefPtr<StyleImage> v) { if (inherited->list_style_image != v) inherited.access()->list_style_image = v; }
void setListStylePosition(EListStylePosition v) { inherited_flags._list_style_position = v; }
void resetMargin() { SET_VAR(surround, margin, LengthBox(Fixed)) }
void setPaddingRight(Length v) { SET_VAR(surround, padding.m_right, v) }
void setCursor(ECursor c) { inherited_flags._cursor_style = c; }
- void addCursor(CachedImage*, const IntPoint& = IntPoint());
+ void addCursor(PassRefPtr<StyleImage>, const IntPoint& hotSpot = IntPoint());
void setCursorList(PassRefPtr<CursorList>);
void clearCursorList();
bool forceBackgroundsToWhite() const { return inherited_flags._force_backgrounds_to_white; }
void setForceBackgroundsToWhite(bool b=true) { inherited_flags._force_backgrounds_to_white = b; }
- bool htmlHacks() const { return inherited_flags._htmlHacks; }
- void setHtmlHacks(bool b=true) { inherited_flags._htmlHacks = b; }
-
bool hasAutoZIndex() const { return m_box->hasAutoZIndex(); }
void setHasAutoZIndex() { SET_VAR(m_box, m_hasAutoZIndex, true); SET_VAR(m_box, m_zIndex, 0) }
int zIndex() const { return m_box->zIndex(); }
void setUserDrag(EUserDrag d) { SET_VAR(rareNonInheritedData, userDrag, d); }
void setUserSelect(EUserSelect s) { SET_VAR(rareInheritedData, userSelect, s); }
void setTextOverflow(bool b) { SET_VAR(rareNonInheritedData, textOverflow, b); }
- void setMarginTopCollapse(EMarginCollapse c) { SET_VAR(rareNonInheritedData, marginTopCollapse, c); }
- void setMarginBottomCollapse(EMarginCollapse c) { SET_VAR(rareNonInheritedData, marginBottomCollapse, c); }
+ void setMarginBeforeCollapse(EMarginCollapse c) { SET_VAR(rareNonInheritedData, marginBeforeCollapse, c); }
+ void setMarginAfterCollapse(EMarginCollapse c) { SET_VAR(rareNonInheritedData, marginAfterCollapse, c); }
void setWordBreak(EWordBreak b) { SET_VAR(rareInheritedData, wordBreak, b); }
void setWordWrap(EWordWrap b) { SET_VAR(rareInheritedData, wordWrap, b); }
void setNBSPMode(ENBSPMode b) { SET_VAR(rareInheritedData, nbspMode, b); }
void setTransformOriginX(Length l) { SET_VAR(rareNonInheritedData.access()->m_transform, m_x, l); }
void setTransformOriginY(Length l) { SET_VAR(rareNonInheritedData.access()->m_transform, m_y, l); }
void setTransformOriginZ(float f) { SET_VAR(rareNonInheritedData.access()->m_transform, m_z, f); }
+ void setSpeak(ESpeak s) { SET_VAR(rareInheritedData, speak, s); }
// End CSS3 Setters
// Apple-specific property setters
void clearContent();
void setContent(PassRefPtr<StringImpl>, bool add = false);
void setContent(PassRefPtr<StyleImage>, bool add = false);
- void setContent(CounterContent*, bool add = false);
+ void setContent(PassOwnPtr<CounterContent>, bool add = false);
const CounterDirectiveMap* counterDirectives() const;
CounterDirectiveMap& accessCounterDirectives();
originalDisplay() == INLINE_BOX || originalDisplay() == INLINE_TABLE;
}
+ void setWritingMode(WritingMode v) { inherited_flags.m_writingMode = v; }
+
// To tell if this style matched attribute selectors. This makes it impossible to share.
bool affectedByAttributeSelectors() const { return m_affectedByAttributeSelectors; }
void setAffectedByAttributeSelectors() { m_affectedByAttributeSelectors = true; }
static bool initialBorderCollapse() { return false; }
static EBorderStyle initialBorderStyle() { return BNONE; }
static NinePieceImage initialNinePieceImage() { return NinePieceImage(); }
- static IntSize initialBorderRadius() { return IntSize(0, 0); }
+ static LengthSize initialBorderRadius() { return LengthSize(Length(0, Fixed), Length(0, Fixed)); }
static ECaptionSide initialCaptionSide() { return CAPTOP; }
static EClear initialClear() { return CNONE; }
static TextDirection initialDirection() { return LTR; }
+ static WritingMode initialWritingMode() { return TopToBottomWritingMode; }
static EDisplay initialDisplay() { return INLINE; }
static EEmptyCell initialEmptyCells() { return SHOW; }
static EFloat initialFloating() { return FNONE; }
static EUserDrag initialUserDrag() { return DRAG_AUTO; }
static EUserSelect initialUserSelect() { return SELECT_TEXT; }
static bool initialTextOverflow() { return false; }
- static EMarginCollapse initialMarginTopCollapse() { return MCOLLAPSE; }
- static EMarginCollapse initialMarginBottomCollapse() { return MCOLLAPSE; }
+ static EMarginCollapse initialMarginBeforeCollapse() { return MCOLLAPSE; }
+ static EMarginCollapse initialMarginAfterCollapse() { return MCOLLAPSE; }
static EWordBreak initialWordBreak() { return NormalWordBreak; }
static EWordWrap initialWordWrap() { return NormalWordWrap; }
static ENBSPMode initialNBSPMode() { return NBNORMAL; }
static EKHTMLLineBreak initialKHTMLLineBreak() { return LBNORMAL; }
static EMatchNearestMailBlockquoteColor initialMatchNearestMailBlockquoteColor() { return BCNORMAL; }
static const AtomicString& initialHighlight() { return nullAtom; }
+ static ESpeak initialSpeak() { return SpeakNormal; }
static Hyphens initialHyphens() { return HyphensManual; }
static const AtomicString& initialHyphenationString() { return nullAtom; }
static const AtomicString& initialHyphenationLocale() { return nullAtom; }
#endif
private:
+ void getShadowExtent(const ShadowData*, int& top, int& right, int& bottom, int& left) const;
+ void getShadowHorizontalExtent(const ShadowData*, int& left, int& right) const;
+ void getShadowVerticalExtent(const ShadowData*, int& top, int& bottom) const;
+ void getShadowInlineDirectionExtent(const ShadowData* shadow, int& logicalLeft, int& logicalRight) const
+ {
+ return isHorizontalWritingMode() ? getShadowHorizontalExtent(shadow, logicalLeft, logicalRight) : getShadowVerticalExtent(shadow, logicalLeft, logicalRight);
+ }
+ void getShadowBlockDirectionExtent(const ShadowData* shadow, int& logicalTop, int& logicalBottom) const
+ {
+ return isHorizontalWritingMode() ? getShadowVerticalExtent(shadow, logicalTop, logicalBottom) : getShadowHorizontalExtent(shadow, logicalTop, logicalBottom);
+ }
+
// Color accessors are all private to make sure callers use visitedDependentColor instead to access them.
const Color& borderLeftColor() const { return surround->border.left().color(); }
const Color& borderRightColor() const { return surround->border.right().color(); }
const Color& textStrokeColor() const { return rareInheritedData->textStrokeColor; }
const Color colorIncludingFallback(int colorProperty, EBorderStyle borderStyle) const;
+
+ ContentData* prepareToSetContent(StringImpl*, bool add);
};
+inline int adjustForAbsoluteZoom(int value, const RenderStyle* style)
+{
+ double zoomFactor = style->effectiveZoom();
+ if (zoomFactor == 1)
+ return value;
+ // Needed because computeLengthInt truncates (rather than rounds) when scaling up.
+ if (zoomFactor > 1)
+ value++;
+
+ return roundForImpreciseConversion<int, INT_MAX, INT_MIN>(value / zoomFactor);
+}
+
} // namespace WebCore
#endif // RenderStyle_h