| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. | 2 * Copyright (C) 2013 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 const FloatSize& bottomRight() const { return m_bottomRight; } | 67 const FloatSize& bottomRight() const { return m_bottomRight; } |
| 68 | 68 |
| 69 bool isZero() const; | 69 bool isZero() const; |
| 70 | 70 |
| 71 void scale(float factor); | 71 void scale(float factor); |
| 72 void expand(float topWidth, float bottomWidth, float leftWidth, float ri
ghtWidth); | 72 void expand(float topWidth, float bottomWidth, float leftWidth, float ri
ghtWidth); |
| 73 void expand(float size) { expand(size, size, size, size); } | 73 void expand(float size) { expand(size, size, size, size); } |
| 74 void shrink(float topWidth, float bottomWidth, float leftWidth, float ri
ghtWidth) { expand(-topWidth, -bottomWidth, -leftWidth, -rightWidth); } | 74 void shrink(float topWidth, float bottomWidth, float leftWidth, float ri
ghtWidth) { expand(-topWidth, -bottomWidth, -leftWidth, -rightWidth); } |
| 75 void shrink(float size) { shrink(size, size, size, size); } | 75 void shrink(float size) { shrink(size, size, size, size); } |
| 76 | 76 |
| 77 void includeLogicalEdges(const Radii& edges, bool isHorizontal, bool inc
ludeLogicalLeftEdge, bool includeLogicalRightEdge); |
| 78 |
| 77 private: | 79 private: |
| 78 FloatSize m_topLeft; | 80 FloatSize m_topLeft; |
| 79 FloatSize m_topRight; | 81 FloatSize m_topRight; |
| 80 FloatSize m_bottomLeft; | 82 FloatSize m_bottomLeft; |
| 81 FloatSize m_bottomRight; | 83 FloatSize m_bottomRight; |
| 82 }; | 84 }; |
| 83 | 85 |
| 84 explicit FloatRoundedRect(const FloatRect&, const Radii& = Radii()); | 86 explicit FloatRoundedRect(const FloatRect&, const Radii& = Radii()); |
| 85 FloatRoundedRect(float x, float y, float width, float height); | 87 FloatRoundedRect(float x, float y, float width, float height); |
| 86 FloatRoundedRect(const FloatRect&, const FloatSize& topLeft, const FloatSize
& topRight, const FloatSize& bottomLeft, const FloatSize& bottomRight); | 88 FloatRoundedRect(const FloatRect&, const FloatSize& topLeft, const FloatSize
& topRight, const FloatSize& bottomLeft, const FloatSize& bottomRight); |
| 87 | 89 |
| 88 const FloatRect& rect() const { return m_rect; } | 90 const FloatRect& rect() const { return m_rect; } |
| 89 const Radii& radii() const { return m_radii; } | 91 const Radii& radii() const { return m_radii; } |
| 90 bool isRounded() const { return !m_radii.isZero(); } | 92 bool isRounded() const { return !m_radii.isZero(); } |
| 91 bool isEmpty() const { return m_rect.isEmpty(); } | 93 bool isEmpty() const { return m_rect.isEmpty(); } |
| 92 | 94 |
| 93 void setRect(const FloatRect& rect) { m_rect = rect; } | 95 void setRect(const FloatRect& rect) { m_rect = rect; } |
| 94 void setRadii(const Radii& radii) { m_radii = radii; } | 96 void setRadii(const Radii& radii) { m_radii = radii; } |
| 95 | 97 |
| 96 void move(const FloatSize& size) { m_rect.move(size); } | 98 void move(const FloatSize& size) { m_rect.move(size); } |
| 97 void inflate(float size) { m_rect.inflate(size); } | 99 void inflateWithRadii(int size); |
| 100 void inflate(float size) { m_rect.inflate(size); } |
| 98 void expandRadii(float size) { m_radii.expand(size); } | 101 void expandRadii(float size) { m_radii.expand(size); } |
| 99 void shrinkRadii(float size) { m_radii.shrink(size); } | 102 void shrinkRadii(float size) { m_radii.shrink(size); } |
| 100 | 103 |
| 104 // Returns a quickly computed rect enclosed by the rounded rect. |
| 105 FloatRect radiusCenterRect() const; |
| 106 |
| 101 FloatRect topLeftCorner() const | 107 FloatRect topLeftCorner() const |
| 102 { | 108 { |
| 103 return FloatRect(m_rect.x(), m_rect.y(), m_radii.topLeft().width(), m_ra
dii.topLeft().height()); | 109 return FloatRect(m_rect.x(), m_rect.y(), m_radii.topLeft().width(), m_ra
dii.topLeft().height()); |
| 104 } | 110 } |
| 105 FloatRect topRightCorner() const | 111 FloatRect topRightCorner() const |
| 106 { | 112 { |
| 107 return FloatRect(m_rect.maxX() - m_radii.topRight().width(), m_rect.y(),
m_radii.topRight().width(), m_radii.topRight().height()); | 113 return FloatRect(m_rect.maxX() - m_radii.topRight().width(), m_rect.y(),
m_radii.topRight().width(), m_radii.topRight().height()); |
| 108 } | 114 } |
| 109 FloatRect bottomLeftCorner() const | 115 FloatRect bottomLeftCorner() const |
| 110 { | 116 { |
| 111 return FloatRect(m_rect.x(), m_rect.maxY() - m_radii.bottomLeft().height
(), m_radii.bottomLeft().width(), m_radii.bottomLeft().height()); | 117 return FloatRect(m_rect.x(), m_rect.maxY() - m_radii.bottomLeft().height
(), m_radii.bottomLeft().width(), m_radii.bottomLeft().height()); |
| 112 } | 118 } |
| 113 FloatRect bottomRightCorner() const | 119 FloatRect bottomRightCorner() const |
| 114 { | 120 { |
| 115 return FloatRect(m_rect.maxX() - m_radii.bottomRight().width(), m_rect.m
axY() - m_radii.bottomRight().height(), m_radii.bottomRight().width(), m_radii.b
ottomRight().height()); | 121 return FloatRect(m_rect.maxX() - m_radii.bottomRight().width(), m_rect.m
axY() - m_radii.bottomRight().height(), m_radii.bottomRight().width(), m_radii.b
ottomRight().height()); |
| 116 } | 122 } |
| 117 | 123 |
| 118 bool xInterceptsAtY(float y, float& minXIntercept, float& maxXIntercept) con
st; | 124 bool xInterceptsAtY(float y, float& minXIntercept, float& maxXIntercept) con
st; |
| 119 | 125 |
| 126 void includeLogicalEdges(const Radii& edges, bool isHorizontal, bool include
LogicalLeftEdge, bool includeLogicalRightEdge); |
| 127 |
| 128 // Tests whether the quad intersects any part of this rounded rectangle. |
| 129 // This only works for convex quads. |
| 130 bool intersectsQuad(const FloatQuad&) const; |
| 131 |
| 132 void adjustRadii(); |
| 133 bool isRenderable() const; |
| 134 |
| 120 private: | 135 private: |
| 121 FloatRect m_rect; | 136 FloatRect m_rect; |
| 122 Radii m_radii; | 137 Radii m_radii; |
| 123 }; | 138 }; |
| 124 | 139 |
| 125 inline bool operator==(const FloatRoundedRect::Radii& a, const FloatRoundedRect:
:Radii& b) | 140 inline bool operator==(const FloatRoundedRect::Radii& a, const FloatRoundedRect:
:Radii& b) |
| 126 { | 141 { |
| 127 return a.topLeft() == b.topLeft() && a.topRight() == b.topRight() && a.botto
mLeft() == b.bottomLeft() && a.bottomRight() == b.bottomRight(); | 142 return a.topLeft() == b.topLeft() && a.topRight() == b.topRight() && a.botto
mLeft() == b.bottomLeft() && a.bottomRight() == b.bottomRight(); |
| 128 } | 143 } |
| 129 | 144 |
| 145 |
| 146 inline bool operator!=(const FloatRoundedRect::Radii& a, const FloatRoundedRect:
:Radii& b) |
| 147 { |
| 148 return !(a == b); |
| 149 } |
| 150 |
| 151 |
| 130 inline bool operator==(const FloatRoundedRect& a, const FloatRoundedRect& b) | 152 inline bool operator==(const FloatRoundedRect& a, const FloatRoundedRect& b) |
| 131 { | 153 { |
| 132 return a.rect() == b.rect() && a.radii() == b.radii(); | 154 return a.rect() == b.rect() && a.radii() == b.radii(); |
| 133 } | 155 } |
| 134 | 156 |
| 135 } // namespace blink | 157 } // namespace blink |
| 136 | 158 |
| 137 #endif // FloatRoundedRect_h | 159 #endif // FloatRoundedRect_h |
| OLD | NEW |