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 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
|
// 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_FRAME_OWNER_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_FRAME_FRAME_OWNER_H_
#include "third_party/blink/public/mojom/frame/color_scheme.mojom-shared.h"
#include "third_party/blink/public/common/frame/frame_policy.h"
#include "third_party/blink/public/mojom/scroll/scrollbar_mode.mojom-blink.h"
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/platform/heap/handle.h"
#include "third_party/blink/renderer/platform/wtf/text/atomic_string.h"
namespace blink {
class Frame;
class FrameSwapScope;
class ResourceTimingInfo;
// Oilpan: all FrameOwner instances are GCed objects. FrameOwner additionally
// derives from GarbageCollectedMixin so that Member<FrameOwner> references can
// be kept (e.g., Frame::m_owner.)
class CORE_EXPORT FrameOwner : public GarbageCollectedMixin {
friend class FrameSwapScope;
public:
virtual ~FrameOwner() = default;
void Trace(Visitor* visitor) const override {}
virtual bool IsLocal() const = 0;
virtual bool IsRemote() const = 0;
virtual bool IsPlugin() const { return false; }
virtual Frame* ContentFrame() const = 0;
virtual void SetContentFrame(Frame&) = 0;
virtual void ClearContentFrame() = 0;
virtual const FramePolicy& GetFramePolicy() const = 0;
// Note: there is a subtle ordering dependency here: if a page load needs to
// report resource timing information, it *must* do so before calling
// DispatchLoad().
virtual void AddResourceTiming(const ResourceTimingInfo&) = 0;
virtual void DispatchLoad() = 0;
// On load failure, a frame can ask its owner to render fallback content
// which replaces the frame contents.
virtual bool CanRenderFallbackContent() const = 0;
// The argument refers to the frame with the failed navigation. Note that this
// is not always the ContentFrame() for this owner; this argument is needed to
// support showing fallback using DOM of parent frame in a separate process.
// The use case is limited to RemoteFrameOwner when the corresponding local
// FrameOwner in parent process is an <object>. In such cases the frame with
// failed navigation could be provisional (cross-site navigations).
virtual void RenderFallbackContent(Frame*) = 0;
// The intrinsic dimensions of the embedded object changed. This is only
// relevant for SVG documents that are embedded via <object> or <embed>.
virtual void IntrinsicSizingInfoChanged() = 0;
// Indicates that a child frame requires its parent frame to track whether the
// child frame is occluded or has visual effects applied.
virtual void SetNeedsOcclusionTracking(bool) = 0;
// Returns the 'name' content attribute value of the browsing context
// container.
// https://html.spec.whatwg.org/C/#browsing-context-container
virtual AtomicString BrowsingContextContainerName() const = 0;
virtual mojom::blink::ScrollbarMode ScrollbarMode() const = 0;
virtual int MarginWidth() const = 0;
virtual int MarginHeight() const = 0;
virtual bool AllowFullscreen() const = 0;
virtual bool AllowPaymentRequest() const = 0;
virtual bool IsDisplayNone() const = 0;
virtual mojom::blink::ColorScheme GetColorScheme() const = 0;
virtual AtomicString RequiredCsp() const = 0;
// Returns whether or not children of the owned frame should be lazily loaded.
virtual bool ShouldLazyLoadChildren() const = 0;
protected:
virtual void FrameOwnerPropertiesChanged() {}
virtual void CSPAttributeChanged() {}
private:
virtual void SetIsSwappingFrames(bool) {}
};
// The purpose of this class is to suppress the propagation of frame owner
// properties while a frame is being replaced. In particular, it prevents the
// erroneous propagation of is_display_none=true, which would otherwise happen
// when the old frame is detached prior to attaching the new frame. This class
// will postpone the propagation until the properties are in their new stable
// state.
//
// It is only intended to handle cases where one frame is detached and a new
// frame immediately attached. For normal frame unload/teardown, we don't need
// to suppress the propagation.
class FrameSwapScope {
STACK_ALLOCATED();
public:
FrameSwapScope(FrameOwner* frame_owner) : frame_owner_(frame_owner) {
if (frame_owner)
frame_owner->SetIsSwappingFrames(true);
}
~FrameSwapScope() {
if (frame_owner_) {
frame_owner_->SetIsSwappingFrames(false);
frame_owner_->FrameOwnerPropertiesChanged();
frame_owner_->CSPAttributeChanged();
}
}
private:
FrameOwner* frame_owner_;
};
// TODO(dcheng): This class is an internal implementation detail of provisional
// frames. Move this into WebLocalFrameImpl.cpp and remove existing dependencies
// on it.
class CORE_EXPORT DummyFrameOwner final
: public GarbageCollected<DummyFrameOwner>,
public FrameOwner {
public:
void Trace(Visitor* visitor) const override { FrameOwner::Trace(visitor); }
// FrameOwner overrides:
Frame* ContentFrame() const override { return nullptr; }
void SetContentFrame(Frame&) override {}
void ClearContentFrame() override {}
const FramePolicy& GetFramePolicy() const override {
DEFINE_STATIC_LOCAL(FramePolicy, frame_policy, ());
return frame_policy;
}
void AddResourceTiming(const ResourceTimingInfo&) override {}
void DispatchLoad() override {}
bool CanRenderFallbackContent() const override { return false; }
void RenderFallbackContent(Frame*) override {}
void IntrinsicSizingInfoChanged() override {}
void SetNeedsOcclusionTracking(bool) override {}
AtomicString BrowsingContextContainerName() const override {
return AtomicString();
}
mojom::blink::ScrollbarMode ScrollbarMode() const override {
return mojom::blink::ScrollbarMode::kAuto;
}
int MarginWidth() const override { return -1; }
int MarginHeight() const override { return -1; }
bool AllowFullscreen() const override { return false; }
bool AllowPaymentRequest() const override { return false; }
bool IsDisplayNone() const override { return false; }
mojom::blink::ColorScheme GetColorScheme() const override {
return mojom::blink::ColorScheme::kLight;
}
AtomicString RequiredCsp() const override { return g_null_atom; }
bool ShouldLazyLoadChildren() const override { return false; }
private:
// Intentionally private to prevent redundant checks when the type is
// already DummyFrameOwner.
bool IsLocal() const override { return false; }
bool IsRemote() const override { return false; }
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_FRAME_FRAME_OWNER_H_
|