| 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 30 matching lines...) Expand all Loading... |
| 41 #include "core/layout/LayoutView.h" | 41 #include "core/layout/LayoutView.h" |
| 42 #include "core/style/ComputedStyle.h" | 42 #include "core/style/ComputedStyle.h" |
| 43 #include "platform/geometry/FloatPoint.h" | 43 #include "platform/geometry/FloatPoint.h" |
| 44 #include "platform/geometry/FloatQuad.h" | 44 #include "platform/geometry/FloatQuad.h" |
| 45 #include "platform/geometry/IntPoint.h" | 45 #include "platform/geometry/IntPoint.h" |
| 46 | 46 |
| 47 namespace blink { | 47 namespace blink { |
| 48 | 48 |
| 49 static const LayoutBlock* enclosingScrollableAncestor(const LayoutObject* layout
Object) | 49 static const LayoutBlock* enclosingScrollableAncestor(const LayoutObject* layout
Object) |
| 50 { | 50 { |
| 51 ASSERT(!layoutObject->isLayoutView()); | 51 DCHECK(!layoutObject->isLayoutView()); |
| 52 | 52 |
| 53 // Trace up the containingBlocks until we reach either the layoutObject view
or a scrollable object. | 53 // Trace up the containingBlocks until we reach either the layoutObject view
or a scrollable object. |
| 54 const LayoutBlock* container = layoutObject->containingBlock(); | 54 const LayoutBlock* container = layoutObject->containingBlock(); |
| 55 while (!container->hasOverflowClip() && !container->isLayoutView()) | 55 while (!container->hasOverflowClip() && !container->isLayoutView()) |
| 56 container = container->containingBlock(); | 56 container = container->containingBlock(); |
| 57 return container; | 57 return container; |
| 58 } | 58 } |
| 59 | 59 |
| 60 static FloatRect toNormalizedRect(const FloatRect& absoluteRect, const LayoutObj
ect* layoutObject, const LayoutBlock* container) | 60 static FloatRect toNormalizedRect(const FloatRect& absoluteRect, const LayoutObj
ect* layoutObject, const LayoutBlock* container) |
| 61 { | 61 { |
| 62 ASSERT(layoutObject); | 62 DCHECK(layoutObject); |
| 63 | 63 |
| 64 ASSERT(container || layoutObject->isLayoutView()); | 64 DCHECK(container || layoutObject->isLayoutView()); |
| 65 if (!container) | 65 if (!container) |
| 66 return FloatRect(); | 66 return FloatRect(); |
| 67 | 67 |
| 68 // We want to normalize by the max layout overflow size instead of only the
visible bounding box. | 68 // We want to normalize by the max layout overflow size instead of only the
visible bounding box. |
| 69 // Quads and their enclosing bounding boxes need to be used in order to keep
results transform-friendly. | 69 // Quads and their enclosing bounding boxes need to be used in order to keep
results transform-friendly. |
| 70 FloatPoint scrolledOrigin; | 70 FloatPoint scrolledOrigin; |
| 71 | 71 |
| 72 // For overflow:scroll we need to get where the actual origin is independent
ly of the scroll. | 72 // For overflow:scroll we need to get where the actual origin is independent
ly of the scroll. |
| 73 if (container->hasOverflowClip()) | 73 if (container->hasOverflowClip()) |
| 74 scrolledOrigin = -IntPoint(container->scrolledContentOffset()); | 74 scrolledOrigin = -IntPoint(container->scrolledContentOffset()); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 const LayoutBlock* container = enclosingScrollableAncestor(layoutObj
ect); | 110 const LayoutBlock* container = enclosingScrollableAncestor(layoutObj
ect); |
| 111 | 111 |
| 112 // Compose the normalized rects. | 112 // Compose the normalized rects. |
| 113 FloatRect normalizedBoxRect = toNormalizedRect(layoutObject->absolut
eBoundingBoxRect(), layoutObject, container); | 113 FloatRect normalizedBoxRect = toNormalizedRect(layoutObject->absolut
eBoundingBoxRect(), layoutObject, container); |
| 114 normalizedRect.scale(normalizedBoxRect.width(), normalizedBoxRect.he
ight()); | 114 normalizedRect.scale(normalizedBoxRect.width(), normalizedBoxRect.he
ight()); |
| 115 normalizedRect.moveBy(normalizedBoxRect.location()); | 115 normalizedRect.moveBy(normalizedBoxRect.location()); |
| 116 | 116 |
| 117 layoutObject = container; | 117 layoutObject = container; |
| 118 } | 118 } |
| 119 | 119 |
| 120 ASSERT(layoutObject->isLayoutView()); | 120 DCHECK(layoutObject->isLayoutView()); |
| 121 | 121 |
| 122 // Jump to the layoutObject owning the frame, if any. | 122 // Jump to the layoutObject owning the frame, if any. |
| 123 layoutObject = layoutObject->frame() ? layoutObject->frame()->ownerLayou
tObject() : 0; | 123 layoutObject = layoutObject->frame() ? layoutObject->frame()->ownerLayou
tObject() : 0; |
| 124 } | 124 } |
| 125 | 125 |
| 126 return normalizedRect; | 126 return normalizedRect; |
| 127 } | 127 } |
| 128 | 128 |
| 129 FloatRect findInPageRectFromRange(Range* range) | 129 FloatRect findInPageRectFromRange(Range* range) |
| 130 { | 130 { |
| 131 if (!range || !range->firstNode()) | 131 if (!range || !range->firstNode()) |
| 132 return FloatRect(); | 132 return FloatRect(); |
| 133 | 133 |
| 134 return findInPageRectFromAbsoluteRect(LayoutObject::absoluteBoundingBoxRectF
orRange(range), range->firstNode()->layoutObject()); | 134 return findInPageRectFromAbsoluteRect(LayoutObject::absoluteBoundingBoxRectF
orRange(range), range->firstNode()->layoutObject()); |
| 135 } | 135 } |
| 136 | 136 |
| 137 } // namespace blink | 137 } // namespace blink |
| OLD | NEW |