зеркало из https://github.com/mozilla/pjs.git
Bug 663375 - When text color is darkened, darken text-decoration color too. r=dbaron
This commit is contained in:
Родитель
8fd97a6a00
Коммит
b6efdf1efb
|
@ -2877,20 +2877,20 @@ DarkenColor(nscolor aColor)
|
|||
return aColor;
|
||||
}
|
||||
|
||||
// Check whether we should darken text colors. We need to do this if
|
||||
// Check whether we should darken text/decoration colors. We need to do this if
|
||||
// background images and colors are being suppressed, because that means
|
||||
// light text will not be visible against the (presumed light-colored) background.
|
||||
static PRBool
|
||||
ShouldDarkenColors(nsPresContext* aPresContext)
|
||||
{
|
||||
return !aPresContext->GetBackgroundColorDraw() &&
|
||||
!aPresContext->GetBackgroundImageDraw();
|
||||
!aPresContext->GetBackgroundImageDraw();
|
||||
}
|
||||
|
||||
nscolor
|
||||
nsLayoutUtils::GetTextColor(nsIFrame* aFrame)
|
||||
nsLayoutUtils::GetColor(nsIFrame* aFrame, nsCSSProperty aProperty)
|
||||
{
|
||||
nscolor color = aFrame->GetVisitedDependentColor(eCSSProperty_color);
|
||||
nscolor color = aFrame->GetVisitedDependentColor(aProperty);
|
||||
if (ShouldDarkenColors(aFrame->PresContext())) {
|
||||
color = DarkenColor(color);
|
||||
}
|
||||
|
|
|
@ -934,8 +934,8 @@ public:
|
|||
static nscoord MinWidthFromInline(nsIFrame* aFrame,
|
||||
nsRenderingContext* aRenderingContext);
|
||||
|
||||
// Get a suitable foreground color for painting text for the frame.
|
||||
static nscolor GetTextColor(nsIFrame* aFrame);
|
||||
// Get a suitable foreground color for painting aProperty for aFrame.
|
||||
static nscolor GetColor(nsIFrame* aFrame, nsCSSProperty aProperty);
|
||||
|
||||
// Get a baseline y position in app units that is snapped to device pixels.
|
||||
static gfxFloat GetSnappedBaselineY(nsIFrame* aFrame, gfxContext* aContext,
|
||||
|
|
|
@ -230,7 +230,8 @@ void
|
|||
nsDisplayTextOverflowMarker::Paint(nsDisplayListBuilder* aBuilder,
|
||||
nsRenderingContext* aCtx)
|
||||
{
|
||||
nscolor foregroundColor = nsLayoutUtils::GetTextColor(mFrame);
|
||||
nscolor foregroundColor =
|
||||
nsLayoutUtils::GetColor(mFrame, eCSSProperty_color);
|
||||
|
||||
// Paint the text-shadows for the overflow marker
|
||||
nsLayoutUtils::PaintTextShadow(mFrame, aCtx, mRect, mVisibleRect,
|
||||
|
|
|
@ -290,7 +290,7 @@ nsBulletFrame::PaintBullet(nsRenderingContext& aRenderingContext, nsPoint aPt,
|
|||
}
|
||||
|
||||
nsRefPtr<nsFontMetrics> fm;
|
||||
aRenderingContext.SetColor(GetVisitedDependentColor(eCSSProperty_color));
|
||||
aRenderingContext.SetColor(nsLayoutUtils::GetColor(this, eCSSProperty_color));
|
||||
|
||||
mTextIsRTL = PR_FALSE;
|
||||
|
||||
|
|
|
@ -3239,7 +3239,7 @@ nsTextPaintStyle::EnsureSufficientContrast(nscolor *aForeColor, nscolor *aBackCo
|
|||
nscolor
|
||||
nsTextPaintStyle::GetTextColor()
|
||||
{
|
||||
return nsLayoutUtils::GetTextColor(mFrame);
|
||||
return nsLayoutUtils::GetColor(mFrame, eCSSProperty_color);
|
||||
}
|
||||
|
||||
PRBool
|
||||
|
@ -4289,13 +4289,12 @@ nsTextFrame::GetTextDecorations(nsPresContext* aPresContext,
|
|||
const PRUint8 textDecorations = styleText->mTextDecorationLine;
|
||||
|
||||
if (!useOverride &&
|
||||
(NS_STYLE_TEXT_DECORATION_LINE_OVERRIDE_ALL & textDecorations))
|
||||
{
|
||||
(NS_STYLE_TEXT_DECORATION_LINE_OVERRIDE_ALL & textDecorations)) {
|
||||
// This handles the <a href="blah.html"><font color="green">La
|
||||
// la la</font></a> case. The link underline should be green.
|
||||
useOverride = PR_TRUE;
|
||||
overrideColor = context->GetVisitedDependentColor(
|
||||
eCSSProperty_text_decoration_color);
|
||||
overrideColor =
|
||||
nsLayoutUtils::GetColor(f, eCSSProperty_text_decoration_color);
|
||||
}
|
||||
|
||||
fParent = nsLayoutUtils::GetParentOrPlaceholderFor(
|
||||
|
@ -4327,22 +4326,19 @@ nsTextFrame::GetTextDecorations(nsPresContext* aPresContext,
|
|||
// Accumulate only elements that have decorations with a genuine style
|
||||
if (textDecorations && style != NS_STYLE_TEXT_DECORATION_STYLE_NONE) {
|
||||
const nscolor color = useOverride ? overrideColor
|
||||
: context->GetVisitedDependentColor(eCSSProperty_text_decoration_color);
|
||||
: nsLayoutUtils::GetColor(f, eCSSProperty_text_decoration_color);
|
||||
|
||||
if (textDecorations & NS_STYLE_TEXT_DECORATION_LINE_UNDERLINE) {
|
||||
aDecorations.mUnderlines.AppendElement(
|
||||
nsTextFrame::LineDecoration(f, baselineOffset, color,
|
||||
style));
|
||||
nsTextFrame::LineDecoration(f, baselineOffset, color, style));
|
||||
}
|
||||
if (textDecorations & NS_STYLE_TEXT_DECORATION_LINE_OVERLINE) {
|
||||
aDecorations.mOverlines.AppendElement(
|
||||
nsTextFrame::LineDecoration(f, baselineOffset, color,
|
||||
style));
|
||||
nsTextFrame::LineDecoration(f, baselineOffset, color, style));
|
||||
}
|
||||
if (textDecorations & NS_STYLE_TEXT_DECORATION_LINE_LINE_THROUGH) {
|
||||
aDecorations.mStrikes.AppendElement(
|
||||
nsTextFrame::LineDecoration(f, baselineOffset, color,
|
||||
style));
|
||||
nsTextFrame::LineDecoration(f, baselineOffset, color, style));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Eric Vaughan, Netscape Communications
|
||||
* Peter Annema <disttsc@bart.nl>
|
||||
* Dean Tessman <dean_tessman@hotmail.com>
|
||||
* Masayuki Nakano <masayuki@d-toybox.com>
|
||||
|
@ -38,15 +39,9 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
//
|
||||
// Eric Vaughan
|
||||
// Netscape Communications
|
||||
//
|
||||
// See documentation in associated header file
|
||||
//
|
||||
#include "nsTextBoxFrame.h"
|
||||
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsTextBoxFrame.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsPresContext.h"
|
||||
|
@ -71,6 +66,7 @@
|
|||
#include "nsIReflowCallback.h"
|
||||
#include "nsBoxFrame.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "nsLayoutUtils.h"
|
||||
|
||||
#ifdef IBMBIDI
|
||||
#include "nsBidiUtils.h"
|
||||
|
@ -79,12 +75,6 @@
|
|||
|
||||
using namespace mozilla;
|
||||
|
||||
#define CROP_LEFT "left"
|
||||
#define CROP_RIGHT "right"
|
||||
#define CROP_CENTER "center"
|
||||
#define CROP_START "start"
|
||||
#define CROP_END "end"
|
||||
|
||||
class nsAccessKeyInfo
|
||||
{
|
||||
public:
|
||||
|
@ -98,11 +88,6 @@ PRBool nsTextBoxFrame::gAccessKeyPrefInitialized = PR_FALSE;
|
|||
PRBool nsTextBoxFrame::gInsertSeparatorBeforeAccessKey = PR_FALSE;
|
||||
PRBool nsTextBoxFrame::gInsertSeparatorPrefInitialized = PR_FALSE;
|
||||
|
||||
//
|
||||
// NS_NewToolbarFrame
|
||||
//
|
||||
// Creates a new Toolbar frame and returns it
|
||||
//
|
||||
nsIFrame*
|
||||
NS_NewTextBoxFrame (nsIPresShell* aPresShell, nsStyleContext* aContext)
|
||||
{
|
||||
|
@ -445,15 +430,18 @@ nsTextBoxFrame::DrawText(nsRenderingContext& aRenderingContext,
|
|||
PRUint8 overStyle;
|
||||
PRUint8 underStyle;
|
||||
PRUint8 strikeStyle;
|
||||
nsStyleContext* context = mStyleContext;
|
||||
|
||||
// Begin with no decorations
|
||||
PRUint8 decorations = NS_STYLE_TEXT_DECORATION_LINE_NONE;
|
||||
// A mask of all possible decorations.
|
||||
PRUint8 decorMask = NS_STYLE_TEXT_DECORATION_LINE_LINES_MASK;
|
||||
PRBool hasDecorationLines = context->HasTextDecorationLines();
|
||||
|
||||
nsIFrame* f = this;
|
||||
do { // find decoration colors
|
||||
nsStyleContext* context = f->GetStyleContext();
|
||||
if (!context->HasTextDecorationLines()) {
|
||||
break;
|
||||
}
|
||||
const nsStyleTextReset* styleText = context->GetStyleTextReset();
|
||||
|
||||
if (decorMask & styleText->mTextDecorationLine) { // a decoration defined here
|
||||
|
@ -464,7 +452,7 @@ nsTextBoxFrame::DrawText(nsRenderingContext& aRenderingContext,
|
|||
PRBool isForeground;
|
||||
styleText->GetDecorationColor(color, isForeground);
|
||||
if (isForeground) {
|
||||
color = context->GetVisitedDependentColor(eCSSProperty_color);
|
||||
color = nsLayoutUtils::GetColor(f, eCSSProperty_color);
|
||||
}
|
||||
}
|
||||
PRUint8 style = styleText->GetDecorationStyle();
|
||||
|
@ -491,13 +479,9 @@ nsTextBoxFrame::DrawText(nsRenderingContext& aRenderingContext,
|
|||
decorations |= NS_STYLE_TEXT_DECORATION_LINE_LINE_THROUGH;
|
||||
}
|
||||
}
|
||||
if (0 != decorMask) {
|
||||
context = context->GetParent();
|
||||
if (context) {
|
||||
hasDecorationLines = context->HasTextDecorationLines();
|
||||
}
|
||||
}
|
||||
} while (context && hasDecorationLines && (0 != decorMask));
|
||||
} while (0 != decorMask &&
|
||||
(f = nsLayoutUtils::GetParentOrPlaceholderFor(
|
||||
presContext->FrameManager(), f)));
|
||||
|
||||
nsRefPtr<nsFontMetrics> fontMet;
|
||||
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fontMet));
|
||||
|
|
Загрузка…
Ссылка в новой задаче