Commit e9592f40 authored by joelhockey's avatar joelhockey Committed by Commit bot

Move methods from FrameViewBase to FrameView.

Remove FrameViewBase.cpp file.
This CL is in preparation to move core/paint/ScrollbarManager
to platform/scroll and use it as replacement for FrameViewBase.

BUG=637460

Review-Url: https://codereview.chromium.org/2843693003
Cr-Commit-Position: refs/heads/master@{#467303}
parent 333e43ab
...@@ -168,8 +168,10 @@ static const double kResourcePriorityUpdateDelayAfterScroll = 0.250; ...@@ -168,8 +168,10 @@ static const double kResourcePriorityUpdateDelayAfterScroll = 0.250;
static bool g_initial_track_all_paint_invalidations = false; static bool g_initial_track_all_paint_invalidations = false;
FrameView::FrameView(LocalFrame& frame) FrameView::FrameView(LocalFrame& frame, IntRect frame_rect)
: frame_(frame), : frame_(frame),
frame_rect_(frame_rect),
parent_(nullptr),
display_mode_(kWebDisplayModeBrowser), display_mode_(kWebDisplayModeBrowser),
can_have_scrollbars_(true), can_have_scrollbars_(true),
has_pending_layout_(false), has_pending_layout_(false),
...@@ -216,14 +218,13 @@ FrameView::FrameView(LocalFrame& frame) ...@@ -216,14 +218,13 @@ FrameView::FrameView(LocalFrame& frame)
} }
FrameView* FrameView::Create(LocalFrame& frame) { FrameView* FrameView::Create(LocalFrame& frame) {
FrameView* view = new FrameView(frame); FrameView* view = new FrameView(frame, IntRect());
view->Show(); view->Show();
return view; return view;
} }
FrameView* FrameView::Create(LocalFrame& frame, const IntSize& initial_size) { FrameView* FrameView::Create(LocalFrame& frame, const IntSize& initial_size) {
FrameView* view = new FrameView(frame); FrameView* view = new FrameView(frame, IntRect(IntPoint(), initial_size));
view->FrameViewBase::SetFrameRect(IntRect(view->Location(), initial_size));
view->SetLayoutSizeInternal(initial_size); view->SetLayoutSizeInternal(initial_size);
view->Show(); view->Show();
...@@ -236,6 +237,7 @@ FrameView::~FrameView() { ...@@ -236,6 +237,7 @@ FrameView::~FrameView() {
DEFINE_TRACE(FrameView) { DEFINE_TRACE(FrameView) {
visitor->Trace(frame_); visitor->Trace(frame_);
visitor->Trace(parent_);
visitor->Trace(fragment_anchor_); visitor->Trace(fragment_anchor_);
visitor->Trace(scrollable_areas_); visitor->Trace(scrollable_areas_);
visitor->Trace(animating_scrollable_areas_); visitor->Trace(animating_scrollable_areas_);
...@@ -544,16 +546,15 @@ void FrameView::InvalidateRect(const IntRect& rect) { ...@@ -544,16 +546,15 @@ void FrameView::InvalidateRect(const IntRect& rect) {
layout_item.InvalidatePaintRectangle(LayoutRect(paint_invalidation_rect)); layout_item.InvalidatePaintRectangle(LayoutRect(paint_invalidation_rect));
} }
void FrameView::SetFrameRect(const IntRect& new_rect) { void FrameView::SetFrameRect(const IntRect& frame_rect) {
IntRect old_rect = FrameRect(); if (frame_rect == frame_rect_)
if (new_rect == old_rect)
return; return;
FrameViewBase::SetFrameRect(new_rect); const bool width_changed = frame_rect_.Width() != frame_rect.Width();
const bool height_changed = frame_rect_.Height() != frame_rect.Height();
frame_rect_ = frame_rect;
const bool frame_size_changed = old_rect.Size() != new_rect.Size(); needs_scrollbars_update_ = width_changed || height_changed;
needs_scrollbars_update_ = frame_size_changed;
// TODO(wjmaclean): find out why scrollbars fail to resize for complex // TODO(wjmaclean): find out why scrollbars fail to resize for complex
// subframes after changing the zoom level. For now always calling // subframes after changing the zoom level. For now always calling
// updateScrollbarsIfNeeded() here fixes the issue, but it would be good to // updateScrollbarsIfNeeded() here fixes the issue, but it would be good to
...@@ -574,9 +575,8 @@ void FrameView::SetFrameRect(const IntRect& new_rect) { ...@@ -574,9 +575,8 @@ void FrameView::SetFrameRect(const IntRect& new_rect) {
if (auto layout_view_item = this->GetLayoutViewItem()) if (auto layout_view_item = this->GetLayoutViewItem())
layout_view_item.SetMayNeedPaintInvalidation(); layout_view_item.SetMayNeedPaintInvalidation();
if (frame_size_changed) { if (width_changed || height_changed) {
ViewportSizeChanged(new_rect.Width() != old_rect.Width(), ViewportSizeChanged(width_changed, height_changed);
new_rect.Height() != old_rect.Height());
if (frame_->IsMainFrame()) if (frame_->IsMainFrame())
frame_->GetPage()->GetVisualViewport().MainFrameDidChangeSize(); frame_->GetPage()->GetVisualViewport().MainFrameDidChangeSize();
...@@ -3656,7 +3656,7 @@ IntPoint FrameView::ConvertSelfToChild(const FrameViewBase* child, ...@@ -3656,7 +3656,7 @@ IntPoint FrameView::ConvertSelfToChild(const FrameViewBase* child,
IntRect FrameView::ConvertToContainingFrameViewBase( IntRect FrameView::ConvertToContainingFrameViewBase(
const IntRect& local_rect) const { const IntRect& local_rect) const {
if (const FrameView* parent = ToFrameView(Parent())) { if (parent_) {
// Get our layoutObject in the parent view // Get our layoutObject in the parent view
LayoutPartItem layout_item = frame_->OwnerLayoutItem(); LayoutPartItem layout_item = frame_->OwnerLayoutItem();
if (layout_item.IsNull()) if (layout_item.IsNull())
...@@ -3666,7 +3666,7 @@ IntRect FrameView::ConvertToContainingFrameViewBase( ...@@ -3666,7 +3666,7 @@ IntRect FrameView::ConvertToContainingFrameViewBase(
// Add borders and padding?? // Add borders and padding??
rect.Move((layout_item.BorderLeft() + layout_item.PaddingLeft()).ToInt(), rect.Move((layout_item.BorderLeft() + layout_item.PaddingLeft()).ToInt(),
(layout_item.BorderTop() + layout_item.PaddingTop()).ToInt()); (layout_item.BorderTop() + layout_item.PaddingTop()).ToInt());
return parent->ConvertFromLayoutItem(layout_item, rect); return parent_->ConvertFromLayoutItem(layout_item, rect);
} }
return local_rect; return local_rect;
...@@ -3674,10 +3674,10 @@ IntRect FrameView::ConvertToContainingFrameViewBase( ...@@ -3674,10 +3674,10 @@ IntRect FrameView::ConvertToContainingFrameViewBase(
IntRect FrameView::ConvertFromContainingFrameViewBase( IntRect FrameView::ConvertFromContainingFrameViewBase(
const IntRect& parent_rect) const { const IntRect& parent_rect) const {
if (const FrameView* parent = ToFrameView(Parent())) { if (parent_) {
IntRect local_rect = parent_rect; IntRect local_rect = parent_rect;
local_rect.SetLocation( local_rect.SetLocation(
parent->ConvertSelfToChild(this, local_rect.Location())); parent_->ConvertSelfToChild(this, local_rect.Location()));
return local_rect; return local_rect;
} }
...@@ -3686,7 +3686,7 @@ IntRect FrameView::ConvertFromContainingFrameViewBase( ...@@ -3686,7 +3686,7 @@ IntRect FrameView::ConvertFromContainingFrameViewBase(
IntPoint FrameView::ConvertToContainingFrameViewBase( IntPoint FrameView::ConvertToContainingFrameViewBase(
const IntPoint& local_point) const { const IntPoint& local_point) const {
if (const FrameView* parent = ToFrameView(Parent())) { if (parent_) {
// Get our layoutObject in the parent view // Get our layoutObject in the parent view
LayoutPartItem layout_item = frame_->OwnerLayoutItem(); LayoutPartItem layout_item = frame_->OwnerLayoutItem();
if (layout_item.IsNull()) if (layout_item.IsNull())
...@@ -3697,7 +3697,7 @@ IntPoint FrameView::ConvertToContainingFrameViewBase( ...@@ -3697,7 +3697,7 @@ IntPoint FrameView::ConvertToContainingFrameViewBase(
// Add borders and padding // Add borders and padding
point.Move((layout_item.BorderLeft() + layout_item.PaddingLeft()).ToInt(), point.Move((layout_item.BorderLeft() + layout_item.PaddingLeft()).ToInt(),
(layout_item.BorderTop() + layout_item.PaddingTop()).ToInt()); (layout_item.BorderTop() + layout_item.PaddingTop()).ToInt());
return parent->ConvertFromLayoutItem(layout_item, point); return parent_->ConvertFromLayoutItem(layout_item, point);
} }
return local_point; return local_point;
...@@ -3705,13 +3705,13 @@ IntPoint FrameView::ConvertToContainingFrameViewBase( ...@@ -3705,13 +3705,13 @@ IntPoint FrameView::ConvertToContainingFrameViewBase(
IntPoint FrameView::ConvertFromContainingFrameViewBase( IntPoint FrameView::ConvertFromContainingFrameViewBase(
const IntPoint& parent_point) const { const IntPoint& parent_point) const {
if (const FrameView* parent = ToFrameView(Parent())) { if (parent_) {
// Get our layoutObject in the parent view // Get our layoutObject in the parent view
LayoutPartItem layout_item = frame_->OwnerLayoutItem(); LayoutPartItem layout_item = frame_->OwnerLayoutItem();
if (layout_item.IsNull()) if (layout_item.IsNull())
return parent_point; return parent_point;
IntPoint point = parent->ConvertToLayoutItem(layout_item, parent_point); IntPoint point = parent_->ConvertToLayoutItem(layout_item, parent_point);
// Subtract borders and padding // Subtract borders and padding
point.Move((-layout_item.BorderLeft() - layout_item.PaddingLeft()).ToInt(), point.Move((-layout_item.BorderLeft() - layout_item.PaddingLeft()).ToInt(),
(-layout_item.BorderTop() - layout_item.PaddingTop()).ToInt()); (-layout_item.BorderTop() - layout_item.PaddingTop()).ToInt());
...@@ -3841,11 +3841,24 @@ void FrameView::RemoveAnimatingScrollableArea(ScrollableArea* scrollable_area) { ...@@ -3841,11 +3841,24 @@ void FrameView::RemoveAnimatingScrollableArea(ScrollableArea* scrollable_area) {
animating_scrollable_areas_->erase(scrollable_area); animating_scrollable_areas_->erase(scrollable_area);
} }
void FrameView::SetParent(FrameViewBase* parent) { FrameView* FrameView::Root() const {
if (parent == Parent()) const FrameView* top = this;
while (top->Parent())
top = ToFrameView(top->Parent());
return const_cast<FrameView*>(top);
}
void FrameView::SetParent(FrameViewBase* parent_frame_view_base) {
FrameView* parent = ToFrameView(parent_frame_view_base);
if (parent == parent_)
return; return;
FrameViewBase::SetParent(parent); DCHECK(!parent || !parent_);
if (!parent || !parent->IsVisible())
SetParentVisible(false);
parent_ = parent;
if (parent && parent->IsVisible())
SetParentVisible(true);
UpdateParentScrollableAreaSet(); UpdateParentScrollableAreaSet();
SetupRenderThrottling(); SetupRenderThrottling();
...@@ -3981,7 +3994,6 @@ IntSize FrameView::MaximumScrollOffsetInt() const { ...@@ -3981,7 +3994,6 @@ IntSize FrameView::MaximumScrollOffsetInt() const {
void FrameView::AddChild(FrameViewBase* child) { void FrameView::AddChild(FrameViewBase* child) {
DCHECK(child != this && !child->Parent()); DCHECK(child != this && !child->Parent());
DCHECK(!child->IsPluginView());
child->SetParent(this); child->SetParent(this);
children_.insert(child); children_.insert(child);
} }
...@@ -4735,17 +4747,17 @@ bool FrameView::ScrollbarCornerPresent() const { ...@@ -4735,17 +4747,17 @@ bool FrameView::ScrollbarCornerPresent() const {
} }
IntRect FrameView::ConvertToRootFrame(const IntRect& local_rect) const { IntRect FrameView::ConvertToRootFrame(const IntRect& local_rect) const {
if (const FrameView* parent = ToFrameView(Parent())) { if (parent_) {
IntRect parent_rect = ConvertToContainingFrameViewBase(local_rect); IntRect parent_rect = ConvertToContainingFrameViewBase(local_rect);
return parent->ConvertToRootFrame(parent_rect); return parent_->ConvertToRootFrame(parent_rect);
} }
return local_rect; return local_rect;
} }
IntPoint FrameView::ConvertToRootFrame(const IntPoint& local_point) const { IntPoint FrameView::ConvertToRootFrame(const IntPoint& local_point) const {
if (const FrameView* parent = ToFrameView(Parent())) { if (parent_) {
IntPoint parent_point = ConvertToContainingFrameViewBase(local_point); IntPoint parent_point = ConvertToContainingFrameViewBase(local_point);
return parent->ConvertToRootFrame(parent_point); return parent_->ConvertToRootFrame(parent_point);
} }
return local_point; return local_point;
} }
...@@ -4774,7 +4786,7 @@ void FrameView::SetParentVisible(bool visible) { ...@@ -4774,7 +4786,7 @@ void FrameView::SetParentVisible(bool visible) {
// and potentially child frame views. // and potentially child frame views.
SetNeedsCompositingUpdate(GetLayoutViewItem(), kCompositingUpdateRebuildTree); SetNeedsCompositingUpdate(GetLayoutViewItem(), kCompositingUpdateRebuildTree);
FrameViewBase::SetParentVisible(visible); parent_visible_ = visible;
if (!IsSelfVisible()) if (!IsSelfVisible())
return; return;
......
...@@ -102,7 +102,8 @@ struct CompositedSelection; ...@@ -102,7 +102,8 @@ struct CompositedSelection;
typedef unsigned long long DOMTimeStamp; typedef unsigned long long DOMTimeStamp;
class CORE_EXPORT FrameView final class CORE_EXPORT FrameView final
: public FrameViewBase, : public GarbageCollectedFinalized<FrameView>,
public FrameViewBase,
public FrameOrPlugin, public FrameOrPlugin,
public PaintInvalidationCapableScrollableArea { public PaintInvalidationCapableScrollableArea {
USING_GARBAGE_COLLECTED_MIXIN(FrameView); USING_GARBAGE_COLLECTED_MIXIN(FrameView);
...@@ -120,9 +121,17 @@ class CORE_EXPORT FrameView final ...@@ -120,9 +121,17 @@ class CORE_EXPORT FrameView final
void Invalidate() { InvalidateRect(IntRect(0, 0, Width(), Height())); } void Invalidate() { InvalidateRect(IntRect(0, 0, Width(), Height())); }
void InvalidateRect(const IntRect&); void InvalidateRect(const IntRect&);
void SetFrameRect(const IntRect&) override; void SetFrameRect(const IntRect&) override;
const IntRect& FrameRect() const override { const IntRect& FrameRect() const override { return frame_rect_; }
return FrameViewBase::FrameRect(); int X() const { return frame_rect_.X(); }
int Y() const { return frame_rect_.Y(); }
int Width() const { return frame_rect_.Width(); }
int Height() const { return frame_rect_.Height(); }
IntSize Size() const { return frame_rect_.Size(); }
IntPoint Location() const override { return frame_rect_.Location(); }
void Resize(int width, int height) {
SetFrameRect(IntRect(frame_rect_.X(), frame_rect_.Y(), width, height));
} }
void Resize(const IntSize& size) { SetFrameRect(IntRect(Location(), size)); }
LocalFrame& GetFrame() const { LocalFrame& GetFrame() const {
ASSERT(frame_); ASSERT(frame_);
...@@ -474,7 +483,20 @@ class CORE_EXPORT FrameView final ...@@ -474,7 +483,20 @@ class CORE_EXPORT FrameView final
typedef HeapHashSet<Member<Scrollbar>> ScrollbarsSet; typedef HeapHashSet<Member<Scrollbar>> ScrollbarsSet;
// Functions for child manipulation and inspection. // Functions for child manipulation and inspection.
bool IsSelfVisible() const {
return self_visible_;
} // Whether or not we have been explicitly marked as visible or not.
bool IsParentVisible() const {
return parent_visible_;
} // Whether or not our parent is visible.
bool IsVisible() const {
return self_visible_ && parent_visible_;
} // Whether or not we are actually visible.
void SetParentVisible(bool);
void SetSelfVisible(bool v) { self_visible_ = v; }
void SetParent(FrameViewBase*) override; void SetParent(FrameViewBase*) override;
FrameViewBase* Parent() const override { return parent_; }
FrameView* Root() const;
void RemoveChild(FrameViewBase*); void RemoveChild(FrameViewBase*);
void AddChild(FrameViewBase*); void AddChild(FrameViewBase*);
const ChildrenSet* Children() const { return &children_; } const ChildrenSet* Children() const { return &children_; }
...@@ -640,11 +662,8 @@ class CORE_EXPORT FrameView final ...@@ -640,11 +662,8 @@ class CORE_EXPORT FrameView final
const GlobalPaintFlags, const GlobalPaintFlags,
const IntRect& damage_rect) const; const IntRect& damage_rect) const;
// FrameViewBase overrides to ensure that our children's visibility status is
// kept up to date when we get shown and hidden.
void Show() override; void Show() override;
void Hide() override; void Hide() override;
void SetParentVisible(bool) override;
bool IsPointInScrollbarCorner(const IntPoint&); bool IsPointInScrollbarCorner(const IntPoint&);
bool ScrollbarCornerPresent() const; bool ScrollbarCornerPresent() const;
...@@ -875,7 +894,7 @@ class CORE_EXPORT FrameView final ...@@ -875,7 +894,7 @@ class CORE_EXPORT FrameView final
void InvalidateTreeIfNeeded(const PaintInvalidationState&); void InvalidateTreeIfNeeded(const PaintInvalidationState&);
private: private:
explicit FrameView(LocalFrame&); explicit FrameView(LocalFrame&, IntRect);
class ScrollbarManager : public blink::ScrollbarManager { class ScrollbarManager : public blink::ScrollbarManager {
DISALLOW_NEW(); DISALLOW_NEW();
...@@ -1054,6 +1073,11 @@ class CORE_EXPORT FrameView final ...@@ -1054,6 +1073,11 @@ class CORE_EXPORT FrameView final
Member<LocalFrame> frame_; Member<LocalFrame> frame_;
IntRect frame_rect_;
Member<FrameView> parent_;
bool self_visible_;
bool parent_visible_;
WebDisplayMode display_mode_; WebDisplayMode display_mode_;
DisplayShape display_shape_; DisplayShape display_shape_;
......
...@@ -22,8 +22,17 @@ RemoteFrameView::RemoteFrameView(RemoteFrame* remote_frame) ...@@ -22,8 +22,17 @@ RemoteFrameView::RemoteFrameView(RemoteFrame* remote_frame)
RemoteFrameView::~RemoteFrameView() {} RemoteFrameView::~RemoteFrameView() {}
void RemoteFrameView::SetParent(FrameViewBase* parent) { void RemoteFrameView::SetParent(FrameViewBase* parent_frame_view_base) {
FrameViewBase::SetParent(parent); FrameView* parent = ToFrameView(parent_frame_view_base);
if (parent == parent_)
return;
DCHECK(!parent || !parent_);
if (!parent || !parent->IsVisible())
SetParentVisible(false);
parent_ = parent;
if (parent && parent->IsVisible())
SetParentVisible(true);
FrameRectsChanged(); FrameRectsChanged();
} }
...@@ -48,7 +57,7 @@ void RemoteFrameView::UpdateRemoteViewportIntersection() { ...@@ -48,7 +57,7 @@ void RemoteFrameView::UpdateRemoteViewportIntersection() {
// scrollable div. Passing nullptr as an argument to // scrollable div. Passing nullptr as an argument to
// mapToVisualRectInAncestorSpace causes it to be clipped to the viewport, // mapToVisualRectInAncestorSpace causes it to be clipped to the viewport,
// even if there are RemoteFrame ancestors in the frame tree. // even if there are RemoteFrame ancestors in the frame tree.
LayoutRect rect(0, 0, FrameRect().Width(), FrameRect().Height()); LayoutRect rect(0, 0, frame_rect_.Width(), frame_rect_.Height());
rect.Move(remote_frame_->OwnerLayoutObject()->ContentBoxOffset()); rect.Move(remote_frame_->OwnerLayoutObject()->ContentBoxOffset());
if (!remote_frame_->OwnerLayoutObject()->MapToVisualRectInAncestorSpace( if (!remote_frame_->OwnerLayoutObject()->MapToVisualRectInAncestorSpace(
nullptr, rect)) nullptr, rect))
...@@ -74,7 +83,6 @@ void RemoteFrameView::Dispose() { ...@@ -74,7 +83,6 @@ void RemoteFrameView::Dispose() {
// RemoteFrameView is disconnected before detachment. // RemoteFrameView is disconnected before detachment.
if (owner_element && owner_element->OwnedWidget() == this) if (owner_element && owner_element->OwnedWidget() == this)
owner_element->SetWidget(nullptr); owner_element->SetWidget(nullptr);
FrameViewBase::Dispose();
} }
void RemoteFrameView::InvalidateRect(const IntRect& rect) { void RemoteFrameView::InvalidateRect(const IntRect& rect) {
...@@ -88,14 +96,11 @@ void RemoteFrameView::InvalidateRect(const IntRect& rect) { ...@@ -88,14 +96,11 @@ void RemoteFrameView::InvalidateRect(const IntRect& rect) {
layout_item.InvalidatePaintRectangle(repaint_rect); layout_item.InvalidatePaintRectangle(repaint_rect);
} }
void RemoteFrameView::SetFrameRect(const IntRect& new_rect) { void RemoteFrameView::SetFrameRect(const IntRect& frame_rect) {
IntRect old_rect = FrameRect(); if (frame_rect == frame_rect_)
if (new_rect == old_rect)
return; return;
FrameViewBase::SetFrameRect(new_rect); frame_rect_ = frame_rect;
FrameRectsChanged(); FrameRectsChanged();
} }
...@@ -103,36 +108,33 @@ void RemoteFrameView::FrameRectsChanged() { ...@@ -103,36 +108,33 @@ void RemoteFrameView::FrameRectsChanged() {
// Update the rect to reflect the position of the frame relative to the // Update the rect to reflect the position of the frame relative to the
// containing local frame root. The position of the local root within // containing local frame root. The position of the local root within
// any remote frames, if any, is accounted for by the embedder. // any remote frames, if any, is accounted for by the embedder.
IntRect new_rect = FrameRect(); IntRect new_rect = frame_rect_;
if (const FrameView* parent = ToFrameView(Parent())) if (parent_)
new_rect = parent->ConvertToRootFrame(parent->ContentsToFrame(new_rect)); new_rect = parent_->ConvertToRootFrame(parent_->ContentsToFrame(new_rect));
remote_frame_->Client()->FrameRectsChanged(new_rect); remote_frame_->Client()->FrameRectsChanged(new_rect);
UpdateRemoteViewportIntersection(); UpdateRemoteViewportIntersection();
} }
void RemoteFrameView::Hide() { void RemoteFrameView::Hide() {
SetSelfVisible(false); self_visible_ = false;
remote_frame_->Client()->VisibilityChanged(false); remote_frame_->Client()->VisibilityChanged(false);
} }
void RemoteFrameView::Show() { void RemoteFrameView::Show() {
SetSelfVisible(true); self_visible_ = true;
remote_frame_->Client()->VisibilityChanged(true); remote_frame_->Client()->VisibilityChanged(true);
} }
void RemoteFrameView::SetParentVisible(bool visible) { void RemoteFrameView::SetParentVisible(bool visible) {
if (IsParentVisible() == visible) if (parent_visible_ == visible)
return; return;
FrameViewBase::SetParentVisible(visible); parent_visible_ = visible;
if (!IsSelfVisible()) if (!self_visible_)
return; return;
remote_frame_->Client()->VisibilityChanged(IsVisible()); remote_frame_->Client()->VisibilityChanged(self_visible_ && parent_visible_);
} }
IntRect RemoteFrameView::ConvertFromContainingFrameViewBase( IntRect RemoteFrameView::ConvertFromContainingFrameViewBase(
...@@ -149,7 +151,7 @@ IntRect RemoteFrameView::ConvertFromContainingFrameViewBase( ...@@ -149,7 +151,7 @@ IntRect RemoteFrameView::ConvertFromContainingFrameViewBase(
DEFINE_TRACE(RemoteFrameView) { DEFINE_TRACE(RemoteFrameView) {
visitor->Trace(remote_frame_); visitor->Trace(remote_frame_);
FrameViewBase::Trace(visitor); visitor->Trace(parent_);
} }
} // namespace blink } // namespace blink
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define RemoteFrameView_h #define RemoteFrameView_h
#include "core/frame/FrameOrPlugin.h" #include "core/frame/FrameOrPlugin.h"
#include "core/frame/FrameView.h"
#include "platform/FrameViewBase.h" #include "platform/FrameViewBase.h"
#include "platform/geometry/IntRect.h" #include "platform/geometry/IntRect.h"
#include "platform/heap/Handle.h" #include "platform/heap/Handle.h"
...@@ -16,7 +17,9 @@ class CullRect; ...@@ -16,7 +17,9 @@ class CullRect;
class GraphicsContext; class GraphicsContext;
class RemoteFrame; class RemoteFrame;
class RemoteFrameView final : public FrameViewBase, public FrameOrPlugin { class RemoteFrameView final : public GarbageCollectedFinalized<RemoteFrameView>,
public FrameViewBase,
public FrameOrPlugin {
USING_GARBAGE_COLLECTED_MIXIN(RemoteFrameView); USING_GARBAGE_COLLECTED_MIXIN(RemoteFrameView);
public: public:
...@@ -26,6 +29,7 @@ class RemoteFrameView final : public FrameViewBase, public FrameOrPlugin { ...@@ -26,6 +29,7 @@ class RemoteFrameView final : public FrameViewBase, public FrameOrPlugin {
bool IsRemoteFrameView() const override { return true; } bool IsRemoteFrameView() const override { return true; }
void SetParent(FrameViewBase*) override; void SetParent(FrameViewBase*) override;
FrameViewBase* Parent() const override { return parent_; }
RemoteFrame& GetFrame() const { RemoteFrame& GetFrame() const {
ASSERT(remote_frame_); ASSERT(remote_frame_);
...@@ -37,9 +41,8 @@ class RemoteFrameView final : public FrameViewBase, public FrameOrPlugin { ...@@ -37,9 +41,8 @@ class RemoteFrameView final : public FrameViewBase, public FrameOrPlugin {
void FrameRectsChanged() override; void FrameRectsChanged() override;
void InvalidateRect(const IntRect&); void InvalidateRect(const IntRect&);
void SetFrameRect(const IntRect&) override; void SetFrameRect(const IntRect&) override;
const IntRect& FrameRect() const override { const IntRect& FrameRect() const override { return frame_rect_; }
return FrameViewBase::FrameRect(); IntPoint Location() const override { return frame_rect_.Location(); }
}
void Paint(GraphicsContext&, const CullRect&) const override {} void Paint(GraphicsContext&, const CullRect&) const override {}
void Hide() override; void Hide() override;
void Show() override; void Show() override;
...@@ -59,8 +62,11 @@ class RemoteFrameView final : public FrameViewBase, public FrameOrPlugin { ...@@ -59,8 +62,11 @@ class RemoteFrameView final : public FrameViewBase, public FrameOrPlugin {
// and FrameView. Please see the FrameView::m_frame comment for // and FrameView. Please see the FrameView::m_frame comment for
// details. // details.
Member<RemoteFrame> remote_frame_; Member<RemoteFrame> remote_frame_;
Member<FrameView> parent_;
IntRect last_viewport_intersection_; IntRect last_viewport_intersection_;
IntRect frame_rect_;
bool self_visible_;
bool parent_visible_;
}; };
DEFINE_TYPE_CASTS(RemoteFrameView, DEFINE_TYPE_CASTS(RemoteFrameView,
......
...@@ -257,7 +257,6 @@ component("platform") { ...@@ -257,7 +257,6 @@ component("platform") {
"FileMetadata.cpp", "FileMetadata.cpp",
"FileMetadata.h", "FileMetadata.h",
"FileSystemType.h", "FileSystemType.h",
"FrameViewBase.cpp",
"FrameViewBase.h", "FrameViewBase.h",
"Histogram.cpp", "Histogram.cpp",
"Histogram.h", "Histogram.h",
......
/*
* Copyright (C) 2004, 2005, 2006, 2010 Apple Inc. All rights reserved.
* Copyright (C) 2013 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "platform/FrameViewBase.h"
#include "platform/wtf/Assertions.h"
namespace blink {
FrameViewBase::FrameViewBase()
: parent_(nullptr), self_visible_(false), parent_visible_(false) {}
FrameViewBase::~FrameViewBase() {}
DEFINE_TRACE(FrameViewBase) {
visitor->Trace(parent_);
}
void FrameViewBase::SetParent(FrameViewBase* frame_view_base) {
DCHECK(!frame_view_base || !parent_);
if (!frame_view_base || !frame_view_base->IsVisible())
SetParentVisible(false);
parent_ = frame_view_base;
if (frame_view_base && frame_view_base->IsVisible())
SetParentVisible(true);
}
FrameViewBase* FrameViewBase::Root() const {
const FrameViewBase* top = this;
while (top->Parent())
top = top->Parent();
if (top->IsFrameView())
return const_cast<FrameViewBase*>(static_cast<const FrameViewBase*>(top));
return 0;
}
IntRect FrameViewBase::ConvertFromRootFrame(
const IntRect& rect_in_root_frame) const {
if (const FrameViewBase* parent_frame_view_base = Parent()) {
IntRect parent_rect =
parent_frame_view_base->ConvertFromRootFrame(rect_in_root_frame);
return ConvertFromContainingFrameViewBase(parent_rect);
}
return rect_in_root_frame;
}
IntPoint FrameViewBase::ConvertFromRootFrame(
const IntPoint& point_in_root_frame) const {
if (const FrameViewBase* parent_frame_view_base = Parent()) {
IntPoint parent_point =
parent_frame_view_base->ConvertFromRootFrame(point_in_root_frame);
return ConvertFromContainingFrameViewBase(parent_point);
}
return point_in_root_frame;
}
FloatPoint FrameViewBase::ConvertFromRootFrame(
const FloatPoint& point_in_root_frame) const {
// FrameViewBase / windows are required to be IntPoint aligned, but we may
// need to convert FloatPoint values within them (eg. for event co-ordinates).
IntPoint floored_point = FlooredIntPoint(point_in_root_frame);
FloatPoint parent_point = ConvertFromRootFrame(floored_point);
FloatSize window_fraction = point_in_root_frame - floored_point;
// Use linear interpolation handle any fractional value (eg. for iframes
// subject to a transform beyond just a simple translation).
// FIXME: Add FloatPoint variants of all co-ordinate space conversion APIs.
if (!window_fraction.IsEmpty()) {
const int kFactor = 1000;
IntPoint parent_line_end = ConvertFromRootFrame(
floored_point + RoundedIntSize(window_fraction.ScaledBy(kFactor)));
FloatSize parent_fraction =
(parent_line_end - parent_point).ScaledBy(1.0f / kFactor);
parent_point.Move(parent_fraction);
}
return parent_point;
}
} // namespace blink
...@@ -32,70 +32,73 @@ ...@@ -32,70 +32,73 @@
#include "platform/geometry/FloatPoint.h" #include "platform/geometry/FloatPoint.h"
#include "platform/geometry/IntRect.h" #include "platform/geometry/IntRect.h"
#include "platform/heap/Handle.h" #include "platform/heap/Handle.h"
#include "platform/wtf/Forward.h"
namespace blink { namespace blink {
class Event; // The FrameViewBase class is the parent of Scrollbar.
// TODO(joelhockey): Move core/paint/ScrollbarManager to platform/scroll
// The FrameViewBase class serves as a base class for FrameView, Scrollbar, and // and use it to replace this class.
// PluginView. class PLATFORM_EXPORT FrameViewBase : public GarbageCollectedMixin {
//
// FrameViewBases are connected in a hierarchy, with the restriction that
// plugins and scrollbars are always leaves of the tree. Only FrameView can have
// children (and therefore the FrameViewBase class has no concept of children).
class PLATFORM_EXPORT FrameViewBase
: public GarbageCollectedFinalized<FrameViewBase> {
public: public:
FrameViewBase(); FrameViewBase(){};
virtual ~FrameViewBase(); virtual ~FrameViewBase(){};
int X() const { return FrameRect().X(); } virtual IntPoint Location() const = 0;
int Y() const { return FrameRect().Y(); }
int Width() const { return FrameRect().Width(); }
int Height() const { return FrameRect().Height(); }
IntSize Size() const { return FrameRect().Size(); }
IntPoint Location() const { return FrameRect().Location(); }
virtual void SetFrameRect(const IntRect& frame_rect) {
frame_rect_ = frame_rect;
}
const IntRect& FrameRect() const { return frame_rect_; }
void Resize(int w, int h) { SetFrameRect(IntRect(X(), Y(), w, h)); }
void Resize(const IntSize& s) { SetFrameRect(IntRect(Location(), s)); }
bool IsSelfVisible() const {
return self_visible_;
} // Whether or not we have been explicitly marked as visible or not.
bool IsParentVisible() const {
return parent_visible_;
} // Whether or not our parent is visible.
bool IsVisible() const {
return self_visible_ && parent_visible_;
} // Whether or not we are actually visible.
virtual void SetParentVisible(bool visible) { parent_visible_ = visible; }
void SetSelfVisible(bool v) { self_visible_ = v; }
virtual bool IsFrameView() const { return false; } virtual bool IsFrameView() const { return false; }
virtual bool IsRemoteFrameView() const { return false; } virtual bool IsRemoteFrameView() const { return false; }
virtual bool IsPluginView() const { return false; }
virtual bool IsPluginContainer() const { return false; }
virtual bool IsScrollbar() const { return false; }
virtual void SetParent(FrameViewBase*); virtual void SetParent(FrameViewBase*) = 0;
FrameViewBase* Parent() const { return parent_; } virtual FrameViewBase* Parent() const = 0;
FrameViewBase* Root() const;
virtual void HandleEvent(Event*) {} // TODO(joelhockey): Remove this from FrameViewBase once FrameView children
// use FrameOrPlugin rather than FrameViewBase. This method does not apply to
// scrollbars.
virtual void SetParentVisible(bool visible) {}
// ConvertFromRootFrame must be in FrameViewBase rather than FrameView // ConvertFromRootFrame must be in FrameViewBase rather than FrameView
// to be visible to Scrollbar::ConvertFromRootFrame and // to be visible to Scrollbar::ConvertFromRootFrame and
// RemoteFrameView::UpdateRemoteViewportIntersection. The related // RemoteFrameView::UpdateRemoteViewportIntersection. The related
// ConvertFromContainingFrameViewBase must be declared locally to be visible. // ConvertFromContainingFrameViewBase must be declared locally to be visible.
IntRect ConvertFromRootFrame(const IntRect&) const; IntRect ConvertFromRootFrame(const IntRect& rect_in_root_frame) const {
IntPoint ConvertFromRootFrame(const IntPoint&) const; if (const FrameViewBase* parent_frame_view_base = Parent()) {
FloatPoint ConvertFromRootFrame(const FloatPoint&) const; IntRect parent_rect =
parent_frame_view_base->ConvertFromRootFrame(rect_in_root_frame);
return ConvertFromContainingFrameViewBase(parent_rect);
}
return rect_in_root_frame;
}
IntPoint ConvertFromRootFrame(const IntPoint& point_in_root_frame) const {
if (const FrameViewBase* parent_frame_view_base = Parent()) {
IntPoint parent_point =
parent_frame_view_base->ConvertFromRootFrame(point_in_root_frame);
return ConvertFromContainingFrameViewBase(parent_point);
}
return point_in_root_frame;
}
FloatPoint ConvertFromRootFrame(const FloatPoint& point_in_root_frame) const {
// FrameViewBase / windows are required to be IntPoint aligned, but we may
// need to convert FloatPoint values within them (eg. for event
// co-ordinates).
IntPoint floored_point = FlooredIntPoint(point_in_root_frame);
FloatPoint parent_point = ConvertFromRootFrame(floored_point);
FloatSize window_fraction = point_in_root_frame - floored_point;
// Use linear interpolation handle any fractional value (eg. for iframes
// subject to a transform beyond just a simple translation).
// FIXME: Add FloatPoint variants of all co-ordinate space conversion APIs.
if (!window_fraction.IsEmpty()) {
const int kFactor = 1000;
IntPoint parent_line_end = ConvertFromRootFrame(
floored_point + RoundedIntSize(window_fraction.ScaledBy(kFactor)));
FloatSize parent_fraction =
(parent_line_end - parent_point).ScaledBy(1.0f / kFactor);
parent_point.Move(parent_fraction);
}
return parent_point;
}
// TODO(joelhockey): Change all these to pure virtual functions // TODO(joelhockey): Change all these to pure virtual functions
// Once RemoteFrameView no longer inherits from FrameViewBase. // Once RemoteFrameView no longer inherits from FrameViewBase.
virtual IntRect ConvertFromContainingFrameViewBase( virtual IntRect ConvertFromContainingFrameViewBase(
...@@ -109,21 +112,9 @@ class PLATFORM_EXPORT FrameViewBase ...@@ -109,21 +112,9 @@ class PLATFORM_EXPORT FrameViewBase
return parent_point; return parent_point;
} }
virtual void FrameRectsChanged() {} virtual void FrameRectsChanged() { NOTREACHED(); }
virtual void GeometryMayHaveChanged() {}
// Notifies this frameviewbase that it will no longer be receiving events.
virtual void EventListenersRemoved() {}
DECLARE_VIRTUAL_TRACE();
virtual void Dispose() {} virtual void Dispose() {}
private:
Member<FrameViewBase> parent_;
IntRect frame_rect_;
bool self_visible_;
bool parent_visible_;
}; };
} // namespace blink } // namespace blink
......
...@@ -51,7 +51,7 @@ namespace { ...@@ -51,7 +51,7 @@ namespace {
float FrameScale(const FrameView* frame_view) { float FrameScale(const FrameView* frame_view) {
float scale = 1; float scale = 1;
if (frame_view) { if (frame_view) {
FrameView* root_view = ToFrameView(frame_view->Root()); FrameView* root_view = frame_view->Root();
if (root_view) if (root_view)
scale = root_view->InputEventsScaleFactor(); scale = root_view->InputEventsScaleFactor();
} }
...@@ -64,7 +64,7 @@ FloatPoint FrameTranslation(const FrameView* frame_view) { ...@@ -64,7 +64,7 @@ FloatPoint FrameTranslation(const FrameView* frame_view) {
IntPoint visual_viewport; IntPoint visual_viewport;
FloatSize overscroll_offset; FloatSize overscroll_offset;
if (frame_view) { if (frame_view) {
FrameView* root_view = ToFrameView(frame_view->Root()); FrameView* root_view = frame_view->Root();
if (root_view) { if (root_view) {
scale = root_view->InputEventsScaleFactor(); scale = root_view->InputEventsScaleFactor();
offset = FloatSize(root_view->InputEventsOffsetForEmulation()); offset = FloatSize(root_view->InputEventsOffsetForEmulation());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment