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

Unified Diff: Source/WebKit/chromium/src/FindInPageCoordinates.cpp

Issue 12092069: Merge 141252 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1364/
Patch Set: Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/WebKit/chromium/ChangeLog ('k') | Source/WebKit/chromium/tests/WebFrameTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/WebKit/chromium/src/FindInPageCoordinates.cpp
===================================================================
--- Source/WebKit/chromium/src/FindInPageCoordinates.cpp (revision 141278)
+++ Source/WebKit/chromium/src/FindInPageCoordinates.cpp (working copy)
@@ -49,11 +49,21 @@
namespace WebKit {
-static FloatRect toNormalizedRect(const FloatRect& absoluteRect, const RenderObject* renderer)
+static const RenderBlock* enclosingScrollableAncestor(const RenderObject* renderer)
{
+ ASSERT(!renderer->isRenderView());
+
+ // Trace up the containingBlocks until we reach either the render view or a scrollable object.
+ const RenderBlock* container = renderer->containingBlock();
+ while (!container->hasOverflowClip() && !container->isRenderView())
+ container = container->containingBlock();
+ return container;
+}
+
+static FloatRect toNormalizedRect(const FloatRect& absoluteRect, const RenderObject* renderer, const RenderBlock* container)
+{
ASSERT(renderer);
- const RenderBlock* container = renderer->containingBlock();
ASSERT(container || renderer->isRenderView());
if (!container)
return FloatRect();
@@ -92,26 +102,27 @@
return FloatRect();
// Normalize the input rect to its container block.
- FloatRect normalizedRect = toNormalizedRect(inputRect, baseRenderer);
+ const RenderBlock* baseContainer = enclosingScrollableAncestor(baseRenderer);
+ FloatRect normalizedRect = toNormalizedRect(inputRect, baseRenderer, baseContainer);
// Go up across frames.
- for (const RenderObject* renderer = baseRenderer->containingBlock(); renderer; ) {
+ for (const RenderBox* renderer = baseContainer; renderer; ) {
// Go up the render tree until we reach the root of the current frame (the RenderView).
- for (const RenderBlock* container = renderer->containingBlock(); container;
- renderer = container, container = container->containingBlock()) {
+ while (!renderer->isRenderView()) {
+ const RenderBlock* container = enclosingScrollableAncestor(renderer);
// Compose the normalized rects.
- FloatRect normalizedBoxRect = toNormalizedRect(renderer->absoluteBoundingBoxRect(), renderer);
+ FloatRect normalizedBoxRect = toNormalizedRect(renderer->absoluteBoundingBoxRect(), renderer, container);
normalizedRect.scale(normalizedBoxRect.width(), normalizedBoxRect.height());
normalizedRect.moveBy(normalizedBoxRect.location());
- if (normalizedRect.isEmpty())
- return normalizedRect;
+ renderer = container;
}
+ ASSERT(renderer->isRenderView());
+
// Jump to the renderer owning the frame, if any.
- ASSERT(renderer->isRenderView());
renderer = renderer->frame() ? renderer->frame()->ownerRenderer() : 0;
}
« no previous file with comments | « Source/WebKit/chromium/ChangeLog ('k') | Source/WebKit/chromium/tests/WebFrameTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698