зеркало из https://github.com/mozilla/pjs.git
Bug 493881: ignore attempts to set legacy color props on a HTML document object before its body element exists. r+sr=bzbarsky
This commit is contained in:
Родитель
bf368314b4
Коммит
16e034181e
|
@ -80,7 +80,6 @@
|
|||
#include "nsIXPConnect.h"
|
||||
#include "nsContentList.h"
|
||||
#include "nsDOMError.h"
|
||||
#include "nsContentErrors.h"
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsAttrName.h"
|
||||
|
@ -2384,37 +2383,14 @@ nsHTMLDocument::GetHeight(PRInt32* aHeight)
|
|||
return GetBodySize(&width, aHeight);
|
||||
}
|
||||
|
||||
static void
|
||||
LegacyRGBToHex(nscolor aColor, nsAString& aResult)
|
||||
{
|
||||
if (NS_GET_A(aColor) == 255) {
|
||||
char buf[10];
|
||||
PR_snprintf(buf, sizeof(buf), "#%02x%02x%02x",
|
||||
NS_GET_R(aColor), NS_GET_G(aColor), NS_GET_B(aColor));
|
||||
CopyASCIItoUTF16(buf, aResult);
|
||||
} else if (aColor == NS_RGBA(0,0,0,0)) {
|
||||
aResult.AssignLiteral("transparent");
|
||||
} else {
|
||||
NS_NOTREACHED("translucent color property cannot be stringified");
|
||||
aResult.Truncate();
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetAlinkColor(nsAString& aAlinkColor)
|
||||
{
|
||||
aAlinkColor.Truncate();
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLBodyElement> body = do_QueryInterface(GetBodyContent());
|
||||
|
||||
if (body) {
|
||||
body->GetALink(aAlinkColor);
|
||||
} else if (mAttrStyleSheet) {
|
||||
nscolor color;
|
||||
nsresult rv = mAttrStyleSheet->GetActiveLinkColor(color);
|
||||
if (NS_SUCCEEDED(rv) && rv != NS_HTML_STYLE_PROPERTY_NOT_THERE) {
|
||||
LegacyRGBToHex(color, aAlinkColor);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -2424,16 +2400,8 @@ NS_IMETHODIMP
|
|||
nsHTMLDocument::SetAlinkColor(const nsAString& aAlinkColor)
|
||||
{
|
||||
nsCOMPtr<nsIDOMHTMLBodyElement> body = do_QueryInterface(GetBodyContent());
|
||||
|
||||
if (body) {
|
||||
body->SetALink(aAlinkColor);
|
||||
} else if (mAttrStyleSheet) {
|
||||
nsAttrValue value;
|
||||
if (value.ParseColor(aAlinkColor, this)) {
|
||||
nscolor color;
|
||||
value.GetColorValue(color);
|
||||
mAttrStyleSheet->SetActiveLinkColor(color);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -2445,15 +2413,8 @@ nsHTMLDocument::GetLinkColor(nsAString& aLinkColor)
|
|||
aLinkColor.Truncate();
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLBodyElement> body = do_QueryInterface(GetBodyContent());
|
||||
|
||||
if (body) {
|
||||
body->GetLink(aLinkColor);
|
||||
} else if (mAttrStyleSheet) {
|
||||
nscolor color;
|
||||
nsresult rv = mAttrStyleSheet->GetLinkColor(color);
|
||||
if (NS_SUCCEEDED(rv) && rv != NS_HTML_STYLE_PROPERTY_NOT_THERE) {
|
||||
LegacyRGBToHex(color, aLinkColor);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -2463,16 +2424,8 @@ NS_IMETHODIMP
|
|||
nsHTMLDocument::SetLinkColor(const nsAString& aLinkColor)
|
||||
{
|
||||
nsCOMPtr<nsIDOMHTMLBodyElement> body = do_QueryInterface(GetBodyContent());
|
||||
|
||||
if (body) {
|
||||
body->SetLink(aLinkColor);
|
||||
} else if (mAttrStyleSheet) {
|
||||
nsAttrValue value;
|
||||
if (value.ParseColor(aLinkColor, this)) {
|
||||
nscolor color;
|
||||
value.GetColorValue(color);
|
||||
mAttrStyleSheet->SetLinkColor(color);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -2484,15 +2437,8 @@ nsHTMLDocument::GetVlinkColor(nsAString& aVlinkColor)
|
|||
aVlinkColor.Truncate();
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLBodyElement> body = do_QueryInterface(GetBodyContent());
|
||||
|
||||
if (body) {
|
||||
body->GetVLink(aVlinkColor);
|
||||
} else if (mAttrStyleSheet) {
|
||||
nscolor color;
|
||||
nsresult rv = mAttrStyleSheet->GetVisitedLinkColor(color);
|
||||
if (NS_SUCCEEDED(rv) && rv != NS_HTML_STYLE_PROPERTY_NOT_THERE) {
|
||||
LegacyRGBToHex(color, aVlinkColor);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -2502,16 +2448,8 @@ NS_IMETHODIMP
|
|||
nsHTMLDocument::SetVlinkColor(const nsAString& aVlinkColor)
|
||||
{
|
||||
nsCOMPtr<nsIDOMHTMLBodyElement> body = do_QueryInterface(GetBodyContent());
|
||||
|
||||
if (body) {
|
||||
body->SetVLink(aVlinkColor);
|
||||
} else if (mAttrStyleSheet) {
|
||||
nsAttrValue value;
|
||||
if (value.ParseColor(aVlinkColor, this)) {
|
||||
nscolor color;
|
||||
value.GetColorValue(color);
|
||||
mAttrStyleSheet->SetVisitedLinkColor(color);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -2523,7 +2461,6 @@ nsHTMLDocument::GetBgColor(nsAString& aBgColor)
|
|||
aBgColor.Truncate();
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLBodyElement> body = do_QueryInterface(GetBodyContent());
|
||||
|
||||
if (body) {
|
||||
body->GetBgColor(aBgColor);
|
||||
}
|
||||
|
@ -2535,11 +2472,9 @@ NS_IMETHODIMP
|
|||
nsHTMLDocument::SetBgColor(const nsAString& aBgColor)
|
||||
{
|
||||
nsCOMPtr<nsIDOMHTMLBodyElement> body = do_QueryInterface(GetBodyContent());
|
||||
|
||||
if (body) {
|
||||
body->SetBgColor(aBgColor);
|
||||
}
|
||||
// XXXldb And otherwise?
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -2550,7 +2485,6 @@ nsHTMLDocument::GetFgColor(nsAString& aFgColor)
|
|||
aFgColor.Truncate();
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLBodyElement> body = do_QueryInterface(GetBodyContent());
|
||||
|
||||
if (body) {
|
||||
body->GetText(aFgColor);
|
||||
}
|
||||
|
@ -2562,11 +2496,9 @@ NS_IMETHODIMP
|
|||
nsHTMLDocument::SetFgColor(const nsAString& aFgColor)
|
||||
{
|
||||
nsCOMPtr<nsIDOMHTMLBodyElement> body = do_QueryInterface(GetBodyContent());
|
||||
|
||||
if (body) {
|
||||
body->SetText(aFgColor);
|
||||
}
|
||||
// XXXldb And otherwise?
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче