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

Side by Side Diff: Source/web/FindInPageCoordinates.cpp

Issue 899163003: Move rendering/RenderObject to layout/LayoutObject. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 months 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 | Annotate | Revision Log
« no previous file with comments | « Source/web/FindInPageCoordinates.h ('k') | Source/web/LinkHighlight.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 16 matching lines...) Expand all
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "web/FindInPageCoordinates.h" 32 #include "web/FindInPageCoordinates.h"
33 33
34 #include "core/dom/Node.h" 34 #include "core/dom/Node.h"
35 #include "core/dom/Range.h" 35 #include "core/dom/Range.h"
36 #include "core/frame/LocalFrame.h" 36 #include "core/frame/LocalFrame.h"
37 #include "core/layout/LayoutObject.h"
37 #include "core/rendering/RenderBlock.h" 38 #include "core/rendering/RenderBlock.h"
38 #include "core/rendering/RenderBox.h" 39 #include "core/rendering/RenderBox.h"
39 #include "core/rendering/RenderObject.h"
40 #include "core/rendering/RenderPart.h" 40 #include "core/rendering/RenderPart.h"
41 #include "core/rendering/RenderView.h" 41 #include "core/rendering/RenderView.h"
42 #include "core/rendering/style/RenderStyle.h" 42 #include "core/rendering/style/RenderStyle.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 RenderBlock* enclosingScrollableAncestor(const RenderObject* render er) 49 static const RenderBlock* enclosingScrollableAncestor(const LayoutObject* render er)
50 { 50 {
51 ASSERT(!renderer->isRenderView()); 51 ASSERT(!renderer->isRenderView());
52 52
53 // Trace up the containingBlocks until we reach either the render view or a scrollable object. 53 // Trace up the containingBlocks until we reach either the render view or a scrollable object.
54 const RenderBlock* container = renderer->containingBlock(); 54 const RenderBlock* container = renderer->containingBlock();
55 while (!container->hasOverflowClip() && !container->isRenderView()) 55 while (!container->hasOverflowClip() && !container->isRenderView())
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 RenderObj ect* renderer, const RenderBlock* container) 60 static FloatRect toNormalizedRect(const FloatRect& absoluteRect, const LayoutObj ect* renderer, const RenderBlock* container)
61 { 61 {
62 ASSERT(renderer); 62 ASSERT(renderer);
63 63
64 ASSERT(container || renderer->isRenderView()); 64 ASSERT(container || renderer->isRenderView());
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;
(...skipping 15 matching lines...) Expand all
86 86
87 // Fixed positions do not make sense in this coordinate system, but need to leave consistent tickmarks. 87 // Fixed positions do not make sense in this coordinate system, but need to leave consistent tickmarks.
88 // So, use their position when the view is not scrolled, like an absolute po sition. 88 // So, use their position when the view is not scrolled, like an absolute po sition.
89 if (renderer->style()->position() == FixedPosition && container->isRenderVie w()) 89 if (renderer->style()->position() == FixedPosition && container->isRenderVie w())
90 normalizedRect.move(-toRenderView(container)->frameView()->scrollOffsetF orViewportConstrainedObjects()); 90 normalizedRect.move(-toRenderView(container)->frameView()->scrollOffsetF orViewportConstrainedObjects());
91 91
92 normalizedRect.scale(1 / containerRect.width(), 1 / containerRect.height()); 92 normalizedRect.scale(1 / containerRect.width(), 1 / containerRect.height());
93 return normalizedRect; 93 return normalizedRect;
94 } 94 }
95 95
96 FloatRect findInPageRectFromAbsoluteRect(const FloatRect& inputRect, const Rende rObject* baseRenderer) 96 FloatRect findInPageRectFromAbsoluteRect(const FloatRect& inputRect, const Layou tObject* baseRenderer)
97 { 97 {
98 if (!baseRenderer || inputRect.isEmpty()) 98 if (!baseRenderer || inputRect.isEmpty())
99 return FloatRect(); 99 return FloatRect();
100 100
101 // Normalize the input rect to its container block. 101 // Normalize the input rect to its container block.
102 const RenderBlock* baseContainer = enclosingScrollableAncestor(baseRenderer) ; 102 const RenderBlock* baseContainer = enclosingScrollableAncestor(baseRenderer) ;
103 FloatRect normalizedRect = toNormalizedRect(inputRect, baseRenderer, baseCon tainer); 103 FloatRect normalizedRect = toNormalizedRect(inputRect, baseRenderer, baseCon tainer);
104 104
105 // Go up across frames. 105 // Go up across frames.
106 for (const RenderBox* renderer = baseContainer; renderer; ) { 106 for (const RenderBox* renderer = baseContainer; renderer; ) {
(...skipping 17 matching lines...) Expand all
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(RenderObject::absoluteBoundingBoxRectF orRange(range), range->firstNode()->renderer()); 134 return findInPageRectFromAbsoluteRect(LayoutObject::absoluteBoundingBoxRectF orRange(range), range->firstNode()->renderer());
135 } 135 }
136 136
137 } // namespace blink 137 } // namespace blink
OLDNEW
« no previous file with comments | « Source/web/FindInPageCoordinates.h ('k') | Source/web/LinkHighlight.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698