Reviewed by Hyatt.
authorbdakin <bdakin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 22 Apr 2006 08:01:36 +0000 (08:01 +0000)
committerbdakin <bdakin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 22 Apr 2006 08:01:36 +0000 (08:01 +0000)
        Fix for http://bugzilla.opendarwin.org/show_bug.cgi?id=6141
        DOMCSSPrimitiveValue is always returning values in pixels when
        using getComputedStyle:

        getFloatValue() took a unit type as a parameter, ignored it, and
        returned m_value.num. This patch writes a second version of the
        function that actually converts m_value.num to the specified unites
        before returning it. Where a conversion is not required, I removed
        the unit type from the caller so that it would go directly to the
        inline version of the function.

        * css/css_valueimpl.cpp:
        (WebCore::CSSPrimitiveValue::computeLengthFloat): Remove type
        parameter since a conversion is not needed.
        (WebCore::scaleFactorForConversion): Helper function for
        conversion.
        (WebCore::CSSPrimitiveValue::getFloatValue): This version of
        getFloatValue() takes a unit type parameter and converts
        m_value.num.
        * css/css_valueimpl.h:
        (WebCore::CSSPrimitiveValue::getFloatValue): This version does not
        take a parameter and just returns m_value.num.
        * css/cssparser.cpp:
        (WebCore::BorderImageParseContext::commitBorderImage): Remove type
        parameter since a conversion is not needed.
        * css/cssstyleselector.cpp:
        (WebCore::convertToLength): Same.
        (WebCore::CSSStyleSelector::applyProperty): Same.
        (WebCore::CSSStyleSelector::mapBackgroundSize): Same.
        (WebCore::CSSStyleSelector::mapBackgroundXPosition): Same.
        (WebCore::CSSStyleSelector::mapBackgroundYPosition): Same.
        * editing/ApplyStyleCommand.cpp:
        (WebCore::ApplyStyleCommand::applyRelativeFontStyleChange): Same.
        * ksvg2/css/SVGCSSStyleSelector.cpp:
        (WebCore::CSSStyleSelector::applySVGProperty): Same.
        * ksvg2/misc/KCanvasRenderingStyle.cpp:
        (WebCore::KSVGPainterFactory::cssPrimitiveToLength): Same.

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

13 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/css/getFloatValueForUnit-expected.checksum [new file with mode: 0644]
LayoutTests/fast/css/getFloatValueForUnit-expected.png [new file with mode: 0644]
LayoutTests/fast/css/getFloatValueForUnit-expected.txt [new file with mode: 0644]
LayoutTests/fast/css/getFloatValueForUnit.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/css/css_valueimpl.cpp
WebCore/css/css_valueimpl.h
WebCore/css/cssparser.cpp
WebCore/css/cssstyleselector.cpp
WebCore/editing/ApplyStyleCommand.cpp
WebCore/ksvg2/css/SVGCSSStyleSelector.cpp
WebCore/ksvg2/misc/KCanvasRenderingStyle.cpp

index 5d38903..c6d7091 100644 (file)
@@ -1,3 +1,16 @@
+2006-04-22  Beth Dakin  <bdakin@apple.com>
+
+        Reviewed by Hyatt.
+
+        Layout test for  http://bugzilla.opendarwin.org/show_bug.cgi?id=6141 
+        DOMCSSPrimitiveValue is always returning values in pixels when 
+        using getComputedStyle:
+
+        * fast/css/getFloatValueForUnit-expected.checksum: Added.
+        * fast/css/getFloatValueForUnit-expected.png: Added.
+        * fast/css/getFloatValueForUnit-expected.txt: Added.
+        * fast/css/getFloatValueForUnit.html: Added.
+
 2006-04-21  Geoffrey Garen  <ggaren@apple.com>
         - Layout test for whether the error event bubbles.
 
