Commit d932f9ab authored by alancutter's avatar alancutter Committed by Commit bot

Use approximation when comparing Length floats in DCHECK

The original DCHECK was asserting on float equality. This was too strict
and was firing for small negligible differences. This change flattens
specified Lengths into a single float and compares them with a constant
slack allowance.

This check is intended to pick up on differences like -5 vs 0 due to
different clamping behaviour, small differences in floating point
arithmetic is fine.

BUG=649525

Review-Url: https://codereview.chromium.org/2366823003
Cr-Commit-Position: refs/heads/master@{#420584}
parent 69b35e1b
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "core/css/CSSCalculationValue.h" #include "core/css/CSSCalculationValue.h"
#include "core/css/resolver/StyleBuilder.h" #include "core/css/resolver/StyleBuilder.h"
#include "core/css/resolver/StyleResolverState.h" #include "core/css/resolver/StyleResolverState.h"
#include "platform/LengthFunctions.h"
#include "wtf/PtrUtil.h" #include "wtf/PtrUtil.h"
#include <memory> #include <memory>
...@@ -122,7 +123,12 @@ void CSSLengthInterpolationType::apply(const InterpolableValue& interpolableValu ...@@ -122,7 +123,12 @@ void CSSLengthInterpolationType::apply(const InterpolableValue& interpolableValu
DCHECK(LengthPropertyFunctions::getLength(cssProperty(), style, before)); DCHECK(LengthPropertyFunctions::getLength(cssProperty(), style, before));
StyleBuilder::applyProperty(cssProperty(), state, *CSSPrimitiveValue::create(length, zoom)); StyleBuilder::applyProperty(cssProperty(), state, *CSSPrimitiveValue::create(length, zoom));
DCHECK(LengthPropertyFunctions::getLength(cssProperty(), style, after)); DCHECK(LengthPropertyFunctions::getLength(cssProperty(), style, after));
DCHECK(before == after); DCHECK_EQ(before.type(), after.type());
if (before.isSpecified()) {
const float kSlack = 0.1;
float delta = floatValueForLength(after, 100) - floatValueForLength(before, 100);
DCHECK_LT(std::abs(delta), kSlack);
}
#endif #endif
return; return;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment