Diff
Modified: trunk/Source/WebCore/ChangeLog (95501 => 95502)
--- trunk/Source/WebCore/ChangeLog 2011-09-20 01:04:25 UTC (rev 95501)
+++ trunk/Source/WebCore/ChangeLog 2011-09-20 01:20:12 UTC (rev 95502)
@@ -1,3 +1,52 @@
+2011-09-19 Luke Macpherson <[email protected]>
+
+ Eliminate Length::undefinedLength = -1 and replace with Undefined LengthType.
+ https://bugs.webkit.org/show_bug.cgi?id=68057
+
+ Reviewed by Darin Adler.
+
+ There appear to be many cases where -1 is actually a valid Length.
+ Encoding the validity of Length separately to the value is a natural solution.
+
+ No new tests / no behavioral changes.
+
+ * css/CSSComputedStyleDeclaration.cpp:
+ (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
+ * css/CSSPrimitiveValue.cpp:
+ (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
+ * css/CSSStyleApplyProperty.cpp:
+ (WebCore::ApplyPropertyLength::applyValue):
+ * platform/Length.h:
+ (WebCore::Length::Length):
+ (WebCore::Length::value):
+ (WebCore::Length::calcValue):
+ (WebCore::Length::calcMinValue):
+ (WebCore::Length::calcFloatValue):
+ (WebCore::Length::isUndefined):
+ * rendering/RenderBlock.cpp:
+ (WebCore::RenderBlock::computePreferredLogicalWidths):
+ * rendering/RenderDeprecatedFlexibleBox.cpp:
+ (WebCore::RenderDeprecatedFlexibleBox::computePreferredLogicalWidths):
+ * rendering/RenderFileUploadControl.cpp:
+ (WebCore::RenderFileUploadControl::computePreferredLogicalWidths):
+ * rendering/RenderImage.cpp:
+ (WebCore::RenderImage::isLogicalWidthSpecified):
+ (WebCore::RenderImage::isLogicalHeightSpecified):
+ * rendering/RenderListBox.cpp:
+ (WebCore::RenderListBox::computePreferredLogicalWidths):
+ * rendering/RenderMenuList.cpp:
+ (WebCore::RenderMenuList::computePreferredLogicalWidths):
+ * rendering/RenderReplaced.cpp:
+ (WebCore::RenderReplaced::computePreferredLogicalWidths):
+ * rendering/RenderSlider.cpp:
+ (WebCore::RenderSlider::computePreferredLogicalWidths):
+ * rendering/RenderTextControl.cpp:
+ (WebCore::RenderTextControl::computePreferredLogicalWidths):
+ * rendering/style/RenderStyle.h:
+ (WebCore::InheritedFlags::initialMaxSize):
+ * rendering/svg/RenderSVGRoot.cpp:
+ (WebCore::RenderSVGRoot::computePreferredLogicalWidths):
+
2011-09-19 Adam Barth <[email protected]>
Always enable ENABLE(EVENTSOURCE)
Modified: trunk/Source/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp (95501 => 95502)
--- trunk/Source/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp 2011-09-20 01:04:25 UTC (rev 95501)
+++ trunk/Source/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp 2011-09-20 01:20:12 UTC (rev 95502)
@@ -1423,8 +1423,8 @@
result = addAttributeToSet(result, atk_text_attribute_get_name(ATK_TEXT_ATTR_RISE), buffer.get());
}
- int indentation = style->textIndent().calcValue(object->size().width());
- if (indentation != undefinedLength) {
+ if (!style->textIndent().isUndefined()) {
+ int indentation = style->textIndent().calcValue(object->size().width());
buffer.set(g_strdup_printf("%i", indentation));
result = addAttributeToSet(result, atk_text_attribute_get_name(ATK_TEXT_ATTR_INDENT), buffer.get());
}
Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (95501 => 95502)
--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp 2011-09-20 01:04:25 UTC (rev 95501)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp 2011-09-20 01:20:12 UTC (rev 95502)
@@ -1395,13 +1395,13 @@
return primitiveValueCache->createValue(style->userModify());
case CSSPropertyMaxHeight: {
const Length& maxHeight = style->maxHeight();
- if (maxHeight.isFixed() && maxHeight.value() == undefinedLength)
+ if (maxHeight.isUndefined())
return primitiveValueCache->createIdentifierValue(CSSValueNone);
return primitiveValueCache->createValue(maxHeight);
}
case CSSPropertyMaxWidth: {
const Length& maxWidth = style->maxWidth();
- if (maxWidth.isFixed() && maxWidth.value() == undefinedLength)
+ if (maxWidth.isUndefined())
return primitiveValueCache->createIdentifierValue(CSSValueNone);
return primitiveValueCache->createValue(maxWidth);
}
Modified: trunk/Source/WebCore/css/CSSPrimitiveValue.cpp (95501 => 95502)
--- trunk/Source/WebCore/css/CSSPrimitiveValue.cpp 2011-09-20 01:04:25 UTC (rev 95501)
+++ trunk/Source/WebCore/css/CSSPrimitiveValue.cpp 2011-09-20 01:20:12 UTC (rev 95502)
@@ -226,6 +226,7 @@
m_value.num = length.percent();
break;
case Relative:
+ case Undefined:
ASSERT_NOT_REACHED();
break;
}
@@ -400,6 +401,7 @@
factor = cssPixelsPerInch * 12.0 / 72.0;
break;
default:
+ ASSERT_NOT_REACHED();
return -1.0;
}
Modified: trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp (95501 => 95502)
--- trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp 2011-09-20 01:04:25 UTC (rev 95501)
+++ trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp 2011-09-20 01:20:12 UTC (rev 95502)
@@ -328,7 +328,7 @@
CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
if (noneEnabled && primitiveValue->getIdent() == CSSValueNone)
if (noneUndefined)
- setValue(selector->style(), Length(undefinedLength, Fixed));
+ setValue(selector->style(), Length(Undefined));
else
setValue(selector->style(), Length());
else if (intrinsicEnabled && primitiveValue->getIdent() == CSSValueIntrinsic)
Modified: trunk/Source/WebCore/platform/Length.h (95501 => 95502)
--- trunk/Source/WebCore/platform/Length.h 2011-09-20 01:04:25 UTC (rev 95501)
+++ trunk/Source/WebCore/platform/Length.h 2011-09-20 01:20:12 UTC (rev 95502)
@@ -30,11 +30,10 @@
namespace WebCore {
-const int undefinedLength = -1;
const int intMaxForLength = 0x7ffffff; // max value for a 28-bit int
const int intMinForLength = (-0x7ffffff - 1); // min value for a 28-bit int
-enum LengthType { Auto, Relative, Percent, Fixed, Intrinsic, MinIntrinsic };
+enum LengthType { Auto, Relative, Percent, Fixed, Intrinsic, MinIntrinsic, Undefined };
struct Length {
WTF_MAKE_FAST_ALLOCATED;
@@ -56,17 +55,17 @@
Length(float v, LengthType t, bool q = false)
: m_floatValue(v), m_quirk(q), m_type(t), m_isFloat(true)
- {
+ {
}
Length(double v, LengthType t, bool q = false)
: m_quirk(q), m_type(t), m_isFloat(true)
- {
+ {
m_floatValue = static_cast<float>(v);
}
- bool operator==(const Length& o) const { return (getFloatValue() == o.getFloatValue()) && (m_type == o.m_type) && (m_quirk == o.m_quirk); }
- bool operator!=(const Length& o) const { return (getFloatValue() != o.getFloatValue()) || (m_type != o.m_type) || (m_quirk != o.m_quirk); }
+ bool operator==(const Length& o) const { return (m_type == o.m_type) && (m_quirk == o.m_quirk) && (isUndefined() || (getFloatValue() == o.getFloatValue())); }
+ bool operator!=(const Length& o) const { return !(*this == o); }
const Length& operator*=(float v)
{
@@ -78,7 +77,8 @@
return *this;
}
- int value() const {
+ int value() const
+ {
return getIntValue();
}
@@ -120,7 +120,8 @@
*this = Length(value, Fixed);
}
- // note: works only for certain types, returns undefinedLength otherwise
+ // Note: May only be called for Fixed, Percent and Auto lengths.
+ // Other types will ASSERT in order to catch invalid length calculations.
int calcValue(int maxValue, bool roundPercentages = false) const
{
switch (type()) {
@@ -129,9 +130,15 @@
return calcMinValue(maxValue, roundPercentages);
case Auto:
return maxValue;
- default:
- return undefinedLength;
+ case Relative:
+ case Intrinsic:
+ case MinIntrinsic:
+ case Undefined:
+ ASSERT_NOT_REACHED();
+ return 0;
}
+ ASSERT_NOT_REACHED();
+ return 0;
}
int calcMinValue(int maxValue, bool roundPercentages = false) const
@@ -145,9 +152,16 @@
// Don't remove the extra cast to float. It is needed for rounding on 32-bit Intel machines that use the FPU stack.
return static_cast<int>(static_cast<float>(maxValue * percent() / 100.0f));
case Auto:
- default:
return 0;
+ case Relative:
+ case Intrinsic:
+ case MinIntrinsic:
+ case Undefined:
+ ASSERT_NOT_REACHED();
+ return 0;
}
+ ASSERT_NOT_REACHED();
+ return 0;
}
float calcFloatValue(int maxValue) const
@@ -159,19 +173,26 @@
return static_cast<float>(maxValue * percent() / 100.0f);
case Auto:
return static_cast<float>(maxValue);
- default:
- return static_cast<float>(undefinedLength);
+ case Relative:
+ case Intrinsic:
+ case MinIntrinsic:
+ case Undefined:
+ ASSERT_NOT_REACHED();
+ return 0;
}
+ ASSERT_NOT_REACHED();
+ return 0;
}
- bool isUndefined() const { return value() == undefinedLength; }
+ bool isUndefined() const { return type() == Undefined; }
bool isZero() const
- {
+ {
+ ASSERT(!isUndefined());
return m_isFloat ? !m_floatValue : !m_intValue;
}
- bool isPositive() const { return getFloatValue() > 0; }
- bool isNegative() const { return getFloatValue() < 0; }
+ bool isPositive() const { return isUndefined() ? false : getFloatValue() > 0; }
+ bool isNegative() const { return isUndefined() ? false : getFloatValue() < 0; }
bool isAuto() const { return type() == Auto; }
bool isRelative() const { return type() == Relative; }
@@ -207,11 +228,13 @@
private:
int getIntValue() const
{
+ ASSERT(!isUndefined());
return m_isFloat ? static_cast<int>(m_floatValue) : m_intValue;
}
float getFloatValue() const
{
+ ASSERT(!isUndefined());
return m_isFloat ? m_floatValue : m_intValue;
}
Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (95501 => 95502)
--- trunk/Source/WebCore/rendering/RenderBlock.cpp 2011-09-20 01:04:25 UTC (rev 95501)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp 2011-09-20 01:20:12 UTC (rev 95502)
@@ -4758,7 +4758,7 @@
m_minPreferredLogicalWidth = max(m_minPreferredLogicalWidth, computeContentBoxLogicalWidth(style()->logicalMinWidth().value()));
}
- if (style()->logicalMaxWidth().isFixed() && style()->logicalMaxWidth().value() != undefinedLength) {
+ if (style()->logicalMaxWidth().isFixed()) {
m_maxPreferredLogicalWidth = min(m_maxPreferredLogicalWidth, computeContentBoxLogicalWidth(style()->logicalMaxWidth().value()));
m_minPreferredLogicalWidth = min(m_minPreferredLogicalWidth, computeContentBoxLogicalWidth(style()->logicalMaxWidth().value()));
}
Modified: trunk/Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp (95501 => 95502)
--- trunk/Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp 2011-09-20 01:04:25 UTC (rev 95501)
+++ trunk/Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp 2011-09-20 01:20:12 UTC (rev 95502)
@@ -202,7 +202,7 @@
m_minPreferredLogicalWidth = max(m_minPreferredLogicalWidth, computeContentBoxLogicalWidth(style()->minWidth().value()));
}
- if (style()->maxWidth().isFixed() && style()->maxWidth().value() != undefinedLength) {
+ if (style()->maxWidth().isFixed()) {
m_maxPreferredLogicalWidth = min(m_maxPreferredLogicalWidth, computeContentBoxLogicalWidth(style()->maxWidth().value()));
m_minPreferredLogicalWidth = min(m_minPreferredLogicalWidth, computeContentBoxLogicalWidth(style()->maxWidth().value()));
}
Modified: trunk/Source/WebCore/rendering/RenderFileUploadControl.cpp (95501 => 95502)
--- trunk/Source/WebCore/rendering/RenderFileUploadControl.cpp 2011-09-20 01:04:25 UTC (rev 95501)
+++ trunk/Source/WebCore/rendering/RenderFileUploadControl.cpp 2011-09-20 01:20:12 UTC (rev 95502)
@@ -188,7 +188,7 @@
else
m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth;
- if (style->maxWidth().isFixed() && style->maxWidth().value() != undefinedLength) {
+ if (style->maxWidth().isFixed()) {
m_maxPreferredLogicalWidth = min(m_maxPreferredLogicalWidth, computeContentBoxLogicalWidth(style->maxWidth().value()));
m_minPreferredLogicalWidth = min(m_minPreferredLogicalWidth, computeContentBoxLogicalWidth(style->maxWidth().value()));
}
Modified: trunk/Source/WebCore/rendering/RenderImage.cpp (95501 => 95502)
--- trunk/Source/WebCore/rendering/RenderImage.cpp 2011-09-20 01:04:25 UTC (rev 95501)
+++ trunk/Source/WebCore/rendering/RenderImage.cpp 2011-09-20 01:20:12 UTC (rev 95502)
@@ -486,8 +486,11 @@
case Intrinsic:
case MinIntrinsic:
return false;
+ case Undefined:
+ ASSERT_NOT_REACHED();
+ return false;
}
- ASSERT(false);
+ ASSERT_NOT_REACHED();
return false;
}
@@ -502,8 +505,11 @@
case Intrinsic:
case MinIntrinsic:
return false;
+ case Undefined:
+ ASSERT_NOT_REACHED();
+ return false;
}
- ASSERT(false);
+ ASSERT_NOT_REACHED();
return false;
}
Modified: trunk/Source/WebCore/rendering/RenderListBox.cpp (95501 => 95502)
--- trunk/Source/WebCore/rendering/RenderListBox.cpp 2011-09-20 01:04:25 UTC (rev 95501)
+++ trunk/Source/WebCore/rendering/RenderListBox.cpp 2011-09-20 01:20:12 UTC (rev 95502)
@@ -194,7 +194,7 @@
else
m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth;
- if (style()->maxWidth().isFixed() && style()->maxWidth().value() != undefinedLength) {
+ if (style()->maxWidth().isFixed()) {
m_maxPreferredLogicalWidth = min(m_maxPreferredLogicalWidth, computeContentBoxLogicalWidth(style()->maxWidth().value()));
m_minPreferredLogicalWidth = min(m_minPreferredLogicalWidth, computeContentBoxLogicalWidth(style()->maxWidth().value()));
}
Modified: trunk/Source/WebCore/rendering/RenderMenuList.cpp (95501 => 95502)
--- trunk/Source/WebCore/rendering/RenderMenuList.cpp 2011-09-20 01:04:25 UTC (rev 95501)
+++ trunk/Source/WebCore/rendering/RenderMenuList.cpp 2011-09-20 01:20:12 UTC (rev 95502)
@@ -273,7 +273,7 @@
else
m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth;
- if (style()->maxWidth().isFixed() && style()->maxWidth().value() != undefinedLength) {
+ if (style()->maxWidth().isFixed()) {
m_maxPreferredLogicalWidth = min(m_maxPreferredLogicalWidth, computeContentBoxLogicalWidth(style()->maxWidth().value()));
m_minPreferredLogicalWidth = min(m_minPreferredLogicalWidth, computeContentBoxLogicalWidth(style()->maxWidth().value()));
}
Modified: trunk/Source/WebCore/rendering/RenderReplaced.cpp (95501 => 95502)
--- trunk/Source/WebCore/rendering/RenderReplaced.cpp 2011-09-20 01:04:25 UTC (rev 95501)
+++ trunk/Source/WebCore/rendering/RenderReplaced.cpp 2011-09-20 01:20:12 UTC (rev 95502)
@@ -397,7 +397,7 @@
LayoutUnit borderAndPadding = borderAndPaddingWidth();
m_maxPreferredLogicalWidth = computeReplacedLogicalWidth(false) + borderAndPadding;
- if (style()->maxWidth().isFixed() && style()->maxWidth().value() != undefinedLength)
+ if (style()->maxWidth().isFixed())
m_maxPreferredLogicalWidth = min(m_maxPreferredLogicalWidth, style()->maxWidth().value() + (style()->boxSizing() == CONTENT_BOX ? borderAndPadding : 0));
if (style()->width().isPercent() || style()->height().isPercent()
Modified: trunk/Source/WebCore/rendering/RenderSlider.cpp (95501 => 95502)
--- trunk/Source/WebCore/rendering/RenderSlider.cpp 2011-09-20 01:04:25 UTC (rev 95501)
+++ trunk/Source/WebCore/rendering/RenderSlider.cpp 2011-09-20 01:20:12 UTC (rev 95502)
@@ -83,7 +83,7 @@
else
m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth;
- if (style()->maxWidth().isFixed() && style()->maxWidth().value() != undefinedLength) {
+ if (style()->maxWidth().isFixed()) {
m_maxPreferredLogicalWidth = min(m_maxPreferredLogicalWidth, computeContentBoxLogicalWidth(style()->maxWidth().value()));
m_minPreferredLogicalWidth = min(m_minPreferredLogicalWidth, computeContentBoxLogicalWidth(style()->maxWidth().value()));
}
Modified: trunk/Source/WebCore/rendering/RenderTextControl.cpp (95501 => 95502)
--- trunk/Source/WebCore/rendering/RenderTextControl.cpp 2011-09-20 01:04:25 UTC (rev 95501)
+++ trunk/Source/WebCore/rendering/RenderTextControl.cpp 2011-09-20 01:20:12 UTC (rev 95502)
@@ -288,7 +288,7 @@
else
m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth;
- if (style()->maxWidth().isFixed() && style()->maxWidth().value() != undefinedLength) {
+ if (style()->maxWidth().isFixed()) {
m_maxPreferredLogicalWidth = min(m_maxPreferredLogicalWidth, computeContentBoxLogicalWidth(style()->maxWidth().value()));
m_minPreferredLogicalWidth = min(m_minPreferredLogicalWidth, computeContentBoxLogicalWidth(style()->maxWidth().value()));
}
Modified: trunk/Source/WebCore/rendering/style/RenderStyle.h (95501 => 95502)
--- trunk/Source/WebCore/rendering/style/RenderStyle.h 2011-09-20 01:04:25 UTC (rev 95501)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.h 2011-09-20 01:20:12 UTC (rev 95502)
@@ -1357,7 +1357,7 @@
static int initialLetterWordSpacing() { return 0; }
static Length initialSize() { return Length(); }
static Length initialMinSize() { return Length(0, Fixed); }
- static Length initialMaxSize() { return Length(undefinedLength, Fixed); }
+ static Length initialMaxSize() { return Length(Undefined); }
static Length initialOffset() { return Length(); }
static Length initialMargin() { return Length(Fixed); }
static Length initialPadding() { return Length(Fixed); }
Modified: trunk/Source/WebCore/rendering/svg/RenderSVGRoot.cpp (95501 => 95502)
--- trunk/Source/WebCore/rendering/svg/RenderSVGRoot.cpp 2011-09-20 01:04:25 UTC (rev 95501)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGRoot.cpp 2011-09-20 01:20:12 UTC (rev 95502)
@@ -102,7 +102,7 @@
LayoutUnit borderAndPadding = borderAndPaddingWidth();
LayoutUnit width = computeReplacedLogicalWidth(false) + borderAndPadding;
- if (style()->maxWidth().isFixed() && style()->maxWidth().value() != undefinedLength)
+ if (style()->maxWidth().isFixed())
width = min(width, style()->maxWidth().value() + (style()->boxSizing() == CONTENT_BOX ? borderAndPadding : 0));
if (style()->width().isPercent() || (style()->width().isAuto() && style()->height().isPercent())) {