Bug 1347411 part 6. Change stylo to correctly recompute style of column-content anonymous boxes. r=heycam

MozReview-Commit-ID: 2pNOSVUuLJK
This commit is contained in:
Boris Zbarsky 2017-03-15 14:00:43 -04:00
parent fccccf142c
commit a16c017a14
10 changed files with 75 additions and 3 deletions

View File

@ -3329,7 +3329,8 @@ nsCSSFrameConstructor::ConstructFieldSetFrame(nsFrameConstructorState& aState,
if (columns->mColumnCount != NS_STYLE_COLUMN_COUNT_AUTO ||
columns->mColumnWidth.GetUnit() != eStyleUnit_Auto) {
columnSetFrame =
NS_NewColumnSetFrame(mPresShell, fieldsetContentStyle, nsFrameState(0));
NS_NewColumnSetFrame(mPresShell, fieldsetContentStyle,
nsFrameState(NS_FRAME_OWNS_ANON_BOXES));
InitAndRestoreFrame(aState, content, parent, columnSetFrame);
innerSC = mPresShell->StyleSet()->
ResolveInheritingAnonymousBoxStyle(nsCSSAnonBoxes::columnContent,
@ -3978,7 +3979,8 @@ nsCSSFrameConstructor::ConstructFrameFromItemInternal(FrameConstructionItem& aIt
if (columns->mColumnCount != NS_STYLE_COLUMN_COUNT_AUTO ||
columns->mColumnWidth.GetUnit() != eStyleUnit_Auto) {
columnSetFrame =
NS_NewColumnSetFrame(mPresShell, outerSC, nsFrameState(0));
NS_NewColumnSetFrame(mPresShell, outerSC,
nsFrameState(NS_FRAME_OWNS_ANON_BOXES));
InitAndRestoreFrame(aState, content, container, columnSetFrame);
innerSC = mPresShell->StyleSet()->
ResolveInheritingAnonymousBoxStyle(nsCSSAnonBoxes::columnContent,
@ -12041,7 +12043,8 @@ nsCSSFrameConstructor::ConstructBlock(nsFrameConstructorState& aState,
if (columns->mColumnCount != NS_STYLE_COLUMN_COUNT_AUTO
|| columns->mColumnWidth.GetUnit() != eStyleUnit_Auto) {
nsContainerFrame* columnSetFrame =
NS_NewColumnSetFrame(mPresShell, aStyleContext, nsFrameState(0));
NS_NewColumnSetFrame(mPresShell, aStyleContext,
nsFrameState(NS_FRAME_OWNS_ANON_BOXES));
InitAndRestoreFrame(aState, aContent, aParentFrame, columnSetFrame);
blockStyle = mPresShell->StyleSet()->

View File

@ -1139,6 +1139,26 @@ nsColumnSetFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
}
}
void
nsColumnSetFrame::DoUpdateStyleOfOwnedAnonBoxes(
mozilla::ServoStyleSet& aStyleSet,
nsStyleChangeList& aChangeList,
nsChangeHint aHintForThisFrame)
{
// Everything in mFrames is continuations of the first thing in mFrames.
nsIFrame* column = mFrames.FirstChild();
// We might not have any columns, apparently?
if (!column) {
return;
}
MOZ_ASSERT(column->StyleContext()->GetPseudo() ==
nsCSSAnonBoxes::columnContent,
"What sort of child is this?");
UpdateStyleOfChildAnonBox(column, aStyleSet, aChangeList, aHintForThisFrame);
}
#ifdef DEBUG
void
nsColumnSetFrame::SetInitialChildList(ChildListID aListID,

View File

@ -83,6 +83,13 @@ public:
*/
void DrainOverflowColumns();
/**
* Update the style on our column-content frames.
*/
void DoUpdateStyleOfOwnedAnonBoxes(mozilla::ServoStyleSet& aStyleSet,
nsStyleChangeList& aChangeList,
nsChangeHint aHintForThisFrame) override;
#ifdef DEBUG_FRAME_DUMP
virtual nsresult GetFrameName(nsAString& aResult) const override {
return MakeFrameName(NS_LITERAL_STRING("ColumnSet"), aResult);

View File

@ -10069,6 +10069,8 @@ nsFrame::UpdateStyleOfChildAnonBox(nsIFrame* aChildFrame,
"This should only be used for children!");
MOZ_ASSERT(aChildFrame->GetContent() == GetContent(),
"What content node is it a frame for?");
MOZ_ASSERT(!aChildFrame->GetPrevContinuation(),
"Only first continuations should end up here");
// We could force the caller to pass in the pseudo, since some callers know it
// statically... But this API is a bit nicer.

View File

@ -0,0 +1,4 @@
<!DOCTYPE html>
<div style="column-count: 2; width: 200px; text-indent: 50px">
This is some text that is too long and it will overflow.
</div>

View File

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html class="reftest-wait">
<div style="column-count: 2; width: 200px;">
This is some text that is too long and it will overflow.
</div>
<script>
onload = function() {
var d = document.querySelector("div");
window.w = d.offsetWidth;
d.style.textIndent = "50px";
document.documentElement.className = "";
}
</script>
</html>

View File

@ -0,0 +1,4 @@
<!DOCTYPE html>
<fieldset style="column-count: 2; width: 200px; border: none; text-indent: 50px">
This is some text that is too long and it will overflow.
</fieldset>

View File

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html class="reftest-wait">
<fieldset style="column-count: 2; width: 200px; border: none">
This is some text that is too long and it will overflow.
</fieldset>
<script>
onload = function() {
var f = document.querySelector("fieldset");
window.w = f.offsetWidth;
f.style.textIndent = "50px";
document.documentElement.className = "";
}
</script>
</html>

View File

@ -37,3 +37,5 @@ fails == column-balancing-nested-001.html column-balancing-nested-001.html
== positioning-transforms-bug1112501.html positioning-transforms-bug1112501.html
== fieldset-columns-001.html fieldset-columns-001.html
== dynamic-change-with-overflow-1.html dynamic-change-with-overflow-1.html
== dynamic-text-indent-1.html dynamic-text-indent-1.html
== dynamic-text-indent-2.html dynamic-text-indent-2.html

View File

@ -36,3 +36,5 @@ HTTP(..) == columnfill-auto-3.html columnfill-auto-2-ref.html
== positioning-transforms-bug1112501.html positioning-transforms-bug1112501-ref.html
fuzzy-if(browserIsRemote&&winWidget,140,276) == fieldset-columns-001.html fieldset-columns-001-ref.html
== dynamic-change-with-overflow-1.html dynamic-change-with-overflow-1-ref.html
== dynamic-text-indent-1.html dynamic-text-indent-1-ref.html
== dynamic-text-indent-2.html dynamic-text-indent-2-ref.html