diff --git a/LayoutTests/fast/css/getFloatValueForUnit-expected.checksum b/LayoutTests/fast/css/getFloatValueForUnit-expected.checksum
new file mode 100644 (file)
index 0000000..00c41eb
--- /dev/null
@@ -0,0 +1 @@
+aac74cf551377e05faf81bcc7dab978f
\ No newline at end of file
diff --git a/LayoutTests/fast/css/getFloatValueForUnit-expected.png b/LayoutTests/fast/css/getFloatValueForUnit-expected.png
new file mode 100644 (file)
index 0000000..0371721
Binary files /dev/null and b/LayoutTests/fast/css/getFloatValueForUnit-expected.png differ
diff --git a/LayoutTests/fast/css/getFloatValueForUnit-expected.txt b/LayoutTests/fast/css/getFloatValueForUnit-expected.txt
new file mode 100644 (file)
index 0000000..3ce65de
--- /dev/null
@@ -0,0 +1,11 @@
+layer at (0,0) size 800x600
+  RenderCanvas at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderBlock {DIV} at (0,0) size 784x0
+      RenderBlock (anonymous) at (0,0) size 784x18
+        RenderText {#text} at (0,0) size 45x18
+          text run at (0,0) width 45: "10pt = "
+        RenderText {#text} at (45,0) size 383x18
+          text run at (45,0) width 383: "3.4395833333333328mm (should be 3.4395833333333328)"
diff --git a/LayoutTests/fast/css/getFloatValueForUnit.html b/LayoutTests/fast/css/getFloatValueForUnit.html
new file mode 100644 (file)
index 0000000..9fd0f7d
--- /dev/null
@@ -0,0 +1,9 @@
+<body>
+<div id='d' style="font-size: 10pt"></div>
+10pt = 
+<script>
+//CSSPrimitiveValue.CSS_MM
+document.write(document.defaultView.getComputedStyle(document.getElementById('d'), '').getPropertyCSSValue('font-size').getFloatValue(7));
+document.write("mm (should be 3.4395833333333328)");
+</script>
+</body>
\ No newline at end of file
index 9dc7ff4..01c3434 100644 (file)
@@ -1,3 +1,45 @@
+2006-04-22  Beth Dakin  <bdakin@apple.com>
+
+        Reviewed by Hyatt.
+
+        Fix for http://bugzilla.opendarwin.org/show_bug.cgi?id=6141 
+        DOMCSSPrimitiveValue is always returning values in pixels when 
+        using getComputedStyle:
+
+        getFloatValue() took a unit type as a parameter, ignored it, and 
+        returned m_value.num. This patch writes a second version of the 
+        function that actually converts m_value.num to the specified unites 
+        before returning it. Where a conversion is not required, I removed 
+        the unit type from the caller so that it would go directly to the 
+        inline version of the function.
+
+        * css/css_valueimpl.cpp:
+        (WebCore::CSSPrimitiveValue::computeLengthFloat): Remove type 
+        parameter since a conversion is not needed.
+        (WebCore::scaleFactorForConversion): Helper function for 
+        conversion.
+        (WebCore::CSSPrimitiveValue::getFloatValue): This version of 
+        getFloatValue() takes a unit type parameter and converts 
+        m_value.num.
+        * css/css_valueimpl.h:
+        (WebCore::CSSPrimitiveValue::getFloatValue): This version does not 
+        take a parameter and just returns m_value.num.
+        * css/cssparser.cpp:
+        (WebCore::BorderImageParseContext::commitBorderImage): Remove type 
+        parameter since a conversion is not needed.
+        * css/cssstyleselector.cpp:
+        (WebCore::convertToLength): Same.
+        (WebCore::CSSStyleSelector::applyProperty): Same.
+        (WebCore::CSSStyleSelector::mapBackgroundSize): Same.
+        (WebCore::CSSStyleSelector::mapBackgroundXPosition): Same.
+        (WebCore::CSSStyleSelector::mapBackgroundYPosition): Same.
+        * editing/ApplyStyleCommand.cpp:
+        (WebCore::ApplyStyleCommand::applyRelativeFontStyleChange): Same.
+        * ksvg2/css/SVGCSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::applySVGProperty): Same.
+        * ksvg2/misc/KCanvasRenderingStyle.cpp:
+        (WebCore::KSVGPainterFactory::cssPrimitiveToLength): Same.
+
 2006-04-21  Geoffrey Garen  <ggaren@apple.com>
 
         Reviewed by John.
index b8ea5ef..be82539 100644 (file)
@@ -921,7 +921,7 @@ double CSSPrimitiveValue::computeLengthFloat(RenderStyle *style, bool applyZoomF
         return -1;
     }
 
-    return getFloatValue(type)*factor;
+    return getFloatValue() * factor;
 }
 
 void CSSPrimitiveValue::setFloatValue( unsigned short unitType, double floatValue, ExceptionCode& ec)
