зеркало из https://github.com/mozilla/pjs.git
Bug 453916: treat transparency strictly as a special case of color alpha. r+sr=dbaron
This commit is contained in:
Родитель
dd5dfe2893
Коммит
10b58f92ef
|
@ -402,12 +402,6 @@ nsMathMLElement::MapMathMLAttributesInto(const nsMappedAttributes* aAttributes,
|
|||
nscolor color;
|
||||
if (value->GetColorValue(color)) {
|
||||
aData->mColorData->mBackColor.SetColorValue(color);
|
||||
} else {
|
||||
nsAutoString str(value->GetStringValue());
|
||||
str.CompressWhitespace();
|
||||
if (str.EqualsLiteral("transparent")) {
|
||||
aData->mColorData->mBackColor.SetColorValue(NS_RGBA(0,0,0,0));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -201,6 +201,7 @@ GFX_COLOR(tan, NS_RGB(210, 180, 140))
|
|||
GFX_COLOR(teal, NS_RGB( 0, 128, 128))
|
||||
GFX_COLOR(thistle, NS_RGB(216, 191, 216))
|
||||
GFX_COLOR(tomato, NS_RGB(255, 99, 71))
|
||||
GFX_COLOR(transparent, NS_RGBA(0, 0, 0, 0))
|
||||
GFX_COLOR(turquoise, NS_RGB( 64, 224, 208))
|
||||
GFX_COLOR(violet, NS_RGB(238, 130, 238))
|
||||
GFX_COLOR(wheat, NS_RGB(245, 222, 179))
|
||||
|
|
|
@ -596,14 +596,12 @@ nsCSSRendering::PaintBorder(nsPresContext* aPresContext,
|
|||
|
||||
// pull out styles, colors, composite colors
|
||||
NS_FOR_CSS_SIDES (i) {
|
||||
PRBool transparent, foreground;
|
||||
PRBool foreground;
|
||||
borderStyles[i] = aBorderStyle.GetBorderStyle(i);
|
||||
aBorderStyle.GetBorderColor(i, borderColors[i], transparent, foreground);
|
||||
aBorderStyle.GetBorderColor(i, borderColors[i], foreground);
|
||||
aBorderStyle.GetCompositeColors(i, &compositeColors[i]);
|
||||
|
||||
if (transparent)
|
||||
borderColors[i] = 0x0;
|
||||
else if (foreground)
|
||||
if (foreground)
|
||||
borderColors[i] = ourColor->mColor;
|
||||
}
|
||||
|
||||
|
@ -963,7 +961,7 @@ nsCSSRendering::FindNonTransparentBackground(nsStyleContext* aContext,
|
|||
|
||||
while (context) {
|
||||
result = context->GetStyleBackground();
|
||||
if (0 == (result->mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT))
|
||||
if (NS_GET_A(result->mBackgroundColor) > 0)
|
||||
break;
|
||||
|
||||
context = context->GetParent();
|
||||
|
@ -1301,7 +1299,7 @@ nsCSSRendering::PaintBackground(nsPresContext* aPresContext,
|
|||
|
||||
nsIViewManager* vm = aPresContext->GetViewManager();
|
||||
|
||||
if (canvasColor.mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT) {
|
||||
if (NS_GET_A(canvasColor.mBackgroundColor) == 0) {
|
||||
nsIView* rootView;
|
||||
vm->GetRootView(rootView);
|
||||
if (!rootView->GetParent()) {
|
||||
|
@ -1314,7 +1312,6 @@ nsCSSRendering::PaintBackground(nsPresContext* aPresContext,
|
|||
if (!widgetIsTransparent) {
|
||||
// Ensure that we always paint a color for the root (in case there's
|
||||
// no background at all or a partly transparent image).
|
||||
canvasColor.mBackgroundFlags &= ~NS_STYLE_BG_COLOR_TRANSPARENT;
|
||||
canvasColor.mBackgroundColor = aPresContext->DefaultBackgroundColor();
|
||||
}
|
||||
}
|
||||
|
@ -1414,10 +1411,9 @@ IsSolidBorderEdge(const nsStyleBorder& aBorder, PRUint32 aSide)
|
|||
return PR_FALSE;
|
||||
|
||||
nscolor color;
|
||||
PRBool isTransparent;
|
||||
PRBool isForeground;
|
||||
aBorder.GetBorderColor(aSide, color, isTransparent, isForeground);
|
||||
return !isTransparent && NS_GET_A(color) == 255;
|
||||
aBorder.GetBorderColor(aSide, color, isForeground);
|
||||
return NS_GET_A(color) == 255;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1590,8 +1586,7 @@ nsCSSRendering::PaintBackgroundWithSC(nsPresContext* aPresContext,
|
|||
// on the dirty rect before accounting for the background-position.
|
||||
nscoord tileWidth = imageSize.width;
|
||||
nscoord tileHeight = imageSize.height;
|
||||
PRBool needBackgroundColor = !(aColor.mBackgroundFlags &
|
||||
NS_STYLE_BG_COLOR_TRANSPARENT);
|
||||
PRBool needBackgroundColor = NS_GET_A(aColor.mBackgroundColor) > 0;
|
||||
PRIntn repeat = aColor.mBackgroundRepeat;
|
||||
|
||||
switch (repeat) {
|
||||
|
@ -2331,7 +2326,7 @@ nsCSSRendering::PaintBackgroundColor(nsPresContext* aPresContext,
|
|||
// color if we're not completely transparent. See the corresponding check
|
||||
// for whether we're allowed to paint background images in
|
||||
// PaintBackgroundWithSC before the first call to PaintBackgroundColor.
|
||||
if ((aColor.mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT) &&
|
||||
if (NS_GET_A(aColor.mBackgroundColor) == 0 &&
|
||||
(aCanPaintNonWhite || aColor.IsTransparent())) {
|
||||
// nothing to paint
|
||||
return;
|
||||
|
|
|
@ -253,31 +253,6 @@ ComputeBorderCornerDimensions(const gfxRect& aOuterRect,
|
|||
}
|
||||
}
|
||||
|
||||
// And this is what we get due to the aRidiculous aPrefix aConvetion
|
||||
// aFor aArguments (sic).
|
||||
static PRBool
|
||||
AreCompositeColorsEqual(nsBorderColors *aA, nsBorderColors *aB)
|
||||
{
|
||||
if (aA == aB)
|
||||
return PR_TRUE;
|
||||
|
||||
if (!aA || !aB)
|
||||
return PR_FALSE;
|
||||
|
||||
while (aA && aB) {
|
||||
if (aA->mTransparent != aB->mTransparent)
|
||||
return PR_FALSE;
|
||||
if (!aA->mTransparent && (aA->mColor != aB->mColor))
|
||||
return PR_FALSE;
|
||||
aA = aA->mNext;
|
||||
aB = aB->mNext;
|
||||
}
|
||||
|
||||
// both should be NULL if these are equal, otherwise one
|
||||
// has more colors than another
|
||||
return (aA == aB);
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsCSSBorderRenderer::AreBorderSideFinalStylesSame(PRUint8 aSides)
|
||||
{
|
||||
|
@ -295,7 +270,8 @@ nsCSSBorderRenderer::AreBorderSideFinalStylesSame(PRUint8 aSides)
|
|||
|
||||
if (mBorderStyles[firstStyle] != mBorderStyles[i] ||
|
||||
mBorderColors[firstStyle] != mBorderColors[i] ||
|
||||
!AreCompositeColorsEqual(mCompositeColors[firstStyle], mCompositeColors[i]))
|
||||
!nsBorderColors::Equal(mCompositeColors[firstStyle],
|
||||
mCompositeColors[i]))
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
|
@ -692,9 +668,6 @@ ComputeCompositeColorForLine(PRUint32 aLineIndex,
|
|||
while (aLineIndex-- && aBorderColors->mNext)
|
||||
aBorderColors = aBorderColors->mNext;
|
||||
|
||||
if (aBorderColors->mTransparent)
|
||||
return gfxRGBA(0.0, 0.0, 0.0, 0.0);
|
||||
|
||||
return gfxRGBA(aBorderColors->mColor);
|
||||
}
|
||||
|
||||
|
|
|
@ -490,16 +490,16 @@ nsDisplayBackground::IsOpaque(nsDisplayListBuilder* aBuilder) {
|
|||
if (mIsThemed)
|
||||
return PR_FALSE;
|
||||
|
||||
PRBool isCanvas;
|
||||
const nsStyleBackground* bg;
|
||||
PRBool isCanvas; // not used
|
||||
PRBool hasBG =
|
||||
nsCSSRendering::FindBackground(mFrame->PresContext(), mFrame, &bg, &isCanvas);
|
||||
if (!hasBG || (bg->mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT) ||
|
||||
bg->mBackgroundClip != NS_STYLE_BG_CLIP_BORDER ||
|
||||
nsLayoutUtils::HasNonZeroSide(mFrame->GetStyleBorder()->mBorderRadius) ||
|
||||
NS_GET_A(bg->mBackgroundColor) < 255)
|
||||
return PR_FALSE;
|
||||
return PR_TRUE;
|
||||
nsCSSRendering::FindBackground(mFrame->PresContext(), mFrame,
|
||||
&bg, &isCanvas);
|
||||
|
||||
return (hasBG && NS_GET_A(bg->mBackgroundColor) == 255 &&
|
||||
bg->mBackgroundClip == NS_STYLE_BG_CLIP_BORDER &&
|
||||
!nsLayoutUtils::HasNonZeroSide(mFrame->GetStyleBorder()->
|
||||
mBorderRadius));
|
||||
}
|
||||
|
||||
PRBool
|
||||
|
|
|
@ -2725,8 +2725,6 @@ nsLayoutUtils::GetFrameTransparency(nsIFrame* aFrame) {
|
|||
const nsStyleBackground* bg;
|
||||
if (!nsCSSRendering::FindBackground(aFrame->PresContext(), aFrame, &bg, &isCanvas))
|
||||
return eTransparencyTransparent;
|
||||
if (bg->mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT)
|
||||
return eTransparencyTransparent;
|
||||
if (NS_GET_A(bg->mBackgroundColor) < 255)
|
||||
return eTransparencyTransparent;
|
||||
if (bg->mBackgroundClip != NS_STYLE_BG_CLIP_BORDER)
|
||||
|
|
|
@ -193,11 +193,10 @@
|
|||
#define NS_STYLE_VOLUME_X_LOUD 5
|
||||
|
||||
// See nsStyleColor
|
||||
#define NS_STYLE_COLOR_TRANSPARENT 0
|
||||
#define NS_STYLE_COLOR_MOZ_USE_TEXT_COLOR 1
|
||||
#ifdef GFX_HAS_INVERT
|
||||
#define NS_STYLE_COLOR_INVERT 1
|
||||
#define NS_STYLE_COLOR_INVERT 2
|
||||
#endif
|
||||
#define NS_STYLE_COLOR_MOZ_USE_TEXT_COLOR 2
|
||||
|
||||
// See nsStyleColor
|
||||
#define NS_COLOR_MOZ_HYPERLINKTEXT -1
|
||||
|
@ -206,7 +205,7 @@
|
|||
#define NS_COLOR_CURRENTCOLOR -4
|
||||
|
||||
// See nsStyleBackground
|
||||
#define NS_STYLE_BG_COLOR_TRANSPARENT 0x01
|
||||
// 0x01 was background-color:transparent
|
||||
#define NS_STYLE_BG_IMAGE_NONE 0x02
|
||||
#define NS_STYLE_BG_X_POSITION_PERCENT 0x04
|
||||
#define NS_STYLE_BG_X_POSITION_LENGTH 0x08
|
||||
|
|
|
@ -3036,9 +3036,6 @@ nsTextPaintStyle::InitSelectionColors()
|
|||
if (sc) {
|
||||
const nsStyleBackground* bg = sc->GetStyleBackground();
|
||||
mSelectionBGColor = bg->mBackgroundColor;
|
||||
if (bg->mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT) {
|
||||
mSelectionBGColor = NS_RGBA(0,0,0,0);
|
||||
}
|
||||
mSelectionTextColor = sc->GetStyleColor()->mColor;
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
|
|
@ -2047,7 +2047,7 @@ nsMathMLChar::Display(nsDisplayListBuilder* aBuilder,
|
|||
else if (mRect.width && mRect.height) {
|
||||
const nsStyleBackground* backg = styleContext->GetStyleBackground();
|
||||
if (styleContext != parentContext &&
|
||||
0 == (backg->mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT)) {
|
||||
NS_GET_A(backg->mBackgroundColor) > 0) {
|
||||
rv = aLists.BorderBackground()->AppendNewToTop(new (aBuilder)
|
||||
nsDisplayMathMLCharBackground(aForFrame, mRect, styleContext));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
|
|
@ -233,10 +233,20 @@ nsCSSCompressedDataBlock::MapRuleInfoInto(nsRuleData *aRuleData) const
|
|||
if (iProp == eCSSProperty_background_color) {
|
||||
// Force non-'transparent' background
|
||||
// colors to the user's default.
|
||||
// We have the value in the form it was
|
||||
// specified at this point, so we have to
|
||||
// look for both the keyword 'transparent'
|
||||
// and its equivalent in rgba notation.
|
||||
nsCSSUnit u = target->GetUnit();
|
||||
if (u != eCSSUnit_Enumerated &&
|
||||
u != eCSSUnit_Inherit &&
|
||||
u != eCSSUnit_Initial) {
|
||||
nsDependentString buf;
|
||||
|
||||
if ((u == eCSSUnit_Color &&
|
||||
NS_GET_A(target->GetColorValue())
|
||||
> 0) ||
|
||||
(u == eCSSUnit_String &&
|
||||
!nsGkAtoms::transparent->
|
||||
Equals(target->GetStringValue(buf))) ||
|
||||
(u == eCSSUnit_EnumColor)) {
|
||||
target->SetColorValue(aRuleData->
|
||||
mPresContext->
|
||||
DefaultBackgroundColor());
|
||||
|
|
|
@ -450,7 +450,6 @@ CSS_KEY(threedshadow, threedshadow)
|
|||
CSS_KEY(toggle, toggle)
|
||||
CSS_KEY(top, top)
|
||||
CSS_KEY(top-outside, top_outside)
|
||||
CSS_KEY(transparent, transparent)
|
||||
CSS_KEY(tri-state, tri_state)
|
||||
CSS_KEY(ultra-condensed, ultra_condensed)
|
||||
CSS_KEY(ultra-expanded, ultra_expanded)
|
||||
|
|
|
@ -3423,14 +3423,6 @@ CSSParserImpl::ParseColor(nsCSSValue& aValue)
|
|||
nsCSSKeyword keyword = nsCSSKeywords::LookupKeyword(tk->mIdent);
|
||||
if (eCSSKeyword_UNKNOWN < keyword) { // known keyword
|
||||
PRInt32 value;
|
||||
// XXX Now that non-cairo is no longer supported, we should remove
|
||||
// the special parsing of transparent for background-color and
|
||||
// border-color. (It currently overrides this, since keywords
|
||||
// are checked earlier in ParseVariant.)
|
||||
if (keyword == eCSSKeyword_transparent) {
|
||||
aValue.SetColorValue(NS_RGBA(0, 0, 0, 0));
|
||||
return PR_TRUE;
|
||||
}
|
||||
if (nsCSSProps::FindKeyword(keyword, nsCSSProps::kColorKTable, value)) {
|
||||
aValue.SetIntValue(value, eCSSUnit_EnumColor);
|
||||
return PR_TRUE;
|
||||
|
@ -5061,8 +5053,7 @@ CSSParserImpl::ParseSingleValueProperty(nsCSSValue& aValue,
|
|||
return ParseVariant(aValue, VARIANT_HK,
|
||||
nsCSSProps::kBackgroundClipKTable);
|
||||
case eCSSProperty_background_color:
|
||||
return ParseVariant(aValue, VARIANT_HCK,
|
||||
nsCSSProps::kBackgroundColorKTable);
|
||||
return ParseVariant(aValue, VARIANT_HC, nsnull);
|
||||
case eCSSProperty_background_image:
|
||||
return ParseVariant(aValue, VARIANT_HUO, nsnull);
|
||||
case eCSSProperty__moz_background_inline_policy:
|
||||
|
@ -5608,8 +5599,7 @@ CSSParserImpl::ParseBackground()
|
|||
|
||||
// Fill in the values that the shorthand will set if we don't find
|
||||
// other values.
|
||||
mTempData.mColor.mBackColor.SetIntValue(NS_STYLE_BG_COLOR_TRANSPARENT,
|
||||
eCSSUnit_Enumerated);
|
||||
mTempData.mColor.mBackColor.SetColorValue(NS_RGBA(0, 0, 0, 0));
|
||||
mTempData.SetPropertyBit(eCSSProperty_background_color);
|
||||
mTempData.mColor.mBackImage.SetNoneValue();
|
||||
mTempData.SetPropertyBit(eCSSProperty_background_image);
|
||||
|
|
|
@ -276,7 +276,7 @@ CSS_PROP_BACKENDONLY(azimuth, azimuth, Azimuth, Aural, mAzimuth, eCSSType_Value,
|
|||
CSS_PROP_SHORTHAND(background, background, Background)
|
||||
CSS_PROP_BACKGROUND(background-attachment, background_attachment, BackgroundAttachment, Color, mBackAttachment, eCSSType_Value, kBackgroundAttachmentKTable)
|
||||
CSS_PROP_BACKGROUND(-moz-background-clip, _moz_background_clip, MozBackgroundClip, Color, mBackClip, eCSSType_Value, kBackgroundClipKTable)
|
||||
CSS_PROP_BACKGROUND(background-color, background_color, BackgroundColor, Color, mBackColor, eCSSType_Value, kBackgroundColorKTable)
|
||||
CSS_PROP_BACKGROUND(background-color, background_color, BackgroundColor, Color, mBackColor, eCSSType_Value, nsnull)
|
||||
CSS_PROP_BACKGROUND(background-image, background_image, BackgroundImage, Color, mBackImage, eCSSType_Value, nsnull)
|
||||
CSS_PROP_BACKGROUND(-moz-background-inline-policy, _moz_background_inline_policy, MozBackgroundInlinePolicy, Color, mBackInlinePolicy, eCSSType_Value, kBackgroundInlinePolicyKTable)
|
||||
CSS_PROP_BACKGROUND(-moz-background-origin, _moz_background_origin, MozBackgroundOrigin, Color, mBackOrigin, eCSSType_Value, kBackgroundOriginKTable)
|
||||
|
|
|
@ -354,11 +354,6 @@ const PRInt32 nsCSSProps::kBackgroundAttachmentKTable[] = {
|
|||
eCSSKeyword_UNKNOWN,-1
|
||||
};
|
||||
|
||||
const PRInt32 nsCSSProps::kBackgroundColorKTable[] = {
|
||||
eCSSKeyword_transparent, NS_STYLE_BG_COLOR_TRANSPARENT,
|
||||
eCSSKeyword_UNKNOWN,-1
|
||||
};
|
||||
|
||||
const PRInt32 nsCSSProps::kBackgroundClipKTable[] = {
|
||||
eCSSKeyword_border, NS_STYLE_BG_CLIP_BORDER,
|
||||
eCSSKeyword_padding, NS_STYLE_BG_CLIP_PADDING,
|
||||
|
@ -406,7 +401,6 @@ const PRInt32 nsCSSProps::kBorderCollapseKTable[] = {
|
|||
};
|
||||
|
||||
const PRInt32 nsCSSProps::kBorderColorKTable[] = {
|
||||
eCSSKeyword_transparent, NS_STYLE_COLOR_TRANSPARENT,
|
||||
eCSSKeyword__moz_use_text_color, NS_STYLE_COLOR_MOZ_USE_TEXT_COLOR,
|
||||
eCSSKeyword_UNKNOWN,-1
|
||||
};
|
||||
|
|
|
@ -120,7 +120,6 @@ public:
|
|||
static const PRInt32 kAzimuthKTable[];
|
||||
static const PRInt32 kBackgroundAttachmentKTable[];
|
||||
static const PRInt32 kBackgroundClipKTable[];
|
||||
static const PRInt32 kBackgroundColorKTable[];
|
||||
static const PRInt32 kBackgroundInlinePolicyKTable[];
|
||||
static const PRInt32 kBackgroundOriginKTable[];
|
||||
static const PRInt32 kBackgroundPositionKTable[];
|
||||
|
|
|
@ -1056,18 +1056,10 @@ nsComputedDOMStyle::GetBackgroundColor(nsIDOMCSSValue** aValue)
|
|||
NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
const nsStyleBackground* color = GetStyleBackground();
|
||||
|
||||
if (color->mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT) {
|
||||
const nsAFlatCString& backgroundColor =
|
||||
nsCSSProps::ValueToKeyword(NS_STYLE_BG_COLOR_TRANSPARENT,
|
||||
nsCSSProps::kBackgroundColorKTable);
|
||||
val->SetIdent(backgroundColor);
|
||||
} else {
|
||||
nsresult rv = SetToRGBAColor(val, color->mBackgroundColor);
|
||||
if (NS_FAILED(rv)) {
|
||||
delete val;
|
||||
return rv;
|
||||
}
|
||||
nsresult rv = SetToRGBAColor(val, color->mBackgroundColor);
|
||||
if (NS_FAILED(rv)) {
|
||||
delete val;
|
||||
return rv;
|
||||
}
|
||||
|
||||
return CallQueryInterface(val, aValue);
|
||||
|
@ -3055,15 +3047,11 @@ nsComputedDOMStyle::GetBorderColorsFor(PRUint8 aSide, nsIDOMCSSValue** aValue)
|
|||
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
if (borderColors->mTransparent) {
|
||||
primitive->SetIdent(nsGkAtoms::transparent);
|
||||
} else {
|
||||
nsresult rv = SetToRGBAColor(primitive, borderColors->mColor);
|
||||
if (NS_FAILED(rv)) {
|
||||
delete valueList;
|
||||
delete primitive;
|
||||
return rv;
|
||||
}
|
||||
nsresult rv = SetToRGBAColor(primitive, borderColors->mColor);
|
||||
if (NS_FAILED(rv)) {
|
||||
delete valueList;
|
||||
delete primitive;
|
||||
return rv;
|
||||
}
|
||||
|
||||
PRBool success = valueList->AppendCSSValue(primitive);
|
||||
|
@ -3125,23 +3113,16 @@ nsComputedDOMStyle::GetBorderColorFor(PRUint8 aSide, nsIDOMCSSValue** aValue)
|
|||
NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
nscolor color;
|
||||
PRBool transparent;
|
||||
PRBool foreground;
|
||||
GetStyleBorder()->GetBorderColor(aSide, color, transparent, foreground);
|
||||
if (transparent) {
|
||||
val->SetIdent(nsGkAtoms::transparent);
|
||||
} else {
|
||||
if (foreground) {
|
||||
const nsStyleColor* colorStruct = GetStyleColor();
|
||||
color = colorStruct->mColor;
|
||||
}
|
||||
// XXX else?
|
||||
GetStyleBorder()->GetBorderColor(aSide, color, foreground);
|
||||
if (foreground) {
|
||||
color = GetStyleColor()->mColor;
|
||||
}
|
||||
|
||||
nsresult rv = SetToRGBAColor(val, color);
|
||||
if (NS_FAILED(rv)) {
|
||||
delete val;
|
||||
return rv;
|
||||
}
|
||||
nsresult rv = SetToRGBAColor(val, color);
|
||||
if (NS_FAILED(rv)) {
|
||||
delete val;
|
||||
return rv;
|
||||
}
|
||||
|
||||
return CallQueryInterface(val, aValue);
|
||||
|
|
|
@ -187,13 +187,13 @@ ProcessTableRulesAttribute(void* aStyleStruct,
|
|||
borderData->SetBorderStyle(aSide, bStyle);
|
||||
|
||||
nscolor borderColor;
|
||||
PRBool transparent, foreground;
|
||||
borderData->GetBorderColor(aSide, borderColor, transparent, foreground);
|
||||
if (transparent || foreground) {
|
||||
PRBool foreground;
|
||||
borderData->GetBorderColor(aSide, borderColor, foreground);
|
||||
if (NS_GET_A(borderColor) == 0 || foreground) {
|
||||
// use the table's border color if it is set, otherwise use black
|
||||
nscolor tableBorderColor;
|
||||
tableBorderData->GetBorderColor(aSide, tableBorderColor, transparent, foreground);
|
||||
borderColor = (transparent || foreground) ? NS_RGB(0,0,0) : tableBorderColor;
|
||||
tableBorderData->GetBorderColor(aSide, tableBorderColor, foreground);
|
||||
borderColor = (NS_GET_A(borderColor) == 0 || foreground) ? NS_RGB(0,0,0) : tableBorderColor;
|
||||
borderData->SetBorderColor(aSide, borderColor);
|
||||
}
|
||||
// set the border width to be 1 pixel
|
||||
|
|
|
@ -1719,7 +1719,7 @@ nsRuleNode::SetDefaultOnRoot(const nsStyleStructID aSID, nsStyleContext* aContex
|
|||
}
|
||||
case eStyleStruct_Background:
|
||||
{
|
||||
nsStyleBackground* bg = new (mPresContext) nsStyleBackground(mPresContext);
|
||||
nsStyleBackground* bg = new (mPresContext) nsStyleBackground();
|
||||
if (NS_LIKELY(bg != nsnull)) {
|
||||
aContext->SetStyle(eStyleStruct_Background, bg);
|
||||
}
|
||||
|
@ -3397,28 +3397,22 @@ nsRuleNode::ComputeBackgroundData(void* aStartStruct,
|
|||
const nsRuleDataStruct& aData,
|
||||
nsStyleContext* aContext,
|
||||
nsRuleNode* aHighestNode,
|
||||
const RuleDetail aRuleDetail, PRBool aInherited)
|
||||
const RuleDetail aRuleDetail,
|
||||
PRBool aInherited)
|
||||
{
|
||||
COMPUTE_START_RESET(Background, (mPresContext), bg, parentBG,
|
||||
Color, colorData)
|
||||
COMPUTE_START_RESET(Background, (), bg, parentBG, Color, colorData)
|
||||
|
||||
// save parentFlags in case bg == parentBG and we clobber them later
|
||||
PRUint8 parentFlags = parentBG->mBackgroundFlags;
|
||||
|
||||
// background-color: color, string, enum (flags), inherit
|
||||
if (eCSSUnit_Inherit == colorData.mBackColor.GetUnit()) { // do inherit first, so SetColor doesn't do it
|
||||
bg->mBackgroundColor = parentBG->mBackgroundColor;
|
||||
bg->mBackgroundFlags &= ~NS_STYLE_BG_COLOR_TRANSPARENT;
|
||||
bg->mBackgroundFlags |= (parentFlags & NS_STYLE_BG_COLOR_TRANSPARENT);
|
||||
inherited = PR_TRUE;
|
||||
}
|
||||
else if (SetColor(colorData.mBackColor, parentBG->mBackgroundColor,
|
||||
mPresContext, aContext, bg->mBackgroundColor, inherited)) {
|
||||
bg->mBackgroundFlags &= ~NS_STYLE_BG_COLOR_TRANSPARENT;
|
||||
}
|
||||
else if (eCSSUnit_Enumerated == colorData.mBackColor.GetUnit() ||
|
||||
eCSSUnit_Initial == colorData.mBackColor.GetUnit()) {
|
||||
bg->mBackgroundFlags |= NS_STYLE_BG_COLOR_TRANSPARENT;
|
||||
// background-color: color, string, inherit
|
||||
if (eCSSUnit_Initial == colorData.mBackColor.GetUnit()) {
|
||||
bg->mBackgroundColor = NS_RGBA(0, 0, 0, 0);
|
||||
} else if (!SetColor(colorData.mBackColor, parentBG->mBackgroundColor,
|
||||
mPresContext, aContext, bg->mBackgroundColor,
|
||||
inherited)) {
|
||||
NS_ASSERTION(eCSSUnit_Null == colorData.mBackColor.GetUnit(),
|
||||
"unexpected color unit");
|
||||
}
|
||||
|
||||
// background-image: url (stored as image), none, inherit
|
||||
|
@ -3708,11 +3702,9 @@ nsRuleNode::ComputeBorderData(void* aStartStruct,
|
|||
border->EnsureBorderColors();
|
||||
border->ClearBorderColors(side);
|
||||
while (list) {
|
||||
if (SetColor(list->mValue, unused, mPresContext, aContext, borderColor, inherited))
|
||||
border->AppendBorderColor(side, borderColor, PR_FALSE);
|
||||
else if (eCSSUnit_Enumerated == list->mValue.GetUnit() &&
|
||||
NS_STYLE_COLOR_TRANSPARENT == list->mValue.GetIntValue())
|
||||
border->AppendBorderColor(side, nsnull, PR_TRUE);
|
||||
if (SetColor(list->mValue, unused, mPresContext,
|
||||
aContext, borderColor, inherited))
|
||||
border->AppendBorderColor(side, borderColor);
|
||||
list = list->mNext;
|
||||
}
|
||||
}
|
||||
|
@ -3721,7 +3713,6 @@ nsRuleNode::ComputeBorderData(void* aStartStruct,
|
|||
|
||||
// border-color, border-*-color: color, string, enum, inherit
|
||||
nsCSSRect ourBorderColor(marginData.mBorderColor);
|
||||
PRBool transparent;
|
||||
PRBool foreground;
|
||||
AdjustLogicalBoxProp(aContext,
|
||||
marginData.mBorderLeftColorLTRSource,
|
||||
|
@ -3739,11 +3730,8 @@ nsRuleNode::ComputeBorderData(void* aStartStruct,
|
|||
if (eCSSUnit_Inherit == value.GetUnit()) {
|
||||
if (parentContext) {
|
||||
inherited = PR_TRUE;
|
||||
parentBorder->GetBorderColor(side, borderColor,
|
||||
transparent, foreground);
|
||||
if (transparent)
|
||||
border->SetBorderTransparent(side);
|
||||
else if (foreground) {
|
||||
parentBorder->GetBorderColor(side, borderColor, foreground);
|
||||
if (foreground) {
|
||||
// We want to inherit the color from the parent, not use the
|
||||
// color on the element where this chunk of style data will be
|
||||
// used. We can ensure that the data for the parent are fully
|
||||
|
@ -3762,9 +3750,6 @@ nsRuleNode::ComputeBorderData(void* aStartStruct,
|
|||
}
|
||||
else if (eCSSUnit_Enumerated == value.GetUnit()) {
|
||||
switch (value.GetIntValue()) {
|
||||
case NS_STYLE_COLOR_TRANSPARENT:
|
||||
border->SetBorderTransparent(side);
|
||||
break;
|
||||
case NS_STYLE_COLOR_MOZ_USE_TEXT_COLOR:
|
||||
border->SetBorderToForeground(side);
|
||||
break;
|
||||
|
|
|
@ -468,11 +468,9 @@ nsChangeHint nsStyleBorder::CalcDifference(const nsStyleBorder& aOther) const
|
|||
// aOther.mBorderColors
|
||||
if (mBorderColors) {
|
||||
NS_FOR_CSS_SIDES(ix) {
|
||||
if (!mBorderColors[ix] != !aOther.mBorderColors[ix]) {
|
||||
if (!nsBorderColors::Equal(mBorderColors[ix],
|
||||
aOther.mBorderColors[ix])) {
|
||||
return NS_STYLE_HINT_VISUAL;
|
||||
} else if (mBorderColors[ix] && aOther.mBorderColors[ix]) {
|
||||
if (!mBorderColors[ix]->Equals(aOther.mBorderColors[ix]))
|
||||
return NS_STYLE_HINT_VISUAL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1154,15 +1152,15 @@ nsChangeHint nsStyleColor::MaxDifference()
|
|||
// nsStyleBackground
|
||||
//
|
||||
|
||||
nsStyleBackground::nsStyleBackground(nsPresContext* aPresContext)
|
||||
: mBackgroundFlags(NS_STYLE_BG_COLOR_TRANSPARENT | NS_STYLE_BG_IMAGE_NONE),
|
||||
nsStyleBackground::nsStyleBackground()
|
||||
: mBackgroundFlags(NS_STYLE_BG_IMAGE_NONE),
|
||||
mBackgroundAttachment(NS_STYLE_BG_ATTACHMENT_SCROLL),
|
||||
mBackgroundClip(NS_STYLE_BG_CLIP_BORDER),
|
||||
mBackgroundInlinePolicy(NS_STYLE_BG_INLINE_POLICY_CONTINUOUS),
|
||||
mBackgroundOrigin(NS_STYLE_BG_ORIGIN_PADDING),
|
||||
mBackgroundRepeat(NS_STYLE_BG_REPEAT_XY)
|
||||
mBackgroundRepeat(NS_STYLE_BG_REPEAT_XY),
|
||||
mBackgroundColor(NS_RGBA(0, 0, 0, 0))
|
||||
{
|
||||
mBackgroundColor = aPresContext->DefaultBackgroundColor();
|
||||
}
|
||||
|
||||
nsStyleBackground::nsStyleBackground(const nsStyleBackground& aSource)
|
||||
|
|
|
@ -144,7 +144,7 @@ struct nsStyleColor {
|
|||
};
|
||||
|
||||
struct nsStyleBackground {
|
||||
nsStyleBackground(nsPresContext* aPresContext);
|
||||
nsStyleBackground();
|
||||
nsStyleBackground(const nsStyleBackground& aOther);
|
||||
~nsStyleBackground();
|
||||
|
||||
|
@ -179,11 +179,11 @@ struct nsStyleBackground {
|
|||
nscolor mBackgroundColor; // [reset]
|
||||
nsCOMPtr<imgIRequest> mBackgroundImage; // [reset]
|
||||
|
||||
// True if this background is completely transparent.
|
||||
PRBool IsTransparent() const
|
||||
{
|
||||
return (mBackgroundFlags &
|
||||
(NS_STYLE_BG_COLOR_TRANSPARENT | NS_STYLE_BG_IMAGE_NONE)) ==
|
||||
(NS_STYLE_BG_COLOR_TRANSPARENT | NS_STYLE_BG_IMAGE_NONE);
|
||||
return (NS_GET_A(mBackgroundColor) == 0 &&
|
||||
(mBackgroundFlags & NS_STYLE_BG_IMAGE_NONE));
|
||||
}
|
||||
|
||||
// We have to take slower codepaths for fixed background attachment,
|
||||
|
@ -193,11 +193,10 @@ struct nsStyleBackground {
|
|||
PRBool HasFixedBackground() const;
|
||||
};
|
||||
|
||||
#define BORDER_COLOR_TRANSPARENT 0x40
|
||||
#define BORDER_COLOR_FOREGROUND 0x20
|
||||
#define OUTLINE_COLOR_INITIAL 0x80
|
||||
// TRANSPARENT | FOREGROUND | INITIAL(OUTLINE)
|
||||
#define BORDER_COLOR_SPECIAL 0xE0
|
||||
// FOREGROUND | INITIAL(OUTLINE)
|
||||
#define BORDER_COLOR_SPECIAL 0xA0
|
||||
#define BORDER_STYLE_MASK 0x1F
|
||||
|
||||
#define NS_SPACING_MARGIN 0
|
||||
|
@ -269,20 +268,18 @@ protected:
|
|||
struct nsBorderColors {
|
||||
nsBorderColors* mNext;
|
||||
nscolor mColor;
|
||||
PRBool mTransparent;
|
||||
|
||||
nsBorderColors* CopyColors() {
|
||||
nsBorderColors* next = nsnull;
|
||||
if (mNext)
|
||||
next = mNext->CopyColors();
|
||||
return new nsBorderColors(mColor, mTransparent, next);
|
||||
return new nsBorderColors(mColor, next);
|
||||
}
|
||||
|
||||
nsBorderColors() :mNext(nsnull) { mColor = NS_RGB(0,0,0); }
|
||||
|
||||
nsBorderColors(const nscolor& aColor, PRBool aTransparent, nsBorderColors* aNext=nsnull) {
|
||||
nsBorderColors(const nscolor& aColor, nsBorderColors* aNext=nsnull) {
|
||||
mColor = aColor;
|
||||
mTransparent = aTransparent;
|
||||
mNext = aNext;
|
||||
}
|
||||
|
||||
|
@ -290,16 +287,18 @@ struct nsBorderColors {
|
|||
delete mNext;
|
||||
}
|
||||
|
||||
PRBool Equals(nsBorderColors* aOther) {
|
||||
nsBorderColors* c1 = this;
|
||||
nsBorderColors* c2 = aOther;
|
||||
static PRBool Equal(const nsBorderColors* c1,
|
||||
const nsBorderColors* c2) {
|
||||
if (c1 == c2)
|
||||
return PR_TRUE;
|
||||
while (c1 && c2) {
|
||||
if (c1->mColor != c2->mColor ||
|
||||
c1->mTransparent != c2->mTransparent)
|
||||
if (c1->mColor != c2->mColor)
|
||||
return PR_FALSE;
|
||||
c1 = c1->mNext;
|
||||
c2 = c2->mNext;
|
||||
}
|
||||
// both should be NULL if these are equal, otherwise one
|
||||
// has more colors than another
|
||||
return !c1 && !c2;
|
||||
}
|
||||
};
|
||||
|
@ -510,16 +509,16 @@ struct nsStyleBorder {
|
|||
inline PRBool IsBorderImageLoaded() const;
|
||||
|
||||
void GetBorderColor(PRUint8 aSide, nscolor& aColor,
|
||||
PRBool& aTransparent, PRBool& aForeground) const
|
||||
PRBool& aForeground) const
|
||||
{
|
||||
aTransparent = aForeground = PR_FALSE;
|
||||
aForeground = PR_FALSE;
|
||||
NS_ASSERTION(aSide <= NS_SIDE_LEFT, "bad side");
|
||||
if ((mBorderStyle[aSide] & BORDER_COLOR_SPECIAL) == 0)
|
||||
aColor = mBorderColor[aSide];
|
||||
else if (mBorderStyle[aSide] & BORDER_COLOR_FOREGROUND)
|
||||
aForeground = PR_TRUE;
|
||||
else
|
||||
aTransparent = PR_TRUE;
|
||||
NS_NOTREACHED("OUTLINE_COLOR_INITIAL should not be set here");
|
||||
}
|
||||
|
||||
void SetBorderColor(PRUint8 aSide, nscolor aColor)
|
||||
|
@ -541,10 +540,10 @@ struct nsStyleBorder {
|
|||
*aColors = mBorderColors[aIndex];
|
||||
}
|
||||
|
||||
void AppendBorderColor(PRInt32 aIndex, nscolor aColor, PRBool aTransparent)
|
||||
void AppendBorderColor(PRInt32 aIndex, nscolor aColor)
|
||||
{
|
||||
NS_ASSERTION(aIndex >= 0 && aIndex <= 3, "bad side for composite border color");
|
||||
nsBorderColors* colorEntry = new nsBorderColors(aColor, aTransparent);
|
||||
nsBorderColors* colorEntry = new nsBorderColors(aColor);
|
||||
if (!mBorderColors[aIndex])
|
||||
mBorderColors[aIndex] = colorEntry;
|
||||
else {
|
||||
|
@ -556,13 +555,6 @@ struct nsStyleBorder {
|
|||
mBorderStyle[aIndex] &= ~BORDER_COLOR_SPECIAL;
|
||||
}
|
||||
|
||||
void SetBorderTransparent(PRUint8 aSide)
|
||||
{
|
||||
NS_ASSERTION(aSide <= NS_SIDE_LEFT, "bad side");
|
||||
mBorderStyle[aSide] &= ~BORDER_COLOR_SPECIAL;
|
||||
mBorderStyle[aSide] |= BORDER_COLOR_TRANSPARENT;
|
||||
}
|
||||
|
||||
void SetBorderToForeground(PRUint8 aSide)
|
||||
{
|
||||
NS_ASSERTION(aSide <= NS_SIDE_LEFT, "bad side");
|
||||
|
|
|
@ -76,7 +76,7 @@ STYLE_STRUCT_INHERITED(Color, CheckColorCallback, (SSARG_PRESCONTEXT))
|
|||
STYLE_STRUCT_TEST_CODE( })
|
||||
STYLE_STRUCT_TEST_CODE( } else {)
|
||||
STYLE_STRUCT_TEST_CODE( if (STYLE_STRUCT_TEST == 2) {)
|
||||
STYLE_STRUCT_RESET(Background, nsnull, (SSARG_PRESCONTEXT))
|
||||
STYLE_STRUCT_RESET(Background, nsnull, ())
|
||||
STYLE_STRUCT_TEST_CODE( } else {)
|
||||
STYLE_STRUCT_INHERITED(List, nsnull, ())
|
||||
STYLE_STRUCT_TEST_CODE( })
|
||||
|
|
|
@ -4575,12 +4575,9 @@ GetColorAndStyle(const nsIFrame* aFrame,
|
|||
(NS_STYLE_BORDER_STYLE_HIDDEN == aStyle)) {
|
||||
return;
|
||||
}
|
||||
PRBool transparent, foreground;
|
||||
styleData->GetBorderColor(aSide, aColor, transparent, foreground);
|
||||
if (transparent) {
|
||||
aColor = 0;
|
||||
}
|
||||
else if (foreground) {
|
||||
PRBool foreground;
|
||||
styleData->GetBorderColor(aSide, aColor, foreground);
|
||||
if (foreground) {
|
||||
aColor = aFrame->GetStyleColor()->mColor;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3199,14 +3199,11 @@ nsTreeBodyFrame::PaintCell(PRInt32 aRowIndex,
|
|||
|
||||
const nsStyleBorder* borderStyle = lineContext->GetStyleBorder();
|
||||
nscolor color;
|
||||
PRBool transparent, foreground;
|
||||
borderStyle->GetBorderColor(NS_SIDE_LEFT, color, transparent, foreground);
|
||||
PRBool foreground;
|
||||
borderStyle->GetBorderColor(NS_SIDE_LEFT, color, foreground);
|
||||
if (foreground) {
|
||||
// GetBorderColor didn't touch color, thus grab it from the treeline context
|
||||
color = lineContext->GetStyleColor()->mColor;
|
||||
} else if (transparent) {
|
||||
// GetBorderColor didn't touch color, thus set it to transparent
|
||||
color = NS_RGBA(0, 0, 0, 0);
|
||||
}
|
||||
aRenderingContext.SetColor(color);
|
||||
PRUint8 style;
|
||||
|
|
Загрузка…
Ссылка в новой задаче