OLD | NEW |
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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 return; | 90 return; |
91 markShapeAsDirty(); | 91 markShapeAsDirty(); |
92 m_referenceBoxLogicalSize = newReferenceBoxLogicalSize; | 92 m_referenceBoxLogicalSize = newReferenceBoxLogicalSize; |
93 } | 93 } |
94 | 94 |
95 static bool checkShapeImageOrigin(Document& document, | 95 static bool checkShapeImageOrigin(Document& document, |
96 const StyleImage& styleImage) { | 96 const StyleImage& styleImage) { |
97 if (styleImage.isGeneratedImage()) | 97 if (styleImage.isGeneratedImage()) |
98 return true; | 98 return true; |
99 | 99 |
100 ASSERT(styleImage.cachedImage()); | 100 DCHECK(styleImage.cachedImage()); |
101 ImageResourceContent& imageResource = *(styleImage.cachedImage()); | 101 ImageResourceContent& imageResource = *(styleImage.cachedImage()); |
102 if (imageResource.isAccessAllowed(document.getSecurityOrigin())) | 102 if (imageResource.isAccessAllowed(document.getSecurityOrigin())) |
103 return true; | 103 return true; |
104 | 104 |
105 const KURL& url = imageResource.url(); | 105 const KURL& url = imageResource.url(); |
106 String urlString = url.isNull() ? "''" : url.elidedString(); | 106 String urlString = url.isNull() ? "''" : url.elidedString(); |
107 document.addConsoleMessage( | 107 document.addConsoleMessage( |
108 ConsoleMessage::create(SecurityMessageSource, ErrorMessageLevel, | 108 ConsoleMessage::create(SecurityMessageSource, ErrorMessageLevel, |
109 "Unsafe attempt to load URL " + urlString + ".")); | 109 "Unsafe attempt to load URL " + urlString + ".")); |
110 | 110 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 : LayoutRect(LayoutPoint(), imageSize); | 156 : LayoutRect(LayoutPoint(), imageSize); |
157 | 157 |
158 if (!isValidRasterShapeRect(marginRect) || | 158 if (!isValidRasterShapeRect(marginRect) || |
159 !isValidRasterShapeRect(imageRect)) { | 159 !isValidRasterShapeRect(imageRect)) { |
160 m_layoutBox.document().addConsoleMessage( | 160 m_layoutBox.document().addConsoleMessage( |
161 ConsoleMessage::create(RenderingMessageSource, ErrorMessageLevel, | 161 ConsoleMessage::create(RenderingMessageSource, ErrorMessageLevel, |
162 "The shape-outside image is too large.")); | 162 "The shape-outside image is too large.")); |
163 return Shape::createEmptyRasterShape(writingMode, margin); | 163 return Shape::createEmptyRasterShape(writingMode, margin); |
164 } | 164 } |
165 | 165 |
166 ASSERT(!styleImage->isPendingImage()); | 166 DCHECK(!styleImage->isPendingImage()); |
167 RefPtr<Image> image = | 167 RefPtr<Image> image = |
168 styleImage->image(m_layoutBox, flooredIntSize(imageSize), | 168 styleImage->image(m_layoutBox, flooredIntSize(imageSize), |
169 m_layoutBox.style()->effectiveZoom()); | 169 m_layoutBox.style()->effectiveZoom()); |
170 | 170 |
171 return Shape::createRasterShape(image.get(), shapeImageThreshold, imageRect, | 171 return Shape::createRasterShape(image.get(), shapeImageThreshold, imageRect, |
172 marginRect, writingMode, margin); | 172 marginRect, writingMode, margin); |
173 } | 173 } |
174 | 174 |
175 const Shape& ShapeOutsideInfo::computedShape() const { | 175 const Shape& ShapeOutsideInfo::computedShape() const { |
176 if (Shape* shape = m_shape.get()) | 176 if (Shape* shape = m_shape.get()) |
177 return *shape; | 177 return *shape; |
178 | 178 |
179 AutoReset<bool> isInComputingShape(&m_isComputingShape, true); | 179 AutoReset<bool> isInComputingShape(&m_isComputingShape, true); |
180 | 180 |
181 const ComputedStyle& style = *m_layoutBox.style(); | 181 const ComputedStyle& style = *m_layoutBox.style(); |
182 ASSERT(m_layoutBox.containingBlock()); | 182 DCHECK(m_layoutBox.containingBlock()); |
183 const ComputedStyle& containingBlockStyle = | 183 const ComputedStyle& containingBlockStyle = |
184 *m_layoutBox.containingBlock()->style(); | 184 *m_layoutBox.containingBlock()->style(); |
185 | 185 |
186 WritingMode writingMode = containingBlockStyle.getWritingMode(); | 186 WritingMode writingMode = containingBlockStyle.getWritingMode(); |
187 // Make sure contentWidth is not negative. This can happen when containing | 187 // Make sure contentWidth is not negative. This can happen when containing |
188 // block has a vertical scrollbar and its content is smaller than the | 188 // block has a vertical scrollbar and its content is smaller than the |
189 // scrollbar width. | 189 // scrollbar width. |
190 LayoutUnit maximumValue = | 190 LayoutUnit maximumValue = |
191 m_layoutBox.containingBlock() | 191 m_layoutBox.containingBlock() |
192 ? std::max(LayoutUnit(), | 192 ? std::max(LayoutUnit(), |
193 m_layoutBox.containingBlock()->contentWidth()) | 193 m_layoutBox.containingBlock()->contentWidth()) |
194 : LayoutUnit(); | 194 : LayoutUnit(); |
195 float margin = floatValueForLength(m_layoutBox.style()->shapeMargin(), | 195 float margin = floatValueForLength(m_layoutBox.style()->shapeMargin(), |
196 maximumValue.toFloat()); | 196 maximumValue.toFloat()); |
197 | 197 |
198 float shapeImageThreshold = style.shapeImageThreshold(); | 198 float shapeImageThreshold = style.shapeImageThreshold(); |
199 ASSERT(style.shapeOutside()); | 199 DCHECK(style.shapeOutside()); |
200 const ShapeValue& shapeValue = *style.shapeOutside(); | 200 const ShapeValue& shapeValue = *style.shapeOutside(); |
201 | 201 |
202 switch (shapeValue.type()) { | 202 switch (shapeValue.type()) { |
203 case ShapeValue::Shape: | 203 case ShapeValue::Shape: |
204 ASSERT(shapeValue.shape()); | 204 DCHECK(shapeValue.shape()); |
205 m_shape = Shape::createShape( | 205 m_shape = Shape::createShape( |
206 shapeValue.shape(), m_referenceBoxLogicalSize, writingMode, margin); | 206 shapeValue.shape(), m_referenceBoxLogicalSize, writingMode, margin); |
207 break; | 207 break; |
208 case ShapeValue::Image: | 208 case ShapeValue::Image: |
209 ASSERT(shapeValue.isImageValid()); | 209 DCHECK(shapeValue.isImageValid()); |
210 m_shape = createShapeForImage(shapeValue.image(), shapeImageThreshold, | 210 m_shape = createShapeForImage(shapeValue.image(), shapeImageThreshold, |
211 writingMode, margin); | 211 writingMode, margin); |
212 break; | 212 break; |
213 case ShapeValue::Box: { | 213 case ShapeValue::Box: { |
214 const FloatRoundedRect& shapeRect = style.getRoundedBorderFor( | 214 const FloatRoundedRect& shapeRect = style.getRoundedBorderFor( |
215 LayoutRect(LayoutPoint(), m_referenceBoxLogicalSize), | 215 LayoutRect(LayoutPoint(), m_referenceBoxLogicalSize), |
216 m_layoutBox.view()); | 216 m_layoutBox.view()); |
217 m_shape = Shape::createLayoutBoxShape(shapeRect, writingMode, margin); | 217 m_shape = Shape::createLayoutBoxShape(shapeRect, writingMode, margin); |
218 break; | 218 break; |
219 } | 219 } |
220 } | 220 } |
221 | 221 |
222 ASSERT(m_shape); | 222 DCHECK(m_shape); |
223 return *m_shape; | 223 return *m_shape; |
224 } | 224 } |
225 | 225 |
226 inline LayoutUnit borderBeforeInWritingMode(const LayoutBox& layoutBox, | 226 inline LayoutUnit borderBeforeInWritingMode(const LayoutBox& layoutBox, |
227 WritingMode writingMode) { | 227 WritingMode writingMode) { |
228 switch (writingMode) { | 228 switch (writingMode) { |
229 case WritingMode::kHorizontalTb: | 229 case WritingMode::kHorizontalTb: |
230 return LayoutUnit(layoutBox.borderTop()); | 230 return LayoutUnit(layoutBox.borderTop()); |
231 case WritingMode::kVerticalLr: | 231 case WritingMode::kVerticalLr: |
232 return LayoutUnit(layoutBox.borderLeft()); | 232 return LayoutUnit(layoutBox.borderLeft()); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 } | 342 } |
343 | 343 |
344 return false; | 344 return false; |
345 } | 345 } |
346 | 346 |
347 ShapeOutsideDeltas ShapeOutsideInfo::computeDeltasForContainingBlockLine( | 347 ShapeOutsideDeltas ShapeOutsideInfo::computeDeltasForContainingBlockLine( |
348 const LineLayoutBlockFlow& containingBlock, | 348 const LineLayoutBlockFlow& containingBlock, |
349 const FloatingObject& floatingObject, | 349 const FloatingObject& floatingObject, |
350 LayoutUnit lineTop, | 350 LayoutUnit lineTop, |
351 LayoutUnit lineHeight) { | 351 LayoutUnit lineHeight) { |
352 ASSERT(lineHeight >= 0); | 352 DCHECK_GE(lineHeight, 0); |
353 | 353 |
354 LayoutUnit borderBoxTop = containingBlock.logicalTopForFloat(floatingObject) + | 354 LayoutUnit borderBoxTop = containingBlock.logicalTopForFloat(floatingObject) + |
355 containingBlock.marginBeforeForChild(m_layoutBox); | 355 containingBlock.marginBeforeForChild(m_layoutBox); |
356 LayoutUnit borderBoxLineTop = lineTop - borderBoxTop; | 356 LayoutUnit borderBoxLineTop = lineTop - borderBoxTop; |
357 | 357 |
358 if (isShapeDirty() || | 358 if (isShapeDirty() || |
359 !m_shapeOutsideDeltas.isForLine(borderBoxLineTop, lineHeight)) { | 359 !m_shapeOutsideDeltas.isForLine(borderBoxLineTop, lineHeight)) { |
360 LayoutUnit referenceBoxLineTop = borderBoxLineTop - logicalTopOffset(); | 360 LayoutUnit referenceBoxLineTop = borderBoxLineTop - logicalTopOffset(); |
361 LayoutUnit floatMarginBoxWidth = std::max( | 361 LayoutUnit floatMarginBoxWidth = std::max( |
362 containingBlock.logicalWidthForFloat(floatingObject), LayoutUnit()); | 362 containingBlock.logicalWidthForFloat(floatingObject), LayoutUnit()); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 return result; | 434 return result; |
435 } | 435 } |
436 | 436 |
437 FloatSize ShapeOutsideInfo::shapeToLayoutObjectSize(FloatSize size) const { | 437 FloatSize ShapeOutsideInfo::shapeToLayoutObjectSize(FloatSize size) const { |
438 if (!m_layoutBox.style()->isHorizontalWritingMode()) | 438 if (!m_layoutBox.style()->isHorizontalWritingMode()) |
439 return size.transposedSize(); | 439 return size.transposedSize(); |
440 return size; | 440 return size; |
441 } | 441 } |
442 | 442 |
443 } // namespace blink | 443 } // namespace blink |
OLD | NEW |