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

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

Issue 1516723003: [Element / Autofill] Add boundsInViewportFloat() to fix <input> popup misalignment. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refator to use boundsInViewportFloat() eventually, but keep boundsInViewportInt(). Created 5 years 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 81
82 IntRect Widget::convertToRootFrame(const IntRect& localRect) const 82 IntRect Widget::convertToRootFrame(const IntRect& localRect) const
83 { 83 {
84 if (const Widget* parentWidget = parent()) { 84 if (const Widget* parentWidget = parent()) {
85 IntRect parentRect = convertToContainingWidget(localRect); 85 IntRect parentRect = convertToContainingWidget(localRect);
86 return parentWidget->convertToRootFrame(parentRect); 86 return parentWidget->convertToRootFrame(parentRect);
87 } 87 }
88 return localRect; 88 return localRect;
89 } 89 }
90 90
91 FloatRect Widget::convertToRootFrame(const FloatRect& localRect) const
92 {
93 if (const Widget* parentWidget = parent()) {
94 FloatRect parentRect = convertToContainingWidget(localRect);
95 return parentWidget->convertToRootFrame(parentRect);
96 }
97 return localRect;
98 }
99
91 IntPoint Widget::convertFromRootFrame(const IntPoint& pointInRootFrame) const 100 IntPoint Widget::convertFromRootFrame(const IntPoint& pointInRootFrame) const
92 { 101 {
93 if (const Widget* parentWidget = parent()) { 102 if (const Widget* parentWidget = parent()) {
94 IntPoint parentPoint = parentWidget->convertFromRootFrame(pointInRootFra me); 103 IntPoint parentPoint = parentWidget->convertFromRootFrame(pointInRootFra me);
95 return convertFromContainingWidget(parentPoint); 104 return convertFromContainingWidget(parentPoint);
96 } 105 }
97 return pointInRootFrame; 106 return pointInRootFrame;
98 } 107 }
99 108
100 FloatPoint Widget::convertFromRootFrame(const FloatPoint& pointInRootFrame) cons t 109 FloatPoint Widget::convertFromRootFrame(const FloatPoint& pointInRootFrame) cons t
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 { 148 {
140 if (const Widget* parentWidget = parent()) { 149 if (const Widget* parentWidget = parent()) {
141 IntRect localRect = parentRect; 150 IntRect localRect = parentRect;
142 localRect.setLocation(parentWidget->convertSelfToChild(this, localRect.l ocation())); 151 localRect.setLocation(parentWidget->convertSelfToChild(this, localRect.l ocation()));
143 return localRect; 152 return localRect;
144 } 153 }
145 154
146 return parentRect; 155 return parentRect;
147 } 156 }
148 157
158 FloatRect Widget::convertToContainingWidget(const FloatRect& localRect) const
159 {
160 if (const Widget* parentWidget = parent()) {
161 FloatRect parentRect(localRect);
162 parentRect.setLocation(parentWidget->convertChildToSelf(this, localRect. location()));
163 return parentRect;
164 }
165 return localRect;
166 }
167
149 IntPoint Widget::convertToContainingWidget(const IntPoint& localPoint) const 168 IntPoint Widget::convertToContainingWidget(const IntPoint& localPoint) const
150 { 169 {
151 if (const Widget* parentWidget = parent()) 170 if (const Widget* parentWidget = parent())
152 return parentWidget->convertChildToSelf(this, localPoint); 171 return parentWidget->convertChildToSelf(this, localPoint);
153 172
154 return localPoint; 173 return localPoint;
155 } 174 }
156 175
157 IntPoint Widget::convertFromContainingWidget(const IntPoint& parentPoint) const 176 IntPoint Widget::convertFromContainingWidget(const IntPoint& parentPoint) const
158 { 177 {
159 if (const Widget* parentWidget = parent()) 178 if (const Widget* parentWidget = parent())
160 return parentWidget->convertSelfToChild(this, parentPoint); 179 return parentWidget->convertSelfToChild(this, parentPoint);
161 180
162 return parentPoint; 181 return parentPoint;
163 } 182 }
164 183
165 IntPoint Widget::convertChildToSelf(const Widget*, const IntPoint& point) const 184 IntPoint Widget::convertChildToSelf(const Widget*, const IntPoint& point) const
166 { 185 {
167 return point; 186 return point;
168 } 187 }
169 188
170 IntPoint Widget::convertSelfToChild(const Widget*, const IntPoint& point) const 189 IntPoint Widget::convertSelfToChild(const Widget*, const IntPoint& point) const
171 { 190 {
172 return point; 191 return point;
173 } 192 }
174 193
194 FloatPoint Widget::convertChildToSelf(const Widget*, const FloatPoint& point) co nst
195 {
196 return point;
197 }
198
175 } // namespace blink 199 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/Widget.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