Bug 1109571 part 3 - Implement table caption specific code for ComputeAutoSize(), GetCorrectedParent() (for getting the style parent frame) and AccessibleType(). r=roc

This commit is contained in:
Mats Palmgren 2014-12-26 07:21:32 +00:00
parent ee39486143
commit 3c1a6ca818
4 changed files with 49 additions and 2 deletions

View File

@ -6442,6 +6442,10 @@ nsBlockFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
a11y::AccType
nsBlockFrame::AccessibleType()
{
if (IsTableCaption()) {
return GetRect().IsEmpty() ? a11y::eNoType : a11y::eHTMLCaptionType;
}
// block frame may be for <hr>
if (mContent->Tag() == nsGkAtoms::hr) {
return a11y::eHTMLHRType;

View File

@ -885,7 +885,7 @@ nsContainerFrame::DoInlineIntrinsicISize(nsRenderingContext *aRenderingContext,
/* virtual */
LogicalSize
nsContainerFrame::ComputeAutoSize(nsRenderingContext *aRenderingContext,
nsContainerFrame::ComputeAutoSize(nsRenderingContext* aRenderingContext,
WritingMode aWM,
const LogicalSize& aCBSize,
nscoord aAvailableISize,
@ -908,6 +908,33 @@ nsContainerFrame::ComputeAutoSize(nsRenderingContext *aRenderingContext,
} else {
result.ISize(aWM) = availBased;
}
if (IsTableCaption()) {
// If we're a container for font size inflation, then shrink
// wrapping inside of us should not apply font size inflation.
AutoMaybeDisableFontInflation an(this);
// XXX todo: make this aware of vertical writing modes
uint8_t captionSide = StyleTableBorder()->mCaptionSide;
if (captionSide == NS_STYLE_CAPTION_SIDE_LEFT ||
captionSide == NS_STYLE_CAPTION_SIDE_RIGHT) {
result.ISize(aWM) = GetMinISize(aRenderingContext);
} else if (captionSide == NS_STYLE_CAPTION_SIDE_TOP ||
captionSide == NS_STYLE_CAPTION_SIDE_BOTTOM) {
// The outer frame constrains our available width to the width of
// the table. Grow if our min-width is bigger than that, but not
// larger than the containing block width. (It would really be nice
// to transmit that information another way, so we could grow up to
// the table's available width, but that's harder.)
nscoord min = GetMinISize(aRenderingContext);
if (min > aCBSize.ISize(aWM)) {
min = aCBSize.ISize(aWM);
}
if (min > result.ISize(aWM)) {
result.ISize(aWM) = min;
}
}
}
return result;
}

View File

@ -7080,6 +7080,9 @@ nsFrame::ChildIsDirty(nsIFrame* aChild)
a11y::AccType
nsFrame::AccessibleType()
{
if (IsTableCaption() && !GetRect().IsEmpty()) {
return a11y::eHTMLCaptionType;
}
return a11y::eNoType;
}
#endif
@ -7748,11 +7751,20 @@ GetIBSplitSiblingForAnonymousBlock(const nsIFrame* aFrame)
static nsIFrame*
GetCorrectedParent(const nsIFrame* aFrame)
{
nsIFrame *parent = aFrame->GetParent();
nsIFrame* parent = aFrame->GetParent();
if (!parent) {
return nullptr;
}
// For a table caption we want the _inner_ table frame (unless it's anonymous)
// as the style parent.
if (aFrame->IsTableCaption()) {
nsIFrame* innerTable = parent->GetFirstPrincipalChild();
if (!innerTable->StyleContext()->GetPseudo()) {
return innerTable;
}
}
// Outer tables are always anon boxes; if we're in here for an outer
// table, that actually means its the _inner_ table that wants to
// know its parent. So get the pseudo of the inner in that case.

View File

@ -931,6 +931,10 @@ nsHTMLScrollFrame::GetFrameName(nsAString& aResult) const
a11y::AccType
nsHTMLScrollFrame::AccessibleType()
{
if (IsTableCaption()) {
return GetRect().IsEmpty() ? a11y::eNoType : a11y::eHTMLCaptionType;
}
// Create an accessible regardless of focusable state because the state can be
// changed during frame life cycle without any notifications to accessibility.
if (mContent->IsRootOfNativeAnonymousSubtree() ||