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

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

Issue 703563002: Remove shape-outside. (Closed) Base URL: git@github.com:domokit/mojo.git@master
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
(Empty)
1 /*
2 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above
9 * copyright notice, this list of conditions and the following
10 * disclaimer.
11 * 2. Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following
13 * disclaimer in the documentation and/or other materials
14 * provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
19 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
20 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
21 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
25 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
27 * OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30 #include "config.h"
31 #include "core/rendering/shapes/BoxShape.h"
32
33 #include "wtf/MathExtras.h"
34
35 namespace blink {
36
37 LayoutRect BoxShape::shapeMarginLogicalBoundingBox() const
38 {
39 FloatRect marginBounds(m_bounds.rect());
40 if (shapeMargin() > 0)
41 marginBounds.inflate(shapeMargin());
42 return static_cast<LayoutRect>(marginBounds);
43 }
44
45 FloatRoundedRect BoxShape::shapeMarginBounds() const
46 {
47 FloatRoundedRect marginBounds(m_bounds);
48 if (shapeMargin() > 0) {
49 marginBounds.inflate(shapeMargin());
50 marginBounds.expandRadii(shapeMargin());
51 }
52 return marginBounds;
53 }
54
55 LineSegment BoxShape::getExcludedInterval(LayoutUnit logicalTop, LayoutUnit logi calHeight) const
56 {
57 const FloatRoundedRect& marginBounds = shapeMarginBounds();
58 if (marginBounds.isEmpty() || !lineOverlapsShapeMarginBounds(logicalTop, log icalHeight))
59 return LineSegment();
60
61 float y1 = logicalTop.toFloat();
62 float y2 = (logicalTop + logicalHeight).toFloat();
63 const FloatRect& rect = marginBounds.rect();
64
65 if (!marginBounds.isRounded())
66 return LineSegment(marginBounds.rect().x(), marginBounds.rect().maxX());
67
68 float topCornerMaxY = std::max<float>(marginBounds.topLeftCorner().maxY(), m arginBounds.topRightCorner().maxY());
69 float bottomCornerMinY = std::min<float>(marginBounds.bottomLeftCorner().y() , marginBounds.bottomRightCorner().y());
70
71 if (topCornerMaxY <= bottomCornerMinY && y1 <= topCornerMaxY && y2 >= bottom CornerMinY)
72 return LineSegment(rect.x(), rect.maxX());
73
74 float x1 = rect.maxX();
75 float x2 = rect.x();
76 float minXIntercept;
77 float maxXIntercept;
78
79 if (y1 <= marginBounds.topLeftCorner().maxY() && y2 >= marginBounds.bottomLe ftCorner().y())
80 x1 = rect.x();
81
82 if (y1 <= marginBounds.topRightCorner().maxY() && y2 >= marginBounds.bottomR ightCorner().y())
83 x2 = rect.maxX();
84
85 if (marginBounds.xInterceptsAtY(y1, minXIntercept, maxXIntercept)) {
86 x1 = std::min<float>(x1, minXIntercept);
87 x2 = std::max<float>(x2, maxXIntercept);
88 }
89
90 if (marginBounds.xInterceptsAtY(y2, minXIntercept, maxXIntercept)) {
91 x1 = std::min<float>(x1, minXIntercept);
92 x2 = std::max<float>(x2, maxXIntercept);
93 }
94
95 ASSERT(x2 >= x1);
96 return LineSegment(x1, x2);
97 }
98
99 void BoxShape::buildDisplayPaths(DisplayPaths& paths) const
100 {
101 paths.shape.addRoundedRect(m_bounds.rect(), m_bounds.radii().topLeft(), m_bo unds.radii().topRight(), m_bounds.radii().bottomLeft(), m_bounds.radii().bottomR ight());
102 if (shapeMargin())
103 paths.marginShape.addRoundedRect(shapeMarginBounds().rect(), shapeMargin Bounds().radii().topLeft(), shapeMarginBounds().radii().topRight(), shapeMarginB ounds().radii().bottomLeft(), shapeMarginBounds().radii().bottomRight());
104 }
105
106 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/rendering/shapes/BoxShape.h ('k') | sky/engine/core/rendering/shapes/BoxShapeTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698