Remove external references to CSSPrimitiveValue::UnitTypes enum.
authormacpherson@chromium.org <macpherson@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 15 Jan 2012 23:18:28 +0000 (23:18 +0000)
committermacpherson@chromium.org <macpherson@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 15 Jan 2012 23:18:28 +0000 (23:18 +0000)
https://bugs.webkit.org/show_bug.cgi?id=76229

Reviewed by Darin Adler.

No new tests / refactoring only.

* css/CSSFontSelector.cpp:
(WebCore::CSSFontSelector::addFontFaceRule):
* css/CSSGradientValue.cpp:
(WebCore::CSSGradientValue::addStops):
(WebCore::positionFromValue):
(WebCore::CSSGradientValue::isCacheable):
(WebCore::CSSRadialGradientValue::resolveRadius):
(WebCore::CSSRadialGradientValue::createGradient):
* css/CSSPrimitiveValue.h:
(WebCore::CSSPrimitiveValue::isUnitTypeLength):
(WebCore::CSSPrimitiveValue::isFontRelativeLength):
(WebCore::CSSPrimitiveValue::isIdent):
(WebCore::CSSPrimitiveValue::isNumber):
(WebCore::CSSPrimitiveValue::isPercentage):
(WebCore::CSSPrimitiveValue::isString):
(WebCore::CSSPrimitiveValue::isURI):
* css/CSSStyleApplyProperty.cpp:
(WebCore::ApplyPropertyLength::applyValue):
(WebCore::ApplyPropertyBorderRadius::applyValue):
(WebCore::ApplyPropertyFontSize::applyValue):
(WebCore::ApplyPropertyCursor::applyValue):
(WebCore::ApplyPropertyPageSize::applyValue):
(WebCore::ApplyPropertyTextEmphasisStyle::applyValue):
(WebCore::ApplyPropertyZoom::applyValue):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@105033 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/css/CSSFontSelector.cpp
Source/WebCore/css/CSSGradientValue.cpp
Source/WebCore/css/CSSPrimitiveValue.h
Source/WebCore/css/CSSStyleApplyProperty.cpp

index 67da4f0..2dfd139 100644 (file)
@@ -1,3 +1,37 @@
+2012-01-15  Luke Macpherson   <macpherson@chromium.org>
+
+        Remove external references to CSSPrimitiveValue::UnitTypes enum.
+        https://bugs.webkit.org/show_bug.cgi?id=76229
+
+        Reviewed by Darin Adler.
+
+        No new tests / refactoring only.
+
+        * css/CSSFontSelector.cpp:
+        (WebCore::CSSFontSelector::addFontFaceRule):
+        * css/CSSGradientValue.cpp:
+        (WebCore::CSSGradientValue::addStops):
+        (WebCore::positionFromValue):
+        (WebCore::CSSGradientValue::isCacheable):
+        (WebCore::CSSRadialGradientValue::resolveRadius):
+        (WebCore::CSSRadialGradientValue::createGradient):
+        * css/CSSPrimitiveValue.h:
+        (WebCore::CSSPrimitiveValue::isUnitTypeLength):
+        (WebCore::CSSPrimitiveValue::isFontRelativeLength):
+        (WebCore::CSSPrimitiveValue::isIdent):
+        (WebCore::CSSPrimitiveValue::isNumber):
+        (WebCore::CSSPrimitiveValue::isPercentage):
+        (WebCore::CSSPrimitiveValue::isString):
+        (WebCore::CSSPrimitiveValue::isURI):
+        * css/CSSStyleApplyProperty.cpp:
+        (WebCore::ApplyPropertyLength::applyValue):
+        (WebCore::ApplyPropertyBorderRadius::applyValue):
+        (WebCore::ApplyPropertyFontSize::applyValue):
+        (WebCore::ApplyPropertyCursor::applyValue):
+        (WebCore::ApplyPropertyPageSize::applyValue):
+        (WebCore::ApplyPropertyTextEmphasisStyle::applyValue):
+        (WebCore::ApplyPropertyZoom::applyValue):
+
 2012-01-15  Pablo Flouret  <pablof@motorola.com>
 
         Fix compilation errors on build-webkit --debug --no-video on mac.
