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. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. |
7 * All rights reserved. | 7 * All rights reserved. |
8 * Copyright (C) 2009 Google Inc. All rights reserved. | 8 * Copyright (C) 2009 Google Inc. All rights reserved. |
9 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. | 9 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. |
10 * (http://www.torchmobile.com/) | 10 * (http://www.torchmobile.com/) |
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
605 if (current->hasLayer()) | 605 if (current->hasLayer()) |
606 return toLayoutBoxModelObject(current)->layer(); | 606 return toLayoutBoxModelObject(current)->layer(); |
607 } | 607 } |
608 // TODO(crbug.com/365897): we should get rid of detached layout subtrees, at | 608 // TODO(crbug.com/365897): we should get rid of detached layout subtrees, at |
609 // which point this code should not be reached. | 609 // which point this code should not be reached. |
610 return nullptr; | 610 return nullptr; |
611 } | 611 } |
612 | 612 |
613 PaintLayer* LayoutObject::paintingLayer() const { | 613 PaintLayer* LayoutObject::paintingLayer() const { |
614 for (const LayoutObject* current = this; current; | 614 for (const LayoutObject* current = this; current; |
615 current = current->paintInvalidationParent()) { | 615 // Use containingBlock instead of paintInvalidationParent for floating |
| 616 // object to omit any self-painting layers of inline objects that don't |
| 617 // paint the floating object. |
| 618 current = current->isFloating() ? current->containingBlock() |
| 619 : current->paintInvalidationParent()) { |
616 if (current->hasLayer() && | 620 if (current->hasLayer() && |
617 toLayoutBoxModelObject(current)->layer()->isSelfPaintingLayer()) | 621 toLayoutBoxModelObject(current)->layer()->isSelfPaintingLayer()) |
618 return toLayoutBoxModelObject(current)->layer(); | 622 return toLayoutBoxModelObject(current)->layer(); |
619 } | 623 } |
620 // TODO(crbug.com/365897): we should get rid of detached layout subtrees, at | 624 // TODO(crbug.com/365897): we should get rid of detached layout subtrees, at |
621 // which point this code should not be reached. | 625 // which point this code should not be reached. |
622 return nullptr; | 626 return nullptr; |
623 } | 627 } |
624 | 628 |
625 bool LayoutObject::scrollRectToVisible(const LayoutRect& rect, | 629 bool LayoutObject::scrollRectToVisible(const LayoutRect& rect, |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
885 *ancestorSkipped = true; | 889 *ancestorSkipped = true; |
886 | 890 |
887 if (filterSkipped && object->hasFilterInducingProperty()) | 891 if (filterSkipped && object->hasFilterInducingProperty()) |
888 *filterSkipped = true; | 892 *filterSkipped = true; |
889 } | 893 } |
890 | 894 |
891 ASSERT(!object || !object->isAnonymousBlock()); | 895 ASSERT(!object || !object->isAnonymousBlock()); |
892 return toLayoutBlock(object); | 896 return toLayoutBlock(object); |
893 } | 897 } |
894 | 898 |
895 LayoutBlock* LayoutObject::containingBlockForAbsolutePosition() const { | 899 LayoutBlock* LayoutObject::containingBlockForAbsolutePosition( |
896 LayoutObject* o = containerForAbsolutePosition(); | 900 const LayoutBoxModelObject* ancestor, |
| 901 bool* ancestorSkipped, |
| 902 bool* filterSkipped) const { |
| 903 LayoutObject* object = |
| 904 containerForAbsolutePosition(ancestor, ancestorSkipped, filterSkipped); |
897 | 905 |
898 // For relpositioned inlines, we return the nearest non-anonymous enclosing | 906 // For relpositioned inlines, we return the nearest non-anonymous enclosing |
899 // block. We don't try to return the inline itself. This allows us to avoid | 907 // block. We don't try to return the inline itself. This allows us to avoid |
900 // having a positioned objects list in all LayoutInlines and lets us return a | 908 // having a positioned objects list in all LayoutInlines and lets us return a |
901 // strongly-typed LayoutBlock* result from this method. The container() method | 909 // strongly-typed LayoutBlock* result from this method. The container() method |
902 // can actually be used to obtain the inline directly. | 910 // can actually be used to obtain the inline directly. |
903 if (o && o->isInline() && !o->isAtomicInlineLevel()) { | 911 if (object && object->isInline() && !object->isAtomicInlineLevel()) { |
904 ASSERT(o->style()->hasInFlowPosition()); | 912 DCHECK(object->style()->hasInFlowPosition()); |
905 o = o->containingBlock(); | 913 object = object->containingBlock(ancestor, ancestorSkipped, filterSkipped); |
906 } | 914 } |
907 | 915 |
908 if (o && !o->isLayoutBlock()) | 916 if (object && !object->isLayoutBlock()) |
909 o = o->containingBlock(); | 917 object = object->containingBlock(ancestor, ancestorSkipped, filterSkipped); |
910 | 918 |
911 while (o && o->isAnonymousBlock()) | 919 while (object && object->isAnonymousBlock()) |
912 o = o->containingBlock(); | 920 object = object->containingBlock(ancestor, ancestorSkipped, filterSkipped); |
913 | 921 |
914 if (!o || !o->isLayoutBlock()) | 922 if (!object || !object->isLayoutBlock()) |
915 return nullptr; // This can still happen in case of an orphaned tree | 923 return nullptr; // This can still happen in case of an orphaned tree |
916 | 924 |
917 return toLayoutBlock(o); | 925 return toLayoutBlock(object); |
918 } | 926 } |
919 | 927 |
920 LayoutBlock* LayoutObject::containingBlock() const { | 928 LayoutBlock* LayoutObject::containingBlock(const LayoutBoxModelObject* ancestor, |
921 LayoutObject* o = parent(); | 929 bool* ancestorSkipped, |
922 if (!o && isLayoutScrollbarPart()) | 930 bool* filterSkipped) const { |
923 o = toLayoutScrollbarPart(this)->layoutObjectOwningScrollbar(); | 931 LayoutObject* object = parent(); |
| 932 if (!object && isLayoutScrollbarPart()) |
| 933 object = toLayoutScrollbarPart(this)->layoutObjectOwningScrollbar(); |
924 if (!isTextOrSVGChild()) { | 934 if (!isTextOrSVGChild()) { |
925 if (m_style->position() == FixedPosition) | 935 if (m_style->position() == FixedPosition) { |
926 return containerForFixedPosition(); | 936 return containerForFixedPosition(ancestor, ancestorSkipped, |
927 if (m_style->position() == AbsolutePosition) | 937 filterSkipped); |
928 return containingBlockForAbsolutePosition(); | 938 } |
| 939 if (m_style->position() == AbsolutePosition) { |
| 940 return containingBlockForAbsolutePosition(ancestor, ancestorSkipped, |
| 941 filterSkipped); |
| 942 } |
929 } | 943 } |
930 if (isColumnSpanAll()) { | 944 if (isColumnSpanAll()) { |
931 o = spannerPlaceholder()->containingBlock(); | 945 object = spannerPlaceholder()->containingBlock(); |
932 } else { | 946 } else { |
933 while (o && ((o->isInline() && !o->isAtomicInlineLevel()) || | 947 while (object && ((object->isInline() && !object->isAtomicInlineLevel()) || |
934 !o->isLayoutBlock())) | 948 !object->isLayoutBlock())) { |
935 o = o->parent(); | 949 if (ancestorSkipped && object == ancestor) |
| 950 *ancestorSkipped = true; |
| 951 |
| 952 if (filterSkipped && object->hasFilterInducingProperty()) |
| 953 *filterSkipped = true; |
| 954 object = object->parent(); |
| 955 } |
936 } | 956 } |
937 | 957 |
938 if (!o || !o->isLayoutBlock()) | 958 if (!object || !object->isLayoutBlock()) |
939 return nullptr; // This can still happen in case of an orphaned tree | 959 return nullptr; // This can still happen in case of an orphaned tree |
940 | 960 |
941 return toLayoutBlock(o); | 961 return toLayoutBlock(object); |
942 } | 962 } |
943 | 963 |
944 FloatRect LayoutObject::absoluteBoundingBoxFloatRect() const { | 964 FloatRect LayoutObject::absoluteBoundingBoxFloatRect() const { |
945 Vector<FloatQuad> quads; | 965 Vector<FloatQuad> quads; |
946 absoluteQuads(quads); | 966 absoluteQuads(quads); |
947 | 967 |
948 size_t n = quads.size(); | 968 size_t n = quads.size(); |
949 if (n == 0) | 969 if (n == 0) |
950 return FloatRect(); | 970 return FloatRect(); |
951 | 971 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1022 for (LayoutObject* current = slowFirstChild(); current; | 1042 for (LayoutObject* current = slowFirstChild(); current; |
1023 current = current->nextSibling()) | 1043 current = current->nextSibling()) |
1024 current->addAbsoluteRectForLayer(result); | 1044 current->addAbsoluteRectForLayer(result); |
1025 return result; | 1045 return result; |
1026 } | 1046 } |
1027 | 1047 |
1028 void LayoutObject::paint(const PaintInfo&, const LayoutPoint&) const {} | 1048 void LayoutObject::paint(const PaintInfo&, const LayoutPoint&) const {} |
1029 | 1049 |
1030 const LayoutBoxModelObject& LayoutObject::containerForPaintInvalidation() | 1050 const LayoutBoxModelObject& LayoutObject::containerForPaintInvalidation() |
1031 const { | 1051 const { |
1032 RELEASE_ASSERT(isRooted()); | 1052 CHECK(isRooted()); |
1033 | 1053 |
1034 if (const LayoutBoxModelObject* paintInvalidationContainer = | 1054 if (const LayoutBoxModelObject* paintInvalidationContainer = |
1035 enclosingCompositedContainer()) | 1055 enclosingCompositedContainer()) |
1036 return *paintInvalidationContainer; | 1056 return *paintInvalidationContainer; |
1037 | 1057 |
1038 // If the current frame is not composited, we send just return the main | 1058 // If the current frame is not composited, we send just return the main |
1039 // frame's LayoutView so that we generate invalidations on the window. | 1059 // frame's LayoutView so that we generate invalidations on the window. |
1040 const LayoutView* layoutView = view(); | 1060 const LayoutView* layoutView = view(); |
1041 while ( | 1061 while (const LayoutObject* ownerObject = LayoutAPIShim::constLayoutObjectFrom( |
1042 LayoutAPIShim::layoutObjectFrom(layoutView->frame()->ownerLayoutItem())) | 1062 layoutView->frame()->ownerLayoutItem())) |
1043 layoutView = | 1063 layoutView = ownerObject->view(); |
1044 LayoutAPIShim::layoutObjectFrom(layoutView->frame()->ownerLayoutItem()) | 1064 |
1045 ->view(); | 1065 DCHECK(layoutView); |
1046 ASSERT(layoutView); | |
1047 return *layoutView; | 1066 return *layoutView; |
1048 } | 1067 } |
1049 | 1068 |
1050 const LayoutBoxModelObject* LayoutObject::enclosingCompositedContainer() const { | 1069 const LayoutBoxModelObject* LayoutObject::enclosingCompositedContainer() const { |
1051 LayoutBoxModelObject* container = nullptr; | 1070 LayoutBoxModelObject* container = nullptr; |
1052 // FIXME: CompositingState is not necessarily up to date for many callers of | 1071 // FIXME: CompositingState is not necessarily up to date for many callers of |
1053 // this function. | 1072 // this function. |
1054 DisableCompositingQueryAsserts disabler; | 1073 DisableCompositingQueryAsserts disabler; |
1055 | 1074 |
1056 if (PaintLayer* paintingLayer = this->paintingLayer()) { | 1075 if (PaintLayer* paintingLayer = this->paintingLayer()) { |
(...skipping 1427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2484 } | 2503 } |
2485 | 2504 |
2486 LayoutObject* LayoutObject::container(const LayoutBoxModelObject* ancestor, | 2505 LayoutObject* LayoutObject::container(const LayoutBoxModelObject* ancestor, |
2487 bool* ancestorSkipped, | 2506 bool* ancestorSkipped, |
2488 bool* filterSkipped) const { | 2507 bool* filterSkipped) const { |
2489 if (ancestorSkipped) | 2508 if (ancestorSkipped) |
2490 *ancestorSkipped = false; | 2509 *ancestorSkipped = false; |
2491 if (filterSkipped) | 2510 if (filterSkipped) |
2492 *filterSkipped = false; | 2511 *filterSkipped = false; |
2493 | 2512 |
2494 LayoutObject* o = parent(); | |
2495 | |
2496 if (isTextOrSVGChild()) | 2513 if (isTextOrSVGChild()) |
2497 return o; | 2514 return parent(); |
2498 | 2515 |
2499 EPosition pos = m_style->position(); | 2516 EPosition pos = m_style->position(); |
2500 if (pos == FixedPosition) | 2517 if (pos == FixedPosition) |
2501 return containerForFixedPosition(ancestor, ancestorSkipped, filterSkipped); | 2518 return containerForFixedPosition(ancestor, ancestorSkipped, filterSkipped); |
2502 | 2519 |
2503 if (pos == AbsolutePosition) | 2520 if (pos == AbsolutePosition) { |
2504 return containerForAbsolutePosition(ancestor, ancestorSkipped, | 2521 return containerForAbsolutePosition(ancestor, ancestorSkipped, |
2505 filterSkipped); | 2522 filterSkipped); |
| 2523 } |
2506 | 2524 |
2507 if (isColumnSpanAll()) { | 2525 if (isColumnSpanAll()) { |
2508 LayoutObject* multicolContainer = spannerPlaceholder()->container(); | 2526 LayoutObject* multicolContainer = spannerPlaceholder()->container(); |
2509 if ((ancestorSkipped && ancestor) || filterSkipped) { | 2527 if ((ancestorSkipped && ancestor) || filterSkipped) { |
2510 // We jumped directly from the spanner to the multicol container. Need to | 2528 // We jumped directly from the spanner to the multicol container. Need to |
2511 // check if we skipped |ancestor| or filter/reflection on the way. | 2529 // check if we skipped |ancestor| or filter/reflection on the way. |
2512 for (LayoutObject* walker = parent(); | 2530 for (LayoutObject* walker = parent(); |
2513 walker && walker != multicolContainer; walker = walker->parent()) { | 2531 walker && walker != multicolContainer; walker = walker->parent()) { |
2514 if (ancestorSkipped && walker == ancestor) | 2532 if (ancestorSkipped && walker == ancestor) |
2515 *ancestorSkipped = true; | 2533 *ancestorSkipped = true; |
2516 if (filterSkipped && walker->hasFilterInducingProperty()) | 2534 if (filterSkipped && walker->hasFilterInducingProperty()) |
2517 *filterSkipped = true; | 2535 *filterSkipped = true; |
2518 } | 2536 } |
2519 } | 2537 } |
2520 return multicolContainer; | 2538 return multicolContainer; |
2521 } | 2539 } |
2522 | 2540 |
2523 return o; | 2541 if (isFloating()) |
| 2542 return containingBlock(ancestor, ancestorSkipped, filterSkipped); |
| 2543 |
| 2544 return parent(); |
2524 } | 2545 } |
2525 | 2546 |
2526 inline LayoutObject* LayoutObject::paintInvalidationParent() const { | 2547 inline LayoutObject* LayoutObject::paintInvalidationParent() const { |
2527 if (isLayoutView()) | 2548 if (isLayoutView()) |
2528 return LayoutAPIShim::layoutObjectFrom(frame()->ownerLayoutItem()); | 2549 return LayoutAPIShim::layoutObjectFrom(frame()->ownerLayoutItem()); |
2529 if (isColumnSpanAll()) | 2550 if (isColumnSpanAll()) |
2530 return spannerPlaceholder(); | 2551 return spannerPlaceholder(); |
2531 return parent(); | 2552 return parent(); |
2532 } | 2553 } |
2533 | 2554 |
(...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3512 const blink::LayoutObject* root = object1; | 3533 const blink::LayoutObject* root = object1; |
3513 while (root->parent()) | 3534 while (root->parent()) |
3514 root = root->parent(); | 3535 root = root->parent(); |
3515 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); | 3536 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); |
3516 } else { | 3537 } else { |
3517 WTFLogAlways("%s", "Cannot showLayoutTree. Root is (nil)"); | 3538 WTFLogAlways("%s", "Cannot showLayoutTree. Root is (nil)"); |
3518 } | 3539 } |
3519 } | 3540 } |
3520 | 3541 |
3521 #endif | 3542 #endif |
OLD | NEW |