зеркало из https://github.com/mozilla/gecko-dev.git
Bug 598833 part 6. Get rid of nsEventStateManager::GetContentState. r=smaug
This commit is contained in:
Родитель
227db86144
Коммит
a63c9fb554
|
@ -4211,17 +4211,6 @@ GetLabelTarget(nsIContent* aPossibleLabel)
|
|||
return label->GetLabeledElement();
|
||||
}
|
||||
|
||||
nsEventStates
|
||||
nsEventStateManager::GetContentState(nsIContent *aContent)
|
||||
{
|
||||
nsEventStates state;
|
||||
if (aContent->IsElement()) {
|
||||
state = aContent->AsElement()->State();
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
static nsIContent* FindCommonAncestor(nsIContent *aNode1, nsIContent *aNode2)
|
||||
{
|
||||
// Find closest common ancestor
|
||||
|
|
|
@ -119,13 +119,6 @@ public:
|
|||
nsIFrame* GetEventTarget();
|
||||
already_AddRefed<nsIContent> GetEventTargetContent(nsEvent* aEvent);
|
||||
|
||||
/**
|
||||
* Returns the content state of aContent.
|
||||
* @param aContent The control whose state is requested.
|
||||
* @return The content state.
|
||||
*/
|
||||
virtual nsEventStates GetContentState(nsIContent *aContent);
|
||||
|
||||
/**
|
||||
* Notify that the given NS_EVENT_STATE_* bit has changed for this content.
|
||||
* @param aContent Content which has changed states
|
||||
|
|
|
@ -289,20 +289,13 @@ NS_IMETHODIMP
|
|||
inDOMUtils::GetContentState(nsIDOMElement *aElement, nsEventStates::InternalType* aState)
|
||||
{
|
||||
*aState = 0;
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(aElement);
|
||||
NS_ENSURE_ARG_POINTER(content);
|
||||
|
||||
NS_ENSURE_ARG_POINTER(aElement);
|
||||
|
||||
nsRefPtr<nsEventStateManager> esm = inLayoutUtils::GetEventStateManagerFor(aElement);
|
||||
if (esm) {
|
||||
nsCOMPtr<nsIContent> content;
|
||||
content = do_QueryInterface(aElement);
|
||||
// NOTE: if this method is removed,
|
||||
// please remove GetInternalValue from nsEventStates
|
||||
*aState = esm->GetContentState(content).GetInternalValue();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
// NOTE: if this method is removed,
|
||||
// please remove GetInternalValue from nsEventStates
|
||||
*aState = content->AsElement()->State().GetInternalValue();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* static */ nsresult
|
||||
|
|
|
@ -71,9 +71,9 @@ function do_test() {
|
|||
|
||||
try {
|
||||
utils.getContentState(docElement);
|
||||
ok(false, "expected an exception");
|
||||
ok(true, "Should not throw");
|
||||
}
|
||||
catch(e) { is(e.result, ERROR_FAILURE, "got the expected exception"); }
|
||||
catch(e) { ok(false, "Got an exception: " + e); }
|
||||
|
||||
try {
|
||||
utils.setContentState(docElement, false);
|
||||
|
|
|
@ -1149,14 +1149,7 @@ static void GetLang(nsIContent* aContent, nsString& aLang)
|
|||
nsEventStates
|
||||
nsCSSRuleProcessor::GetContentState(Element* aElement)
|
||||
{
|
||||
nsIPresShell* shell = aElement->GetOwnerDoc()->GetShell();
|
||||
nsPresContext* presContext;
|
||||
nsEventStates state;
|
||||
if (shell && (presContext = shell->GetPresContext())) {
|
||||
state = presContext->EventStateManager()->GetContentState(aElement);
|
||||
} else {
|
||||
state = aElement->IntrinsicState();
|
||||
}
|
||||
nsEventStates state = aElement->State();
|
||||
|
||||
// If we are not supposed to mark visited links as such, be sure to
|
||||
// flip the bits appropriately. We want to do this here, rather
|
||||
|
|
|
@ -121,11 +121,12 @@ nsButtonBoxFrame::HandleEvent(nsPresContext* aPresContext,
|
|||
nsKeyEvent* keyEvent = (nsKeyEvent*)aEvent;
|
||||
if (NS_VK_SPACE == keyEvent->keyCode) {
|
||||
// only activate on keyup if we're already in the :hover:active state
|
||||
nsEventStateManager *esm = aPresContext->EventStateManager();
|
||||
nsEventStates buttonState = esm->GetContentState(mContent);
|
||||
NS_ASSERTION(mContent->IsElement(), "How do we have a non-element?");
|
||||
nsEventStates buttonState = mContent->AsElement()->State();
|
||||
if (buttonState.HasAllStates(NS_EVENT_STATE_ACTIVE |
|
||||
NS_EVENT_STATE_HOVER)) {
|
||||
// return to normal state
|
||||
nsEventStateManager *esm = aPresContext->EventStateManager();
|
||||
esm->SetContentState(nsnull, NS_EVENT_STATE_ACTIVE);
|
||||
esm->SetContentState(nsnull, NS_EVENT_STATE_HOVER);
|
||||
MouseClicked(aPresContext, aEvent);
|
||||
|
|
|
@ -836,12 +836,13 @@ nsMenuPopupFrame::HidePopup(PRBool aDeselectMenu, nsPopupState aNewState)
|
|||
// XXX, bug 137033, In Windows, if mouse is outside the window when the menupopup closes, no
|
||||
// mouse_enter/mouse_exit event will be fired to clear current hover state, we should clear it manually.
|
||||
// This code may not the best solution, but we can leave it here until we find the better approach.
|
||||
nsEventStateManager *esm = PresContext()->EventStateManager();
|
||||
NS_ASSERTION(mContent->IsElement(), "How do we have a non-element?");
|
||||
nsEventStates state = mContent->AsElement()->State();
|
||||
|
||||
nsEventStates state = esm->GetContentState(mContent);
|
||||
|
||||
if (state.HasState(NS_EVENT_STATE_HOVER))
|
||||
if (state.HasState(NS_EVENT_STATE_HOVER)) {
|
||||
nsEventStateManager *esm = PresContext()->EventStateManager();
|
||||
esm->SetContentState(nsnull, NS_EVENT_STATE_HOVER);
|
||||
}
|
||||
|
||||
nsMenuFrame* menuFrame = GetParentMenu();
|
||||
if (menuFrame) {
|
||||
|
|
|
@ -92,8 +92,11 @@ nsNativeTheme::GetContentState(nsIFrame* aFrame, PRUint8 aWidgetType)
|
|||
if (!shell)
|
||||
return nsEventStates();
|
||||
|
||||
nsEventStateManager* esm = shell->GetPresContext()->EventStateManager();
|
||||
nsEventStates flags = esm->GetContentState(aFrame->GetContent());
|
||||
nsIContent* frameContent = aFrame->GetContent();
|
||||
nsEventStates flags;
|
||||
if (frameContent->IsElement()) {
|
||||
flags = frameContent->AsElement()->State();
|
||||
}
|
||||
|
||||
if (isXULCheckboxRadio && aWidgetType == NS_THEME_RADIO) {
|
||||
if (IsFocused(aFrame))
|
||||
|
|
Загрузка…
Ссылка в новой задаче