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

Side by Side Diff: Source/core/rendering/shapes/ShapeInfo.cpp

Issue 178473024: Convert some Shape code to use references (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebased patch Created 6 years, 9 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. 2 * Copyright (C) 2012 Adobe Systems Incorporated. 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 * 7 *
8 * 1. Redistributions of source code must retain the above 8 * 1. Redistributions of source code must retain the above
9 * copyright notice, this list of conditions and the following 9 * copyright notice, this list of conditions and the following
10 * disclaimer. 10 * disclaimer.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 { 51 {
52 if (renderBox->isRenderImage()) 52 if (renderBox->isRenderImage())
53 return toRenderImage(renderBox)->replacedContentRect(); 53 return toRenderImage(renderBox)->replacedContentRect();
54 54
55 ASSERT(styleImage.cachedImage()); 55 ASSERT(styleImage.cachedImage());
56 ASSERT(styleImage.cachedImage()->hasImage()); 56 ASSERT(styleImage.cachedImage()->hasImage());
57 return LayoutRect(LayoutPoint(), styleImage.cachedImage()->image()->size()); 57 return LayoutRect(LayoutPoint(), styleImage.cachedImage()->image()->size());
58 } 58 }
59 59
60 template<class RenderType> 60 template<class RenderType>
61 const Shape* ShapeInfo<RenderType>::computedShape() const 61 const Shape& ShapeInfo<RenderType>::computedShape() const
62 { 62 {
63 if (Shape* shape = m_shape.get()) 63 if (Shape* shape = m_shape.get())
64 return shape; 64 return *shape;
65 65
66 WritingMode writingMode = m_renderer->style()->writingMode(); 66 WritingMode writingMode = m_renderer.style()->writingMode();
67 Length margin = m_renderer->style()->shapeMargin(); 67 Length margin = m_renderer.style()->shapeMargin();
68 Length padding = m_renderer->style()->shapePadding(); 68 Length padding = m_renderer.style()->shapePadding();
69 float shapeImageThreshold = m_renderer->style()->shapeImageThreshold(); 69 float shapeImageThreshold = m_renderer.style()->shapeImageThreshold();
70 const ShapeValue* shapeValue = this->shapeValue(); 70 const ShapeValue* shapeValue = this->shapeValue();
71 ASSERT(shapeValue); 71 ASSERT(shapeValue);
72 72
73 switch (shapeValue->type()) { 73 switch (shapeValue->type()) {
74 case ShapeValue::Shape: 74 case ShapeValue::Shape:
75 ASSERT(shapeValue->shape()); 75 ASSERT(shapeValue->shape());
76 m_shape = Shape::createShape(shapeValue->shape(), m_referenceBoxLogicalS ize, writingMode, margin, padding); 76 m_shape = Shape::createShape(shapeValue->shape(), m_referenceBoxLogicalS ize, writingMode, margin, padding);
77 break; 77 break;
78 case ShapeValue::Image: { 78 case ShapeValue::Image: {
79 ASSERT(shapeValue->image()); 79 ASSERT(shapeValue->image());
80 const StyleImage& styleImage = *(shapeValue->image()); 80 const StyleImage& styleImage = *(shapeValue->image());
81 m_shape = Shape::createRasterShape(styleImage, shapeImageThreshold, getS hapeImageRect(styleImage, m_renderer), m_referenceBoxLogicalSize, writingMode, m argin, padding); 81 m_shape = Shape::createRasterShape(styleImage, shapeImageThreshold, getS hapeImageRect(styleImage, &m_renderer), m_referenceBoxLogicalSize, writingMode, margin, padding);
82 break; 82 break;
83 } 83 }
84 case ShapeValue::Box: { 84 case ShapeValue::Box: {
85 const RoundedRect& shapeRect = m_renderer->style()->getRoundedBorderFor( LayoutRect(LayoutPoint(), m_referenceBoxLogicalSize), m_renderer->view()); 85 const RoundedRect& shapeRect = m_renderer.style()->getRoundedBorderFor(L ayoutRect(LayoutPoint(), m_referenceBoxLogicalSize), m_renderer.view());
86 m_shape = Shape::createLayoutBoxShape(shapeRect, writingMode, margin, pa dding); 86 m_shape = Shape::createLayoutBoxShape(shapeRect, writingMode, margin, pa dding);
87 break; 87 break;
88 } 88 }
89 case ShapeValue::Outside: 89 case ShapeValue::Outside:
90 // Outside should have already resolved to a different shape value. 90 // Outside should have already resolved to a different shape value.
91 ASSERT_NOT_REACHED(); 91 ASSERT_NOT_REACHED();
92 } 92 }
93 93
94 ASSERT(m_shape); 94 ASSERT(m_shape);
95 return m_shape.get(); 95 return *m_shape;
96 } 96 }
97 97
98 template<class RenderType> 98 template<class RenderType>
99 SegmentList ShapeInfo<RenderType>::computeSegmentsForLine(LayoutUnit lineTop, La youtUnit lineHeight) const 99 SegmentList ShapeInfo<RenderType>::computeSegmentsForLine(LayoutUnit lineTop, La youtUnit lineHeight) const
100 { 100 {
101 ASSERT(lineHeight >= 0); 101 ASSERT(lineHeight >= 0);
102 SegmentList segments; 102 SegmentList segments;
103 103
104 getIntervals((lineTop - logicalTopOffset()), std::min(lineHeight, shapeLogic alBottom() - lineTop), segments); 104 getIntervals((lineTop - logicalTopOffset()), std::min(lineHeight, shapeLogic alBottom() - lineTop), segments);
105 105
106 for (size_t i = 0; i < segments.size(); i++) { 106 for (size_t i = 0; i < segments.size(); i++) {
107 segments[i].logicalLeft += logicalLeftOffset(); 107 segments[i].logicalLeft += logicalLeftOffset();
108 segments[i].logicalRight += logicalLeftOffset(); 108 segments[i].logicalRight += logicalLeftOffset();
109 } 109 }
110 110
111 return segments; 111 return segments;
112 } 112 }
113 113
114 template class ShapeInfo<RenderBlock>; 114 template class ShapeInfo<RenderBlock>;
115 template class ShapeInfo<RenderBox>; 115 template class ShapeInfo<RenderBox>;
116 } 116 }
OLDNEW
« no previous file with comments | « Source/core/rendering/shapes/ShapeInfo.h ('k') | Source/core/rendering/shapes/ShapeInsideInfo.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698