Bug 1608515: Update the SVG IsContainingWindowElementOfType impl for Fission r=barret,dholbert

In nsSVGOuterSVGFrame::IsContainingWindowElementOfType, we now inspect
the embedder by asking the window for its browsing context, instead of
asking it directly for its frame element.

Differential Revision: https://phabricator.services.mozilla.com/D77518
This commit is contained in:
Keefer Rourke 2020-06-03 15:24:54 +00:00
Родитель d813d2e019
Коммит 1b3a17d452
2 изменённых файлов: 21 добавлений и 10 удалений

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

@ -902,18 +902,16 @@ bool nsSVGOuterSVGFrame::IsContainingWindowElementOfType(
nsIFrame** aContainingWindowFrame, Args... aArgs) const {
if (!mContent->GetParent()) {
// Our content is the document element
nsCOMPtr<nsIDocShell> docShell = PresContext()->GetDocShell();
nsCOMPtr<nsPIDOMWindowOuter> window;
if (docShell) {
window = docShell->GetWindow();
}
if (nsCOMPtr<nsIDocShell> docShell = PresContext()->GetDocShell()) {
RefPtr<BrowsingContext> bc = docShell->GetBrowsingContext();
const Maybe<nsString>& type = bc->GetEmbedderElementType();
if (window) {
RefPtr<Element> frameElement = window->GetFrameElement();
if (frameElement && frameElement->IsAnyOfHTMLElements(aArgs...)) {
if (type && IsAnyAtomEqual(*type, aArgs...)) {
if (aContainingWindowFrame) {
*aContainingWindowFrame = frameElement->GetPrimaryFrame();
NS_ASSERTION(*aContainingWindowFrame, "Yikes, no frame!");
if (const Element* const element = bc->GetEmbedderElement()) {
*aContainingWindowFrame = element->GetPrimaryFrame();
NS_ASSERTION(*aContainingWindowFrame, "Yikes, no frame!");
}
}
return true;
}
@ -1046,3 +1044,9 @@ bool nsSVGOuterSVGAnonChildFrame::IsSVGTransformed(
return true;
}
template <typename... Atoms>
bool IsAnyAtomEqual(const nsAString& aString, nsAtom* aFirst, Atoms... aArgs) {
return aFirst->Equals(aString) || IsAnyAtomEqual(aString, aArgs...);
}
bool IsAnyAtomEqual(const nsAString& aString) { return false; }

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

@ -261,4 +261,11 @@ class nsSVGOuterSVGAnonChildFrame final : public nsSVGDisplayContainerFrame {
}
};
/**
* Recursively checks if any atom in the parameter pack is equal to |aString|.
*/
template <typename... Atoms>
bool IsAnyAtomEqual(const nsAString& aString, nsAtom* aFirst, Atoms... aArgs);
bool IsAnyAtomEqual(const nsAString& aString);
#endif