Changeset 95502 in webkit
- Timestamp:
- Sep 19, 2011, 6:20:12 PM (14 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r95501 r95502 1 2011-09-19 Luke Macpherson <macpherson@chromium.org> 2 3 Eliminate Length::undefinedLength = -1 and replace with Undefined LengthType. 4 https://bugs.webkit.org/show_bug.cgi?id=68057 5 6 Reviewed by Darin Adler. 7 8 There appear to be many cases where -1 is actually a valid Length. 9 Encoding the validity of Length separately to the value is a natural solution. 10 11 No new tests / no behavioral changes. 12 13 * css/CSSComputedStyleDeclaration.cpp: 14 (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): 15 * css/CSSPrimitiveValue.cpp: 16 (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): 17 * css/CSSStyleApplyProperty.cpp: 18 (WebCore::ApplyPropertyLength::applyValue): 19 * platform/Length.h: 20 (WebCore::Length::Length): 21 (WebCore::Length::value): 22 (WebCore::Length::calcValue): 23 (WebCore::Length::calcMinValue): 24 (WebCore::Length::calcFloatValue): 25 (WebCore::Length::isUndefined): 26 * rendering/RenderBlock.cpp: 27 (WebCore::RenderBlock::computePreferredLogicalWidths): 28 * rendering/RenderDeprecatedFlexibleBox.cpp: 29 (WebCore::RenderDeprecatedFlexibleBox::computePreferredLogicalWidths): 30 * rendering/RenderFileUploadControl.cpp: 31 (WebCore::RenderFileUploadControl::computePreferredLogicalWidths): 32 * rendering/RenderImage.cpp: 33 (WebCore::RenderImage::isLogicalWidthSpecified): 34 (WebCore::RenderImage::isLogicalHeightSpecified): 35 * rendering/RenderListBox.cpp: 36 (WebCore::RenderListBox::computePreferredLogicalWidths): 37 * rendering/RenderMenuList.cpp: 38 (WebCore::RenderMenuList::computePreferredLogicalWidths): 39 * rendering/RenderReplaced.cpp: 40 (WebCore::RenderReplaced::computePreferredLogicalWidths): 41 * rendering/RenderSlider.cpp: 42 (WebCore::RenderSlider::computePreferredLogicalWidths): 43 * rendering/RenderTextControl.cpp: 44 (WebCore::RenderTextControl::computePreferredLogicalWidths): 45 * rendering/style/RenderStyle.h: 46 (WebCore::InheritedFlags::initialMaxSize): 47 * rendering/svg/RenderSVGRoot.cpp: 48 (WebCore::RenderSVGRoot::computePreferredLogicalWidths): 49 1 50 2011-09-19 Adam Barth <abarth@webkit.org> 2 51 -
trunk/Source/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp
r94427 r95502 1424 1424 } 1425 1425 1426 i nt indentation = style->textIndent().calcValue(object->size().width());1427 if (indentation != undefinedLength) {1426 if (!style->textIndent().isUndefined()) { 1427 int indentation = style->textIndent().calcValue(object->size().width()); 1428 1428 buffer.set(g_strdup_printf("%i", indentation)); 1429 1429 result = addAttributeToSet(result, atk_text_attribute_get_name(ATK_TEXT_ATTR_INDENT), buffer.get()); -
trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp
r94989 r95502 1396 1396 case CSSPropertyMaxHeight: { 1397 1397 const Length& maxHeight = style->maxHeight(); 1398 if (maxHeight.is Fixed() && maxHeight.value() == undefinedLength)1398 if (maxHeight.isUndefined()) 1399 1399 return primitiveValueCache->createIdentifierValue(CSSValueNone); 1400 1400 return primitiveValueCache->createValue(maxHeight); … … 1402 1402 case CSSPropertyMaxWidth: { 1403 1403 const Length& maxWidth = style->maxWidth(); 1404 if (maxWidth.is Fixed() && maxWidth.value() == undefinedLength)1404 if (maxWidth.isUndefined()) 1405 1405 return primitiveValueCache->createIdentifierValue(CSSValueNone); 1406 1406 return primitiveValueCache->createValue(maxWidth); -
trunk/Source/WebCore/css/CSSPrimitiveValue.cpp
r95071 r95502 227 227 break; 228 228 case Relative: 229 case Undefined: 229 230 ASSERT_NOT_REACHED(); 230 231 break; … … 401 402 break; 402 403 default: 404 ASSERT_NOT_REACHED(); 403 405 return -1.0; 404 406 } -
trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp
r94625 r95502 329 329 if (noneEnabled && primitiveValue->getIdent() == CSSValueNone) 330 330 if (noneUndefined) 331 setValue(selector->style(), Length( undefinedLength, Fixed));331 setValue(selector->style(), Length(Undefined)); 332 332 else 333 333 setValue(selector->style(), Length()); -
trunk/Source/WebCore/platform/Length.h
r91969 r95502 31 31 namespace WebCore { 32 32 33 const int undefinedLength = -1;34 33 const int intMaxForLength = 0x7ffffff; // max value for a 28-bit int 35 34 const int intMinForLength = (-0x7ffffff - 1); // min value for a 28-bit int 36 35 37 enum LengthType { Auto, Relative, Percent, Fixed, Intrinsic, MinIntrinsic };36 enum LengthType { Auto, Relative, Percent, Fixed, Intrinsic, MinIntrinsic, Undefined }; 38 37 39 38 struct Length { … … 57 56 Length(float v, LengthType t, bool q = false) 58 57 : m_floatValue(v), m_quirk(q), m_type(t), m_isFloat(true) 59 { 58 { 60 59 } 61 60 62 61 Length(double v, LengthType t, bool q = false) 63 62 : m_quirk(q), m_type(t), m_isFloat(true) 64 { 63 { 65 64 m_floatValue = static_cast<float>(v); 66 65 } 67 66 68 bool operator==(const Length& o) const { return ( getFloatValue() == o.getFloatValue()) && (m_type == o.m_type) && (m_quirk == o.m_quirk); }69 bool operator!=(const Length& o) const { return (getFloatValue() != o.getFloatValue()) || (m_type != o.m_type) || (m_quirk != o.m_quirk); }67 bool operator==(const Length& o) const { return (m_type == o.m_type) && (m_quirk == o.m_quirk) && (isUndefined() || (getFloatValue() == o.getFloatValue())); } 68 bool operator!=(const Length& o) const { return !(*this == o); } 70 69 71 70 const Length& operator*=(float v) … … 79 78 } 80 79 81 int value() const { 80 int value() const 81 { 82 82 return getIntValue(); 83 83 } … … 121 121 } 122 122 123 // note: works only for certain types, returns undefinedLength otherwise 123 // Note: May only be called for Fixed, Percent and Auto lengths. 124 // Other types will ASSERT in order to catch invalid length calculations. 124 125 int calcValue(int maxValue, bool roundPercentages = false) const 125 126 { … … 130 131 case Auto: 131 132 return maxValue; 132 default: 133 return undefinedLength; 133 case Relative: 134 case Intrinsic: 135 case MinIntrinsic: 136 case Undefined: 137 ASSERT_NOT_REACHED(); 138 return 0; 134 139 } 140 ASSERT_NOT_REACHED(); 141 return 0; 135 142 } 136 143 … … 146 153 return static_cast<int>(static_cast<float>(maxValue * percent() / 100.0f)); 147 154 case Auto: 148 default: 155 return 0; 156 case Relative: 157 case Intrinsic: 158 case MinIntrinsic: 159 case Undefined: 160 ASSERT_NOT_REACHED(); 149 161 return 0; 150 162 } 163 ASSERT_NOT_REACHED(); 164 return 0; 151 165 } 152 166 … … 160 174 case Auto: 161 175 return static_cast<float>(maxValue); 162 default: 163 return static_cast<float>(undefinedLength); 176 case Relative: 177 case Intrinsic: 178 case MinIntrinsic: 179 case Undefined: 180 ASSERT_NOT_REACHED(); 181 return 0; 164 182 } 165 } 166 167 bool isUndefined() const { return value() == undefinedLength; } 183 ASSERT_NOT_REACHED(); 184 return 0; 185 } 186 187 bool isUndefined() const { return type() == Undefined; } 168 188 bool isZero() const 169 { 189 { 190 ASSERT(!isUndefined()); 170 191 return m_isFloat ? !m_floatValue : !m_intValue; 171 192 } 172 193 173 bool isPositive() const { return getFloatValue() > 0; }174 bool isNegative() const { return getFloatValue() < 0; }194 bool isPositive() const { return isUndefined() ? false : getFloatValue() > 0; } 195 bool isNegative() const { return isUndefined() ? false : getFloatValue() < 0; } 175 196 176 197 bool isAuto() const { return type() == Auto; } … … 208 229 int getIntValue() const 209 230 { 231 ASSERT(!isUndefined()); 210 232 return m_isFloat ? static_cast<int>(m_floatValue) : m_intValue; 211 233 } … … 213 235 float getFloatValue() const 214 236 { 237 ASSERT(!isUndefined()); 215 238 return m_isFloat ? m_floatValue : m_intValue; 216 239 } -
trunk/Source/WebCore/rendering/RenderBlock.cpp
r95478 r95502 4759 4759 } 4760 4760 4761 if (style()->logicalMaxWidth().isFixed() && style()->logicalMaxWidth().value() != undefinedLength) {4761 if (style()->logicalMaxWidth().isFixed()) { 4762 4762 m_maxPreferredLogicalWidth = min(m_maxPreferredLogicalWidth, computeContentBoxLogicalWidth(style()->logicalMaxWidth().value())); 4763 4763 m_minPreferredLogicalWidth = min(m_minPreferredLogicalWidth, computeContentBoxLogicalWidth(style()->logicalMaxWidth().value())); -
trunk/Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp
r94706 r95502 203 203 } 204 204 205 if (style()->maxWidth().isFixed() && style()->maxWidth().value() != undefinedLength) {205 if (style()->maxWidth().isFixed()) { 206 206 m_maxPreferredLogicalWidth = min(m_maxPreferredLogicalWidth, computeContentBoxLogicalWidth(style()->maxWidth().value())); 207 207 m_minPreferredLogicalWidth = min(m_minPreferredLogicalWidth, computeContentBoxLogicalWidth(style()->maxWidth().value())); -
trunk/Source/WebCore/rendering/RenderFileUploadControl.cpp
r94045 r95502 189 189 m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth; 190 190 191 if (style->maxWidth().isFixed() && style->maxWidth().value() != undefinedLength) {191 if (style->maxWidth().isFixed()) { 192 192 m_maxPreferredLogicalWidth = min(m_maxPreferredLogicalWidth, computeContentBoxLogicalWidth(style->maxWidth().value())); 193 193 m_minPreferredLogicalWidth = min(m_minPreferredLogicalWidth, computeContentBoxLogicalWidth(style->maxWidth().value())); -
trunk/Source/WebCore/rendering/RenderImage.cpp
r95103 r95502 487 487 case MinIntrinsic: 488 488 return false; 489 } 490 ASSERT(false); 489 case Undefined: 490 ASSERT_NOT_REACHED(); 491 return false; 492 } 493 ASSERT_NOT_REACHED(); 491 494 return false; 492 495 } … … 503 506 case MinIntrinsic: 504 507 return false; 505 } 506 ASSERT(false); 508 case Undefined: 509 ASSERT_NOT_REACHED(); 510 return false; 511 } 512 ASSERT_NOT_REACHED(); 507 513 return false; 508 514 } -
trunk/Source/WebCore/rendering/RenderListBox.cpp
r92998 r95502 195 195 m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth; 196 196 197 if (style()->maxWidth().isFixed() && style()->maxWidth().value() != undefinedLength) {197 if (style()->maxWidth().isFixed()) { 198 198 m_maxPreferredLogicalWidth = min(m_maxPreferredLogicalWidth, computeContentBoxLogicalWidth(style()->maxWidth().value())); 199 199 m_minPreferredLogicalWidth = min(m_minPreferredLogicalWidth, computeContentBoxLogicalWidth(style()->maxWidth().value())); -
trunk/Source/WebCore/rendering/RenderMenuList.cpp
r94427 r95502 274 274 m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth; 275 275 276 if (style()->maxWidth().isFixed() && style()->maxWidth().value() != undefinedLength) {276 if (style()->maxWidth().isFixed()) { 277 277 m_maxPreferredLogicalWidth = min(m_maxPreferredLogicalWidth, computeContentBoxLogicalWidth(style()->maxWidth().value())); 278 278 m_minPreferredLogicalWidth = min(m_minPreferredLogicalWidth, computeContentBoxLogicalWidth(style()->maxWidth().value())); -
trunk/Source/WebCore/rendering/RenderReplaced.cpp
r94912 r95502 398 398 m_maxPreferredLogicalWidth = computeReplacedLogicalWidth(false) + borderAndPadding; 399 399 400 if (style()->maxWidth().isFixed() && style()->maxWidth().value() != undefinedLength)400 if (style()->maxWidth().isFixed()) 401 401 m_maxPreferredLogicalWidth = min(m_maxPreferredLogicalWidth, style()->maxWidth().value() + (style()->boxSizing() == CONTENT_BOX ? borderAndPadding : 0)); 402 402 -
trunk/Source/WebCore/rendering/RenderSlider.cpp
r91574 r95502 84 84 m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth; 85 85 86 if (style()->maxWidth().isFixed() && style()->maxWidth().value() != undefinedLength) {86 if (style()->maxWidth().isFixed()) { 87 87 m_maxPreferredLogicalWidth = min(m_maxPreferredLogicalWidth, computeContentBoxLogicalWidth(style()->maxWidth().value())); 88 88 m_minPreferredLogicalWidth = min(m_minPreferredLogicalWidth, computeContentBoxLogicalWidth(style()->maxWidth().value())); -
trunk/Source/WebCore/rendering/RenderTextControl.cpp
r94252 r95502 289 289 m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth; 290 290 291 if (style()->maxWidth().isFixed() && style()->maxWidth().value() != undefinedLength) {291 if (style()->maxWidth().isFixed()) { 292 292 m_maxPreferredLogicalWidth = min(m_maxPreferredLogicalWidth, computeContentBoxLogicalWidth(style()->maxWidth().value())); 293 293 m_minPreferredLogicalWidth = min(m_minPreferredLogicalWidth, computeContentBoxLogicalWidth(style()->maxWidth().value())); -
trunk/Source/WebCore/rendering/style/RenderStyle.h
r94912 r95502 1358 1358 static Length initialSize() { return Length(); } 1359 1359 static Length initialMinSize() { return Length(0, Fixed); } 1360 static Length initialMaxSize() { return Length( undefinedLength, Fixed); }1360 static Length initialMaxSize() { return Length(Undefined); } 1361 1361 static Length initialOffset() { return Length(); } 1362 1362 static Length initialMargin() { return Length(Fixed); } -
trunk/Source/WebCore/rendering/svg/RenderSVGRoot.cpp
r94372 r95502 103 103 LayoutUnit width = computeReplacedLogicalWidth(false) + borderAndPadding; 104 104 105 if (style()->maxWidth().isFixed() && style()->maxWidth().value() != undefinedLength)105 if (style()->maxWidth().isFixed()) 106 106 width = min(width, style()->maxWidth().value() + (style()->boxSizing() == CONTENT_BOX ? borderAndPadding : 0)); 107 107
Note:
See TracChangeset
for help on using the changeset viewer.