| 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 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 #include "core/layout/shapes/ShapeOutsideInfo.h" | 30 #include "core/layout/shapes/ShapeOutsideInfo.h" |
| 31 | 31 |
| 32 #include "core/inspector/ConsoleMessage.h" | 32 #include "core/inspector/ConsoleMessage.h" |
| 33 #include "core/layout/FloatingObjects.h" | 33 #include "core/layout/FloatingObjects.h" |
| 34 #include "core/layout/LayoutBlockFlow.h" | 34 #include "core/layout/LayoutBlockFlow.h" |
| 35 #include "core/layout/LayoutBox.h" | 35 #include "core/layout/LayoutBox.h" |
| 36 #include "core/layout/LayoutImage.h" | 36 #include "core/layout/LayoutImage.h" |
| 37 #include "platform/LengthFunctions.h" | 37 #include "platform/LengthFunctions.h" |
| 38 #include "public/platform/Platform.h" | 38 #include "public/platform/Platform.h" |
| 39 #include <memory> |
| 39 | 40 |
| 40 namespace blink { | 41 namespace blink { |
| 41 | 42 |
| 42 CSSBoxType referenceBox(const ShapeValue& shapeValue) | 43 CSSBoxType referenceBox(const ShapeValue& shapeValue) |
| 43 { | 44 { |
| 44 if (shapeValue.cssBox() == BoxMissing) | 45 if (shapeValue.cssBox() == BoxMissing) |
| 45 return MarginBox; | 46 return MarginBox; |
| 46 return shapeValue.cssBox(); | 47 return shapeValue.cssBox(); |
| 47 } | 48 } |
| 48 | 49 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 static bool isValidRasterShapeRect(const LayoutRect& rect) | 113 static bool isValidRasterShapeRect(const LayoutRect& rect) |
| 113 { | 114 { |
| 114 static double maxImageSizeBytes = 0; | 115 static double maxImageSizeBytes = 0; |
| 115 if (!maxImageSizeBytes) { | 116 if (!maxImageSizeBytes) { |
| 116 size_t size32MaxBytes = 0xFFFFFFFF / 4; // Some platforms don't limit m
axDecodedImageBytes. | 117 size_t size32MaxBytes = 0xFFFFFFFF / 4; // Some platforms don't limit m
axDecodedImageBytes. |
| 117 maxImageSizeBytes = std::min(size32MaxBytes, Platform::current()->maxDec
odedImageBytes()); | 118 maxImageSizeBytes = std::min(size32MaxBytes, Platform::current()->maxDec
odedImageBytes()); |
| 118 } | 119 } |
| 119 return (rect.width().toFloat() * rect.height().toFloat() * 4.0) < maxImageSi
zeBytes; | 120 return (rect.width().toFloat() * rect.height().toFloat() * 4.0) < maxImageSi
zeBytes; |
| 120 } | 121 } |
| 121 | 122 |
| 122 PassOwnPtr<Shape> ShapeOutsideInfo::createShapeForImage(StyleImage* styleImage,
float shapeImageThreshold, WritingMode writingMode, float margin) const | 123 std::unique_ptr<Shape> ShapeOutsideInfo::createShapeForImage(StyleImage* styleIm
age, float shapeImageThreshold, WritingMode writingMode, float margin) const |
| 123 { | 124 { |
| 124 const LayoutSize& imageSize = styleImage->imageSize(m_layoutBox, m_layoutBox
.style()->effectiveZoom(), m_referenceBoxLogicalSize); | 125 const LayoutSize& imageSize = styleImage->imageSize(m_layoutBox, m_layoutBox
.style()->effectiveZoom(), m_referenceBoxLogicalSize); |
| 125 | 126 |
| 126 const LayoutRect& marginRect = getShapeImageMarginRect(m_layoutBox, m_refere
nceBoxLogicalSize); | 127 const LayoutRect& marginRect = getShapeImageMarginRect(m_layoutBox, m_refere
nceBoxLogicalSize); |
| 127 const LayoutRect& imageRect = (m_layoutBox.isLayoutImage()) | 128 const LayoutRect& imageRect = (m_layoutBox.isLayoutImage()) |
| 128 ? toLayoutImage(m_layoutBox).replacedContentRect() | 129 ? toLayoutImage(m_layoutBox).replacedContentRect() |
| 129 : LayoutRect(LayoutPoint(), imageSize); | 130 : LayoutRect(LayoutPoint(), imageSize); |
| 130 | 131 |
| 131 if (!isValidRasterShapeRect(marginRect) || !isValidRasterShapeRect(imageRect
)) { | 132 if (!isValidRasterShapeRect(marginRect) || !isValidRasterShapeRect(imageRect
)) { |
| 132 m_layoutBox.document().addConsoleMessage(ConsoleMessage::create(Renderin
gMessageSource, ErrorMessageLevel, "The shape-outside image is too large.")); | 133 m_layoutBox.document().addConsoleMessage(ConsoleMessage::create(Renderin
gMessageSource, ErrorMessageLevel, "The shape-outside image is too large.")); |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 } | 345 } |
| 345 | 346 |
| 346 FloatSize ShapeOutsideInfo::shapeToLayoutObjectSize(FloatSize size) const | 347 FloatSize ShapeOutsideInfo::shapeToLayoutObjectSize(FloatSize size) const |
| 347 { | 348 { |
| 348 if (!m_layoutBox.style()->isHorizontalWritingMode()) | 349 if (!m_layoutBox.style()->isHorizontalWritingMode()) |
| 349 return size.transposedSize(); | 350 return size.transposedSize(); |
| 350 return size; | 351 return size; |
| 351 } | 352 } |
| 352 | 353 |
| 353 } // namespace blink | 354 } // namespace blink |
| OLD | NEW |