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 2253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2264 } | 2264 } |
2265 | 2265 |
2266 LayoutRect RenderObject::localCaretRect(InlineBox*, int, LayoutUnit* extraWidthT
oEndOfLine) | 2266 LayoutRect RenderObject::localCaretRect(InlineBox*, int, LayoutUnit* extraWidthT
oEndOfLine) |
2267 { | 2267 { |
2268 if (extraWidthToEndOfLine) | 2268 if (extraWidthToEndOfLine) |
2269 *extraWidthToEndOfLine = 0; | 2269 *extraWidthToEndOfLine = 0; |
2270 | 2270 |
2271 return LayoutRect(); | 2271 return LayoutRect(); |
2272 } | 2272 } |
2273 | 2273 |
| 2274 void RenderObject::computeLayerHitTestRects(LayerHitTestRects& layerRects) const |
| 2275 { |
| 2276 // Figure out what layer our container is in. Any offset (or new layer) for
this |
| 2277 // renderer within it's container will be applied in addLayerHitTestRects. |
| 2278 LayoutPoint layerOffset; |
| 2279 const RenderLayer* currentLayer = 0; |
| 2280 |
| 2281 if (!hasLayer()) { |
| 2282 RenderObject* container = this->container(); |
| 2283 if (container) { |
| 2284 currentLayer = container->enclosingLayer(); |
| 2285 if (currentLayer && currentLayer->renderer() != container) |
| 2286 layerOffset.move(container->offsetFromAncestorContainer(currentL
ayer->renderer())); |
| 2287 } else { |
| 2288 currentLayer = enclosingLayer(); |
| 2289 } |
| 2290 if (!currentLayer) |
| 2291 return; |
| 2292 } |
| 2293 |
| 2294 this->addLayerHitTestRects(layerRects, currentLayer, layerOffset); |
| 2295 } |
| 2296 |
| 2297 void RenderObject::addLayerHitTestRects(LayerHitTestRects& layerRects, const Ren
derLayer* currentLayer, const LayoutPoint& layerOffset) const |
| 2298 { |
| 2299 ASSERT(currentLayer); |
| 2300 ASSERT(currentLayer == this->enclosingLayer()); |
| 2301 |
| 2302 // If it's possible for children to have rects outside our bounds, then we n
eed to descend into |
| 2303 // the children and compute them. |
| 2304 // Ideally there would be other cases where we could detect that children co
uldn't have rects |
| 2305 // outside our bounds and prune the tree walk. |
| 2306 // Note that we don't use Region here because Union is O(N) - better to just
keep a list of |
| 2307 // partially redundant rectangles. If we find examples where this is expensi
ve, then we could |
| 2308 // rewrite Region to be more efficient. See https://bugs.webkit.org/show_bug
.cgi?id=100814. |
| 2309 if (!isRenderView()) { |
| 2310 for (RenderObject* curr = firstChild(); curr; curr = curr->nextSibling()
) { |
| 2311 curr->addLayerHitTestRects(layerRects, currentLayer, layerOffset); |
| 2312 } |
| 2313 } |
| 2314 |
| 2315 // Compute the rects for this renderer only and add them to the results. |
| 2316 // Note that we could avoid passing the offset and instead adjust each resul
t, but this |
| 2317 // seems slightly simpler. |
| 2318 Vector<LayoutRect> ownRects; |
| 2319 computeSelfHitTestRects(ownRects, layerOffset); |
| 2320 |
| 2321 LayerHitTestRects::iterator iter = layerRects.find(currentLayer); |
| 2322 if (iter == layerRects.end()) |
| 2323 layerRects.add(currentLayer, ownRects); |
| 2324 else |
| 2325 iter->value.append(ownRects); |
| 2326 } |
| 2327 |
2274 bool RenderObject::isRooted(RenderView** view) const | 2328 bool RenderObject::isRooted(RenderView** view) const |
2275 { | 2329 { |
2276 const RenderObject* o = this; | 2330 const RenderObject* o = this; |
2277 while (o->parent()) | 2331 while (o->parent()) |
2278 o = o->parent(); | 2332 o = o->parent(); |
2279 | 2333 |
2280 if (!o->isRenderView()) | 2334 if (!o->isRenderView()) |
2281 return false; | 2335 return false; |
2282 | 2336 |
2283 if (view) | 2337 if (view) |
(...skipping 916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3200 { | 3254 { |
3201 if (object1) { | 3255 if (object1) { |
3202 const WebCore::RenderObject* root = object1; | 3256 const WebCore::RenderObject* root = object1; |
3203 while (root->parent()) | 3257 while (root->parent()) |
3204 root = root->parent(); | 3258 root = root->parent(); |
3205 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); | 3259 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); |
3206 } | 3260 } |
3207 } | 3261 } |
3208 | 3262 |
3209 #endif | 3263 #endif |
OLD | NEW |