Bug 1678487 - Color-manage system colors from style too. r=mstange

Differential Revision: https://phabricator.services.mozilla.com/D104947
This commit is contained in:
Emilio Cobos Álvarez 2021-03-08 02:02:42 +00:00
Родитель 4b0411a401
Коммит 5506f49e17
1 изменённых файлов: 15 добавлений и 18 удалений

Просмотреть файл

@ -824,26 +824,23 @@ nsresult nsXPLookAndFeel::GetColorValue(ColorID aID,
}
if (NS_SUCCEEDED(NativeGetColor(aID, aResult))) {
// TODO(bug 1678487): We should color-correct style colors as well when in
// the traversal.
if (!mozilla::ServoStyleSet::IsInServoTraversal()) {
MOZ_ASSERT(NS_IsMainThread());
if (gfxPlatform::GetCMSMode() == CMSMode::All &&
!IsSpecialColor(aID, aResult)) {
qcms_transform* transform = gfxPlatform::GetCMSInverseRGBTransform();
if (transform) {
uint8_t color[4];
color[0] = NS_GET_R(aResult);
color[1] = NS_GET_G(aResult);
color[2] = NS_GET_B(aResult);
color[3] = NS_GET_A(aResult);
qcms_transform_data(transform, color, color, 1);
aResult = NS_RGBA(color[0], color[1], color[2], color[3]);
}
if (gfxPlatform::GetCMSMode() == CMSMode::All &&
!IsSpecialColor(aID, aResult)) {
qcms_transform* transform = gfxPlatform::GetCMSInverseRGBTransform();
if (transform) {
uint8_t color[4];
color[0] = NS_GET_R(aResult);
color[1] = NS_GET_G(aResult);
color[2] = NS_GET_B(aResult);
color[3] = NS_GET_A(aResult);
qcms_transform_data(transform, color, color, 1);
aResult = NS_RGBA(color[0], color[1], color[2], color[3]);
}
CACHE_COLOR(aID, aResult);
}
// NOTE: Servo holds a lock and the main thread is paused, so writing to the
// global cache here is fine.
CACHE_COLOR(aID, aResult);
return NS_OK;
}