2011-04-20 Luke Macpherson <macpherson@chromium.org>

        Reviewed by Dimitri Glazkov.

        Allow casting between CSSPrimitiveValue and EBorderCollapse to remove special-case logic from CSSStyleSelector.
        https://bugs.webkit.org/show_bug.cgi?id=58964

        No new tests as no new functionality added.

        * css/CSSPrimitiveValueMappings.h:
        Support casting to/from EBorderCollapse.
        * css/CSSStyleSelector.cpp:
        Use new casting ability to simplify code.
        * rendering/style/RenderStyle.h:
        Use EBorderCollapse instead of a bool for representing border collapse member variable.
        * rendering/style/RenderStyleConstants.h:
        Added EBorderCollapse enum.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@84380 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 8876c9ef
2011-04-20 Luke Macpherson <macpherson@chromium.org>
Reviewed by Dimitri Glazkov.
Allow casting between CSSPrimitiveValue and EBorderCollapse to remove special-case logic from CSSStyleSelector.
https://bugs.webkit.org/show_bug.cgi?id=58964
No new tests as no new functionality added.
* css/CSSPrimitiveValueMappings.h:
Support casting to/from EBorderCollapse.
* css/CSSStyleSelector.cpp:
Use new casting ability to simplify code.
* rendering/style/RenderStyle.h:
Use EBorderCollapse instead of a bool for representing border collapse member variable.
* rendering/style/RenderStyleConstants.h:
Added EBorderCollapse enum.
2011-04-19 Stephen White <senorblanco@chromium.org>
Reviewed by Kenneth Russell.
......@@ -2642,6 +2642,33 @@ template<> inline CSSPrimitiveValue::operator EAlignmentBaseline() const
}
}
template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EBorderCollapse e)
: m_type(CSS_IDENT)
, m_hasCachedCSSText(false)
{
switch (e) {
case BSEPARATE:
m_value.ident = CSSValueSeparate;
break;
case BCOLLAPSE:
m_value.ident = CSSValueCollapse;
break;
}
}
template<> inline CSSPrimitiveValue::operator EBorderCollapse() const
{
switch (m_value.ident) {
case CSSValueSeparate:
return BSEPARATE;
case CSSValueCollapse:
return BCOLLAPSE;
default:
ASSERT_NOT_REACHED();
return BSEPARATE;
}
}
template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EColorInterpolation e)
: m_type(CSS_IDENT)
, m_hasCachedCSSText(false)
......
......@@ -3586,19 +3586,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
switch (property) {
// ident only properties
case CSSPropertyBorderCollapse:
HANDLE_INHERIT_AND_INITIAL(borderCollapse, BorderCollapse)
if (!primitiveValue)
return;
switch (primitiveValue->getIdent()) {
case CSSValueCollapse:
m_style->setBorderCollapse(true);
break;
case CSSValueSeparate:
m_style->setBorderCollapse(false);
break;
default:
return;
}
HANDLE_INHERIT_AND_INITIAL_AND_PRIMITIVE(borderCollapse, BorderCollapse)
return;
case CSSPropertyOutlineStyle:
HANDLE_INHERIT_AND_INITIAL_WITH_VALUE(outlineStyle, OutlineStyle, BorderStyle)
......
......@@ -193,7 +193,7 @@ protected:
unsigned _text_decorations : 4;
unsigned _cursor_style : 6; // ECursor
unsigned _direction : 1; // TextDirection
bool _border_collapse : 1 ;
unsigned _border_collapse : 1; // EBorderCollapse
unsigned _white_space : 3; // EWhiteSpace
unsigned _box_direction : 1; // EBoxDirection (CSS3 box_direction property, flexible box layout module)
// 34 bits
......@@ -592,8 +592,7 @@ public:
const FillLayer* maskLayers() const { return &(rareNonInheritedData->m_mask); }
const NinePieceImage& maskBoxImage() const { return rareNonInheritedData->m_maskBoxImage; }
// returns true for collapsing borders, false for separate borders
bool borderCollapse() const { return inherited_flags._border_collapse; }
EBorderCollapse borderCollapse() const { return static_cast<EBorderCollapse>(inherited_flags._border_collapse); }
short horizontalBorderSpacing() const { return inherited->horizontal_border_spacing; }
short verticalBorderSpacing() const { return inherited->vertical_border_spacing; }
EEmptyCell emptyCells() const { return static_cast<EEmptyCell>(inherited_flags._empty_cells); }
......@@ -968,7 +967,7 @@ public:
void setMaskYPosition(Length l) { SET_VAR(rareNonInheritedData, m_mask.m_yPosition, l) }
void setMaskSize(LengthSize l) { SET_VAR(rareNonInheritedData, m_mask.m_sizeLength, l) }
void setBorderCollapse(bool collapse) { inherited_flags._border_collapse = collapse; }
void setBorderCollapse(EBorderCollapse collapse) { inherited_flags._border_collapse = collapse; }
void setHorizontalBorderSpacing(short v) { SET_VAR(inherited, horizontal_border_spacing, v) }
void setVerticalBorderSpacing(short v) { SET_VAR(inherited, vertical_border_spacing, v) }
void setEmptyCells(EEmptyCell v) { inherited_flags._empty_cells = v; }
......@@ -1210,7 +1209,7 @@ public:
const Color visitedDependentColor(int colorProperty) const;
// Initial values for all the properties
static bool initialBorderCollapse() { return false; }
static EBorderCollapse initialBorderCollapse() { return BSEPARATE; }
static EBorderStyle initialBorderStyle() { return BNONE; }
static NinePieceImage initialNinePieceImage() { return NinePieceImage(); }
static LengthSize initialBorderRadius() { return LengthSize(Length(0, Fixed), Length(0, Fixed)); }
......
......@@ -80,6 +80,8 @@ enum PseudoId {
PUBLIC_PSEUDOID_MASK = ((1 << FIRST_INTERNAL_PSEUDOID) - 1) & ~((1 << FIRST_PUBLIC_PSEUDOID) - 1)
};
enum EBorderCollapse { BSEPARATE = 0, BCOLLAPSE = 1 };
// These have been defined in the order of their precedence for border-collapsing. Do
// not change this order!
enum EBorderStyle { BNONE, BHIDDEN, INSET, GROOVE, RIDGE, OUTSET, DOTTED, DASHED, SOLID, DOUBLE };
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment