Bug 579276. Part 5: Set CONTENT_NO_TEXT and CONTENT_NO_TEXT_OVER_TRANSPARENT flags. r=tnikkel

This commit is contained in:
Robert O'Callahan 2010-09-02 21:18:40 +12:00
Родитель 99c9793ffb
Коммит 69edc7671f
1 изменённых файлов: 36 добавлений и 2 удалений

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

@ -159,7 +159,8 @@ protected:
public:
ThebesLayerData() :
mActiveScrolledRoot(nsnull), mLayer(nsnull),
mIsSolidColorInVisibleRegion(PR_FALSE) {}
mIsSolidColorInVisibleRegion(PR_FALSE),
mHasText(PR_FALSE), mHasTextOverTransparent(PR_FALSE) {}
/**
* Record that an item has been added to the ThebesLayer, so we
* need to update our regions.
@ -228,6 +229,15 @@ protected:
* True if every pixel in mVisibleRegion will have color mSolidColor.
*/
PRPackedBool mIsSolidColorInVisibleRegion;
/**
* True if there is any text visible in the layer.
*/
PRPackedBool mHasText;
/**
* True if there is any text visible in the layer that's over
* transparent pixels in the layer.
*/
PRPackedBool mHasTextOverTransparent;
};
/**
@ -839,7 +849,10 @@ ContainerState::PopThebesLayerData()
}
userData->mForcedBackgroundColor = backgroundColor;
}
PRUint32 flags = isOpaque ? Layer::CONTENT_OPAQUE : 0;
PRUint32 flags =
(isOpaque ? Layer::CONTENT_OPAQUE : 0) |
(data->mHasText ? 0 : Layer::CONTENT_NO_TEXT) |
(data->mHasTextOverTransparent ? 0 : Layer::CONTENT_NO_TEXT_OVER_TRANSPARENT);
layer->SetContentFlags(flags);
if (lastIndex > 0) {
@ -860,6 +873,22 @@ ContainerState::PopThebesLayerData()
mThebesLayerDataStack.RemoveElementAt(lastIndex);
}
static PRBool
IsText(nsDisplayItem* aItem) {
switch (aItem->GetType()) {
case nsDisplayItem::TYPE_TEXT:
case nsDisplayItem::TYPE_BULLET:
case nsDisplayItem::TYPE_HEADER_FOOTER:
case nsDisplayItem::TYPE_MATHML_CHAR_FOREGROUND:
#ifdef MOZ_XUL
case nsDisplayItem::TYPE_XUL_TEXT_BOX:
#endif
return PR_TRUE;
default:
return PR_FALSE;
}
}
void
ContainerState::ThebesLayerData::Accumulate(nsDisplayListBuilder* aBuilder,
nsDisplayItem* aItem,
@ -899,6 +928,11 @@ ContainerState::ThebesLayerData::Accumulate(nsDisplayListBuilder* aBuilder,
if (tmp.GetNumRects() <= 4) {
mOpaqueRegion = tmp;
}
} else if (IsText(aItem)) {
mHasText = PR_TRUE;
if (!mOpaqueRegion.Contains(aVisibleRect)) {
mHasTextOverTransparent = PR_TRUE;
}
}
}