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

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

Issue 1486743002: Clean up some remaining obsolete coordinate-space naming. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed Mac compile 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 Widget* Widget::root() const 63 Widget* Widget::root() const
64 { 64 {
65 const Widget* top = this; 65 const Widget* top = this;
66 while (top->parent()) 66 while (top->parent())
67 top = top->parent(); 67 top = top->parent();
68 if (top->isFrameView()) 68 if (top->isFrameView())
69 return const_cast<Widget*>(static_cast<const Widget*>(top)); 69 return const_cast<Widget*>(static_cast<const Widget*>(top));
70 return 0; 70 return 0;
71 } 71 }
72 72
73 IntRect Widget::convertFromContainingWindow(const IntRect& windowRect) const 73 IntRect Widget::convertFromRootFrame(const IntRect& rectInRootFrame) const
74 { 74 {
75 if (const Widget* parentWidget = parent()) { 75 if (const Widget* parentWidget = parent()) {
76 IntRect parentRect = parentWidget->convertFromContainingWindow(windowRec t); 76 IntRect parentRect = parentWidget->convertFromRootFrame(rectInRootFrame) ;
77 return convertFromContainingView(parentRect); 77 return convertFromContainingWidget(parentRect);
78 } 78 }
79 return windowRect; 79 return rectInRootFrame;
80 } 80 }
81 81
82 IntRect Widget::convertToContainingWindow(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 = convertToContainingView(localRect); 85 IntRect parentRect = convertToContainingWidget(localRect);
86 return parentWidget->convertToContainingWindow(parentRect); 86 return parentWidget->convertToRootFrame(parentRect);
87 } 87 }
88 return localRect; 88 return localRect;
89 } 89 }
90 90
91 IntPoint Widget::convertFromContainingWindow(const IntPoint& windowPoint) const 91 IntPoint Widget::convertFromRootFrame(const IntPoint& pointInRootFrame) const
92 { 92 {
93 if (const Widget* parentWidget = parent()) { 93 if (const Widget* parentWidget = parent()) {
94 IntPoint parentPoint = parentWidget->convertFromContainingWindow(windowP oint); 94 IntPoint parentPoint = parentWidget->convertFromRootFrame(pointInRootFra me);
95 return convertFromContainingView(parentPoint); 95 return convertFromContainingWidget(parentPoint);
96 } 96 }
97 return windowPoint; 97 return pointInRootFrame;
98 } 98 }
99 99
100 FloatPoint Widget::convertFromContainingWindow(const FloatPoint& windowPoint) co nst 100 FloatPoint Widget::convertFromRootFrame(const FloatPoint& pointInRootFrame) cons t
101 { 101 {
102 // Widgets / windows are required to be IntPoint aligned, but we may need to convert 102 // Widgets / windows are required to be IntPoint aligned, but we may need to convert
103 // FloatPoint values within them (eg. for event co-ordinates). 103 // FloatPoint values within them (eg. for event co-ordinates).
104 IntPoint flooredPoint = flooredIntPoint(windowPoint); 104 IntPoint flooredPoint = flooredIntPoint(pointInRootFrame);
105 FloatPoint parentPoint = this->convertFromContainingWindow(flooredPoint); 105 FloatPoint parentPoint = this->convertFromRootFrame(flooredPoint);
106 FloatSize windowFraction = windowPoint - flooredPoint; 106 FloatSize windowFraction = pointInRootFrame - flooredPoint;
107 // Use linear interpolation handle any fractional value (eg. for iframes sub ject to a transform 107 // Use linear interpolation handle any fractional value (eg. for iframes sub ject to a transform
108 // beyond just a simple translation). 108 // beyond just a simple translation).
109 // FIXME: Add FloatPoint variants of all co-ordinate space conversion APIs. 109 // FIXME: Add FloatPoint variants of all co-ordinate space conversion APIs.
110 if (!windowFraction.isEmpty()) { 110 if (!windowFraction.isEmpty()) {
111 const int kFactor = 1000; 111 const int kFactor = 1000;
112 IntPoint parentLineEnd = this->convertFromContainingWindow(flooredPoint + roundedIntSize(windowFraction.scaledBy(kFactor))); 112 IntPoint parentLineEnd = this->convertFromRootFrame(flooredPoint + round edIntSize(windowFraction.scaledBy(kFactor)));
113 FloatSize parentFraction = (parentLineEnd - parentPoint).scaledBy(1.0f / kFactor); 113 FloatSize parentFraction = (parentLineEnd - parentPoint).scaledBy(1.0f / kFactor);
114 parentPoint.move(parentFraction); 114 parentPoint.move(parentFraction);
115 } 115 }
116 return parentPoint; 116 return parentPoint;
117 } 117 }
118 118
119 IntPoint Widget::convertToContainingWindow(const IntPoint& localPoint) const 119 IntPoint Widget::convertToRootFrame(const IntPoint& localPoint) const
120 { 120 {
121 if (const Widget* parentWidget = parent()) { 121 if (const Widget* parentWidget = parent()) {
122 IntPoint parentPoint = convertToContainingView(localPoint); 122 IntPoint parentPoint = convertToContainingWidget(localPoint);
123 return parentWidget->convertToContainingWindow(parentPoint); 123 return parentWidget->convertToRootFrame(parentPoint);
124 } 124 }
125 return localPoint; 125 return localPoint;
126 } 126 }
127 127
128 IntRect Widget::convertToContainingView(const IntRect& localRect) const 128 IntRect Widget::convertToContainingWidget(const IntRect& localRect) const
129 { 129 {
130 if (const Widget* parentWidget = parent()) { 130 if (const Widget* parentWidget = parent()) {
131 IntRect parentRect(localRect); 131 IntRect parentRect(localRect);
132 parentRect.setLocation(parentWidget->convertChildToSelf(this, localRect. location())); 132 parentRect.setLocation(parentWidget->convertChildToSelf(this, localRect. location()));
133 return parentRect; 133 return parentRect;
134 } 134 }
135 return localRect; 135 return localRect;
136 } 136 }
137 137
138 IntRect Widget::convertFromContainingView(const IntRect& parentRect) const 138 IntRect Widget::convertFromContainingWidget(const IntRect& parentRect) const
139 { 139 {
140 if (const Widget* parentWidget = parent()) { 140 if (const Widget* parentWidget = parent()) {
141 IntRect localRect = parentRect; 141 IntRect localRect = parentRect;
142 localRect.setLocation(parentWidget->convertSelfToChild(this, localRect.l ocation())); 142 localRect.setLocation(parentWidget->convertSelfToChild(this, localRect.l ocation()));
143 return localRect; 143 return localRect;
144 } 144 }
145 145
146 return parentRect; 146 return parentRect;
147 } 147 }
148 148
149 IntPoint Widget::convertToContainingView(const IntPoint& localPoint) const 149 IntPoint Widget::convertToContainingWidget(const IntPoint& localPoint) const
150 { 150 {
151 if (const Widget* parentWidget = parent()) 151 if (const Widget* parentWidget = parent())
152 return parentWidget->convertChildToSelf(this, localPoint); 152 return parentWidget->convertChildToSelf(this, localPoint);
153 153
154 return localPoint; 154 return localPoint;
155 } 155 }
156 156
157 IntPoint Widget::convertFromContainingView(const IntPoint& parentPoint) const 157 IntPoint Widget::convertFromContainingWidget(const IntPoint& parentPoint) const
158 { 158 {
159 if (const Widget* parentWidget = parent()) 159 if (const Widget* parentWidget = parent())
160 return parentWidget->convertSelfToChild(this, parentPoint); 160 return parentWidget->convertSelfToChild(this, parentPoint);
161 161
162 return parentPoint; 162 return parentPoint;
163 } 163 }
164 164
165 IntPoint Widget::convertChildToSelf(const Widget*, const IntPoint& point) const 165 IntPoint Widget::convertChildToSelf(const Widget*, const IntPoint& point) const
166 { 166 {
167 return point; 167 return point;
168 } 168 }
169 169
170 IntPoint Widget::convertSelfToChild(const Widget*, const IntPoint& point) const 170 IntPoint Widget::convertSelfToChild(const Widget*, const IntPoint& point) const
171 { 171 {
172 return point; 172 return point;
173 } 173 }
174 174
175 } // namespace blink 175 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/Widget.h ('k') | third_party/WebKit/Source/platform/exported/WebScrollbarThemeClientImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698