@@ -938,6 +938,54 @@ void CSSPrimitiveValue::setFloatValue( unsigned short unitType, double floatValu
     m_type = unitType;
 }
 
+double scaleFactorForConversion(unsigned short unitType)
+{
+    double cssPixelsPerInch = 96.0;
+    double factor = 1.0;
+    
+    switch(unitType) {
+        case CSSPrimitiveValue::CSS_PX:
+            break;
+        case CSSPrimitiveValue::CSS_CM:
+            factor = cssPixelsPerInch / 2.54; // (2.54 cm/in)
+            break;
+        case CSSPrimitiveValue::CSS_MM:
+            factor = cssPixelsPerInch / 25.4;
+            break;
+        case CSSPrimitiveValue::CSS_IN:
+            factor = cssPixelsPerInch;
+            break;
+        case CSSPrimitiveValue::CSS_PT:
+            factor = cssPixelsPerInch / 72.0;
+            break;
+        case CSSPrimitiveValue::CSS_PC:
+            factor = cssPixelsPerInch * 12.0 / 72.0; // 1 pc == 12 pt
+            break;
+        default:
+            break;
+    }
+    
+    return factor;
+}
+
+double CSSPrimitiveValue::getFloatValue(unsigned short unitType)
+{
+    if (unitType == m_type || unitType < CSS_PX || unitType > CSS_PC)
+        return m_value.num;
+    
+    double convertedValue = m_value.num;
+    
+    // First convert the value from m_type into CSSPixels
+    double factor = scaleFactorForConversion(m_type);
+    convertedValue *= factor;
+    
+    // Now convert from CSSPixels to the specified unitType
+    factor = scaleFactorForConversion(unitType);
+    convertedValue /= factor;
+    
+    return convertedValue;
+}
+
 void CSSPrimitiveValue::setStringValue( unsigned short stringType, const String &stringValue, ExceptionCode& ec)
 {
     ec = 0;
index 7fefedb..3b96cd1 100644 (file)
@@ -227,7 +227,8 @@ public:
     // use with care!!!
     void setPrimitiveType(unsigned short type) { m_type = type; }
     void setFloatValue(unsigned short unitType, double floatValue, ExceptionCode&);
-    double getFloatValue(unsigned short /* unitType */) const { return m_value.num; }
+    double getFloatValue(unsigned short unitType);
+    double getFloatValue() { return m_value.num; }
 
     void setStringValue(unsigned short stringType, const String& stringValue, ExceptionCode&);
     String getStringValue() const;
index 1f783f9..5619013 100644 (file)
@@ -2448,16 +2448,16 @@ struct BorderImageParseContext
     void commitBorderImage(CSSParser* p, int propId, bool important) {
         // We need to clone and repeat values for any omissions.
         if (!m_right) {
-            m_right = new CSSPrimitiveValue(m_top->getFloatValue(m_top->primitiveType()), (CSSPrimitiveValue::UnitTypes)m_top->primitiveType());
-            m_bottom = new CSSPrimitiveValue(m_top->getFloatValue(m_top->primitiveType()), (CSSPrimitiveValue::UnitTypes)m_top->primitiveType());
-            m_left = new CSSPrimitiveValue(m_top->getFloatValue(m_top->primitiveType()), (CSSPrimitiveValue::UnitTypes)m_top->primitiveType());
+            m_right = new CSSPrimitiveValue(m_top->getFloatValue(), (CSSPrimitiveValue::UnitTypes)m_top->primitiveType());
+            m_bottom = new CSSPrimitiveValue(m_top->getFloatValue(), (CSSPrimitiveValue::UnitTypes)m_top->primitiveType());
+            m_left = new CSSPrimitiveValue(m_top->getFloatValue(), (CSSPrimitiveValue::UnitTypes)m_top->primitiveType());
         }
         if (!m_bottom) {
-            m_bottom = new CSSPrimitiveValue(m_top->getFloatValue(m_top->primitiveType()), (CSSPrimitiveValue::UnitTypes)m_top->primitiveType());
-            m_left = new CSSPrimitiveValue(m_right->getFloatValue(m_right->primitiveType()), (CSSPrimitiveValue::UnitTypes)m_right->primitiveType());
+            m_bottom = new CSSPrimitiveValue(m_top->getFloatValue(), (CSSPrimitiveValue::UnitTypes)m_top->primitiveType());
+            m_left = new CSSPrimitiveValue(m_right->getFloatValue(), (CSSPrimitiveValue::UnitTypes)m_right->primitiveType());
         }
         if (!m_left)
-             m_left = new CSSPrimitiveValue(m_top->getFloatValue(m_top->primitiveType()), (CSSPrimitiveValue::UnitTypes)m_top->primitiveType());
+             m_left = new CSSPrimitiveValue(m_top->getFloatValue(), (CSSPrimitiveValue::UnitTypes)m_top->primitiveType());
              
         // Now build a rect value to hold all four of our primitive values.
         RectImpl* rect = new RectImpl;
index f6b03c5..96d96bf 100644 (file)
@@ -1624,9 +1624,9 @@ static Length convertToLength(CSSPrimitiveValue *primitiveValue, RenderStyle *st
         if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
             l = Length(primitiveValue->computeLengthIntForLength(style), Fixed);
         else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
-            l = Length(int(primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_PERCENTAGE)), Percent);
+            l = Length(int(primitiveValue->getFloatValue()), Percent);
         else if(type == CSSPrimitiveValue::CSS_NUMBER)
-            l = Length(int(primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_NUMBER)*100), Percent);
+            l = Length(int(primitiveValue->getFloatValue() * 100), Percent);
         else if (ok)
             *ok = false;
     }
