Commit de2d9370 authored by tony@chromium.org's avatar tony@chromium.org

use more specific types in CSSFlexValue

https://bugs.webkit.org/show_bug.cgi?id=64763

Reviewed by Ojan Vafai.

No new tests because no change in functionality.

* css/CSSFlexValue.h:
(WebCore::CSSFlexValue::create):
(WebCore::CSSFlexValue::isFlexValue): Make it possible to tell if
    we're a flex value or not.  Will be needed when we're copying
    values to RenderStyle.
(WebCore::CSSFlexValue::positiveFlex): Use floats for positive and
    negative flex because in the render code, we use floats.
(WebCore::CSSFlexValue::negativeFlex): Add accessors for these since
    we'll need it when reading the flex values.
(WebCore::CSSFlexValue::preferredSize):
(WebCore::CSSFlexValue::CSSFlexValue):
* css/CSSParser.cpp:
(WebCore::CSSParser::parseValidPrimitive): Make the type more
    specific.
(WebCore::CSSParser::parseFlex):
* css/CSSParser.h:
* css/CSSValue.h:
(WebCore::CSSValue::isFlexValue):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@91268 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent ff63faae
2011-07-19 Tony Chang <tony@chromium.org>
use more specific types in CSSFlexValue
https://bugs.webkit.org/show_bug.cgi?id=64763
Reviewed by Ojan Vafai.
No new tests because no change in functionality.
* css/CSSFlexValue.h:
(WebCore::CSSFlexValue::create):
(WebCore::CSSFlexValue::isFlexValue): Make it possible to tell if
we're a flex value or not. Will be needed when we're copying
values to RenderStyle.
(WebCore::CSSFlexValue::positiveFlex): Use floats for positive and
negative flex because in the render code, we use floats.
(WebCore::CSSFlexValue::negativeFlex): Add accessors for these since
we'll need it when reading the flex values.
(WebCore::CSSFlexValue::preferredSize):
(WebCore::CSSFlexValue::CSSFlexValue):
* css/CSSParser.cpp:
(WebCore::CSSParser::parseValidPrimitive): Make the type more
specific.
(WebCore::CSSParser::parseFlex):
* css/CSSParser.h:
* css/CSSValue.h:
(WebCore::CSSValue::isFlexValue):
2011-07-19 Chris Fleizach <cfleizach@apple.com>
If the control associated with a <label> is hidden, the label is also hidden (incorrectly)
......@@ -38,7 +38,7 @@ namespace WebCore {
class CSSFlexValue : public CSSValue {
public:
static PassRefPtr<CSSFlexValue> create(double positiveFlex, double negativeFlex, PassRefPtr<CSSValue> preferredSize)
static PassRefPtr<CSSFlexValue> create(float positiveFlex, float negativeFlex, PassRefPtr<CSSPrimitiveValue> preferredSize)
{
return adoptRef(new CSSFlexValue(positiveFlex, negativeFlex, preferredSize));
}
......@@ -47,17 +47,23 @@ public:
virtual String cssText() const;
virtual bool isFlexValue() const { return true; }
float positiveFlex() { return m_positiveFlex; }
float negativeFlex() { return m_negativeFlex; }
CSSPrimitiveValue* preferredSize() { return m_preferredSize.get(); }
private:
CSSFlexValue(double positiveFlex, double negativeFlex, PassRefPtr<CSSValue> preferredSize)
CSSFlexValue(float positiveFlex, float negativeFlex, PassRefPtr<CSSPrimitiveValue> preferredSize)
: m_positiveFlex(positiveFlex)
, m_negativeFlex(negativeFlex)
, m_preferredSize(preferredSize)
{
}
double m_positiveFlex;
double m_negativeFlex;
RefPtr<CSSValue> m_preferredSize;
float m_positiveFlex;
float m_negativeFlex;
RefPtr<CSSPrimitiveValue> m_preferredSize;
};
}
......
......@@ -793,7 +793,7 @@ void CSSParser::checkForOrphanedUnits()
}
}
inline PassRefPtr<CSSValue> CSSParser::parseValidPrimitive(int id, CSSParserValue* value)
inline PassRefPtr<CSSPrimitiveValue> CSSParser::parseValidPrimitive(int id, CSSParserValue* value)
{
if (id)
return primitiveValueCache()->createIdentifierValue(id);
......@@ -5049,7 +5049,7 @@ bool CSSParser::parseFlex(int propId, bool important)
static const double unsetValue = -1;
double positiveFlex = unsetValue;
double negativeFlex = unsetValue;
RefPtr<CSSValue> preferredSize;
RefPtr<CSSPrimitiveValue> preferredSize;
while (CSSParserValue* arg = args->current()) {
if (validUnit(arg, FNumber | FNonNeg, m_strict)) {
......@@ -5080,7 +5080,7 @@ bool CSSParser::parseFlex(int propId, bool important)
if (!preferredSize)
preferredSize = primitiveValueCache()->createIdentifierValue(CSSValueAuto);
RefPtr<CSSFlexValue> flex = CSSFlexValue::create(positiveFlex, negativeFlex, preferredSize);
RefPtr<CSSFlexValue> flex = CSSFlexValue::create(clampToFloat(positiveFlex), clampToFloat(negativeFlex), preferredSize);
addProperty(propId, flex.release(), important);
return true;
#else
......
......@@ -68,7 +68,7 @@ namespace WebCore {
static bool parseValue(CSSMutableStyleDeclaration*, int propId, const String&, bool important, bool strict);
static bool parseColor(RGBA32& color, const String&, bool strict = false);
static bool parseSystemColor(RGBA32& color, const String&, Document*);
PassRefPtr<CSSValue> parseValidPrimitive(int propId, CSSParserValue*);
PassRefPtr<CSSPrimitiveValue> parseValidPrimitive(int propId, CSSParserValue*);
bool parseColor(CSSMutableStyleDeclaration*, const String&);
bool parseDeclaration(CSSMutableStyleDeclaration*, const String&, RefPtr<CSSStyleSourceData>* styleSourceData = 0);
bool parseMediaQuery(MediaList*, const String&);
......
......@@ -54,6 +54,9 @@ public:
virtual bool isBorderImageValue() const { return false; }
virtual bool isCursorImageValue() const { return false; }
#if ENABLE(CSS3_FLEXBOX)
virtual bool isFlexValue() const { return false; }
#endif
virtual bool isFontFamilyValue() const { return false; }
virtual bool isFontValue() const { return false; }
virtual bool isImageGeneratorValue() const { return false; }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment