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

Side by Side Diff: Source/core/platform/graphics/RoundedRect.cpp

Issue 16402019: Remove clips where we can show that they are unnecessary. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: per jchaffraix Created 7 years, 4 months 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
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
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 16 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28 #include "config.h" 28 #include "config.h"
29 #include "core/platform/graphics/RoundedRect.h" 29 #include "core/platform/graphics/RoundedRect.h"
30 #include "wtf/Assertions.h"
30 31
31 #include <algorithm> 32 #include <algorithm>
32 33
33 using namespace std; 34 using namespace std;
34 35
35 namespace WebCore { 36 namespace WebCore {
36 37
37 bool RoundedRect::Radii::isZero() const 38 bool RoundedRect::Radii::isZero() const
38 { 39 {
39 return m_topLeft.isZero() && m_topRight.isZero() && m_bottomLeft.isZero() && m_bottomRight.isZero(); 40 return m_topLeft.isZero() && m_topRight.isZero() && m_bottomLeft.isZero() && m_bottomRight.isZero();
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 , m_radii(radii) 144 , m_radii(radii)
144 { 145 {
145 } 146 }
146 147
147 RoundedRect::RoundedRect(const IntRect& rect, const IntSize& topLeft, const IntS ize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight) 148 RoundedRect::RoundedRect(const IntRect& rect, const IntSize& topLeft, const IntS ize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight)
148 : m_rect(rect) 149 : m_rect(rect)
149 , m_radii(topLeft, topRight, bottomLeft, bottomRight) 150 , m_radii(topLeft, topRight, bottomLeft, bottomRight)
150 { 151 {
151 } 152 }
152 153
154 IntRect RoundedRect::radiusCenterRect() const
155 {
156 ASSERT(isRenderable());
157 int minX = m_rect.x() + max(m_radii.topLeft().width(), m_radii.bottomLeft(). width());
158 int minY = m_rect.y() + max(m_radii.topLeft().height(), m_radii.topRight().h eight());
159 int maxX = m_rect.maxX() - max(m_radii.topRight().width(), m_radii.bottomRig ht().width());
160 int maxY = m_rect.maxY() - max(m_radii.bottomLeft().height(), m_radii.bottom Right().height());
161 return IntRect(minX, minY, maxX - minX, maxY - minY);
162 }
163
153 void RoundedRect::includeLogicalEdges(const Radii& edges, bool isHorizontal, boo l includeLogicalLeftEdge, bool includeLogicalRightEdge) 164 void RoundedRect::includeLogicalEdges(const Radii& edges, bool isHorizontal, boo l includeLogicalLeftEdge, bool includeLogicalRightEdge)
154 { 165 {
155 m_radii.includeLogicalEdges(edges, isHorizontal, includeLogicalLeftEdge, inc ludeLogicalRightEdge); 166 m_radii.includeLogicalEdges(edges, isHorizontal, includeLogicalLeftEdge, inc ludeLogicalRightEdge);
156 } 167 }
157 168
158 void RoundedRect::excludeLogicalEdges(bool isHorizontal, bool excludeLogicalLeft Edge, bool excludeLogicalRightEdge) 169 void RoundedRect::excludeLogicalEdges(bool isHorizontal, bool excludeLogicalLeft Edge, bool excludeLogicalRightEdge)
159 { 170 {
160 m_radii.excludeLogicalEdges(isHorizontal, excludeLogicalLeftEdge, excludeLog icalRightEdge); 171 m_radii.excludeLogicalEdges(isHorizontal, excludeLogicalLeftEdge, excludeLog icalRightEdge);
161 } 172 }
162 173
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 FloatSize size(bottomRight.width(), bottomRight.height()); 240 FloatSize size(bottomRight.width(), bottomRight.height());
230 if (!quad.intersectsEllipse(center, size)) 241 if (!quad.intersectsEllipse(center, size))
231 return false; 242 return false;
232 } 243 }
233 } 244 }
234 245
235 return true; 246 return true;
236 } 247 }
237 248
238 } // namespace WebCore 249 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/platform/graphics/RoundedRect.h ('k') | Source/core/platform/graphics/RoundedRectTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698