blob: 8d9763a1e33f0813c9c8582b496a1800c694d061 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
// Copyright 2020 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 "components/query_tiles/tile.h"
#include <utility>
namespace query_tiles {
namespace {
void DeepCopyTiles(const Tile& input, Tile* out) {
DCHECK(out);
out->id = input.id;
out->display_text = input.display_text;
out->query_text = input.query_text;
out->accessibility_text = input.accessibility_text;
out->image_metadatas = input.image_metadatas;
out->search_params = input.search_params;
out->sub_tiles.clear();
for (const auto& child : input.sub_tiles) {
auto entry = std::make_unique<Tile>();
DeepCopyTiles(*child.get(), entry.get());
out->sub_tiles.emplace_back(std::move(entry));
}
}
} // namespace
ImageMetadata::ImageMetadata() = default;
ImageMetadata::ImageMetadata(const GURL& url) : url(url) {}
ImageMetadata::~ImageMetadata() = default;
ImageMetadata::ImageMetadata(const ImageMetadata& other) = default;
bool ImageMetadata::operator==(const ImageMetadata& other) const {
return url == other.url;
}
bool Tile::operator==(const Tile& other) const {
return id == other.id && display_text == other.display_text &&
query_text == other.query_text &&
accessibility_text == other.accessibility_text &&
image_metadatas.size() == other.image_metadatas.size() &&
sub_tiles.size() == other.sub_tiles.size() &&
search_params == other.search_params;
}
bool Tile::operator!=(const Tile& other) const {
return !(*this == other);
}
Tile::Tile(const Tile& other) {
DeepCopyTiles(other, this);
}
Tile::Tile() = default;
Tile::Tile(Tile&& other) noexcept = default;
Tile::~Tile() = default;
Tile& Tile::operator=(const Tile& other) {
DeepCopyTiles(other, this);
return *this;
}
Tile& Tile::operator=(Tile&& other) noexcept = default;
} // namespace query_tiles
|