@@ -2574,7 +2574,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
                 l = Length(primitiveValue->computeLengthIntForLength(style), Fixed, 
                            primitiveValue->isQuirkValue());
             else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
-                l = Length((int)primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent);
+                l = Length((int)primitiveValue->getFloatValue(), Percent);
             else
                 return;
             if (id == CSS_PROP_PADDING_LEFT || id == CSS_PROP_PADDING_RIGHT ||
@@ -2657,7 +2657,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
             if (type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
                 l = Length(primitiveValue->computeLengthIntForLength(style), Fixed);
             else if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
-                l = Length((int)primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent);
+                l = Length((int)primitiveValue->getFloatValue(), Percent);
             else
                 return;
             apply = true;
@@ -2713,7 +2713,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
           if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
             l = Length(primitiveValue->computeLengthIntForLength(style), Fixed);
           else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
-            l = Length(int(primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_PERCENTAGE)), Percent);
+            l = Length(int(primitiveValue->getFloatValue()), Percent);
 
           style->setVerticalAlign(LENGTH);
           style->setVerticalAlignLength(l);
@@ -2771,8 +2771,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
             if (type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
                 size = primitiveValue->computeLengthFloat(parentStyle, false);
             else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
-                size = (primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_PERCENTAGE)
-                        * oldSize) / 100;
+                size = (primitiveValue->getFloatValue() * oldSize) / 100;
             else
                 return;
         }
@@ -2805,7 +2804,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
         if (primitiveValue->primitiveType() != CSSPrimitiveValue::CSS_NUMBER)
             return; // Error case.
         
-        style->setZIndex((int)primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_NUMBER));
+        style->setZIndex((int)primitiveValue->getFloatValue());
         
         return;
     }
