Modified: trunk/Source/WebCore/ChangeLog (103211 => 103212)
--- trunk/Source/WebCore/ChangeLog 2011-12-19 03:27:43 UTC (rev 103211)
+++ trunk/Source/WebCore/ChangeLog 2011-12-19 03:50:08 UTC (rev 103212)
@@ -1,5 +1,23 @@
2011-12-18 Luke Macpherson <[email protected]>
+ Implement CSS line-height property in CSSStyleApplyProperty.
+ https://bugs.webkit.org/show_bug.cgi?id=74561
+
+ Reviewed by Andreas Kling.
+
+ No new tests / refactoring only.
+
+ * css/CSSPrimitiveValue.h:
+ (WebCore::CSSPrimitiveValue::isNumber):
+ * css/CSSStyleApplyProperty.cpp:
+ (WebCore::ApplyPropertyLineHeight::applyValue):
+ (WebCore::ApplyPropertyLineHeight::createHandler):
+ (WebCore::CSSStyleApplyProperty::CSSStyleApplyProperty):
+ * css/CSSStyleSelector.cpp:
+ (WebCore::CSSStyleSelector::applyProperty):
+
+2011-12-18 Luke Macpherson <[email protected]>
+
Implement CSS outline shorthand property in CSSStyleApplyProperty.
https://bugs.webkit.org/show_bug.cgi?id=74467
Modified: trunk/Source/WebCore/css/CSSPrimitiveValue.h (103211 => 103212)
--- trunk/Source/WebCore/css/CSSPrimitiveValue.h 2011-12-19 03:27:43 UTC (rev 103211)
+++ trunk/Source/WebCore/css/CSSPrimitiveValue.h 2011-12-19 03:50:08 UTC (rev 103212)
@@ -121,6 +121,7 @@
bool isLength() const { return isUnitTypeLength(m_primitiveUnitType); }
bool isPercentage() const { return m_primitiveUnitType == CSSPrimitiveValue::CSS_PERCENTAGE; }
+ bool isNumber() const { return m_primitiveUnitType == CSSPrimitiveValue::CSS_NUMBER; }
static PassRefPtr<CSSPrimitiveValue> createIdentifier(int identifier) { return adoptRef(new CSSPrimitiveValue(identifier)); }
static PassRefPtr<CSSPrimitiveValue> createColor(unsigned rgbValue) { return adoptRef(new CSSPrimitiveValue(rgbValue)); }
Modified: trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp (103211 => 103212)
--- trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp 2011-12-19 03:27:43 UTC (rev 103211)
+++ trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp 2011-12-19 03:50:08 UTC (rev 103212)
@@ -1005,6 +1005,42 @@
}
};
+class ApplyPropertyLineHeight {
+public:
+ static void applyValue(CSSStyleSelector* selector, CSSValue* value)
+ {
+ if (!value->isPrimitiveValue())
+ return;
+
+ CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
+ Length lineHeight;
+
+ if (primitiveValue->getIdent() == CSSValueNormal)
+ lineHeight = Length(-100.0, Percent);
+ else if (primitiveValue->isLength()) {
+ double multiplier = selector->style()->effectiveZoom();
+ if (selector->style()->textSizeAdjust()) {
+ if (Frame* frame = selector->document()->frame())
+ multiplier *= frame->textZoomFactor();
+ }
+ lineHeight = primitiveValue->computeLength<Length>(selector->style(), selector->rootElementStyle(), multiplier);
+ } else if (primitiveValue->isPercentage()) {
+ // FIXME: percentage should not be restricted to an integer here.
+ lineHeight = Length((selector->style()->fontSize() * primitiveValue->getIntValue()) / 100, Fixed);
+ } else if (primitiveValue->isNumber()) {
+ // FIXME: number and percentage values should produce the same type of Length (ie. Fixed or Percent).
+ lineHeight = Length(primitiveValue->getDoubleValue() * 100.0, Percent);
+ } else
+ return;
+ selector->style()->setLineHeight(lineHeight);
+ }
+ static PropertyHandler createHandler()
+ {
+ PropertyHandler handler = ApplyPropertyDefaultBase<Length, &RenderStyle::lineHeight, Length, &RenderStyle::setLineHeight, Length, &RenderStyle::initialLineHeight>::createHandler();
+ return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
+ }
+};
+
class ApplyPropertyPageSize {
private:
static Length mmLength(double mm) { return CSSPrimitiveValue::create(mm, CSSPrimitiveValue::CSS_MM)->computeLength<Length>(0, 0); }
@@ -1677,6 +1713,8 @@
setPropertyHandler(CSSPropertyTextIndent, ApplyPropertyLength<&RenderStyle::textIndent, &RenderStyle::setTextIndent, &RenderStyle::initialTextIndent>::createHandler());
+ setPropertyHandler(CSSPropertyLineHeight, ApplyPropertyLineHeight::createHandler());
+
setPropertyHandler(CSSPropertyListStyleImage, ApplyPropertyStyleImage<&RenderStyle::listStyleImage, &RenderStyle::setListStyleImage, &RenderStyle::initialListStyleImage, CSSPropertyListStyleImage>::createHandler());
setPropertyHandler(CSSPropertyListStylePosition, ApplyPropertyDefault<EListStylePosition, &RenderStyle::listStylePosition, EListStylePosition, &RenderStyle::setListStylePosition, EListStylePosition, &RenderStyle::initialListStylePosition>::createHandler());
setPropertyHandler(CSSPropertyListStyleType, ApplyPropertyDefault<EListStyleType, &RenderStyle::listStyleType, EListStyleType, &RenderStyle::setListStyleType, EListStyleType, &RenderStyle::initialListStyleType>::createHandler());
Modified: trunk/Source/WebCore/css/CSSStyleSelector.cpp (103211 => 103212)
--- trunk/Source/WebCore/css/CSSStyleSelector.cpp 2011-12-19 03:27:43 UTC (rev 103211)
+++ trunk/Source/WebCore/css/CSSStyleSelector.cpp 2011-12-19 03:50:08 UTC (rev 103212)
@@ -2687,33 +2687,6 @@
case CSSPropertyOrphans:
HANDLE_INHERIT_AND_INITIAL_AND_PRIMITIVE(orphans, Orphans)
return;
-// length, percent, number
- case CSSPropertyLineHeight:
- {
- HANDLE_INHERIT_AND_INITIAL(lineHeight, LineHeight)
- if (!primitiveValue)
- return;
- Length lineHeight;
- int type = primitiveValue->primitiveType();
- if (primitiveValue->getIdent() == CSSValueNormal)
- lineHeight = Length(-100.0, Percent);
- else if (CSSPrimitiveValue::isUnitTypeLength(type)) {
- double multiplier = zoomFactor;
- if (m_style->textSizeAdjust()) {
- if (Frame* frame = m_checker.document()->frame())
- multiplier *= frame->textZoomFactor();
- }
- lineHeight = primitiveValue->computeLength<Length>(style(), m_rootElementStyle, multiplier);
- } else if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
- lineHeight = Length((m_style->fontSize() * primitiveValue->getIntValue()) / 100, Fixed);
- else if (type == CSSPrimitiveValue::CSS_NUMBER)
- lineHeight = Length(primitiveValue->getDoubleValue() * 100.0, Percent);
- else
- return;
- m_style->setLineHeight(lineHeight);
- return;
- }
-
// rect
case CSSPropertyClip:
{
@@ -3753,6 +3726,7 @@
case CSSPropertyBottom:
case CSSPropertyWidth:
case CSSPropertyMinWidth:
+ case CSSPropertyLineHeight:
case CSSPropertyListStyle:
case CSSPropertyListStyleImage:
case CSSPropertyListStylePosition: