// Copyright 2022 The Chromium Authors // 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_ANNOTATION_ANNOTATION_AGENT_IMPL_H_ #define THIRD_PARTY_BLINK_RENDERER_CORE_ANNOTATION_ANNOTATION_AGENT_IMPL_H_ #include "base/types/pass_key.h" #include "third_party/blink/public/mojom/annotation/annotation.mojom-blink.h" #include "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/core/layout/geometry/physical_rect.h" #include "third_party/blink/renderer/platform/heap/garbage_collected.h" #include "third_party/blink/renderer/platform/heap/member.h" #include "third_party/blink/renderer/platform/mojo/heap_mojo_receiver.h" #include "third_party/blink/renderer/platform/mojo/heap_mojo_remote.h" #include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" namespace blink { class AnnotationAgentContainerImpl; class AnnotationAgentImplTest; class AnnotationSelector; class Document; class RangeInFlatTree; // This class represents an instantiation of an annotation in a Document. It is // always owned and stored in an AnnotationAgentContainerImpl. Removing it from // the container will remove any visible effects on content and disconnect mojo // bindings. Once removed, an agent cannot be reused. // // AnnotationAgentImpl allows its client to provide a selector that it uses to // "attach" to a particular Range in the Document. Once attached, the // annotation adds a visible marker to the content and enables the client to // scroll the attached content into view. An agent is considered attached if it // has found a Range and that Range is valid and uncollapsed. The range may // become invalid in response to changes in a Document's DOM. // TODO(bokan): Changes in the DOM affecting an annotation should be signaled // via the AnnotationAgentHost interface. // // This class is the renderer end of an annotation. It can be instantiated // directly from Blink as well in which case it need not be bound to a host on // the browser side. If bound to a corresponding AnnotationAgentHost in the // browser, it will notify the host of relevant events (e.g. attachment // succeeded/failed) and self-remove itself from the container if the mojo // bindings become disconnected (i.e. if the browser closes the connection, the // AnnotationAgentImpl will be removed). class CORE_EXPORT AnnotationAgentImpl final : public GarbageCollected<AnnotationAgentImpl>, public mojom::blink::AnnotationAgent { … }; } // namespace blink #endif // THIRD_PARTY_BLINK_RENDERER_CORE_ANNOTATION_ANNOTATION_AGENT_IMPL_H_