Bug 472410. Don't adjust selection colors if the background is a -moz-appearance that we can't know anything about. r+sr=roc

This commit is contained in:
Michael Ventnor 2009-01-09 13:29:38 +13:00
Родитель d3c96eb2d7
Коммит 4d2d429ffe
4 изменённых файлов: 40 добавлений и 19 удалений

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

@ -488,8 +488,9 @@ nsCSSRendering::PaintBorder(nsPresContext* aPresContext,
// in NavQuirks mode we want to use the parent's context as a starting point
// for determining the background color
const nsStyleBackground* bgColor = nsCSSRendering::FindNonTransparentBackground
nsStyleContext* bgContext = nsCSSRendering::FindNonTransparentBackground
(aStyleContext, compatMode == eCompatibility_NavQuirks ? PR_TRUE : PR_FALSE);
const nsStyleBackground* bgColor = bgContext->GetStyleBackground();
border = aBorderStyle.GetComputedBorder();
if ((0 == border.left) && (0 == border.right) &&
@ -614,8 +615,9 @@ nsCSSRendering::PaintOutline(nsPresContext* aPresContext,
return;
}
const nsStyleBackground* bgColor = nsCSSRendering::FindNonTransparentBackground
nsStyleContext* bgContext = nsCSSRendering::FindNonTransparentBackground
(aStyleContext, PR_FALSE);
const nsStyleBackground* bgColor = bgContext->GetStyleBackground();
// get the radius for our outline
GetBorderRadiusTwips(aOutlineStyle.mOutlineRadius, aBorderArea.width,
@ -829,13 +831,12 @@ ComputeBackgroundAnchorPoint(const nsStyleBackground& aColor,
}
}
const nsStyleBackground*
nsStyleContext*
nsCSSRendering::FindNonTransparentBackground(nsStyleContext* aContext,
PRBool aStartAtParent /*= PR_FALSE*/)
{
NS_ASSERTION(aContext, "Cannot find NonTransparentBackground in a null context" );
const nsStyleBackground* result = nsnull;
nsStyleContext* context = nsnull;
if (aStartAtParent) {
context = aContext->GetParent();
@ -845,13 +846,21 @@ nsCSSRendering::FindNonTransparentBackground(nsStyleContext* aContext,
}
while (context) {
result = context->GetStyleBackground();
if (NS_GET_A(result->mBackgroundColor) > 0)
const nsStyleBackground* bg = context->GetStyleBackground();
if (NS_GET_A(bg->mBackgroundColor) > 0)
break;
context = context->GetParent();
const nsStyleDisplay* display = context->GetStyleDisplay();
if (display->mAppearance)
break;
nsStyleContext* parent = context->GetParent();
if (!parent)
break;
context = parent;
}
return result;
return context;
}

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

@ -125,12 +125,15 @@ struct nsCSSRendering {
PRBool* aIsCanvas);
/**
* Find a non-transparent background, for various table-related and
* HR-related backwards-compatibility hacks. Be very hesitant if
* you're considering calling this function -- it's usually not what
* you want.
* Find a style context containing a non-transparent background,
* for various table-related and HR-related backwards-compatibility hacks.
* This function will also stop if it finds a -moz-appearance value, as
* the theme may draw a widget as a background.
*
* Be very hesitant if you're considering calling this function -- it's
* usually not what you want.
*/
static const nsStyleBackground*
static nsStyleContext*
FindNonTransparentBackground(nsStyleContext* aContext,
PRBool aStartAtParent = PR_FALSE);

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

@ -3060,17 +3060,25 @@ nsTextPaintStyle::InitCommonColors()
nsStyleContext* sc = mFrame->GetStyleContext();
const nsStyleBackground* bg =
nsStyleContext* bgContext =
nsCSSRendering::FindNonTransparentBackground(sc);
NS_ASSERTION(bg, "Cannot find NonTransparentBackground.");
NS_ASSERTION(bgContext, "Cannot find NonTransparentBackground.");
const nsStyleBackground* bg = bgContext->GetStyleBackground();
nscolor defaultBgColor = mPresContext->DefaultBackgroundColor();
NS_ASSERTION(NS_GET_A(defaultBgColor) == 255,
"default background color is not opaque");
mFrameBackgroundColor = NS_ComposeColors(defaultBgColor,
bg->mBackgroundColor);
if (bgContext->GetStyleDisplay()->mAppearance) {
// Assume a native widget has sufficient contrast always
mSufficientContrast = 0;
mInitCommonColors = PR_TRUE;
return;
}
NS_ASSERTION(NS_GET_A(defaultBgColor) == 255,
"default background color is not opaque");
nsILookAndFeel* look = mPresContext->LookAndFeel();
nscolor defaultWindowBackgroundColor, selectionTextColor, selectionBGColor;
look->GetColor(nsILookAndFeel::eColor_TextSelectBackground,

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

@ -6385,7 +6385,8 @@ nsTableFrame::PaintBCBorders(nsIRenderingContext& aRenderingContext,
PRInt32 startRowY = (GetPrevInFlow()) ? 0 : childAreaOffset.top; // y position of first row in damage area
const nsStyleBackground* bgColor = nsCSSRendering::FindNonTransparentBackground(mStyleContext);
nsStyleContext* bgContext = nsCSSRendering::FindNonTransparentBackground(mStyleContext);
const nsStyleBackground* bgColor = bgContext->GetStyleBackground();
// determine the damage area in terms of rows and columns and finalize startColX and startRowY
PRUint32 startRowIndex, endRowIndex, startColIndex, endColIndex;
startRowIndex = endRowIndex = startColIndex = endColIndex = 0;