Changeset 79784 in webkit
- Timestamp:
- Feb 26, 2011 6:40:20 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r79783 r79784 1 2011-02-26 Rik Cabanier <cabanier@adobe.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-02-26 Kenneth Rohde Christiansen <kenneth@webkit.org> 2 15 -
trunk/LayoutTests/transitions/matched-transform-functions.html
r37496 r79784 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'; 29 33 30 document.getElementById('result').innerHTML = result; 34 31 -
trunk/LayoutTests/transitions/retargetted-transition.html
r37495 r79784 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
r79781 r79784 1 2011-02-26 Rik Cabanier <cabanier@adobe.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 * WebCore.xcodeproj/project.pbxproj: 12 * css/CSSStyleSelector.cpp: 13 (WebCore::convertToLength): 14 (WebCore::convertToIntLength): 15 (WebCore::convertToFloatLength): 16 (WebCore::CSSStyleSelector::applyProperty): 17 (WebCore::CSSStyleSelector::createTransformOperations): 18 * platform/Length.h: 19 (WebCore::Length::Length): 20 (WebCore::Length::operator==): 21 (WebCore::Length::operator!=): 22 (WebCore::Length::rawValue): 23 (WebCore::Length::type): 24 (WebCore::Length::quirk): 25 (WebCore::Length::setValue): 26 (WebCore::Length::calcFloatValue): 27 (WebCore::Length::isZero): 28 (WebCore::Length::blend): 29 (WebCore::Length::getIntValue): 30 (WebCore::Length::getFloatValue): 31 * rendering/AutoTableLayout.cpp: 32 (WebCore::AutoTableLayout::recalcColumn): 33 (WebCore::AutoTableLayout::calcEffectiveLogicalWidth): 34 * rendering/FixedTableLayout.cpp: 35 (WebCore::FixedTableLayout::calcWidthArray): 36 1 37 2011-02-26 Eric Seidel <eric@webkit.org> 2 38 -
trunk/Source/WebCore/css/CSSStyleSelector.cpp
r79298 r79784 3335 3335 // ------------------------------------------------------------------------------------- 3336 3336 // this is mostly boring stuff on how to apply a certain rule to the renderstyle... 3337 3338 static Length convertToLength(CSSPrimitiveValue* primitiveValue, RenderStyle* style, RenderStyle* rootStyle, double multiplier = 1, bool *ok = 0) 3337 static Length convertToLength(CSSPrimitiveValue* primitiveValue, RenderStyle* style, RenderStyle* rootStyle, bool toFloat, double multiplier = 1, bool *ok = 0) 3339 3338 { 3340 3339 // This function is tolerant of a null style value. The only place style is used is in … … 3347 3346 } else { 3348 3347 int type = primitiveValue->primitiveType(); 3349 3348 3350 3349 if (!style && (type == CSSPrimitiveValue::CSS_EMS || type == CSSPrimitiveValue::CSS_EXS || type == CSSPrimitiveValue::CSS_REMS)) { 3351 3350 if (ok) 3352 3351 *ok = false; 3353 } else if (CSSPrimitiveValue::isUnitTypeLength(type)) 3354 l = Length(primitiveValue->computeLengthIntForLength(style, rootStyle, multiplier), Fixed); 3352 } else if (CSSPrimitiveValue::isUnitTypeLength(type)) { 3353 if (toFloat) 3354 l = Length(primitiveValue->computeLengthDouble(style, rootStyle, multiplier), Fixed); 3355 else 3356 l = Length(primitiveValue->computeLengthIntForLength(style, rootStyle, multiplier), Fixed); 3357 } 3355 3358 else if (type == CSSPrimitiveValue::CSS_PERCENTAGE) 3356 3359 l = Length(primitiveValue->getDoubleValue(), Percent); … … 3361 3364 } 3362 3365 return l; 3366 } 3367 3368 static Length convertToIntLength(CSSPrimitiveValue* primitiveValue, RenderStyle* style, RenderStyle* rootStyle, double multiplier = 1, bool *ok = 0) 3369 { 3370 return convertToLength(primitiveValue, style, rootStyle, false, multiplier, ok); 3371 } 3372 3373 static Length convertToFloatLength(CSSPrimitiveValue* primitiveValue, RenderStyle* style, RenderStyle* rootStyle, double multiplier = 1, bool *ok = 0) 3374 { 3375 return convertToLength(primitiveValue, style, rootStyle, true, multiplier, ok); 3363 3376 } 3364 3377 … … 4682 4695 if (!rect) 4683 4696 return; 4684 top = convertTo Length(rect->top(), style(), m_rootElementStyle, zoomFactor);4685 right = convertTo Length(rect->right(), style(), m_rootElementStyle, zoomFactor);4686 bottom = convertTo Length(rect->bottom(), style(), m_rootElementStyle, zoomFactor);4687 left = convertTo Length(rect->left(), style(), m_rootElementStyle, zoomFactor);4697 top = convertToIntLength(rect->top(), style(), m_rootElementStyle, zoomFactor); 4698 right = convertToIntLength(rect->right(), style(), m_rootElementStyle, zoomFactor); 4699 bottom = convertToIntLength(rect->bottom(), style(), m_rootElementStyle, zoomFactor); 4700 left = convertToIntLength(rect->left(), style(), m_rootElementStyle, zoomFactor); 4688 4701 } else if (primitiveValue->getIdent() != CSSValueAuto) { 4689 4702 return; … … 5574 5587 else { 5575 5588 bool ok = true; 5576 Length l = convertToLength(primitiveValue, style(), m_rootElementStyle, 1, &ok);5589 Length marqueeLength = convertToIntLength(primitiveValue, style(), m_rootElementStyle, 1, &ok); 5577 5590 if (ok) 5578 m_style->setMarqueeIncrement( l);5591 m_style->setMarqueeIncrement(marqueeLength); 5579 5592 } 5580 5593 return; … … 5722 5735 DashboardRegion *first = region; 5723 5736 while (region) { 5724 Length top = convertTo Length(region->top(), style(), m_rootElementStyle);5725 Length right = convertTo Length(region->right(), style(), m_rootElementStyle);5726 Length bottom = convertTo Length(region->bottom(), style(), m_rootElementStyle);5727 Length left = convertTo Length(region->left(), style(), m_rootElementStyle);5737 Length top = convertToIntLength(region->top(), style(), m_rootElementStyle); 5738 Length right = convertToIntLength(region->right(), style(), m_rootElementStyle); 5739 Length bottom = convertToIntLength(region->bottom(), style(), m_rootElementStyle); 5740 Length left = convertToIntLength(region->left(), style(), m_rootElementStyle); 5728 5741 if (region->m_isCircle) 5729 5742 m_style->setDashboardRegion(StyleDashboardRegion::Circle, region->m_label, top, right, bottom, left, region == first ? false : true); … … 7184 7197 Length ty = Length(0, Fixed); 7185 7198 if (transformValue->operationType() == WebKitCSSTransformValue::TranslateYTransformOperation) 7186 ty = convertTo Length(firstValue, style, rootStyle, zoomFactor, &ok);7199 ty = convertToFloatLength(firstValue, style, rootStyle, zoomFactor, &ok); 7187 7200 else { 7188 tx = convertTo Length(firstValue, style, rootStyle, zoomFactor, &ok);7201 tx = convertToFloatLength(firstValue, style, rootStyle, zoomFactor, &ok); 7189 7202 if (transformValue->operationType() != WebKitCSSTransformValue::TranslateXTransformOperation) { 7190 7203 if (transformValue->length() > 1) { 7191 7204 CSSPrimitiveValue* secondValue = static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(1)); 7192 ty = convertTo Length(secondValue, style, rootStyle, zoomFactor, &ok);7205 ty = convertToFloatLength(secondValue, style, rootStyle, zoomFactor, &ok); 7193 7206 } 7194 7207 } … … 7208 7221 Length tz = Length(0, Fixed); 7209 7222 if (transformValue->operationType() == WebKitCSSTransformValue::TranslateZTransformOperation) 7210 tz = convertTo Length(firstValue, style, rootStyle, zoomFactor, &ok);7223 tz = convertToFloatLength(firstValue, style, rootStyle, zoomFactor, &ok); 7211 7224 else if (transformValue->operationType() == WebKitCSSTransformValue::TranslateYTransformOperation) 7212 ty = convertTo Length(firstValue, style, rootStyle, zoomFactor, &ok);7225 ty = convertToFloatLength(firstValue, style, rootStyle, zoomFactor, &ok); 7213 7226 else { 7214 tx = convertTo Length(firstValue, style, rootStyle, zoomFactor, &ok);7227 tx = convertToFloatLength(firstValue, style, rootStyle, zoomFactor, &ok); 7215 7228 if (transformValue->operationType() != WebKitCSSTransformValue::TranslateXTransformOperation) { 7216 7229 if (transformValue->length() > 2) { 7217 7230 CSSPrimitiveValue* thirdValue = static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(2)); 7218 tz = convertTo Length(thirdValue, style, rootStyle, zoomFactor, &ok);7231 tz = convertToFloatLength(thirdValue, style, rootStyle, zoomFactor, &ok); 7219 7232 } 7220 7233 if (transformValue->length() > 1) { 7221 7234 CSSPrimitiveValue* secondValue = static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(1)); 7222 ty = convertTo Length(secondValue, style, rootStyle, zoomFactor, &ok);7235 ty = convertToFloatLength(secondValue, style, rootStyle, zoomFactor, &ok); 7223 7236 } 7224 7237 } … … 7351 7364 Length p = Length(0, Fixed); 7352 7365 if (CSSPrimitiveValue::isUnitTypeLength(firstValue->primitiveType())) 7353 p = convertTo Length(firstValue, style, rootStyle, zoomFactor, &ok);7366 p = convertToFloatLength(firstValue, style, rootStyle, zoomFactor, &ok); 7354 7367 else { 7355 7368 // This is a quirk that should go away when 3d transforms are finalized. -
trunk/Source/WebCore/platform/Length.h
r79733 r79784 41 41 public: 42 42 Length() 43 : m_ value(0)43 : m_intValue(0), m_quirk(0), m_type(Auto), m_isFloat(0) 44 44 { 45 45 } 46 46 47 47 Length(LengthType t) 48 : m_ value(t)48 : m_intValue(0), m_quirk(0), m_type(t), m_isFloat(0) 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(0) 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; } 66 59 : m_quirk(q), m_type(t), m_isFloat(0) 60 { 61 if (m_type == Percent) 62 m_intValue = static_cast<int>(v*percentScaleFactor); 63 else { 64 m_isFloat = 1; 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); } 71 72 67 73 int value() const { 68 74 ASSERT(type() != Percent); … … 70 76 } 71 77 72 int rawValue() const { return (m_value & ~0xF) / 16; }78 int rawValue() const { return getIntValue(); } 73 79 74 80 double percent() const … … 78 84 } 79 85 80 LengthType type() const { return static_cast<LengthType>(m_ value & 7); }81 bool quirk() const { return (m_value >> 3) & 1; }86 LengthType type() const { return static_cast<LengthType>(m_type); } 87 bool quirk() const { return m_quirk; } 82 88 83 89 void setValue(LengthType t, int value) 84 90 { 85 91 ASSERT(t != Percent); 86 setRawValue(t, value); 87 } 88 89 void setRawValue(LengthType t, int value) { m_value = value * 16 | (m_value & 0x8) | t; } 92 *this = Length(value, t); 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 *this = Length(value, Fixed); 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 *this = Length(value, t); 103 104 } 104 105 105 106 void setValue(double value) 106 107 { 107 ASSERT(type() == Percent); 108 m_value = static_cast<int>(value * percentScaleFactor) * 16 | (m_value & 0xF); 108 *this = Length(value, Fixed); 109 109 } 110 110 … … 145 145 switch (type()) { 146 146 case Fixed: 147 return static_cast<float>(value());147 return getFloatValue(); 148 148 case Percent: 149 149 return static_cast<float>(maxValue * percent() / 100.0); … … 156 156 157 157 bool isUndefined() const { return rawValue() == undefinedLength; } 158 bool isZero() const { return ! (m_value & ~0xF); }158 bool isZero() const { return !getIntValue(); } 159 159 bool isPositive() const { return rawValue() > 0; } 160 160 bool isNegative() const { return rawValue() < 0; } … … 185 185 } 186 186 187 int fromValue = from.isZero() ? 0 : from.value();188 int toValue = isZero() ? 0 : value();189 return Length( int(fromValue + (toValue - fromValue) * progress), resultType);187 double fromValue = from.isZero() ? 0 : from.getFloatValue(); 188 double toValue = isZero() ? 0 : getFloatValue(); 189 return Length(fromValue + (toValue - fromValue) * progress, resultType); 190 190 } 191 191 192 192 private: 193 int m_value; 193 int getIntValue() const 194 { 195 if (m_isFloat) 196 return static_cast<int>(m_floatValue); 197 return m_intValue; 198 } 199 200 float getFloatValue() const 201 { 202 if (m_isFloat) 203 return m_floatValue; 204 return m_intValue; 205 } 206 207 union { 208 int m_intValue; 209 float m_floatValue; 210 }; 211 bool m_quirk; 212 unsigned char m_type; 213 bool m_isFloat; 194 214 }; 195 215 -
trunk/Source/WebCore/rendering/AutoTableLayout.cpp
r79733 r79784 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
r71262 r79784 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.