@@ -2815,7 +2814,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
         HANDLE_INHERIT_AND_INITIAL(widows, Widows)
         if (!primitiveValue || primitiveValue->primitiveType() != CSSPrimitiveValue::CSS_NUMBER)
             return;
-        style->setWidows((int)primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_NUMBER));
+        style->setWidows((int)primitiveValue->getFloatValue());
         break;
     }
         
@@ -2824,7 +2823,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
         HANDLE_INHERIT_AND_INITIAL(orphans, Orphans)
         if (!primitiveValue || primitiveValue->primitiveType() != CSSPrimitiveValue::CSS_NUMBER)
             return;
-        style->setOrphans((int)primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_NUMBER));
+        style->setOrphans((int)primitiveValue->getFloatValue());
         break;
     }        
 
@@ -2846,9 +2845,9 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
             }
             lineHeight = Length(primitiveValue->computeLengthIntForLength(style, multiplier), Fixed);
         } else if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
-            lineHeight = Length((style->fontSize() * int(primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_PERCENTAGE))) / 100, Fixed);
+            lineHeight = Length((style->fontSize() * int(primitiveValue->getFloatValue())) / 100, Fixed);
         else if (type == CSSPrimitiveValue::CSS_NUMBER)
-            lineHeight = Length(int(primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_NUMBER)*100), Percent);
+            lineHeight = Length(int(primitiveValue->getFloatValue() * 100), Percent);
         else
             return;
         style->setLineHeight(lineHeight);
@@ -3311,19 +3310,19 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
             LengthBox& l = image.m_slices;
             RectImpl* r = borderImage->m_imageSliceRect.get();
             if (r->top()->primitiveType() == CSSPrimitiveValue::CSS_PERCENTAGE)
-                l.top = Length((int)r->top()->getFloatValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent);
+                l.top = Length((int)r->top()->getFloatValue(), Percent);
             else
                 l.top = Length((int)r->top()->getFloatValue(CSSPrimitiveValue::CSS_NUMBER), Fixed);
             if (r->bottom()->primitiveType() == CSSPrimitiveValue::CSS_PERCENTAGE)
-                l.bottom = Length((int)r->bottom()->getFloatValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent);
+                l.bottom = Length((int)r->bottom()->getFloatValue(), Percent);
             else
                 l.bottom = Length((int)r->bottom()->getFloatValue(CSSPrimitiveValue::CSS_NUMBER), Fixed);
             if (r->left()->primitiveType() == CSSPrimitiveValue::CSS_PERCENTAGE)
-                l.left = Length((int)r->left()->getFloatValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent);
+                l.left = Length((int)r->left()->getFloatValue(), Percent);
             else
                 l.left = Length((int)r->left()->getFloatValue(CSSPrimitiveValue::CSS_NUMBER), Fixed);
             if (r->right()->primitiveType() == CSSPrimitiveValue::CSS_PERCENTAGE)
-                l.right = Length((int)r->right()->getFloatValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent);
+                l.right = Length((int)r->right()->getFloatValue(), Percent);
             else
                 l.right = Length((int)r->right()->getFloatValue(CSSPrimitiveValue::CSS_NUMBER), Fixed);
             
@@ -3469,7 +3468,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
         if (!primitiveValue || primitiveValue->primitiveType() != CSSPrimitiveValue::CSS_NUMBER)
             return; // Error case.
         // Clamp opacity to the range 0-1
-        style->setOpacity(min(1.0, max(0.0, primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_NUMBER))));
+        style->setOpacity(min(1.0, max(0.0, primitiveValue->getFloatValue())));
         return;
     case CSS_PROP__WEBKIT_BOX_ALIGN:
         HANDLE_INHERIT_AND_INITIAL(boxAlign, BoxAlign)
@@ -3543,19 +3542,19 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
         HANDLE_INHERIT_AND_INITIAL(boxFlex, BoxFlex)
         if (!primitiveValue || primitiveValue->primitiveType() != CSSPrimitiveValue::CSS_NUMBER)
             return; // Error case.
