Bug 1426747 - Remove the IE compat quirk for <table align=left>. r=emilio

Chrome and Safari don't implement this quirk.

Differential Revision: https://phabricator.services.mozilla.com/D94330
This commit is contained in:
Mats Palmgren 2020-10-21 16:31:29 +00:00
Родитель d9fb1ffd72
Коммит 5f553183fe
6 изменённых файлов: 82 добавлений и 90 удалений

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

@ -719,7 +719,7 @@ bool BlockReflowInput::FlowAndPlaceFloat(nsIFrame* aFloat) {
nsFlowAreaRect floatAvailableSpace =
GetFloatAvailableSpaceForPlacingFloat(mBCoord);
LogicalRect adjustedAvailableSpace = mBlock->AdjustFloatAvailableSpace(
*this, floatAvailableSpace.mRect, aFloat);
*this, floatAvailableSpace.mRect);
NS_ASSERTION(aFloat->GetParent() == mBlock, "Float frame has wrong parent");
@ -758,9 +758,6 @@ bool BlockReflowInput::FlowAndPlaceFloat(nsIFrame* aFloat) {
MOZ_ASSERT(StyleFloat::Left == floatStyle || StyleFloat::Right == floatStyle,
"Invalid float type!");
// Can the float fit here?
bool keepFloatOnSameLine = false;
// Are we required to place at least part of the float because we're
// at the top of the page (to avoid an infinite loop of pushing and
// breaking).
@ -780,63 +777,11 @@ bool BlockReflowInput::FlowAndPlaceFloat(nsIFrame* aFloat) {
}
// Nope. try to advance to the next band.
if (StyleDisplay::Table != floatDisplay->mDisplay ||
eCompatibility_NavQuirks != mPresContext->CompatibilityMode()) {
mBCoord += floatAvailableSpace.mRect.BSize(wm);
if (adjustedAvailableSpace.BSize(wm) != NS_UNCONSTRAINEDSIZE) {
adjustedAvailableSpace.BSize(wm) -= floatAvailableSpace.mRect.BSize(wm);
}
floatAvailableSpace = GetFloatAvailableSpaceForPlacingFloat(mBCoord);
} else {
// This quirk matches the one in nsBlockFrame::AdjustFloatAvailableSpace
// IE handles float tables in a very special way
// see if the previous float is also a table and has "align"
nsFloatCache* fc = mCurrentLineFloats.Head();
nsIFrame* prevFrame = nullptr;
while (fc) {
if (fc->mFloat == aFloat) {
break;
}
prevFrame = fc->mFloat;
fc = fc->Next();
}
if (prevFrame) {
// get the frame type
if (prevFrame->IsTableWrapperFrame()) {
// see if it has "align="
// IE makes a difference between align and the float property.
//
// We're interested only if previous frame is align=left IE messes
// things up when "right" (overlapping frames).
//
// FIXME(emilio, bug 1426747): This looks fishy.
nsIContent* content = prevFrame->GetContent();
if (content && content->IsElement() &&
content->AsElement()->AttrValueIs(kNameSpaceID_None,
nsGkAtoms::align, u"left"_ns,
eIgnoreCase)) {
keepFloatOnSameLine = true;
// don't advance to next line (IE quirkie behaviour)
// it breaks rule CSS2/9.5.1/1, but what the hell
// since we cannot evangelize the world
break;
}
}
}
// the table does not fit anymore in this line so advance to next band
mBCoord += floatAvailableSpace.mRect.BSize(wm);
// To match nsBlockFrame::AdjustFloatAvailableSpace, we have to
// get a new width for the new band.
floatAvailableSpace = GetFloatAvailableSpaceForPlacingFloat(mBCoord);
adjustedAvailableSpace = mBlock->AdjustFloatAvailableSpace(
*this, floatAvailableSpace.mRect, aFloat);
floatMarginISize = FloatMarginISize(
mReflowInput, adjustedAvailableSpace.ISize(wm), aFloat, offsets);
mBCoord += floatAvailableSpace.mRect.BSize(wm);
if (adjustedAvailableSpace.BSize(wm) != NS_UNCONSTRAINEDSIZE) {
adjustedAvailableSpace.BSize(wm) -= floatAvailableSpace.mRect.BSize(wm);
}
floatAvailableSpace = GetFloatAvailableSpaceForPlacingFloat(mBCoord);
mustPlaceFloat = false;
}
@ -855,14 +800,7 @@ bool BlockReflowInput::FlowAndPlaceFloat(nsIFrame* aFloat) {
if (leftFloat == wm.IsBidiLTR()) {
floatPos.I(wm) = floatAvailableSpace.mRect.IStart(wm);
} else {
if (!keepFloatOnSameLine) {
floatPos.I(wm) = floatAvailableSpace.mRect.IEnd(wm) - floatMarginISize;
} else {
// this is the IE quirk (see few lines above)
// the table is kept in the same line: don't let it overlap the
// previous float
floatPos.I(wm) = floatAvailableSpace.mRect.IStart(wm);
}
floatPos.I(wm) = floatAvailableSpace.mRect.IEnd(wm) - floatMarginISize;
}
// CSS2 spec, 9.5.1 rule [4]: "A floating box's outer top may not
// be higher than the top of its containing block." (Since the

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

@ -6525,31 +6525,15 @@ const nsStyleText* nsBlockFrame::StyleTextForLineLayout() {
// Float support
LogicalRect nsBlockFrame::AdjustFloatAvailableSpace(
BlockReflowInput& aState, const LogicalRect& aFloatAvailableSpace,
nsIFrame* aFloatFrame) {
// Compute the available inline size. By default, assume the inline
// size of the containing block.
nscoord availISize;
const nsStyleDisplay* floatDisplay = aFloatFrame->StyleDisplay();
BlockReflowInput& aState, const LogicalRect& aFloatAvailableSpace) {
WritingMode wm = aState.mReflowInput.GetWritingMode();
if (mozilla::StyleDisplay::Table != floatDisplay->mDisplay ||
eCompatibility_NavQuirks != aState.mPresContext->CompatibilityMode()) {
availISize = aState.ContentISize();
} else {
// This quirk matches the one in BlockReflowInput::FlowAndPlaceFloat
// give tables only the available space
// if they can shrink we may not be constrained to place
// them in the next line
availISize = aFloatAvailableSpace.ISize(wm);
}
nscoord availBSize = NS_UNCONSTRAINEDSIZE == aState.ContentBSize()
? NS_UNCONSTRAINEDSIZE
: std::max(0, aState.ContentBEnd() - aState.mBCoord);
return LogicalRect(wm, aState.ContentIStart(), aState.ContentBStart(),
availISize, availBSize);
aState.ContentISize(), availBSize);
}
nscoord nsBlockFrame::ComputeFloatISize(BlockReflowInput& aState,
@ -6560,7 +6544,7 @@ nscoord nsBlockFrame::ComputeFloatISize(BlockReflowInput& aState,
// Reflow the float.
LogicalRect availSpace =
AdjustFloatAvailableSpace(aState, aFloatAvailableSpace, aFloat);
AdjustFloatAvailableSpace(aState, aFloatAvailableSpace);
WritingMode blockWM = aState.mReflowInput.GetWritingMode();
WritingMode floatWM = aFloat->GetWritingMode();

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

@ -752,10 +752,10 @@ class nsBlockFrame : public nsContainerFrame {
LineIterator aLine, nsIFrame* aFrame,
LineReflowStatus* aLineReflowStatus);
// Compute the available inline size for a float.
// Compute the available size for a float.
mozilla::LogicalRect AdjustFloatAvailableSpace(
BlockReflowInput& aState,
const mozilla::LogicalRect& aFloatAvailableSpace, nsIFrame* aFloatFrame);
const mozilla::LogicalRect& aFloatAvailableSpace);
// Computes the border-box inline size of the float
nscoord ComputeFloatISize(BlockReflowInput& aState,
const mozilla::LogicalRect& aFloatAvailableSpace,

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

@ -2,7 +2,7 @@
<body style="width:400px;">
<div style="float:left; width:200px; height:100px; background:yellow;"></div>
Hello
<table style="width:200px;"><tr><td>
<br clear=all><table><tr><td>
This is some very long text. This is some very long text.
This is some very long text. This is some very long text.
This is some very long text. This is some very long text.

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

@ -0,0 +1,34 @@
<!-- intentionally quirks mode -->
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<html><head>
<title>Reference: Check that the old IE quirk for &lt;table align=left&gt; is NOT implemented</title>
<meta name="assert" content="1 and 2 should all be on separate lines below.">
<link rel="author" title="Mats Palmgren" href="mailto:mats@mozilla.com">
</head>
<body>
<div style="width:0">
<table><td>1</td></table>
<table><td>2</td></table>
</div>
<div style="width:0">
<table><td>1</td></table>
<table><td>2</td></table>
</div>
<div style="width:0">
<table><td>1</td></table>
<table><td>2</td></table>
</div>
<div style="width:0">
<table><td>1</td></table>
<table><td>2</td></table>
</div>
</body>
</html>

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

@ -0,0 +1,36 @@
<!-- intentionally quirks mode -->
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<html><head>
<title>CSS2: Check that the old IE quirk for &lt;table align=left&gt; is NOT implemented</title>
<meta name="assert" content="1 and 2 should all be on separate lines below.">
<link rel="author" title="Mats Palmgren" href="mailto:mats@mozilla.com">
<link rel="help" href="http://www.w3.org/TR/CSS21/visuren.html#floats" />
<link rel="match" href="float-table-align-left-quirk-ref.html">
</head>
<body>
<div style="width:0">
<table align="left"><td>1</td></table>
<table align="left"><td>2</td></table>
</div>
<div style="width:0">
<table align="left"><td>1</td></table>
<table style="float:left"><td>2</td></table>
</div>
<div style="width:0">
<table style="float:left"><td>1</td></table>
<table align="left"><td>2</td></table>
</div>
<div style="width:0">
<table style="float:left"><td>1</td></table>
<table style="float:left"><td>2</td></table>
</div>
</body>
</html>