- Revision
- 97314
- Author
- [email protected]
- Date
- 2011-10-12 15:51:17 -0700 (Wed, 12 Oct 2011)
Log Message
Clean up CSSPropertyTextDecoration implementation and ETextDecoration usage.
https://bugs.webkit.org/show_bug.cgi?id=67625
Reviewed by Eric Seidel.
No new tests - no functionality changed.
The implementation of CSSPropertyTextDecoration is simlified because
1) CSSValueListIterator produces a valid iterator when no results available.
2) CSSParser only allows CSSValueNone or a list of appropriate idents.
3) CSSParser will treat a zero-length list as invalid at parse time.
* css/CSSPrimitiveValueMappings.h:
(WebCore::CSSPrimitiveValue::operator ETextDecoration):
Implement cast from CSSPrimitiveValue to ETextDecoration.
* css/CSSStyleSelector.cpp:
(WebCore::CSSStyleSelector::applyProperty):
* rendering/style/RenderStyle.h:
Use ETextDecoration enum instead of int throughout.
(WebCore::InheritedFlags::textDecorationsInEffect):
(WebCore::InheritedFlags::textDecoration):
(WebCore::InheritedFlags::addToTextDecorationsInEffect):
(WebCore::InheritedFlags::setTextDecorationsInEffect):
(WebCore::InheritedFlags::setTextDecoration):
* rendering/style/RenderStyleConstants.h:
Introduce constant for number of bits required to represent enum.
(WebCore::operator|):
Implement | operator for bitfield enum.
(WebCore::operator|=):
Implement |= operator for bitfield enum.
* rendering/style/StyleVisualData.h:
Use ETextDecoration instead of int.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (97313 => 97314)
--- trunk/Source/WebCore/ChangeLog 2011-10-12 22:49:25 UTC (rev 97313)
+++ trunk/Source/WebCore/ChangeLog 2011-10-12 22:51:17 UTC (rev 97314)
@@ -1,3 +1,38 @@
+2011-10-12 Luke Macpherson <[email protected]>
+
+ Clean up CSSPropertyTextDecoration implementation and ETextDecoration usage.
+ https://bugs.webkit.org/show_bug.cgi?id=67625
+
+ Reviewed by Eric Seidel.
+
+ No new tests - no functionality changed.
+
+ The implementation of CSSPropertyTextDecoration is simlified because
+ 1) CSSValueListIterator produces a valid iterator when no results available.
+ 2) CSSParser only allows CSSValueNone or a list of appropriate idents.
+ 3) CSSParser will treat a zero-length list as invalid at parse time.
+
+ * css/CSSPrimitiveValueMappings.h:
+ (WebCore::CSSPrimitiveValue::operator ETextDecoration):
+ Implement cast from CSSPrimitiveValue to ETextDecoration.
+ * css/CSSStyleSelector.cpp:
+ (WebCore::CSSStyleSelector::applyProperty):
+ * rendering/style/RenderStyle.h:
+ Use ETextDecoration enum instead of int throughout.
+ (WebCore::InheritedFlags::textDecorationsInEffect):
+ (WebCore::InheritedFlags::textDecoration):
+ (WebCore::InheritedFlags::addToTextDecorationsInEffect):
+ (WebCore::InheritedFlags::setTextDecorationsInEffect):
+ (WebCore::InheritedFlags::setTextDecoration):
+ * rendering/style/RenderStyleConstants.h:
+ Introduce constant for number of bits required to represent enum.
+ (WebCore::operator|):
+ Implement | operator for bitfield enum.
+ (WebCore::operator|=):
+ Implement |= operator for bitfield enum.
+ * rendering/style/StyleVisualData.h:
+ Use ETextDecoration instead of int.
+
2011-10-12 Tony Chang <[email protected]>
Implement -webkit-flex-align for cross axis alignment in flex-flow: row
Modified: trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h (97313 => 97314)
--- trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h 2011-10-12 22:49:25 UTC (rev 97313)
+++ trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h 2011-10-12 22:51:17 UTC (rev 97314)
@@ -1958,6 +1958,25 @@
}
}
+template<> inline CSSPrimitiveValue::operator ETextDecoration() const
+{
+ switch (m_value.ident) {
+ case CSSValueNone:
+ return TDNONE;
+ case CSSValueUnderline:
+ return UNDERLINE;
+ case CSSValueOverline:
+ return OVERLINE;
+ case CSSValueLineThrough:
+ return LINE_THROUGH;
+ case CSSValueBlink:
+ return BLINK;
+ default:
+ ASSERT_NOT_REACHED();
+ return TDNONE;
+ }
+}
+
template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ETextSecurity e)
: m_type(CSS_IDENT)
, m_hasCachedCSSText(false)
Modified: trunk/Source/WebCore/css/CSSStyleSelector.cpp (97313 => 97314)
--- trunk/Source/WebCore/css/CSSStyleSelector.cpp 2011-10-12 22:49:25 UTC (rev 97313)
+++ trunk/Source/WebCore/css/CSSStyleSelector.cpp 2011-10-12 22:51:17 UTC (rev 97314)
@@ -2963,35 +2963,12 @@
case CSSPropertyTextDecoration: {
// list of ident
HANDLE_INHERIT_AND_INITIAL(textDecoration, TextDecoration)
- int t = RenderStyle::initialTextDecoration();
- if (primitiveValue && primitiveValue->getIdent() == CSSValueNone) {
- // do nothing
- } else {
- if (!value->isValueList())
- return;
- for (CSSValueListIterator i = value; i.hasMore(); i.advance())
- {
- CSSValue* item = i.value();
- if (!item->isPrimitiveValue())
- continue;
- primitiveValue = static_cast<CSSPrimitiveValue*>(item);
- switch (primitiveValue->getIdent()) {
- case CSSValueNone:
- t = TDNONE; break;
- case CSSValueUnderline:
- t |= UNDERLINE; break;
- case CSSValueOverline:
- t |= OVERLINE; break;
- case CSSValueLineThrough:
- t |= LINE_THROUGH; break;
- case CSSValueBlink:
- t |= BLINK; break;
- default:
- return;
- }
- }
+ ETextDecoration t = RenderStyle::initialTextDecoration();
+ for (CSSValueListIterator i = value; i.hasMore(); i.advance()) {
+ CSSValue* item = i.value();
+ ASSERT(item->isPrimitiveValue());
+ t |= *static_cast<CSSPrimitiveValue*>(item);
}
-
m_style->setTextDecoration(t);
return;
}
Modified: trunk/Source/WebCore/rendering/style/RenderStyle.h (97313 => 97314)
--- trunk/Source/WebCore/rendering/style/RenderStyle.h 2011-10-12 22:49:25 UTC (rev 97313)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.h 2011-10-12 22:51:17 UTC (rev 97314)
@@ -198,7 +198,7 @@
unsigned _visibility : 2; // EVisibility
unsigned _text_align : 4; // ETextAlign
unsigned _text_transform : 2; // ETextTransform
- unsigned _text_decorations : 4;
+ unsigned _text_decorations : ETextDecorationBits;
unsigned _cursor_style : 6; // ECursor
unsigned _direction : 1; // TextDirection
unsigned _border_collapse : 1; // EBorderCollapse
@@ -522,8 +522,8 @@
Length textIndent() const { return rareInheritedData->indent; }
ETextAlign textAlign() const { return static_cast<ETextAlign>(inherited_flags._text_align); }
ETextTransform textTransform() const { return static_cast<ETextTransform>(inherited_flags._text_transform); }
- int textDecorationsInEffect() const { return inherited_flags._text_decorations; }
- int textDecoration() const { return visual->textDecoration; }
+ ETextDecoration textDecorationsInEffect() const { return static_cast<ETextDecoration>(inherited_flags._text_decorations); }
+ ETextDecoration textDecoration() const { return static_cast<ETextDecoration>(visual->textDecoration); }
int wordSpacing() const { return inherited->font.wordSpacing(); }
int letterSpacing() const { return inherited->font.letterSpacing(); }
@@ -994,9 +994,9 @@
void setTextIndent(Length v) { SET_VAR(rareInheritedData, indent, v) }
void setTextAlign(ETextAlign v) { inherited_flags._text_align = v; }
void setTextTransform(ETextTransform v) { inherited_flags._text_transform = v; }
- void addToTextDecorationsInEffect(int v) { inherited_flags._text_decorations |= v; }
- void setTextDecorationsInEffect(int v) { inherited_flags._text_decorations = v; }
- void setTextDecoration(int v) { SET_VAR(visual, textDecoration, v); }
+ void addToTextDecorationsInEffect(ETextDecoration v) { inherited_flags._text_decorations |= v; }
+ void setTextDecorationsInEffect(ETextDecoration v) { inherited_flags._text_decorations = v; }
+ void setTextDecoration(ETextDecoration v) { SET_VAR(visual, textDecoration, v); }
void setDirection(TextDirection v) { inherited_flags._direction = v; }
void setLineHeight(Length v) { SET_VAR(inherited, line_height, v) }
bool setZoom(float);
Modified: trunk/Source/WebCore/rendering/style/RenderStyleConstants.h (97313 => 97314)
--- trunk/Source/WebCore/rendering/style/RenderStyleConstants.h 2011-10-12 22:49:25 UTC (rev 97313)
+++ trunk/Source/WebCore/rendering/style/RenderStyleConstants.h 2011-10-12 22:51:17 UTC (rev 97314)
@@ -334,9 +334,12 @@
CAPITALIZE, UPPERCASE, LOWERCASE, TTNONE
};
+static const size_t ETextDecorationBits = 4;
enum ETextDecoration {
TDNONE = 0x0 , UNDERLINE = 0x1, OVERLINE = 0x2, LINE_THROUGH= 0x4, BLINK = 0x8
};
+inline ETextDecoration operator|(ETextDecoration a, ETextDecoration b) { return ETextDecoration(int(a) | int(b)); }
+inline ETextDecoration& operator|=(ETextDecoration& a, ETextDecoration b) { return a = a | b; }
enum EPageBreak {
PBAUTO, PBALWAYS, PBAVOID
Modified: trunk/Source/WebCore/rendering/style/StyleVisualData.h (97313 => 97314)
--- trunk/Source/WebCore/rendering/style/StyleVisualData.h 2011-10-12 22:49:25 UTC (rev 97313)
+++ trunk/Source/WebCore/rendering/style/StyleVisualData.h 2011-10-12 22:51:17 UTC (rev 97314)
@@ -26,6 +26,7 @@
#define StyleVisualData_h
#include "LengthBox.h"
+#include "RenderStyleConstants.h"
#include <wtf/RefCounted.h>
#include <wtf/PassRefPtr.h>
@@ -48,7 +49,7 @@
LengthBox clip;
bool hasClip : 1;
- unsigned textDecoration : 4; // Text decorations defined *only* by this element.
+ unsigned textDecoration : ETextDecorationBits; // Text decorations defined *only* by this element.
float m_zoom;