-        style->setBoxFlex(primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_NUMBER));
+        style->setBoxFlex(primitiveValue->getFloatValue());
         return;
     case CSS_PROP__WEBKIT_BOX_FLEX_GROUP:
         HANDLE_INHERIT_AND_INITIAL(boxFlexGroup, BoxFlexGroup)
         if (!primitiveValue || primitiveValue->primitiveType() != CSSPrimitiveValue::CSS_NUMBER)
             return; // Error case.
-        style->setBoxFlexGroup((unsigned int)(primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_NUMBER)));
+        style->setBoxFlexGroup((unsigned int)(primitiveValue->getFloatValue()));
         return;        
     case CSS_PROP__WEBKIT_BOX_ORDINAL_GROUP:
         HANDLE_INHERIT_AND_INITIAL(boxOrdinalGroup, BoxOrdinalGroup)
         if (!primitiveValue || primitiveValue->primitiveType() != CSSPrimitiveValue::CSS_NUMBER)
             return; // Error case.
-        style->setBoxOrdinalGroup((unsigned int)(primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_NUMBER)));
+        style->setBoxOrdinalGroup((unsigned int)(primitiveValue->getFloatValue()));
         return;
     case CSS_PROP_BOX_SIZING:
         HANDLE_INHERIT_AND_INITIAL(boxSizing, BoxSizing)
@@ -3579,7 +3578,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
         if (primitiveValue->getIdent() == CSS_VAL_INFINITE)
             style->setMarqueeLoopCount(-1); // -1 means repeat forever.
         else if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_NUMBER)
-            style->setMarqueeLoopCount((int)(primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_NUMBER)));
+            style->setMarqueeLoopCount((int)(primitiveValue->getFloatValue()));
         break;
     }
     case CSS_PROP__WEBKIT_MARQUEE_SPEED: {
@@ -3600,11 +3599,11 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
             }
         }
         else if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_S)
-            style->setMarqueeSpeed(int(1000*primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_S)));
+            style->setMarqueeSpeed(int(1000*primitiveValue->getFloatValue()));
         else if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_MS)
-            style->setMarqueeSpeed(int(primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_MS)));
+            style->setMarqueeSpeed(int(primitiveValue->getFloatValue()));
         else if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_NUMBER) // For scrollamount support.
