Chromium Code Reviews| 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 16 matching lines...) Expand all Loading... | |
| 27 #include "config.h" | 27 #include "config.h" |
| 28 #include "core/rendering/RenderObject.h" | 28 #include "core/rendering/RenderObject.h" |
| 29 | 29 |
| 30 #include "HTMLNames.h" | 30 #include "HTMLNames.h" |
| 31 #include "core/accessibility/AXObjectCache.h" | 31 #include "core/accessibility/AXObjectCache.h" |
| 32 #include "core/css/resolver/StyleResolver.h" | 32 #include "core/css/resolver/StyleResolver.h" |
| 33 #include "core/editing/EditingBoundary.h" | 33 #include "core/editing/EditingBoundary.h" |
| 34 #include "core/editing/FrameSelection.h" | 34 #include "core/editing/FrameSelection.h" |
| 35 #include "core/editing/htmlediting.h" | 35 #include "core/editing/htmlediting.h" |
| 36 #include "core/html/HTMLElement.h" | 36 #include "core/html/HTMLElement.h" |
| 37 #include "core/html/HTMLFrameOwnerElement.h" | |
| 37 #include "core/page/EventHandler.h" | 38 #include "core/page/EventHandler.h" |
| 38 #include "core/page/Frame.h" | 39 #include "core/page/Frame.h" |
| 39 #include "core/page/FrameView.h" | 40 #include "core/page/FrameView.h" |
| 40 #include "core/page/Page.h" | 41 #include "core/page/Page.h" |
| 41 #include "core/page/Settings.h" | 42 #include "core/page/Settings.h" |
| 42 #include "core/page/animation/AnimationController.h" | 43 #include "core/page/animation/AnimationController.h" |
| 43 #include "core/platform/graphics/FloatQuad.h" | 44 #include "core/platform/graphics/FloatQuad.h" |
| 44 #include "core/platform/graphics/GraphicsContext.h" | 45 #include "core/platform/graphics/GraphicsContext.h" |
| 45 #include "core/platform/graphics/transforms/TransformState.h" | 46 #include "core/platform/graphics/transforms/TransformState.h" |
| 46 #include "core/rendering/FlowThreadController.h" | 47 #include "core/rendering/FlowThreadController.h" |
| (...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 632 | 633 |
| 633 RenderNamedFlowThread* RenderObject::renderNamedFlowThreadWrapper() const | 634 RenderNamedFlowThread* RenderObject::renderNamedFlowThreadWrapper() const |
| 634 { | 635 { |
| 635 RenderObject* object = const_cast<RenderObject*>(this); | 636 RenderObject* object = const_cast<RenderObject*>(this); |
| 636 while (object && object->isAnonymousBlock() && !object->isRenderNamedFlowThr ead()) | 637 while (object && object->isAnonymousBlock() && !object->isRenderNamedFlowThr ead()) |
| 637 object = object->parent(); | 638 object = object->parent(); |
| 638 | 639 |
| 639 return object && object->isRenderNamedFlowThread() ? toRenderNamedFlowThread (object) : 0; | 640 return object && object->isRenderNamedFlowThread() ? toRenderNamedFlowThread (object) : 0; |
| 640 } | 641 } |
| 641 | 642 |
| 643 void RenderObject::enclosingCompositedLayerAndOffset(const RenderLayer** enclosi ngCompositedLayer, LayoutPoint& offset) const | |
| 644 { | |
| 645 // Determine the new compositing layer and the offset from it. | |
| 646 RenderLayer* layer = enclosingLayer(); | |
| 647 *enclosingCompositedLayer = layer->enclosingCompositingLayerForRepaint(); | |
| 648 | |
| 649 if (!*enclosingCompositedLayer) { | |
| 650 if (document()) { | |
| 651 if (HTMLFrameOwnerElement* ownerElement = document()->ownerElement() ) { | |
| 652 if (RenderObject* parentDocRenderer = ownerElement->renderer()) { | |
| 653 // Nearest composited layer is in another document. | |
| 654 // TODO There must be a simpler way to achieve this! | |
| 655 // Would it be simpler to use FrameView::contentsToWindow/wi ndowToContents as in | |
| 656 // convertTargetSpaceQuadToCompositedLayer in LinkHighlight. cpp? | |
| 657 | |
| 658 // First get the offset of this frame within the composited layer. | |
| 659 parentDocRenderer->enclosingCompositedLayerAndOffset(enclosi ngCompositedLayer, offset); | |
| 660 | |
| 661 // Add the offset of the frame contents within the frame (i. e. border+padding). | |
| 662 if (parentDocRenderer->isBox()) | |
| 663 offset.moveBy(toRenderBox(parentDocRenderer)->contentBox Rect().location()); | |
| 664 | |
| 665 // Now add the offset of this object within our frame. | |
| 666 TransformState transformState(TransformState::ApplyTransform Direction, FloatPoint()); | |
| 667 mapLocalToContainer(view(), transformState, ApplyContainerFl ip | UseTransforms); | |
| 668 transformState.flatten(); | |
| 669 offset.moveBy(LayoutPoint(transformState.lastPlanarPoint())) ; | |
| 670 | |
| 671 // And subtract the scroll offset of this frame. | |
| 672 offset -= frame()->view()->scrollOffset(); | |
| 673 } | |
| 674 } | |
| 675 } | |
| 676 return; | |
| 677 } | |
| 678 | |
| 679 // Self-painting layers subtract the renderer's location. Otherwise, we need to map our location to layer space. | |
| 680 if ((*enclosingCompositedLayer)->renderer() == this) { | |
| 681 offset = LayoutPoint(); | |
| 682 } else { | |
| 683 TransformState transformState(TransformState::ApplyTransformDirection, F loatPoint()); | |
| 684 mapLocalToContainer((*enclosingCompositedLayer)->renderer(), transformSt ate, ApplyContainerFlip | UseTransforms); | |
| 685 transformState.flatten(); | |
| 686 offset = LayoutPoint(transformState.lastPlanarPoint()); | |
| 687 } | |
| 688 } | |
| 689 | |
| 642 RenderBlock* RenderObject::firstLineBlock() const | 690 RenderBlock* RenderObject::firstLineBlock() const |
| 643 { | 691 { |
| 644 return 0; | 692 return 0; |
| 645 } | 693 } |
| 646 | 694 |
| 647 static inline bool objectIsRelayoutBoundary(const RenderObject* object) | 695 static inline bool objectIsRelayoutBoundary(const RenderObject* object) |
| 648 { | 696 { |
| 649 // FIXME: In future it may be possible to broaden these conditions in order to improve performance. | 697 // FIXME: In future it may be possible to broaden these conditions in order to improve performance. |
| 650 if (object->isTextControl()) | 698 if (object->isTextControl()) |
| 651 return true; | 699 return true; |
| (...skipping 1608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2260 } | 2308 } |
| 2261 | 2309 |
| 2262 LayoutRect RenderObject::localCaretRect(InlineBox*, int, LayoutUnit* extraWidthT oEndOfLine) | 2310 LayoutRect RenderObject::localCaretRect(InlineBox*, int, LayoutUnit* extraWidthT oEndOfLine) |
| 2263 { | 2311 { |
| 2264 if (extraWidthToEndOfLine) | 2312 if (extraWidthToEndOfLine) |
| 2265 *extraWidthToEndOfLine = 0; | 2313 *extraWidthToEndOfLine = 0; |
| 2266 | 2314 |
| 2267 return LayoutRect(); | 2315 return LayoutRect(); |
| 2268 } | 2316 } |
| 2269 | 2317 |
| 2318 void RenderObject::computeLayerHitTestRects(LayerHitTestRects& layerRects) const | |
| 2319 { | |
| 2320 // Figure out what composited layer our container is in. Any offset (or new layer) for this | |
| 2321 // renderer within it's container will be applied in addLayerHitTestRects. | |
| 2322 LayoutPoint layerOffset; | |
| 2323 const RenderLayer* currentCompositedLayer; | |
| 2324 if (container()) | |
| 2325 container()->enclosingCompositedLayerAndOffset(¤tCompositedLayer, layerOffset); | |
| 2326 else | |
| 2327 enclosingCompositedLayerAndOffset(¤tCompositedLayer, layerOffset); | |
| 2328 if (!currentCompositedLayer) | |
| 2329 return; | |
| 2330 | |
| 2331 this->addLayerHitTestRects(layerRects, currentCompositedLayer, layerOffset); | |
| 2332 } | |
| 2333 | |
| 2334 void RenderObject::addLayerHitTestRects(LayerHitTestRects& layerRects, const Ren derLayer* currentCompositedLayer, const LayoutPoint& layerOffset) const | |
| 2335 { | |
| 2336 ASSERT(currentCompositedLayer); | |
| 2337 | |
| 2338 // If it's possible for children to have rects outside our bounds, then we n eed to descend into the | |
| 2339 // children and compute them. | |
| 2340 // TODO: Any tighter guarantee on when we don't need to descend into childre n? | |
|
leviw_travelin_and_unemployed
2013/07/10 01:51:16
I don't think there's any tighter guarantee, but g
| |
| 2341 // TODO: Should I improve Region and use it? https://bugs.webkit.org/show_bu g.cgi?id=100814 | |
| 2342 if (!isRoot()) { | |
| 2343 for (RenderObject* curr = firstChild(); curr; curr = curr->nextSibling() ) { | |
| 2344 // TODO: levi's original patch excluded curr->isText(), curr->isList Marker() and !curr->isBox(). Why? | |
|
leviw_travelin_and_unemployed
2013/07/10 01:51:16
I can't recall on the latter two, but text nodes a
| |
| 2345 curr->addLayerHitTestRects(layerRects, currentCompositedLayer, laye rOffset); | |
| 2346 } | |
| 2347 } | |
| 2348 | |
| 2349 // Compute the rects for this renderer only and add them to the results. | |
| 2350 // TODO: We could avoid passing the offset here and instead offset each resu lt. | |
| 2351 Vector<IntRect> ownRects; | |
| 2352 computeOwnHitTestRects(ownRects, layerOffset); | |
| 2353 | |
| 2354 LayerHitTestRects::iterator iter = layerRects.find(currentCompositedLayer); | |
| 2355 if (iter == layerRects.end()) | |
| 2356 layerRects.add(currentCompositedLayer, ownRects); | |
| 2357 else | |
| 2358 iter->value.append(ownRects); | |
| 2359 } | |
| 2360 | |
| 2270 bool RenderObject::isRooted(RenderView** view) const | 2361 bool RenderObject::isRooted(RenderView** view) const |
| 2271 { | 2362 { |
| 2272 const RenderObject* o = this; | 2363 const RenderObject* o = this; |
| 2273 while (o->parent()) | 2364 while (o->parent()) |
| 2274 o = o->parent(); | 2365 o = o->parent(); |
| 2275 | 2366 |
| 2276 if (!o->isRenderView()) | 2367 if (!o->isRenderView()) |
| 2277 return false; | 2368 return false; |
| 2278 | 2369 |
| 2279 if (view) | 2370 if (view) |
| (...skipping 957 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3237 { | 3328 { |
| 3238 if (object1) { | 3329 if (object1) { |
| 3239 const WebCore::RenderObject* root = object1; | 3330 const WebCore::RenderObject* root = object1; |
| 3240 while (root->parent()) | 3331 while (root->parent()) |
| 3241 root = root->parent(); | 3332 root = root->parent(); |
| 3242 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); | 3333 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); |
| 3243 } | 3334 } |
| 3244 } | 3335 } |
| 3245 | 3336 |
| 3246 #endif | 3337 #endif |
| OLD | NEW |