| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2003, 2006, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2003, 2006, 2009 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2010 Google Inc. All rights reserved. | 3 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 4 * Copyright (C) 2013 Xidorn Quan (quanxunzhen@gmail.com) | 4 * Copyright (C) 2013 Xidorn Quan (quanxunzhen@gmail.com) |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * | 9 * |
| 10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 // Considering the inflation factor of shorter size to scale the radii seems
appropriate here | 87 // Considering the inflation factor of shorter size to scale the radii seems
appropriate here |
| 88 float factor; | 88 float factor; |
| 89 if (m_rect.width() < m_rect.height()) | 89 if (m_rect.width() < m_rect.height()) |
| 90 factor = old.width() ? (float)m_rect.width() / old.width() : int(0); | 90 factor = old.width() ? (float)m_rect.width() / old.width() : int(0); |
| 91 else | 91 else |
| 92 factor = old.height() ? (float)m_rect.height() / old.height() : int(0); | 92 factor = old.height() ? (float)m_rect.height() / old.height() : int(0); |
| 93 | 93 |
| 94 m_radii.scale(factor); | 94 m_radii.scale(factor); |
| 95 } | 95 } |
| 96 | 96 |
| 97 void RoundedRect::Radii::includeLogicalEdges(const RoundedRect::Radii& edges, bo
ol isHorizontal, bool includeLogicalLeftEdge, bool includeLogicalRightEdge) | 97 void RoundedRect::Radii::includeLogicalEdges(const RoundedRect::Radii& edges, bo
ol includeLogicalLeftEdge, bool includeLogicalRightEdge) |
| 98 { | 98 { |
| 99 if (includeLogicalLeftEdge) { | 99 if (includeLogicalLeftEdge) { |
| 100 if (isHorizontal) | 100 m_bottomLeft = edges.bottomLeft(); |
| 101 m_bottomLeft = edges.bottomLeft(); | |
| 102 else | |
| 103 m_topRight = edges.topRight(); | |
| 104 m_topLeft = edges.topLeft(); | 101 m_topLeft = edges.topLeft(); |
| 105 } | 102 } |
| 106 | 103 |
| 107 if (includeLogicalRightEdge) { | 104 if (includeLogicalRightEdge) { |
| 108 if (isHorizontal) | 105 m_topRight = edges.topRight(); |
| 109 m_topRight = edges.topRight(); | |
| 110 else | |
| 111 m_bottomLeft = edges.bottomLeft(); | |
| 112 m_bottomRight = edges.bottomRight(); | 106 m_bottomRight = edges.bottomRight(); |
| 113 } | 107 } |
| 114 } | 108 } |
| 115 | 109 |
| 116 void RoundedRect::Radii::excludeLogicalEdges(bool isHorizontal, bool excludeLogi
calLeftEdge, bool excludeLogicalRightEdge) | |
| 117 { | |
| 118 if (excludeLogicalLeftEdge) { | |
| 119 if (isHorizontal) | |
| 120 m_bottomLeft = IntSize(); | |
| 121 else | |
| 122 m_topRight = IntSize(); | |
| 123 m_topLeft = IntSize(); | |
| 124 } | |
| 125 | |
| 126 if (excludeLogicalRightEdge) { | |
| 127 if (isHorizontal) | |
| 128 m_topRight = IntSize(); | |
| 129 else | |
| 130 m_bottomLeft = IntSize(); | |
| 131 m_bottomRight = IntSize(); | |
| 132 } | |
| 133 } | |
| 134 | |
| 135 RoundedRect::RoundedRect(int x, int y, int width, int height) | 110 RoundedRect::RoundedRect(int x, int y, int width, int height) |
| 136 : m_rect(x, y, width, height) | 111 : m_rect(x, y, width, height) |
| 137 { | 112 { |
| 138 } | 113 } |
| 139 | 114 |
| 140 RoundedRect::RoundedRect(const IntRect& rect, const Radii& radii) | 115 RoundedRect::RoundedRect(const IntRect& rect, const Radii& radii) |
| 141 : m_rect(rect) | 116 : m_rect(rect) |
| 142 , m_radii(radii) | 117 , m_radii(radii) |
| 143 { | 118 { |
| 144 } | 119 } |
| 145 | 120 |
| 146 RoundedRect::RoundedRect(const IntRect& rect, const IntSize& topLeft, const IntS
ize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight) | 121 RoundedRect::RoundedRect(const IntRect& rect, const IntSize& topLeft, const IntS
ize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight) |
| 147 : m_rect(rect) | 122 : m_rect(rect) |
| 148 , m_radii(topLeft, topRight, bottomLeft, bottomRight) | 123 , m_radii(topLeft, topRight, bottomLeft, bottomRight) |
| 149 { | 124 { |
| 150 } | 125 } |
| 151 | 126 |
| 152 IntRect RoundedRect::radiusCenterRect() const | 127 IntRect RoundedRect::radiusCenterRect() const |
| 153 { | 128 { |
| 154 ASSERT(isRenderable()); | 129 ASSERT(isRenderable()); |
| 155 int minX = m_rect.x() + std::max(m_radii.topLeft().width(), m_radii.bottomLe
ft().width()); | 130 int minX = m_rect.x() + std::max(m_radii.topLeft().width(), m_radii.bottomLe
ft().width()); |
| 156 int minY = m_rect.y() + std::max(m_radii.topLeft().height(), m_radii.topRigh
t().height()); | 131 int minY = m_rect.y() + std::max(m_radii.topLeft().height(), m_radii.topRigh
t().height()); |
| 157 int maxX = m_rect.maxX() - std::max(m_radii.topRight().width(), m_radii.bott
omRight().width()); | 132 int maxX = m_rect.maxX() - std::max(m_radii.topRight().width(), m_radii.bott
omRight().width()); |
| 158 int maxY = m_rect.maxY() - std::max(m_radii.bottomLeft().height(), m_radii.b
ottomRight().height()); | 133 int maxY = m_rect.maxY() - std::max(m_radii.bottomLeft().height(), m_radii.b
ottomRight().height()); |
| 159 return IntRect(minX, minY, maxX - minX, maxY - minY); | 134 return IntRect(minX, minY, maxX - minX, maxY - minY); |
| 160 } | 135 } |
| 161 | 136 |
| 162 void RoundedRect::includeLogicalEdges(const Radii& edges, bool isHorizontal, boo
l includeLogicalLeftEdge, bool includeLogicalRightEdge) | 137 void RoundedRect::includeLogicalEdges(const Radii& edges, bool includeLogicalLef
tEdge, bool includeLogicalRightEdge) |
| 163 { | 138 { |
| 164 m_radii.includeLogicalEdges(edges, isHorizontal, includeLogicalLeftEdge, inc
ludeLogicalRightEdge); | 139 m_radii.includeLogicalEdges(edges, includeLogicalLeftEdge, includeLogicalRig
htEdge); |
| 165 } | |
| 166 | |
| 167 void RoundedRect::excludeLogicalEdges(bool isHorizontal, bool excludeLogicalLeft
Edge, bool excludeLogicalRightEdge) | |
| 168 { | |
| 169 m_radii.excludeLogicalEdges(isHorizontal, excludeLogicalLeftEdge, excludeLog
icalRightEdge); | |
| 170 } | 140 } |
| 171 | 141 |
| 172 bool RoundedRect::isRenderable() const | 142 bool RoundedRect::isRenderable() const |
| 173 { | 143 { |
| 174 return m_radii.topLeft().width() + m_radii.topRight().width() <= m_rect.widt
h() | 144 return m_radii.topLeft().width() + m_radii.topRight().width() <= m_rect.widt
h() |
| 175 && m_radii.bottomLeft().width() + m_radii.bottomRight().width() <= m_rec
t.width() | 145 && m_radii.bottomLeft().width() + m_radii.bottomRight().width() <= m_rec
t.width() |
| 176 && m_radii.topLeft().height() + m_radii.bottomLeft().height() <= m_rect.
height() | 146 && m_radii.topLeft().height() + m_radii.bottomLeft().height() <= m_rect.
height() |
| 177 && m_radii.topRight().height() + m_radii.bottomRight().height() <= m_rec
t.height(); | 147 && m_radii.topRight().height() + m_radii.bottomRight().height() <= m_rec
t.height(); |
| 178 } | 148 } |
| 179 | 149 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 FloatSize size(bottomRight.width(), bottomRight.height()); | 208 FloatSize size(bottomRight.width(), bottomRight.height()); |
| 239 if (!quad.intersectsEllipse(center, size)) | 209 if (!quad.intersectsEllipse(center, size)) |
| 240 return false; | 210 return false; |
| 241 } | 211 } |
| 242 } | 212 } |
| 243 | 213 |
| 244 return true; | 214 return true; |
| 245 } | 215 } |
| 246 | 216 |
| 247 } // namespace blink | 217 } // namespace blink |
| OLD | NEW |