зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1341230 - Part 3: Add nsIDOMWindowUtils API to add/remove manually managed EventStates bits. r=smaug
MozReview-Commit-ID: 8brJct2tkTo --HG-- extra : rebase_source : 6a9aae7f63992a74620126bf626963b3dcc00e41
This commit is contained in:
Родитель
78b9d4ee3b
Коммит
539c85b4ec
|
@ -4095,6 +4095,63 @@ nsDOMWindowUtils::IsTimeoutTracking(uint32_t aTimeoutId, bool* aResult)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
struct StateTableEntry
|
||||
{
|
||||
const char* mStateString;
|
||||
EventStates mState;
|
||||
};
|
||||
|
||||
static const StateTableEntry kManuallyManagedStates[] = {
|
||||
// none yet; but for example: { "highlight", NS_EVENT_STATE_HIGHLIGHT },
|
||||
};
|
||||
|
||||
static EventStates
|
||||
GetEventStateForString(const nsAString& aStateString)
|
||||
{
|
||||
for (auto& entry : kManuallyManagedStates) {
|
||||
if (aStateString.EqualsASCII(entry.mStateString)) {
|
||||
return entry.mState;
|
||||
}
|
||||
}
|
||||
return EventStates();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMWindowUtils::AddManuallyManagedState(nsIDOMElement* aElement,
|
||||
const nsAString& aStateString)
|
||||
{
|
||||
nsCOMPtr<Element> element = do_QueryInterface(aElement);
|
||||
if (!element) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
EventStates state = GetEventStateForString(aStateString);
|
||||
if (state.IsEmpty()) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
element->AddManuallyManagedStates(state);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMWindowUtils::RemoveManuallyManagedState(nsIDOMElement* aElement,
|
||||
const nsAString& aStateString)
|
||||
{
|
||||
nsCOMPtr<Element> element = do_QueryInterface(aElement);
|
||||
if (!element) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
EventStates state = GetEventStateForString(aStateString);
|
||||
if (state.IsEmpty()) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
element->RemoveManuallyManagedStates(state);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsTranslationNodeList)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_ENTRY(nsITranslationNodeList)
|
||||
|
|
|
@ -1976,6 +1976,26 @@ interface nsIDOMWindowUtils : nsISupports {
|
|||
*/
|
||||
boolean isTimeoutTracking(in unsigned long timeoutId);
|
||||
|
||||
/**
|
||||
* Adds an EventStates bit to the element.
|
||||
*
|
||||
* The state string must be one of the following:
|
||||
* * (none yet; but for example "higlighted" for NS_EVENT_STATE_HIGHLIGHTED)
|
||||
*
|
||||
* The supported state strings are defined in kManuallyManagedStates
|
||||
* in nsDOMWindowUtils.cpp.
|
||||
*/
|
||||
void addManuallyManagedState(in nsIDOMElement element,
|
||||
in AString state);
|
||||
|
||||
/**
|
||||
* Removes the specified EventStates bits from the element.
|
||||
*
|
||||
* See above for the strings that can be passed for |state|.
|
||||
*/
|
||||
void removeManuallyManagedState(in nsIDOMElement element,
|
||||
in AString state);
|
||||
|
||||
// These consts are only for testing purposes.
|
||||
const long DEFAULT_MOUSE_POINTER_ID = 0;
|
||||
const long DEFAULT_PEN_POINTER_ID = 1;
|
||||
|
|
Загрузка…
Ссылка в новой задаче