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

Side by Side Diff: Source/core/rendering/RenderOverflowTest.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: NeedsRebaseline for Mac 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
(Empty)
1 /*
2 * Copyright (C) 2013 Google Inc. 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 are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 #include "config.h"
32 #include "core/rendering/RenderOverflow.h"
33
34 #include "core/platform/graphics/LayoutRect.h"
35
36 #include <gtest/gtest.h>
37
38 using namespace WebCore;
39
40 namespace WebCore {
41
42 // FIXME: Move this somewhere more generic.
43 void PrintTo(const LayoutRect& rect, ::std::ostream* os)
44 {
45 *os << "LayoutRect("
46 << rect.x().toFloat() << ", "
47 << rect.y().toFloat() << ", "
48 << rect.width().toFloat() << ", "
49 << rect.height().toFloat() << ")";
50 }
51
52 } // namespace WebCore
53
54 namespace {
55
56 TEST(RenderOverflowTest, InitialOverflowRects)
57 {
58 RenderOverflow overflow(LayoutRect(10, 10, 80, 80), LayoutRect(0, 0, 100, 10 0));
59 EXPECT_EQ(LayoutRect(10, 10, 80, 80), overflow.layoutOverflowRect());
60 EXPECT_EQ(LayoutRect(0, 0, 100, 100), overflow.visualOverflowRect());
61 EXPECT_TRUE(overflow.contentsVisualOverflowRect().isEmpty());
62 }
63
64 TEST(RenderOverflowTest, AddLayoutOverflow)
65 {
66 RenderOverflow overflow(LayoutRect(10, 10, 80, 80), LayoutRect(0, 0, 100, 10 0));
67
68 overflow.addLayoutOverflow(LayoutRect(0, 10, 30, 10));
69 EXPECT_EQ(LayoutRect(0, 10, 90, 80), overflow.layoutOverflowRect());
70
71 overflow.addLayoutOverflow(LayoutRect(50, 50, 10, 20));
72 EXPECT_EQ(LayoutRect(0, 10, 90, 80), overflow.layoutOverflowRect());
73
74 // It's not clear whether any code relies on this behavior (it seems like th is
75 // could probably just use LayoutRect::unite).
Julien - ping for review 2013/08/07 00:17:08 No clue what this comment means.
jbroman 2013/08/08 14:35:39 Removed. It didn't add much value anyhow.
76 overflow.addLayoutOverflow(LayoutRect(200, 200, 0, 0));
Julien - ping for review 2013/08/07 00:17:08 This seems like a dumb case (and arguable in how w
jbroman 2013/08/08 14:35:39 I agree that it's a dumb case, and the previous co
77 EXPECT_EQ(LayoutRect(0, 10, 200, 190), overflow.layoutOverflowRect());
78
79 EXPECT_EQ(LayoutRect(0, 0, 100, 100), overflow.visualOverflowRect());
80 EXPECT_TRUE(overflow.contentsVisualOverflowRect().isEmpty());
81 }
82
83 TEST(RenderOverflowTest, AddVisualOverflow)
84 {
85 RenderOverflow overflow(LayoutRect(10, 10, 80, 80), LayoutRect(0, 0, 100, 10 0));
86
87 overflow.addVisualOverflow(LayoutRect(-10, 0, 30, 30));
88 EXPECT_EQ(LayoutRect(-10, 0, 110, 100), overflow.visualOverflowRect());
89
90 overflow.addVisualOverflow(LayoutRect(50, 50, 10, 20));
91 EXPECT_EQ(LayoutRect(-10, 0, 110, 100), overflow.visualOverflowRect());
92
93 // It's not clear whether any code relies on this behavior (it seems like th is
94 // could probably just use LayoutRect::unite).
95 overflow.addVisualOverflow(LayoutRect(200, 200, 0, 0));
96 EXPECT_EQ(LayoutRect(-10, 0, 210, 200), overflow.visualOverflowRect());
97
98 EXPECT_EQ(LayoutRect(10, 10, 80, 80), overflow.layoutOverflowRect());
99 EXPECT_TRUE(overflow.contentsVisualOverflowRect().isEmpty());
100 }
101
102 TEST(RenderOverflowTest, AddContentsVisualOverflow)
103 {
104 RenderOverflow overflow(LayoutRect(10, 10, 80, 80), LayoutRect(0, 0, 100, 10 0));
105
106 overflow.addContentsVisualOverflow(LayoutRect(0, 0, 10, 10));
107 EXPECT_EQ(LayoutRect(0, 0, 10, 10), overflow.contentsVisualOverflowRect());
108
109 overflow.addContentsVisualOverflow(LayoutRect(80, 80, 10, 10));
110 EXPECT_EQ(LayoutRect(0, 0, 90, 90), overflow.contentsVisualOverflowRect());
111
112 // Empty contents visual overflow does not affect the overflow rect.
113 overflow.addContentsVisualOverflow(LayoutRect(200, 200, 0, 0));
114 EXPECT_EQ(LayoutRect(0, 0, 90, 90), overflow.contentsVisualOverflowRect());
115
116 EXPECT_EQ(LayoutRect(0, 0, 100, 100), overflow.visualOverflowRect());
117 EXPECT_EQ(LayoutRect(10, 10, 80, 80), overflow.layoutOverflowRect());
118 }
119
120 TEST(RenderOverflowTest, Move)
121 {
122 RenderOverflow overflow(LayoutRect(10, 10, 80, 80), LayoutRect(0, 0, 100, 10 0));
123 overflow.addContentsVisualOverflow(LayoutRect(50, 20, 10, 100));
124
125 overflow.move(500, 0);
126 EXPECT_EQ(LayoutRect(510, 10, 80, 80), overflow.layoutOverflowRect());
127 EXPECT_EQ(LayoutRect(500, 0, 100, 100), overflow.visualOverflowRect());
128 EXPECT_EQ(LayoutRect(550, 20, 10, 100), overflow.contentsVisualOverflowRect( ));
129
130 overflow.move(-500, 500);
131 EXPECT_EQ(LayoutRect(10, 510, 80, 80), overflow.layoutOverflowRect());
132 EXPECT_EQ(LayoutRect(0, 500, 100, 100), overflow.visualOverflowRect());
133 EXPECT_EQ(LayoutRect(50, 520, 10, 100), overflow.contentsVisualOverflowRect( ));
134 }
135
136 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698