Backed out changeset 7985a1fa0789 (bug 1764768) for causing multiple failures CLOSED TREE
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
var res1 = [
|
||||
{
|
||||
selector: ".boxmodel-element-size",
|
||||
value: "160" + "\u00D7" + "160.1",
|
||||
value: "160" + "\u00D7" + "160.117",
|
||||
},
|
||||
{
|
||||
selector: ".boxmodel-size > .boxmodel-width",
|
||||
@@ -18,7 +18,7 @@ var res1 = [
|
||||
},
|
||||
{
|
||||
selector: ".boxmodel-size > .boxmodel-height",
|
||||
value: "100.1",
|
||||
value: "100.117",
|
||||
},
|
||||
{
|
||||
selector: ".boxmodel-position.boxmodel-top > span",
|
||||
|
||||
@@ -1969,11 +1969,11 @@ bool BuildTextRunsScanner::ContinueTextRunAcrossFrames(nsTextFrame* aFrame1,
|
||||
// character units in the inline axis is non-zero.
|
||||
const auto& margin = ctx->StyleMargin()->mMargin.Get(aSide);
|
||||
if (!margin.ConvertsToLength() ||
|
||||
!margin.AsLengthPercentage().IsDefinitelyZero()) {
|
||||
margin.AsLengthPercentage().ToLength() != 0) {
|
||||
return true;
|
||||
}
|
||||
const auto& padding = ctx->StylePadding()->mPadding.Get(aSide);
|
||||
if (!padding.ConvertsToLength() || !padding.IsDefinitelyZero()) {
|
||||
if (!padding.ConvertsToLength() || padding.ToLength() != 0) {
|
||||
return true;
|
||||
}
|
||||
if (ctx->StyleBorder()->GetComputedBorderWidth(aSide) != 0) {
|
||||
|
||||
@@ -550,7 +550,7 @@ nscoord StyleCSSPixelLength::ToAppUnits() const {
|
||||
// Avoid the expensive FP math below.
|
||||
return 0;
|
||||
}
|
||||
float length = _0 * float(AppUnitsPerCSSPixel());
|
||||
float length = _0 * float(mozilla::AppUnitsPerCSSPixel());
|
||||
if (length >= float(nscoord_MAX)) {
|
||||
return nscoord_MAX;
|
||||
}
|
||||
@@ -682,17 +682,16 @@ bool LengthPercentage::HasPercent() const { return IsPercentage() || IsCalc(); }
|
||||
|
||||
bool LengthPercentage::ConvertsToLength() const { return IsLength(); }
|
||||
|
||||
nscoord LengthPercentage::ToLength() const {
|
||||
MOZ_ASSERT(ConvertsToLength());
|
||||
return AsLength().ToAppUnits();
|
||||
}
|
||||
|
||||
CSSCoord LengthPercentage::ToLengthInCSSPixels() const {
|
||||
MOZ_ASSERT(ConvertsToLength());
|
||||
return AsLength().ToCSSPixels();
|
||||
}
|
||||
|
||||
nscoord LengthPercentage::ToLength() const {
|
||||
MOZ_ASSERT(ConvertsToLength());
|
||||
// We use the same rounder as Resolve()'s default.
|
||||
return NSToCoordTruncClamped(ToLengthInCSSPixels() * AppUnitsPerCSSPixel());
|
||||
}
|
||||
|
||||
bool LengthPercentage::ConvertsToPercentage() const { return IsPercentage(); }
|
||||
|
||||
float LengthPercentage::ToPercentage() const {
|
||||
@@ -753,7 +752,7 @@ nscoord LengthPercentage::Resolve(T aPercentageGetter, U aRounder) const {
|
||||
static_assert(std::is_same<decltype(aRounder(1.0f)), nscoord>::value,
|
||||
"Should return app units");
|
||||
if (ConvertsToLength()) {
|
||||
return aRounder(ToLengthInCSSPixels() * AppUnitsPerCSSPixel());
|
||||
return ToLength();
|
||||
}
|
||||
if (IsPercentage() && AsPercentage()._0 == 0.0f) {
|
||||
return 0.0f;
|
||||
@@ -779,8 +778,10 @@ nscoord LengthPercentage::Resolve(T aPercentageGetter) const {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
nscoord LengthPercentage::Resolve(nscoord aPercentageBasis, T aRounder) const {
|
||||
return Resolve([aPercentageBasis] { return aPercentageBasis; }, aRounder);
|
||||
nscoord LengthPercentage::Resolve(nscoord aPercentageBasis,
|
||||
T aPercentageRounder) const {
|
||||
return Resolve([aPercentageBasis] { return aPercentageBasis; },
|
||||
aPercentageRounder);
|
||||
}
|
||||
|
||||
void LengthPercentage::ScaleLengthsBy(float aScale) {
|
||||
|
||||
@@ -1290,7 +1290,7 @@ var gFlexboxTestcases = [
|
||||
"_main-size": [null, "200px"],
|
||||
},
|
||||
{
|
||||
flex: "0 1 0.02px",
|
||||
flex: "0 1 0.01px",
|
||||
"_main-size": [null, "0px"],
|
||||
},
|
||||
],
|
||||
@@ -1309,7 +1309,7 @@ var gFlexboxTestcases = [
|
||||
"_main-size": [null, "250px"],
|
||||
},
|
||||
{
|
||||
flex: "0 5 0.02px",
|
||||
flex: "0 5 0.01px",
|
||||
"_main-size": [null, "0px"],
|
||||
},
|
||||
],
|
||||
|
||||
@@ -20,6 +20,7 @@ use crate::values::specified::calc::{self, CalcNode};
|
||||
use crate::values::specified::NonNegativeNumber;
|
||||
use crate::values::CSSFloat;
|
||||
use crate::Zero;
|
||||
use app_units::Au;
|
||||
use cssparser::{Parser, Token};
|
||||
use std::cmp;
|
||||
use std::ops::{Add, Mul};
|
||||
@@ -610,8 +611,13 @@ impl ViewportPercentageLength {
|
||||
size.height
|
||||
}
|
||||
},
|
||||
}.to_f32_px();
|
||||
CSSPixelLength::new(length * factor / 100.)
|
||||
};
|
||||
|
||||
// FIXME: Bug 1396535, we need to fix the extremely small viewport length for transform.
|
||||
// See bug 989802. We truncate so that adding multiple viewport units
|
||||
// that add up to 100 does not overflow due to rounding differences
|
||||
let trunc_scaled = ((length.0 as f64) * factor as f64 / 100.).trunc();
|
||||
Au::from_f64_au(trunc_scaled).into()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ function assert_style_left_at(animation, time, easingFunction) {
|
||||
var portion = time / animation.effect.getTiming()['duration'];
|
||||
assert_approx_equals(pxToNum(getComputedStyle(animation.effect.target).left),
|
||||
easingFunction(portion) * 100,
|
||||
0.02,
|
||||
0.01,
|
||||
'The left of the animation should be approximately ' +
|
||||
easingFunction(portion) * 100 + ' at ' + time + 'ms');
|
||||
}
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
<!doctype html>
|
||||
<meta charset="utf-8">
|
||||
<title>Viewport units rounding and calc()</title>
|
||||
<link rel="help" href="https://drafts.csswg.org/css-values-4/#viewport-relative-lengths">
|
||||
<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1764768">
|
||||
<link rel="author" href="mailto:emilio@crisal.io" title="Emilio Cobos Álvarez">
|
||||
<link rel="author" href="https://mozilla.org" title="Mozilla">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<style>
|
||||
iframe {
|
||||
width: 150px;
|
||||
height: 100px;
|
||||
}
|
||||
</style>
|
||||
<iframe scrolling="no" srcdoc="<div id=target></div>"></iframe>
|
||||
<script>
|
||||
onload = function() {
|
||||
let win = document.querySelector("iframe").contentWindow;
|
||||
let target = win.document.getElementById("target");
|
||||
test(function() {
|
||||
target.style.width = 'calc(100vw / 192)';
|
||||
let viewport = win.getComputedStyle(target).width;
|
||||
target.style.width = 'calc(150px / 192)';
|
||||
let nonViewport = win.getComputedStyle(target).width;
|
||||
assert_equals(viewport, nonViewport, "Rounding for viewport units should be consistent with pixels");
|
||||
});
|
||||
};
|
||||
</script>
|
||||
Reference in New Issue
Block a user