Only try to process first-letter frames when they exist. Bug 404209, r+sr+b=roc

This commit is contained in:
smontagu@smontagu.org 2007-12-05 00:15:15 -08:00
parent b60b7f31eb
commit fdfed24896
6 changed files with 63 additions and 3 deletions

View File

@ -12066,6 +12066,7 @@ nsCSSFrameConstructor::CreateLetterFrame(nsFrameConstructorState& aState,
letterFrame->SetInitialChildList(nsnull, textFrame);
aResult.childList = aResult.lastChild = letterFrame;
aBlockFrame->AddStateBits(NS_BLOCK_HAS_FIRST_LETTER_CHILD);
}
}
}
@ -12356,6 +12357,7 @@ nsCSSFrameConstructor::RemoveFirstLetterFrames(nsPresContext* aPresContext,
aFrameManager->InsertFrames(aFrame, nsnull, prevSibling, textFrame);
*aStopLooking = PR_TRUE;
aFrame->RemoveStateBits(NS_BLOCK_HAS_FIRST_LETTER_CHILD);
break;
}
else if (IsInlineFrame(kid)) {

View File

@ -85,6 +85,7 @@ _TEST_FILES = \
test_bug388019.html \
test_bug399284.html \
test_bug399951.html \
test_bug404209.xhtml \
$(NULL)
libs:: $(_TEST_FILES)

View File

@ -0,0 +1,47 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=404209
-->
<head>
<title>Test for Bug 404209</title>
<script type="text/javascript" src="/MochiKit/packed.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<style type="text/css">
div::first-letter { color: green; }
</style>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=404209">Mozilla Bug 404209</a>
<table id="table" dir="rtl"><div><span id="v"><span><tfoot></tfoot>abcd</span></span></div></table>
<pre id="test">
<script class="testbody" type="text/javascript">
function boom1()
{
document.getElementById("table").style.borderRight = "1px solid magenta";
setTimeout(boom2, 400);
}
function boom2()
{
var v = document.getElementById("v");
var newTD = document.createElementNS("http://www.w3.org/1999/xhtml", "td");
newTD.setAttribute("width", "13%");
v.insertBefore(newTD, v.firstChild);
setTimeout(lastTest, 400);
}
function lastTest()
{
/** Test for Bug 404209 **/
ok(true, "Should not crash");
SimpleTest.finish();
}
setTimeout(boom1, 400);
SimpleTest.waitForExplicitFinish();
</script>
</pre>
</body>
</html>

View File

@ -3366,6 +3366,7 @@ nsBlockFrame::DoReflowInlineFrames(nsBlockReflowState& aState,
// XXX Unfortunately we need to know this before reflowing the first
// inline frame in the line. FIX ME.
if ((0 == aLineLayout.GetLineNumber()) &&
(NS_BLOCK_HAS_FIRST_LETTER_CHILD & mState) &&
(NS_BLOCK_HAS_FIRST_LETTER_STYLE & mState)) {
aLineLayout.SetFirstLetterStyleOK(PR_TRUE);
}

View File

@ -61,12 +61,21 @@ class nsTableColFrame;
/**
* Additional frame-state bits used by nsBlockFrame
* See the meanings at http://www.mozilla.org/newlayout/doc/block-and-line.html
*
* NS_BLOCK_HAS_FIRST_LETTER_STYLE means that the block has first-letter style,
* even if it has no actual first-letter frame among its descendants.
*
* NS_BLOCK_HAS_FIRST_LETTER_CHILD means that there is an inflow first-letter
* frame among the block's descendants. If there is a floating first-letter
* frame, or the block has first-letter style but has no first letter, this
* bit is not set.
*/
#define NS_BLOCK_NO_AUTO_MARGINS 0x00200000
#define NS_BLOCK_MARGIN_ROOT 0x00400000
#define NS_BLOCK_SPACE_MGR 0x00800000
#define NS_BLOCK_HAS_FIRST_LETTER_STYLE 0x20000000
#define NS_BLOCK_FRAME_HAS_OUTSIDE_BULLET 0x40000000
#define NS_BLOCK_HAS_FIRST_LETTER_CHILD 0x80000000
// These are the bits that get inherited from a block frame to its
// next-in-flows and are not private to blocks
#define NS_BLOCK_FLAGS_MASK 0xF0E00000

View File

@ -917,9 +917,9 @@ nsLineLayout::ReflowFrame(nsIFrame* aFrame,
else {
placedFloat = AddFloat(placeholder, aReflowStatus);
}
if (outOfFlowFrame->GetType() == nsGkAtoms::letterFrame) {
SetFlag(LL_FIRSTLETTERSTYLEOK, PR_FALSE);
}
NS_ASSERTION(!(outOfFlowFrame->GetType() == nsGkAtoms::letterFrame &&
GetFirstLetterStyleOK()),
"FirstLetterStyle set on line with floating first letter");
}
}
else if (nsGkAtoms::textFrame == frameType) {