index 58a551f..ada612c 100644 (file)
@@ -285,9 +285,9 @@ void CSSFontSelector::addFontFaceRule(const CSSFontFaceRule* fontFaceRule)
     for (int i = 0; i < familyLength; i++) {
         CSSPrimitiveValue* item = static_cast<CSSPrimitiveValue*>(familyList->itemWithoutBoundsCheck(i));
         String familyName;
-        if (item->primitiveType() == CSSPrimitiveValue::CSS_STRING)
+        if (item->isString())
             familyName = static_cast<FontFamilyValue*>(item)->familyName();
-        else if (item->primitiveType() == CSSPrimitiveValue::CSS_IDENT) {
+        else if (item->isIdent()) {
             // We need to use the raw text for all the generic family types, since @font-face is a way of actually
             // defining what font to use for those types.
             String familyName;
index 41977fb..d8d7253 100644 (file)
@@ -117,7 +117,7 @@ void CSSGradientValue::addStops(Gradient* gradient, RenderObject* renderer, Rend
             Color color = renderer->document()->styleSelector()->colorFromPrimitiveValue(stop.m_color.get());
 
             float offset;
-            if (stop.m_position->primitiveType() == CSSPrimitiveValue::CSS_PERCENTAGE)
+            if (stop.m_position->isPercentage())
                 offset = stop.m_position->getFloatValue(CSSPrimitiveValue::CSS_PERCENTAGE) / 100;
             else
                 offset = stop.m_position->getFloatValue(CSSPrimitiveValue::CSS_NUMBER);
@@ -150,10 +150,9 @@ void CSSGradientValue::addStops(Gradient* gradient, RenderObject* renderer, Rend
         stops[i].color = renderer->document()->styleSelector()->colorFromPrimitiveValue(stop.m_color.get());
 
         if (stop.m_position) {
-            int type = stop.m_position->primitiveType();
-            if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
+            if (stop.m_position->isPercentage())
                 stops[i].offset = stop.m_position->getFloatValue(CSSPrimitiveValue::CSS_PERCENTAGE) / 100;
-            else if (CSSPrimitiveValue::isUnitTypeLength(type)) {
+            else if (stop.m_position->isLength()) {
                 float length = stop.m_position->computeLength<float>(style, rootStyle, style->effectiveZoom());
                 if (!computedGradientLength) {
                     FloatSize gradientSize(gradientStart - gradientEnd);
@@ -363,32 +362,28 @@ static float positionFromValue(CSSPrimitiveValue* value, RenderStyle* style, Ren
 {
     float zoomFactor = style->effectiveZoom();
 
-    switch (value->primitiveType()) {
-    case CSSPrimitiveValue::CSS_NUMBER:
+    if (value->isNumber())
         return value->getFloatValue() * zoomFactor;
 
-    case CSSPrimitiveValue::CSS_PERCENTAGE:
+    if (value->isPercentage())
         return value->getFloatValue() / 100.f * (isHorizontal ? size.width() : size.height());
 
-    case CSSPrimitiveValue::CSS_IDENT:
-        switch (value->getIdent()) {
-            case CSSValueTop:
-                ASSERT(!isHorizontal);
-                return 0;
-            case CSSValueLeft:
-                ASSERT(isHorizontal);
-                return 0;
-            case CSSValueBottom:
-                ASSERT(!isHorizontal);
-                return size.height();
-            case CSSValueRight:
-                ASSERT(isHorizontal);
-                return size.width();
-        }
-
-    default:
-        return value->computeLength<float>(style, rootStyle, zoomFactor);
+    switch (value->getIdent()) {
+    case CSSValueTop:
+        ASSERT(!isHorizontal);
+        return 0;
+    case CSSValueLeft:
+        ASSERT(isHorizontal);
+        return 0;
+    case CSSValueBottom:
+        ASSERT(!isHorizontal);
+        return size.height();
+    case CSSValueRight:
+        ASSERT(isHorizontal);
+        return size.width();
     }
+
+    return value->computeLength<float>(style, rootStyle, zoomFactor);
 }
 
 FloatPoint CSSGradientValue::computeEndPoint(CSSPrimitiveValue* first, CSSPrimitiveValue* second, RenderStyle* style, RenderStyle* rootStyle, const IntSize& size)
@@ -416,8 +411,7 @@ bool CSSGradientValue::isCacheable() const
         if (!stop.m_position)
             continue;
 
-        unsigned short unitType = stop.m_position->primitiveType();
-        if (unitType == CSSPrimitiveValue::CSS_EMS || unitType == CSSPrimitiveValue::CSS_EXS || unitType == CSSPrimitiveValue::CSS_REMS)
+        if (stop.m_position->isFontRelativeLength())
             return false;
     }
 
@@ -640,9 +634,9 @@ float CSSRadialGradientValue::resolveRadius(CSSPrimitiveValue* radius, RenderSty
     float zoomFactor = style->effectiveZoom();
 
     float result = 0;
-    if (radius->primitiveType() == CSSPrimitiveValue::CSS_NUMBER)  // Can the radius be a percentage?
+    if (radius->isNumber()) // Can the radius be a percentage?
         result = radius->getFloatValue() * zoomFactor;
-    else if (widthOrHeight && radius->primitiveType() == CSSPrimitiveValue::CSS_PERCENTAGE)
+    else if (widthOrHeight && radius->isPercentage())
         result = *widthOrHeight * radius->getFloatValue() / 100;
     else
         result = radius->computeLength<float>(style, rootStyle, zoomFactor);
@@ -761,29 +755,27 @@ PassRefPtr<Gradient> CSSRadialGradientValue::createGradient(RenderObject* render
     } else {
         enum GradientShape { Circle, Ellipse };
         GradientShape shape = Ellipse;
-        if (m_shape && m_shape->primitiveType() == CSSPrimitiveValue::CSS_IDENT && m_shape->getIdent() == CSSValueCircle)
+        if (m_shape && m_shape->getIdent() == CSSValueCircle)
             shape = Circle;
 
         enum GradientFill { ClosestSide, ClosestCorner, FarthestSide, FarthestCorner };
         GradientFill fill = FarthestCorner;
 
-        if (m_sizingBehavior && m_sizingBehavior->primitiveType() == CSSPrimitiveValue::CSS_IDENT) {
-            switch (m_sizingBehavior->getIdent()) {
-            case CSSValueContain:
-            case CSSValueClosestSide:
-                fill = ClosestSide;
-                break;
-            case CSSValueClosestCorner:
-                fill = ClosestCorner;
-                break;
-            case CSSValueFarthestSide:
-                fill = FarthestSide;
-                break;
-            case CSSValueCover:
-            case CSSValueFarthestCorner:
-                fill = FarthestCorner;
-                break;
-            }
+        switch (m_sizingBehavior ? m_sizingBehavior->getIdent() : 0) {
+        case CSSValueContain:
+        case CSSValueClosestSide:
+            fill = ClosestSide;
+            break;
+        case CSSValueClosestCorner:
+            fill = ClosestCorner;
+            break;
+        case CSSValueFarthestSide:
+            fill = FarthestSide;
+            break;
+        case CSSValueCover:
+        case CSSValueFarthestCorner:
+            fill = FarthestCorner;
+            break;
         }
 
         // Now compute the end radii based on the second point, shape and fill.
index 8fd4ad2..9d55b41 100644 (file)
@@ -116,12 +116,19 @@ public:
         UOther
     };
 
-    static bool isUnitTypeLength(int type) { return (type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG) ||
-                                                    type == CSSPrimitiveValue::CSS_REMS; }
+    static bool isUnitTypeLength(int type) { return (type > CSS_PERCENTAGE && type < CSS_DEG) || type == CSS_REMS; }
 
+    bool isFontRelativeLength() const
+    {
+        return m_primitiveUnitType == CSS_EMS || m_primitiveUnitType == CSS_EXS || m_primitiveUnitType == CSS_REMS;
+    }
+    bool isIdent() const { return m_primitiveUnitType == CSS_IDENT; }
     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; }
+    bool isNumber() const { return m_primitiveUnitType == CSS_NUMBER; }
+    bool isPercentage() const { return m_primitiveUnitType == CSS_PERCENTAGE; }
+    bool isString() const { return m_primitiveUnitType == CSS_STRING; }
+    bool isURI() const { return m_primitiveUnitType == CSS_URI; }
+
 
     static PassRefPtr<CSSPrimitiveValue> createIdentifier(int identifier) { return adoptRef(new CSSPrimitiveValue(identifier)); }
     static PassRefPtr<CSSPrimitiveValue> createColor(unsigned rgbValue) { return adoptRef(new CSSPrimitiveValue(rgbValue)); }
index 45a6349..5ad6836 100644 (file)
@@ -329,12 +329,11 @@ public:
         else if (autoEnabled && primitiveValue->getIdent() == CSSValueAuto)
             setValue(selector->style(), Length());
         else {
-            int type = primitiveValue->primitiveType();
-            if (CSSPrimitiveValue::isUnitTypeLength(type)) {
+            if (primitiveValue->isLength()) {
                 Length length = primitiveValue->computeLength<Length>(selector->style(), selector->rootElementStyle(), selector->style()->effectiveZoom());
                 length.setQuirk(primitiveValue->isQuirkValue());
                 setValue(selector->style(), length);
-            } else if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
+            } else if (primitiveValue->isPercentage())
                 setValue(selector->style(), Length(primitiveValue->getDoubleValue(), Percent));
         }
     }
@@ -385,11 +384,11 @@ public:
 
         Length radiusWidth;
         Length radiusHeight;
-        if (pair->first()->primitiveType() == CSSPrimitiveValue::CSS_PERCENTAGE)
+        if (pair->first()->isPercentage())
             radiusWidth = Length(pair->first()->getDoubleValue(), Percent);
         else
             radiusWidth = Length(max(intMinForLength, min(intMaxForLength, pair->first()->computeLength<int>(selector->style(), selector->rootElementStyle(), selector->style()->effectiveZoom()))), Fixed);
-        if (pair->second()->primitiveType() == CSSPrimitiveValue::CSS_PERCENTAGE)
+        if (pair->second()->isPercentage())
             radiusHeight = Length(pair->second()->getDoubleValue(), Percent);
         else
             radiusHeight = Length(max(intMinForLength, min(intMaxForLength, pair->second()->computeLength<int>(selector->style(), selector->rootElementStyle(), selector->style()->effectiveZoom()))), Fixed);
@@ -669,12 +668,8 @@ public:
 
             fontDescription.setIsAbsoluteSize(parentIsAbsoluteSize && (ident == CSSValueLarger || ident == CSSValueSmaller));
         } else {
-            int type = primitiveValue->primitiveType();
             fontDescription.setIsAbsoluteSize(parentIsAbsoluteSize
-                                              || (type != CSSPrimitiveValue::CSS_PERCENTAGE
-                                                  && type != CSSPrimitiveValue::CSS_EMS
-                                                  && type != CSSPrimitiveValue::CSS_EXS
-                                                  && type != CSSPrimitiveValue::CSS_REMS));
+                                              || !(primitiveValue->isPercentage() || primitiveValue->isFontRelativeLength()));
             if (primitiveValue->isLength())
                 size = primitiveValue->computeLength<float>(selector->parentStyle(), selector->rootElementStyle(), 1.0, true);
             else if (primitiveValue->isPercentage())
@@ -1023,21 +1018,19 @@ public:
                 if (!item->isPrimitiveValue())
                     continue;
                 CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(item);
-                int type = primitiveValue->primitiveType();
-                if (type == CSSPrimitiveValue::CSS_URI) {
+                if (primitiveValue->isURI()) {
                     if (primitiveValue->isCursorImageValue()) {
                         CSSCursorImageValue* image = static_cast<CSSCursorImageValue*>(primitiveValue);
                         if (image->updateIfSVGCursorIsUsed(selector->element())) // Elements with SVG cursors are not allowed to share style.
                             selector->style()->setUnique();
                         selector->style()->addCursor(selector->cachedOrPendingFromValue(CSSPropertyCursor, image), image->hotSpot());
                     }
-                } else if (type == CSSPrimitiveValue::CSS_IDENT)
+                } else if (primitiveValue->isIdent())
                     selector->style()->setCursor(*primitiveValue);
             }
         } else if (value->isPrimitiveValue()) {
             CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
-            int type = primitiveValue->primitiveType();
-            if (type == CSSPrimitiveValue::CSS_IDENT && selector->style()->cursor() != ECursor(*primitiveValue))
+            if (primitiveValue->isIdent() && selector->style()->cursor() != ECursor(*primitiveValue))
                 selector->style()->setCursor(*primitiveValue);
         }
     }
@@ -1236,9 +1229,9 @@ public:
                 pageSizeType = PAGE_SIZE_RESOLVED;
                 width = height = primitiveValue->computeLength<Length>(selector->style(), selector->rootElementStyle());
             } else {
-                if (primitiveValue->primitiveType() != CSSPrimitiveValue::CSS_IDENT)
-                    return;
                 switch (primitiveValue->getIdent()) {
+                case 0:
+                    return;
                 case CSSValueAuto:
                     pageSizeType = PAGE_SIZE_AUTO;
                     break;
@@ -1308,7 +1301,7 @@ public:
             return;
         CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
 
-        if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_STRING) {
+        if (primitiveValue->isString()) {
             selector->style()->setTextEmphasisFill(TextEmphasisFillFilled);
             selector->style()->setTextEmphasisMark(TextEmphasisMarkCustom);
             selector->style()->setTextEmphasisCustomMark(primitiveValue->getStringValue());
@@ -1555,11 +1548,11 @@ public:
             float docZoom = selector->document()->renderer()->style()->zoom();
             selector->setEffectiveZoom(docZoom);
             selector->setZoom(docZoom);
-        } else if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_PERCENTAGE) {
+        } else if (primitiveValue->isPercentage()) {
             resetEffectiveZoom(selector);
             if (float percent = primitiveValue->getFloatValue())
                 selector->setZoom(percent / 100.0f);
-        } else if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_NUMBER) {
+        } else if (primitiveValue->isNumber()) {
             resetEffectiveZoom(selector);
             if (float number = primitiveValue->getFloatValue())
                 selector->setZoom(number);