Commit e4af0377 authored by kojii's avatar kojii Committed by Commit bot

Mark/unmark orthogonal writing-mode roots when ancestors were changed

When the writing-mode of ancestors of an orthogonal writing-mode root
were changed, the orthogonal writing-mode root may no longer be
orthogonal to its parent. However, since the style of the orthogonal
writing-mode root was not changed, its styleDidChange() is not called
and thus FrameView fails to track it.

This patch checks children to mark or unmark as orthogonal roots when
the writing-mode was changed after they were created.

BUG=584185, 584210

Review URL: https://codereview.chromium.org/1672003002

Cr-Commit-Position: refs/heads/master@{#374794}
parent 09b5446a
<!DOCTYPE html>
<style>
html {
writing-mode:vertical-rl;
}
#h {
writing-mode: horizontal-tb;
}
</style>
<div id="h">Test passes if it does not crash.</div>
<script>
window.onload = function() {
var root = document.documentElement;
root.style.writingMode = "horizontal-tb";
if (window.testRunner)
testRunner.dumpAsText();
}
</script>
......@@ -265,6 +265,11 @@ static bool borderOrPaddingLogicalWidthChanged(const ComputedStyle& oldStyle, co
void LayoutBlock::styleDidChange(StyleDifference diff, const ComputedStyle* oldStyle)
{
// Horizontal writing mode definition is updated in LayoutBoxModelObject::updateFromStyle,
// (as part of the LayoutBoxModelObject::styleDidChange call below). So, we can safely cache the horizontal
// writing mode value before style change here.
bool oldHorizontalWritingMode = isHorizontalWritingMode();
LayoutBox::styleDidChange(diff, oldStyle);
if (isFloatingOrOutOfFlowPositioned() && oldStyle && !oldStyle->isFloating() && !oldStyle->hasOutOfFlowPosition() && parent() && parent()->isLayoutBlockFlow()) {
......@@ -286,6 +291,21 @@ void LayoutBlock::styleDidChange(StyleDifference diff, const ComputedStyle* oldS
if (LayoutBlock* cb = containingBlock())
cb->removePositionedObjects(this, NewContainingBlock);
}
// Changing the writingMode() may change isOrthogonalWritingModeRoot()
// of children. Make sure all children are marked/unmarked as orthogonal
// writing-mode roots.
bool newHorizontalWritingMode = isHorizontalWritingMode();
if (oldHorizontalWritingMode != newHorizontalWritingMode) {
for (LayoutObject* child = firstChild(); child; child = child->nextSibling()) {
if (!child->isBox())
continue;
if (newHorizontalWritingMode != child->isHorizontalWritingMode())
toLayoutBox(child)->markOrthogonalWritingModeRoot();
else
toLayoutBox(child)->unmarkOrthogonalWritingModeRoot();
}
}
}
if (TextAutosizer* textAutosizer = document().textAutosizer())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment