summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/core/frame/remote_frame_view.h
blob: a4655607b0650252a46acffc7136e16d3b1b38f3 (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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
// Copyright 2014 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_FRAME_REMOTE_FRAME_VIEW_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_FRAME_REMOTE_FRAME_VIEW_H_

#include "cc/paint/paint_canvas.h"
#include "third_party/blink/public/mojom/frame/lifecycle.mojom-blink-forward.h"
#include "third_party/blink/public/platform/viewport_intersection_state.h"
#include "third_party/blink/renderer/core/dom/document_lifecycle.h"
#include "third_party/blink/renderer/core/frame/frame_view.h"
#include "third_party/blink/renderer/core/layout/intrinsic_sizing_info.h"
#include "third_party/blink/renderer/platform/geometry/int_rect.h"
#include "third_party/blink/renderer/platform/heap/handle.h"

namespace cc {
class PaintCanvas;
}

namespace blink {
class CullRect;
class GraphicsContext;
class LocalFrameView;
class RemoteFrame;

class RemoteFrameView final : public GarbageCollected<RemoteFrameView>,
                              public FrameView {
  USING_GARBAGE_COLLECTED_MIXIN(RemoteFrameView);

 public:
  explicit RemoteFrameView(RemoteFrame*);
  ~RemoteFrameView() override;

  void AttachToLayout() override;
  void DetachFromLayout() override;

  LocalFrameView* ParentFrameView() const override;
  LayoutEmbeddedContent* GetLayoutEmbeddedContent() const override;
  RemoteFrame& GetFrame() const {
    DCHECK(remote_frame_);
    return *remote_frame_;
  }

  void Dispose() override;
  void SetFrameRect(const IntRect&) override;
  void PropagateFrameRects() override;
  // Override to notify remote frame that its viewport size has changed.
  void InvalidateRect(const IntRect&);
  void Paint(GraphicsContext&,
             const GlobalPaintFlags,
             const CullRect&,
             const IntSize& paint_offset = IntSize()) const override;
  void UpdateGeometry() override;
  void Hide() override;
  void Show() override;

  bool UpdateViewportIntersectionsForSubtree(unsigned parent_flags) override;
  void SetNeedsOcclusionTracking(bool);
  bool NeedsOcclusionTracking() const { return needs_occlusion_tracking_; }

  bool GetIntrinsicSizingInfo(IntrinsicSizingInfo&) const override;

  void SetIntrinsicSizeInfo(const IntrinsicSizingInfo& size_info);
  bool HasIntrinsicSizingInfo() const override;

  bool CanThrottleRendering() const override;
  void VisibilityForThrottlingChanged() override;
  void VisibilityChanged(blink::mojom::FrameVisibility visibility) override;

  // Compute the interest rect of this frame in its unscrolled space. This may
  // be used by the OOPIF's compositor to limit the amount of rastered tiles,
  // and reduce the number of paint-ops generated.
  IntRect GetCompositingRect();

  uint32_t Print(const IntRect&, cc::PaintCanvas*) const;

  void Trace(blink::Visitor*) override;

 protected:
  bool NeedsViewportOffset() const override { return true; }
  // This is used to service IntersectionObservers in an OOPIF child document.
  void SetViewportIntersection(
      const ViewportIntersectionState& intersection_state) override;
  void ParentVisibleChanged() override;

 private:
  // This function returns the LocalFrameView associated with the parent frame's
  // local root, or nullptr if the parent frame is not a local frame. For
  // portals, this will return the local root associated with the portal's
  // owner.
  LocalFrameView* ParentLocalRootFrameView() const;

  // The properties and handling of the cycle between RemoteFrame
  // and its RemoteFrameView corresponds to that between LocalFrame
  // and LocalFrameView. Please see the LocalFrameView::frame_ comment for
  // details.
  Member<RemoteFrame> remote_frame_;
  ViewportIntersectionState last_intersection_state_;

  IntrinsicSizingInfo intrinsic_sizing_info_;
  bool has_intrinsic_sizing_info_ = false;
  bool needs_occlusion_tracking_ = false;
  bool needs_frame_rect_propagation_ = false;
};

template <>
struct DowncastTraits<RemoteFrameView> {
  static bool AllowFrom(const EmbeddedContentView& embedded_content_view) {
    return !embedded_content_view.IsLocalFrameView() &&
           !embedded_content_view.IsPluginView();
  }
};

}  // namespace blink

#endif  // THIRD_PARTY_BLINK_RENDERER_CORE_FRAME_REMOTE_FRAME_VIEW_H_