diff --git a/content/base/src/nsRuleNode.cpp b/content/base/src/nsRuleNode.cpp index 11d24f40a90..612034e79d6 100644 --- a/content/base/src/nsRuleNode.cpp +++ b/content/base/src/nsRuleNode.cpp @@ -365,6 +365,11 @@ static PRBool SetColor(const nsCSSValue& aValue, const nscolor aParentColor, result = PR_TRUE; } break; + case NS_COLOR_MOZ_ACTIVEHYPERLINKTEXT: + if (NS_SUCCEEDED(aPresContext->GetDefaultActiveLinkColor(&aResult))) { + result = PR_TRUE; + } + break; default: NS_NOTREACHED("Should never have an unknown negative colorID."); break; diff --git a/content/html/content/src/nsHTMLBodyElement.cpp b/content/html/content/src/nsHTMLBodyElement.cpp index 4371f42e2e9..6d5a490f947 100644 --- a/content/html/content/src/nsHTMLBodyElement.cpp +++ b/content/html/content/src/nsHTMLBodyElement.cpp @@ -411,7 +411,7 @@ nsHTMLBodyElement::Set##func_(const nsAString& aColor) \ } NS_IMPL_HTMLBODY_COLOR_ATTR(vlink, VLink, VisitedLinkColor) -NS_IMPL_HTMLBODY_COLOR_ATTR(alink, ALink, LinkColor) +NS_IMPL_HTMLBODY_COLOR_ATTR(alink, ALink, ActiveLinkColor) NS_IMPL_HTMLBODY_COLOR_ATTR(link, Link, LinkColor) // XXX Should text check the body frame's style struct for color, // like we do for bgColor? diff --git a/content/shared/public/nsCSSKeywordList.h b/content/shared/public/nsCSSKeywordList.h index 810086b8f82..a77ae3448d8 100644 --- a/content/shared/public/nsCSSKeywordList.h +++ b/content/shared/public/nsCSSKeywordList.h @@ -66,6 +66,7 @@ // OUTPUT_CLASS=nsCSSKeywords // MACRO_NAME=CSS_KEY +CSS_KEY(-moz-activehyperlinktext, _moz_activehyperlinktext) CSS_KEY(-moz-alias, _moz_alias) CSS_KEY(-moz-all, _moz_all) CSS_KEY(-moz-anchor-decoration, _moz_anchor_decoration) diff --git a/content/shared/src/nsCSSProps.cpp b/content/shared/src/nsCSSProps.cpp index b14a272cbfc..2193a165c95 100644 --- a/content/shared/src/nsCSSProps.cpp +++ b/content/shared/src/nsCSSProps.cpp @@ -352,6 +352,7 @@ const PRInt32 nsCSSProps::kColorKTable[] = { eCSSKeyword_window, nsILookAndFeel::eColor_window, eCSSKeyword_windowframe, nsILookAndFeel::eColor_windowframe, eCSSKeyword_windowtext, nsILookAndFeel::eColor_windowtext, + eCSSKeyword__moz_activehyperlinktext, NS_COLOR_MOZ_ACTIVEHYPERLINKTEXT, eCSSKeyword__moz_buttondefault, nsILookAndFeel::eColor__moz_buttondefault, eCSSKeyword__moz_field, nsILookAndFeel::eColor__moz_field, eCSSKeyword__moz_fieldtext, nsILookAndFeel::eColor__moz_fieldtext, diff --git a/editor/ui/composer/content/editor.js b/editor/ui/composer/content/editor.js index 717612d06b1..3dc04ed0218 100644 --- a/editor/ui/composer/content/editor.js +++ b/editor/ui/composer/content/editor.js @@ -1537,7 +1537,7 @@ function EditorSelectColor(colorType, mouseEvent) editor.setAttribute(bodyelement, "link", defColors.LinkColor); if (!bodyelement.getAttribute("alink")) - editor.setAttribute(bodyelement, "alink", defColors.LinkColor); + editor.setAttribute(bodyelement, "alink", defColors.ActiveLinkColor); if (!bodyelement.getAttribute("vlink")) editor.setAttribute(bodyelement, "vlink", defColors.VisitedLinkColor); diff --git a/editor/ui/composer/content/editorUtilities.js b/editor/ui/composer/content/editorUtilities.js index d4987b453dd..0ebdcf68e1e 100644 --- a/editor/ui/composer/content/editorUtilities.js +++ b/editor/ui/composer/content/editorUtilities.js @@ -594,7 +594,7 @@ function SaveFilePickerDirectory(filePicker, fileType) function GetDefaultBrowserColors() { var prefs = GetPrefs(); - var colors = { TextColor:0, BackgroundColor:0, LinkColor:0, VisitedLinkColor:0 }; + var colors = { TextColor:0, BackgroundColor:0, LinkColor:0, ActiveLinkColor:0 , VisitedLinkColor:0 }; var useSysColors = false; try { useSysColors = prefs.getBoolPref("browser.display.use_system_colors"); } catch (e) {} @@ -612,6 +612,7 @@ function GetDefaultBrowserColors() colors.BackgroundColor = "window"; colors.LinkColor = prefs.getCharPref("browser.anchor_color"); + colors.ActiveLinkColor = prefs.getCharPref("browser.active_color"); colors.VisitedLinkColor = prefs.getCharPref("browser.visited_color"); return colors; diff --git a/editor/ui/composer/content/pref-composer.js b/editor/ui/composer/content/pref-composer.js index 5eed61cd36e..873447da1b5 100644 --- a/editor/ui/composer/content/pref-composer.js +++ b/editor/ui/composer/content/pref-composer.js @@ -75,8 +75,7 @@ function Startup() // Use author's browser pref colors passed into dialog defaultTextColor = browserColors.TextColor; defaultLinkColor = browserColors.LinkColor; - // Note: Browser doesn't store a value for ActiveLinkColor - defaultActiveColor = defaultLinkColor; + defaultActiveColor = browserColors.ActiveLinkColor; defaultVisitedColor = browserColors.VisitedLinkColor; defaultBackgroundColor= browserColors.BackgroundColor; diff --git a/editor/ui/dialogs/content/EdColorProps.js b/editor/ui/dialogs/content/EdColorProps.js index 1e86c923961..6df3fcded6b 100644 --- a/editor/ui/dialogs/content/EdColorProps.js +++ b/editor/ui/dialogs/content/EdColorProps.js @@ -104,8 +104,7 @@ function Startup() // Use author's browser pref colors passed into dialog defaultTextColor = browserColors.TextColor; defaultLinkColor = browserColors.LinkColor; - // Note: Browser doesn't store a value for ActiveLinkColor - defaultActiveColor = defaultLinkColor; + defaultActiveColor = browserColors.ActiveLinkColor; defaultVisitedColor = browserColors.VisitedLinkColor; defaultBackgroundColor= browserColors.BackgroundColor; } diff --git a/l10n/langpacks/en-DE/chrome/en-DE/communicator/locale/pref/pref-colors.dtd b/l10n/langpacks/en-DE/chrome/en-DE/communicator/locale/pref/pref-colors.dtd index fad3441a791..e69de29bb2d 100644 --- a/l10n/langpacks/en-DE/chrome/en-DE/communicator/locale/pref/pref-colors.dtd +++ b/l10n/langpacks/en-DE/chrome/en-DE/communicator/locale/pref/pref-colors.dtd @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/l10n/langpacks/en-GB/chrome/en-GB/communicator/locale/pref/pref-colors.dtd b/l10n/langpacks/en-GB/chrome/en-GB/communicator/locale/pref/pref-colors.dtd index fad3441a791..e69de29bb2d 100644 --- a/l10n/langpacks/en-GB/chrome/en-GB/communicator/locale/pref/pref-colors.dtd +++ b/l10n/langpacks/en-GB/chrome/en-GB/communicator/locale/pref/pref-colors.dtd @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index fafab68d844..c7e5f58da54 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -184,8 +184,9 @@ nsPresContext::nsPresContext() // the minimum font-size is unconstrained by default mMinimumFontSize = 0; - mLinkColor = NS_RGB(0x33, 0x33, 0xFF); - mVisitedLinkColor = NS_RGB(0x66, 0x00, 0xCC); + mLinkColor = NS_RGB(0x00, 0x00, 0xEE); + mActiveLinkColor = NS_RGB(0xEE, 0x00, 0x00); + mVisitedLinkColor = NS_RGB(0x55, 0x1A, 0x8B); mUnderlineLinks = PR_TRUE; mUseFocusColors = PR_FALSE; @@ -222,6 +223,7 @@ nsPresContext::~nsPresContext() mPrefs->UnregisterCallback("browser.display.", nsPresContext::PrefChangedCallback, (void*)this); mPrefs->UnregisterCallback("browser.underline_anchors", nsPresContext::PrefChangedCallback, (void*)this); mPrefs->UnregisterCallback("browser.anchor_color", nsPresContext::PrefChangedCallback, (void*)this); + mPrefs->UnregisterCallback("browser.active_color", nsPresContext::PrefChangedCallback, (void*)this); mPrefs->UnregisterCallback("browser.visited_color", nsPresContext::PrefChangedCallback, (void*)this); mPrefs->UnregisterCallback("network.image.imageBehavior", nsPresContext::PrefChangedCallback, (void*)this); mPrefs->UnregisterCallback("image.animation_mode", nsPresContext::PrefChangedCallback, (void*)this); @@ -470,6 +472,9 @@ nsPresContext::GetUserPreferences() if (NS_SUCCEEDED(mPrefs->CopyCharPref("browser.anchor_color", getter_Copies(colorStr)))) { mLinkColor = MakeColorPref(colorStr); } + if (NS_SUCCEEDED(mPrefs->CopyCharPref("browser.active_color", getter_Copies(colorStr)))) { + mActiveLinkColor = MakeColorPref(colorStr); + } if (NS_SUCCEEDED(mPrefs->CopyCharPref("browser.visited_color", getter_Copies(colorStr)))) { mVisitedLinkColor = MakeColorPref(colorStr); } @@ -637,6 +642,7 @@ nsPresContext::Init(nsIDeviceContext* aDeviceContext) mPrefs->RegisterCallback("browser.display.", nsPresContext::PrefChangedCallback, (void*)this); mPrefs->RegisterCallback("browser.underline_anchors", nsPresContext::PrefChangedCallback, (void*)this); mPrefs->RegisterCallback("browser.anchor_color", nsPresContext::PrefChangedCallback, (void*)this); + mPrefs->RegisterCallback("browser.active_color", nsPresContext::PrefChangedCallback, (void*)this); mPrefs->RegisterCallback("browser.visited_color", nsPresContext::PrefChangedCallback, (void*)this); mPrefs->RegisterCallback("network.image.imageBehavior", nsPresContext::PrefChangedCallback, (void*)this); mPrefs->RegisterCallback("image.animation_mode", nsPresContext::PrefChangedCallback, (void*)this); @@ -1160,6 +1166,14 @@ nsPresContext::GetDefaultLinkColor(nscolor* aColor) return NS_OK; } +NS_IMETHODIMP +nsPresContext::GetDefaultActiveLinkColor(nscolor* aColor) +{ + NS_PRECONDITION(aColor, "null out param"); + *aColor = mActiveLinkColor; + return NS_OK; +} + NS_IMETHODIMP nsPresContext::GetDefaultVisitedLinkColor(nscolor* aColor) { @@ -1232,6 +1246,13 @@ nsPresContext::SetDefaultLinkColor(nscolor aColor) return NS_OK; } +NS_IMETHODIMP +nsPresContext::SetDefaultActiveLinkColor(nscolor aColor) +{ + mActiveLinkColor = aColor; + return NS_OK; +} + NS_IMETHODIMP nsPresContext::SetDefaultVisitedLinkColor(nscolor aColor) { diff --git a/layout/base/nsPresContext.h b/layout/base/nsPresContext.h index 2d1c61573d6..f918f559db9 100644 --- a/layout/base/nsPresContext.h +++ b/layout/base/nsPresContext.h @@ -298,6 +298,7 @@ public: NS_IMETHOD GetDefaultColor(nscolor* aColor) = 0; NS_IMETHOD GetDefaultBackgroundColor(nscolor* aColor) = 0; NS_IMETHOD GetDefaultLinkColor(nscolor* aColor) = 0; + NS_IMETHOD GetDefaultActiveLinkColor(nscolor* aColor) = 0; NS_IMETHOD GetDefaultVisitedLinkColor(nscolor* aColor) = 0; NS_IMETHOD GetFocusBackgroundColor(nscolor* aColor) = 0; NS_IMETHOD GetFocusTextColor(nscolor* aColor) = 0; @@ -309,6 +310,7 @@ public: NS_IMETHOD SetDefaultColor(nscolor aColor) = 0; NS_IMETHOD SetDefaultBackgroundColor(nscolor aColor) = 0; NS_IMETHOD SetDefaultLinkColor(nscolor aColor) = 0; + NS_IMETHOD SetDefaultActiveLinkColor(nscolor aColor) = 0; NS_IMETHOD SetDefaultVisitedLinkColor(nscolor aColor) = 0; /** diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 8c6f1c842ca..6052d1056a9 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -2352,114 +2352,87 @@ PresShell::SetPrefNoScriptRule() nsresult PresShell::SetPrefLinkRules(void) { NS_ASSERTION(mPresContext,"null prescontext not allowed"); - if (mPresContext) { - nsresult result = NS_OK; - - if (!mPrefStyleSheet) { - result = CreatePreferenceStyleSheet(); - } - if (NS_SUCCEEDED(result)) { - NS_ASSERTION(mPrefStyleSheet, "prefstylesheet should not be null"); - - // get the DOM interface to the stylesheet - nsCOMPtr sheet(do_QueryInterface(mPrefStyleSheet,&result)); - if (NS_SUCCEEDED(result)) { - -#ifdef DEBUG_attinasi - printf(" - Creating rules for link and visited colors\n"); -#endif - - // support default link colors: - // this means the link colors need to be overridable, - // which they are if we put them in the agent stylesheet, - // though if using an override sheet this will cause authors grief still - // In the agent stylesheet, they are !important when we are ignoring document colors - // - // XXX: Do active links and visited links get another color? - // They are red in the html.css rules, but there is no pref for their color. - - nscolor linkColor, visitedColor; - result = mPresContext->GetDefaultLinkColor(&linkColor); - if (NS_SUCCEEDED(result)) { - result = mPresContext->GetDefaultVisitedLinkColor(&visitedColor); - } - if (NS_SUCCEEDED(result)) { - // insert a rule to make links the preferred color - PRUint32 index = 0; - nsAutoString strColor; - PRBool useDocColors = PR_TRUE; - - // see if we need to create the rules first - mPresContext->GetCachedBoolPref(kPresContext_UseDocumentColors, useDocColors); - - /////////////////////////////////////////////////////////////// - // - links: '*|*:link {color: #RRGGBB [!important];}' - ColorToString(linkColor,strColor); - NS_NAMED_LITERAL_STRING(notImportantStr, "}"); - NS_NAMED_LITERAL_STRING(importantStr, "!important}"); - const nsAString& ruleClose = useDocColors ? notImportantStr : importantStr; - result = sheet->InsertRule(NS_LITERAL_STRING("*|*:link{color:") + - strColor + - ruleClose, - sInsertPrefSheetRulesAt, &index); - NS_ENSURE_SUCCESS(result, result); - - /////////////////////////////////////////////////////////////// - // - visited links '*|*:visited {color: #RRGGBB [!important];}' - ColorToString(visitedColor,strColor); - // insert the rule - result = sheet->InsertRule(NS_LITERAL_STRING("*|*:visited{color:") + - strColor + - ruleClose, - sInsertPrefSheetRulesAt, &index); - - /////////////////////////////////////////////////////////////// - // - active links '*|*:-moz-any-link {color: red [!important];}' - // This has to be here (i.e. we can't just rely on the rule in the UA stylesheet) - // because this entire stylesheet is at the user level (not UA level) and so - // the two rules above override the rule in the UA stylesheet regardless of the - // weights of the respective rules. - result = sheet->InsertRule(NS_LITERAL_STRING("*|*:-moz-any-link:active{color:red") + - ruleClose, - sInsertPrefSheetRulesAt, &index); - } - - if (NS_SUCCEEDED(result)) { - PRBool underlineLinks = PR_TRUE; - result = mPresContext->GetCachedBoolPref(kPresContext_UnderlineLinks,underlineLinks); - if (NS_SUCCEEDED(result)) { - // create a rule for underline: on or off - PRUint32 index = 0; - nsAutoString strRule; - if (underlineLinks) { - // create a rule to make underlining happen - // ':link, :visited {text-decoration:[underline|none];}' - // no need for important, we want these to be overridable - // NOTE: these must go in the agent stylesheet or they cannot be - // overridden by authors - #ifdef DEBUG_attinasi - printf (" - Creating rules for enabling link underlines\n"); - #endif - // make a rule to make text-decoration: underline happen for links - strRule.Append(NS_LITERAL_STRING("*|*:-moz-any-link{text-decoration:underline}")); - } else { - #ifdef DEBUG_attinasi - printf (" - Creating rules for disabling link underlines\n"); - #endif - // make a rule to make text-decoration: none happen for links - strRule.Append(NS_LITERAL_STRING("*|*:-moz-any-link{text-decoration:none}")); - } - - // ...now insert the rule - result = sheet->InsertRule(strRule, sInsertPrefSheetRulesAt, &index); - } - } - } - } - return result; - } else { + if (!mPresContext) { return NS_ERROR_FAILURE; } + + nsresult rv = NS_OK; + + if (!mPrefStyleSheet) { + rv = CreatePreferenceStyleSheet(); + NS_ENSURE_SUCCESS(rv, rv); + } + + NS_ASSERTION(mPrefStyleSheet, "prefstylesheet should not be null"); + + // get the DOM interface to the stylesheet + nsCOMPtr sheet(do_QueryInterface(mPrefStyleSheet, &rv)); + NS_ENSURE_SUCCESS(rv, rv); + + // support default link colors: + // this means the link colors need to be overridable, + // which they are if we put them in the agent stylesheet, + // though if using an override sheet this will cause authors grief still + // In the agent stylesheet, they are !important when we are ignoring document colors + + nscolor linkColor, activeColor, visitedColor; + + rv = mPresContext->GetDefaultLinkColor(&linkColor); + NS_ENSURE_SUCCESS(rv, rv); + + rv = mPresContext->GetDefaultActiveLinkColor(&activeColor); + NS_ENSURE_SUCCESS(rv, rv); + + rv = mPresContext->GetDefaultVisitedLinkColor(&visitedColor); + NS_ENSURE_SUCCESS(rv, rv); + + PRBool useDocColors = PR_TRUE; + mPresContext->GetCachedBoolPref(kPresContext_UseDocumentColors, useDocColors); + NS_NAMED_LITERAL_STRING(notImportantStr, "}"); + NS_NAMED_LITERAL_STRING(importantStr, "!important}"); + const nsAString& ruleClose = useDocColors ? notImportantStr : importantStr; + PRUint32 index = 0; + nsAutoString strColor; + + // insert a rule to color links: '*|*:link {color: #RRGGBB [!important];}' + ColorToString(linkColor, strColor); + rv = sheet->InsertRule(NS_LITERAL_STRING("*|*:link{color:") + + strColor + ruleClose, + sInsertPrefSheetRulesAt, &index); + NS_ENSURE_SUCCESS(rv, rv); + + // - visited links: '*|*:visited {color: #RRGGBB [!important];}' + ColorToString(visitedColor, strColor); + rv = sheet->InsertRule(NS_LITERAL_STRING("*|*:visited{color:") + + strColor + ruleClose, + sInsertPrefSheetRulesAt, &index); + NS_ENSURE_SUCCESS(rv, rv); + + // - active links: '*|*:-moz-any-link:active {color: #RRGGBB [!important];}' + ColorToString(activeColor, strColor); + rv = sheet->InsertRule(NS_LITERAL_STRING("*|*:-moz-any-link:active{color:") + + strColor + ruleClose, + sInsertPrefSheetRulesAt, &index); + NS_ENSURE_SUCCESS(rv, rv); + + PRBool underlineLinks = PR_TRUE; + rv = mPresContext->GetCachedBoolPref(kPresContext_UnderlineLinks, underlineLinks); + NS_ENSURE_SUCCESS(rv, rv); + + if (underlineLinks) { + // create a rule to make underlining happen + // '*|*:-moz-any-link {text-decoration:[underline|none];}' + // no need for important, we want these to be overridable + // NOTE: these must go in the agent stylesheet or they cannot be + // overridden by authors + rv = sheet->InsertRule(NS_LITERAL_STRING("*|*:-moz-any-link{text-decoration:underline}"), + sInsertPrefSheetRulesAt, &index); + } else { + rv = sheet->InsertRule(NS_LITERAL_STRING("*|*:-moz-any-link{text-decoration:none}"), + sInsertPrefSheetRulesAt, &index); + } + + return rv; } nsresult PresShell::SetPrefFocusRules(void) diff --git a/layout/base/nsStyleConsts.h b/layout/base/nsStyleConsts.h index 5f72fc0984b..0df20f6ce2c 100644 --- a/layout/base/nsStyleConsts.h +++ b/layout/base/nsStyleConsts.h @@ -196,6 +196,7 @@ // See nsStyleColor #define NS_COLOR_MOZ_HYPERLINKTEXT -1 #define NS_COLOR_MOZ_VISITEDHYPERLINKTEXT -2 +#define NS_COLOR_MOZ_ACTIVEHYPERLINKTEXT -3 // See nsStyleBackground #define NS_STYLE_BG_COLOR_TRANSPARENT 0x01 diff --git a/layout/base/public/nsIPresContext.h b/layout/base/public/nsIPresContext.h index 2d1c61573d6..f918f559db9 100644 --- a/layout/base/public/nsIPresContext.h +++ b/layout/base/public/nsIPresContext.h @@ -298,6 +298,7 @@ public: NS_IMETHOD GetDefaultColor(nscolor* aColor) = 0; NS_IMETHOD GetDefaultBackgroundColor(nscolor* aColor) = 0; NS_IMETHOD GetDefaultLinkColor(nscolor* aColor) = 0; + NS_IMETHOD GetDefaultActiveLinkColor(nscolor* aColor) = 0; NS_IMETHOD GetDefaultVisitedLinkColor(nscolor* aColor) = 0; NS_IMETHOD GetFocusBackgroundColor(nscolor* aColor) = 0; NS_IMETHOD GetFocusTextColor(nscolor* aColor) = 0; @@ -309,6 +310,7 @@ public: NS_IMETHOD SetDefaultColor(nscolor aColor) = 0; NS_IMETHOD SetDefaultBackgroundColor(nscolor aColor) = 0; NS_IMETHOD SetDefaultLinkColor(nscolor aColor) = 0; + NS_IMETHOD SetDefaultActiveLinkColor(nscolor aColor) = 0; NS_IMETHOD SetDefaultVisitedLinkColor(nscolor aColor) = 0; /** diff --git a/layout/base/public/nsPresContext.h b/layout/base/public/nsPresContext.h index 2d1c61573d6..f918f559db9 100644 --- a/layout/base/public/nsPresContext.h +++ b/layout/base/public/nsPresContext.h @@ -298,6 +298,7 @@ public: NS_IMETHOD GetDefaultColor(nscolor* aColor) = 0; NS_IMETHOD GetDefaultBackgroundColor(nscolor* aColor) = 0; NS_IMETHOD GetDefaultLinkColor(nscolor* aColor) = 0; + NS_IMETHOD GetDefaultActiveLinkColor(nscolor* aColor) = 0; NS_IMETHOD GetDefaultVisitedLinkColor(nscolor* aColor) = 0; NS_IMETHOD GetFocusBackgroundColor(nscolor* aColor) = 0; NS_IMETHOD GetFocusTextColor(nscolor* aColor) = 0; @@ -309,6 +310,7 @@ public: NS_IMETHOD SetDefaultColor(nscolor aColor) = 0; NS_IMETHOD SetDefaultBackgroundColor(nscolor aColor) = 0; NS_IMETHOD SetDefaultLinkColor(nscolor aColor) = 0; + NS_IMETHOD SetDefaultActiveLinkColor(nscolor aColor) = 0; NS_IMETHOD SetDefaultVisitedLinkColor(nscolor aColor) = 0; /** diff --git a/layout/base/public/nsStyleConsts.h b/layout/base/public/nsStyleConsts.h index 5f72fc0984b..0df20f6ce2c 100644 --- a/layout/base/public/nsStyleConsts.h +++ b/layout/base/public/nsStyleConsts.h @@ -196,6 +196,7 @@ // See nsStyleColor #define NS_COLOR_MOZ_HYPERLINKTEXT -1 #define NS_COLOR_MOZ_VISITEDHYPERLINKTEXT -2 +#define NS_COLOR_MOZ_ACTIVEHYPERLINKTEXT -3 // See nsStyleBackground #define NS_STYLE_BG_COLOR_TRANSPARENT 0x01 diff --git a/layout/base/src/nsPresContext.cpp b/layout/base/src/nsPresContext.cpp index fafab68d844..c7e5f58da54 100644 --- a/layout/base/src/nsPresContext.cpp +++ b/layout/base/src/nsPresContext.cpp @@ -184,8 +184,9 @@ nsPresContext::nsPresContext() // the minimum font-size is unconstrained by default mMinimumFontSize = 0; - mLinkColor = NS_RGB(0x33, 0x33, 0xFF); - mVisitedLinkColor = NS_RGB(0x66, 0x00, 0xCC); + mLinkColor = NS_RGB(0x00, 0x00, 0xEE); + mActiveLinkColor = NS_RGB(0xEE, 0x00, 0x00); + mVisitedLinkColor = NS_RGB(0x55, 0x1A, 0x8B); mUnderlineLinks = PR_TRUE; mUseFocusColors = PR_FALSE; @@ -222,6 +223,7 @@ nsPresContext::~nsPresContext() mPrefs->UnregisterCallback("browser.display.", nsPresContext::PrefChangedCallback, (void*)this); mPrefs->UnregisterCallback("browser.underline_anchors", nsPresContext::PrefChangedCallback, (void*)this); mPrefs->UnregisterCallback("browser.anchor_color", nsPresContext::PrefChangedCallback, (void*)this); + mPrefs->UnregisterCallback("browser.active_color", nsPresContext::PrefChangedCallback, (void*)this); mPrefs->UnregisterCallback("browser.visited_color", nsPresContext::PrefChangedCallback, (void*)this); mPrefs->UnregisterCallback("network.image.imageBehavior", nsPresContext::PrefChangedCallback, (void*)this); mPrefs->UnregisterCallback("image.animation_mode", nsPresContext::PrefChangedCallback, (void*)this); @@ -470,6 +472,9 @@ nsPresContext::GetUserPreferences() if (NS_SUCCEEDED(mPrefs->CopyCharPref("browser.anchor_color", getter_Copies(colorStr)))) { mLinkColor = MakeColorPref(colorStr); } + if (NS_SUCCEEDED(mPrefs->CopyCharPref("browser.active_color", getter_Copies(colorStr)))) { + mActiveLinkColor = MakeColorPref(colorStr); + } if (NS_SUCCEEDED(mPrefs->CopyCharPref("browser.visited_color", getter_Copies(colorStr)))) { mVisitedLinkColor = MakeColorPref(colorStr); } @@ -637,6 +642,7 @@ nsPresContext::Init(nsIDeviceContext* aDeviceContext) mPrefs->RegisterCallback("browser.display.", nsPresContext::PrefChangedCallback, (void*)this); mPrefs->RegisterCallback("browser.underline_anchors", nsPresContext::PrefChangedCallback, (void*)this); mPrefs->RegisterCallback("browser.anchor_color", nsPresContext::PrefChangedCallback, (void*)this); + mPrefs->RegisterCallback("browser.active_color", nsPresContext::PrefChangedCallback, (void*)this); mPrefs->RegisterCallback("browser.visited_color", nsPresContext::PrefChangedCallback, (void*)this); mPrefs->RegisterCallback("network.image.imageBehavior", nsPresContext::PrefChangedCallback, (void*)this); mPrefs->RegisterCallback("image.animation_mode", nsPresContext::PrefChangedCallback, (void*)this); @@ -1160,6 +1166,14 @@ nsPresContext::GetDefaultLinkColor(nscolor* aColor) return NS_OK; } +NS_IMETHODIMP +nsPresContext::GetDefaultActiveLinkColor(nscolor* aColor) +{ + NS_PRECONDITION(aColor, "null out param"); + *aColor = mActiveLinkColor; + return NS_OK; +} + NS_IMETHODIMP nsPresContext::GetDefaultVisitedLinkColor(nscolor* aColor) { @@ -1232,6 +1246,13 @@ nsPresContext::SetDefaultLinkColor(nscolor aColor) return NS_OK; } +NS_IMETHODIMP +nsPresContext::SetDefaultActiveLinkColor(nscolor aColor) +{ + mActiveLinkColor = aColor; + return NS_OK; +} + NS_IMETHODIMP nsPresContext::SetDefaultVisitedLinkColor(nscolor aColor) { diff --git a/layout/base/src/nsPresContext.h b/layout/base/src/nsPresContext.h index 9ca3f93073c..a9061b5b1e5 100644 --- a/layout/base/src/nsPresContext.h +++ b/layout/base/src/nsPresContext.h @@ -121,6 +121,7 @@ public: NS_IMETHOD GetDefaultColor(nscolor* aColor); NS_IMETHOD GetDefaultBackgroundColor(nscolor* aColor); NS_IMETHOD GetDefaultLinkColor(nscolor* aColor); + NS_IMETHOD GetDefaultActiveLinkColor(nscolor* aColor); NS_IMETHOD GetDefaultVisitedLinkColor(nscolor* aColor); NS_IMETHOD GetFocusBackgroundColor(nscolor* aColor); @@ -131,6 +132,7 @@ public: NS_IMETHOD SetDefaultColor(nscolor aColor); NS_IMETHOD SetDefaultBackgroundColor(nscolor aColor); NS_IMETHOD SetDefaultLinkColor(nscolor aColor); + NS_IMETHOD SetDefaultActiveLinkColor(nscolor aColor); NS_IMETHOD SetDefaultVisitedLinkColor(nscolor aColor); NS_IMETHOD LoadImage(nsIURI* aURL, @@ -240,6 +242,7 @@ protected: nscolor mDefaultColor; // set in GetUserPrefs nscolor mDefaultBackgroundColor; // set in GetUserPrefs nscolor mLinkColor; // set in GetUserPrefs + nscolor mActiveLinkColor; // set in GetUserPrefs nscolor mVisitedLinkColor; // set in GetUserPrefs nscolor mFocusTextColor; // set in GetUserPrefs nscolor mFocusBackgroundColor; // set in GetUserPrefs diff --git a/layout/html/base/src/nsPresShell.cpp b/layout/html/base/src/nsPresShell.cpp index 8c6f1c842ca..6052d1056a9 100644 --- a/layout/html/base/src/nsPresShell.cpp +++ b/layout/html/base/src/nsPresShell.cpp @@ -2352,114 +2352,87 @@ PresShell::SetPrefNoScriptRule() nsresult PresShell::SetPrefLinkRules(void) { NS_ASSERTION(mPresContext,"null prescontext not allowed"); - if (mPresContext) { - nsresult result = NS_OK; - - if (!mPrefStyleSheet) { - result = CreatePreferenceStyleSheet(); - } - if (NS_SUCCEEDED(result)) { - NS_ASSERTION(mPrefStyleSheet, "prefstylesheet should not be null"); - - // get the DOM interface to the stylesheet - nsCOMPtr sheet(do_QueryInterface(mPrefStyleSheet,&result)); - if (NS_SUCCEEDED(result)) { - -#ifdef DEBUG_attinasi - printf(" - Creating rules for link and visited colors\n"); -#endif - - // support default link colors: - // this means the link colors need to be overridable, - // which they are if we put them in the agent stylesheet, - // though if using an override sheet this will cause authors grief still - // In the agent stylesheet, they are !important when we are ignoring document colors - // - // XXX: Do active links and visited links get another color? - // They are red in the html.css rules, but there is no pref for their color. - - nscolor linkColor, visitedColor; - result = mPresContext->GetDefaultLinkColor(&linkColor); - if (NS_SUCCEEDED(result)) { - result = mPresContext->GetDefaultVisitedLinkColor(&visitedColor); - } - if (NS_SUCCEEDED(result)) { - // insert a rule to make links the preferred color - PRUint32 index = 0; - nsAutoString strColor; - PRBool useDocColors = PR_TRUE; - - // see if we need to create the rules first - mPresContext->GetCachedBoolPref(kPresContext_UseDocumentColors, useDocColors); - - /////////////////////////////////////////////////////////////// - // - links: '*|*:link {color: #RRGGBB [!important];}' - ColorToString(linkColor,strColor); - NS_NAMED_LITERAL_STRING(notImportantStr, "}"); - NS_NAMED_LITERAL_STRING(importantStr, "!important}"); - const nsAString& ruleClose = useDocColors ? notImportantStr : importantStr; - result = sheet->InsertRule(NS_LITERAL_STRING("*|*:link{color:") + - strColor + - ruleClose, - sInsertPrefSheetRulesAt, &index); - NS_ENSURE_SUCCESS(result, result); - - /////////////////////////////////////////////////////////////// - // - visited links '*|*:visited {color: #RRGGBB [!important];}' - ColorToString(visitedColor,strColor); - // insert the rule - result = sheet->InsertRule(NS_LITERAL_STRING("*|*:visited{color:") + - strColor + - ruleClose, - sInsertPrefSheetRulesAt, &index); - - /////////////////////////////////////////////////////////////// - // - active links '*|*:-moz-any-link {color: red [!important];}' - // This has to be here (i.e. we can't just rely on the rule in the UA stylesheet) - // because this entire stylesheet is at the user level (not UA level) and so - // the two rules above override the rule in the UA stylesheet regardless of the - // weights of the respective rules. - result = sheet->InsertRule(NS_LITERAL_STRING("*|*:-moz-any-link:active{color:red") + - ruleClose, - sInsertPrefSheetRulesAt, &index); - } - - if (NS_SUCCEEDED(result)) { - PRBool underlineLinks = PR_TRUE; - result = mPresContext->GetCachedBoolPref(kPresContext_UnderlineLinks,underlineLinks); - if (NS_SUCCEEDED(result)) { - // create a rule for underline: on or off - PRUint32 index = 0; - nsAutoString strRule; - if (underlineLinks) { - // create a rule to make underlining happen - // ':link, :visited {text-decoration:[underline|none];}' - // no need for important, we want these to be overridable - // NOTE: these must go in the agent stylesheet or they cannot be - // overridden by authors - #ifdef DEBUG_attinasi - printf (" - Creating rules for enabling link underlines\n"); - #endif - // make a rule to make text-decoration: underline happen for links - strRule.Append(NS_LITERAL_STRING("*|*:-moz-any-link{text-decoration:underline}")); - } else { - #ifdef DEBUG_attinasi - printf (" - Creating rules for disabling link underlines\n"); - #endif - // make a rule to make text-decoration: none happen for links - strRule.Append(NS_LITERAL_STRING("*|*:-moz-any-link{text-decoration:none}")); - } - - // ...now insert the rule - result = sheet->InsertRule(strRule, sInsertPrefSheetRulesAt, &index); - } - } - } - } - return result; - } else { + if (!mPresContext) { return NS_ERROR_FAILURE; } + + nsresult rv = NS_OK; + + if (!mPrefStyleSheet) { + rv = CreatePreferenceStyleSheet(); + NS_ENSURE_SUCCESS(rv, rv); + } + + NS_ASSERTION(mPrefStyleSheet, "prefstylesheet should not be null"); + + // get the DOM interface to the stylesheet + nsCOMPtr sheet(do_QueryInterface(mPrefStyleSheet, &rv)); + NS_ENSURE_SUCCESS(rv, rv); + + // support default link colors: + // this means the link colors need to be overridable, + // which they are if we put them in the agent stylesheet, + // though if using an override sheet this will cause authors grief still + // In the agent stylesheet, they are !important when we are ignoring document colors + + nscolor linkColor, activeColor, visitedColor; + + rv = mPresContext->GetDefaultLinkColor(&linkColor); + NS_ENSURE_SUCCESS(rv, rv); + + rv = mPresContext->GetDefaultActiveLinkColor(&activeColor); + NS_ENSURE_SUCCESS(rv, rv); + + rv = mPresContext->GetDefaultVisitedLinkColor(&visitedColor); + NS_ENSURE_SUCCESS(rv, rv); + + PRBool useDocColors = PR_TRUE; + mPresContext->GetCachedBoolPref(kPresContext_UseDocumentColors, useDocColors); + NS_NAMED_LITERAL_STRING(notImportantStr, "}"); + NS_NAMED_LITERAL_STRING(importantStr, "!important}"); + const nsAString& ruleClose = useDocColors ? notImportantStr : importantStr; + PRUint32 index = 0; + nsAutoString strColor; + + // insert a rule to color links: '*|*:link {color: #RRGGBB [!important];}' + ColorToString(linkColor, strColor); + rv = sheet->InsertRule(NS_LITERAL_STRING("*|*:link{color:") + + strColor + ruleClose, + sInsertPrefSheetRulesAt, &index); + NS_ENSURE_SUCCESS(rv, rv); + + // - visited links: '*|*:visited {color: #RRGGBB [!important];}' + ColorToString(visitedColor, strColor); + rv = sheet->InsertRule(NS_LITERAL_STRING("*|*:visited{color:") + + strColor + ruleClose, + sInsertPrefSheetRulesAt, &index); + NS_ENSURE_SUCCESS(rv, rv); + + // - active links: '*|*:-moz-any-link:active {color: #RRGGBB [!important];}' + ColorToString(activeColor, strColor); + rv = sheet->InsertRule(NS_LITERAL_STRING("*|*:-moz-any-link:active{color:") + + strColor + ruleClose, + sInsertPrefSheetRulesAt, &index); + NS_ENSURE_SUCCESS(rv, rv); + + PRBool underlineLinks = PR_TRUE; + rv = mPresContext->GetCachedBoolPref(kPresContext_UnderlineLinks, underlineLinks); + NS_ENSURE_SUCCESS(rv, rv); + + if (underlineLinks) { + // create a rule to make underlining happen + // '*|*:-moz-any-link {text-decoration:[underline|none];}' + // no need for important, we want these to be overridable + // NOTE: these must go in the agent stylesheet or they cannot be + // overridden by authors + rv = sheet->InsertRule(NS_LITERAL_STRING("*|*:-moz-any-link{text-decoration:underline}"), + sInsertPrefSheetRulesAt, &index); + } else { + rv = sheet->InsertRule(NS_LITERAL_STRING("*|*:-moz-any-link{text-decoration:none}"), + sInsertPrefSheetRulesAt, &index); + } + + return rv; } nsresult PresShell::SetPrefFocusRules(void) diff --git a/layout/html/document/src/ua.css b/layout/html/document/src/ua.css index 18152f3420e..a4f0684511b 100644 --- a/layout/html/document/src/ua.css +++ b/layout/html/document/src/ua.css @@ -116,10 +116,6 @@ -moz-user-focus: normal; } -*|*:-moz-any-link:active { - color: red; -} - *|*:-moz-any-link:focus { -moz-outline: 1px dotted invert; } diff --git a/layout/style/nsCSSKeywordList.h b/layout/style/nsCSSKeywordList.h index 810086b8f82..a77ae3448d8 100644 --- a/layout/style/nsCSSKeywordList.h +++ b/layout/style/nsCSSKeywordList.h @@ -66,6 +66,7 @@ // OUTPUT_CLASS=nsCSSKeywords // MACRO_NAME=CSS_KEY +CSS_KEY(-moz-activehyperlinktext, _moz_activehyperlinktext) CSS_KEY(-moz-alias, _moz_alias) CSS_KEY(-moz-all, _moz_all) CSS_KEY(-moz-anchor-decoration, _moz_anchor_decoration) diff --git a/layout/style/nsCSSProps.cpp b/layout/style/nsCSSProps.cpp index b14a272cbfc..2193a165c95 100644 --- a/layout/style/nsCSSProps.cpp +++ b/layout/style/nsCSSProps.cpp @@ -352,6 +352,7 @@ const PRInt32 nsCSSProps::kColorKTable[] = { eCSSKeyword_window, nsILookAndFeel::eColor_window, eCSSKeyword_windowframe, nsILookAndFeel::eColor_windowframe, eCSSKeyword_windowtext, nsILookAndFeel::eColor_windowtext, + eCSSKeyword__moz_activehyperlinktext, NS_COLOR_MOZ_ACTIVEHYPERLINKTEXT, eCSSKeyword__moz_buttondefault, nsILookAndFeel::eColor__moz_buttondefault, eCSSKeyword__moz_field, nsILookAndFeel::eColor__moz_field, eCSSKeyword__moz_fieldtext, nsILookAndFeel::eColor__moz_fieldtext, diff --git a/layout/style/nsRuleNode.cpp b/layout/style/nsRuleNode.cpp index 11d24f40a90..612034e79d6 100644 --- a/layout/style/nsRuleNode.cpp +++ b/layout/style/nsRuleNode.cpp @@ -365,6 +365,11 @@ static PRBool SetColor(const nsCSSValue& aValue, const nscolor aParentColor, result = PR_TRUE; } break; + case NS_COLOR_MOZ_ACTIVEHYPERLINKTEXT: + if (NS_SUCCEEDED(aPresContext->GetDefaultActiveLinkColor(&aResult))) { + result = PR_TRUE; + } + break; default: NS_NOTREACHED("Should never have an unknown negative colorID."); break; diff --git a/layout/style/ua.css b/layout/style/ua.css index 18152f3420e..a4f0684511b 100644 --- a/layout/style/ua.css +++ b/layout/style/ua.css @@ -116,10 +116,6 @@ -moz-user-focus: normal; } -*|*:-moz-any-link:active { - color: red; -} - *|*:-moz-any-link:focus { -moz-outline: 1px dotted invert; } diff --git a/modules/libpref/src/init/all.js b/modules/libpref/src/init/all.js index 0d3b30d81cd..e3f0d637e87 100644 --- a/modules/libpref/src/init/all.js +++ b/modules/libpref/src/init/all.js @@ -90,6 +90,7 @@ pref("browser.display.force_inline_alttext", false); // true = force ALT text fo pref("browser.display.normal_lineheight_calc_control", 2); pref("browser.display.show_image_placeholders", true); // true = show image placeholders while image is loaded and when image is broken pref("browser.anchor_color", "#0000EE"); +pref("browser.active_color", "#EE0000"); pref("browser.visited_color", "#551A8B"); pref("browser.underline_anchors", true); pref("browser.blink_allowed", true); diff --git a/xpfe/components/prefwindow/resources/content/pref-colors.js b/xpfe/components/prefwindow/resources/content/pref-colors.js index e80e658c3bd..e69de29bb2d 100644 --- a/xpfe/components/prefwindow/resources/content/pref-colors.js +++ b/xpfe/components/prefwindow/resources/content/pref-colors.js @@ -1,40 +0,0 @@ -function setColorWell(aPicker) -{ - var colorRef = aPicker.nextSibling; // colour value is held here - colorRef.setAttribute( "value", aPicker.color ); -} - - function setColorWellSr(menu,otherId,setbackground) - { - // Find the colorWell and colorPicker in the hierarchy. - var colorWell = menu.firstChild; - var colorPicker = menu.firstChild.nextSibling.nextSibling.firstChild; - var colorRef = menu.nextSibling; // colour value is held here - - // Extract color from colorPicker and assign to colorWell. - var color = colorPicker.getAttribute('color'); - // set colour values in the display - setColorFromPicker( colorWell, color ); - // set the colour value internally for use in prefwindow - colorRef.setAttribute( "value", color ); - } - - function getColorFromWellAndSetValue(aPickerId) - { - var picker = document.getElementById(aPickerId); - var colorRef = picker.nextSibling; - var color = colorRef.getAttribute("value"); - picker.color = color; - return color; - } - - function Startup() - { - getColorFromWellAndSetValue("foregroundtextmenu"); - getColorFromWellAndSetValue("backgroundmenu"); - getColorFromWellAndSetValue("unvisitedlinkmenu"); - getColorFromWellAndSetValue("visitedlinkmenu"); - - return true; - } - diff --git a/xpfe/components/prefwindow/resources/content/pref-colors.xul b/xpfe/components/prefwindow/resources/content/pref-colors.xul index dfa6a555da4..5ee43517910 100644 --- a/xpfe/components/prefwindow/resources/content/pref-colors.xul +++ b/xpfe/components/prefwindow/resources/content/pref-colors.xul @@ -33,7 +33,7 @@ @@ -69,6 +69,12 @@ + +