Bug 1191855 - Make the intrinsic size of <iframe> remain physical 300x150, regardless of writing mode. r=dholbert

This commit is contained in:
Jonathan Kew 2015-08-12 11:02:02 +01:00
parent 2960021444
commit e2a1a6c621
5 changed files with 26 additions and 13 deletions

View File

@ -81,15 +81,20 @@ protected:
virtual ~nsLeafFrame();
/**
* Return the intrinsic width of the frame's content area. Note that this
* Return the intrinsic isize of the frame's content area. Note that this
* should not include borders or padding and should not depend on the applied
* styles.
* One exception to this is that the intrinsic (logical) size of an <iframe>
* depends on the writing-mode property (because the default intrinsic size
* is specified physically, for compat reasons). This should be OK because a
* change to writing-mode will trigger frame reconstruction anyhow, so the
* result will remain consistent for any given frame once constructed.
*/
virtual nscoord GetIntrinsicISize() = 0;
/**
* Return the intrinsic height of the frame's content area. This should not
* include border or padding. This will only matter if the specified height
* Return the intrinsic bsize of the frame's content area. This should not
* include border or padding. This will only matter if the specified bsize
* is auto. Note that subclasses must either implement this or override
* Reflow and ComputeAutoSize; the default Reflow and ComputeAutoSize impls
* call this method.

View File

@ -594,19 +594,23 @@ nscoord
nsSubDocumentFrame::GetIntrinsicISize()
{
if (!IsInline()) {
return 0; // HTML <frame> has no useful intrinsic width
return 0; // HTML <frame> has no useful intrinsic isize
}
if (mContent->IsXULElement()) {
return 0; // XUL <iframe> and <browser> have no useful intrinsic width
return 0; // XUL <iframe> and <browser> have no useful intrinsic isize
}
NS_ASSERTION(ObtainIntrinsicSizeFrame() == nullptr,
"Intrinsic width should come from the embedded document.");
"Intrinsic isize should come from the embedded document.");
// We must be an HTML <iframe>. Default to a width of 300, for IE
// We must be an HTML <iframe>. Default to size of 300px x 150px, for IE
// compat (and per CSS2.1 draft).
return nsPresContext::CSSPixelsToAppUnits(300);
// This depends on the applied styles, which the comments in nsLeafFrame.h
// say it should not, but we know it cannot change during the lifetime of
// the frame because changing writing-mode leads to frame reconstruction.
WritingMode wm = GetWritingMode();
return nsPresContext::CSSPixelsToAppUnits(wm.IsVertical() ? 150 : 300);
}
nscoord
@ -620,10 +624,11 @@ nsSubDocumentFrame::GetIntrinsicBSize()
}
NS_ASSERTION(ObtainIntrinsicSizeFrame() == nullptr,
"Intrinsic height should come from the embedded document.");
"Intrinsic bsize should come from the embedded document.");
// Use 150px, for compatibility with IE, and per CSS2.1 draft.
return nsPresContext::CSSPixelsToAppUnits(150);
// Use size of 300px x 150px, for compatibility with IE, and per CSS2.1 draft.
WritingMode wm = GetWritingMode();
return nsPresContext::CSSPixelsToAppUnits(wm.IsVertical() ? 300 : 150);
}
#ifdef DEBUG_FRAME_DUMP

View File

@ -10,7 +10,7 @@ body>div { margin: 50px 20px; width: 400px; height: 500px; border: 5px solid blu
iframe {
position: absolute; left: 0; top: 34px;
background: yellow; border: 5px solid green;
width: 150px; height: 300px; /* XXX this is probably wrong, pending CSSWG clarification */
width: 300px; height: 150px;
}
</style>
<body>

View File

@ -10,7 +10,7 @@ body>div { margin: 50px 20px; width: 400px; height: 500px; border: 5px solid blu
iframe {
position: absolute; right: 0; top: 34px;
background: yellow; border: 5px solid green;
width: 150px; height: 300px; /* XXX this is probably wrong, pending CSSWG clarification */
width: 300px; height: 150px;
}
</style>
<body>

View File

@ -2956,6 +2956,9 @@ nsChangeHint nsStyleVisibility::CalcDifference(const nsStyleVisibility& aOther)
nsChangeHint hint = nsChangeHint(0);
if (mDirection != aOther.mDirection || mWritingMode != aOther.mWritingMode) {
// It's important that a change in mWritingMode results in frame
// reconstruction, because it may affect intrinsic size (see
// nsSubDocumentFrame::GetIntrinsicISize/BSize).
NS_UpdateHint(hint, nsChangeHint_ReconstructFrame);
} else {
if ((mImageOrientation != aOther.mImageOrientation)) {