OLD | NEW |
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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 | 120 |
121 IntPoint Widget::convertFromContainingWindow(const IntPoint& windowPoint) const | 121 IntPoint Widget::convertFromContainingWindow(const IntPoint& windowPoint) const |
122 { | 122 { |
123 if (const Widget* parentWidget = parent()) { | 123 if (const Widget* parentWidget = parent()) { |
124 IntPoint parentPoint = parentWidget->convertFromContainingWindow(windowP
oint); | 124 IntPoint parentPoint = parentWidget->convertFromContainingWindow(windowP
oint); |
125 return convertFromContainingView(parentPoint); | 125 return convertFromContainingView(parentPoint); |
126 } | 126 } |
127 return windowPoint; | 127 return windowPoint; |
128 } | 128 } |
129 | 129 |
| 130 FloatPoint Widget::convertFromContainingWindow(const FloatPoint& windowPoint) co
nst |
| 131 { |
| 132 // Widgets / windows are required to be IntPoint aligned, but we may need to
convert |
| 133 // FloatPoint values within them (eg. for event co-ordinates). |
| 134 IntPoint flooredPoint = flooredIntPoint(windowPoint); |
| 135 FloatPoint parentPoint = this->convertFromContainingWindow(flooredPoint); |
| 136 FloatSize windowFraction = windowPoint - flooredPoint; |
| 137 // Use linear interpolation handle any fractional value (eg. for iframes sub
ject to a transform |
| 138 // beyond just a simple translation). |
| 139 // FIXME: Add FloatPoint variants of all co-ordinate space conversion APIs. |
| 140 if (!windowFraction.isEmpty()) { |
| 141 const int kFactor = 1000; |
| 142 IntPoint parentLineEnd = this->convertFromContainingWindow(flooredPoint
+ roundedIntSize(windowFraction.scaledBy(kFactor))); |
| 143 FloatSize parentFraction = (parentLineEnd - parentPoint).scaledBy(1.0f /
kFactor); |
| 144 parentPoint.move(parentFraction); |
| 145 } |
| 146 return parentPoint; |
| 147 } |
| 148 |
130 IntPoint Widget::convertToContainingWindow(const IntPoint& localPoint) const | 149 IntPoint Widget::convertToContainingWindow(const IntPoint& localPoint) const |
131 { | 150 { |
132 if (const Widget* parentWidget = parent()) { | 151 if (const Widget* parentWidget = parent()) { |
133 IntPoint parentPoint = convertToContainingView(localPoint); | 152 IntPoint parentPoint = convertToContainingView(localPoint); |
134 return parentWidget->convertToContainingWindow(parentPoint); | 153 return parentWidget->convertToContainingWindow(parentPoint); |
135 } | 154 } |
136 return localPoint; | 155 return localPoint; |
137 } | 156 } |
138 | 157 |
139 IntRect Widget::convertToContainingView(const IntRect& localRect) const | 158 IntRect Widget::convertToContainingView(const IntRect& localRect) const |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 { | 196 { |
178 return point; | 197 return point; |
179 } | 198 } |
180 | 199 |
181 IntPoint Widget::convertSelfToChild(const Widget*, const IntPoint& point) const | 200 IntPoint Widget::convertSelfToChild(const Widget*, const IntPoint& point) const |
182 { | 201 { |
183 return point; | 202 return point; |
184 } | 203 } |
185 | 204 |
186 } // namespace WebCore | 205 } // namespace WebCore |
OLD | NEW |