Bug 1247420 - part1: removeContentState. r=smaug

This commit is contained in:
Gabor Krizsanits 2016-03-30 11:54:27 +02:00
Родитель 1696ce6feb
Коммит 696b23001a
3 изменённых файлов: 37 добавлений и 12 удалений

Просмотреть файл

@ -1095,21 +1095,36 @@ inDOMUtils::GetBindingURLs(nsIDOMElement *aElement, nsIArray **_retval)
NS_IMETHODIMP
inDOMUtils::SetContentState(nsIDOMElement* aElement,
EventStates::InternalType aState)
EventStates::InternalType aState,
bool* aRetVal)
{
NS_ENSURE_ARG_POINTER(aElement);
RefPtr<EventStateManager> esm =
inLayoutUtils::GetEventStateManagerFor(aElement);
if (esm) {
nsCOMPtr<nsIContent> content;
content = do_QueryInterface(aElement);
NS_ENSURE_TRUE(esm, NS_ERROR_INVALID_ARG);
// XXX Invalid cast of bool to nsresult (bug 778108)
return (nsresult)esm->SetContentState(content, EventStates(aState));
}
nsCOMPtr<nsIContent> content;
content = do_QueryInterface(aElement);
NS_ENSURE_TRUE(content, NS_ERROR_INVALID_ARG);
return NS_ERROR_FAILURE;
*aRetVal = esm->SetContentState(content, EventStates(aState));
return NS_OK;
}
NS_IMETHODIMP
inDOMUtils::RemoveContentState(nsIDOMElement* aElement,
EventStates::InternalType aState,
bool* aRetVal)
{
NS_ENSURE_ARG_POINTER(aElement);
RefPtr<EventStateManager> esm =
inLayoutUtils::GetEventStateManagerFor(aElement);
NS_ENSURE_TRUE(esm, NS_ERROR_INVALID_ARG);
*aRetVal = esm->SetContentState(nullptr, EventStates(aState));
return NS_OK;
}
NS_IMETHODIMP

Просмотреть файл

@ -17,7 +17,7 @@ interface nsIDOMFontFaceList;
interface nsIDOMRange;
interface nsIDOMCSSStyleSheet;
[scriptable, uuid(ec3dc3d5-41d1-4d08-ace5-7e944de6614d)]
[scriptable, uuid(362e98c3-82c2-4ad8-8dcb-00e8e4eab497)]
interface inIDOMUtils : nsISupports
{
// CSS utilities
@ -158,7 +158,17 @@ interface inIDOMUtils : nsISupports
// content state utilities
unsigned long long getContentState(in nsIDOMElement aElement);
void setContentState(in nsIDOMElement aElement, in unsigned long long aState);
/**
* Setting and removing content state on an element. Both these functions
* calling EventStateManager::SetContentState internally, the difference is
* that for the remove case we simply pass in nullptr for the element.
* Use them accordingly.
*
* @return Returns true if the state was set successfully. See more details
* in EventStateManager.h SetContentState.
*/
bool setContentState(in nsIDOMElement aElement, in unsigned long long aState);
bool removeContentState(in nsIDOMElement aElement, in unsigned long long aState);
nsIDOMFontFaceList getUsedFontFaces(in nsIDOMRange aRange);

Просмотреть файл

@ -20,7 +20,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=462789
/** Test for Bug 462789 **/
function do_test() {
const ERROR_FAILURE = 0x80004005;
const ERROR_INVALID_ARG = 0x80070057;
const DOCUMENT_NODE_TYPE = 9;
var utils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
@ -79,7 +79,7 @@ function do_test() {
}
catch(e) {
e = SpecialPowers.wrap(e);
is(e.result, ERROR_FAILURE, "got the expected exception");
is(e.result, ERROR_INVALID_ARG, "got the expected exception");
}
SimpleTest.finish();