Bug 718157 - Fix dynamic changes of percentage text-indent when the parent's size changes and the element's size does not. r=jfkthame

This code needs to move out of PrepareResizeReflow() (and things that
trigger code in it) because PrepareResizeReflow is conditioned on the
block itself resizing.

The reftest is based on a test by Jesse Ruderman <jruderman@gmail.com>.

The reftest fails without the patch and passes with the patch.

--HG--
extra : transplant_source : %E9%5E%97zE%A4%60n%8C%DD%F8K-%01%F3fF%E8%C9K
This commit is contained in:
L. David Baron 2015-02-11 22:43:05 +11:00
Родитель 1feca4bc89
Коммит bada98f01b
5 изменённых файлов: 36 добавлений и 4 удалений

Просмотреть файл

@ -1141,6 +1141,16 @@ nsBlockFrame::Reflow(nsPresContext* aPresContext,
PrepareResizeReflow(state);
}
// The same for percentage text-indent, except conditioned on the
// parent resizing.
if (!(GetStateBits() & NS_FRAME_IS_DIRTY) &&
reflowState->mCBReflowState &&
reflowState->mCBReflowState->IsIResize() &&
reflowState->mStyleText->mTextIndent.HasPercent() &&
!mLines.empty()) {
mLines.front()->MarkDirty();
}
LazyMarkLinesDirty();
mState &= ~NS_FRAME_FIRST_REFLOW;

Просмотреть файл

@ -241,10 +241,6 @@ nsLineLayout::BeginLineReflow(nscoord aICoord, nscoord aBCoord,
if (textIndent.HasPercent()) {
pctBasis =
nsHTMLReflowState::GetContainingBlockContentWidth(mBlockReflowState);
if (mGotLineBox) {
mLineBox->DisableResizeReflowOptimization();
}
}
nscoord indent = nsRuleNode::ComputeCoordPercentCalc(textIndent, pctBasis);

Просмотреть файл

@ -16,3 +16,4 @@
== text-indent-intrinsic-min.html text-indent-intrinsic-min-ref.html
== text-indent-negative-intrinsic-pref.html text-indent-negative-intrinsic-pref-ref.html
== text-indent-negative-intrinsic-min.html text-indent-negative-intrinsic-min-ref.html
== text-indent-parent-dynamic.html text-indent-parent-dynamic-ref.html

Просмотреть файл

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<body>
<div id="x" style="background: lightgreen; height: 3em; width: 500px; padding: 4px;">
<div style="text-indent: 200px; width: 200px; background: yellow;">X</div>
</div>
</body>
</html>

Просмотреть файл

@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<body>
<div id="x" style="background: lightgreen; height: 3em; width: 400px; padding: 4px;">
<div style="text-indent: 40%; width: 200px; background: yellow;">X</div>
</div>
<script>
var x = document.getElementById('x');
x.offsetWidth;
x.style.width = '500px';
</script>
</body>
</html>