Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / Source / web / tests / sim / SimDisplayItemList.cpp
blob1fa83b9d8129ae1a49473c784c96a9d096aae55a
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
3 // found in the LICENSE file.
5 #include "config.h"
6 #include "web/tests/sim/SimDisplayItemList.h"
8 #include "core/css/parser/CSSParser.h"
9 #include "platform/graphics/LoggingCanvas.h"
10 #include "third_party/skia/include/core/SkPicture.h"
11 #include "third_party/skia/include/core/SkRect.h"
13 namespace blink {
15 SimDisplayItemList::SimDisplayItemList()
16 : m_containsText(false)
20 void SimDisplayItemList::appendDrawingItem(const SkPicture* picture)
22 m_containsText |= picture->hasText();
24 SkIRect bounds = picture->cullRect().roundOut();
25 SimCanvas canvas(bounds.width(), bounds.height());
26 picture->playback(&canvas);
27 m_commands.append(canvas.commands().data(), canvas.commands().size());
30 bool SimDisplayItemList::contains(SimCanvas::CommandType type, const String& colorString) const
32 RGBA32 color = 0;
33 if (!colorString.isNull())
34 RELEASE_ASSERT(CSSParser::parseColor(color, colorString, true));
35 for (auto& command : m_commands) {
36 if (command.type == type && (colorString.isNull() || command.color == color))
37 return true;
39 return false;
42 } // namespace blink