Modified: trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp (91037 => 91038)
--- trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp 2011-07-14 23:48:51 UTC (rev 91037)
+++ trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp 2011-07-15 01:28:54 UTC (rev 91038)
@@ -189,7 +189,6 @@
InitialFunction m_initial;
};
-// CSSPropertyDirection
class ApplyPropertyDirection : public ApplyPropertyDefault<TextDirection> {
public:
ApplyPropertyDirection(GetterFunction getter, SetterFunction setter, InitialFunction initial)
@@ -387,42 +386,48 @@
void (CSSStyleSelector::*m_mapFill)(CSSPropertyID, FillLayer*, CSSValue*);
};
-class ApplyPropertyWidth : public ApplyPropertyDefaultBase<unsigned short> {
+enum ComputeLengthNormal {NormalDisabled = 0, NormalEnabled};
+enum ComputeLengthThickness {ThicknessDisabled = 0, ThicknessEnabled};
+enum ComputeLengthSVGZoom {SVGZoomDisabled = 0, SVGZoomEnabled};
+template <typename T,
+ ComputeLengthNormal normalEnabled = NormalDisabled,
+ ComputeLengthThickness thicknessEnabled = ThicknessDisabled,
+ ComputeLengthSVGZoom svgZoomEnabled = SVGZoomDisabled>
+class ApplyPropertyComputeLength : public ApplyPropertyDefaultBase<T> {
public:
- ApplyPropertyWidth(GetterFunction getter, SetterFunction setter, InitialFunction initial)
- : ApplyPropertyDefaultBase<unsigned short>(getter, setter, initial)
+ ApplyPropertyComputeLength(typename ApplyPropertyDefaultBase<T>::GetterFunction getter, typename ApplyPropertyDefaultBase<T>::SetterFunction setter, typename ApplyPropertyDefaultBase<T>::InitialFunction initial)
+ : ApplyPropertyDefaultBase<T>(getter, setter, initial)
{
}
private:
virtual void applyValue(CSSStyleSelector* selector, CSSValue* value) const
{
+ // note: CSSPropertyLetter/WordSpacing right now sets to zero if it's not a primitive value for some reason...
if (!value->isPrimitiveValue())
return;
CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
- short width;
- switch (primitiveValue->getIdent()) {
- case CSSValueThin:
- width = 1;
- break;
- case CSSValueMedium:
- width = 3;
- break;
- case CSSValueThick:
- width = 5;
- break;
- case CSSValueInvalid:
- width = primitiveValue->computeLength<short>(selector->style(), selector->rootElementStyle(), selector->style()->effectiveZoom());
- // CSS2 box model does not allow negative lengths for borders.
- if (width < 0)
- return;
- break;
- default:
- return;
+
+ int ident = primitiveValue->getIdent();
+ T length;
+ if (normalEnabled && ident == CSSValueNormal) {
+ length = 0;
+ } else if (thicknessEnabled && ident == CSSValueThin) {
+ length = 1;
+ } else if (thicknessEnabled && ident == CSSValueMedium) {
+ length = 3;
+ } else if (thicknessEnabled && ident == CSSValueThick) {
+ length = 5;
+ } else if (ident == CSSValueInvalid) {
+ float zoom = (svgZoomEnabled && selector->useSVGZoomRules()) ? 1.0f : selector->style()->effectiveZoom();
+ length = primitiveValue->computeLength<T>(selector->style(), selector->rootElementStyle(), zoom);
+ } else {
+ ASSERT_NOT_REACHED();
+ length = 0;
}
- setValue(selector->style(), width);
+ setValue(selector->style(), length);
}
};
@@ -582,12 +587,12 @@
setPropertyHandler(CSSPropertyBorderBottomStyle, new ApplyPropertyDefault<EBorderStyle>(&RenderStyle::borderBottomStyle, &RenderStyle::setBorderBottomStyle, &RenderStyle::initialBorderStyle));
setPropertyHandler(CSSPropertyBorderLeftStyle, new ApplyPropertyDefault<EBorderStyle>(&RenderStyle::borderLeftStyle, &RenderStyle::setBorderLeftStyle, &RenderStyle::initialBorderStyle));
- setPropertyHandler(CSSPropertyBorderTopWidth, new ApplyPropertyWidth(&RenderStyle::borderTopWidth, &RenderStyle::setBorderTopWidth, &RenderStyle::initialBorderWidth));
- setPropertyHandler(CSSPropertyBorderRightWidth, new ApplyPropertyWidth(&RenderStyle::borderRightWidth, &RenderStyle::setBorderRightWidth, &RenderStyle::initialBorderWidth));
- setPropertyHandler(CSSPropertyBorderBottomWidth, new ApplyPropertyWidth(&RenderStyle::borderBottomWidth, &RenderStyle::setBorderBottomWidth, &RenderStyle::initialBorderWidth));
- setPropertyHandler(CSSPropertyBorderLeftWidth, new ApplyPropertyWidth(&RenderStyle::borderLeftWidth, &RenderStyle::setBorderLeftWidth, &RenderStyle::initialBorderWidth));
- setPropertyHandler(CSSPropertyOutlineWidth, new ApplyPropertyWidth(&RenderStyle::outlineWidth, &RenderStyle::setOutlineWidth, &RenderStyle::initialBorderWidth));
- setPropertyHandler(CSSPropertyWebkitColumnRuleWidth, new ApplyPropertyWidth(&RenderStyle::columnRuleWidth, &RenderStyle::setColumnRuleWidth, &RenderStyle::initialBorderWidth));
+ setPropertyHandler(CSSPropertyBorderTopWidth, new ApplyPropertyComputeLength<unsigned short, NormalDisabled, ThicknessEnabled>(&RenderStyle::borderTopWidth, &RenderStyle::setBorderTopWidth, &RenderStyle::initialBorderWidth));
+ setPropertyHandler(CSSPropertyBorderRightWidth, new ApplyPropertyComputeLength<unsigned short, NormalDisabled, ThicknessEnabled>(&RenderStyle::borderRightWidth, &RenderStyle::setBorderRightWidth, &RenderStyle::initialBorderWidth));
+ setPropertyHandler(CSSPropertyBorderBottomWidth, new ApplyPropertyComputeLength<unsigned short, NormalDisabled, ThicknessEnabled>(&RenderStyle::borderBottomWidth, &RenderStyle::setBorderBottomWidth, &RenderStyle::initialBorderWidth));
+ setPropertyHandler(CSSPropertyBorderLeftWidth, new ApplyPropertyComputeLength<unsigned short, NormalDisabled, ThicknessEnabled>(&RenderStyle::borderLeftWidth, &RenderStyle::setBorderLeftWidth, &RenderStyle::initialBorderWidth));
+ setPropertyHandler(CSSPropertyOutlineWidth, new ApplyPropertyComputeLength<unsigned short, NormalDisabled, ThicknessEnabled>(&RenderStyle::outlineWidth, &RenderStyle::setOutlineWidth, &RenderStyle::initialBorderWidth));
+ setPropertyHandler(CSSPropertyWebkitColumnRuleWidth, new ApplyPropertyComputeLength<unsigned short, NormalDisabled, ThicknessEnabled>(&RenderStyle::columnRuleWidth, &RenderStyle::setColumnRuleWidth, &RenderStyle::initialBorderWidth));
setPropertyHandler(CSSPropertyBorderTop, new ApplyPropertyExpanding<SuppressValue>(propertyHandler(CSSPropertyBorderTopColor), propertyHandler(CSSPropertyBorderTopStyle), propertyHandler(CSSPropertyBorderTopWidth)));
setPropertyHandler(CSSPropertyBorderRight, new ApplyPropertyExpanding<SuppressValue>(propertyHandler(CSSPropertyBorderRightColor), propertyHandler(CSSPropertyBorderRightStyle), propertyHandler(CSSPropertyBorderRightWidth)));
@@ -606,6 +611,13 @@
setPropertyHandler(CSSPropertyBorderRadius, new ApplyPropertyExpanding<ExpandValue>(propertyHandler(CSSPropertyBorderTopLeftRadius), propertyHandler(CSSPropertyBorderTopRightRadius), propertyHandler(CSSPropertyBorderBottomLeftRadius), propertyHandler(CSSPropertyBorderBottomRightRadius)));
setPropertyHandler(CSSPropertyWebkitBorderRadius, CSSPropertyBorderRadius);
+ setPropertyHandler(CSSPropertyWebkitBorderHorizontalSpacing, new ApplyPropertyComputeLength<short>(&RenderStyle::horizontalBorderSpacing, &RenderStyle::setHorizontalBorderSpacing, &RenderStyle::initialHorizontalBorderSpacing));
+ setPropertyHandler(CSSPropertyWebkitBorderVerticalSpacing, new ApplyPropertyComputeLength<short>(&RenderStyle::verticalBorderSpacing, &RenderStyle::setVerticalBorderSpacing, &RenderStyle::initialVerticalBorderSpacing));
+ setPropertyHandler(CSSPropertyBorderSpacing, new ApplyPropertyExpanding<SuppressValue>(propertyHandler(CSSPropertyWebkitBorderHorizontalSpacing), propertyHandler(CSSPropertyWebkitBorderVerticalSpacing)));
+
+ setPropertyHandler(CSSPropertyLetterSpacing, new ApplyPropertyComputeLength<int, NormalEnabled, ThicknessDisabled, SVGZoomEnabled>(&RenderStyle::letterSpacing, &RenderStyle::setLetterSpacing, &RenderStyle::initialLetterWordSpacing));
+ setPropertyHandler(CSSPropertyWordSpacing, new ApplyPropertyComputeLength<int, NormalEnabled, ThicknessDisabled, SVGZoomEnabled>(&RenderStyle::wordSpacing, &RenderStyle::setWordSpacing, &RenderStyle::initialLetterWordSpacing));
+
setPropertyHandler(CSSPropertyFontStyle, new ApplyPropertyFont<FontItalic>(&FontDescription::italic, &FontDescription::setItalic, FontItalicOff));
setPropertyHandler(CSSPropertyFontVariant, new ApplyPropertyFont<FontSmallCaps>(&FontDescription::smallCaps, &FontDescription::setSmallCaps, FontSmallCapsOff));
setPropertyHandler(CSSPropertyTextRendering, new ApplyPropertyFont<TextRenderingMode>(&FontDescription::textRenderingMode, &FontDescription::setTextRenderingMode, AutoTextRendering));
@@ -616,7 +628,6 @@
setPropertyHandler(CSSPropertyOutlineStyle, new ApplyPropertyExpanding<ExpandValue>(new ApplyPropertyDefault<OutlineIsAuto>(&RenderStyle::outlineStyleIsAuto, &RenderStyle::setOutlineStyleIsAuto, &RenderStyle::initialOutlineStyleIsAuto), new ApplyPropertyDefault<EBorderStyle>(&RenderStyle::outlineStyle, &RenderStyle::setOutlineStyle, &RenderStyle::initialBorderStyle)));
setPropertyHandler(CSSPropertyOutlineColor, new ApplyPropertyColor<InheritFromParent>(&RenderStyle::outlineColor, &RenderStyle::setOutlineColor, &RenderStyle::color));
-
setPropertyHandler(CSSPropertyOverflowX, new ApplyPropertyDefault<EOverflow>(&RenderStyle::overflowX, &RenderStyle::setOverflowX, &RenderStyle::initialOverflowX));
setPropertyHandler(CSSPropertyOverflowY, new ApplyPropertyDefault<EOverflow>(&RenderStyle::overflowY, &RenderStyle::setOverflowY, &RenderStyle::initialOverflowY));
setPropertyHandler(CSSPropertyOverflow, new ApplyPropertyExpanding<ExpandValue>(propertyHandler(CSSPropertyOverflowX), propertyHandler(CSSPropertyOverflowY)));
Modified: trunk/Source/WebCore/css/CSSStyleSelector.cpp (91037 => 91038)
--- trunk/Source/WebCore/css/CSSStyleSelector.cpp 2011-07-14 23:48:51 UTC (rev 91037)
+++ trunk/Source/WebCore/css/CSSStyleSelector.cpp 2011-07-15 01:28:54 UTC (rev 91038)
@@ -3667,9 +3667,9 @@
// width/height/border/padding/... from the RenderStyle -> for SVG these values would never scale,
// if we'd pass a 1.0 zoom factor everyhwere. So we only pass a zoom factor of 1.0 for specific
// properties that are NOT allowed to scale within a zoomed SVG document (letter/word-spacing/font-size).
-static inline bool useSVGZoomRules(const Element* e)
+bool CSSStyleSelector::useSVGZoomRules()
{
- return e && e->isSVGElement();
+ return m_element && m_element->isSVGElement();
}
void CSSStyleSelector::applyProperty(int id, CSSValue *value)
@@ -3780,33 +3780,6 @@
case CSSPropertyWhiteSpace:
HANDLE_INHERIT_AND_INITIAL_AND_PRIMITIVE(whiteSpace, WhiteSpace)
return;
- case CSSPropertyBorderSpacing: {
- if (isInherit) {
- m_style->setHorizontalBorderSpacing(m_parentStyle->horizontalBorderSpacing());
- m_style->setVerticalBorderSpacing(m_parentStyle->verticalBorderSpacing());
- }
- else if (isInitial) {
- m_style->setHorizontalBorderSpacing(0);
- m_style->setVerticalBorderSpacing(0);
- }
- return;
- }
- case CSSPropertyWebkitBorderHorizontalSpacing: {
- HANDLE_INHERIT_AND_INITIAL(horizontalBorderSpacing, HorizontalBorderSpacing)
- if (!primitiveValue)
- return;
- short spacing = primitiveValue->computeLength<short>(style(), m_rootElementStyle, zoomFactor);
- m_style->setHorizontalBorderSpacing(spacing);
- return;
- }
- case CSSPropertyWebkitBorderVerticalSpacing: {
- HANDLE_INHERIT_AND_INITIAL(verticalBorderSpacing, VerticalBorderSpacing)
- if (!primitiveValue)
- return;
- short spacing = primitiveValue->computeLength<short>(style(), m_rootElementStyle, zoomFactor);
- m_style->setVerticalBorderSpacing(spacing);
- return;
- }
case CSSPropertyCursor:
if (isInherit) {
m_style->setCursor(m_parentStyle->cursor());
@@ -3852,41 +3825,6 @@
m_style->setListStyleImage(styleImage(CSSPropertyListStyleImage, value));
return;
}
- case CSSPropertyLetterSpacing:
- case CSSPropertyWordSpacing:
- {
- if (isInherit) {
- HANDLE_INHERIT_COND(CSSPropertyLetterSpacing, letterSpacing, LetterSpacing)
- HANDLE_INHERIT_COND(CSSPropertyWordSpacing, wordSpacing, WordSpacing)
- return;
- }
- else if (isInitial) {
- HANDLE_INITIAL_COND_WITH_VALUE(CSSPropertyLetterSpacing, LetterSpacing, LetterWordSpacing)
- HANDLE_INITIAL_COND_WITH_VALUE(CSSPropertyWordSpacing, WordSpacing, LetterWordSpacing)
- return;
- }
-
- int width = 0;
- if (primitiveValue && primitiveValue->getIdent() == CSSValueNormal) {
- width = 0;
- } else {
- if (!primitiveValue)
- return;
- width = primitiveValue->computeLength<int>(style(), m_rootElementStyle, useSVGZoomRules(m_element) ? 1.0f : zoomFactor);
- }
- switch (id) {
- case CSSPropertyLetterSpacing:
- m_style->setLetterSpacing(width);
- break;
- case CSSPropertyWordSpacing:
- m_style->setWordSpacing(width);
- break;
- // ### needs the definitions in renderstyle
- default: break;
- }
- return;
- }
-
case CSSPropertyWordBreak:
HANDLE_INHERIT_AND_INITIAL_AND_PRIMITIVE(wordBreak, WordBreak)
return;
@@ -4496,7 +4434,7 @@
fontDescription.setUsePrinterFont(m_checker.m_document->printing());
// Handle the zoom factor.
- fontDescription.setComputedSize(getComputedSizeFromSpecifiedSize(m_checker.m_document, m_style.get(), fontDescription.isAbsoluteSize(), fontDescription.specifiedSize(), useSVGZoomRules(m_element)));
+ fontDescription.setComputedSize(getComputedSizeFromSpecifiedSize(m_checker.m_document, m_style.get(), fontDescription.isAbsoluteSize(), fontDescription.specifiedSize(), useSVGZoomRules()));
if (m_style->setFontDescription(fontDescription))
m_fontDirty = true;
}
@@ -5398,6 +5336,11 @@
case CSSPropertyBorderTopRightRadius:
case CSSPropertyBorderBottomLeftRadius:
case CSSPropertyBorderBottomRightRadius:
+ case CSSPropertyBorderSpacing:
+ case CSSPropertyWebkitBorderHorizontalSpacing:
+ case CSSPropertyWebkitBorderVerticalSpacing:
+ case CSSPropertyLetterSpacing:
+ case CSSPropertyWordSpacing:
case CSSPropertyFontStyle:
case CSSPropertyFontVariant:
case CSSPropertyTextRendering:
@@ -6162,9 +6105,7 @@
void CSSStyleSelector::setFontSize(FontDescription& fontDescription, float size)
{
fontDescription.setSpecifiedSize(size);
-
- bool useSVGZoomRules = m_element && m_element->isSVGElement();
- fontDescription.setComputedSize(getComputedSizeFromSpecifiedSize(m_checker.m_document, m_style.get(), fontDescription.isAbsoluteSize(), size, useSVGZoomRules));
+ fontDescription.setComputedSize(getComputedSizeFromSpecifiedSize(m_checker.m_document, m_style.get(), fontDescription.isAbsoluteSize(), size, useSVGZoomRules()));
}
float CSSStyleSelector::getComputedSizeFromSpecifiedSize(Document* document, RenderStyle* style, bool isAbsoluteSize, float specifiedSize, bool useSVGZoomRules)