зеркало из https://github.com/mozilla/gecko-dev.git
Bug 848745 part 1. Add a scriptable API for converting CSS color names to RGB triples. r=dbaron,miker
This commit is contained in:
Родитель
b99f74d53d
Коммит
7c9bd5afaf
|
@ -13,6 +13,7 @@ interface DummyInterface {
|
|||
RTCConfiguration rtcConfiguration();
|
||||
CFStateChangeEventDict cfstateChangeEvent();
|
||||
USSDReceivedEventDict ussdReceivedEvent();
|
||||
InspectorRGBTriple rgbTriple();
|
||||
};
|
||||
|
||||
interface DummyInterfaceWorkers {
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
/* -*- 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/.
|
||||
*/
|
||||
dictionary InspectorRGBTriple {
|
||||
/*
|
||||
* NOTE: Using octet for RGB components is not generally OK, because
|
||||
* they can be outside the 0-255 range, but for backwards-compatible
|
||||
* named colors (which is what we use this dictionary for) the 0-255
|
||||
* assumption is fine.
|
||||
*/
|
||||
octet r = 0;
|
||||
octet g = 0;
|
||||
octet b = 0;
|
||||
};
|
|
@ -119,6 +119,7 @@ webidl_files = \
|
|||
HTMLUListElement.webidl \
|
||||
IDBVersionChangeEvent.webidl \
|
||||
ImageData.webidl \
|
||||
InspectorUtils.webidl \
|
||||
LinkStyle.webidl \
|
||||
LocalMediaStream.webidl \
|
||||
Location.webidl \
|
||||
|
|
|
@ -16,7 +16,7 @@ interface nsIDOMFontFaceList;
|
|||
interface nsIDOMRange;
|
||||
interface nsIDOMCSSStyleSheet;
|
||||
|
||||
[scriptable, uuid(ea7e58ad-da38-4d1e-b0fc-fd7fb5c560c9)]
|
||||
[scriptable, uuid(1d9c29dc-230a-441e-bba9-49104ffa185e)]
|
||||
interface inIDOMUtils : nsISupports
|
||||
{
|
||||
// CSS utilities
|
||||
|
@ -54,6 +54,10 @@ interface inIDOMUtils : nsISupports
|
|||
[optional] out unsigned long aCount,
|
||||
[retval, array, size_is(aCount)] out wstring aProps);
|
||||
|
||||
// Utilities for working with CSS colors
|
||||
[implicit_jscontext]
|
||||
jsval colorNameToRGB(in DOMString aColorName);
|
||||
|
||||
// DOM Node utilities
|
||||
boolean isIgnorableWhitespace(in nsIDOMCharacterData aDataNode);
|
||||
// Returns the "parent" of a node. The parent of a document node is the
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "nsRuleWalker.h"
|
||||
#include "nsRuleProcessorData.h"
|
||||
#include "nsCSSRuleProcessor.h"
|
||||
#include "mozilla/dom/InspectorUtilsBinding.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::css;
|
||||
|
@ -414,6 +415,27 @@ inDOMUtils::GetCSSPropertyNames(uint32_t aFlags, uint32_t* aCount,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inDOMUtils::ColorNameToRGB(const nsAString& aColorName, JSContext* aCx,
|
||||
JS::Value* aValue)
|
||||
{
|
||||
nscolor color;
|
||||
if (!NS_ColorNameToRGB(aColorName, &color)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
InspectorRGBTriple triple;
|
||||
triple.mR = NS_GET_R(color);
|
||||
triple.mG = NS_GET_G(color);
|
||||
triple.mB = NS_GET_B(color);
|
||||
|
||||
if (!triple.ToObject(aCx, nullptr, aValue)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inDOMUtils::GetBindingURLs(nsIDOMElement *aElement, nsIArray **_retval)
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче