forked from Pissandshittium/pissandshittium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnode_holder.cc
51 lines (40 loc) · 1.25 KB
/
node_holder.cc
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
// Copyright 2019 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 "cc/paint/node_holder.h"
#include "base/no_destructor.h"
namespace cc {
NodeHolder::NodeHolder() : is_empty(true) {}
NodeHolder::NodeHolder(scoped_refptr<TextHolder> holder)
: text_holder(holder), type(Type::kTextHolder), is_empty(false) {}
NodeHolder::NodeHolder(int id) : id(id), type(Type::kID), is_empty(false) {}
NodeHolder::NodeHolder(const NodeHolder& other) {
text_holder = other.text_holder;
id = other.id;
type = other.type;
is_empty = other.is_empty;
}
NodeHolder::~NodeHolder() = default;
// static
const NodeHolder& NodeHolder::EmptyNodeHolder() {
static const base::NoDestructor<NodeHolder> s;
return *s;
}
bool operator==(const NodeHolder& l, const NodeHolder& r) {
if (l.is_empty != r.is_empty) {
return false;
} else if (l.is_empty) {
return true;
} else {
switch (l.type) {
case NodeHolder::Type::kTextHolder:
return l.text_holder == r.text_holder;
case NodeHolder::Type::kID:
return l.id == r.id;
}
}
}
bool operator!=(const NodeHolder& l, const NodeHolder& r) {
return !(l == r);
}
} // namespace cc