| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2000 Dirk Mueller (mueller@kde.org) | 4 * (C) 2000 Dirk Mueller (mueller@kde.org) |
| 5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) | 5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) |
| 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv
ed. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv
ed. |
| 7 * Copyright (C) 2009 Google Inc. All rights reserved. | 7 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
| 9 * | 9 * |
| 10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
| (...skipping 2277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2288 currentLayer = container->enclosingLayer(); | 2288 currentLayer = container->enclosingLayer(); |
| 2289 if (currentLayer && currentLayer->renderer() != container) | 2289 if (currentLayer && currentLayer->renderer() != container) |
| 2290 layerOffset.move(container->offsetFromAncestorContainer(currentL
ayer->renderer())); | 2290 layerOffset.move(container->offsetFromAncestorContainer(currentL
ayer->renderer())); |
| 2291 } else { | 2291 } else { |
| 2292 currentLayer = enclosingLayer(); | 2292 currentLayer = enclosingLayer(); |
| 2293 } | 2293 } |
| 2294 if (!currentLayer) | 2294 if (!currentLayer) |
| 2295 return; | 2295 return; |
| 2296 } | 2296 } |
| 2297 | 2297 |
| 2298 this->addLayerHitTestRects(layerRects, currentLayer, layerOffset); | 2298 this->addLayerHitTestRects(layerRects, currentLayer, layerOffset, LayoutRect
()); |
| 2299 } | 2299 } |
| 2300 | 2300 |
| 2301 void RenderObject::addLayerHitTestRects(LayerHitTestRects& layerRects, const Ren
derLayer* currentLayer, const LayoutPoint& layerOffset) const | 2301 void RenderObject::addLayerHitTestRects(LayerHitTestRects& layerRects, const Ren
derLayer* currentLayer, const LayoutPoint& layerOffset, const LayoutRect& contai
nerRect) const |
| 2302 { | 2302 { |
| 2303 ASSERT(currentLayer); | 2303 ASSERT(currentLayer); |
| 2304 ASSERT(currentLayer == this->enclosingLayer()); | 2304 ASSERT(currentLayer == this->enclosingLayer()); |
| 2305 | 2305 |
| 2306 // Compute the rects for this renderer only and add them to the results. |
| 2307 // Note that we could avoid passing the offset and instead adjust each resul
t, but this |
| 2308 // seems slightly simpler. |
| 2309 Vector<LayoutRect> ownRects; |
| 2310 LayoutRect newContainerRect; |
| 2311 computeSelfHitTestRects(ownRects, layerOffset); |
| 2312 |
| 2313 LayerHitTestRects::iterator iter = layerRects.find(currentLayer); |
| 2314 if (iter == layerRects.end()) |
| 2315 iter = layerRects.add(currentLayer, Vector<LayoutRect>()).iterator; |
| 2316 for (size_t i = 0; i < ownRects.size(); i++) { |
| 2317 if (!containerRect.contains(ownRects[i])) { |
| 2318 iter->value.append(ownRects[i]); |
| 2319 if (newContainerRect.isEmpty()) |
| 2320 newContainerRect = ownRects[i]; |
| 2321 } |
| 2322 } |
| 2323 if (newContainerRect.isEmpty()) |
| 2324 newContainerRect = containerRect; |
| 2325 |
| 2306 // If it's possible for children to have rects outside our bounds, then we n
eed to descend into | 2326 // If it's possible for children to have rects outside our bounds, then we n
eed to descend into |
| 2307 // the children and compute them. | 2327 // the children and compute them. |
| 2308 // Ideally there would be other cases where we could detect that children co
uldn't have rects | 2328 // Ideally there would be other cases where we could detect that children co
uldn't have rects |
| 2309 // outside our bounds and prune the tree walk. | 2329 // outside our bounds and prune the tree walk. |
| 2310 // Note that we don't use Region here because Union is O(N) - better to just
keep a list of | 2330 // Note that we don't use Region here because Union is O(N) - better to just
keep a list of |
| 2311 // partially redundant rectangles. If we find examples where this is expensi
ve, then we could | 2331 // partially redundant rectangles. If we find examples where this is expensi
ve, then we could |
| 2312 // rewrite Region to be more efficient. See https://bugs.webkit.org/show_bug
.cgi?id=100814. | 2332 // rewrite Region to be more efficient. See https://bugs.webkit.org/show_bug
.cgi?id=100814. |
| 2313 if (!isRenderView()) { | 2333 if (!isRenderView()) { |
| 2314 for (RenderObject* curr = firstChild(); curr; curr = curr->nextSibling()
) { | 2334 for (RenderObject* curr = firstChild(); curr; curr = curr->nextSibling()
) { |
| 2315 curr->addLayerHitTestRects(layerRects, currentLayer, layerOffset); | 2335 curr->addLayerHitTestRects(layerRects, currentLayer, layerOffset, n
ewContainerRect); |
| 2316 } | 2336 } |
| 2317 } | 2337 } |
| 2318 | |
| 2319 // Compute the rects for this renderer only and add them to the results. | |
| 2320 // Note that we could avoid passing the offset and instead adjust each resul
t, but this | |
| 2321 // seems slightly simpler. | |
| 2322 Vector<LayoutRect> ownRects; | |
| 2323 computeSelfHitTestRects(ownRects, layerOffset); | |
| 2324 | |
| 2325 LayerHitTestRects::iterator iter = layerRects.find(currentLayer); | |
| 2326 if (iter == layerRects.end()) | |
| 2327 layerRects.add(currentLayer, ownRects); | |
| 2328 else | |
| 2329 iter->value.append(ownRects); | |
| 2330 } | 2338 } |
| 2331 | 2339 |
| 2332 bool RenderObject::isRooted(RenderView** view) const | 2340 bool RenderObject::isRooted(RenderView** view) const |
| 2333 { | 2341 { |
| 2334 const RenderObject* o = this; | 2342 const RenderObject* o = this; |
| 2335 while (o->parent()) | 2343 while (o->parent()) |
| 2336 o = o->parent(); | 2344 o = o->parent(); |
| 2337 | 2345 |
| 2338 if (!o->isRenderView()) | 2346 if (!o->isRenderView()) |
| 2339 return false; | 2347 return false; |
| (...skipping 954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3294 { | 3302 { |
| 3295 if (object1) { | 3303 if (object1) { |
| 3296 const WebCore::RenderObject* root = object1; | 3304 const WebCore::RenderObject* root = object1; |
| 3297 while (root->parent()) | 3305 while (root->parent()) |
| 3298 root = root->parent(); | 3306 root = root->parent(); |
| 3299 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); | 3307 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); |
| 3300 } | 3308 } |
| 3301 } | 3309 } |
| 3302 | 3310 |
| 3303 #endif | 3311 #endif |
| OLD | NEW |