Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 28 matching lines...) Expand all Loading... | |
| 39 // TODO(joelhockey): Move core/paint/ScrollbarManager to platform/scroll | 39 // TODO(joelhockey): Move core/paint/ScrollbarManager to platform/scroll |
| 40 // and use it to replace this class. | 40 // and use it to replace this class. |
| 41 class PLATFORM_EXPORT FrameViewBase : public GarbageCollectedMixin { | 41 class PLATFORM_EXPORT FrameViewBase : public GarbageCollectedMixin { |
| 42 public: | 42 public: |
| 43 FrameViewBase(){}; | 43 FrameViewBase(){}; |
| 44 virtual ~FrameViewBase(){}; | 44 virtual ~FrameViewBase(){}; |
| 45 | 45 |
| 46 virtual IntPoint Location() const = 0; | 46 virtual IntPoint Location() const = 0; |
| 47 | 47 |
| 48 virtual bool IsFrameView() const { return false; } | 48 virtual bool IsFrameView() const { return false; } |
| 49 virtual bool IsRemoteFrameView() const { return false; } | |
| 50 | 49 |
| 51 virtual void SetParent(FrameViewBase*) = 0; | |
|
joelhockey
2017/05/01 23:04:35
SetParent, SetParentVisible, FrameRectsChanged met
| |
| 52 virtual FrameViewBase* Parent() const = 0; | 50 virtual FrameViewBase* Parent() const = 0; |
| 53 | 51 |
| 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) {} | |
| 58 | |
| 59 // ConvertFromRootFrame must be in FrameViewBase rather than FrameView | 52 // ConvertFromRootFrame must be in FrameViewBase rather than FrameView |
| 60 // to be visible to Scrollbar::ConvertFromRootFrame and | 53 // to be visible to Scrollbar::ConvertFromRootFrame and |
| 61 // RemoteFrameView::UpdateRemoteViewportIntersection. The related | 54 // RemoteFrameView::UpdateRemoteViewportIntersection. The related |
| 62 // ConvertFromContainingFrameViewBase must be declared locally to be visible. | 55 // ConvertFromContainingFrameViewBase must be declared locally to be visible. |
| 63 IntRect ConvertFromRootFrame(const IntRect& rect_in_root_frame) const { | 56 IntRect ConvertFromRootFrame(const IntRect& rect_in_root_frame) const { |
| 64 if (const FrameViewBase* parent_frame_view_base = Parent()) { | 57 if (const FrameViewBase* parent_frame_view_base = Parent()) { |
| 65 IntRect parent_rect = | 58 IntRect parent_rect = |
| 66 parent_frame_view_base->ConvertFromRootFrame(rect_in_root_frame); | 59 parent_frame_view_base->ConvertFromRootFrame(rect_in_root_frame); |
| 67 return ConvertFromContainingFrameViewBase(parent_rect); | 60 return ConvertFromContainingFrameView(parent_rect); |
| 68 } | 61 } |
| 69 return rect_in_root_frame; | 62 return rect_in_root_frame; |
| 70 } | 63 } |
| 71 | 64 |
| 72 IntPoint ConvertFromRootFrame(const IntPoint& point_in_root_frame) const { | 65 IntPoint ConvertFromRootFrame(const IntPoint& point_in_root_frame) const { |
| 73 if (const FrameViewBase* parent_frame_view_base = Parent()) { | 66 if (const FrameViewBase* parent_frame_view_base = Parent()) { |
| 74 IntPoint parent_point = | 67 IntPoint parent_point = |
| 75 parent_frame_view_base->ConvertFromRootFrame(point_in_root_frame); | 68 parent_frame_view_base->ConvertFromRootFrame(point_in_root_frame); |
| 76 return ConvertFromContainingFrameViewBase(parent_point); | 69 return ConvertFromContainingFrameView(parent_point); |
| 77 } | 70 } |
| 78 return point_in_root_frame; | 71 return point_in_root_frame; |
| 79 } | 72 } |
| 80 | 73 |
| 81 FloatPoint ConvertFromRootFrame(const FloatPoint& point_in_root_frame) const { | 74 FloatPoint ConvertFromRootFrame(const FloatPoint& point_in_root_frame) const { |
| 82 // FrameViewBase / windows are required to be IntPoint aligned, but we may | 75 // FrameViewBase / windows are required to be IntPoint aligned, but we may |
| 83 // need to convert FloatPoint values within them (eg. for event | 76 // need to convert FloatPoint values within them (eg. for event |
| 84 // co-ordinates). | 77 // co-ordinates). |
| 85 IntPoint floored_point = FlooredIntPoint(point_in_root_frame); | 78 IntPoint floored_point = FlooredIntPoint(point_in_root_frame); |
| 86 FloatPoint parent_point = ConvertFromRootFrame(floored_point); | 79 FloatPoint parent_point = ConvertFromRootFrame(floored_point); |
| 87 FloatSize window_fraction = point_in_root_frame - floored_point; | 80 FloatSize window_fraction = point_in_root_frame - floored_point; |
| 88 // Use linear interpolation handle any fractional value (eg. for iframes | 81 // Use linear interpolation handle any fractional value (eg. for iframes |
| 89 // subject to a transform beyond just a simple translation). | 82 // subject to a transform beyond just a simple translation). |
| 90 // FIXME: Add FloatPoint variants of all co-ordinate space conversion APIs. | 83 // FIXME: Add FloatPoint variants of all co-ordinate space conversion APIs. |
| 91 if (!window_fraction.IsEmpty()) { | 84 if (!window_fraction.IsEmpty()) { |
| 92 const int kFactor = 1000; | 85 const int kFactor = 1000; |
| 93 IntPoint parent_line_end = ConvertFromRootFrame( | 86 IntPoint parent_line_end = ConvertFromRootFrame( |
| 94 floored_point + RoundedIntSize(window_fraction.ScaledBy(kFactor))); | 87 floored_point + RoundedIntSize(window_fraction.ScaledBy(kFactor))); |
| 95 FloatSize parent_fraction = | 88 FloatSize parent_fraction = |
| 96 (parent_line_end - parent_point).ScaledBy(1.0f / kFactor); | 89 (parent_line_end - parent_point).ScaledBy(1.0f / kFactor); |
| 97 parent_point.Move(parent_fraction); | 90 parent_point.Move(parent_fraction); |
| 98 } | 91 } |
| 99 return parent_point; | 92 return parent_point; |
| 100 } | 93 } |
| 101 | 94 |
| 102 // TODO(joelhockey): Change all these to pure virtual functions | 95 virtual IntRect ConvertFromContainingFrameView(const IntRect&) const = 0; |
| 103 // Once RemoteFrameView no longer inherits from FrameViewBase. | 96 virtual IntPoint ConvertFromContainingFrameView(const IntPoint&) const = 0; |
| 104 virtual IntRect ConvertFromContainingFrameViewBase( | |
| 105 const IntRect& parent_rect) const { | |
| 106 NOTREACHED(); | |
| 107 return parent_rect; | |
| 108 } | |
| 109 virtual IntPoint ConvertFromContainingFrameViewBase( | |
| 110 const IntPoint& parent_point) const { | |
| 111 NOTREACHED(); | |
| 112 return parent_point; | |
| 113 } | |
| 114 | |
| 115 virtual void FrameRectsChanged() { NOTREACHED(); } | |
| 116 | 97 |
| 117 virtual void Dispose() {} | 98 virtual void Dispose() {} |
| 118 }; | 99 }; |
| 119 | 100 |
| 120 } // namespace blink | 101 } // namespace blink |
| 121 | 102 |
| 122 #endif // FrameViewBase_h | 103 #endif // FrameViewBase_h |
| OLD | NEW |