Bug 1073043 - Fix mouse events trapped in shadow DOM. r=smaug

This commit is contained in:
William Chen 2014-10-02 01:31:45 -07:00
Родитель 8a4adcbe04
Коммит a2ff640daa
2 изменённых файлов: 7 добавлений и 7 удалений

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

@ -187,6 +187,7 @@ public:
/**
* Returns the parent node of aChild crossing document boundaries.
* Uses the parent node in the composed document.
*/
static nsINode* GetCrossDocParentNode(nsINode* aChild);
@ -217,7 +218,8 @@ public:
/**
* Similar to ContentIsDescendantOf except it crosses document boundaries,
* also crosses ShadowRoot boundaries from ShadowRoot to its host.
* this function uses ancestor/descendant relations in the composed document
* (see shadow DOM spec).
*/
static bool ContentIsCrossDocDescendantOf(nsINode* aPossibleDescendant,
nsINode* aPossibleAncestor);

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

@ -2025,6 +2025,10 @@ nsContentUtils::GetCrossDocParentNode(nsINode* aChild)
NS_PRECONDITION(aChild, "The child is null!");
nsINode* parent = aChild->GetParentNode();
if (parent && parent->IsContent() && aChild->IsContent()) {
parent = aChild->AsContent()->GetFlattenedTreeParent();
}
if (parent || !aChild->IsNodeOfType(nsINode::eDOCUMENT))
return parent;
@ -2083,12 +2087,6 @@ nsContentUtils::ContentIsCrossDocDescendantOf(nsINode* aPossibleDescendant,
if (aPossibleDescendant == aPossibleAncestor)
return true;
// Step over shadow root to the host node.
ShadowRoot* shadowRoot = ShadowRoot::FromNode(aPossibleDescendant);
if (shadowRoot) {
aPossibleDescendant = shadowRoot->GetHost();
}
aPossibleDescendant = GetCrossDocParentNode(aPossibleDescendant);
} while (aPossibleDescendant);