Changeset 121289 in webkit for trunk/Source/WebCore/css/CSSGradientValue.cpp
- Timestamp:
- Jun 26, 2012, 2:35:55 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/css/CSSGradientValue.cpp
r121285 r121289 106 106 }; 107 107 108 void CSSGradientValue::addStops(Gradient* gradient, RenderObject* renderer, RenderStyle* rootStyle, RenderStyle* parentStyle,float maxLengthForRepeat)108 void CSSGradientValue::addStops(Gradient* gradient, RenderObject* renderer, RenderStyle* rootStyle, float maxLengthForRepeat) 109 109 { 110 110 RenderStyle* style = renderer->style(); … … 161 161 float length; 162 162 if (stop.m_position->isLength()) 163 length = stop.m_position->computeLength<float>(style, rootStyle, parentStyle,style->effectiveZoom());163 length = stop.m_position->computeLength<float>(style, rootStyle, style->effectiveZoom()); 164 164 else 165 length = stop.m_position->cssCalcValue()->toCalcValue(style, rootStyle, parentStyle,style->effectiveZoom())->evaluate(gradientLength);165 length = stop.m_position->cssCalcValue()->toCalcValue(style, rootStyle, style->effectiveZoom())->evaluate(gradientLength); 166 166 stops[i].offset = (gradientLength > 0) ? length / gradientLength : 0; 167 167 } else { … … 364 364 } 365 365 366 static float positionFromValue(CSSPrimitiveValue* value, RenderStyle* style, RenderStyle* rootStyle, RenderStyle* parentStyle,const IntSize& size, bool isHorizontal)366 static float positionFromValue(CSSPrimitiveValue* value, RenderStyle* style, RenderStyle* rootStyle, const IntSize& size, bool isHorizontal) 367 367 { 368 368 float zoomFactor = style->effectiveZoom(); … … 376 376 377 377 if (value->isCalculatedPercentageWithLength()) 378 return value->cssCalcValue()->toCalcValue(style, rootStyle, parentStyle,style->effectiveZoom())->evaluate(edgeDistance);378 return value->cssCalcValue()->toCalcValue(style, rootStyle, style->effectiveZoom())->evaluate(edgeDistance); 379 379 380 380 switch (value->getIdent()) { … … 393 393 } 394 394 395 return value->computeLength<float>(style, rootStyle, parentStyle,zoomFactor);396 } 397 398 FloatPoint CSSGradientValue::computeEndPoint(CSSPrimitiveValue* first, CSSPrimitiveValue* second, RenderStyle* style, RenderStyle* rootStyle, RenderStyle* parentStyle,const IntSize& size)395 return value->computeLength<float>(style, rootStyle, zoomFactor); 396 } 397 398 FloatPoint CSSGradientValue::computeEndPoint(CSSPrimitiveValue* first, CSSPrimitiveValue* second, RenderStyle* style, RenderStyle* rootStyle, const IntSize& size) 399 399 { 400 400 FloatPoint result; 401 401 402 402 if (first) 403 result.setX(positionFromValue(first, style, rootStyle, parentStyle,size, true));403 result.setX(positionFromValue(first, style, rootStyle, size, true)); 404 404 405 405 if (second) 406 result.setY(positionFromValue(second, style, rootStyle, parentStyle,size, false));406 result.setY(positionFromValue(second, style, rootStyle, size, false)); 407 407 408 408 return result; … … 543 543 544 544 RenderStyle* rootStyle = renderer->document()->documentElement()->renderStyle(); 545 RenderObject* parent = renderer->parent();546 RenderStyle* parentStyle = parent ? parent->style() : 0;547 545 548 546 FloatPoint firstPoint; … … 552 550 endPointsFromAngle(angle, size, firstPoint, secondPoint); 553 551 } else { 554 firstPoint = computeEndPoint(m_firstX.get(), m_firstY.get(), renderer->style(), rootStyle, parentStyle,size);552 firstPoint = computeEndPoint(m_firstX.get(), m_firstY.get(), renderer->style(), rootStyle, size); 555 553 556 554 if (m_secondX || m_secondY) 557 secondPoint = computeEndPoint(m_secondX.get(), m_secondY.get(), renderer->style(), rootStyle, parentStyle,size);555 secondPoint = computeEndPoint(m_secondX.get(), m_secondY.get(), renderer->style(), rootStyle, size); 558 556 else { 559 557 if (m_firstX) … … 567 565 568 566 // Now add the stops. 569 addStops(gradient.get(), renderer, rootStyle, parentStyle,1);567 addStops(gradient.get(), renderer, rootStyle, 1); 570 568 571 569 return gradient.release(); … … 641 639 } 642 640 643 float CSSRadialGradientValue::resolveRadius(CSSPrimitiveValue* radius, RenderStyle* style, RenderStyle* rootStyle, RenderStyle* parentStyle,float* widthOrHeight)641 float CSSRadialGradientValue::resolveRadius(CSSPrimitiveValue* radius, RenderStyle* style, RenderStyle* rootStyle, float* widthOrHeight) 644 642 { 645 643 float zoomFactor = style->effectiveZoom(); … … 651 649 result = *widthOrHeight * radius->getFloatValue() / 100; 652 650 else 653 result = radius->computeLength<float>(style, rootStyle, parentStyle,zoomFactor);651 result = radius->computeLength<float>(style, rootStyle, zoomFactor); 654 652 655 653 return result; … … 738 736 739 737 RenderStyle* rootStyle = renderer->document()->documentElement()->renderStyle(); 740 RenderObject* parent = renderer->parent(); 741 RenderStyle* parentStyle = parent ? parent->style() : 0; 742 743 FloatPoint firstPoint = computeEndPoint(m_firstX.get(), m_firstY.get(), renderer->style(), rootStyle, parentStyle, size); 738 739 FloatPoint firstPoint = computeEndPoint(m_firstX.get(), m_firstY.get(), renderer->style(), rootStyle, size); 744 740 if (!m_firstX) 745 741 firstPoint.setX(size.width() / 2); … … 747 743 firstPoint.setY(size.height() / 2); 748 744 749 FloatPoint secondPoint = computeEndPoint(m_secondX.get(), m_secondY.get(), renderer->style(), rootStyle, parentStyle,size);745 FloatPoint secondPoint = computeEndPoint(m_secondX.get(), m_secondY.get(), renderer->style(), rootStyle, size); 750 746 if (!m_secondX) 751 747 secondPoint.setX(size.width() / 2); … … 755 751 float firstRadius = 0; 756 752 if (m_firstRadius) 757 firstRadius = resolveRadius(m_firstRadius.get(), renderer->style(), rootStyle , parentStyle);753 firstRadius = resolveRadius(m_firstRadius.get(), renderer->style(), rootStyle); 758 754 759 755 float secondRadius = 0; 760 756 float aspectRatio = 1; // width / height. 761 757 if (m_secondRadius) 762 secondRadius = resolveRadius(m_secondRadius.get(), renderer->style(), rootStyle , parentStyle);758 secondRadius = resolveRadius(m_secondRadius.get(), renderer->style(), rootStyle); 763 759 else if (m_endHorizontalSize || m_endVerticalSize) { 764 760 float width = size.width(); 765 761 float height = size.height(); 766 secondRadius = resolveRadius(m_endHorizontalSize.get(), renderer->style(), rootStyle, parentStyle,&width);767 aspectRatio = secondRadius / resolveRadius(m_endVerticalSize.get(), renderer->style(), rootStyle, parentStyle,&height);762 secondRadius = resolveRadius(m_endHorizontalSize.get(), renderer->style(), rootStyle, &width); 763 aspectRatio = secondRadius / resolveRadius(m_endVerticalSize.get(), renderer->style(), rootStyle, &height); 768 764 } else { 769 765 enum GradientShape { Circle, Ellipse }; … … 866 862 867 863 // Now add the stops. 868 addStops(gradient.get(), renderer, rootStyle, parentStyle,maxExtent);864 addStops(gradient.get(), renderer, rootStyle, maxExtent); 869 865 870 866 return gradient.release();
Note:
See TracChangeset
for help on using the changeset viewer.