-            style->setMarqueeSpeed(int(primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_NUMBER)));
+            style->setMarqueeSpeed(int(primitiveValue->getFloatValue()));
         break;
     }
     case CSS_PROP__WEBKIT_MARQUEE_INCREMENT: {
@@ -3988,7 +3987,7 @@ void CSSStyleSelector::mapBackgroundSize(BackgroundLayer* layer, CSSValue* value
     else if (firstType > CSSPrimitiveValue::CSS_PERCENTAGE && firstType < CSSPrimitiveValue::CSS_DEG)
         firstLength = Length(first->computeLengthIntForLength(style), Fixed);
     else if (firstType == CSSPrimitiveValue::CSS_PERCENTAGE)
-        firstLength = Length((int)first->getFloatValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent);
+        firstLength = Length((int)first->getFloatValue(), Percent);
     else
         return;
 
@@ -3997,7 +3996,7 @@ void CSSStyleSelector::mapBackgroundSize(BackgroundLayer* layer, CSSValue* value
     else if (secondType > CSSPrimitiveValue::CSS_PERCENTAGE && secondType < CSSPrimitiveValue::CSS_DEG)
         secondLength = Length(second->computeLengthIntForLength(style), Fixed);
     else if (secondType == CSSPrimitiveValue::CSS_PERCENTAGE)
-        secondLength = Length((int)second->getFloatValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent);
+        secondLength = Length((int)second->getFloatValue(), Percent);
     else
         return;
     
@@ -4021,7 +4020,7 @@ void CSSStyleSelector::mapBackgroundXPosition(BackgroundLayer* layer, CSSValue*
     if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
         l = Length(primitiveValue->computeLengthIntForLength(style), Fixed);
     else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
-        l = Length((int)primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent);
+        l = Length((int)primitiveValue->getFloatValue(), Percent);
     else
         return;
     layer->setBackgroundXPosition(l);
@@ -4042,7 +4041,7 @@ void CSSStyleSelector::mapBackgroundYPosition(BackgroundLayer* layer, CSSValue*
     if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
         l = Length(primitiveValue->computeLengthIntForLength(style), Fixed);
     else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
-        l = Length((int)primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent);
+        l = Length((int)primitiveValue->getFloatValue(), Percent);
     else
         return;
     layer->setBackgroundYPosition(l);
index a90b37f..bdd492a 100644 (file)
@@ -423,7 +423,7 @@ void ApplyStyleCommand::applyRelativeFontStyleChange(CSSMutableStyleDeclaration
         if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_PX) {
             // Only PX handled now. If we handle more types in the future, perhaps
             // a switch statement here would be more appropriate.
-            adjustment = primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_PX);
+            adjustment = primitiveValue->getFloatValue();
         }
     }
     style->removeProperty(CSS_PROP__WEBKIT_FONT_SIZE_DELTA);
index a86d968..1dbcf98 100644 (file)
@@ -431,9 +431,9 @@ void CSSStyleSelector::applySVGProperty(int id, CSSValue *value)
             float f = 0.0;    
             int type = primitiveValue->primitiveType();
             if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
-                f = primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_PERCENTAGE) / 100.;
+                f = primitiveValue->getFloatValue() / 100.;
             else if(type == CSSPrimitiveValue::CSS_NUMBER)
-                f = primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_NUMBER);
+                f = primitiveValue->getFloatValue();
             else
                 return;
 
@@ -449,9 +449,9 @@ void CSSStyleSelector::applySVGProperty(int id, CSSValue *value)
             float f = 0.0;    
             int type = primitiveValue->primitiveType();
             if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
-                f = primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_PERCENTAGE) / 100.;
+                f = primitiveValue->getFloatValue() / 100.;
             else if(type == CSSPrimitiveValue::CSS_NUMBER)
-                f = primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_NUMBER);
+                f = primitiveValue->getFloatValue();
             else
                 return;
 
@@ -467,9 +467,9 @@ void CSSStyleSelector::applySVGProperty(int id, CSSValue *value)
             float f = 0.0;    
             int type = primitiveValue->primitiveType();
             if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
-                f = primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_PERCENTAGE) / 100.;
+                f = primitiveValue->getFloatValue() / 100.;
             else if(type == CSSPrimitiveValue::CSS_NUMBER)
-                f = primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_NUMBER);
+                f = primitiveValue->getFloatValue();
             else
                 return;
 
@@ -555,7 +555,7 @@ void CSSStyleSelector::applySVGProperty(int id, CSSValue *value)
             float f = 0.0;
             int type = primitiveValue->primitiveType();
             if(type == CSSPrimitiveValue::CSS_NUMBER)
-                f = primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_NUMBER);
+                f = primitiveValue->getFloatValue();
             else
                 return;
 
@@ -696,9 +696,9 @@ void CSSStyleSelector::applySVGProperty(int id, CSSValue *value)
             float f = 0.0;    
             int type = primitiveValue->primitiveType();
             if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
-                f = primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_PERCENTAGE) / 100.;
+                f = primitiveValue->getFloatValue() / 100.;
             else if(type == CSSPrimitiveValue::CSS_NUMBER)
-                f = primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_NUMBER);
+                f = primitiveValue->getFloatValue();
             else
                 return;
 
index f67375a..d965e74 100644 (file)
@@ -140,7 +140,7 @@ double KSVGPainterFactory::cssPrimitiveToLength(const RenderObject* item, CSSVal
         SVGElement *viewportElement = (element ? element->viewportElement() : 0);
         if(viewportElement)
         {
-            double result = primitive->getFloatValue(CSSPrimitiveValue::CSS_PERCENTAGE) / 100.0;
+            double result = primitive->getFloatValue() / 100.0;
             return SVGHelper::PercentageOfViewport(result, viewportElement, LM_OTHER);
         }
     }