blob: 8afe379befd435fe51f04d33f82348a2e6a06ae4 (
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
|
// Copyright 2018 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.
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_NG_CUSTOM_PENDING_LAYOUT_REGISTRY_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_NG_CUSTOM_PENDING_LAYOUT_REGISTRY_H_
#include "third_party/blink/renderer/platform/heap/handle.h"
#include "third_party/blink/renderer/platform/wtf/text/atomic_string.h"
#include "third_party/blink/renderer/platform/wtf/text/atomic_string_hash.h"
namespace blink {
class Node;
// This class keeps a reference to any Node which will need their layout tree
// re-attached when a custom layout is registered. This is primarily owned by
// the LayoutWorklet instance.
class PendingLayoutRegistry : public GarbageCollected<PendingLayoutRegistry> {
public:
PendingLayoutRegistry() = default;
void NotifyLayoutReady(const AtomicString& name);
void AddPendingLayout(const AtomicString& name, Node*);
void Trace(Visitor*);
private:
// This is a map of Nodes which are waiting for a CSSLayoutDefinition to be
// registered. We keep a reference to the Node instead of the LayoutObject as
// Nodes are garbage-collected and we can keep a weak reference to it. (With
// a LayoutObject we'd have to respect the life-cycle of it which would be
// error-prone and complicated).
//
// NOTE: By the time a layout has been registered, the node may have a
// different "display" value.
using PendingSet = HeapHashSet<WeakMember<Node>>;
using PendingLayoutMap = HeapHashMap<AtomicString, Member<PendingSet>>;
PendingLayoutMap pending_layouts_;
DISALLOW_COPY_AND_ASSIGN(PendingLayoutRegistry);
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_NG_CUSTOM_PENDING_LAYOUT_REGISTRY_H_
|