Changeset 80379 in webkit
- Timestamp:
- Mar 4, 2011 3:05:51 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r80378 r80379 1 2011-03-04 Rik Cabanier <cabanier@gmail.com> 2 3 Reviewed by David Hyatt. 4 5 Fix that allows fixed length values to be floating point 6 https://bugs.webkit.org/show_bug.cgi?id=52699 7 8 Transitions now return matrices in floating point. 2 of the transition tests were failing 9 because they expected integer values. 10 11 * transitions/matched-transform-functions.html: 12 * transitions/retargetted-transition.html: 13 1 14 2011-03-03 Gavin Barraclough <barraclough@apple.com> 2 15 -
trunk/LayoutTests/transitions/matched-transform-functions.html
r79876 r80379 25 25 function test() 26 26 { 27 var t = window.getComputedStyle(document.getElementById('box')).webkitTransform; 28 // grab the last value from the matrix() 29 var lastValueRE = /(\d+)\)$/; 30 var yTranslate = parseInt(lastValueRE.exec(t)); 31 32 var result = (yTranslate < 200) ? 'PASS' : 'FAIL: transition should still be running, so y < 200'; 27 var c = new WebKitCSSMatrix(window.getComputedStyle(document.getElementById('box')).webkitTransform); 28 var result = (c.f < 200) ? 'PASS' : 'FAIL: transition should still be running, so y < 200'; 33 29 document.getElementById('result').innerHTML = result; 34 30 -
trunk/LayoutTests/transitions/retargetted-transition.html
r79876 r80379 24 24 function test() 25 25 { 26 var t = window.getComputedStyle(document.getElementById('box')).webkitTransform; 27 // grab the last value from the matrix() 28 var lastValueRE = /(\d+)\)$/; 29 var yTranslate = parseInt(lastValueRE.exec(t)); 30 31 var result = (yTranslate < 200) ? 'PASS' : 'FAIL: transition should still be running, so y < 200'; 26 var c = new WebKitCSSMatrix(window.getComputedStyle(document.getElementById('box')).webkitTransform); 27 var result = (c.f < 200) ? 'PASS' : 'FAIL: transition should still be running, so y < 200'; 32 28 document.getElementById('result').innerHTML = result; 33 29 -
trunk/Source/WebCore/ChangeLog
r80377 r80379 1 2011-03-04 Rik Cabanier <cabanier@gmail.com> 2 3 Reviewed by David Hyatt. 4 5 Fix that allows fixed length values to be floating point 6 https://bugs.webkit.org/show_bug.cgi?id=52699 7 8 * WebCore.xcodeproj/project.pbxproj: 9 * css/CSSStyleSelector.cpp: 10 (WebCore::convertToLength): 11 (WebCore::convertToIntLength): 12 (WebCore::convertToFloatLength): 13 (WebCore::CSSStyleSelector::applyProperty): 14 (WebCore::CSSStyleSelector::createTransformOperations): 15 * platform/Length.h: 16 (WebCore::Length::Length): 17 (WebCore::Length::operator==): 18 (WebCore::Length::operator!=): 19 (WebCore::Length::rawValue): 20 (WebCore::Length::type): 21 (WebCore::Length::quirk): 22 (WebCore::Length::setValue): 23 (WebCore::Length::calcFloatValue): 24 (WebCore::Length::isZero): 25 (WebCore::Length::blend): 26 (WebCore::Length::getIntValue): 27 (WebCore::Length::getFloatValue): 28 * rendering/AutoTableLayout.cpp: 29 (WebCore::AutoTableLayout::recalcColumn): 30 (WebCore::AutoTableLayout::calcEffectiveLogicalWidth): 31 * rendering/FixedTableLayout.cpp: 32 (WebCore::FixedTableLayout::calcWidthArray): 33 1 34 2011-03-04 Steve Falkenburg <sfalken@apple.com> 2 35 -
trunk/Source/WebCore/css/CSSStyleSelector.cpp
r80288 r80379 3364 3364 // this is mostly boring stuff on how to apply a certain rule to the renderstyle... 3365 3365 3366 static Length convertToLength(CSSPrimitiveValue* primitiveValue, RenderStyle* style, RenderStyle* rootStyle, double multiplier = 1, bool *ok = 0)3366 static Length convertToLength(CSSPrimitiveValue* primitiveValue, RenderStyle* style, RenderStyle* rootStyle, bool toFloat, double multiplier = 1, bool *ok = 0) 3367 3367 { 3368 3368 // This function is tolerant of a null style value. The only place style is used is in … … 3379 3379 if (ok) 3380 3380 *ok = false; 3381 } else if (CSSPrimitiveValue::isUnitTypeLength(type)) 3382 l = Length(primitiveValue->computeLengthIntForLength(style, rootStyle, multiplier), Fixed); 3381 } else if (CSSPrimitiveValue::isUnitTypeLength(type)) { 3382 if (toFloat) 3383 l = Length(primitiveValue->computeLengthDouble(style, rootStyle, multiplier), Fixed); 3384 else 3385 l = Length(primitiveValue->computeLengthIntForLength(style, rootStyle, multiplier), Fixed); 3386 } 3383 3387 else if (type == CSSPrimitiveValue::CSS_PERCENTAGE) 3384 3388 l = Length(primitiveValue->getDoubleValue(), Percent); … … 3389 3393 } 3390 3394 return l; 3395 } 3396 3397 static Length convertToIntLength(CSSPrimitiveValue* primitiveValue, RenderStyle* style, RenderStyle* rootStyle, double multiplier = 1, bool *ok = 0) 3398 { 3399 return convertToLength(primitiveValue, style, rootStyle, false, multiplier, ok); 3400 } 3401 3402 static Length convertToFloatLength(CSSPrimitiveValue* primitiveValue, RenderStyle* style, RenderStyle* rootStyle, double multiplier = 1, bool *ok = 0) 3403 { 3404 return convertToLength(primitiveValue, style, rootStyle, true, multiplier, ok); 3391 3405 } 3392 3406 … … 4710 4724 if (!rect) 4711 4725 return; 4712 top = convertTo Length(rect->top(), style(), m_rootElementStyle, zoomFactor);4713 right = convertTo Length(rect->right(), style(), m_rootElementStyle, zoomFactor);4714 bottom = convertTo Length(rect->bottom(), style(), m_rootElementStyle, zoomFactor);4715 left = convertTo Length(rect->left(), style(), m_rootElementStyle, zoomFactor);4726 top = convertToIntLength(rect->top(), style(), m_rootElementStyle, zoomFactor); 4727 right = convertToIntLength(rect->right(), style(), m_rootElementStyle, zoomFactor); 4728 bottom = convertToIntLength(rect->bottom(), style(), m_rootElementStyle, zoomFactor); 4729 left = convertToIntLength(rect->left(), style(), m_rootElementStyle, zoomFactor); 4716 4730 } else if (primitiveValue->getIdent() != CSSValueAuto) { 4717 4731 return; … … 5656 5670 else { 5657 5671 bool ok = true; 5658 Length l = convertToLength(primitiveValue, style(), m_rootElementStyle, 1, &ok);5672 Length marqueeLength = convertToIntLength(primitiveValue, style(), m_rootElementStyle, 1, &ok); 5659 5673 if (ok) 5660 m_style->setMarqueeIncrement( l);5674 m_style->setMarqueeIncrement(marqueeLength); 5661 5675 } 5662 5676 return; … … 5804 5818 DashboardRegion *first = region; 5805 5819 while (region) { 5806 Length top = convertTo Length(region->top(), style(), m_rootElementStyle);5807 Length right = convertTo Length(region->right(), style(), m_rootElementStyle);5808 Length bottom = convertTo Length(region->bottom(), style(), m_rootElementStyle);5809 Length left = convertTo Length(region->left(), style(), m_rootElementStyle);5820 Length top = convertToIntLength(region->top(), style(), m_rootElementStyle); 5821 Length right = convertToIntLength(region->right(), style(), m_rootElementStyle); 5822 Length bottom = convertToIntLength(region->bottom(), style(), m_rootElementStyle); 5823 Length left = convertToIntLength(region->left(), style(), m_rootElementStyle); 5810 5824 if (region->m_isCircle) 5811 5825 m_style->setDashboardRegion(StyleDashboardRegion::Circle, region->m_label, top, right, bottom, left, region == first ? false : true); … … 7265 7279 Length ty = Length(0, Fixed); 7266 7280 if (transformValue->operationType() == WebKitCSSTransformValue::TranslateYTransformOperation) 7267 ty = convertTo Length(firstValue, style, rootStyle, zoomFactor, &ok);7281 ty = convertToFloatLength(firstValue, style, rootStyle, zoomFactor, &ok); 7268 7282 else { 7269 tx = convertTo Length(firstValue, style, rootStyle, zoomFactor, &ok);7283 tx = convertToFloatLength(firstValue, style, rootStyle, zoomFactor, &ok); 7270 7284 if (transformValue->operationType() != WebKitCSSTransformValue::TranslateXTransformOperation) { 7271 7285 if (transformValue->length() > 1) { 7272 7286 CSSPrimitiveValue* secondValue = static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(1)); 7273 ty = convertTo Length(secondValue, style, rootStyle, zoomFactor, &ok);7287 ty = convertToFloatLength(secondValue, style, rootStyle, zoomFactor, &ok); 7274 7288 } 7275 7289 } … … 7289 7303 Length tz = Length(0, Fixed); 7290 7304 if (transformValue->operationType() == WebKitCSSTransformValue::TranslateZTransformOperation) 7291 tz = convertTo Length(firstValue, style, rootStyle, zoomFactor, &ok);7305 tz = convertToFloatLength(firstValue, style, rootStyle, zoomFactor, &ok); 7292 7306 else if (transformValue->operationType() == WebKitCSSTransformValue::TranslateYTransformOperation) 7293 ty = convertTo Length(firstValue, style, rootStyle, zoomFactor, &ok);7307 ty = convertToFloatLength(firstValue, style, rootStyle, zoomFactor, &ok); 7294 7308 else { 7295 tx = convertTo Length(firstValue, style, rootStyle, zoomFactor, &ok);7309 tx = convertToFloatLength(firstValue, style, rootStyle, zoomFactor, &ok); 7296 7310 if (transformValue->operationType() != WebKitCSSTransformValue::TranslateXTransformOperation) { 7297 7311 if (transformValue->length() > 2) { 7298 7312 CSSPrimitiveValue* thirdValue = static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(2)); 7299 tz = convertTo Length(thirdValue, style, rootStyle, zoomFactor, &ok);7313 tz = convertToFloatLength(thirdValue, style, rootStyle, zoomFactor, &ok); 7300 7314 } 7301 7315 if (transformValue->length() > 1) { 7302 7316 CSSPrimitiveValue* secondValue = static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(1)); 7303 ty = convertTo Length(secondValue, style, rootStyle, zoomFactor, &ok);7317 ty = convertToFloatLength(secondValue, style, rootStyle, zoomFactor, &ok); 7304 7318 } 7305 7319 } … … 7432 7446 Length p = Length(0, Fixed); 7433 7447 if (CSSPrimitiveValue::isUnitTypeLength(firstValue->primitiveType())) 7434 p = convertTo Length(firstValue, style, rootStyle, zoomFactor, &ok);7448 p = convertToFloatLength(firstValue, style, rootStyle, zoomFactor, &ok); 7435 7449 else { 7436 7450 // This is a quirk that should go away when 3d transforms are finalized. -
trunk/Source/WebCore/platform/Length.h
r79876 r80379 41 41 public: 42 42 Length() 43 : m_value(0)43 : m_intValue(0), m_quirk(false), m_type(Auto), m_isFloat(false) 44 44 { 45 45 } 46 46 47 47 Length(LengthType t) 48 : m_ value(t)48 : m_intValue(0), m_quirk(false), m_type(t), m_isFloat(false) 49 49 { 50 50 } 51 51 52 52 Length(int v, LengthType t, bool q = false) 53 : m_ value((v * 16) | (q << 3) | t) // FIXME: Doesn't work if the passed-in value is very large!53 : m_intValue(v), m_quirk(q), m_type(t), m_isFloat(false) 54 54 { 55 55 ASSERT(t != Percent); … … 57 57 58 58 Length(double v, LengthType t, bool q = false) 59 : m_value(static_cast<int>(v * percentScaleFactor) * 16 | (q << 3) | t) 60 { 61 ASSERT(t == Percent); 62 } 63 64 bool operator==(const Length& o) const { return m_value == o.m_value; } 65 bool operator!=(const Length& o) const { return m_value != o.m_value; } 59 : m_quirk(q), m_type(t), m_isFloat(false) 60 { 61 if (m_type == Percent) 62 m_intValue = static_cast<int>(v*percentScaleFactor); 63 else { 64 m_isFloat = true; 65 m_floatValue = static_cast<float>(v); 66 } 67 } 68 69 bool operator==(const Length& o) const { return (getFloatValue() == o.getFloatValue()) && (m_type == o.m_type) && (m_quirk == o.m_quirk); } 70 bool operator!=(const Length& o) const { return (getFloatValue() != o.getFloatValue()) || (m_type != o.m_type) || (m_quirk != o.m_quirk); } 66 71 67 72 int value() const { … … 70 75 } 71 76 72 int rawValue() const { return (m_value & ~0xF) / 16; }77 int rawValue() const { return getIntValue(); } 73 78 74 79 double percent() const … … 78 83 } 79 84 80 LengthType type() const { return static_cast<LengthType>(m_ value & 7); }81 bool quirk() const { return (m_value >> 3) & 1; }85 LengthType type() const { return static_cast<LengthType>(m_type); } 86 bool quirk() const { return m_quirk; } 82 87 83 88 void setValue(LengthType t, int value) 84 89 { 85 ASSERT(t != Percent); 86 setRawValue(t, value); 87 } 88 89 void setRawValue(LengthType t, int value) { m_value = value * 16 | (m_value & 0x8) | t; } 90 m_type = t; 91 m_intValue = value; 92 m_isFloat = false; 93 } 90 94 91 95 void setValue(int value) 92 96 { 93 97 ASSERT(!value || type() != Percent); 94 setRawValue(value); 95 } 96 97 void setRawValue(int value) { m_value = value * 16 | (m_value & 0xF); } 98 setValue(Fixed, value); 99 } 98 100 99 101 void setValue(LengthType t, double value) 100 102 { 101 ASSERT(t == Percent); 102 m_value = static_cast<int>(value * percentScaleFactor) * 16 | (m_value & 0x8) | t; 103 m_type = t; 104 m_floatValue = value; 105 m_isFloat = true; 103 106 } 104 107 105 108 void setValue(double value) 106 109 { 107 ASSERT(type() == Percent); 108 m_value = static_cast<int>(value * percentScaleFactor) * 16 | (m_value & 0xF); 110 *this = Length(value, Fixed); 109 111 } 110 112 … … 145 147 switch (type()) { 146 148 case Fixed: 147 return static_cast<float>(value());149 return getFloatValue(); 148 150 case Percent: 149 151 return static_cast<float>(maxValue * percent() / 100.0); … … 156 158 157 159 bool isUndefined() const { return rawValue() == undefinedLength; } 158 bool isZero() const { return ! (m_value & ~0xF); }160 bool isZero() const { return !getIntValue(); } 159 161 bool isPositive() const { return rawValue() > 0; } 160 162 bool isNegative() const { return rawValue() < 0; } … … 185 187 } 186 188 187 intfromValue = from.isZero() ? 0 : from.value();188 inttoValue = isZero() ? 0 : value();189 return Length( int(fromValue + (toValue - fromValue) * progress), resultType);189 double fromValue = from.isZero() ? 0 : from.value(); 190 double toValue = isZero() ? 0 : value(); 191 return Length(fromValue + (toValue - fromValue) * progress, resultType); 190 192 } 191 193 192 194 private: 193 int m_value; 195 int getIntValue() const 196 { 197 if (m_isFloat) 198 return static_cast<int>(m_floatValue); 199 return m_intValue; 200 } 201 202 float getFloatValue() const 203 { 204 if (m_isFloat) 205 return m_floatValue; 206 return m_intValue; 207 } 208 209 union { 210 int m_intValue; 211 float m_floatValue; 212 }; 213 bool m_quirk; 214 unsigned char m_type; 215 bool m_isFloat; 194 216 }; 195 217 -
trunk/Source/WebCore/rendering/AutoTableLayout.cpp
r79876 r80379 83 83 // FIXME: What is this arbitrary value? 84 84 if (cellLogicalWidth.rawValue() > 32760) 85 cellLogicalWidth.set RawValue(32760);85 cellLogicalWidth.setValue(32760); 86 86 if (cellLogicalWidth.isNegative()) 87 87 cellLogicalWidth.setValue(0); … … 375 375 percentMissing -= percent; 376 376 if (percent > 0) 377 m_layoutStruct[pos].effectiveLogicalWidth.set RawValue(Percent, percent);377 m_layoutStruct[pos].effectiveLogicalWidth.setValue(Percent, percent); 378 378 else 379 379 m_layoutStruct[pos].effectiveLogicalWidth = Length(); -
trunk/Source/WebCore/rendering/FixedTableLayout.cpp
r79876 r80379 119 119 } 120 120 if ((w.isFixed() || w.isPercent()) && w.isPositive()) { 121 m_width[currentEffectiveColumn].set RawValue(w.type(), w.rawValue() * spanInCurrentEffectiveColumn);121 m_width[currentEffectiveColumn].setValue(w.type(), w.rawValue() * spanInCurrentEffectiveColumn); 122 122 usedWidth += effWidth * spanInCurrentEffectiveColumn; 123 123 } … … 168 168 // Only set if no col element has already set it. 169 169 if (m_width[cCol + i].isAuto() && w.type() != Auto) { 170 m_width[cCol + i].set RawValue(w.type(), w.rawValue() * eSpan / span);170 m_width[cCol + i].setValue(w.type(), w.rawValue() * eSpan / span); 171 171 usedWidth += effWidth * eSpan / span; 172 172 }
Note: See TracChangeset
for help on using the changeset viewer.