OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 // Make the coordinates relative to the container enclosing bounding box. | 89 // Make the coordinates relative to the container enclosing bounding box. |
90 // Since we work with rects enclosing quad unions this is still | 90 // Since we work with rects enclosing quad unions this is still |
91 // transform-friendly. | 91 // transform-friendly. |
92 FloatRect normalizedRect = absoluteRect; | 92 FloatRect normalizedRect = absoluteRect; |
93 normalizedRect.moveBy(-containerRect.location()); | 93 normalizedRect.moveBy(-containerRect.location()); |
94 | 94 |
95 // Fixed positions do not make sense in this coordinate system, but need to | 95 // Fixed positions do not make sense in this coordinate system, but need to |
96 // leave consistent tickmarks. So, use their position when the view is not | 96 // leave consistent tickmarks. So, use their position when the view is not |
97 // scrolled, like an absolute position. | 97 // scrolled, like an absolute position. |
98 if (layoutObject->style()->position() == FixedPosition && | 98 if (layoutObject->style()->position() == FixedPosition && |
99 container->isLayoutView()) | 99 container->isLayoutView()) { |
100 normalizedRect.moveBy( | 100 normalizedRect.move(-toLayoutView(container)->frameView()->scrollOffset()); |
101 -toLayoutView(container)->frameView()->scrollPosition()); | 101 } |
102 | 102 |
103 normalizedRect.scale(1 / containerRect.width(), 1 / containerRect.height()); | 103 normalizedRect.scale(1 / containerRect.width(), 1 / containerRect.height()); |
104 return normalizedRect; | 104 return normalizedRect; |
105 } | 105 } |
106 | 106 |
107 FloatRect findInPageRectFromAbsoluteRect(const FloatRect& inputRect, | 107 FloatRect findInPageRectFromAbsoluteRect(const FloatRect& inputRect, |
108 const LayoutObject* baseLayoutObject) { | 108 const LayoutObject* baseLayoutObject) { |
109 if (!baseLayoutObject || inputRect.isEmpty()) | 109 if (!baseLayoutObject || inputRect.isEmpty()) |
110 return FloatRect(); | 110 return FloatRect(); |
111 | 111 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 FloatRect findInPageRectFromRange(Range* range) { | 145 FloatRect findInPageRectFromRange(Range* range) { |
146 if (!range || !range->firstNode()) | 146 if (!range || !range->firstNode()) |
147 return FloatRect(); | 147 return FloatRect(); |
148 | 148 |
149 return findInPageRectFromAbsoluteRect( | 149 return findInPageRectFromAbsoluteRect( |
150 LayoutObject::absoluteBoundingBoxRectForRange(range), | 150 LayoutObject::absoluteBoundingBoxRectForRange(range), |
151 range->firstNode()->layoutObject()); | 151 range->firstNode()->layoutObject()); |
152 } | 152 } |
153 | 153 |
154 } // namespace blink | 154 } // namespace blink |
OLD | NEW |