зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1583980 - Restrict mapping of width and height to aspect-ratio for <img> for now. r=bzbarsky
This is an easier thing to implement interoperably than what we implement now, which is basically "whatever goes through this function". Differential Revision: https://phabricator.services.mozilla.com/D47145 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
af3f033028
Коммит
e4c23e97da
|
@ -234,11 +234,11 @@ bool HTMLImageElement::ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
|
|||
|
||||
void HTMLImageElement::MapAttributesIntoRule(
|
||||
const nsMappedAttributes* aAttributes, MappedDeclarations& aDecls) {
|
||||
nsGenericHTMLElement::MapImageAlignAttributeInto(aAttributes, aDecls);
|
||||
nsGenericHTMLElement::MapImageBorderAttributeInto(aAttributes, aDecls);
|
||||
nsGenericHTMLElement::MapImageMarginAttributeInto(aAttributes, aDecls);
|
||||
nsGenericHTMLElement::MapImageSizeAttributesInto(aAttributes, aDecls);
|
||||
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aDecls);
|
||||
MapImageAlignAttributeInto(aAttributes, aDecls);
|
||||
MapImageBorderAttributeInto(aAttributes, aDecls);
|
||||
MapImageMarginAttributeInto(aAttributes, aDecls);
|
||||
MapImageSizeAttributesInto(aAttributes, aDecls, MapAspectRatio::Yes);
|
||||
MapCommonAttributesInto(aAttributes, aDecls);
|
||||
}
|
||||
|
||||
nsChangeHint HTMLImageElement::GetAttributeChangeHint(const nsAtom* aAttribute,
|
||||
|
|
|
@ -1220,7 +1220,8 @@ void nsGenericHTMLElement::MapHeightAttributeInto(
|
|||
}
|
||||
|
||||
void nsGenericHTMLElement::MapImageSizeAttributesInto(
|
||||
const nsMappedAttributes* aAttributes, MappedDeclarations& aDecls) {
|
||||
const nsMappedAttributes* aAttributes, MappedDeclarations& aDecls,
|
||||
MapAspectRatio aMapAspectRatio) {
|
||||
auto* width = aAttributes->GetAttr(nsGkAtoms::width);
|
||||
auto* height = aAttributes->GetAttr(nsGkAtoms::height);
|
||||
if (width) {
|
||||
|
@ -1229,11 +1230,8 @@ void nsGenericHTMLElement::MapImageSizeAttributesInto(
|
|||
if (height) {
|
||||
MapDimensionAttributeInto(aDecls, eCSSProperty_height, *height);
|
||||
}
|
||||
// NOTE(emilio): If we implement the unrestricted aspect-ratio proposal, we
|
||||
// probably need to make this attribute mapping not apply to things like
|
||||
// <marquee> and <table>, which right now can go through this path.
|
||||
if (StaticPrefs::layout_css_width_and_height_map_to_aspect_ratio_enabled() &&
|
||||
width && height) {
|
||||
aMapAspectRatio == MapAspectRatio::Yes && width && height) {
|
||||
Maybe<double> w;
|
||||
if (width->Type() == nsAttrValue::eInteger) {
|
||||
w.emplace(width->GetIntegerValue());
|
||||
|
|
|
@ -482,15 +482,16 @@ class nsGenericHTMLElement : public nsGenericHTMLElementBase {
|
|||
*/
|
||||
static void MapImageMarginAttributeInto(const nsMappedAttributes* aAttributes,
|
||||
mozilla::MappedDeclarations&);
|
||||
|
||||
// Whether to map the width and height attributes to aspect-ratio.
|
||||
enum class MapAspectRatio { No, Yes };
|
||||
|
||||
/**
|
||||
* Helper to map the image position attribute into a style struct.
|
||||
*
|
||||
* @param aAttributes the list of attributes to map
|
||||
* @param aData the returned rule data [INOUT]
|
||||
* @see GetAttributeMappingFunction
|
||||
*/
|
||||
static void MapImageSizeAttributesInto(const nsMappedAttributes* aAttributes,
|
||||
mozilla::MappedDeclarations&);
|
||||
static void MapImageSizeAttributesInto(const nsMappedAttributes*,
|
||||
mozilla::MappedDeclarations&,
|
||||
MapAspectRatio = MapAspectRatio::No);
|
||||
|
||||
/**
|
||||
* Helper to map `width` attribute into a style struct.
|
||||
|
|
Загрузка…
Ссылка в новой задаче