mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-26 12:20:56 +00:00
Backout bug 821593 for bustage.
This commit is contained in:
parent
d5b38a1374
commit
527b4acbd2
@ -75,6 +75,7 @@ interface nsIDOMCSSStyleSheet;
|
||||
interface nsIDOMCSSStyleDeclaration;
|
||||
interface nsIDOMCounter;
|
||||
interface nsIDOMRect;
|
||||
interface nsIDOMRGBColor;
|
||||
interface nsIDOMCSSStyleRule;
|
||||
interface nsIDOMCSSStyleRuleCollection;
|
||||
interface nsIDOMHTMLTableCaptionElement;
|
||||
|
@ -39,7 +39,9 @@ XPIDLSRCS = \
|
||||
nsIDOMCSSStyleRule.idl \
|
||||
nsIDOMCSSUnknownRule.idl \
|
||||
nsIDOMCounter.idl \
|
||||
nsIDOMRGBColor.idl \
|
||||
nsIDOMRect.idl \
|
||||
nsIDOMNSRGBAColor.idl \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
@ -13,7 +13,7 @@
|
||||
* http://www.w3.org/TR/DOM-Level-2-Style
|
||||
*/
|
||||
|
||||
[scriptable, uuid(f6df7293-2dc9-4cb9-9531-778caf4370e0)]
|
||||
[scriptable, uuid(e249031f-8df9-4e7a-b644-18946dce0019)]
|
||||
interface nsIDOMCSSPrimitiveValue : nsIDOMCSSValue
|
||||
{
|
||||
// UnitTypes
|
||||
@ -59,4 +59,6 @@ interface nsIDOMCSSPrimitiveValue : nsIDOMCSSValue
|
||||
raises(DOMException);
|
||||
nsIDOMRect getRectValue()
|
||||
raises(DOMException);
|
||||
nsIDOMRGBColor getRGBColorValue()
|
||||
raises(DOMException);
|
||||
};
|
||||
|
12
dom/interfaces/css/nsIDOMNSRGBAColor.idl
Normal file
12
dom/interfaces/css/nsIDOMNSRGBAColor.idl
Normal file
@ -0,0 +1,12 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsIDOMRGBColor.idl"
|
||||
|
||||
[scriptable, uuid(742dc816-5134-4214-adfa-cad9dd3377cd)]
|
||||
interface nsIDOMNSRGBAColor : nsIDOMRGBColor
|
||||
{
|
||||
readonly attribute nsIDOMCSSPrimitiveValue alpha;
|
||||
};
|
14
dom/interfaces/css/nsIDOMRGBColor.idl
Normal file
14
dom/interfaces/css/nsIDOMRGBColor.idl
Normal file
@ -0,0 +1,14 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "domstubs.idl"
|
||||
|
||||
[scriptable, uuid(6aff3102-320d-4986-9790-12316bb87cf9)]
|
||||
interface nsIDOMRGBColor : nsISupports
|
||||
{
|
||||
readonly attribute nsIDOMCSSPrimitiveValue red;
|
||||
readonly attribute nsIDOMCSSPrimitiveValue green;
|
||||
readonly attribute nsIDOMCSSPrimitiveValue blue;
|
||||
};
|
@ -26,13 +26,14 @@
|
||||
#include "nsHTMLEditor.h"
|
||||
#include "nsHTMLObjectResizer.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsROCSSPrimitiveValue.h"
|
||||
#include "nsIDOMCSSPrimitiveValue.h"
|
||||
#include "nsIDOMCSSStyleDeclaration.h"
|
||||
#include "nsIDOMCSSValue.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMEventListener.h"
|
||||
#include "nsIDOMEventTarget.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsDOMCSSRGBColor.h"
|
||||
#include "nsIDOMRGBColor.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIEditor.h"
|
||||
#include "nsIHTMLEditor.h"
|
||||
@ -660,32 +661,43 @@ nsHTMLEditor::CheckPositionedElementBGandFG(nsIDOMElement * aElement,
|
||||
NS_ENSURE_STATE(cssDecl);
|
||||
|
||||
// from these declarations, get the one we want and that one only
|
||||
ErrorResult error;
|
||||
nsRefPtr<dom::CSSValue> cssVal = cssDecl->GetPropertyCSSValue(NS_LITERAL_STRING("color"), error);
|
||||
NS_ENSURE_SUCCESS(error.ErrorCode(), error.ErrorCode());
|
||||
nsCOMPtr<nsIDOMCSSValue> colorCssValue;
|
||||
res = cssDecl->GetPropertyCSSValue(NS_LITERAL_STRING("color"), getter_AddRefs(colorCssValue));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
nsROCSSPrimitiveValue* val = cssVal->AsPrimitiveValue();
|
||||
NS_ENSURE_TRUE(val);
|
||||
|
||||
if (nsIDOMCSSPrimitiveValue::CSS_RGBCOLOR == val->PrimitiveType()) {
|
||||
nsDOMCSSRGBColor* rgbVal = val->GetRGBColorValue(error);
|
||||
NS_ENSURE_SUCCESS(error.ErrorCode(), error.ErrorCode());
|
||||
float r = rgbVal->Red()->
|
||||
GetFloatValue(nsIDOMCSSPrimitiveValue::CSS_NUMBER, error);
|
||||
NS_ENSURE_SUCCESS(error.ErrorCode(), error.ErrorCode());
|
||||
float g = rgbVal->Green()->
|
||||
GetFloatValue(nsIDOMCSSPrimitiveValue::CSS_NUMBER, error);
|
||||
NS_ENSURE_SUCCESS(error.ErrorCode(), error.ErrorCode());
|
||||
float b = rgbVal->Blue()->
|
||||
GetFloatValue(nsIDOMCSSPrimitiveValue::CSS_NUMBER, error);
|
||||
NS_ENSURE_SUCCESS(error.ErrorCode(), error.ErrorCode());
|
||||
if (r >= BLACK_BG_RGB_TRIGGER &&
|
||||
g >= BLACK_BG_RGB_TRIGGER &&
|
||||
b >= BLACK_BG_RGB_TRIGGER)
|
||||
aReturn.AssignLiteral("black");
|
||||
else
|
||||
aReturn.AssignLiteral("white");
|
||||
return NS_OK;
|
||||
uint16_t type;
|
||||
res = colorCssValue->GetCssValueType(&type);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
if (nsIDOMCSSValue::CSS_PRIMITIVE_VALUE == type) {
|
||||
nsCOMPtr<nsIDOMCSSPrimitiveValue> val = do_QueryInterface(colorCssValue);
|
||||
res = val->GetPrimitiveType(&type);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
if (nsIDOMCSSPrimitiveValue::CSS_RGBCOLOR == type) {
|
||||
nsCOMPtr<nsIDOMRGBColor> rgbColor;
|
||||
res = val->GetRGBColorValue(getter_AddRefs(rgbColor));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
nsCOMPtr<nsIDOMCSSPrimitiveValue> red, green, blue;
|
||||
float r, g, b;
|
||||
res = rgbColor->GetRed(getter_AddRefs(red));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
res = rgbColor->GetGreen(getter_AddRefs(green));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
res = rgbColor->GetBlue(getter_AddRefs(blue));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
res = red->GetFloatValue(nsIDOMCSSPrimitiveValue::CSS_NUMBER, &r);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
res = green->GetFloatValue(nsIDOMCSSPrimitiveValue::CSS_NUMBER, &g);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
res = blue->GetFloatValue(nsIDOMCSSPrimitiveValue::CSS_NUMBER, &b);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
if (r >= BLACK_BG_RGB_TRIGGER &&
|
||||
g >= BLACK_BG_RGB_TRIGGER &&
|
||||
b >= BLACK_BG_RGB_TRIGGER)
|
||||
aReturn.AssignLiteral("black");
|
||||
else
|
||||
aReturn.AssignLiteral("white");
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,14 +31,6 @@ public:
|
||||
virtual void GetCssText(nsString& aText, mozilla::ErrorResult& aRv) = 0;
|
||||
virtual void SetCssText(const nsAString& aText, mozilla::ErrorResult& aRv) = 0;
|
||||
virtual uint16_t CssValueType() const = 0;
|
||||
|
||||
// Downcasting
|
||||
|
||||
/**
|
||||
* Return this as a nsROCSSPrimitiveValue* if its a primitive value, and null
|
||||
* otherwise.
|
||||
*/
|
||||
nsROCSSPrimitiveValue *AsPrimitiveValue();
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -32,6 +32,8 @@ nsDOMCSSRGBColor::~nsDOMCSSRGBColor(void)
|
||||
}
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsDOMCSSRGBColor)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMRGBColor)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMNSRGBAColor)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
NS_INTERFACE_MAP_END
|
||||
@ -46,3 +48,39 @@ nsDOMCSSRGBColor::WrapObject(JSContext *aCx, JSObject *aScope, bool *aTried)
|
||||
return dom::RGBColorBinding::Wrap(aCx, aScope, this, aTried);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMCSSRGBColor::GetRed(nsIDOMCSSPrimitiveValue** aRed)
|
||||
{
|
||||
NS_ENSURE_TRUE(mRed, NS_ERROR_NOT_INITIALIZED);
|
||||
*aRed = mRed;
|
||||
NS_ADDREF(*aRed);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMCSSRGBColor::GetGreen(nsIDOMCSSPrimitiveValue** aGreen)
|
||||
{
|
||||
NS_ENSURE_TRUE(mGreen, NS_ERROR_NOT_INITIALIZED);
|
||||
*aGreen = mGreen;
|
||||
NS_ADDREF(*aGreen);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMCSSRGBColor::GetBlue(nsIDOMCSSPrimitiveValue** aBlue)
|
||||
{
|
||||
NS_ENSURE_TRUE(mBlue, NS_ERROR_NOT_INITIALIZED);
|
||||
*aBlue = mBlue;
|
||||
NS_ADDREF(*aBlue);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMCSSRGBColor::GetAlpha(nsIDOMCSSPrimitiveValue** aAlpha)
|
||||
{
|
||||
NS_ENSURE_TRUE(mAlpha, NS_ERROR_NOT_INITIALIZED);
|
||||
*aAlpha = mAlpha;
|
||||
NS_ADDREF(*aAlpha);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -11,11 +11,12 @@
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIDOMNSRGBAColor.h"
|
||||
#include "nsWrapperCache.h"
|
||||
|
||||
class nsROCSSPrimitiveValue;
|
||||
|
||||
class nsDOMCSSRGBColor : public nsISupports,
|
||||
class nsDOMCSSRGBColor : public nsIDOMNSRGBAColor,
|
||||
public nsWrapperCache
|
||||
{
|
||||
public:
|
||||
@ -28,6 +29,8 @@ public:
|
||||
virtual ~nsDOMCSSRGBColor(void);
|
||||
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_NSIDOMRGBCOLOR
|
||||
NS_DECL_NSIDOMNSRGBACOLOR
|
||||
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsDOMCSSRGBColor)
|
||||
|
||||
|
@ -479,6 +479,14 @@ nsROCSSPrimitiveValue::GetRectValue(nsIDOMRect** aRect)
|
||||
return error.ErrorCode();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsROCSSPrimitiveValue::GetRGBColorValue(nsIDOMRGBColor** aColor)
|
||||
{
|
||||
ErrorResult error;
|
||||
NS_IF_ADDREF(*aColor = GetRGBColorValue(error));
|
||||
return error.ErrorCode();
|
||||
}
|
||||
|
||||
nsDOMCSSRGBColor*
|
||||
nsROCSSPrimitiveValue::GetRGBColorValue(ErrorResult& aRv)
|
||||
{
|
||||
|
@ -99,11 +99,5 @@ private:
|
||||
} mValue;
|
||||
};
|
||||
|
||||
inline nsROCSSPrimitiveValue *mozilla::dom::CSSValue::AsPrimitiveValue()
|
||||
{
|
||||
return CssValueType() == nsIDOMCSSValue::CSS_PRIMITIVE_VALUE ?
|
||||
static_cast<nsROCSSPrimitiveValue*>(this) : nullptr;
|
||||
}
|
||||
|
||||
#endif /* nsROCSSPrimitiveValue_h___ */
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user