mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 948265 - Add CSS contrast filter to nsCSSFilterInstance. r=mstange
This commit is contained in:
parent
add508fb53
commit
e75863b45a
@ -0,0 +1,22 @@
|
||||
<!--
|
||||
Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>CSS Filters: Increase the Contrast of an HTML Element Using a Large Factor</title>
|
||||
<link rel="author" title="Max Vujovic" href="mailto:mvujovic@adobe.com">
|
||||
<style type="text/css">
|
||||
#target {
|
||||
background-color: #0f0;
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<p>You should see a bright green square.</p>
|
||||
<div id="target"></div>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,29 @@
|
||||
<!--
|
||||
Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>CSS Filters: Increase the Contrast of an HTML Element Using a Large Factor</title>
|
||||
<link rel="author" title="Max Vujovic" href="mailto:mvujovic@adobe.com">
|
||||
<link rel="help" href="http://www.w3.org/TR/filter-effects-1/#funcdef-contrast">
|
||||
<link rel="match" href="contrast-extreme-ref.html">
|
||||
<meta name="assert"
|
||||
content="Given a large factor, the CSS contrast filter function should
|
||||
should change color channel values to be much farther from
|
||||
their middle value.">
|
||||
<style type="text/css">
|
||||
#target {
|
||||
filter: contrast(1000);
|
||||
background-color: rgb(127, 129, 127); /* 127 should change to 0, and 129 should change to 255. */
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<p>You should see a bright green square.</p>
|
||||
<div id="target"></div>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,22 @@
|
||||
<!--
|
||||
Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>CSS Filters: Set the Contrast of HTML Element Using a Factor of One</title>
|
||||
<link rel="author" title="Max Vujovic" href="mailto:mvujovic@adobe.com">
|
||||
<style type="text/css">
|
||||
#target {
|
||||
background-color: rgb(0, 128, 0);
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<p>You should see a green square.</p>
|
||||
<div id="target"></div>
|
||||
</body>
|
||||
</html>
|
28
layout/reftests/svg/filters/css-filters/contrast-one.html
Normal file
28
layout/reftests/svg/filters/css-filters/contrast-one.html
Normal file
@ -0,0 +1,28 @@
|
||||
<!--
|
||||
Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>CSS Filters: Set the Contrast of HTML Element Using a Factor of One</title>
|
||||
<link rel="author" title="Max Vujovic" href="mailto:mvujovic@adobe.com">
|
||||
<link rel="help" href="http://www.w3.org/TR/filter-effects-1/#funcdef-contrast">
|
||||
<link rel="match" href="contrast-one-ref.html">
|
||||
<meta name="assert"
|
||||
content="Given a factor of one, the CSS contrast filter function
|
||||
should not change the color of an HTML element.">
|
||||
<style type="text/css">
|
||||
#target {
|
||||
filter: contrast(1);
|
||||
background-color: rgb(0, 128, 0);
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<p>You should see a green square.</p>
|
||||
<div id="target"></div>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,22 @@
|
||||
<!--
|
||||
Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>CSS Filters: Increase the Contrast of an HTML Element</title>
|
||||
<link rel="author" title="Max Vujovic" href="mailto:mvujovic@adobe.com">
|
||||
<style type="text/css">
|
||||
#target {
|
||||
background-color: #0f0;
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<p>You should see a bright green square.</p>
|
||||
<div id="target"></div>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,28 @@
|
||||
<!--
|
||||
Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>CSS Filters: Increase the Contrast of an HTML Element</title>
|
||||
<link rel="author" title="Max Vujovic" href="mailto:mvujovic@adobe.com">
|
||||
<link rel="help" href="http://www.w3.org/TR/filter-effects-1/#funcdef-contrast">
|
||||
<link rel="match" href="contrast-percent-ref.html">
|
||||
<meta name="assert"
|
||||
content="Given a percentage, the CSS contrast filter function should
|
||||
change the color of an HTML element.">
|
||||
<style type="text/css">
|
||||
#target {
|
||||
filter: contrast(200%);
|
||||
background-color: rgb(0, 196, 0);
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<p>You should see a bright green square.</p>
|
||||
<div id="target"></div>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,22 @@
|
||||
<!--
|
||||
Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>CSS Filters: Reduce the Contrast of an HTML Element</title>
|
||||
<link rel="author" title="Max Vujovic" href="mailto:mvujovic@adobe.com">
|
||||
<style type="text/css">
|
||||
#target {
|
||||
background-color: rgb(64, 191, 64);
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<p>You should see a green square.</p>
|
||||
<div id="target"></div>
|
||||
</body>
|
||||
</html>
|
29
layout/reftests/svg/filters/css-filters/contrast-reduce.html
Normal file
29
layout/reftests/svg/filters/css-filters/contrast-reduce.html
Normal file
@ -0,0 +1,29 @@
|
||||
<!--
|
||||
Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>CSS Filters: Reduce the Contrast of an HTML Element</title>
|
||||
<link rel="author" title="Max Vujovic" href="mailto:mvujovic@adobe.com">
|
||||
<link rel="help" href="http://www.w3.org/TR/filter-effects-1/#funcdef-contrast">
|
||||
<link rel="match" href="contrast-reduce-ref.html">
|
||||
<meta name="assert"
|
||||
content="Given a factor of less than one, the CSS contrast filter
|
||||
function should change color channel values to be closer to
|
||||
their middle value.">
|
||||
<style type="text/css">
|
||||
#target {
|
||||
filter: contrast(0.5);
|
||||
background-color: #0f0;
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<p>You should see a green square.</p>
|
||||
<div id="target"></div>
|
||||
</body>
|
||||
</html>
|
22
layout/reftests/svg/filters/css-filters/contrast-ref.html
Normal file
22
layout/reftests/svg/filters/css-filters/contrast-ref.html
Normal file
@ -0,0 +1,22 @@
|
||||
<!--
|
||||
Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>CSS Filters: Increase the Contrast of an HTML Element</title>
|
||||
<link rel="author" title="Max Vujovic" href="mailto:mvujovic@adobe.com">
|
||||
<style type="text/css">
|
||||
#target {
|
||||
background-color: #0f0;
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<p>You should see a bright green square.</p>
|
||||
<div id="target"></div>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,23 @@
|
||||
<!--
|
||||
Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>CSS Filters: Reduce the Contrast of an HTML Element Using a Factor of Zero</title>
|
||||
<link rel="author" title="Max Vujovic" href="mailto:mvujovic@adobe.com">
|
||||
<style type="text/css">
|
||||
#target {
|
||||
filter: contrast(0);
|
||||
background-color: rgb(128, 128, 128);
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<p>You should see a gray square.</p>
|
||||
<div id="target"></div>
|
||||
</body>
|
||||
</html>
|
28
layout/reftests/svg/filters/css-filters/contrast-zero.html
Normal file
28
layout/reftests/svg/filters/css-filters/contrast-zero.html
Normal file
@ -0,0 +1,28 @@
|
||||
<!--
|
||||
Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>CSS Filters: Reduce the Contrast of an HTML Element Using a Factor of Zero</title>
|
||||
<link rel="author" title="Max Vujovic" href="mailto:mvujovic@adobe.com">
|
||||
<link rel="help" href="http://www.w3.org/TR/filter-effects-1/#funcdef-contrast">
|
||||
<link rel="match" href="contrast-zero-ref.html">
|
||||
<meta name="assert"
|
||||
content="Given a factor of zero, the CSS contrast filter function
|
||||
should change the color of an HTML element to gray.">
|
||||
<style type="text/css">
|
||||
#target {
|
||||
filter: contrast(0);
|
||||
background-color: rgb(0, 128, 0);
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<p>You should see a gray square.</p>
|
||||
<div id="target"></div>
|
||||
</body>
|
||||
</html>
|
28
layout/reftests/svg/filters/css-filters/contrast.html
Normal file
28
layout/reftests/svg/filters/css-filters/contrast.html
Normal file
@ -0,0 +1,28 @@
|
||||
<!--
|
||||
Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>CSS Filters: Increase the Contrast of an HTML Element</title>
|
||||
<link rel="author" title="Max Vujovic" href="mailto:mvujovic@adobe.com">
|
||||
<link rel="help" href="http://www.w3.org/TR/filter-effects-1/#funcdef-contrast">
|
||||
<link rel="match" href="contrast-ref.html">
|
||||
<meta name="assert"
|
||||
content="The CSS contrast filter function should change the color of
|
||||
an HTML element.">
|
||||
<style type="text/css">
|
||||
#target {
|
||||
filter: contrast(2);
|
||||
background-color: rgb(0, 196, 0);
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<p>You should see a bright green square.</p>
|
||||
<div id="target"></div>
|
||||
</body>
|
||||
</html>
|
@ -13,6 +13,12 @@ default-preferences pref(layout.css.filters.enabled,true)
|
||||
== brightness-one.html brightness-one-ref.html
|
||||
== brightness-percent.html brightness-percent-ref.html
|
||||
== brightness-zero.html brightness-zero-ref.html
|
||||
== contrast.html contrast-ref.html
|
||||
== contrast-extreme.html contrast-extreme-ref.html
|
||||
== contrast-one.html contrast-one-ref.html
|
||||
== contrast-percent.html contrast-percent-ref.html
|
||||
== contrast-reduce.html contrast-reduce-ref.html
|
||||
== contrast-zero.html contrast-zero-ref.html
|
||||
== drop-shadow.html drop-shadow-ref.html
|
||||
== drop-shadow-default-color.html drop-shadow-default-color-ref.html
|
||||
== drop-shadow-negative-offset.html drop-shadow-negative-offset-ref.html
|
||||
|
@ -55,7 +55,9 @@ nsCSSFilterInstance::BuildPrimitives(nsTArray<FilterPrimitiveDescription>& aPrim
|
||||
result = SetAttributesForBrightness(descr);
|
||||
break;
|
||||
case NS_STYLE_FILTER_CONTRAST:
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
descr = CreatePrimitiveDescription(PrimitiveType::ComponentTransfer, aPrimitiveDescrs);
|
||||
result = SetAttributesForContrast(descr);
|
||||
break;
|
||||
case NS_STYLE_FILTER_DROP_SHADOW:
|
||||
descr = CreatePrimitiveDescription(PrimitiveType::DropShadow, aPrimitiveDescrs);
|
||||
result = SetAttributesForDropShadow(descr);
|
||||
@ -151,6 +153,32 @@ nsCSSFilterInstance::SetAttributesForBrightness(FilterPrimitiveDescription& aDes
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsCSSFilterInstance::SetAttributesForContrast(FilterPrimitiveDescription& aDescr)
|
||||
{
|
||||
const nsStyleCoord& styleValue = mFilter.GetFilterParameter();
|
||||
float value = styleValue.GetFactorOrPercentValue();
|
||||
float intercept = -(0.5 * value) + 0.5;
|
||||
|
||||
// Set transfer functions for RGB.
|
||||
AttributeMap contrastAttrs;
|
||||
contrastAttrs.Set(eComponentTransferFunctionType,
|
||||
(uint32_t)SVG_FECOMPONENTTRANSFER_TYPE_LINEAR);
|
||||
contrastAttrs.Set(eComponentTransferFunctionSlope, value);
|
||||
contrastAttrs.Set(eComponentTransferFunctionIntercept, intercept);
|
||||
aDescr.Attributes().Set(eComponentTransferFunctionR, contrastAttrs);
|
||||
aDescr.Attributes().Set(eComponentTransferFunctionG, contrastAttrs);
|
||||
aDescr.Attributes().Set(eComponentTransferFunctionB, contrastAttrs);
|
||||
|
||||
// Set identity transfer function for A.
|
||||
AttributeMap identityAttrs;
|
||||
identityAttrs.Set(eComponentTransferFunctionType,
|
||||
(uint32_t)SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY);
|
||||
aDescr.Attributes().Set(eComponentTransferFunctionA, identityAttrs);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsCSSFilterInstance::SetAttributesForDropShadow(FilterPrimitiveDescription& aDescr)
|
||||
{
|
||||
|
@ -64,6 +64,7 @@ private:
|
||||
*/
|
||||
nsresult SetAttributesForBlur(FilterPrimitiveDescription& aDescr);
|
||||
nsresult SetAttributesForBrightness(FilterPrimitiveDescription& aDescr);
|
||||
nsresult SetAttributesForContrast(FilterPrimitiveDescription& aDescr);
|
||||
nsresult SetAttributesForDropShadow(FilterPrimitiveDescription& aDescr);
|
||||
nsresult SetAttributesForGrayscale(FilterPrimitiveDescription& aDescr);
|
||||
nsresult SetAttributesForHueRotate(FilterPrimitiveDescription& aDescr);
|
||||
|
Loading…
Reference in New Issue
Block a user