#include "config.h"
#include "RenderStyle.h"
#include "ContentData.h"
#include "CursorList.h"
#include "CSSPropertyNames.h"
#include "CSSWrapShapes.h"
#include "FontSelector.h"
#include "QuotesData.h"
#include "RenderArena.h"
#include "RenderObject.h"
#include "ScaleTransformOperation.h"
#include "ShadowData.h"
#include "StyleImage.h"
#include "StyleResolver.h"
#if ENABLE(TOUCH_EVENTS)
#include "RenderTheme.h"
#endif
#include <wtf/MathExtras.h>
#include <wtf/StdLibExtras.h>
#include <algorithm>
using namespace std;
namespace WebCore {
struct SameSizeAsBorderValue {
RGBA32 m_color;
unsigned m_width;
};
COMPILE_ASSERT(sizeof(BorderValue) == sizeof(SameSizeAsBorderValue), BorderValue_should_not_grow);
struct SameSizeAsRenderStyle : public RefCounted<SameSizeAsRenderStyle> {
unsigned m_bitfields;
void* dataRefs[7];
void* ownPtrs[1];
#if ENABLE(SVG)
void* dataRefSvgStyle;
#endif
struct InheritedFlags {
unsigned m_bitfields[2];
} inherited_flags;
struct NonInheritedFlags {
unsigned m_bitfields[2];
} noninherited_flags;
};
COMPILE_ASSERT(sizeof(RenderStyle) == sizeof(SameSizeAsRenderStyle), RenderStyle_should_stay_small);
inline RenderStyle* defaultStyle()
{
static RenderStyle* s_defaultStyle = RenderStyle::createDefaultStyle().leakRef();
return s_defaultStyle;
}
PassRefPtr<RenderStyle> RenderStyle::create()
{
return adoptRef(new RenderStyle());
}
PassRefPtr<RenderStyle> RenderStyle::createDefaultStyle()
{
return adoptRef(new RenderStyle(true));
}
PassRefPtr<RenderStyle> RenderStyle::createAnonymousStyleWithDisplay(const RenderStyle* parentStyle, EDisplay display)
{
RefPtr<RenderStyle> newStyle = RenderStyle::create();
newStyle->inheritFrom(parentStyle);
newStyle->inheritUnicodeBidiFrom(parentStyle);
newStyle->setDisplay(display);
return newStyle;
}
PassRefPtr<RenderStyle> RenderStyle::clone(const RenderStyle* other)
{
return adoptRef(new RenderStyle(*other));
}
ALWAYS_INLINE RenderStyle::RenderStyle()
: m_box(defaultStyle()->m_box)
, visual(defaultStyle()->visual)
, m_background(defaultStyle()->m_background)
, surround(defaultStyle()->surround)
, rareNonInheritedData(defaultStyle()->rareNonInheritedData)
, rareInheritedData(defaultStyle()->rareInheritedData)
, inherited(defaultStyle()->inherited)
#if ENABLE(SVG)
, m_svgStyle(defaultStyle()->m_svgStyle)
#endif
{
setBitDefaults(); COMPILE_ASSERT((sizeof(InheritedFlags) <= 8), InheritedFlags_does_not_grow);
COMPILE_ASSERT((sizeof(NonInheritedFlags) <= 8), NonInheritedFlags_does_not_grow);
}
ALWAYS_INLINE RenderStyle::RenderStyle(bool)
{
setBitDefaults();
m_box.init();
visual.init();
m_background.init();
surround.init();
rareNonInheritedData.init();
rareNonInheritedData.access()->m_deprecatedFlexibleBox.init();
rareNonInheritedData.access()->m_flexibleBox.init();
rareNonInheritedData.access()->m_marquee.init();
rareNonInheritedData.access()->m_multiCol.init();
rareNonInheritedData.access()->m_transform.init();
#if ENABLE(CSS_FILTERS)
rareNonInheritedData.access()->m_filter.init();
#endif
#if ENABLE(CSS_GRID_LAYOUT)
rareNonInheritedData.access()->m_grid.init();
rareNonInheritedData.access()->m_gridItem.init();
#endif
rareInheritedData.init();
inherited.init();
#if ENABLE(SVG)
m_svgStyle.init();
#endif
}
ALWAYS_INLINE RenderStyle::RenderStyle(const RenderStyle& o)
: RefCounted<RenderStyle>()
, m_box(o.m_box)
, visual(o.visual)
, m_background(o.m_background)
, surround(o.surround)
, rareNonInheritedData(o.rareNonInheritedData)
, rareInheritedData(o.rareInheritedData)
, inherited(o.inherited)
#if ENABLE(SVG)
, m_svgStyle(o.m_svgStyle)
#endif
, inherited_flags(o.inherited_flags)
, noninherited_flags(o.noninherited_flags)
{
}
void RenderStyle::inheritFrom(const RenderStyle* inheritParent)
{
rareInheritedData = inheritParent->rareInheritedData;
inherited = inheritParent->inherited;
inherited_flags = inheritParent->inherited_flags;
#if ENABLE(SVG)
if (m_svgStyle != inheritParent->m_svgStyle)
m_svgStyle.access()->inheritFrom(inheritParent->m_svgStyle.get());
#endif
}
void RenderStyle::copyNonInheritedFrom(const RenderStyle* other)
{
m_box = other->m_box;
visual = other->visual;
m_background = other->m_background;
surround = other->surround;
rareNonInheritedData = other->rareNonInheritedData;
noninherited_flags._effectiveDisplay = other->noninherited_flags._effectiveDisplay;
noninherited_flags._originalDisplay = other->noninherited_flags._originalDisplay;
noninherited_flags._overflowX = other->noninherited_flags._overflowX;
noninherited_flags._overflowY = other->noninherited_flags._overflowY;
noninherited_flags._vertical_align = other->noninherited_flags._vertical_align;
noninherited_flags._clear = other->noninherited_flags._clear;
noninherited_flags._position = other->noninherited_flags._position;
noninherited_flags._floating = other->noninherited_flags._floating;
noninherited_flags._table_layout = other->noninherited_flags._table_layout;
noninherited_flags._unicodeBidi = other->noninherited_flags._unicodeBidi;
noninherited_flags._page_break_before = other->noninherited_flags._page_break_before;
noninherited_flags._page_break_after = other->noninherited_flags._page_break_after;
noninherited_flags._page_break_inside = other->noninherited_flags._page_break_inside;
#if ENABLE(SVG)
if (m_svgStyle != other->m_svgStyle)
m_svgStyle.access()->copyNonInheritedFrom(other->m_svgStyle.get());
#endif
ASSERT(zoom() == initialZoom());
}
bool RenderStyle::operator==(const RenderStyle& o) const
{
return inherited_flags == o.inherited_flags
&& noninherited_flags == o.noninherited_flags
&& m_box == o.m_box
&& visual == o.visual
&& m_background == o.m_background
&& surround == o.surround
&& rareNonInheritedData == o.rareNonInheritedData
&& rareInheritedData == o.rareInheritedData
&& inherited == o.inherited
#if ENABLE(SVG)
&& m_svgStyle == o.m_svgStyle
#endif
;
}
bool RenderStyle::isStyleAvailable() const
{
return this != StyleResolver::styleNotYetAvailable();
}
static inline int pseudoBit(PseudoId pseudo)
{
return 1 << (pseudo - 1);
}
bool RenderStyle::hasAnyPublicPseudoStyles() const
{
return PUBLIC_PSEUDOID_MASK & noninherited_flags._pseudoBits;
}
bool RenderStyle::hasPseudoStyle(PseudoId pseudo) const
{
ASSERT(pseudo > NOPSEUDO);
ASSERT(pseudo < FIRST_INTERNAL_PSEUDOID);
return pseudoBit(pseudo) & noninherited_flags._pseudoBits;
}
void RenderStyle::setHasPseudoStyle(PseudoId pseudo)
{
ASSERT(pseudo > NOPSEUDO);
ASSERT(pseudo < FIRST_INTERNAL_PSEUDOID);
noninherited_flags._pseudoBits |= pseudoBit(pseudo);
}
RenderStyle* RenderStyle::getCachedPseudoStyle(PseudoId pid) const
{
if (!m_cachedPseudoStyles || !m_cachedPseudoStyles->size())
return 0;
if (styleType() != NOPSEUDO)
return 0;
for (size_t i = 0; i < m_cachedPseudoStyles->size(); ++i) {
RenderStyle* pseudoStyle = m_cachedPseudoStyles->at(i).get();
if (pseudoStyle->styleType() == pid)
return pseudoStyle;
}
return 0;
}
RenderStyle* RenderStyle::addCachedPseudoStyle(PassRefPtr<RenderStyle> pseudo)
{
if (!pseudo)
return 0;
ASSERT(pseudo->styleType() > NOPSEUDO);
RenderStyle* result = pseudo.get();
if (!m_cachedPseudoStyles)
m_cachedPseudoStyles = adoptPtr(new PseudoStyleCache);
m_cachedPseudoStyles->append(pseudo);
return result;
}
void RenderStyle::removeCachedPseudoStyle(PseudoId pid)
{
if (!m_cachedPseudoStyles)
return;
for (size_t i = 0; i < m_cachedPseudoStyles->size(); ++i) {
RenderStyle* pseudoStyle = m_cachedPseudoStyles->at(i).get();
if (pseudoStyle->styleType() == pid) {
m_cachedPseudoStyles->remove(i);
return;
}
}
}
bool RenderStyle::inheritedNotEqual(const RenderStyle* other) const
{
return inherited_flags != other->inherited_flags
|| inherited != other->inherited
#if ENABLE(SVG)
|| m_svgStyle->inheritedNotEqual(other->m_svgStyle.get())
#endif
|| rareInheritedData != other->rareInheritedData;
}
bool RenderStyle::inheritedDataShared(const RenderStyle* other) const
{
return inherited_flags == other->inherited_flags
&& inherited.get() == other->inherited.get()
#if ENABLE(SVG)
&& m_svgStyle.get() == other->m_svgStyle.get()
#endif
&& rareInheritedData.get() == other->rareInheritedData.get();
}
static bool positionedObjectMoved(const LengthBox& a, const LengthBox& b)
{
if (a.left().type() != b.left().type()
|| a.right().type() != b.right().type()
|| a.top().type() != b.top().type()
|| a.bottom().type() != b.bottom().type())
return false;
if (!a.left().isIntrinsicOrAuto() && !a.right().isIntrinsicOrAuto())
return false;
if (!a.top().isIntrinsicOrAuto() && !a.bottom().isIntrinsicOrAuto())
return false;
return true;
}
StyleDifference RenderStyle::diff(const RenderStyle* other, unsigned& changedContextSensitiveProperties) const
{
changedContextSensitiveProperties = ContextSensitivePropertyNone;
#if ENABLE(SVG)
StyleDifference svgChange = StyleDifferenceEqual;
if (m_svgStyle != other->m_svgStyle) {
svgChange = m_svgStyle->diff(other->m_svgStyle.get());
if (svgChange == StyleDifferenceLayout)
return svgChange;
}
#endif
if (m_box->width() != other->m_box->width()
|| m_box->minWidth() != other->m_box->minWidth()
|| m_box->maxWidth() != other->m_box->maxWidth()
|| m_box->height() != other->m_box->height()
|| m_box->minHeight() != other->m_box->minHeight()
|| m_box->maxHeight() != other->m_box->maxHeight())
return StyleDifferenceLayout;
if (m_box->verticalAlign() != other->m_box->verticalAlign() || noninherited_flags._vertical_align != other->noninherited_flags._vertical_align)
return StyleDifferenceLayout;
if (m_box->boxSizing() != other->m_box->boxSizing())
return StyleDifferenceLayout;
if (surround->margin != other->surround->margin)
return StyleDifferenceLayout;
if (surround->padding != other->surround->padding)
return StyleDifferenceLayout;
if (rareNonInheritedData.get() != other->rareNonInheritedData.get()) {
if (rareNonInheritedData->m_appearance != other->rareNonInheritedData->m_appearance
|| rareNonInheritedData->marginBeforeCollapse != other->rareNonInheritedData->marginBeforeCollapse
|| rareNonInheritedData->marginAfterCollapse != other->rareNonInheritedData->marginAfterCollapse
|| rareNonInheritedData->lineClamp != other->rareNonInheritedData->lineClamp
|| rareNonInheritedData->textOverflow != other->rareNonInheritedData->textOverflow)
return StyleDifferenceLayout;
if (rareNonInheritedData->m_regionOverflow != other->rareNonInheritedData->m_regionOverflow)
return StyleDifferenceLayout;
if (rareNonInheritedData->m_wrapFlow != other->rareNonInheritedData->m_wrapFlow
|| rareNonInheritedData->m_wrapThrough != other->rareNonInheritedData->m_wrapThrough
|| rareNonInheritedData->m_wrapMargin != other->rareNonInheritedData->m_wrapMargin
|| rareNonInheritedData->m_wrapPadding != other->rareNonInheritedData->m_wrapPadding)
return StyleDifferenceLayout;
if (rareNonInheritedData->m_deprecatedFlexibleBox.get() != other->rareNonInheritedData->m_deprecatedFlexibleBox.get()
&& *rareNonInheritedData->m_deprecatedFlexibleBox.get() != *other->rareNonInheritedData->m_deprecatedFlexibleBox.get())
return StyleDifferenceLayout;
if (rareNonInheritedData->m_flexibleBox.get() != other->rareNonInheritedData->m_flexibleBox.get()
&& *rareNonInheritedData->m_flexibleBox.get() != *other->rareNonInheritedData->m_flexibleBox.get())
return StyleDifferenceLayout;
if (!rareNonInheritedData->shadowDataEquivalent(*other->rareNonInheritedData.get()))
return StyleDifferenceLayout;
if (!rareNonInheritedData->reflectionDataEquivalent(*other->rareNonInheritedData.get()))
return StyleDifferenceLayout;
if (rareNonInheritedData->m_multiCol.get() != other->rareNonInheritedData->m_multiCol.get()
&& *rareNonInheritedData->m_multiCol.get() != *other->rareNonInheritedData->m_multiCol.get())
return StyleDifferenceLayout;
if (rareNonInheritedData->m_transform.get() != other->rareNonInheritedData->m_transform.get()
&& *rareNonInheritedData->m_transform.get() != *other->rareNonInheritedData->m_transform.get()) {
#if USE(ACCELERATED_COMPOSITING)
changedContextSensitiveProperties |= ContextSensitivePropertyTransform;
#else
return StyleDifferenceLayout;
#endif
}
#if ENABLE(CSS_GRID_LAYOUT)
if (rareNonInheritedData->m_grid.get() != other->rareNonInheritedData->m_grid.get()
&& rareNonInheritedData->m_gridItem.get() != other->rareNonInheritedData->m_gridItem.get())
return StyleDifferenceLayout;
#endif
#if !USE(ACCELERATED_COMPOSITING)
if (rareNonInheritedData.get() != other->rareNonInheritedData.get()) {
if (rareNonInheritedData->m_transformStyle3D != other->rareNonInheritedData->m_transformStyle3D
|| rareNonInheritedData->m_backfaceVisibility != other->rareNonInheritedData->m_backfaceVisibility
|| rareNonInheritedData->m_perspective != other->rareNonInheritedData->m_perspective
|| rareNonInheritedData->m_perspectiveOriginX != other->rareNonInheritedData->m_perspectiveOriginX
|| rareNonInheritedData->m_perspectiveOriginY != other->rareNonInheritedData->m_perspectiveOriginY)
return StyleDifferenceLayout;
}
#endif
#if ENABLE(DASHBOARD_SUPPORT)
if (rareNonInheritedData->m_dashboardRegions != other->rareNonInheritedData->m_dashboardRegions)
return StyleDifferenceLayout;
#endif
}
if (rareInheritedData.get() != other->rareInheritedData.get()) {
if (rareInheritedData->highlight != other->rareInheritedData->highlight
|| rareInheritedData->indent != other->rareInheritedData->indent
|| rareInheritedData->m_effectiveZoom != other->rareInheritedData->m_effectiveZoom
|| rareInheritedData->textSizeAdjust != other->rareInheritedData->textSizeAdjust
|| rareInheritedData->wordBreak != other->rareInheritedData->wordBreak
|| rareInheritedData->wordWrap != other->rareInheritedData->wordWrap
|| rareInheritedData->nbspMode != other->rareInheritedData->nbspMode
|| rareInheritedData->khtmlLineBreak != other->rareInheritedData->khtmlLineBreak
|| rareInheritedData->textSecurity != other->rareInheritedData->textSecurity
|| rareInheritedData->hyphens != other->rareInheritedData->hyphens
|| rareInheritedData->hyphenationLimitBefore != other->rareInheritedData->hyphenationLimitBefore
|| rareInheritedData->hyphenationLimitAfter != other->rareInheritedData->hyphenationLimitAfter
|| rareInheritedData->hyphenationString != other->rareInheritedData->hyphenationString
|| rareInheritedData->locale != other->rareInheritedData->locale
|| rareInheritedData->textEmphasisMark != other->rareInheritedData->textEmphasisMark
|| rareInheritedData->textEmphasisPosition != other->rareInheritedData->textEmphasisPosition
|| rareInheritedData->textEmphasisCustomMark != other->rareInheritedData->textEmphasisCustomMark
|| rareInheritedData->m_lineBoxContain != other->rareInheritedData->m_lineBoxContain
|| rareInheritedData->m_lineGrid != other->rareInheritedData->m_lineGrid
|| rareInheritedData->m_lineSnap != other->rareInheritedData->m_lineSnap
|| rareInheritedData->m_lineAlign != other->rareInheritedData->m_lineAlign)
return StyleDifferenceLayout;
if (!rareInheritedData->shadowDataEquivalent(*other->rareInheritedData.get()))
return StyleDifferenceLayout;
if (textStrokeWidth() != other->textStrokeWidth())
return StyleDifferenceLayout;
}
if (inherited->line_height != other->inherited->line_height
|| inherited->list_style_image != other->inherited->list_style_image
|| inherited->font != other->inherited->font
|| inherited->horizontal_border_spacing != other->inherited->horizontal_border_spacing
|| inherited->vertical_border_spacing != other->inherited->vertical_border_spacing
|| inherited_flags._box_direction != other->inherited_flags._box_direction
|| inherited_flags.m_rtlOrdering != other->inherited_flags.m_rtlOrdering
|| noninherited_flags._position != other->noninherited_flags._position
|| noninherited_flags._floating != other->noninherited_flags._floating
|| noninherited_flags._originalDisplay != other->noninherited_flags._originalDisplay)
return StyleDifferenceLayout;
if (((int)noninherited_flags._effectiveDisplay) >= TABLE) {
if (inherited_flags._border_collapse != other->inherited_flags._border_collapse
|| inherited_flags._empty_cells != other->inherited_flags._empty_cells
|| inherited_flags._caption_side != other->inherited_flags._caption_side
|| noninherited_flags._table_layout != other->noninherited_flags._table_layout)
return StyleDifferenceLayout;
if (inherited_flags._border_collapse
&& ((borderTopStyle() == BHIDDEN && other->borderTopStyle() == BNONE)
|| (borderTopStyle() == BNONE && other->borderTopStyle() == BHIDDEN)
|| (borderBottomStyle() == BHIDDEN && other->borderBottomStyle() == BNONE)
|| (borderBottomStyle() == BNONE && other->borderBottomStyle() == BHIDDEN)
|| (borderLeftStyle() == BHIDDEN && other->borderLeftStyle() == BNONE)
|| (borderLeftStyle() == BNONE && other->borderLeftStyle() == BHIDDEN)
|| (borderRightStyle() == BHIDDEN && other->borderRightStyle() == BNONE)
|| (borderRightStyle() == BNONE && other->borderRightStyle() == BHIDDEN)))
return StyleDifferenceLayout;
}
if (noninherited_flags._effectiveDisplay == LIST_ITEM) {
if (inherited_flags._list_style_type != other->inherited_flags._list_style_type
|| inherited_flags._list_style_position != other->inherited_flags._list_style_position)
return StyleDifferenceLayout;
}
if (inherited_flags._text_align != other->inherited_flags._text_align
|| inherited_flags._text_transform != other->inherited_flags._text_transform
|| inherited_flags._direction != other->inherited_flags._direction
|| inherited_flags._white_space != other->inherited_flags._white_space
|| noninherited_flags._clear != other->noninherited_flags._clear
|| noninherited_flags._unicodeBidi != other->noninherited_flags._unicodeBidi)
return StyleDifferenceLayout;
if (inherited_flags.m_writingMode != other->inherited_flags.m_writingMode)
return StyleDifferenceLayout;
if (rareNonInheritedData->m_textCombine != other->rareNonInheritedData->m_textCombine)
return StyleDifferenceLayout;
if (noninherited_flags._overflowX != other->noninherited_flags._overflowX
|| noninherited_flags._overflowY != other->noninherited_flags._overflowY)
return StyleDifferenceLayout;
if (borderLeftWidth() != other->borderLeftWidth()
|| borderTopWidth() != other->borderTopWidth()
|| borderBottomWidth() != other->borderBottomWidth()
|| borderRightWidth() != other->borderRightWidth())
return StyleDifferenceLayout;
const CounterDirectiveMap* mapA = rareNonInheritedData->m_counterDirectives.get();
const CounterDirectiveMap* mapB = other->rareNonInheritedData->m_counterDirectives.get();
if (!(mapA == mapB || (mapA && mapB && *mapA == *mapB)))
return StyleDifferenceLayout;
if (rareNonInheritedData->m_counterIncrement != other->rareNonInheritedData->m_counterIncrement
|| rareNonInheritedData->m_counterReset != other->rareNonInheritedData->m_counterReset)
return StyleDifferenceLayout;
if ((visibility() == COLLAPSE) != (other->visibility() == COLLAPSE))
return StyleDifferenceLayout;
if ((rareNonInheritedData->opacity == 1 && other->rareNonInheritedData->opacity < 1)
|| (rareNonInheritedData->opacity < 1 && other->rareNonInheritedData->opacity == 1)) {
return StyleDifferenceLayout;
}
#if ENABLE(SVG)
if (svgChange != StyleDifferenceEqual)
return svgChange;
#endif
if (position() != StaticPosition) {
if (surround->offset != other->surround->offset) {
if (position() == AbsolutePosition && positionedObjectMoved(surround->offset, other->surround->offset))
return StyleDifferenceLayoutPositionedMovementOnly;
return StyleDifferenceLayout;
} else if (m_box->zIndex() != other->m_box->zIndex() || m_box->hasAutoZIndex() != other->m_box->hasAutoZIndex()
|| visual->clip != other->visual->clip || visual->hasClip != other->visual->hasClip)
return StyleDifferenceRepaintLayer;
}
if (rareNonInheritedData->opacity != other->rareNonInheritedData->opacity) {
#if USE(ACCELERATED_COMPOSITING)
changedContextSensitiveProperties |= ContextSensitivePropertyOpacity;
#else
return StyleDifferenceRepaintLayer;
#endif
}
#if ENABLE(CSS_FILTERS)
if (rareNonInheritedData->m_filter.get() != other->rareNonInheritedData->m_filter.get()
&& *rareNonInheritedData->m_filter.get() != *other->rareNonInheritedData->m_filter.get()) {
#if USE(ACCELERATED_COMPOSITING)
changedContextSensitiveProperties |= ContextSensitivePropertyFilter;
#else
return StyleDifferenceRepaintLayer;
#endif
}
#endif
if (rareNonInheritedData->m_mask != other->rareNonInheritedData->m_mask
|| rareNonInheritedData->m_maskBoxImage != other->rareNonInheritedData->m_maskBoxImage)
return StyleDifferenceRepaintLayer;
if (inherited->color != other->inherited->color
|| inherited_flags._visibility != other->inherited_flags._visibility
|| inherited_flags._text_decorations != other->inherited_flags._text_decorations
|| inherited_flags.m_printColorAdjust != other->inherited_flags.m_printColorAdjust
|| inherited_flags._insideLink != other->inherited_flags._insideLink
|| surround->border != other->surround->border
|| *m_background.get() != *other->m_background.get()
|| visual->textDecoration != other->visual->textDecoration
|| rareInheritedData->userModify != other->rareInheritedData->userModify
|| rareInheritedData->userSelect != other->rareInheritedData->userSelect
|| rareNonInheritedData->userDrag != other->rareNonInheritedData->userDrag
|| rareNonInheritedData->m_borderFit != other->rareNonInheritedData->m_borderFit
|| rareInheritedData->textFillColor != other->rareInheritedData->textFillColor
|| rareInheritedData->textStrokeColor != other->rareInheritedData->textStrokeColor
|| rareInheritedData->textEmphasisColor != other->rareInheritedData->textEmphasisColor
|| rareInheritedData->textEmphasisFill != other->rareInheritedData->textEmphasisFill
|| rareInheritedData->m_imageRendering != other->rareInheritedData->m_imageRendering)
return StyleDifferenceRepaint;
if (rareNonInheritedData->m_wrapShapeInside != other->rareNonInheritedData->m_wrapShapeInside
|| rareNonInheritedData->m_wrapShapeOutside != other->rareNonInheritedData->m_wrapShapeOutside)
return StyleDifferenceRepaint;
#if USE(ACCELERATED_COMPOSITING)
if (rareNonInheritedData.get() != other->rareNonInheritedData.get()) {
if (rareNonInheritedData->m_transformStyle3D != other->rareNonInheritedData->m_transformStyle3D
|| rareNonInheritedData->m_backfaceVisibility != other->rareNonInheritedData->m_backfaceVisibility
|| rareNonInheritedData->m_perspective != other->rareNonInheritedData->m_perspective
|| rareNonInheritedData->m_perspectiveOriginX != other->rareNonInheritedData->m_perspectiveOriginX
|| rareNonInheritedData->m_perspectiveOriginY != other->rareNonInheritedData->m_perspectiveOriginY)
return StyleDifferenceRecompositeLayer;
}
#endif
return StyleDifferenceEqual;
}
void RenderStyle::setClip(Length top, Length right, Length bottom, Length left)
{
StyleVisualData* data = visual.access();
data->clip.m_top = top;
data->clip.m_right = right;
data->clip.m_bottom = bottom;
data->clip.m_left = left;
}
void RenderStyle::addCursor(PassRefPtr<StyleImage> image, const IntPoint& hotSpot)
{
if (!rareInheritedData.access()->cursorData)
rareInheritedData.access()->cursorData = CursorList::create();
rareInheritedData.access()->cursorData->append(CursorData(image, hotSpot));
}
void RenderStyle::setCursorList(PassRefPtr<CursorList> other)
{
rareInheritedData.access()->cursorData = other;
}
void RenderStyle::setQuotes(PassRefPtr<QuotesData> q)
{
if (QuotesData::equal(rareInheritedData->quotes.get(), q.get()))
return;
rareInheritedData.access()->quotes = q;
}
void RenderStyle::clearCursorList()
{
if (rareInheritedData->cursorData)
rareInheritedData.access()->cursorData = 0;
}
void RenderStyle::clearContent()
{
if (rareNonInheritedData->m_content)
rareNonInheritedData.access()->m_content = nullptr;
}
void RenderStyle::appendContent(PassOwnPtr<ContentData> contentData)
{
OwnPtr<ContentData>& content = rareNonInheritedData.access()->m_content;
ContentData* lastContent = content.get();
while (lastContent && lastContent->next())
lastContent = lastContent->next();
if (lastContent)
lastContent->setNext(contentData);
else
content = contentData;
}
void RenderStyle::setContent(PassRefPtr<StyleImage> image, bool add)
{
if (!image)
return;
if (add) {
appendContent(ContentData::create(image));
return;
}
rareNonInheritedData.access()->m_content = ContentData::create(image);
}
void RenderStyle::setContent(const String& string, bool add)
{
OwnPtr<ContentData>& content = rareNonInheritedData.access()->m_content;
if (add) {
ContentData* lastContent = content.get();
while (lastContent && lastContent->next())
lastContent = lastContent->next();
if (lastContent) {
if (lastContent->isText()) {
TextContentData* textContent = static_cast<TextContentData*>(lastContent);
String text = textContent->text();
text += string;
textContent->setText(text);
} else
lastContent->setNext(ContentData::create(string));
return;
}
}
content = ContentData::create(string);
}
void RenderStyle::setContent(PassOwnPtr<CounterContent> counter, bool add)
{
if (!counter)
return;
if (add) {
appendContent(ContentData::create(counter));
return;
}
rareNonInheritedData.access()->m_content = ContentData::create(counter);
}
void RenderStyle::setContent(QuoteType quote, bool add)
{
if (add) {
appendContent(ContentData::create(quote));
return;
}
rareNonInheritedData.access()->m_content = ContentData::create(quote);
}
inline bool requireTransformOrigin(const Vector<RefPtr<TransformOperation> >& transformOperations, RenderStyle::ApplyTransformOrigin applyOrigin)
{
if (applyOrigin != RenderStyle::IncludeTransformOrigin)
return false;
unsigned size = transformOperations.size();
for (unsigned i = 0; i < size; ++i) {
TransformOperation::OperationType type = transformOperations[i]->getOperationType();
if (type != TransformOperation::TRANSLATE_X
&& type != TransformOperation::TRANSLATE_Y
&& type != TransformOperation::TRANSLATE
&& type != TransformOperation::TRANSLATE_Z
&& type != TransformOperation::TRANSLATE_3D)
return true;
}
return false;
}
void RenderStyle::applyTransform(TransformationMatrix& transform, const LayoutSize& borderBoxSize, ApplyTransformOrigin applyOrigin) const
{
const Vector<RefPtr<TransformOperation> >& transformOperations = rareNonInheritedData->m_transform->m_operations.operations();
bool applyTransformOrigin = requireTransformOrigin(transformOperations, applyOrigin);
if (applyTransformOrigin)
transform.translate3d(floatValueForLength(transformOriginX(), borderBoxSize.width()), floatValueForLength(transformOriginY(), borderBoxSize.height()), transformOriginZ());
unsigned size = transformOperations.size();
for (unsigned i = 0; i < size; ++i)
transformOperations[i]->apply(transform, borderBoxSize);
if (applyTransformOrigin)
transform.translate3d(-floatValueForLength(transformOriginX(), borderBoxSize.width()), -floatValueForLength(transformOriginY(), borderBoxSize.height()), -transformOriginZ());
}
void RenderStyle::applyTransform(TransformationMatrix& transform, const FloatRect& boundingBox, ApplyTransformOrigin applyOrigin) const
{
const Vector<RefPtr<TransformOperation> >& transformOperations = rareNonInheritedData->m_transform->m_operations.operations();
bool applyTransformOrigin = requireTransformOrigin(transformOperations, applyOrigin);
float offsetX = transformOriginX().type() == Percent ? boundingBox.x() : 0;
float offsetY = transformOriginY().type() == Percent ? boundingBox.y() : 0;
if (applyTransformOrigin) {
transform.translate3d(floatValueForLength(transformOriginX(), boundingBox.width()) + offsetX,
floatValueForLength(transformOriginY(), boundingBox.height()) + offsetY,
transformOriginZ());
}
unsigned size = transformOperations.size();
for (unsigned i = 0; i < size; ++i)
transformOperations[i]->apply(transform, boundingBox.size());
if (applyTransformOrigin) {
transform.translate3d(-floatValueForLength(transformOriginX(), boundingBox.width()) - offsetX,
-floatValueForLength(transformOriginY(), boundingBox.height()) - offsetY,
-transformOriginZ());
}
}
void RenderStyle::setPageScaleTransform(float scale)
{
if (scale == 1)
return;
TransformOperations transform;
transform.operations().append(ScaleTransformOperation::create(scale, scale, ScaleTransformOperation::SCALE));
setTransform(transform);
setTransformOriginX(Length(0, Fixed));
setTransformOriginY(Length(0, Fixed));
}
void RenderStyle::setTextShadow(PassOwnPtr<ShadowData> shadowData, bool add)
{
ASSERT(!shadowData || (!shadowData->spread() && shadowData->style() == Normal));
StyleRareInheritedData* rareData = rareInheritedData.access();
if (!add) {
rareData->textShadow = shadowData;
return;
}
shadowData->setNext(rareData->textShadow.release());
rareData->textShadow = shadowData;
}
void RenderStyle::setBoxShadow(PassOwnPtr<ShadowData> shadowData, bool add)
{
StyleRareNonInheritedData* rareData = rareNonInheritedData.access();
if (!add) {
rareData->m_boxShadow = shadowData;
return;
}
shadowData->setNext(rareData->m_boxShadow.release());
rareData->m_boxShadow = shadowData;
}
static RoundedRect::Radii calcRadiiFor(const BorderData& border, IntSize size, RenderView* renderView)
{
return RoundedRect::Radii(
IntSize(valueForLength(border.topLeft().width(), size.width(), renderView),
valueForLength(border.topLeft().height(), size.height(), renderView)),
IntSize(valueForLength(border.topRight().width(), size.width(), renderView),
valueForLength(border.topRight().height(), size.height(), renderView)),
IntSize(valueForLength(border.bottomLeft().width(), size.width(), renderView),
valueForLength(border.bottomLeft().height(), size.height(), renderView)),
IntSize(valueForLength(border.bottomRight().width(), size.width(), renderView),
valueForLength(border.bottomRight().height(), size.height(), renderView)));
}
static float calcConstraintScaleFor(const IntRect& rect, const RoundedRect::Radii& radii)
{
float factor = 1;
unsigned radiiSum;
radiiSum = static_cast<unsigned>(radii.topLeft().width()) + static_cast<unsigned>(radii.topRight().width()); if (radiiSum > static_cast<unsigned>(rect.width()))
factor = min(static_cast<float>(rect.width()) / radiiSum, factor);
radiiSum = static_cast<unsigned>(radii.bottomLeft().width()) + static_cast<unsigned>(radii.bottomRight().width());
if (radiiSum > static_cast<unsigned>(rect.width()))
factor = min(static_cast<float>(rect.width()) / radiiSum, factor);
radiiSum = static_cast<unsigned>(radii.topLeft().height()) + static_cast<unsigned>(radii.bottomLeft().height());
if (radiiSum > static_cast<unsigned>(rect.height()))
factor = min(static_cast<float>(rect.height()) / radiiSum, factor);
radiiSum = static_cast<unsigned>(radii.topRight().height()) + static_cast<unsigned>(radii.bottomRight().height());
if (radiiSum > static_cast<unsigned>(rect.height()))
factor = min(static_cast<float>(rect.height()) / radiiSum, factor);
ASSERT(factor <= 1);
return factor;
}
RoundedRect RenderStyle::getRoundedBorderFor(const LayoutRect& borderRect, RenderView* renderView, bool includeLogicalLeftEdge, bool includeLogicalRightEdge) const
{
IntRect snappedBorderRect(pixelSnappedIntRect(borderRect));
RoundedRect roundedRect(snappedBorderRect);
if (hasBorderRadius()) {
RoundedRect::Radii radii = calcRadiiFor(surround->border, snappedBorderRect.size(), renderView);
radii.scale(calcConstraintScaleFor(snappedBorderRect, radii));
roundedRect.includeLogicalEdges(radii, isHorizontalWritingMode(), includeLogicalLeftEdge, includeLogicalRightEdge);
}
return roundedRect;
}
RoundedRect RenderStyle::getRoundedInnerBorderFor(const LayoutRect& borderRect, bool includeLogicalLeftEdge, bool includeLogicalRightEdge) const
{
bool horizontal = isHorizontalWritingMode();
LayoutUnit leftWidth = (!horizontal || includeLogicalLeftEdge) ? borderLeftWidth() : 0;
LayoutUnit rightWidth = (!horizontal || includeLogicalRightEdge) ? borderRightWidth() : 0;
LayoutUnit topWidth = (horizontal || includeLogicalLeftEdge) ? borderTopWidth() : 0;
LayoutUnit bottomWidth = (horizontal || includeLogicalRightEdge) ? borderBottomWidth() : 0;
return getRoundedInnerBorderFor(borderRect, topWidth, bottomWidth, leftWidth, rightWidth, includeLogicalLeftEdge, includeLogicalRightEdge);
}
RoundedRect RenderStyle::getRoundedInnerBorderFor(const LayoutRect& borderRect,
LayoutUnit topWidth, LayoutUnit bottomWidth, LayoutUnit leftWidth, LayoutUnit rightWidth, bool includeLogicalLeftEdge, bool includeLogicalRightEdge) const
{
LayoutRect innerRect(borderRect.x() + leftWidth,
borderRect.y() + topWidth,
borderRect.width() - leftWidth - rightWidth,
borderRect.height() - topWidth - bottomWidth);
RoundedRect roundedRect(pixelSnappedIntRect(innerRect));
if (hasBorderRadius()) {
RoundedRect::Radii radii = getRoundedBorderFor(borderRect).radii();
radii.shrink(topWidth, bottomWidth, leftWidth, rightWidth);
roundedRect.includeLogicalEdges(radii, isHorizontalWritingMode(), includeLogicalLeftEdge, includeLogicalRightEdge);
}
return roundedRect;
}
const CounterDirectiveMap* RenderStyle::counterDirectives() const
{
return rareNonInheritedData->m_counterDirectives.get();
}
CounterDirectiveMap& RenderStyle::accessCounterDirectives()
{
OwnPtr<CounterDirectiveMap>& map = rareNonInheritedData.access()->m_counterDirectives;
if (!map)
map = adoptPtr(new CounterDirectiveMap);
return *map;
}
const AtomicString& RenderStyle::hyphenString() const
{
ASSERT(hyphens() != HyphensNone);
const AtomicString& hyphenationString = rareInheritedData.get()->hyphenationString;
if (!hyphenationString.isNull())
return hyphenationString;
DEFINE_STATIC_LOCAL(AtomicString, hyphenMinusString, (&hyphenMinus, 1));
DEFINE_STATIC_LOCAL(AtomicString, hyphenString, (&hyphen, 1));
return font().primaryFontHasGlyphForCharacter(hyphen) ? hyphenString : hyphenMinusString;
}
const AtomicString& RenderStyle::textEmphasisMarkString() const
{
switch (textEmphasisMark()) {
case TextEmphasisMarkNone:
return nullAtom;
case TextEmphasisMarkCustom:
return textEmphasisCustomMark();
case TextEmphasisMarkDot: {
DEFINE_STATIC_LOCAL(AtomicString, filledDotString, (&bullet, 1));
DEFINE_STATIC_LOCAL(AtomicString, openDotString, (&whiteBullet, 1));
return textEmphasisFill() == TextEmphasisFillFilled ? filledDotString : openDotString;
}
case TextEmphasisMarkCircle: {
DEFINE_STATIC_LOCAL(AtomicString, filledCircleString, (&blackCircle, 1));
DEFINE_STATIC_LOCAL(AtomicString, openCircleString, (&whiteCircle, 1));
return textEmphasisFill() == TextEmphasisFillFilled ? filledCircleString : openCircleString;
}
case TextEmphasisMarkDoubleCircle: {
DEFINE_STATIC_LOCAL(AtomicString, filledDoubleCircleString, (&fisheye, 1));
DEFINE_STATIC_LOCAL(AtomicString, openDoubleCircleString, (&bullseye, 1));
return textEmphasisFill() == TextEmphasisFillFilled ? filledDoubleCircleString : openDoubleCircleString;
}
case TextEmphasisMarkTriangle: {
DEFINE_STATIC_LOCAL(AtomicString, filledTriangleString, (&blackUpPointingTriangle, 1));
DEFINE_STATIC_LOCAL(AtomicString, openTriangleString, (&whiteUpPointingTriangle, 1));
return textEmphasisFill() == TextEmphasisFillFilled ? filledTriangleString : openTriangleString;
}
case TextEmphasisMarkSesame: {
DEFINE_STATIC_LOCAL(AtomicString, filledSesameString, (&sesameDot, 1));
DEFINE_STATIC_LOCAL(AtomicString, openSesameString, (&whiteSesameDot, 1));
return textEmphasisFill() == TextEmphasisFillFilled ? filledSesameString : openSesameString;
}
case TextEmphasisMarkAuto:
ASSERT_NOT_REACHED();
return nullAtom;
}
ASSERT_NOT_REACHED();
return nullAtom;
}
#if ENABLE(DASHBOARD_SUPPORT)
const Vector<StyleDashboardRegion>& RenderStyle::initialDashboardRegions()
{
DEFINE_STATIC_LOCAL(Vector<StyleDashboardRegion>, emptyList, ());
return emptyList;
}
const Vector<StyleDashboardRegion>& RenderStyle::noneDashboardRegions()
{
DEFINE_STATIC_LOCAL(Vector<StyleDashboardRegion>, noneList, ());
static bool noneListInitialized = false;
if (!noneListInitialized) {
StyleDashboardRegion region;
region.label = "";
region.offset.m_top = Length();
region.offset.m_right = Length();
region.offset.m_bottom = Length();
region.offset.m_left = Length();
region.type = StyleDashboardRegion::None;
noneList.append(region);
noneListInitialized = true;
}
return noneList;
}
#endif
void RenderStyle::adjustAnimations()
{
AnimationList* animationList = rareNonInheritedData->m_animations.get();
if (!animationList)
return;
for (size_t i = 0; i < animationList->size(); ++i) {
if (animationList->animation(i)->isEmpty()) {
animationList->resize(i);
break;
}
}
if (animationList->isEmpty()) {
clearAnimations();
return;
}
animationList->fillUnsetProperties();
}
void RenderStyle::adjustTransitions()
{
AnimationList* transitionList = rareNonInheritedData->m_transitions.get();
if (!transitionList)
return;
for (size_t i = 0; i < transitionList->size(); ++i) {
if (transitionList->animation(i)->isEmpty()) {
transitionList->resize(i);
break;
}
}
if (transitionList->isEmpty()) {
clearTransitions();
return;
}
transitionList->fillUnsetProperties();
for (size_t i = 0; i < transitionList->size(); ++i) {
for (size_t j = i+1; j < transitionList->size(); ++j) {
if (transitionList->animation(i)->property() == transitionList->animation(j)->property()) {
transitionList->remove(i);
j = i;
}
}
}
}
AnimationList* RenderStyle::accessAnimations()
{
if (!rareNonInheritedData.access()->m_animations)
rareNonInheritedData.access()->m_animations = adoptPtr(new AnimationList());
return rareNonInheritedData->m_animations.get();
}
AnimationList* RenderStyle::accessTransitions()
{
if (!rareNonInheritedData.access()->m_transitions)
rareNonInheritedData.access()->m_transitions = adoptPtr(new AnimationList());
return rareNonInheritedData->m_transitions.get();
}
const Animation* RenderStyle::transitionForProperty(CSSPropertyID property) const
{
if (transitions()) {
for (size_t i = 0; i < transitions()->size(); ++i) {
const Animation* p = transitions()->animation(i);
if (p->animationMode() == Animation::AnimateAll || p->property() == property) {
return p;
}
}
}
return 0;
}
void RenderStyle::setBlendedFontSize(int size)
{
float sizef = (float)size;
ASSERT(isfinite(sizef));
if (!isfinite(sizef) || size < 0)
size = 0;
else
size = min(maximumAllowedFontSize, sizef);
FontSelector* currentFontSelector = font().fontSelector();
FontDescription desc(fontDescription());
desc.setSpecifiedSize(size);
desc.setComputedSize(size);
setFontDescription(desc);
font().update(currentFontSelector);
}
void RenderStyle::getShadowExtent(const ShadowData* shadow, LayoutUnit &top, LayoutUnit &right, LayoutUnit &bottom, LayoutUnit &left) const
{
top = 0;
right = 0;
bottom = 0;
left = 0;
for ( ; shadow; shadow = shadow->next()) {
if (shadow->style() == Inset)
continue;
int blurAndSpread = shadow->blur() + shadow->spread();
top = min<LayoutUnit>(top, shadow->y() - blurAndSpread);
right = max<LayoutUnit>(right, shadow->x() + blurAndSpread);
bottom = max<LayoutUnit>(bottom, shadow->y() + blurAndSpread);
left = min<LayoutUnit>(left, shadow->x() - blurAndSpread);
}
}
void RenderStyle::getShadowHorizontalExtent(const ShadowData* shadow, LayoutUnit &left, LayoutUnit &right) const
{
left = 0;
right = 0;
for ( ; shadow; shadow = shadow->next()) {
if (shadow->style() == Inset)
continue;
int blurAndSpread = shadow->blur() + shadow->spread();
left = min<LayoutUnit>(left, shadow->x() - blurAndSpread);
right = max<LayoutUnit>(right, shadow->x() + blurAndSpread);
}
}
void RenderStyle::getShadowVerticalExtent(const ShadowData* shadow, LayoutUnit &top, LayoutUnit &bottom) const
{
top = 0;
bottom = 0;
for ( ; shadow; shadow = shadow->next()) {
if (shadow->style() == Inset)
continue;
int blurAndSpread = shadow->blur() + shadow->spread();
top = min<LayoutUnit>(top, shadow->y() - blurAndSpread);
bottom = max<LayoutUnit>(bottom, shadow->y() + blurAndSpread);
}
}
Color RenderStyle::colorIncludingFallback(int colorProperty, bool visitedLink) const
{
Color result;
EBorderStyle borderStyle = BNONE;
switch (colorProperty) {
case CSSPropertyBackgroundColor:
return visitedLink ? rareNonInheritedData->m_visitedLinkBackgroundColor : backgroundColor(); case CSSPropertyBorderLeftColor:
result = visitedLink ? rareNonInheritedData->m_visitedLinkBorderLeftColor : borderLeftColor();
borderStyle = borderLeftStyle();
break;
case CSSPropertyBorderRightColor:
result = visitedLink ? rareNonInheritedData->m_visitedLinkBorderRightColor : borderRightColor();
borderStyle = borderRightStyle();
break;
case CSSPropertyBorderTopColor:
result = visitedLink ? rareNonInheritedData->m_visitedLinkBorderTopColor : borderTopColor();
borderStyle = borderTopStyle();
break;
case CSSPropertyBorderBottomColor:
result = visitedLink ? rareNonInheritedData->m_visitedLinkBorderBottomColor : borderBottomColor();
borderStyle = borderBottomStyle();
break;
case CSSPropertyColor:
result = visitedLink ? inherited->visitedLinkColor : color();
break;
case CSSPropertyOutlineColor:
result = visitedLink ? rareNonInheritedData->m_visitedLinkOutlineColor : outlineColor();
break;
case CSSPropertyWebkitColumnRuleColor:
result = visitedLink ? rareNonInheritedData->m_multiCol->m_visitedLinkColumnRuleColor : columnRuleColor();
break;
case CSSPropertyWebkitTextEmphasisColor:
result = visitedLink ? rareInheritedData->visitedLinkTextEmphasisColor : textEmphasisColor();
break;
case CSSPropertyWebkitTextFillColor:
result = visitedLink ? rareInheritedData->visitedLinkTextFillColor : textFillColor();
break;
case CSSPropertyWebkitTextStrokeColor:
result = visitedLink ? rareInheritedData->visitedLinkTextStrokeColor : textStrokeColor();
break;
default:
ASSERT_NOT_REACHED();
break;
}
if (!result.isValid()) {
if (!visitedLink && (borderStyle == INSET || borderStyle == OUTSET || borderStyle == RIDGE || borderStyle == GROOVE))
result.setRGB(238, 238, 238);
else
result = visitedLink ? inherited->visitedLinkColor : color();
}
return result;
}
Color RenderStyle::visitedDependentColor(int colorProperty) const
{
Color unvisitedColor = colorIncludingFallback(colorProperty, false);
if (insideLink() != InsideVisitedLink)
return unvisitedColor;
Color visitedColor = colorIncludingFallback(colorProperty, true);
if (colorProperty == CSSPropertyBackgroundColor && visitedColor == Color::transparent)
return unvisitedColor;
return Color(visitedColor.red(), visitedColor.green(), visitedColor.blue(), unvisitedColor.alpha());
}
Length RenderStyle::logicalWidth() const
{
if (isHorizontalWritingMode())
return width();
return height();
}
Length RenderStyle::logicalHeight() const
{
if (isHorizontalWritingMode())
return height();
return width();
}
Length RenderStyle::logicalMinWidth() const
{
if (isHorizontalWritingMode())
return minWidth();
return minHeight();
}
Length RenderStyle::logicalMaxWidth() const
{
if (isHorizontalWritingMode())
return maxWidth();
return maxHeight();
}
Length RenderStyle::logicalMinHeight() const
{
if (isHorizontalWritingMode())
return minHeight();
return minWidth();
}
Length RenderStyle::logicalMaxHeight() const
{
if (isHorizontalWritingMode())
return maxHeight();
return maxWidth();
}
const BorderValue& RenderStyle::borderBefore() const
{
switch (writingMode()) {
case TopToBottomWritingMode:
return borderTop();
case BottomToTopWritingMode:
return borderBottom();
case LeftToRightWritingMode:
return borderLeft();
case RightToLeftWritingMode:
return borderRight();
}
ASSERT_NOT_REACHED();
return borderTop();
}
const BorderValue& RenderStyle::borderAfter() const
{
switch (writingMode()) {
case TopToBottomWritingMode:
return borderBottom();
case BottomToTopWritingMode:
return borderTop();
case LeftToRightWritingMode:
return borderRight();
case RightToLeftWritingMode:
return borderLeft();
}
ASSERT_NOT_REACHED();
return borderBottom();
}
const BorderValue& RenderStyle::borderStart() const
{
if (isHorizontalWritingMode())
return isLeftToRightDirection() ? borderLeft() : borderRight();
return isLeftToRightDirection() ? borderTop() : borderBottom();
}
const BorderValue& RenderStyle::borderEnd() const
{
if (isHorizontalWritingMode())
return isLeftToRightDirection() ? borderRight() : borderLeft();
return isLeftToRightDirection() ? borderBottom() : borderTop();
}
unsigned short RenderStyle::borderBeforeWidth() const
{
switch (writingMode()) {
case TopToBottomWritingMode:
return borderTopWidth();
case BottomToTopWritingMode:
return borderBottomWidth();
case LeftToRightWritingMode:
return borderLeftWidth();
case RightToLeftWritingMode:
return borderRightWidth();
}
ASSERT_NOT_REACHED();
return borderTopWidth();
}
unsigned short RenderStyle::borderAfterWidth() const
{
switch (writingMode()) {
case TopToBottomWritingMode:
return borderBottomWidth();
case BottomToTopWritingMode:
return borderTopWidth();
case LeftToRightWritingMode:
return borderRightWidth();
case RightToLeftWritingMode:
return borderLeftWidth();
}
ASSERT_NOT_REACHED();
return borderBottomWidth();
}
unsigned short RenderStyle::borderStartWidth() const
{
if (isHorizontalWritingMode())
return isLeftToRightDirection() ? borderLeftWidth() : borderRightWidth();
return isLeftToRightDirection() ? borderTopWidth() : borderBottomWidth();
}
unsigned short RenderStyle::borderEndWidth() const
{
if (isHorizontalWritingMode())
return isLeftToRightDirection() ? borderRightWidth() : borderLeftWidth();
return isLeftToRightDirection() ? borderBottomWidth() : borderTopWidth();
}
Length RenderStyle::marginBefore() const
{
switch (writingMode()) {
case TopToBottomWritingMode:
return marginTop();
case BottomToTopWritingMode:
return marginBottom();
case LeftToRightWritingMode:
return marginLeft();
case RightToLeftWritingMode:
return marginRight();
}
ASSERT_NOT_REACHED();
return marginTop();
}
Length RenderStyle::marginAfter() const
{
switch (writingMode()) {
case TopToBottomWritingMode:
return marginBottom();
case BottomToTopWritingMode:
return marginTop();
case LeftToRightWritingMode:
return marginRight();
case RightToLeftWritingMode:
return marginLeft();
}
ASSERT_NOT_REACHED();
return marginBottom();
}
Length RenderStyle::marginBeforeUsing(const RenderStyle* otherStyle) const
{
switch (otherStyle->writingMode()) {
case TopToBottomWritingMode:
return marginTop();
case BottomToTopWritingMode:
return marginBottom();
case LeftToRightWritingMode:
return marginLeft();
case RightToLeftWritingMode:
return marginRight();
}
ASSERT_NOT_REACHED();
return marginTop();
}
Length RenderStyle::marginAfterUsing(const RenderStyle* otherStyle) const
{
switch (otherStyle->writingMode()) {
case TopToBottomWritingMode:
return marginBottom();
case BottomToTopWritingMode:
return marginTop();
case LeftToRightWritingMode:
return marginRight();
case RightToLeftWritingMode:
return marginLeft();
}
ASSERT_NOT_REACHED();
return marginBottom();
}
Length RenderStyle::marginStart() const
{
if (isHorizontalWritingMode())
return isLeftToRightDirection() ? marginLeft() : marginRight();
return isLeftToRightDirection() ? marginTop() : marginBottom();
}
Length RenderStyle::marginEnd() const
{
if (isHorizontalWritingMode())
return isLeftToRightDirection() ? marginRight() : marginLeft();
return isLeftToRightDirection() ? marginBottom() : marginTop();
}
Length RenderStyle::marginStartUsing(const RenderStyle* otherStyle) const
{
if (otherStyle->isHorizontalWritingMode())
return otherStyle->isLeftToRightDirection() ? marginLeft() : marginRight();
return otherStyle->isLeftToRightDirection() ? marginTop() : marginBottom();
}
Length RenderStyle::marginEndUsing(const RenderStyle* otherStyle) const
{
if (otherStyle->isHorizontalWritingMode())
return otherStyle->isLeftToRightDirection() ? marginRight() : marginLeft();
return otherStyle->isLeftToRightDirection() ? marginBottom() : marginTop();
}
void RenderStyle::setMarginStart(Length margin)
{
if (isHorizontalWritingMode()) {
if (isLeftToRightDirection())
setMarginLeft(margin);
else
setMarginRight(margin);
} else {
if (isLeftToRightDirection())
setMarginTop(margin);
else
setMarginBottom(margin);
}
}
void RenderStyle::setMarginEnd(Length margin)
{
if (isHorizontalWritingMode()) {
if (isLeftToRightDirection())
setMarginRight(margin);
else
setMarginLeft(margin);
} else {
if (isLeftToRightDirection())
setMarginBottom(margin);
else
setMarginTop(margin);
}
}
Length RenderStyle::paddingBefore() const
{
switch (writingMode()) {
case TopToBottomWritingMode:
return paddingTop();
case BottomToTopWritingMode:
return paddingBottom();
case LeftToRightWritingMode:
return paddingLeft();
case RightToLeftWritingMode:
return paddingRight();
}
ASSERT_NOT_REACHED();
return paddingTop();
}
Length RenderStyle::paddingAfter() const
{
switch (writingMode()) {
case TopToBottomWritingMode:
return paddingBottom();
case BottomToTopWritingMode:
return paddingTop();
case LeftToRightWritingMode:
return paddingRight();
case RightToLeftWritingMode:
return paddingLeft();
}
ASSERT_NOT_REACHED();
return paddingBottom();
}
Length RenderStyle::paddingStart() const
{
if (isHorizontalWritingMode())
return isLeftToRightDirection() ? paddingLeft() : paddingRight();
return isLeftToRightDirection() ? paddingTop() : paddingBottom();
}
Length RenderStyle::paddingEnd() const
{
if (isHorizontalWritingMode())
return isLeftToRightDirection() ? paddingRight() : paddingLeft();
return isLeftToRightDirection() ? paddingBottom() : paddingTop();
}
TextEmphasisMark RenderStyle::textEmphasisMark() const
{
TextEmphasisMark mark = static_cast<TextEmphasisMark>(rareInheritedData->textEmphasisMark);
if (mark != TextEmphasisMarkAuto)
return mark;
if (isHorizontalWritingMode())
return TextEmphasisMarkDot;
return TextEmphasisMarkSesame;
}
#if ENABLE(TOUCH_EVENTS)
Color RenderStyle::initialTapHighlightColor()
{
return RenderTheme::tapHighlightColor();
}
#endif
void RenderStyle::getImageOutsets(const NinePieceImage& image, LayoutUnit& top, LayoutUnit& right, LayoutUnit& bottom, LayoutUnit& left) const
{
top = NinePieceImage::computeOutset(image.outset().top(), borderTopWidth());
right = NinePieceImage::computeOutset(image.outset().right(), borderRightWidth());
bottom = NinePieceImage::computeOutset(image.outset().bottom(), borderBottomWidth());
left = NinePieceImage::computeOutset(image.outset().left(), borderLeftWidth());
}
void RenderStyle::getImageHorizontalOutsets(const NinePieceImage& image, LayoutUnit& left, LayoutUnit& right) const
{
right = NinePieceImage::computeOutset(image.outset().right(), borderRightWidth());
left = NinePieceImage::computeOutset(image.outset().left(), borderLeftWidth());
}
void RenderStyle::getImageVerticalOutsets(const NinePieceImage& image, LayoutUnit& top, LayoutUnit& bottom) const
{
top = NinePieceImage::computeOutset(image.outset().top(), borderTopWidth());
bottom = NinePieceImage::computeOutset(image.outset().bottom(), borderBottomWidth());
}
}