| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/paint/NinePieceImageGrid.h" | 5 #include "core/paint/NinePieceImageGrid.h" |
| 6 | 6 |
| 7 #include "core/style/ComputedStyle.h" | 7 #include "core/style/ComputedStyle.h" |
| 8 #include "core/style/NinePieceImage.h" | 8 #include "core/style/NinePieceImage.h" |
| 9 #include "platform/LengthFunctions.h" | 9 #include "platform/LengthFunctions.h" |
| 10 #include "platform/geometry/FloatSize.h" | 10 #include "platform/geometry/FloatSize.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 borderWidths.bottom(), m_bottom.slice, | 56 borderWidths.bottom(), m_bottom.slice, |
| 57 borderImageArea.height()); | 57 borderImageArea.height()); |
| 58 m_left.width = computeEdgeWidth(ninePieceImage.borderSlices().left(), | 58 m_left.width = computeEdgeWidth(ninePieceImage.borderSlices().left(), |
| 59 borderWidths.left(), m_left.slice, | 59 borderWidths.left(), m_left.slice, |
| 60 borderImageArea.width()); | 60 borderImageArea.width()); |
| 61 | 61 |
| 62 // The spec says: Given Lwidth as the width of the border image area, Lheight | 62 // The spec says: Given Lwidth as the width of the border image area, Lheight |
| 63 // as its height, and Wside as the border image width offset for the side, let | 63 // as its height, and Wside as the border image width offset for the side, let |
| 64 // f = min(Lwidth/(Wleft+Wright), Lheight/(Wtop+Wbottom)). If f < 1, then all | 64 // f = min(Lwidth/(Wleft+Wright), Lheight/(Wtop+Wbottom)). If f < 1, then all |
| 65 // W are reduced by multiplying them by f. | 65 // W are reduced by multiplying them by f. |
| 66 int borderSideWidth = std::max(1, m_left.width + m_right.width); | 66 int borderSideWidth = |
| 67 int borderSideHeight = std::max(1, m_top.width + m_bottom.width); | 67 std::max(1, SaturatedAddition(m_left.width, m_right.width)); |
| 68 int borderSideHeight = |
| 69 std::max(1, SaturatedAddition(m_top.width, m_bottom.width)); |
| 68 float borderSideScaleFactor = | 70 float borderSideScaleFactor = |
| 69 std::min((float)borderImageArea.width() / borderSideWidth, | 71 std::min((float)borderImageArea.width() / borderSideWidth, |
| 70 (float)borderImageArea.height() / borderSideHeight); | 72 (float)borderImageArea.height() / borderSideHeight); |
| 71 if (borderSideScaleFactor < 1) { | 73 if (borderSideScaleFactor < 1) { |
| 72 m_top.width *= borderSideScaleFactor; | 74 m_top.width *= borderSideScaleFactor; |
| 73 m_right.width *= borderSideScaleFactor; | 75 m_right.width *= borderSideScaleFactor; |
| 74 m_bottom.width *= borderSideScaleFactor; | 76 m_bottom.width *= borderSideScaleFactor; |
| 75 m_left.width *= borderSideScaleFactor; | 77 m_left.width *= borderSideScaleFactor; |
| 76 } | 78 } |
| 77 } | 79 } |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 drawInfo.source.scale(imageScaleFactor); | 302 drawInfo.source.scale(imageScaleFactor); |
| 301 | 303 |
| 302 // Compensate for source scaling by scaling down the individual tiles. | 304 // Compensate for source scaling by scaling down the individual tiles. |
| 303 drawInfo.tileScale.scale(1 / imageScaleFactor); | 305 drawInfo.tileScale.scale(1 / imageScaleFactor); |
| 304 } | 306 } |
| 305 | 307 |
| 306 return drawInfo; | 308 return drawInfo; |
| 307 } | 309 } |
| 308 | 310 |
| 309 } // namespace blink | 311 } // namespace blink |
| OLD | NEW |