Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Side by Side Diff: third_party/WebKit/Source/platform/FrameViewBase.h

Issue 2843693003: Move methods from FrameViewBase to FrameView. (Closed)
Patch Set: address comments Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
3 * Copyright (C) 2008 Collabora Ltd. All rights reserved. 3 * Copyright (C) 2008 Collabora Ltd. All rights reserved.
4 * Copyright (C) 2013 Google Inc. All rights reserved. 4 * Copyright (C) 2013 Google Inc. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 14 matching lines...) Expand all
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28 #ifndef FrameViewBase_h 28 #ifndef FrameViewBase_h
29 #define FrameViewBase_h 29 #define FrameViewBase_h
30 30
31 #include "platform/PlatformExport.h" 31 #include "platform/PlatformExport.h"
32 #include "platform/geometry/FloatPoint.h" 32 #include "platform/geometry/FloatPoint.h"
33 #include "platform/geometry/IntRect.h" 33 #include "platform/geometry/IntRect.h"
34 #include "platform/heap/Handle.h" 34 #include "platform/heap/Handle.h"
35 #include "platform/wtf/Forward.h"
36 35
37 namespace blink { 36 namespace blink {
38 37
39 class Event; 38 // The FrameViewBase class is the parent of Scrollbar.
39 // TODO(joelhockey): Move core/paint/ScrollbarManager to platform/scroll
40 // and use it to replace this class.
41 class PLATFORM_EXPORT FrameViewBase : public GarbageCollectedMixin {
42 public:
43 FrameViewBase(){};
44 virtual ~FrameViewBase(){};
40 45
41 // The FrameViewBase class serves as a base class for FrameView, Scrollbar, and 46 virtual IntPoint Location() const = 0;
42 // PluginView.
43 //
44 // FrameViewBases are connected in a hierarchy, with the restriction that
45 // plugins and scrollbars are always leaves of the tree. Only FrameView can have
46 // children (and therefore the FrameViewBase class has no concept of children).
47 class PLATFORM_EXPORT FrameViewBase
48 : public GarbageCollectedFinalized<FrameViewBase> {
49 public:
50 FrameViewBase();
51 virtual ~FrameViewBase();
52
53 int X() const { return FrameRect().X(); }
54 int Y() const { return FrameRect().Y(); }
55 int Width() const { return FrameRect().Width(); }
56 int Height() const { return FrameRect().Height(); }
57 IntSize Size() const { return FrameRect().Size(); }
58 IntPoint Location() const { return FrameRect().Location(); }
59
60 virtual void SetFrameRect(const IntRect& frame_rect) {
61 frame_rect_ = frame_rect;
62 }
63 const IntRect& FrameRect() const { return frame_rect_; }
64
65 void Resize(int w, int h) { SetFrameRect(IntRect(X(), Y(), w, h)); }
66 void Resize(const IntSize& s) { SetFrameRect(IntRect(Location(), s)); }
67
68 bool IsSelfVisible() const {
69 return self_visible_;
70 } // Whether or not we have been explicitly marked as visible or not.
71 bool IsParentVisible() const {
72 return parent_visible_;
73 } // Whether or not our parent is visible.
74 bool IsVisible() const {
75 return self_visible_ && parent_visible_;
76 } // Whether or not we are actually visible.
77 virtual void SetParentVisible(bool visible) { parent_visible_ = visible; }
78 void SetSelfVisible(bool v) { self_visible_ = v; }
79 47
80 virtual bool IsFrameView() const { return false; } 48 virtual bool IsFrameView() const { return false; }
81 virtual bool IsRemoteFrameView() const { return false; } 49 virtual bool IsRemoteFrameView() const { return false; }
82 virtual bool IsPluginView() const { return false; }
83 virtual bool IsPluginContainer() const { return false; }
84 virtual bool IsScrollbar() const { return false; }
85 50
86 virtual void SetParent(FrameViewBase*); 51 virtual void SetParent(FrameViewBase*) = 0;
87 FrameViewBase* Parent() const { return parent_; } 52 virtual FrameViewBase* Parent() const = 0;
88 FrameViewBase* Root() const;
89 53
90 virtual void HandleEvent(Event*) {} 54 // TODO(joelhockey): Remove this from FrameViewBase once FrameView children
55 // use FrameOrPlugin rather than FrameViewBase. This method does not apply to
56 // scrollbars.
57 virtual void SetParentVisible(bool visible) {}
91 58
92 // ConvertFromRootFrame must be in FrameViewBase rather than FrameView 59 // ConvertFromRootFrame must be in FrameViewBase rather than FrameView
93 // to be visible to Scrollbar::ConvertFromRootFrame and 60 // to be visible to Scrollbar::ConvertFromRootFrame and
94 // RemoteFrameView::UpdateRemoteViewportIntersection. The related 61 // RemoteFrameView::UpdateRemoteViewportIntersection. The related
95 // ConvertFromContainingFrameViewBase must be declared locally to be visible. 62 // ConvertFromContainingFrameViewBase must be declared locally to be visible.
96 IntRect ConvertFromRootFrame(const IntRect&) const; 63 IntRect ConvertFromRootFrame(const IntRect& rect_in_root_frame) const {
97 IntPoint ConvertFromRootFrame(const IntPoint&) const; 64 if (const FrameViewBase* parent_frame_view_base = Parent()) {
98 FloatPoint ConvertFromRootFrame(const FloatPoint&) const; 65 IntRect parent_rect =
66 parent_frame_view_base->ConvertFromRootFrame(rect_in_root_frame);
67 return ConvertFromContainingFrameViewBase(parent_rect);
68 }
69 return rect_in_root_frame;
70 }
71
72 IntPoint ConvertFromRootFrame(const IntPoint& point_in_root_frame) const {
73 if (const FrameViewBase* parent_frame_view_base = Parent()) {
74 IntPoint parent_point =
75 parent_frame_view_base->ConvertFromRootFrame(point_in_root_frame);
76 return ConvertFromContainingFrameViewBase(parent_point);
77 }
78 return point_in_root_frame;
79 }
80
81 FloatPoint ConvertFromRootFrame(const FloatPoint& point_in_root_frame) const {
82 // FrameViewBase / windows are required to be IntPoint aligned, but we may
83 // need to convert FloatPoint values within them (eg. for event
84 // co-ordinates).
85 IntPoint floored_point = FlooredIntPoint(point_in_root_frame);
86 FloatPoint parent_point = ConvertFromRootFrame(floored_point);
87 FloatSize window_fraction = point_in_root_frame - floored_point;
88 // Use linear interpolation handle any fractional value (eg. for iframes
89 // subject to a transform beyond just a simple translation).
90 // FIXME: Add FloatPoint variants of all co-ordinate space conversion APIs.
91 if (!window_fraction.IsEmpty()) {
92 const int kFactor = 1000;
93 IntPoint parent_line_end = ConvertFromRootFrame(
94 floored_point + RoundedIntSize(window_fraction.ScaledBy(kFactor)));
95 FloatSize parent_fraction =
96 (parent_line_end - parent_point).ScaledBy(1.0f / kFactor);
97 parent_point.Move(parent_fraction);
98 }
99 return parent_point;
100 }
101
99 // TODO(joelhockey): Change all these to pure virtual functions 102 // TODO(joelhockey): Change all these to pure virtual functions
100 // Once RemoteFrameView no longer inherits from FrameViewBase. 103 // Once RemoteFrameView no longer inherits from FrameViewBase.
101 virtual IntRect ConvertFromContainingFrameViewBase( 104 virtual IntRect ConvertFromContainingFrameViewBase(
102 const IntRect& parent_rect) const { 105 const IntRect& parent_rect) const {
103 NOTREACHED(); 106 NOTREACHED();
104 return parent_rect; 107 return parent_rect;
105 } 108 }
106 virtual IntPoint ConvertFromContainingFrameViewBase( 109 virtual IntPoint ConvertFromContainingFrameViewBase(
107 const IntPoint& parent_point) const { 110 const IntPoint& parent_point) const {
108 NOTREACHED(); 111 NOTREACHED();
109 return parent_point; 112 return parent_point;
110 } 113 }
111 114
112 virtual void FrameRectsChanged() {} 115 virtual void FrameRectsChanged() { NOTREACHED(); }
113 116
114 virtual void GeometryMayHaveChanged() {}
115
116 // Notifies this frameviewbase that it will no longer be receiving events.
117 virtual void EventListenersRemoved() {}
118
119 DECLARE_VIRTUAL_TRACE();
120 virtual void Dispose() {} 117 virtual void Dispose() {}
121
122 private:
123 Member<FrameViewBase> parent_;
124 IntRect frame_rect_;
125 bool self_visible_;
126 bool parent_visible_;
127 }; 118 };
128 119
129 } // namespace blink 120 } // namespace blink
130 121
131 #endif // FrameViewBase_h 122 #endif // FrameViewBase_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698