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

Side by Side Diff: sky/engine/core/rendering/shapes/ShapeOutsideInfo.cpp

Issue 683803006: Remove all writing mode function arguments and remove writing mode from RenderStyle. (Closed) Base URL: git@github.com:domokit/mojo.git@writingmode
Patch Set: Created 6 years, 1 month 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 static bool isValidRasterShapeRect(const LayoutRect& rect) 92 static bool isValidRasterShapeRect(const LayoutRect& rect)
93 { 93 {
94 static double maxImageSizeBytes = 0; 94 static double maxImageSizeBytes = 0;
95 if (!maxImageSizeBytes) { 95 if (!maxImageSizeBytes) {
96 size_t size32MaxBytes = 0xFFFFFFFF / 4; // Some platforms don't limit m axDecodedImageBytes. 96 size_t size32MaxBytes = 0xFFFFFFFF / 4; // Some platforms don't limit m axDecodedImageBytes.
97 maxImageSizeBytes = std::min(size32MaxBytes, Platform::current()->maxDec odedImageBytes()); 97 maxImageSizeBytes = std::min(size32MaxBytes, Platform::current()->maxDec odedImageBytes());
98 } 98 }
99 return (rect.width().toFloat() * rect.height().toFloat() * 4.0) < maxImageSi zeBytes; 99 return (rect.width().toFloat() * rect.height().toFloat() * 4.0) < maxImageSi zeBytes;
100 } 100 }
101 101
102 PassOwnPtr<Shape> ShapeOutsideInfo::createShapeForImage(StyleImage* styleImage, float shapeImageThreshold, WritingMode writingMode, float margin) const 102 PassOwnPtr<Shape> ShapeOutsideInfo::createShapeForImage(StyleImage* styleImage, float shapeImageThreshold, float margin) const
103 { 103 {
104 const IntSize& imageSize = m_renderer.calculateImageIntrinsicDimensions(styl eImage, roundedIntSize(m_referenceBoxLogicalSize), RenderImage::ScaleByEffective Zoom); 104 const IntSize& imageSize = m_renderer.calculateImageIntrinsicDimensions(styl eImage, roundedIntSize(m_referenceBoxLogicalSize), RenderImage::ScaleByEffective Zoom);
105 styleImage->setContainerSizeForRenderer(&m_renderer, imageSize, m_renderer.s tyle()->effectiveZoom()); 105 styleImage->setContainerSizeForRenderer(&m_renderer, imageSize, m_renderer.s tyle()->effectiveZoom());
106 106
107 const LayoutRect& marginRect = getShapeImageMarginRect(m_renderer, m_referen ceBoxLogicalSize); 107 const LayoutRect& marginRect = getShapeImageMarginRect(m_renderer, m_referen ceBoxLogicalSize);
108 const LayoutRect& imageRect = (m_renderer.isRenderImage()) 108 const LayoutRect& imageRect = (m_renderer.isRenderImage())
109 ? toRenderImage(m_renderer).replacedContentRect() 109 ? toRenderImage(m_renderer).replacedContentRect()
110 : LayoutRect(LayoutPoint(), imageSize); 110 : LayoutRect(LayoutPoint(), imageSize);
111 111
112 if (!isValidRasterShapeRect(marginRect) || !isValidRasterShapeRect(imageRect )) { 112 if (!isValidRasterShapeRect(marginRect) || !isValidRasterShapeRect(imageRect )) {
113 m_renderer.document().addConsoleMessage(ConsoleMessage::create(Rendering MessageSource, ErrorMessageLevel, "The shape-outside image is too large.")); 113 m_renderer.document().addConsoleMessage(ConsoleMessage::create(Rendering MessageSource, ErrorMessageLevel, "The shape-outside image is too large."));
114 return Shape::createEmptyRasterShape(writingMode, margin); 114 return Shape::createEmptyRasterShape(margin);
115 } 115 }
116 116
117 ASSERT(!styleImage->isPendingImage()); 117 ASSERT(!styleImage->isPendingImage());
118 RefPtr<Image> image = styleImage->image(const_cast<RenderBox*>(&m_renderer), imageSize); 118 RefPtr<Image> image = styleImage->image(const_cast<RenderBox*>(&m_renderer), imageSize);
119 119
120 return Shape::createRasterShape(image.get(), shapeImageThreshold, imageRect, marginRect, writingMode, margin); 120 return Shape::createRasterShape(image.get(), shapeImageThreshold, imageRect, marginRect, margin);
121 } 121 }
122 122
123 const Shape& ShapeOutsideInfo::computedShape() const 123 const Shape& ShapeOutsideInfo::computedShape() const
124 { 124 {
125 if (Shape* shape = m_shape.get()) 125 if (Shape* shape = m_shape.get())
126 return *shape; 126 return *shape;
127 127
128 const RenderStyle& style = *m_renderer.style(); 128 const RenderStyle& style = *m_renderer.style();
129 ASSERT(m_renderer.containingBlock()); 129 ASSERT(m_renderer.containingBlock());
130 const RenderStyle& containingBlockStyle = *m_renderer.containingBlock()->sty le();
131
132 WritingMode writingMode = containingBlockStyle.writingMode();
133 LayoutUnit maximumValue = m_renderer.containingBlock() ? m_renderer.containi ngBlock()->contentWidth() : LayoutUnit(); 130 LayoutUnit maximumValue = m_renderer.containingBlock() ? m_renderer.containi ngBlock()->contentWidth() : LayoutUnit();
134 float margin = floatValueForLength(m_renderer.style()->shapeMargin(), maximu mValue.toFloat()); 131 float margin = floatValueForLength(m_renderer.style()->shapeMargin(), maximu mValue.toFloat());
135 132
136 float shapeImageThreshold = style.shapeImageThreshold(); 133 float shapeImageThreshold = style.shapeImageThreshold();
137 ASSERT(style.shapeOutside()); 134 ASSERT(style.shapeOutside());
138 const ShapeValue& shapeValue = *style.shapeOutside(); 135 const ShapeValue& shapeValue = *style.shapeOutside();
139 136
140 switch (shapeValue.type()) { 137 switch (shapeValue.type()) {
141 case ShapeValue::Shape: 138 case ShapeValue::Shape:
142 ASSERT(shapeValue.shape()); 139 ASSERT(shapeValue.shape());
143 m_shape = Shape::createShape(shapeValue.shape(), m_referenceBoxLogicalSi ze, writingMode, margin); 140 m_shape = Shape::createShape(shapeValue.shape(), m_referenceBoxLogicalSi ze, margin);
144 break; 141 break;
145 case ShapeValue::Image: 142 case ShapeValue::Image:
146 ASSERT(shapeValue.isImageValid()); 143 ASSERT(shapeValue.isImageValid());
147 m_shape = createShapeForImage(shapeValue.image(), shapeImageThreshold, w ritingMode, margin); 144 m_shape = createShapeForImage(shapeValue.image(), shapeImageThreshold, m argin);
148 break; 145 break;
149 case ShapeValue::Box: { 146 case ShapeValue::Box: {
150 const RoundedRect& shapeRect = style.getRoundedBorderFor(LayoutRect(Layo utPoint(), m_referenceBoxLogicalSize), m_renderer.view()); 147 const RoundedRect& shapeRect = style.getRoundedBorderFor(LayoutRect(Layo utPoint(), m_referenceBoxLogicalSize), m_renderer.view());
151 m_shape = Shape::createLayoutBoxShape(shapeRect, writingMode, margin); 148 m_shape = Shape::createLayoutBoxShape(shapeRect, margin);
152 break; 149 break;
153 } 150 }
154 } 151 }
155 152
156 ASSERT(m_shape); 153 ASSERT(m_shape);
157 return *m_shape; 154 return *m_shape;
158 } 155 }
159 156
160 inline LayoutUnit borderBeforeInWritingMode(const RenderBox& renderer, WritingMo de writingMode) 157 inline LayoutUnit borderBeforeInWritingMode(const RenderBox& renderer)
161 { 158 {
162 // FIXME(sky): Remove 159 // FIXME(sky): Remove
163 return renderer.borderBefore(); 160 return renderer.borderBefore();
164 } 161 }
165 162
166 inline LayoutUnit borderAndPaddingBeforeInWritingMode(const RenderBox& renderer, WritingMode writingMode) 163 inline LayoutUnit borderAndPaddingBeforeInWritingMode(const RenderBox& renderer)
167 { 164 {
168 // FIXME(sky): Remove 165 // FIXME(sky): Remove
169 return renderer.borderAndPaddingBefore(); 166 return renderer.borderAndPaddingBefore();
170 } 167 }
171 168
172 LayoutUnit ShapeOutsideInfo::logicalTopOffset() const 169 LayoutUnit ShapeOutsideInfo::logicalTopOffset() const
173 { 170 {
174 switch (referenceBox(*m_renderer.style()->shapeOutside())) { 171 switch (referenceBox(*m_renderer.style()->shapeOutside())) {
175 case MarginBox: return -m_renderer.marginBefore(m_renderer.containingBlock() ->style()); 172 case MarginBox: return -m_renderer.marginBefore(m_renderer.containingBlock() ->style());
176 case BorderBox: return LayoutUnit(); 173 case BorderBox: return LayoutUnit();
177 case PaddingBox: return borderBeforeInWritingMode(m_renderer, m_renderer.con tainingBlock()->style()->writingMode()); 174 case PaddingBox: return borderBeforeInWritingMode(m_renderer);
178 case ContentBox: return borderAndPaddingBeforeInWritingMode(m_renderer, m_re nderer.containingBlock()->style()->writingMode()); 175 case ContentBox: return borderAndPaddingBeforeInWritingMode(m_renderer);
179 case BoxMissing: break; 176 case BoxMissing: break;
180 } 177 }
181 178
182 ASSERT_NOT_REACHED(); 179 ASSERT_NOT_REACHED();
183 return LayoutUnit(); 180 return LayoutUnit();
184 } 181 }
185 182
186 inline LayoutUnit borderStartWithStyleForWritingMode(const RenderBox& renderer, const RenderStyle* style) 183 inline LayoutUnit borderStartWithStyleForWritingMode(const RenderBox& renderer, const RenderStyle* style)
187 { 184 {
188 if (style->isHorizontalWritingMode()) { 185 if (style->isHorizontalWritingMode()) {
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 } 305 }
309 306
310 FloatSize ShapeOutsideInfo::shapeToRendererSize(FloatSize size) const 307 FloatSize ShapeOutsideInfo::shapeToRendererSize(FloatSize size) const
311 { 308 {
312 if (!m_renderer.style()->isHorizontalWritingMode()) 309 if (!m_renderer.style()->isHorizontalWritingMode())
313 return size.transposedSize(); 310 return size.transposedSize();
314 return size; 311 return size;
315 } 312 }
316 313
317 } // namespace blink 314 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/rendering/shapes/ShapeOutsideInfo.h ('k') | sky/engine/core/rendering/style/RenderStyle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698