Give captions the right style context parent when dynamically restyling. Bug378240, r=bernd, sr=dbaron

This commit is contained in:
bzbarsky@mit.edu 2007-04-22 12:15:24 -07:00
parent 2012087fb2
commit be25658d6f
5 changed files with 125 additions and 0 deletions

View File

@ -0,0 +1,40 @@
<!DOCTYPE html>
<html>
<head>
<title>Test inheritance into captions</title>
<style>
/**
* The idea is that "color" inherits by default while "border-color" does
* not. So if the former is red and the latter is green on a parent, and
* the child's border-color is set to "inherit", it'll be green only if
* the child is inheriting from the parent. If not, it'll either be
* whatever the border-color is on what it's inheriting from, which will
* be red if what it's inheriting from has the default (currentColor)
* border-color).
*/
/* 't' for "test" */
* { color: red; border: 0px hidden red; background: transparent }
.t, .t2 { border-color: green }
.t > :first-child
{ border-color: green; border-style: solid; border-width: 10px }
.t2 > :first-child
{ border-style: solid; border-width: 10px }
.t2 > .test
{ border-color: green }
</style>
</head>
<body>
<table class="t"><caption></caption></table>
<table class="t2 d2"><caption class="test"></caption></table>
<table class="t d"><caption></caption></table>
<table class="t d"><caption></caption></table>
<table class="t d"><caption></caption></table>
<table class="t2 d d2"><caption class="test"></caption></table>
<table class="t2 d d2"><caption class="test"></caption></table>
<table class="t2 d d2"><caption class="test"></caption></table>
</body>
</html>

View File

@ -0,0 +1,57 @@
<!DOCTYPE html>
<html>
<head>
<title>Test inheritance into captions</title>
<style>
/**
* The idea is that "color" inherits by default while "border-color" does
* not. So if the former is red and the latter is green on a parent, and
* the child's border-color is set to "inherit", it'll be green only if
* the child is inheriting from the parent. If not, it'll either be
* whatever the border-color is on what it's inheriting from, which will
* be red if what it's inheriting from has the default (currentColor)
* border-color).
*/
/* 't' for "test" */
* { color: red; border: 0px hidden red; background: transparent }
.t, .t2 { border-color: green }
.t > caption
{ border-color: inherit; border-style: solid; border-width: 10px }
.t2 > caption
{ border-style: solid; border-width: 10px }
.t2 > caption.test
{ border-color: inherit }
</style>
<script>
function makeCaption() {
return document.createElement("caption");
}
window.onload = function() {
var lst = document.getElementsByClassName("d");
for (var i = 0; i < lst.length; ++i) {
lst[i].appendChild(makeCaption());
}
var lst = document.getElementsByClassName("d2");
for (var i = 0; i < lst.length; ++i) {
lst[i].firstChild.className = "test";
}
}
</script>
</head>
<body>
<table class="t"><caption></caption></table>
<table class="t2 d2"><caption></caption></table>
<table class="t d"></table>
<div class="t d"></div>
<div style="display: table" class="t d"></div>
<table class="t2 d d2"></table>
<div class="t2 d d2"></div>
<div style="display: table" class="t2 d d2"></div>
</body>
</html>

View File

@ -105,6 +105,7 @@ fails == 25888-3r.html 25888-3r-ref.html # bug 25888
== 323656-3.html 323656-3-ref.html
== 323656-4.html 323656-4-ref.html
fails == 323656-5.svg 323656-5-ref.svg # bug 377584
== 323656-6.html 323656-6-ref.html
== 325486-1.html 325486-1-ref.html
random == 328829-1.xhtml 328829-1-ref.xhtml # bug 369046 (intermittent)
== 328829-2.xhtml 328829-2-ref.xhtml

View File

@ -110,6 +110,30 @@ nsTableCaptionFrame::ComputeAutoSize(nsIRenderingContext *aRenderingContext,
return result;
}
NS_IMETHODIMP
nsTableCaptionFrame::GetParentStyleContextFrame(nsPresContext* aPresContext,
nsIFrame** aProviderFrame,
PRBool* aIsChild)
{
// The caption's style context parent is the inner frame, unless
// it's anonymous.
nsIFrame* outerFrame = GetParent();
if (outerFrame && outerFrame->GetType() == nsGkAtoms::tableOuterFrame) {
nsIFrame* innerFrame = outerFrame->GetFirstChild(nsnull);
if (innerFrame) {
*aProviderFrame =
nsFrame::CorrectStyleParentFrame(innerFrame,
GetStyleContext()->GetPseudoType());
*aIsChild = PR_FALSE;
return NS_OK;
}
}
NS_NOTREACHED("Where is our inner table frame?");
return nsBlockFrame::GetParentStyleContextFrame(aPresContext, aProviderFrame,
aIsChild);
}
#ifdef NS_DEBUG
NS_IMETHODIMP
nsTableCaptionFrame::GetFrameName(nsAString& aResult) const

View File

@ -57,6 +57,9 @@ public:
nsSize aMargin, nsSize aBorder,
nsSize aPadding, PRBool aShrinkWrap);
NS_IMETHOD GetParentStyleContextFrame(nsPresContext* aPresContext,
nsIFrame** aProviderFrame,
PRBool* aIsChild);
#ifdef NS_DEBUG
NS_IMETHOD GetFrameName(nsAString& aResult) const;
#endif