- Revision
- 105033
- Author
- macpher...@chromium.org
- Date
- 2012-01-15 15:18:28 -0800 (Sun, 15 Jan 2012)
Log Message
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):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (105032 => 105033)
--- trunk/Source/WebCore/ChangeLog 2012-01-15 20:14:31 UTC (rev 105032)
+++ trunk/Source/WebCore/ChangeLog 2012-01-15 23:18:28 UTC (rev 105033)
@@ -1,3 +1,37 @@
+2012-01-15 Luke Macpherson <macpher...@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 <pab...@motorola.com>
Fix compilation errors on build-webkit --debug --no-video on mac.
Modified: trunk/Source/WebCore/css/CSSFontSelector.cpp (105032 => 105033)
--- trunk/Source/WebCore/css/CSSFontSelector.cpp 2012-01-15 20:14:31 UTC (rev 105032)
+++ trunk/Source/WebCore/css/CSSFontSelector.cpp 2012-01-15 23:18:28 UTC (rev 105033)
@@ -285,9 +285,9 @@
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;
Modified: trunk/Source/WebCore/css/CSSGradientValue.cpp (105032 => 105033)
--- trunk/Source/WebCore/css/CSSGradientValue.cpp 2012-01-15 20:14:31 UTC (rev 105032)
+++ trunk/Source/WebCore/css/CSSGradientValue.cpp 2012-01-15 23:18:28 UTC (rev 105033)
@@ -117,7 +117,7 @@
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 @@
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 @@
{
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 @@
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 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 @@
} 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.
Modified: trunk/Source/WebCore/css/CSSPrimitiveValue.h (105032 => 105033)
--- trunk/Source/WebCore/css/CSSPrimitiveValue.h 2012-01-15 20:14:31 UTC (rev 105032)
+++ trunk/Source/WebCore/css/CSSPrimitiveValue.h 2012-01-15 23:18:28 UTC (rev 105033)
@@ -116,13 +116,20 @@
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)); }
static PassRefPtr<CSSPrimitiveValue> create(double value, UnitTypes type) { return adoptRef(new CSSPrimitiveValue(value, type)); }
Modified: trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp (105032 => 105033)
--- trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp 2012-01-15 20:14:31 UTC (rev 105032)
+++ trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp 2012-01-15 23:18:28 UTC (rev 105033)
@@ -329,12 +329,11 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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);