Title: [208661] trunk/Source/WebCore
- Revision
- 208661
- Author
- [email protected]
- Date
- 2016-11-12 19:08:52 -0800 (Sat, 12 Nov 2016)
Log Message
RenderObject::flowThreadState should follow containing block instead of parent.
https://bugs.webkit.org/show_bug.cgi?id=164629
Reviewed by Simon Fraser.
Currently every descendant of a region/multicolumn container is considered to be part of the
flowthread including out-of-flow renderers. They all have the InsideFlowThread flag set.
However since out-of-flow renderers are not really part of the flowthread layout context,
whenever the layout code actually checks for their flowthread containers, we return nullptr and
try to handle this seemingly defective state gracefully (that is, flag indicates "inside the flow thread" state,
but there's no flow tread container).
This patch fixes this confused state by setting the RenderObject::flowThreadState flag based on
the containing block's state instead of the parent's.
Not testable, since we seem to manage out-of-flow elements just fine even
when they have the InsideFlowThread flag set.
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::styleDidChange):
* rendering/RenderElement.cpp:
(WebCore::RenderElement::setStyle):
(WebCore::RenderElement::adjustFlowThreadStateIncludingDescendants): This is an iterative DFS pre-order traversal so
we set the flow state first on containers.
* rendering/RenderElement.h:
* rendering/RenderObject.cpp:
(WebCore::RenderObject::computedFlowThreadState):
(WebCore::RenderObject::initializeFlowThreadStateOnInsertion):
* rendering/RenderObject.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (208660 => 208661)
--- trunk/Source/WebCore/ChangeLog 2016-11-13 02:43:37 UTC (rev 208660)
+++ trunk/Source/WebCore/ChangeLog 2016-11-13 03:08:52 UTC (rev 208661)
@@ -1,3 +1,35 @@
+2016-11-12 Zalan Bujtas <[email protected]>
+
+ RenderObject::flowThreadState should follow containing block instead of parent.
+ https://bugs.webkit.org/show_bug.cgi?id=164629
+
+ Reviewed by Simon Fraser.
+
+ Currently every descendant of a region/multicolumn container is considered to be part of the
+ flowthread including out-of-flow renderers. They all have the InsideFlowThread flag set.
+ However since out-of-flow renderers are not really part of the flowthread layout context,
+ whenever the layout code actually checks for their flowthread containers, we return nullptr and
+ try to handle this seemingly defective state gracefully (that is, flag indicates "inside the flow thread" state,
+ but there's no flow tread container).
+
+ This patch fixes this confused state by setting the RenderObject::flowThreadState flag based on
+ the containing block's state instead of the parent's.
+
+ Not testable, since we seem to manage out-of-flow elements just fine even
+ when they have the InsideFlowThread flag set.
+
+ * rendering/RenderBlock.cpp:
+ (WebCore::RenderBlock::styleDidChange):
+ * rendering/RenderElement.cpp:
+ (WebCore::RenderElement::setStyle):
+ (WebCore::RenderElement::adjustFlowThreadStateIncludingDescendants): This is an iterative DFS pre-order traversal so
+ we set the flow state first on containers.
+ * rendering/RenderElement.h:
+ * rendering/RenderObject.cpp:
+ (WebCore::RenderObject::computedFlowThreadState):
+ (WebCore::RenderObject::initializeFlowThreadStateOnInsertion):
+ * rendering/RenderObject.h:
+
2016-11-12 Ryosuke Niwa <[email protected]>
document.currentScript should be null when running a script inside a shadow tree
Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (208660 => 208661)
--- trunk/Source/WebCore/rendering/RenderBlock.cpp 2016-11-13 02:43:37 UTC (rev 208660)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp 2016-11-13 03:08:52 UTC (rev 208661)
@@ -427,7 +427,7 @@
RenderBox::styleDidChange(diff, oldStyle);
if (hadTransform != hasTransform())
- resetFlowThreadContainingBlockAndChildInfoIncludingDescendants();
+ adjustFlowThreadStateOnContainingBlockChangeIfNeeded();
auto& newStyle = style();
if (!isAnonymousBlock()) {
Modified: trunk/Source/WebCore/rendering/RenderElement.cpp (208660 => 208661)
--- trunk/Source/WebCore/rendering/RenderElement.cpp 2016-11-13 02:43:37 UTC (rev 208660)
+++ trunk/Source/WebCore/rendering/RenderElement.cpp 2016-11-13 03:08:52 UTC (rev 208661)
@@ -46,6 +46,7 @@
#include "RenderChildIterator.h"
#include "RenderCounter.h"
#include "RenderDeprecatedFlexibleBox.h"
+#include "RenderDescendantIterator.h"
#include "RenderFlexibleBox.h"
#include "RenderImage.h"
#include "RenderImageResourceStyleImage.h"
@@ -411,8 +412,8 @@
// Make sure we invalidate the containing block cache for flows when the contianing block context changes
// so that styleDidChange can safely use RenderBlock::locateFlowThreadContainingBlock()
- if (is<RenderBlock>(*this) && oldStyle.position() != m_style.position())
- downcast<RenderBlock>(*this).resetFlowThreadContainingBlockAndChildInfoIncludingDescendants();
+ if (oldStyle.position() != m_style.position())
+ adjustFlowThreadStateOnContainingBlockChangeIfNeeded();
styleDidChange(diff, &oldStyle);
@@ -2185,6 +2186,21 @@
return (frame().settings().shouldRespectImageOrientation() && is<HTMLImageElement>(element())) ? RespectImageOrientation : DoNotRespectImageOrientation;
}
+void RenderElement::adjustFlowThreadStateOnContainingBlockChangeIfNeeded()
+{
+ if (flowThreadState() == NotInsideFlowThread)
+ return;
+
+ // Invalidate the containing block caches.
+ if (is<RenderBlock>(*this))
+ downcast<RenderBlock>(*this).resetFlowThreadContainingBlockAndChildInfoIncludingDescendants();
+
+ // Adjust the flow tread state on the subtree.
+ setFlowThreadState(RenderObject::computedFlowThreadState(*this));
+ for (auto& descendant : descendantsOfType<RenderObject>(*this))
+ descendant.setFlowThreadState(RenderObject::computedFlowThreadState(descendant));
+}
+
void RenderElement::removeFromRenderFlowThread()
{
ASSERT(flowThreadState() != NotInsideFlowThread);
Modified: trunk/Source/WebCore/rendering/RenderElement.h (208660 => 208661)
--- trunk/Source/WebCore/rendering/RenderElement.h 2016-11-13 02:43:37 UTC (rev 208660)
+++ trunk/Source/WebCore/rendering/RenderElement.h 2016-11-13 03:08:52 UTC (rev 208661)
@@ -281,6 +281,7 @@
void updateOutlineAutoAncestor(bool hasOutlineAuto);
void removeFromRenderFlowThreadIncludingDescendants(bool shouldUpdateState);
+ void adjustFlowThreadStateOnContainingBlockChangeIfNeeded();
private:
RenderElement(ContainerNode&, RenderStyle&&, BaseTypeFlags);
Modified: trunk/Source/WebCore/rendering/RenderObject.cpp (208660 => 208661)
--- trunk/Source/WebCore/rendering/RenderObject.cpp 2016-11-13 02:43:37 UTC (rev 208660)
+++ trunk/Source/WebCore/rendering/RenderObject.cpp 2016-11-13 03:08:52 UTC (rev 208661)
@@ -177,18 +177,36 @@
}
}
+RenderObject::FlowThreadState RenderObject::computedFlowThreadState(const RenderObject& renderer)
+{
+ if (!renderer.parent())
+ return renderer.flowThreadState();
+
+ auto inheritedFlowState = RenderObject::NotInsideFlowThread;
+ if (is<RenderText>(renderer))
+ inheritedFlowState = renderer.parent()->flowThreadState();
+ else if (auto* containingBlock = renderer.containingBlock())
+ inheritedFlowState = containingBlock->flowThreadState();
+ else {
+ // Splitting lines or doing continuation, so just keep the current state.
+ inheritedFlowState = renderer.flowThreadState();
+ }
+ return inheritedFlowState;
+}
+
void RenderObject::initializeFlowThreadStateOnInsertion()
{
ASSERT(parent());
- if (flowThreadState() == parent()->flowThreadState())
- return;
-
// A RenderFlowThread is always considered to be inside itself, so it never has to change its state in response to parent changes.
if (isRenderFlowThread())
return;
- setFlowThreadStateIncludingDescendants(parent()->flowThreadState());
+ auto computedState = computedFlowThreadState(*this);
+ if (flowThreadState() == computedState)
+ return;
+
+ setFlowThreadStateIncludingDescendants(computedState);
}
void RenderObject::resetFlowThreadStateOnRemoval()
Modified: trunk/Source/WebCore/rendering/RenderObject.h (208660 => 208661)
--- trunk/Source/WebCore/rendering/RenderObject.h 2016-11-13 02:43:37 UTC (rev 208660)
+++ trunk/Source/WebCore/rendering/RenderObject.h 2016-11-13 03:08:52 UTC (rev 208661)
@@ -820,6 +820,7 @@
void initializeFlowThreadStateOnInsertion();
void resetFlowThreadStateOnRemoval();
+ static FlowThreadState computedFlowThreadState(const RenderObject&);
private:
#ifndef NDEBUG
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes