mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 510388, check descendant documents for focus when closing popups, r=bz,sr=smaug
This commit is contained in:
parent
d688108446
commit
3028324937
@ -29,6 +29,7 @@ function testCustomizeFrameLoaded()
|
||||
var framedoc = document.getElementById("customizeToolbarSheetIFrame").contentDocument;
|
||||
var b = framedoc.getElementById("donebutton");
|
||||
|
||||
b.focus();
|
||||
framedoc.getElementById("donebutton").doCommand();
|
||||
}
|
||||
|
||||
@ -36,5 +37,7 @@ function testCustomizePopupHidden()
|
||||
{
|
||||
var panel = document.getElementById("customizeToolbarSheetPopup");
|
||||
panel.removeEventListener("popuphidden", testCustomizePopupHidden, false);
|
||||
is(document.activeElement, document.documentElement, "focus after customize done");
|
||||
|
||||
finish();
|
||||
}
|
||||
|
@ -211,6 +211,12 @@ public:
|
||||
static PRBool ContentIsDescendantOf(nsINode* aPossibleDescendant,
|
||||
nsINode* aPossibleAncestor);
|
||||
|
||||
/**
|
||||
* Similar to ContentIsDescendantOf except it crosses document boundaries.
|
||||
*/
|
||||
static PRBool ContentIsCrossDocDescendantOf(nsINode* aPossibleDescendant,
|
||||
nsINode* aPossibleAncestor);
|
||||
|
||||
/*
|
||||
* This method fills the |aArray| with all ancestor nodes of |aNode|
|
||||
* including |aNode| at the zero index.
|
||||
|
@ -1409,6 +1409,32 @@ nsContentUtils::ContentIsDescendantOf(nsINode* aPossibleDescendant,
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
// static
|
||||
PRBool
|
||||
nsContentUtils::ContentIsCrossDocDescendantOf(nsINode* aPossibleDescendant,
|
||||
nsINode* aPossibleAncestor)
|
||||
{
|
||||
NS_PRECONDITION(aPossibleDescendant, "The possible descendant is null!");
|
||||
NS_PRECONDITION(aPossibleAncestor, "The possible ancestor is null!");
|
||||
|
||||
do {
|
||||
if (aPossibleDescendant == aPossibleAncestor)
|
||||
return PR_TRUE;
|
||||
nsINode* parent = aPossibleDescendant->GetNodeParent();
|
||||
if (!parent && aPossibleDescendant->IsNodeOfType(nsINode::eDOCUMENT)) {
|
||||
nsIDocument* doc = static_cast<nsIDocument*>(aPossibleDescendant);
|
||||
nsIDocument* parentDoc = doc->GetParentDocument();
|
||||
aPossibleDescendant = parentDoc ?
|
||||
parentDoc->FindContentForSubDocument(doc) : nsnull;
|
||||
}
|
||||
else {
|
||||
aPossibleDescendant = parent;
|
||||
}
|
||||
} while (aPossibleDescendant);
|
||||
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
|
||||
// static
|
||||
nsresult
|
||||
|
@ -1043,7 +1043,7 @@ nsXULPopupManager::FirePopupShowingEvent(nsIContent* aPopup,
|
||||
fm->GetFocusedElement(getter_AddRefs(currentFocusElement));
|
||||
nsCOMPtr<nsIContent> currentFocus = do_QueryInterface(currentFocusElement);
|
||||
if (doc && currentFocus &&
|
||||
!nsContentUtils::ContentIsDescendantOf(currentFocus, aPopup)) {
|
||||
!nsContentUtils::ContentIsCrossDocDescendantOf(currentFocus, aPopup)) {
|
||||
fm->ClearFocus(doc->GetWindow());
|
||||
}
|
||||
}
|
||||
@ -1101,7 +1101,7 @@ nsXULPopupManager::FirePopupHidingEvent(nsIContent* aPopup,
|
||||
fm->GetFocusedElement(getter_AddRefs(currentFocusElement));
|
||||
nsCOMPtr<nsIContent> currentFocus = do_QueryInterface(currentFocusElement);
|
||||
if (doc && currentFocus &&
|
||||
nsContentUtils::ContentIsDescendantOf(currentFocus, aPopup)) {
|
||||
nsContentUtils::ContentIsCrossDocDescendantOf(currentFocus, aPopup)) {
|
||||
fm->ClearFocus(doc->GetWindow());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user