mirror of
https://github.com/classilla/tenfourfox.git
synced 2026-04-26 08:17:54 +00:00
#493: image max-width M823483 M1247929
This commit is contained in:
@@ -4489,6 +4489,43 @@ GetIntrinsicCoord(const nsStyleCoord& aStyle,
|
||||
static int32_t gNoiseIndent = 0;
|
||||
#endif
|
||||
|
||||
// Return true for form controls whose minimum intrinsic inline-size
|
||||
// shrinks to 0 when they have a percentage inline-size (but not
|
||||
// percentage max-inline-size). (Proper replaced elements, whose
|
||||
// intrinsic minimium inline-size shrinks to 0 for both percentage
|
||||
// inline-size and percentage max-inline-size, are handled elsewhere.)
|
||||
inline static bool
|
||||
FormControlShrinksForPercentISize(nsIFrame* aFrame)
|
||||
{
|
||||
if (!aFrame->IsFrameOfType(nsIFrame::eReplaced)) {
|
||||
// Quick test to reject most frames.
|
||||
return false;
|
||||
}
|
||||
|
||||
nsIAtom* fType = aFrame->GetType();
|
||||
if (fType == nsGkAtoms::meterFrame || fType == nsGkAtoms::progressFrame) {
|
||||
// progress and meter do have this shrinking behavior
|
||||
// FIXME: Maybe these should be nsIFormControlFrame?
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!static_cast<nsIFormControlFrame*>(do_QueryFrame(aFrame))) {
|
||||
// Not a form control. This includes fieldsets, which do not
|
||||
// shrink.
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fType == nsGkAtoms::gfxButtonControlFrame ||
|
||||
fType == nsGkAtoms::HTMLButtonControlFrame) {
|
||||
// Buttons don't have this shrinking behavior. (Note that color
|
||||
// inputs do, even though they inherit from button, so we can't use
|
||||
// do_QueryFrame here.)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add aOffsets which describes what to add on outside of the content box
|
||||
* aContentSize (controlled by 'box-sizing') and apply min/max properties.
|
||||
@@ -4565,19 +4602,23 @@ AddIntrinsicSizeOffset(nsRenderingContext* aRenderingContext,
|
||||
pctTotal += pctOutsideSize;
|
||||
|
||||
nscoord size;
|
||||
if (GetAbsoluteCoord(aStyleSize, size) ||
|
||||
GetIntrinsicCoord(aStyleSize, aRenderingContext, aFrame,
|
||||
PROP_WIDTH, size)) {
|
||||
if (aType == nsLayoutUtils::MIN_ISIZE &&
|
||||
(((aStyleSize.HasPercent() || aStyleMaxSize.HasPercent()) &&
|
||||
aFrame->IsFrameOfType(nsIFrame::eReplacedSizing)) ||
|
||||
(aStyleSize.HasPercent() &&
|
||||
FormControlShrinksForPercentISize(aFrame)))) {
|
||||
// A percentage width or max-width on replaced elements means they
|
||||
// can shrink to 0.
|
||||
// This is also true for percentage widths (but not max-widths) on
|
||||
// text inputs.
|
||||
// Note that if this is max-width, this overrides the fixed-width
|
||||
// rule in the next condition.
|
||||
result = 0; // let |min| handle padding/border/margin
|
||||
} else if (GetAbsoluteCoord(aStyleSize, size) ||
|
||||
GetIntrinsicCoord(aStyleSize, aRenderingContext, aFrame,
|
||||
PROP_WIDTH, size)) {
|
||||
result = nsLayoutUtils::AddPercents(aType, size + coordOutsideSize,
|
||||
pctOutsideSize);
|
||||
} else if (aType == nsLayoutUtils::MIN_ISIZE &&
|
||||
// The only cases of coord-percent-calc() units that
|
||||
// GetAbsoluteCoord didn't handle are percent and calc()s
|
||||
// containing percent.
|
||||
aStyleSize.IsCoordPercentCalcUnit() &&
|
||||
aFrame->IsFrameOfType(nsIFrame::eReplaced)) {
|
||||
// A percentage width on replaced elements means they can shrink to 0.
|
||||
result = 0; // let |min| handle padding/border/margin
|
||||
} else {
|
||||
// NOTE: We could really do a lot better for percents and for some
|
||||
// cases of calc() containing percent (certainly including any where
|
||||
|
||||
Reference in New Issue
Block a user