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

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

Issue 2832883003: Remove unneeded Convert* methods and move many from FrameViewBase to FrameView (Closed)
Patch Set: fix ScrollableArea::ConvertFromScrollbarToContainingFrameViewBase and remove dchecks 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, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2005, 2006, 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2013 Google Inc. All rights reserved. 3 * Copyright (C) 2013 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 IntRect FrameViewBase::ConvertFromRootFrame( 60 IntRect FrameViewBase::ConvertFromRootFrame(
61 const IntRect& rect_in_root_frame) const { 61 const IntRect& rect_in_root_frame) const {
62 if (const FrameViewBase* parent_frame_view_base = Parent()) { 62 if (const FrameViewBase* parent_frame_view_base = Parent()) {
63 IntRect parent_rect = 63 IntRect parent_rect =
64 parent_frame_view_base->ConvertFromRootFrame(rect_in_root_frame); 64 parent_frame_view_base->ConvertFromRootFrame(rect_in_root_frame);
65 return ConvertFromContainingFrameViewBase(parent_rect); 65 return ConvertFromContainingFrameViewBase(parent_rect);
66 } 66 }
67 return rect_in_root_frame; 67 return rect_in_root_frame;
68 } 68 }
69 69
70 IntRect FrameViewBase::ConvertToRootFrame(const IntRect& local_rect) const {
71 if (const FrameViewBase* parent_frame_view_base = Parent()) {
72 IntRect parent_rect = ConvertToContainingFrameViewBase(local_rect);
73 return parent_frame_view_base->ConvertToRootFrame(parent_rect);
74 }
75 return local_rect;
76 }
77
78 IntPoint FrameViewBase::ConvertFromRootFrame( 70 IntPoint FrameViewBase::ConvertFromRootFrame(
79 const IntPoint& point_in_root_frame) const { 71 const IntPoint& point_in_root_frame) const {
80 if (const FrameViewBase* parent_frame_view_base = Parent()) { 72 if (const FrameViewBase* parent_frame_view_base = Parent()) {
81 IntPoint parent_point = 73 IntPoint parent_point =
82 parent_frame_view_base->ConvertFromRootFrame(point_in_root_frame); 74 parent_frame_view_base->ConvertFromRootFrame(point_in_root_frame);
83 return ConvertFromContainingFrameViewBase(parent_point); 75 return ConvertFromContainingFrameViewBase(parent_point);
84 } 76 }
85 return point_in_root_frame; 77 return point_in_root_frame;
86 } 78 }
87 79
88 FloatPoint FrameViewBase::ConvertFromRootFrame( 80 FloatPoint FrameViewBase::ConvertFromRootFrame(
89 const FloatPoint& point_in_root_frame) const { 81 const FloatPoint& point_in_root_frame) const {
90 // FrameViewBase / windows are required to be IntPoint aligned, but we may 82 // FrameViewBase / windows are required to be IntPoint aligned, but we may
91 // need to convert FloatPoint values within them (eg. for event co-ordinates). 83 // need to convert FloatPoint values within them (eg. for event co-ordinates).
92 IntPoint floored_point = FlooredIntPoint(point_in_root_frame); 84 IntPoint floored_point = FlooredIntPoint(point_in_root_frame);
93 FloatPoint parent_point = this->ConvertFromRootFrame(floored_point); 85 FloatPoint parent_point = ConvertFromRootFrame(floored_point);
94 FloatSize window_fraction = point_in_root_frame - floored_point; 86 FloatSize window_fraction = point_in_root_frame - floored_point;
95 // Use linear interpolation handle any fractional value (eg. for iframes 87 // Use linear interpolation handle any fractional value (eg. for iframes
96 // subject to a transform beyond just a simple translation). 88 // subject to a transform beyond just a simple translation).
97 // FIXME: Add FloatPoint variants of all co-ordinate space conversion APIs. 89 // FIXME: Add FloatPoint variants of all co-ordinate space conversion APIs.
98 if (!window_fraction.IsEmpty()) { 90 if (!window_fraction.IsEmpty()) {
99 const int kFactor = 1000; 91 const int kFactor = 1000;
100 IntPoint parent_line_end = this->ConvertFromRootFrame( 92 IntPoint parent_line_end = ConvertFromRootFrame(
101 floored_point + RoundedIntSize(window_fraction.ScaledBy(kFactor))); 93 floored_point + RoundedIntSize(window_fraction.ScaledBy(kFactor)));
102 FloatSize parent_fraction = 94 FloatSize parent_fraction =
103 (parent_line_end - parent_point).ScaledBy(1.0f / kFactor); 95 (parent_line_end - parent_point).ScaledBy(1.0f / kFactor);
104 parent_point.Move(parent_fraction); 96 parent_point.Move(parent_fraction);
105 } 97 }
106 return parent_point; 98 return parent_point;
107 } 99 }
108 100
109 IntPoint FrameViewBase::ConvertToRootFrame(const IntPoint& local_point) const {
110 if (const FrameViewBase* parent_frame_view_base = Parent()) {
111 IntPoint parent_point = ConvertToContainingFrameViewBase(local_point);
112 return parent_frame_view_base->ConvertToRootFrame(parent_point);
113 }
114 return local_point;
115 }
116
117 IntRect FrameViewBase::ConvertToContainingFrameViewBase(
118 const IntRect& local_rect) const {
119 if (const FrameViewBase* parent_frame_view_base = Parent()) {
120 IntRect parent_rect(local_rect);
121 parent_rect.SetLocation(parent_frame_view_base->ConvertChildToSelf(
122 this, local_rect.Location()));
123 return parent_rect;
124 }
125 return local_rect;
126 }
127
128 IntRect FrameViewBase::ConvertFromContainingFrameViewBase(
129 const IntRect& parent_rect) const {
130 if (const FrameViewBase* parent_frame_view_base = Parent()) {
131 IntRect local_rect = parent_rect;
132 local_rect.SetLocation(parent_frame_view_base->ConvertSelfToChild(
133 this, local_rect.Location()));
134 return local_rect;
135 }
136
137 return parent_rect;
138 }
139
140 IntPoint FrameViewBase::ConvertToContainingFrameViewBase(
141 const IntPoint& local_point) const {
142 if (const FrameViewBase* parent_frame_view_base = Parent())
143 return parent_frame_view_base->ConvertChildToSelf(this, local_point);
144
145 return local_point;
146 }
147
148 IntPoint FrameViewBase::ConvertFromContainingFrameViewBase(
149 const IntPoint& parent_point) const {
150 if (const FrameViewBase* parent_frame_view_base = Parent())
151 return parent_frame_view_base->ConvertSelfToChild(this, parent_point);
152
153 return parent_point;
154 }
155
156 IntPoint FrameViewBase::ConvertChildToSelf(const FrameViewBase*,
157 const IntPoint& point) const {
158 return point;
159 }
160
161 IntPoint FrameViewBase::ConvertSelfToChild(const FrameViewBase*,
162 const IntPoint& point) const {
163 return point;
164 }
165
166 } // namespace blink 101 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/FrameViewBase.h ('k') | third_party/WebKit/Source/platform/scroll/ScrollableArea.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698