Bug 740743 - Implement CSS overflow for <legend>. r=bz

This commit is contained in:
Mats Palmgren 2012-04-13 17:52:13 +02:00
Родитель 163749cf99
Коммит f4490cde11
6 изменённых файлов: 204 добавлений и 14 удалений

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

@ -3178,16 +3178,16 @@ nsCSSFrameConstructor::ConstructFieldSetFrame(nsFrameConstructorState& aState,
fieldsetKids.AddChild(blockFrame);
for (nsFrameList::Enumerator e(childItems); !e.AtEnd(); e.Next()) {
nsLegendFrame* legendFrame = do_QueryFrame(e.get());
if (legendFrame) {
nsIFrame* child = e.get();
if (child->GetContentInsertionFrame()->GetType() == nsGkAtoms::legendFrame) {
// We want the legend to be the first frame in the fieldset child list.
// That way the EventStateManager will do the right thing when tabbing
// from a selection point within the legend (bug 236071), which is
// used for implementing legend access keys (bug 81481).
// GetAdjustedParentFrame() below depends on this frame order.
childItems.RemoveFrame(legendFrame);
childItems.RemoveFrame(child);
// Make sure to reparent the legend so it has the fieldset as the parent.
fieldsetKids.InsertFrame(newFrame, nsnull, legendFrame);
fieldsetKids.InsertFrame(newFrame, nsnull, child);
break;
}
}
@ -3414,7 +3414,8 @@ nsCSSFrameConstructor::FindHTMLData(Element* aElement,
COMPLEX_TAG_CREATE(fieldset,
&nsCSSFrameConstructor::ConstructFieldSetFrame),
{ &nsGkAtoms::legend,
FCDATA_DECL(FCDATA_ALLOW_BLOCK_STYLES, NS_NewLegendFrame) },
FCDATA_DECL(FCDATA_ALLOW_BLOCK_STYLES | FCDATA_MAY_NEED_SCROLLFRAME,
NS_NewLegendFrame) },
SIMPLE_TAG_CREATE(frameset, NS_NewHTMLFramesetFrame),
SIMPLE_TAG_CREATE(iframe, NS_NewSubDocumentFrame),
{ &nsGkAtoms::button,
@ -5813,7 +5814,7 @@ nsCSSFrameConstructor::IsValidSibling(nsIFrame* aSibling,
(nsGkAtoms::fieldSetFrame == grandparentType &&
nsGkAtoms::blockFrame == parentType)) {
// Legends can be sibling of legends but not of other content in the fieldset
nsIAtom* sibType = aSibling->GetType();
nsIAtom* sibType = aSibling->GetContentInsertionFrame()->GetType();
nsCOMPtr<nsIDOMHTMLLegendElement> legendContent(do_QueryInterface(aContent));
if ((legendContent && (nsGkAtoms::legendFrame != sibType)) ||
@ -8900,7 +8901,7 @@ nsCSSFrameConstructor::MaybeRecreateContainerForFrameRemoval(nsIFrame* aFrame,
return true;
}
if (aFrame->GetType() == nsGkAtoms::legendFrame &&
if (aFrame->GetContentInsertionFrame()->GetType() == nsGkAtoms::legendFrame &&
aFrame->GetParent()->GetType() == nsGkAtoms::fieldSetFrame) {
// When we remove the legend for a fieldset, we should reframe
// the fieldset to ensure another legend is used, if there is one

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

@ -126,6 +126,8 @@ protected:
virtual PRIntn GetSkipSides() const;
void ReparentFrameList(const nsFrameList& aFrameList);
// mLegendFrame is a nsLegendFrame or a nsHTMLScrollFrame with the
// nsLegendFrame as the scrolled frame (aka content insertion frame).
nsIFrame* mLegendFrame;
nsIFrame* mContentFrame;
nsRect mLegendRect;
@ -560,7 +562,8 @@ nsFieldSetFrame::Reflow(nsPresContext* aPresContext,
if (mLegendFrame) {
// if the content rect is larger then the legend we can align the legend
if (contentRect.width > mLegendRect.width) {
PRInt32 align = static_cast<nsLegendFrame*>(mLegendFrame)->GetAlign();
PRInt32 align = static_cast<nsLegendFrame*>
(mLegendFrame->GetContentInsertionFrame())->GetAlign();
switch(align) {
case NS_STYLE_TEXT_ALIGN_RIGHT:

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

@ -1873,13 +1873,16 @@ nsHTMLReflowState::InitConstraints(nsPresContext* aPresContext,
} else {
AutoMaybeNullInflationContainer an(frame);
bool isBlock =
NS_CSS_FRAME_TYPE_BLOCK == NS_FRAME_GET_TYPE(mFrameType);
// make sure legend frames with display:block and width:auto still
// shrink-wrap
bool isBlock = NS_CSS_FRAME_TYPE_BLOCK == NS_FRAME_GET_TYPE(mFrameType);
PRUint32 computeSizeFlags = isBlock ? 0 : nsIFrame::eShrinkWrap;
PRUint32 computeSizeFlags = 0;
if (!isBlock || aFrameType == nsGkAtoms::legendFrame) {
// Make sure legend frames with display:block and width:auto still
// shrink-wrap.
if (isBlock &&
((aFrameType == nsGkAtoms::legendFrame &&
frame->GetStyleContext()->GetPseudo() != nsCSSAnonBoxes::scrolledContent) ||
(aFrameType == nsGkAtoms::scrollFrame &&
frame->GetContentInsertionFrame()->GetType() == nsGkAtoms::legendFrame))) {
computeSizeFlags |= nsIFrame::eShrinkWrap;
}

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

@ -0,0 +1,94 @@
<!DOCTYPE HTML>
<html><head>
<title>Testcase for bug 740743</title>
<style type="text/css">
html,body {
color:black; background-color:white; font-size:16px; padding:0; margin:0;
}
fieldset { padding: 2px; }
legend { padding: 0; }
span { background: lime; display: block;}
legend > span {
padding-left: 2px;
padding-right: 2px;
}
.s10 { width:10px; height:10px; }
.h10 { height:10px; }
.w50 { width:50px; }
.hidden { overflow:hidden; }
.scroll { overflow:scroll; }
.auto { overflow:auto; }
.o { text-overflow: ellipsis; }
#inline span { display:inline; }
#inline-block span { display:inline-block; }
</style>
</head>
<body>
<fieldset><legend><span class="hidden s10"><b>Legend Test</b></span></legend></fieldset>
<fieldset><legend><span class="scroll s10">Legend Test</span></legend></fieldset>
<fieldset><legend><span class="auto s10">Legend Test</span></legend></fieldset>
<fieldset><legend><span class="hidden w50"><b>Legend Test</b></span></legend></fieldset>
<fieldset><legend><span class="scroll w50">Legend Test</span></legend></fieldset>
<fieldset><legend><span class="auto w50"><b>Legend Test</b></span></legend></fieldset>
<fieldset><legend><span class="hidden">Legend Test</span></legend></fieldset>
<fieldset><legend><span class="auto"><b>Legend Test</b></span></legend></fieldset>
<fieldset><legend><span class="auto"><b>Legend Test</b></span></legend></fieldset>
<fieldset><legend><span class="auto"><b>Legend Test</b></span></legend></fieldset>
<fieldset><legend><span class="hidden w50 o"><b>Legend Test</b></span></legend></fieldset>
<fieldset><legend><span class="hidden w50 o">Test Legend</span></legend></fieldset>
<fieldset><legend><span class="hidden o">Test Legend</span></legend></fieldset>
<fieldset><legend><span class="auto w50 o"><b>Legend Test</b></span></legend></fieldset>
<fieldset><legend align="right"><span class="hidden w50 o">Test Legend</span></legend></fieldset>
<fieldset><legend align="center"><span class="hidden w50 o">Test Legend</span></legend></fieldset>
<div id="inline">
<span class="hidden s10"><b>Legend Test</b></span>
<span class="scroll s10">Legend Test</span>
<span class="auto s10">Legend Test</span>
<span class="hidden w50"><b>Legend Test</b></span>
<span class="scroll w50">Legend Test</span>
<span class="auto w50"><b>Legend Test</b></span>
<span class="hidden">Legend Test</span>
<span class="auto"><b>Legend Test</b></span>
<span class="hidden w50 o"><b>Legend Test</b></span>
<span class="hidden w50 o">Test Legend</span>
<span class="hidden o">Test Legend</span>
<span class="auto w50 o"><b>Legend Test</b></span>
<span class="hidden w50 o">Test Legend</span>
<span class="hidden w50 o">Test Legend</span>
</div>
<div id="inline-block">
<span class="hidden s10"><b>Legend Test</b></span>
<span class="scroll s10">Legend Test</span>
<span class="auto s10">Legend Test</span>
<span class="hidden w50"><b>Legend Test</b></span>
<span class="scroll w50">Legend Test</span>
<span class="auto w50"><b>Legend Test</b></span>
<span class="hidden">Legend Test</span>
<span class="auto"><b>Legend Test</b></span>
<span class="auto"><b>Legend Test</b></span>
<span class="hidden w50 o"><b>Legend Test</b></span>
<span class="hidden w50 o">Test Legend</span>
<span class="hidden o">Test Legend</span>
<span class="auto w50 o"><b>Legend Test</b></span>
<span class="hidden w50 o">Test Legend</span>
<span class="hidden w50 o">Test Legend</span>
</div>
<span class="auto w50"><b>Legend Test</b></span>
<span><b>Legend Test</b></span>
<span><b>Legend Test</b></span>
</body>
</html>

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

@ -0,0 +1,87 @@
<!DOCTYPE HTML>
<html><head>
<title>Testcase for bug 740743</title>
<style type="text/css">
html,body {
color:black; background-color:white; font-size:16px; padding:0; margin:0;
}
fieldset { padding: 2px; }
legend { background: lime; }
.s10 { width:10px; height:10px; }
.h10 { height:10px; }
.w50 { width:50px; }
.hidden { overflow:hidden; }
.scroll { overflow:scroll; }
.auto { overflow:auto; }
.o { text-overflow: ellipsis; }
#inline legend { display:inline; }
#inline-block legend { display:inline-block; }
</style>
</head>
<body>
<fieldset><legend class="hidden s10"><b>Legend Test</b></legend></fieldset>
<fieldset><legend class="scroll s10">Legend Test</legend></fieldset>
<fieldset><legend class="auto s10">Legend Test</legend></fieldset>
<fieldset><legend class="hidden w50"><b>Legend Test</b></legend></fieldset>
<fieldset><legend class="scroll w50">Legend Test</legend></fieldset>
<fieldset><legend class="auto w50"><b>Legend Test</b></legend></fieldset>
<fieldset><legend class="hidden">Legend Test</legend></fieldset>
<fieldset><legend class="auto"><b>Legend Test</b></legend></fieldset>
<fieldset><legend class="auto" style="width:auto"><b>Legend Test</b></legend></fieldset>
<fieldset><legend style="width:auto"><b>Legend Test</b></legend></fieldset>
<fieldset><legend class="hidden w50 o"><b>Legend Test</b></legend></fieldset>
<fieldset><legend class="hidden w50 o">Test Legend</legend></fieldset>
<fieldset><legend class="hidden o">Test Legend</legend></fieldset>
<fieldset><legend class="auto w50 o"><b>Legend Test</b></legend></fieldset>
<fieldset><legend class="hidden w50 o" align="right">Test Legend</legend></fieldset>
<fieldset><legend class="hidden w50 o" align="center">Test Legend</legend></fieldset>
<div id="inline">
<legend class="hidden s10"><b>Legend Test</b></legend>
<legend class="scroll s10">Legend Test</legend>
<legend class="auto s10">Legend Test</legend>
<legend class="hidden w50"><b>Legend Test</b></legend>
<legend class="scroll w50">Legend Test</legend>
<legend class="auto w50"><b>Legend Test</b></legend>
<legend class="hidden">Legend Test</legend>
<legend class="auto"><b>Legend Test</b></legend>
<legend class="hidden w50 o"><b>Legend Test</b></legend>
<legend class="hidden w50 o">Test Legend</legend>
<legend class="hidden o">Test Legend</legend>
<legend class="auto w50 o"><b>Legend Test</b></legend>
<legend class="hidden w50 o" align="right">Test Legend</legend>
<legend class="hidden w50 o" align="center">Test Legend</legend>
</div>
<div id="inline-block">
<legend class="hidden s10"><b>Legend Test</b></legend>
<legend class="scroll s10">Legend Test</legend>
<legend class="auto s10">Legend Test</legend>
<legend class="hidden w50"><b>Legend Test</b></legend>
<legend class="scroll w50">Legend Test</legend>
<legend class="auto w50"><b>Legend Test</b></legend>
<legend class="hidden">Legend Test</legend>
<legend class="auto"><b>Legend Test</b></legend>
<legend class="auto" style="width:auto"><b>Legend Test</b></legend>
<legend class="hidden w50 o"><b>Legend Test</b></legend>
<legend class="hidden w50 o">Test Legend</legend>
<legend class="hidden o">Test Legend</legend>
<legend class="auto w50 o"><b>Legend Test</b></legend>
<legend class="hidden w50 o" align="right">Test Legend</legend>
<legend class="hidden w50 o" align="center">Test Legend</legend>
</div>
<legend class="auto w50"><b>Legend Test</b></legend>
<legend class="auto" zstyle="width:auto"><b>Legend Test</b></legend>
<legend style="width:auto"><b>Legend Test</b></legend>
</body>
</html>

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

@ -64,6 +64,8 @@ fails-if(Android) != textarea-rtl.html textarea-no-resize.html
asserts(2) == button-first-letter-1.html button-first-letter-1-ref.html
asserts(1) != button-first-letter-1.html button-first-letter-1-noref.html
== legend.html legend-ref.html
# placeholder
include placeholder/reftest.list