Bug 1652819 - Don't assume that all filtered frames have an associated DOM node. r=mstange

This is not true for pages, which I want to add a filter to in
bug 1631449.

Differential Revision: https://phabricator.services.mozilla.com/D83544
This commit is contained in:
Emilio Cobos Álvarez 2020-07-14 18:08:23 +00:00
Родитель fe4a027e82
Коммит 47efbc8aa8
2 изменённых файлов: 8 добавлений и 9 удалений

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

@ -52,8 +52,7 @@ FilterDescription FilterInstance::GetFilterDescription(
}
static UniquePtr<UserSpaceMetrics> UserSpaceMetricsForFrame(nsIFrame* aFrame) {
if (aFrame->GetContent()->IsSVGElement()) {
SVGElement* element = static_cast<SVGElement*>(aFrame->GetContent());
if (auto* element = SVGElement::FromNodeOrNull(aFrame->GetContent())) {
return MakeUnique<SVGElementMetrics>(element);
}
return MakeUnique<NonSVGFrameUserSpaceMetrics>(aFrame);

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

@ -969,7 +969,7 @@ void SVGUtils::SetClipRect(gfxContext* aContext, const gfxMatrix& aCTM,
gfxRect SVGUtils::GetBBox(nsIFrame* aFrame, uint32_t aFlags,
const gfxMatrix* aToBoundsSpace) {
if (aFrame->GetContent()->IsText()) {
if (aFrame->IsTextFrame()) {
aFrame = aFrame->GetParent();
}
@ -1008,10 +1008,10 @@ gfxRect SVGUtils::GetBBox(nsIFrame* aFrame, uint32_t aFlags,
MOZ_ASSERT(svg);
nsIContent* content = aFrame->GetContent();
if (content->IsSVGElement() &&
!static_cast<const SVGElement*>(content)->HasValidDimensions()) {
return gfxRect();
if (auto* element = SVGElement::FromNodeOrNull(aFrame->GetContent())) {
if (!element->HasValidDimensions()) {
return gfxRect();
}
}
// Clean out flags which have no effects on returning bbox from now, so that
@ -1043,8 +1043,8 @@ gfxRect SVGUtils::GetBBox(nsIFrame* aFrame, uint32_t aFlags,
// needs investigation to check that we won't break too much content.
// NOTE: When changing this to apply to other frame types, make sure to
// also update SVGUtils::FrameSpaceInCSSPxToUserSpaceOffset.
MOZ_ASSERT(content->IsSVGElement(), "bad cast");
SVGElement* element = static_cast<SVGElement*>(content);
MOZ_ASSERT(aFrame->GetContent()->IsSVGElement(), "bad cast");
SVGElement* element = static_cast<SVGElement*>(aFrame->GetContent());
matrix = element->PrependLocalTransformsTo(matrix, eChildToUserSpace);
}
gfxRect bbox =