OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "web/tests/sim/SimDisplayItemList.h" | 5 #include "web/tests/sim/SimDisplayItemList.h" |
6 | 6 |
7 #include "core/css/parser/CSSParser.h" | 7 #include "core/css/parser/CSSParser.h" |
8 #include "platform/graphics/LoggingCanvas.h" | 8 #include "platform/graphics/LoggingCanvas.h" |
9 #include "platform/graphics/paint/PaintRecord.h" | 9 #include "platform/graphics/paint/PaintRecord.h" |
10 #include "third_party/skia/include/core/SkRect.h" | 10 #include "third_party/skia/include/core/SkRect.h" |
11 | 11 |
12 namespace blink { | 12 namespace blink { |
13 | 13 |
14 SimDisplayItemList::SimDisplayItemList() {} | 14 SimDisplayItemList::SimDisplayItemList() {} |
15 | 15 |
16 void SimDisplayItemList::AppendDrawingItem(const WebRect&, | 16 void SimDisplayItemList::AppendDrawingItem(const WebRect& visual_rect, |
17 sk_sp<const PaintRecord> record) { | 17 sk_sp<const PaintRecord> record, |
18 SkIRect bounds = record->cullRect().roundOut(); | 18 const WebRect& record_bounds) { |
19 SimCanvas canvas(bounds.width(), bounds.height()); | 19 SimCanvas canvas(record_bounds.width, record_bounds.height); |
20 record->playback(&canvas); | 20 record->playback(&canvas); |
21 commands_.Append(canvas.Commands().data(), canvas.Commands().size()); | 21 commands_.Append(canvas.Commands().data(), canvas.Commands().size()); |
22 } | 22 } |
23 | 23 |
24 bool SimDisplayItemList::Contains(SimCanvas::CommandType type, | 24 bool SimDisplayItemList::Contains(SimCanvas::CommandType type, |
25 const String& color_string) const { | 25 const String& color_string) const { |
26 Color color = 0; | 26 Color color = 0; |
27 if (!color_string.IsNull()) | 27 if (!color_string.IsNull()) |
28 CHECK(CSSParser::ParseColor(color, color_string, true)); | 28 CHECK(CSSParser::ParseColor(color, color_string, true)); |
29 for (auto& command : commands_) { | 29 for (auto& command : commands_) { |
30 if (command.type == type && | 30 if (command.type == type && |
31 (color_string.IsNull() || command.color == color.Rgb())) | 31 (color_string.IsNull() || command.color == color.Rgb())) |
32 return true; | 32 return true; |
33 } | 33 } |
34 return false; | 34 return false; |
35 } | 35 } |
36 | 36 |
37 } // namespace blink | 37 } // namespace blink |
OLD | NEW |