Index: Source/web/tests/sim/SimDisplayItemList.cpp |
diff --git a/Source/web/tests/sim/SimDisplayItemList.cpp b/Source/web/tests/sim/SimDisplayItemList.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..1fa83b9d8129ae1a49473c784c96a9d096aae55a |
--- /dev/null |
+++ b/Source/web/tests/sim/SimDisplayItemList.cpp |
@@ -0,0 +1,42 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "config.h" |
+#include "web/tests/sim/SimDisplayItemList.h" |
+ |
+#include "core/css/parser/CSSParser.h" |
+#include "platform/graphics/LoggingCanvas.h" |
+#include "third_party/skia/include/core/SkPicture.h" |
+#include "third_party/skia/include/core/SkRect.h" |
+ |
+namespace blink { |
+ |
+SimDisplayItemList::SimDisplayItemList() |
+ : m_containsText(false) |
+{ |
+} |
+ |
+void SimDisplayItemList::appendDrawingItem(const SkPicture* picture) |
+{ |
+ m_containsText |= picture->hasText(); |
+ |
+ SkIRect bounds = picture->cullRect().roundOut(); |
+ SimCanvas canvas(bounds.width(), bounds.height()); |
+ picture->playback(&canvas); |
+ m_commands.append(canvas.commands().data(), canvas.commands().size()); |
+} |
+ |
+bool SimDisplayItemList::contains(SimCanvas::CommandType type, const String& colorString) const |
+{ |
+ RGBA32 color = 0; |
+ if (!colorString.isNull()) |
+ RELEASE_ASSERT(CSSParser::parseColor(color, colorString, true)); |
+ for (auto& command : m_commands) { |
+ if (command.type == type && (colorString.isNull() || command.color == color)) |
+ return true; |
+ } |
+ return false; |
+} |
+ |
+} // namespace blink |