| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 #include "core/html/HTMLTableElement.h" | 50 #include "core/html/HTMLTableElement.h" |
| 51 #include "core/page/AutoscrollController.h" | 51 #include "core/page/AutoscrollController.h" |
| 52 #include "core/page/EventHandler.h" | 52 #include "core/page/EventHandler.h" |
| 53 #include "core/page/Page.h" | 53 #include "core/page/Page.h" |
| 54 #include "core/paint/ObjectPainter.h" | 54 #include "core/paint/ObjectPainter.h" |
| 55 #include "core/rendering/FlowThreadController.h" | 55 #include "core/rendering/FlowThreadController.h" |
| 56 #include "core/rendering/HitTestResult.h" | 56 #include "core/rendering/HitTestResult.h" |
| 57 #include "core/rendering/RenderCounter.h" | 57 #include "core/rendering/RenderCounter.h" |
| 58 #include "core/rendering/RenderDeprecatedFlexibleBox.h" | 58 #include "core/rendering/RenderDeprecatedFlexibleBox.h" |
| 59 #include "core/rendering/RenderFlexibleBox.h" | 59 #include "core/rendering/RenderFlexibleBox.h" |
| 60 #include "core/rendering/RenderFlowThread.h" | |
| 61 #include "core/rendering/RenderGeometryMap.h" | 60 #include "core/rendering/RenderGeometryMap.h" |
| 62 #include "core/rendering/RenderGrid.h" | 61 #include "core/rendering/RenderGrid.h" |
| 63 #include "core/rendering/RenderImage.h" | 62 #include "core/rendering/RenderImage.h" |
| 64 #include "core/rendering/RenderImageResourceStyleImage.h" | 63 #include "core/rendering/RenderImageResourceStyleImage.h" |
| 65 #include "core/rendering/RenderInline.h" | 64 #include "core/rendering/RenderInline.h" |
| 66 #include "core/rendering/RenderLayer.h" | 65 #include "core/rendering/RenderLayer.h" |
| 67 #include "core/rendering/RenderListItem.h" | 66 #include "core/rendering/RenderListItem.h" |
| 67 #include "core/rendering/RenderMultiColumnFlowThread.h" |
| 68 #include "core/rendering/RenderObjectInlines.h" | 68 #include "core/rendering/RenderObjectInlines.h" |
| 69 #include "core/rendering/RenderPart.h" | 69 #include "core/rendering/RenderPart.h" |
| 70 #include "core/rendering/RenderScrollbarPart.h" | 70 #include "core/rendering/RenderScrollbarPart.h" |
| 71 #include "core/rendering/RenderTableCaption.h" | 71 #include "core/rendering/RenderTableCaption.h" |
| 72 #include "core/rendering/RenderTableCell.h" | 72 #include "core/rendering/RenderTableCell.h" |
| 73 #include "core/rendering/RenderTableCol.h" | 73 #include "core/rendering/RenderTableCol.h" |
| 74 #include "core/rendering/RenderTableRow.h" | 74 #include "core/rendering/RenderTableRow.h" |
| 75 #include "core/rendering/RenderTheme.h" | 75 #include "core/rendering/RenderTheme.h" |
| 76 #include "core/rendering/RenderView.h" | 76 #include "core/rendering/RenderView.h" |
| 77 #include "core/rendering/compositing/CompositedLayerMapping.h" | 77 #include "core/rendering/compositing/CompositedLayerMapping.h" |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 return !isTable(); | 318 return !isTable(); |
| 319 else if (newChild->isTableSection()) | 319 else if (newChild->isTableSection()) |
| 320 return !isTable(); | 320 return !isTable(); |
| 321 else if (newChild->isTableRow()) | 321 else if (newChild->isTableRow()) |
| 322 return !isTableSection(); | 322 return !isTableSection(); |
| 323 else if (newChild->isTableCell()) | 323 else if (newChild->isTableCell()) |
| 324 return !isTableRow(); | 324 return !isTableRow(); |
| 325 return false; | 325 return false; |
| 326 } | 326 } |
| 327 | 327 |
| 328 bool RenderObject::isValidColumnSpanAll() const |
| 329 { |
| 330 ASSERT(style()->columnSpan() == ColumnSpanAll); |
| 331 RenderFlowThread* flowThread = flowThreadContainingBlock(); |
| 332 return flowThread && flowThread->isColumnSpanner(this); |
| 333 } |
| 334 |
| 328 void RenderObject::addChild(RenderObject* newChild, RenderObject* beforeChild) | 335 void RenderObject::addChild(RenderObject* newChild, RenderObject* beforeChild) |
| 329 { | 336 { |
| 330 ASSERT(isAllowedToModifyRenderTreeStructure(document())); | 337 ASSERT(isAllowedToModifyRenderTreeStructure(document())); |
| 331 | 338 |
| 332 RenderObjectChildList* children = virtualChildren(); | 339 RenderObjectChildList* children = virtualChildren(); |
| 333 ASSERT(children); | 340 ASSERT(children); |
| 334 if (!children) | 341 if (!children) |
| 335 return; | 342 return; |
| 336 | 343 |
| 337 if (requiresAnonymousTableWrappers(newChild)) { | 344 if (requiresAnonymousTableWrappers(newChild)) { |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 627 // See if we have the thread cached because we're in the middle of layout. | 634 // See if we have the thread cached because we're in the middle of layout. |
| 628 RenderFlowThread* flowThread = view()->flowThreadController()->currentRender
FlowThread(); | 635 RenderFlowThread* flowThread = view()->flowThreadController()->currentRender
FlowThread(); |
| 629 if (flowThread) | 636 if (flowThread) |
| 630 return flowThread; | 637 return flowThread; |
| 631 | 638 |
| 632 // Not in the middle of layout so have to find the thread the slow way. | 639 // Not in the middle of layout so have to find the thread the slow way. |
| 633 RenderObject* curr = const_cast<RenderObject*>(this); | 640 RenderObject* curr = const_cast<RenderObject*>(this); |
| 634 while (curr) { | 641 while (curr) { |
| 635 if (curr->isRenderFlowThread()) | 642 if (curr->isRenderFlowThread()) |
| 636 return toRenderFlowThread(curr); | 643 return toRenderFlowThread(curr); |
| 637 curr = curr->containingBlock(); | 644 switch (curr->style()->position()) { |
| 645 case FixedPosition: |
| 646 curr = curr->containerForFixedPosition(); |
| 647 break; |
| 648 case AbsolutePosition: |
| 649 curr = curr->containerForAbsolutePosition(); |
| 650 break; |
| 651 default: |
| 652 curr = curr->parentBlock(); |
| 653 break; |
| 654 } |
| 638 } | 655 } |
| 639 return 0; | 656 return 0; |
| 640 } | 657 } |
| 641 | 658 |
| 642 bool RenderObject::skipInvalidationWhenLaidOutChildren() const | 659 bool RenderObject::skipInvalidationWhenLaidOutChildren() const |
| 643 { | 660 { |
| 644 if (!neededLayoutBecauseOfChildren()) | 661 if (!neededLayoutBecauseOfChildren()) |
| 645 return false; | 662 return false; |
| 646 | 663 |
| 647 // SVG renderers need to be invalidated when their children are laid out. | 664 // SVG renderers need to be invalidated when their children are laid out. |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 794 RenderObject* ancestor = parent(); | 811 RenderObject* ancestor = parent(); |
| 795 for (; ancestor && !ancestor->canContainFixedPositionObjects(); ancestor = a
ncestor->parent()) { | 812 for (; ancestor && !ancestor->canContainFixedPositionObjects(); ancestor = a
ncestor->parent()) { |
| 796 if (paintInvalidationContainerSkipped && ancestor == paintInvalidationCo
ntainer) | 813 if (paintInvalidationContainerSkipped && ancestor == paintInvalidationCo
ntainer) |
| 797 *paintInvalidationContainerSkipped = true; | 814 *paintInvalidationContainerSkipped = true; |
| 798 } | 815 } |
| 799 | 816 |
| 800 ASSERT(!ancestor || !ancestor->isAnonymousBlock()); | 817 ASSERT(!ancestor || !ancestor->isAnonymousBlock()); |
| 801 return toRenderBlock(ancestor); | 818 return toRenderBlock(ancestor); |
| 802 } | 819 } |
| 803 | 820 |
| 804 RenderBlock* RenderObject::containingBlock() const | 821 RenderBlock* RenderObject::containerForAbsolutePosition() const |
| 805 { | 822 { |
| 806 RenderObject* o = parent(); | 823 RenderObject* o = parent(); |
| 807 if (!o && isRenderScrollbarPart()) | 824 while (o) { |
| 808 o = toRenderScrollbarPart(this)->rendererOwningScrollbar(); | 825 // For relpositioned inlines, we return the nearest non-anonymous enclos
ing block. We don't try |
| 809 if (!isText() && m_style->position() == FixedPosition) { | 826 // to return the inline itself. This allows us to avoid having a positi
oned objects |
| 810 return containerForFixedPosition(); | 827 // list in all RenderInlines and lets us return a strongly-typed RenderB
lock* result |
| 811 } else if (!isText() && m_style->position() == AbsolutePosition) { | 828 // from this method. The container() method can actually be used to obt
ain the |
| 812 while (o) { | 829 // inline directly. |
| 813 // For relpositioned inlines, we return the nearest non-anonymous en
closing block. We don't try | 830 if (o->style()->position() != StaticPosition && (!o->isInline() || o->is
Replaced())) |
| 814 // to return the inline itself. This allows us to avoid having a po
sitioned objects | 831 break; |
| 815 // list in all RenderInlines and lets us return a strongly-typed Ren
derBlock* result | |
| 816 // from this method. The container() method can actually be used to
obtain the | |
| 817 // inline directly. | |
| 818 if (o->style()->position() != StaticPosition && (!o->isInline() || o
->isReplaced())) | |
| 819 break; | |
| 820 | 832 |
| 821 if (o->canContainFixedPositionObjects()) | 833 if (o->canContainFixedPositionObjects()) |
| 822 break; | 834 break; |
| 823 | 835 |
| 824 if (o->style()->hasInFlowPosition() && o->isInline() && !o->isReplac
ed()) { | 836 if (o->style()->hasInFlowPosition() && o->isInline() && !o->isReplaced()
) { |
| 825 o = o->containingBlock(); | 837 o = o->parentBlock(); |
| 826 break; | 838 break; |
| 827 } | |
| 828 | |
| 829 o = o->parent(); | |
| 830 } | 839 } |
| 831 | 840 |
| 832 if (o && !o->isRenderBlock()) | 841 o = o->parent(); |
| 833 o = o->containingBlock(); | 842 } |
| 834 | 843 |
| 835 while (o && o->isAnonymousBlock()) | 844 if (o && !o->isRenderBlock()) |
| 836 o = o->containingBlock(); | 845 o = o->parentBlock(); |
| 837 } else { | 846 |
| 838 while (o && ((o->isInline() && !o->isReplaced()) || !o->isRenderBlock())
) | 847 while (o && o->isAnonymousBlock()) |
| 839 o = o->parent(); | 848 o = o->parentBlock(); |
| 840 } | 849 |
| 850 return toRenderBlock(o); |
| 851 } |
| 852 |
| 853 RenderBlock* RenderObject::parentBlock() const |
| 854 { |
| 855 RenderObject* o = parent(); |
| 856 while (o && ((o->isInline() && !o->isReplaced()) || !o->isRenderBlock())) |
| 857 o = o->parent(); |
| 841 | 858 |
| 842 if (!o || !o->isRenderBlock()) | 859 if (!o || !o->isRenderBlock()) |
| 843 return 0; // This can still happen in case of an orphaned tree | 860 return 0; // This can still happen in case of an orphaned tree |
| 844 | 861 |
| 845 return toRenderBlock(o); | 862 return toRenderBlock(o); |
| 846 } | 863 } |
| 847 | 864 |
| 865 RenderBlock* RenderObject::containingBlock() const |
| 866 { |
| 867 if (!parent() && isRenderScrollbarPart()) { |
| 868 RenderObject* o = toRenderScrollbarPart(this)->rendererOwningScrollbar()
; |
| 869 if (o && !o->isRenderBlock()) |
| 870 o = o->parentBlock(); |
| 871 return toRenderBlock(o); |
| 872 } |
| 873 if (!isText()) { |
| 874 if (m_style->position() == FixedPosition) |
| 875 return containerForFixedPosition(); |
| 876 if (m_style->position() == AbsolutePosition) |
| 877 return containerForAbsolutePosition(); |
| 878 } |
| 879 if (isColumnSpanAll()) |
| 880 return toRenderMultiColumnFlowThread(flowThreadContainingBlock())->multi
ColumnBlockFlow(); |
| 881 return parentBlock(); |
| 882 } |
| 883 |
| 848 bool RenderObject::canRenderBorderImage() const | 884 bool RenderObject::canRenderBorderImage() const |
| 849 { | 885 { |
| 850 if (!style()->hasBorder()) | 886 if (!style()->hasBorder()) |
| 851 return false; | 887 return false; |
| 852 | 888 |
| 853 StyleImage* borderImage = style()->borderImage().image(); | 889 StyleImage* borderImage = style()->borderImage().image(); |
| 854 return borderImage && borderImage->canRender(*this, style()->effectiveZoom()
) && borderImage->isLoaded(); | 890 return borderImage && borderImage->canRender(*this, style()->effectiveZoom()
) && borderImage->isLoaded(); |
| 855 } | 891 } |
| 856 | 892 |
| 857 bool RenderObject::mustInvalidateFillLayersPaintOnWidthChange(const FillLayer& l
ayer) const | 893 bool RenderObject::mustInvalidateFillLayersPaintOnWidthChange(const FillLayer& l
ayer) const |
| (...skipping 1529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2387 if (slowFirstChild() || hasLayer()) { | 2423 if (slowFirstChild() || hasLayer()) { |
| 2388 if (!layer) | 2424 if (!layer) |
| 2389 layer = parent()->enclosingLayer(); | 2425 layer = parent()->enclosingLayer(); |
| 2390 removeLayers(layer); | 2426 removeLayers(layer); |
| 2391 } | 2427 } |
| 2392 | 2428 |
| 2393 if (isOutOfFlowPositioned() && parent()->childrenInline()) | 2429 if (isOutOfFlowPositioned() && parent()->childrenInline()) |
| 2394 parent()->dirtyLinesFromChangedChild(this); | 2430 parent()->dirtyLinesFromChangedChild(this); |
| 2395 | 2431 |
| 2396 removeFromRenderFlowThread(); | 2432 removeFromRenderFlowThread(); |
| 2433 RELEASE_ASSERT(!isColumnSpanAll()); // Former spanners should have been remo
ved from the flow thread map by now. |
| 2397 | 2434 |
| 2398 // Update cached boundaries in SVG renderers if a child is removed. | 2435 // Update cached boundaries in SVG renderers if a child is removed. |
| 2399 if (parent()->isSVG()) | 2436 if (parent()->isSVG()) |
| 2400 parent()->setNeedsBoundariesUpdate(); | 2437 parent()->setNeedsBoundariesUpdate(); |
| 2401 } | 2438 } |
| 2402 | 2439 |
| 2403 void RenderObject::removeFromRenderFlowThread() | 2440 void RenderObject::removeFromRenderFlowThread() |
| 2404 { | 2441 { |
| 2405 if (flowThreadState() == NotInsideFlowThread) | 2442 if (flowThreadState() == NotInsideFlowThread) |
| 2406 return; | 2443 return; |
| 2407 | 2444 |
| 2408 // Sometimes we remove the element from the flow, but it's not destroyed at
that time. | 2445 // Sometimes we remove the element from the flow, but it's not destroyed at
that time. |
| 2409 // It's only until later when we actually destroy it and remove all the chil
dren from it. | 2446 // It's only until later when we actually destroy it and remove all the chil
dren from it. |
| 2410 // Currently, that happens for firstLetter elements and list markers. | 2447 // Currently, that happens for firstLetter elements and list markers. |
| 2411 // Pass in the flow thread so that we don't have to look it up for all the c
hildren. | 2448 // Pass in the flow thread so that we don't have to look it up for all the c
hildren. |
| 2412 removeFromRenderFlowThreadRecursive(flowThreadContainingBlock()); | 2449 removeFromRenderFlowThreadRecursive(flowThreadContainingBlock()); |
| 2413 } | 2450 } |
| 2414 | 2451 |
| 2415 void RenderObject::removeFromRenderFlowThreadRecursive(RenderFlowThread* renderF
lowThread) | 2452 void RenderObject::removeFromRenderFlowThreadRecursive(RenderFlowThread* renderF
lowThread) |
| 2416 { | 2453 { |
| 2417 if (const RenderObjectChildList* children = virtualChildren()) { | 2454 if (const RenderObjectChildList* children = virtualChildren()) { |
| 2418 for (RenderObject* child = children->firstChild(); child; child = child-
>nextSibling()) | 2455 for (RenderObject* child = children->firstChild(); child; child = child-
>nextSibling()) |
| 2419 child->removeFromRenderFlowThreadRecursive(renderFlowThread); | 2456 child->removeFromRenderFlowThreadRecursive(renderFlowThread); |
| 2420 } | 2457 } |
| 2458 |
| 2459 if (renderFlowThread && renderFlowThread != this) |
| 2460 renderFlowThread->flowThreadDescendantWillBeRemoved(this); |
| 2421 setFlowThreadState(NotInsideFlowThread); | 2461 setFlowThreadState(NotInsideFlowThread); |
| 2422 } | 2462 } |
| 2423 | 2463 |
| 2424 void RenderObject::destroyAndCleanupAnonymousWrappers() | 2464 void RenderObject::destroyAndCleanupAnonymousWrappers() |
| 2425 { | 2465 { |
| 2426 // If the tree is destroyed, there is no need for a clean-up phase. | 2466 // If the tree is destroyed, there is no need for a clean-up phase. |
| 2427 if (documentBeingDestroyed()) { | 2467 if (documentBeingDestroyed()) { |
| 2428 destroy(); | 2468 destroy(); |
| 2429 return; | 2469 return; |
| 2430 } | 2470 } |
| (...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3148 { | 3188 { |
| 3149 if (object1) { | 3189 if (object1) { |
| 3150 const blink::RenderObject* root = object1; | 3190 const blink::RenderObject* root = object1; |
| 3151 while (root->parent()) | 3191 while (root->parent()) |
| 3152 root = root->parent(); | 3192 root = root->parent(); |
| 3153 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); | 3193 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); |
| 3154 } | 3194 } |
| 3155 } | 3195 } |
| 3156 | 3196 |
| 3157 #endif | 3197 #endif |
| OLD | NEW |