Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Side by Side Diff: Source/core/css/CSSGradientValue.cpp

Issue 899163003: Move rendering/RenderObject to layout/LayoutObject. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/css/CSSGradientValue.h ('k') | Source/core/css/CSSImageGeneratorValue.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2008 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 14 matching lines...) Expand all
25 25
26 #include "config.h" 26 #include "config.h"
27 #include "core/css/CSSGradientValue.h" 27 #include "core/css/CSSGradientValue.h"
28 28
29 #include "core/CSSValueKeywords.h" 29 #include "core/CSSValueKeywords.h"
30 #include "core/css/CSSCalculationValue.h" 30 #include "core/css/CSSCalculationValue.h"
31 #include "core/css/CSSToLengthConversionData.h" 31 #include "core/css/CSSToLengthConversionData.h"
32 #include "core/css/Pair.h" 32 #include "core/css/Pair.h"
33 #include "core/dom/NodeRenderStyle.h" 33 #include "core/dom/NodeRenderStyle.h"
34 #include "core/dom/TextLinkColors.h" 34 #include "core/dom/TextLinkColors.h"
35 #include "core/rendering/RenderObject.h" 35 #include "core/layout/LayoutObject.h"
36 #include "platform/geometry/IntSize.h" 36 #include "platform/geometry/IntSize.h"
37 #include "platform/graphics/Gradient.h" 37 #include "platform/graphics/Gradient.h"
38 #include "platform/graphics/GradientGeneratedImage.h" 38 #include "platform/graphics/GradientGeneratedImage.h"
39 #include "platform/graphics/Image.h" 39 #include "platform/graphics/Image.h"
40 #include "platform/graphics/skia/SkiaUtils.h" 40 #include "platform/graphics/skia/SkiaUtils.h"
41 #include "wtf/text/StringBuilder.h" 41 #include "wtf/text/StringBuilder.h"
42 #include "wtf/text/WTFString.h" 42 #include "wtf/text/WTFString.h"
43 43
44 namespace blink { 44 namespace blink {
45 45
46 void CSSGradientColorStop::trace(Visitor* visitor) 46 void CSSGradientColorStop::trace(Visitor* visitor)
47 { 47 {
48 visitor->trace(m_position); 48 visitor->trace(m_position);
49 visitor->trace(m_color); 49 visitor->trace(m_color);
50 } 50 }
51 51
52 PassRefPtr<Image> CSSGradientValue::image(RenderObject* renderer, const IntSize& size) 52 PassRefPtr<Image> CSSGradientValue::image(LayoutObject* renderer, const IntSize& size)
53 { 53 {
54 if (size.isEmpty()) 54 if (size.isEmpty())
55 return nullptr; 55 return nullptr;
56 56
57 bool cacheable = isCacheable(); 57 bool cacheable = isCacheable();
58 if (cacheable) { 58 if (cacheable) {
59 if (!clients().contains(renderer)) 59 if (!clients().contains(renderer))
60 return nullptr; 60 return nullptr;
61 61
62 // Need to look up our size. Create a string of width*height to use as a hash key. 62 // Need to look up our size. Create a string of width*height to use as a hash key.
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 newStops[y].color = blend(leftColor, rightColor, weighting); 195 newStops[y].color = blend(leftColor, rightColor, weighting);
196 } 196 }
197 197
198 // Replace the color hint with the new color stops. 198 // Replace the color hint with the new color stops.
199 stops.remove(x); 199 stops.remove(x);
200 stops.insert(x, newStops, 9); 200 stops.insert(x, newStops, 9);
201 indexOffset += 8; 201 indexOffset += 8;
202 } 202 }
203 } 203 }
204 204
205 static Color resolveStopColor(CSSPrimitiveValue* stopColor, const RenderObject& object) 205 static Color resolveStopColor(CSSPrimitiveValue* stopColor, const LayoutObject& object)
206 { 206 {
207 return object.document().textLinkColors().colorFromPrimitiveValue(stopColor, object.resolveColor(CSSPropertyColor)); 207 return object.document().textLinkColors().colorFromPrimitiveValue(stopColor, object.resolveColor(CSSPropertyColor));
208 } 208 }
209 209
210 void CSSGradientValue::addStops(Gradient* gradient, const CSSToLengthConversionD ata& conversionData, float maxLengthForRepeat, const RenderObject& object) 210 void CSSGradientValue::addStops(Gradient* gradient, const CSSToLengthConversionD ata& conversionData, float maxLengthForRepeat, const LayoutObject& object)
211 { 211 {
212 if (m_gradientType == CSSDeprecatedLinearGradient || m_gradientType == CSSDe precatedRadialGradient) { 212 if (m_gradientType == CSSDeprecatedLinearGradient || m_gradientType == CSSDe precatedRadialGradient) {
213 sortStopsIfNeeded(); 213 sortStopsIfNeeded();
214 214
215 for (unsigned i = 0; i < m_stops.size(); i++) { 215 for (unsigned i = 0; i < m_stops.size(); i++) {
216 const CSSGradientColorStop& stop = m_stops[i]; 216 const CSSGradientColorStop& stop = m_stops[i];
217 217
218 float offset; 218 float offset;
219 if (stop.m_position->isPercentage()) 219 if (stop.m_position->isPercentage())
220 offset = stop.m_position->getFloatValue(CSSPrimitiveValue::CSS_P ERCENTAGE) / 100; 220 offset = stop.m_position->getFloatValue(CSSPrimitiveValue::CSS_P ERCENTAGE) / 100;
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 if (!stop.m_position) 541 if (!stop.m_position)
542 continue; 542 continue;
543 543
544 if (stop.m_position->isFontRelativeLength()) 544 if (stop.m_position->isFontRelativeLength())
545 return false; 545 return false;
546 } 546 }
547 547
548 return true; 548 return true;
549 } 549 }
550 550
551 bool CSSGradientValue::knownToBeOpaque(const RenderObject* object) const 551 bool CSSGradientValue::knownToBeOpaque(const LayoutObject* object) const
552 { 552 {
553 ASSERT(object); 553 ASSERT(object);
554 for (auto& stop : m_stops) { 554 for (auto& stop : m_stops) {
555 if (!stop.isHint() && resolveStopColor(stop.m_color.get(), *object).hasA lpha()) 555 if (!stop.isHint() && resolveStopColor(stop.m_color.get(), *object).hasA lpha())
556 return false; 556 return false;
557 } 557 }
558 return true; 558 return true;
559 } 559 }
560 560
561 void CSSGradientValue::traceAfterDispatch(Visitor* visitor) 561 void CSSGradientValue::traceAfterDispatch(Visitor* visitor)
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 float endX = c / (slope - perpendicularSlope); 718 float endX = c / (slope - perpendicularSlope);
719 float endY = perpendicularSlope * endX + c; 719 float endY = perpendicularSlope * endX + c;
720 720
721 // We computed the end point, so set the second point, 721 // We computed the end point, so set the second point,
722 // taking into account the moved origin and the fact that we're in drawing s pace (+y = down). 722 // taking into account the moved origin and the fact that we're in drawing s pace (+y = down).
723 secondPoint.set(halfWidth + endX, halfHeight - endY); 723 secondPoint.set(halfWidth + endX, halfHeight - endY);
724 // Reflect around the center for the start point. 724 // Reflect around the center for the start point.
725 firstPoint.set(halfWidth - endX, halfHeight + endY); 725 firstPoint.set(halfWidth - endX, halfHeight + endY);
726 } 726 }
727 727
728 PassRefPtr<Gradient> CSSLinearGradientValue::createGradient(const CSSToLengthCon versionData& conversionData, const IntSize& size, const RenderObject& object) 728 PassRefPtr<Gradient> CSSLinearGradientValue::createGradient(const CSSToLengthCon versionData& conversionData, const IntSize& size, const LayoutObject& object)
729 { 729 {
730 ASSERT(!size.isEmpty()); 730 ASSERT(!size.isEmpty());
731 731
732 FloatPoint firstPoint; 732 FloatPoint firstPoint;
733 FloatPoint secondPoint; 733 FloatPoint secondPoint;
734 if (m_angle) { 734 if (m_angle) {
735 float angle = m_angle->getFloatValue(CSSPrimitiveValue::CSS_DEG); 735 float angle = m_angle->getFloatValue(CSSPrimitiveValue::CSS_DEG);
736 endPointsFromAngle(angle, size, firstPoint, secondPoint, m_gradientType) ; 736 endPointsFromAngle(angle, size, firstPoint, secondPoint, m_gradientType) ;
737 } else { 737 } else {
738 switch (m_gradientType) { 738 switch (m_gradientType) {
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
1066 // width/height given by aspectRatio. 1066 // width/height given by aspectRatio.
1067 static inline float horizontalEllipseRadius(const FloatSize& p, float aspectRati o) 1067 static inline float horizontalEllipseRadius(const FloatSize& p, float aspectRati o)
1068 { 1068 {
1069 // x^2/a^2 + y^2/b^2 = 1 1069 // x^2/a^2 + y^2/b^2 = 1
1070 // a/b = aspectRatio, b = a/aspectRatio 1070 // a/b = aspectRatio, b = a/aspectRatio
1071 // a = sqrt(x^2 + y^2/(1/r^2)) 1071 // a = sqrt(x^2 + y^2/(1/r^2))
1072 return sqrtf(p.width() * p.width() + (p.height() * p.height()) / (1 / (aspec tRatio * aspectRatio))); 1072 return sqrtf(p.width() * p.width() + (p.height() * p.height()) / (1 / (aspec tRatio * aspectRatio)));
1073 } 1073 }
1074 1074
1075 // FIXME: share code with the linear version 1075 // FIXME: share code with the linear version
1076 PassRefPtr<Gradient> CSSRadialGradientValue::createGradient(const CSSToLengthCon versionData& conversionData, const IntSize& size, const RenderObject& object) 1076 PassRefPtr<Gradient> CSSRadialGradientValue::createGradient(const CSSToLengthCon versionData& conversionData, const IntSize& size, const LayoutObject& object)
1077 { 1077 {
1078 ASSERT(!size.isEmpty()); 1078 ASSERT(!size.isEmpty());
1079 1079
1080 FloatPoint firstPoint = computeEndPoint(m_firstX.get(), m_firstY.get(), conv ersionData, size); 1080 FloatPoint firstPoint = computeEndPoint(m_firstX.get(), m_firstY.get(), conv ersionData, size);
1081 if (!m_firstX) 1081 if (!m_firstX)
1082 firstPoint.setX(size.width() / 2); 1082 firstPoint.setX(size.width() / 2);
1083 if (!m_firstY) 1083 if (!m_firstY)
1084 firstPoint.setY(size.height() / 2); 1084 firstPoint.setY(size.height() / 2);
1085 1085
1086 FloatPoint secondPoint = computeEndPoint(m_secondX.get(), m_secondY.get(), c onversionData, size); 1086 FloatPoint secondPoint = computeEndPoint(m_secondX.get(), m_secondY.get(), c onversionData, size);
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
1266 visitor->trace(m_firstRadius); 1266 visitor->trace(m_firstRadius);
1267 visitor->trace(m_secondRadius); 1267 visitor->trace(m_secondRadius);
1268 visitor->trace(m_shape); 1268 visitor->trace(m_shape);
1269 visitor->trace(m_sizingBehavior); 1269 visitor->trace(m_sizingBehavior);
1270 visitor->trace(m_endHorizontalSize); 1270 visitor->trace(m_endHorizontalSize);
1271 visitor->trace(m_endVerticalSize); 1271 visitor->trace(m_endVerticalSize);
1272 CSSGradientValue::traceAfterDispatch(visitor); 1272 CSSGradientValue::traceAfterDispatch(visitor);
1273 } 1273 }
1274 1274
1275 } // namespace blink 1275 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/css/CSSGradientValue.h ('k') | Source/core/css/CSSImageGeneratorValue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698