Bug 1341703 - Part 3. Handle nsStyleBorder::CalcDifference off main thread. r=heycam

Image loading status can be accessed in main thread only, so we can not use
nsStyleImage::IsLoaded in nsStyleBorder::CalcDifference, which might be executed
on a background thread.

The drawback of this change is we may paint a border-image, once, even before it
was actually loaded, which is a waste, because we have nothing to draw yet.

PS:
We did not check nsStyleImage::IsLoaded in both background-image and mask-image's
CalcDifference.

MozReview-Commit-ID: 5knH6dZziL8

--HG--
extra : rebase_source : 8e854960bfec130fe06e57b5e898651814e7f36e
This commit is contained in:
cku 2017-04-18 15:04:35 +08:00
Родитель 1cfdb6e485
Коммит 10c26c73a2
1 изменённых файлов: 6 добавлений и 4 удалений

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

@ -479,7 +479,11 @@ nsStyleBorder::CalcDifference(const nsStyleBorder& aNewData) const
return nsChangeHint_RepaintFrame;
}
if (IsBorderImageLoaded() || aNewData.IsBorderImageLoaded()) {
// Loading status of the border image can be accessed in main thread only
// while CalcDifference might be executed on a background thread. As a
// result, we have to check mBorderImage* fields even before border image was
// actually loaded.
if (!mBorderImageSource.IsEmpty() || !aNewData.mBorderImageSource.IsEmpty()) {
if (mBorderImageSource != aNewData.mBorderImageSource ||
mBorderImageRepeatH != aNewData.mBorderImageRepeatH ||
mBorderImageRepeatV != aNewData.mBorderImageRepeatV ||
@ -508,9 +512,7 @@ nsStyleBorder::CalcDifference(const nsStyleBorder& aNewData) const
return nsChangeHint_NeutralChange;
}
// mBorderImage* fields are checked only when border image was
// actualy loaded. But we need to return neutral change even when
// they are not actually used.
// mBorderImage* fields are checked only when border-image is not 'none'.
if (mBorderImageSource != aNewData.mBorderImageSource ||
mBorderImageRepeatH != aNewData.mBorderImageRepeatH ||
mBorderImageRepeatV != aNewData.mBorderImageRepeatV ||