Title: [277698] trunk/Source/WebCore
- Revision
- 277698
- Author
- [email protected]
- Date
- 2021-05-18 17:26:11 -0700 (Tue, 18 May 2021)
Log Message
The containing block for a fixed renderer has to be a type of RenderBlock
https://bugs.webkit.org/show_bug.cgi?id=225924
<rdar://77968716>
Reviewed by Simon Fraser.
While an atomic inline level box with layout containment can certainly be the containing block for fixed (and absolute) boxes,
the current render tree logic requires a containing block to be the type of RenderBlock.
* rendering/RenderElement.cpp:
(WebCore::nearestNonAnonymousContainingBlockIncludingSelf): make this function static so that we can call it from containingBlockForFixedPosition()
(WebCore::RenderElement::containingBlockForFixedPosition const):
(WebCore::RenderElement::containingBlockForAbsolutePosition const):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (277697 => 277698)
--- trunk/Source/WebCore/ChangeLog 2021-05-18 23:55:58 UTC (rev 277697)
+++ trunk/Source/WebCore/ChangeLog 2021-05-19 00:26:11 UTC (rev 277698)
@@ -1,3 +1,19 @@
+2021-05-18 Alan Bujtas <[email protected]>
+
+ The containing block for a fixed renderer has to be a type of RenderBlock
+ https://bugs.webkit.org/show_bug.cgi?id=225924
+ <rdar://77968716>
+
+ Reviewed by Simon Fraser.
+
+ While an atomic inline level box with layout containment can certainly be the containing block for fixed (and absolute) boxes,
+ the current render tree logic requires a containing block to be the type of RenderBlock.
+
+ * rendering/RenderElement.cpp:
+ (WebCore::nearestNonAnonymousContainingBlockIncludingSelf): make this function static so that we can call it from containingBlockForFixedPosition()
+ (WebCore::RenderElement::containingBlockForFixedPosition const):
+ (WebCore::RenderElement::containingBlockForAbsolutePosition const):
+
2021-05-18 Simon Fraser <[email protected]>
Layer names should not contain object addresses in release builds
Modified: trunk/Source/WebCore/rendering/RenderElement.cpp (277697 => 277698)
--- trunk/Source/WebCore/rendering/RenderElement.cpp 2021-05-18 23:55:58 UTC (rev 277697)
+++ trunk/Source/WebCore/rendering/RenderElement.cpp 2021-05-19 00:26:11 UTC (rev 277698)
@@ -621,24 +621,23 @@
return RenderPtr<RenderObject>(&renderer);
}
-RenderBlock* RenderElement::containingBlockForFixedPosition() const
+static inline RenderBlock* nearestNonAnonymousContainingBlockIncludingSelf(RenderElement* renderer)
{
- auto* renderer = parent();
- while (renderer && !renderer->canContainFixedPositionObjects())
- renderer = renderer->parent();
-
- ASSERT(!renderer || !renderer->isAnonymousBlock());
+ while (renderer && (!is<RenderBlock>(*renderer) || renderer->isAnonymousBlock()))
+ renderer = renderer->containingBlock();
return downcast<RenderBlock>(renderer);
}
+RenderBlock* RenderElement::containingBlockForFixedPosition() const
+{
+ auto* ancestor = parent();
+ while (ancestor && !ancestor->canContainFixedPositionObjects())
+ ancestor = ancestor->parent();
+ return nearestNonAnonymousContainingBlockIncludingSelf(ancestor);
+}
+
RenderBlock* RenderElement::containingBlockForAbsolutePosition() const
{
- auto nearestNonAnonymousContainingBlockIncludingSelf = [&] (auto* renderer) {
- while (renderer && (!is<RenderBlock>(*renderer) || renderer->isAnonymousBlock()))
- renderer = renderer->containingBlock();
- return downcast<RenderBlock>(renderer);
- };
-
if (is<RenderInline>(*this) && style().position() == PositionType::Relative) {
// A relatively positioned RenderInline forwards its absolute positioned descendants to
// its nearest non-anonymous containing block (to avoid having positioned objects list in RenderInlines).
Modified: trunk/Source/WebCore/rendering/RenderElement.h (277697 => 277698)
--- trunk/Source/WebCore/rendering/RenderElement.h 2021-05-18 23:55:58 UTC (rev 277697)
+++ trunk/Source/WebCore/rendering/RenderElement.h 2021-05-19 00:26:11 UTC (rev 277698)
@@ -73,6 +73,7 @@
RenderObject* firstInFlowChild() const;
RenderObject* lastInFlowChild() const;
+ // Note that even if these 2 "canContain" functions return true for a particular renderer, it does not necessarily mean the renderer is the containing block (see containingBlockForAbsolute(Fixed)Position).
bool canContainFixedPositionObjects() const;
bool canContainAbsolutelyPositionedObjects() const;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes