Bug 1826001 - Change SVGUtils::IsInSVGTextSubtree into a member function on nsIFrame r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D174375
This commit is contained in:
Robert Longson 2023-04-02 21:17:07 +00:00
parent c245ca8f03
commit 7e65e06613
19 changed files with 83 additions and 101 deletions

View File

@ -10,7 +10,6 @@
#include "mozilla/PointerLockManager.h"
#include "mozilla/PresShell.h"
#include "mozilla/StyleSheet.h"
#include "mozilla/SVGUtils.h"
#include "mozilla/dom/AnimatableBinding.h"
#include "mozilla/dom/Document.h"
#include "mozilla/dom/HTMLInputElement.h"
@ -414,7 +413,7 @@ static void QueryNodesFromRect(DocumentOrShadowRoot& aRoot, const nsRect& aRect,
// SVG 'text' element's SVGTextFrame doesn't respond to hit-testing, so
// if 'content' is a child of such an element then we need to manually
// defer to the parent here.
if (aMultiple == Multiple::Yes && !SVGUtils::IsInSVGTextSubtree(frame)) {
if (aMultiple == Multiple::Yes && !frame->IsInSVGTextSubtree()) {
continue;
}

View File

@ -61,7 +61,7 @@ already_AddRefed<SVGRect> SVGGraphicsElement::GetBBox(
ISVGDisplayableFrame* svgframe = do_QueryFrame(frame);
if (!svgframe) {
if (!SVGUtils::IsInSVGTextSubtree(frame)) {
if (!frame->IsInSVGTextSubtree()) {
return ZeroBBox(*this);
}

View File

@ -991,7 +991,7 @@ static bool ContainingBlockChangeAffectsDescendants(
nsIFrame* outOfFlow = nsPlaceholderFrame::GetRealFrameForPlaceholder(f);
// If SVG text frames could appear here, they could confuse us since
// they ignore their position style ... but they can't.
NS_ASSERTION(!SVGUtils::IsInSVGTextSubtree(outOfFlow),
NS_ASSERTION(!outOfFlow->IsInSVGTextSubtree(),
"SVG text frames can't be out of flow");
// Top-layer frames don't change containing block based on direct
// ancestors.

View File

@ -119,7 +119,6 @@
#include "mozilla/dom/SVGFilters.h"
#include "mozilla/dom/SVGTests.h"
#include "mozilla/SVGGradientFrame.h"
#include "mozilla/SVGUtils.h"
#include "nsRefreshDriver.h"
#include "nsTextNode.h"
@ -286,8 +285,7 @@ static inline bool IsDisplayContents(const nsIContent* aContent) {
* frame being used for SVG text.
*/
static bool IsFrameForSVG(const nsIFrame* aFrame) {
return aFrame->IsFrameOfType(nsIFrame::eSVG) ||
SVGUtils::IsInSVGTextSubtree(aFrame);
return aFrame->IsFrameOfType(nsIFrame::eSVG) || aFrame->IsInSVGTextSubtree();
}
static bool IsLastContinuationForColumnContent(const nsIFrame* aFrame) {
@ -935,8 +933,7 @@ nsContainerFrame* nsFrameConstructorState::GetGeometricParent(
// XXXbz couldn't we just force position to "static" on roots and
// float to "none"? That's OK per CSS 2.1, as far as I can tell.
if (aContentParentFrame &&
SVGUtils::IsInSVGTextSubtree(aContentParentFrame)) {
if (aContentParentFrame && aContentParentFrame->IsInSVGTextSubtree()) {
return aContentParentFrame;
}
@ -3338,7 +3335,7 @@ const nsCSSFrameConstructor::FrameConstructionData*
nsCSSFrameConstructor::FindTextData(const Text& aTextContent,
nsIFrame* aParentFrame) {
if (aParentFrame && IsFrameForSVG(aParentFrame)) {
if (!SVGUtils::IsInSVGTextSubtree(aParentFrame)) {
if (!aParentFrame->IsInSVGTextSubtree()) {
return nullptr;
}
@ -4578,7 +4575,7 @@ nsIFrame* nsCSSFrameConstructor::ConstructNonScrollableBlock(
if ((aDisplay->IsAbsolutelyPositionedStyle() || aDisplay->IsFloatingStyle() ||
aDisplay->DisplayInside() == StyleDisplayInside::FlowRoot ||
clipPaginatedOverflow) &&
!SVGUtils::IsInSVGTextSubtree(aParentFrame)) {
!aParentFrame->IsInSVGTextSubtree()) {
flags = NS_BLOCK_FORMATTING_CONTEXT_STATE_BITS;
if (clipPaginatedOverflow) {
flags |= NS_BLOCK_CLIP_PAGINATED_OVERFLOW;
@ -5151,7 +5148,7 @@ void nsCSSFrameConstructor::AddFrameConstructionItems(
RefPtr<ComputedStyle> computedStyle = ResolveComputedStyle(aContent);
auto flags = aFlags + ItemFlag::AllowPageBreak;
if (parentFrame) {
if (SVGUtils::IsInSVGTextSubtree(parentFrame)) {
if (parentFrame->IsInSVGTextSubtree()) {
flags += ItemFlag::IsWithinSVGText;
}
if (parentFrame->IsBlockFrame() && parentFrame->GetParent() &&
@ -10134,8 +10131,7 @@ void nsCSSFrameConstructor::CreateLetterFrame(
// Create the right type of first-letter frame
const nsStyleDisplay* display = sc->StyleDisplay();
nsFirstLetterFrame* letterFrame;
if (display->IsFloatingStyle() &&
!SVGUtils::IsInSVGTextSubtree(aParentFrame)) {
if (display->IsFloatingStyle() && !aParentFrame->IsInSVGTextSubtree()) {
// Make a floating first-letter frame
letterFrame = CreateFloatingLetterFrame(state, aTextContent, textFrame,
aParentFrame, parentComputedStyle,

View File

@ -1714,7 +1714,7 @@ nsPoint GetEventCoordinatesRelativeTo(nsIWidget* aWidget,
/* If we encountered a transform, we can't do simple arithmetic to figure
* out how to convert back to aFrame's coordinates and must use the CTM.
*/
if (transformFound || SVGUtils::IsInSVGTextSubtree(frame)) {
if (transformFound || frame->IsInSVGTextSubtree()) {
return nsLayoutUtils::TransformRootPointToFrame(ViewportType::Visual,
aFrame, widgetToView);
}
@ -2254,7 +2254,7 @@ bool nsLayoutUtils::AuthorSpecifiedBorderBackgroundDisablesTheming(
}
static SVGTextFrame* GetContainingSVGTextFrame(const nsIFrame* aFrame) {
if (!SVGUtils::IsInSVGTextSubtree(aFrame)) {
if (!aFrame->IsInSVGTextSubtree()) {
return nullptr;
}
@ -8050,7 +8050,7 @@ nscoord nsLayoutUtils::InflationMinFontSizeFor(const nsIFrame* aFrame) {
}
float nsLayoutUtils::FontSizeInflationFor(const nsIFrame* aFrame) {
if (SVGUtils::IsInSVGTextSubtree(aFrame)) {
if (aFrame->IsInSVGTextSubtree()) {
const nsIFrame* container = aFrame;
while (!container->IsSVGTextFrame()) {
container = container->GetParent();

View File

@ -14,7 +14,6 @@
#include "LayoutLogging.h"
#include "mozilla/dom/HTMLInputElement.h"
#include "mozilla/StaticPrefs_layout.h"
#include "mozilla/SVGUtils.h"
#include "mozilla/WritingModes.h"
#include "nsBlockFrame.h"
#include "nsCSSAnonBoxes.h"
@ -2494,7 +2493,7 @@ void SizeComputationInput::InitOffsets(WritingMode aCBWM, nscoord aPercentBasis,
widgetPadding, presContext->AppUnitsPerDevPixel());
SetComputedLogicalPadding(wm, LogicalMargin(wm, padding));
needPaddingProp = false;
} else if (SVGUtils::IsInSVGTextSubtree(mFrame)) {
} else if (mFrame->IsInSVGTextSubtree()) {
SetComputedLogicalPadding(wm, LogicalMargin(wm));
needPaddingProp = false;
} else if (aPadding) { // padding is an input arg
@ -2548,7 +2547,7 @@ void SizeComputationInput::InitOffsets(WritingMode aCBWM, nscoord aPercentBasis,
border = LogicalMargin(
wm, LayoutDevicePixel::ToAppUnits(widgetBorder,
presContext->AppUnitsPerDevPixel()));
} else if (SVGUtils::IsInSVGTextSubtree(mFrame)) {
} else if (mFrame->IsInSVGTextSubtree()) {
// Do nothing since the border local variable is initialized all zero.
} else if (aBorder) { // border is an input arg
border = *aBorder;
@ -2835,7 +2834,7 @@ bool SizeComputationInput::ComputeMargin(WritingMode aCBWM,
nscoord aPercentBasis,
LayoutFrameType aFrameType) {
// SVG text frames have no margin.
if (SVGUtils::IsInSVGTextSubtree(mFrame)) {
if (mFrame->IsInSVGTextSubtree()) {
return false;
}

View File

@ -21,7 +21,6 @@
#include "mozilla/PresShell.h"
#include "mozilla/StaticPrefs_browser.h"
#include "mozilla/StaticPrefs_layout.h"
#include "mozilla/SVGUtils.h"
#include "mozilla/ToString.h"
#include "mozilla/UniquePtr.h"
@ -577,7 +576,7 @@ nsresult nsBlockFrame::GetFrameName(nsAString& aResult) const {
void nsBlockFrame::InvalidateFrame(uint32_t aDisplayItemKey,
bool aRebuildDisplayItems) {
if (SVGUtils::IsInSVGTextSubtree(this)) {
if (IsInSVGTextSubtree()) {
NS_ASSERTION(GetParent()->IsSVGTextFrame(),
"unexpected block frame in SVG text");
GetParent()->InvalidateFrame();
@ -589,7 +588,7 @@ void nsBlockFrame::InvalidateFrame(uint32_t aDisplayItemKey,
void nsBlockFrame::InvalidateFrameWithRect(const nsRect& aRect,
uint32_t aDisplayItemKey,
bool aRebuildDisplayItems) {
if (SVGUtils::IsInSVGTextSubtree(this)) {
if (IsInSVGTextSubtree()) {
NS_ASSERTION(GetParent()->IsSVGTextFrame(),
"unexpected block frame in SVG text");
GetParent()->InvalidateFrame();
@ -2359,8 +2358,7 @@ static inline bool IsAlignedLeft(StyleTextAlign aAlignment,
StyleDirection aDirection,
StyleUnicodeBidi aUnicodeBidi,
nsIFrame* aFrame) {
return SVGUtils::IsInSVGTextSubtree(aFrame) ||
StyleTextAlign::Left == aAlignment ||
return aFrame->IsInSVGTextSubtree() || StyleTextAlign::Left == aAlignment ||
(((StyleTextAlign::Start == aAlignment &&
StyleDirection::Ltr == aDirection) ||
(StyleTextAlign::End == aAlignment &&
@ -5172,7 +5170,7 @@ bool nsBlockFrame::PlaceLine(BlockReflowState& aState,
* In other words, isLastLine really means isLastLineAndWeCare.
*/
const bool isLastLine =
!SVGUtils::IsInSVGTextSubtree(this) &&
!IsInSVGTextSubtree() &&
styleText->TextAlignForLastLine() != styleText->mTextAlign &&
(aLineLayout.GetLineEndsInBR() || IsLastLine(aState, aLine));
@ -5764,7 +5762,7 @@ void nsBlockFrame::AppendFrames(ChildListID aListID, nsFrameList&& aFrameList) {
printf("\n");
#endif
if (SVGUtils::IsInSVGTextSubtree(this)) {
if (IsInSVGTextSubtree()) {
MOZ_ASSERT(GetParent()->IsSVGTextFrame(),
"unexpected block frame in SVG text");
// Workaround for bug 1399425 in case this bit has been removed from the

View File

@ -543,7 +543,7 @@ static bool IsFontSizeInflationContainer(nsIFrame* aFrame,
}
static void MaybeScheduleReflowSVGNonDisplayText(nsIFrame* aFrame) {
if (!SVGUtils::IsInSVGTextSubtree(aFrame)) {
if (!aFrame->IsInSVGTextSubtree()) {
return;
}
@ -1570,7 +1570,7 @@ void nsIFrame::CreateView() {
nsMargin nsIFrame::GetUsedMargin() const {
nsMargin margin(0, 0, 0, 0);
if (((mState & NS_FRAME_FIRST_REFLOW) && !(mState & NS_FRAME_IN_REFLOW)) ||
SVGUtils::IsInSVGTextSubtree(this))
IsInSVGTextSubtree())
return margin;
nsMargin* m = GetProperty(UsedMarginProperty());
@ -1591,7 +1591,7 @@ nsMargin nsIFrame::GetUsedMargin() const {
nsMargin nsIFrame::GetUsedBorder() const {
nsMargin border(0, 0, 0, 0);
if (((mState & NS_FRAME_FIRST_REFLOW) && !(mState & NS_FRAME_IN_REFLOW)) ||
SVGUtils::IsInSVGTextSubtree(this))
IsInSVGTextSubtree())
return border;
// Theme methods don't use const-ness.
@ -1620,7 +1620,7 @@ nsMargin nsIFrame::GetUsedBorder() const {
nsMargin nsIFrame::GetUsedPadding() const {
nsMargin padding(0, 0, 0, 0);
if (((mState & NS_FRAME_FIRST_REFLOW) && !(mState & NS_FRAME_IN_REFLOW)) ||
SVGUtils::IsInSVGTextSubtree(this))
IsInSVGTextSubtree())
return padding;
// Theme methods don't use const-ness.
@ -5637,7 +5637,7 @@ static FrameTarget GetSelectionClosestFrame(nsIFrame* aFrame,
kid->FindCloserFrameForSelection(aPoint, &closest);
}
if (closest.mFrame) {
if (SVGUtils::IsInSVGTextSubtree(closest.mFrame))
if (closest.mFrame->IsInSVGTextSubtree())
return FrameTarget{closest.mFrame, false, false};
return GetSelectionClosestFrameForChild(closest.mFrame, aPoint, aFlags);
}
@ -5754,7 +5754,7 @@ nsIFrame::ContentOffsets nsIFrame::GetContentOffsetsFromPoint(
nsPoint pt;
if (closest.frame != this) {
if (SVGUtils::IsInSVGTextSubtree(closest.frame)) {
if (closest.frame->IsInSVGTextSubtree()) {
pt = nsLayoutUtils::TransformAncestorPointToFrame(
RelativeTo{closest.frame}, aPoint, RelativeTo{this});
} else {
@ -10622,7 +10622,7 @@ static StyleVerticalAlignKeyword ConvertSVGDominantBaselineToVerticalAlign(
}
Maybe<StyleVerticalAlignKeyword> nsIFrame::VerticalAlignEnum() const {
if (SVGUtils::IsInSVGTextSubtree(this)) {
if (IsInSVGTextSubtree()) {
StyleDominantBaseline dominantBaseline = StyleSVG()->mDominantBaseline;
return Some(ConvertSVGDominantBaselineToVerticalAlign(dominantBaseline));
}

View File

@ -4513,6 +4513,13 @@ class nsIFrame : public nsQueryFrame {
return HasAnyStateBits(NS_FRAME_IS_DIRTY | NS_FRAME_HAS_DIRTY_CHILDREN);
}
/**
* Returns true if the frame is an SVGTextFrame or one of its descendants.
*/
bool IsInSVGTextSubtree() const {
return HasAnyStateBits(NS_FRAME_IS_SVG_TEXT);
}
/**
* Return whether this frame keeps track of overflow areas. (Frames for
* non-display SVG elements -- e.g. <clipPath> -- do not maintain overflow

View File

@ -15,7 +15,6 @@
#include "mozilla/RestyleManager.h"
#include "mozilla/ServoStyleSet.h"
#include "mozilla/SVGTextFrame.h"
#include "mozilla/SVGUtils.h"
#include "nsLineLayout.h"
#include "nsBlockFrame.h"
#include "nsLayoutUtils.h"
@ -56,7 +55,7 @@ nsresult nsInlineFrame::GetFrameName(nsAString& aResult) const {
void nsInlineFrame::InvalidateFrame(uint32_t aDisplayItemKey,
bool aRebuildDisplayItems) {
if (SVGUtils::IsInSVGTextSubtree(this)) {
if (IsInSVGTextSubtree()) {
nsIFrame* svgTextFrame = nsLayoutUtils::GetClosestFrameOfType(
GetParent(), LayoutFrameType::SVGText);
svgTextFrame->InvalidateFrame();
@ -68,7 +67,7 @@ void nsInlineFrame::InvalidateFrame(uint32_t aDisplayItemKey,
void nsInlineFrame::InvalidateFrameWithRect(const nsRect& aRect,
uint32_t aDisplayItemKey,
bool aRebuildDisplayItems) {
if (SVGUtils::IsInSVGTextSubtree(this)) {
if (IsInSVGTextSubtree()) {
nsIFrame* svgTextFrame = nsLayoutUtils::GetClosestFrameOfType(
GetParent(), LayoutFrameType::SVGText);
svgTextFrame->InvalidateFrame();
@ -373,7 +372,7 @@ nsresult nsInlineFrame::AttributeChanged(int32_t aNameSpaceID,
return rv;
}
if (SVGUtils::IsInSVGTextSubtree(this)) {
if (IsInSVGTextSubtree()) {
SVGTextFrame* f = static_cast<SVGTextFrame*>(
nsLayoutUtils::GetClosestFrameOfType(this, LayoutFrameType::SVGText));
f->HandleAttributeChangeInDescendant(mContent->AsElement(), aNameSpaceID,

View File

@ -10,7 +10,6 @@
#include "mozilla/ComputedStyle.h"
#include "mozilla/SVGTextFrame.h"
#include "mozilla/SVGUtils.h"
#include "LayoutLogging.h"
#include "nsBlockFrame.h"
@ -79,7 +78,7 @@ nsLineLayout::nsLineLayout(nsPresContext* aPresContext,
mDirtyNextLine(false),
mLineAtStart(false),
mHasRuby(false),
mSuppressLineWrap(SVGUtils::IsInSVGTextSubtree(LineContainerFrame()))
mSuppressLineWrap(LineContainerFrame()->IsInSVGTextSubtree())
#ifdef DEBUG
,
mSpansAllocated(0),
@ -1702,7 +1701,7 @@ void nsLineLayout::AdjustLeadings(nsIFrame* spanFrame, PerSpanData* psd,
static float GetInflationForBlockDirAlignment(nsIFrame* aFrame,
nscoord aInflationMinFontSize) {
if (SVGUtils::IsInSVGTextSubtree(aFrame)) {
if (aFrame->IsInSVGTextSubtree()) {
const nsIFrame* container =
nsLayoutUtils::GetClosestFrameOfType(aFrame, LayoutFrameType::SVGText);
NS_ASSERTION(container, "expected to find an ancestor SVGTextFrame");
@ -3050,7 +3049,7 @@ void nsLineLayout::TextAlignLine(nsLineBox* aLine, bool aIsLastLine) {
StyleTextAlign textAlign =
aIsLastLine ? mStyleText->TextAlignForLastLine() : mStyleText->mTextAlign;
bool isSVG = SVGUtils::IsInSVGTextSubtree(LineContainerFrame());
bool isSVG = LineContainerFrame()->IsInSVGTextSubtree();
bool doTextAlign = remainingISize > 0;
int32_t additionalGaps = 0;

View File

@ -21,7 +21,6 @@
#include "mozilla/StaticPrefs_layout.h"
#include "mozilla/StaticPresData.h"
#include "mozilla/SVGTextFrame.h"
#include "mozilla/SVGUtils.h"
#include "mozilla/TextEditor.h"
#include "mozilla/TextEvents.h"
#include "mozilla/BinarySearch.h"
@ -608,8 +607,7 @@ static void InvalidateFrameDueToGlyphsChanged(nsIFrame* aFrame) {
// to reflow the SVGTextFrame. (This is similar to reflowing the
// SVGTextFrame in response to style changes, in
// SVGTextFrame::DidSetComputedStyle.)
if (SVGUtils::IsInSVGTextSubtree(f) &&
f->HasAnyStateBits(NS_FRAME_IS_NONDISPLAY)) {
if (f->IsInSVGTextSubtree() && f->HasAnyStateBits(NS_FRAME_IS_NONDISPLAY)) {
auto* svgTextFrame = static_cast<SVGTextFrame*>(
nsLayoutUtils::GetClosestFrameOfType(f, LayoutFrameType::SVGText));
svgTextFrame->ScheduleReflowSVGNonDisplayText(IntrinsicDirty::None);
@ -1405,7 +1403,7 @@ static void BuildTextRuns(DrawTarget* aDrawTarget, nsTextFrame* aForFrame,
}
nsPresContext* presContext = aLineContainer->PresContext();
bool doLineBreaking = !SVGUtils::IsInSVGTextSubtree(aForFrame);
bool doLineBreaking = !aForFrame->IsInSVGTextSubtree();
BuildTextRunsScanner scanner(presContext, aDrawTarget, aLineContainer,
aWhichTextRun, doLineBreaking);
@ -1748,7 +1746,7 @@ static gfxFloat GetMinTabAdvanceAppUnits(const gfxTextRun* aTextRun) {
}
static float GetSVGFontSizeScaleFactor(nsIFrame* aFrame) {
if (!SVGUtils::IsInSVGTextSubtree(aFrame)) {
if (!aFrame->IsInSVGTextSubtree()) {
return 1.0f;
}
auto* container =
@ -1758,7 +1756,7 @@ static float GetSVGFontSizeScaleFactor(nsIFrame* aFrame) {
}
static nscoord LetterSpacing(nsIFrame* aFrame, const nsStyleText& aStyleText) {
if (SVGUtils::IsInSVGTextSubtree(aFrame)) {
if (aFrame->IsInSVGTextSubtree()) {
// SVG text can have a scaling factor applied so that very small or very
// large font-sizes don't suffer from poor glyph placement due to app unit
// rounding. The used letter-spacing value must be scaled by the same
@ -1774,7 +1772,7 @@ static nscoord LetterSpacing(nsIFrame* aFrame, const nsStyleText& aStyleText) {
// This function converts non-coord values (e.g. percentages) to nscoord.
static nscoord WordSpacing(nsIFrame* aFrame, const gfxTextRun* aTextRun,
const nsStyleText& aStyleText) {
if (SVGUtils::IsInSVGTextSubtree(aFrame)) {
if (aFrame->IsInSVGTextSubtree()) {
// SVG text can have a scaling factor applied so that very small or very
// large font-sizes don't suffer from poor glyph placement due to app unit
// rounding. The used word-spacing value must be scaled by the same
@ -1913,7 +1911,7 @@ bool BuildTextRunsScanner::ContinueTextRunAcrossFrames(nsTextFrame* aFrame1,
// as there are too many things SVG might be doing (like applying per-
// element positioning) that wouldn't make sense with shaping across
// the boundary.
if (SVGUtils::IsInSVGTextSubtree(ancestor)) {
if (ancestor->IsInSVGTextSubtree()) {
return false;
}
@ -2200,7 +2198,7 @@ already_AddRefed<gfxTextRun> BuildTextRunsScanner::BuildTextRunForFrames(
uint32_t nextBreakIndex = 0;
nsTextFrame* nextBreakBeforeFrame = GetNextBreakBeforeFrame(&nextBreakIndex);
bool isSVG = SVGUtils::IsInSVGTextSubtree(mLineContainer);
bool isSVG = mLineContainer->IsInSVGTextSubtree();
bool enabledJustification =
(mLineContainer->StyleText()->mTextAlign == StyleTextAlign::Justify ||
mLineContainer->StyleText()->mTextAlignLast ==
@ -4235,7 +4233,7 @@ void nsTextFrame::InvalidateFrame(uint32_t aDisplayItemKey,
bool aRebuildDisplayItems) {
InvalidateSelectionState();
if (SVGUtils::IsInSVGTextSubtree(this)) {
if (IsInSVGTextSubtree()) {
nsIFrame* svgTextFrame = nsLayoutUtils::GetClosestFrameOfType(
GetParent(), LayoutFrameType::SVGText);
svgTextFrame->InvalidateFrame();
@ -4249,7 +4247,7 @@ void nsTextFrame::InvalidateFrameWithRect(const nsRect& aRect,
bool aRebuildDisplayItems) {
InvalidateSelectionState();
if (SVGUtils::IsInSVGTextSubtree(this)) {
if (IsInSVGTextSubtree()) {
nsIFrame* svgTextFrame = nsLayoutUtils::GetClosestFrameOfType(
GetParent(), LayoutFrameType::SVGText);
svgTextFrame->InvalidateFrame();
@ -4488,7 +4486,7 @@ void nsTextFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
NS_GET_A(st->mWebkitTextStrokeColor.CalcColor(this)) == 0;
if ((HasAnyStateBits(TEXT_NO_RENDERED_GLYPHS) ||
(isTextTransparent && !StyleText()->HasTextShadow())) &&
aBuilder->IsForPainting() && !SVGUtils::IsInSVGTextSubtree(this)) {
aBuilder->IsForPainting() && !IsInSVGTextSubtree()) {
if (!IsSelected()) {
TextDecorations textDecs;
GetTextDecorations(PresContext(), eResolvedColors, textDecs);
@ -4680,7 +4678,7 @@ void nsTextFrame::GetTextDecorations(
nscolor color;
if (useOverride) {
color = overrideColor;
} else if (SVGUtils::IsInSVGTextSubtree(this)) {
} else if (IsInSVGTextSubtree()) {
// XXX We might want to do something with text-decoration-color when
// painting SVG text, but it's not clear what we should do. We
// at least need SVG text decorations to paint with 'fill' if
@ -4760,7 +4758,7 @@ void nsTextFrame::GetTextDecorations(
static float GetInflationForTextDecorations(nsIFrame* aFrame,
nscoord aInflationMinFontSize) {
if (SVGUtils::IsInSVGTextSubtree(aFrame)) {
if (aFrame->IsInSVGTextSubtree()) {
auto* container =
nsLayoutUtils::GetClosestFrameOfType(aFrame, LayoutFrameType::SVGText);
MOZ_ASSERT(container);
@ -6192,7 +6190,7 @@ nscolor nsTextFrame::GetCaretColorAt(int32_t aOffset) {
}
bool isSolidTextColor = true;
if (SVGUtils::IsInSVGTextSubtree(this)) {
if (IsInSVGTextSubtree()) {
const nsStyleSVG* style = StyleSVG();
if (!style->mFill.kind.IsNone() && !style->mFill.kind.IsColor()) {
isSolidTextColor = false;
@ -6383,7 +6381,7 @@ void nsTextFrame::PaintText(const PaintTextParams& aParams,
const bool aIsSelected,
float aOpacity /* = 1.0f */) {
#ifdef DEBUG
if (SVGUtils::IsInSVGTextSubtree(this)) {
if (IsInSVGTextSubtree()) {
auto* container =
nsLayoutUtils::GetClosestFrameOfType(this, LayoutFrameType::SVGText);
MOZ_ASSERT(container);
@ -9473,7 +9471,7 @@ void nsTextFrame::ReflowText(nsLineLayout& aLineLayout, nscoord aAvailableWidth,
lineContainer->StyleText()->mTextAlignLast ==
StyleTextAlignLast::Justify ||
shouldSuppressLineBreak) &&
!SVGUtils::IsInSVGTextSubtree(lineContainer)) {
!lineContainer->IsInSVGTextSubtree()) {
AddStateBits(TEXT_JUSTIFICATION_ENABLED);
Range range(uint32_t(offset), uint32_t(offset + charsFit));
aLineLayout.SetJustificationInfo(provider.ComputeJustification(range));

View File

@ -88,7 +88,7 @@ bool nsTextPaintStyle::EnsureSufficientContrast(nscolor* aForeColor,
}
nscolor nsTextPaintStyle::GetTextColor() {
if (SVGUtils::IsInSVGTextSubtree(mFrame)) {
if (mFrame->IsInSVGTextSubtree()) {
if (!mResolveColors) {
return NS_SAME_AS_FOREGROUND_COLOR;
}
@ -559,14 +559,14 @@ nscolor nsTextPaintStyle::GetResolvedForeColor(nscolor aColor,
}
nscolor nsTextPaintStyle::GetWebkitTextStrokeColor() {
if (mozilla::SVGUtils::IsInSVGTextSubtree(mFrame)) {
if (mFrame->IsInSVGTextSubtree()) {
return 0;
}
return mFrame->StyleText()->mWebkitTextStrokeColor.CalcColor(mFrame);
}
float nsTextPaintStyle::GetWebkitTextStrokeWidth() {
if (mozilla::SVGUtils::IsInSVGTextSubtree(mFrame)) {
if (mFrame->IsInSVGTextSubtree()) {
return 0.0f;
}
nscoord coord = mFrame->StyleText()->mWebkitTextStrokeWidth;

View File

@ -88,7 +88,7 @@ bool ComputedStyle::IsFixedPosContainingBlock(
const nsIFrame* aContextFrame) const {
// NOTE: Any CSS properties that influence the output of this function
// should also handle will-change appropriately.
if (mozilla::SVGUtils::IsInSVGTextSubtree(aContextFrame)) {
if (aContextFrame->IsInSVGTextSubtree()) {
return false;
}
if (IsFixedPosContainingBlockForNonSVGTextFrames()) {
@ -114,7 +114,7 @@ bool ComputedStyle::IsAbsPosContainingBlock(
// NOTE: Any CSS properties that influence the output of this function
// should also handle will-change appropriately.
return StyleDisplay()->IsPositionedStyle() &&
!mozilla::SVGUtils::IsInSVGTextSubtree(aContextFrame);
!aContextFrame->IsInSVGTextSubtree();
}
} // namespace mozilla

View File

@ -10,7 +10,6 @@
#include "gfxUserFontSet.h"
#include "mozilla/PresShell.h"
#include "mozilla/RestyleManager.h"
#include "mozilla/SVGUtils.h"
#include "nsFontMetrics.h"
#include "nsIFrame.h"
#include "nsLayoutUtils.h"
@ -125,7 +124,7 @@ static FontUsageKind FrameFontUsage(nsIFrame* aFrame,
// TODO(emilio): Can we use the restyle-hint machinery instead of this?
static void ScheduleReflow(PresShell* aPresShell, nsIFrame* aFrame) {
nsIFrame* f = aFrame;
if (f->IsFrameOfType(nsIFrame::eSVG) || SVGUtils::IsInSVGTextSubtree(f)) {
if (f->IsFrameOfType(nsIFrame::eSVG) || f->IsInSVGTextSubtree()) {
// SVG frames (and the non-SVG descendants of an SVGTextFrame) need special
// reflow handling. We need to search upwards for the first displayed
// SVGOuterSVGFrame or non-SVG frame, which is the frame we can call
@ -142,7 +141,7 @@ static void ScheduleReflow(PresShell* aPresShell, nsIFrame* aFrame) {
return;
}
if (!f->HasAnyStateBits(NS_FRAME_SVG_LAYOUT) ||
!SVGUtils::IsInSVGTextSubtree(f)) {
!f->IsInSVGTextSubtree()) {
break;
}
f->AddStateBits(NS_FRAME_HAS_DIRTY_CHILDREN);

View File

@ -14,9 +14,8 @@
#include "nsIFrame.h"
#include "nsStyleStruct.h"
#include "nsIContent.h" // for GetParent()
#include "nsTextFrame.h" // for nsTextFrame::ShouldSuppressLineBreak
#include "mozilla/SVGUtils.h" // for SVGUtils::IsInSVGTextSubtree
#include "nsIContent.h" // for GetParent()
#include "nsTextFrame.h" // for nsTextFrame::ShouldSuppressLineBreak
bool nsStyleText::NewlineIsSignificant(const nsTextFrame* aContextFrame) const {
NS_ASSERTION(aContextFrame->StyleText() == this, "unexpected aContextFrame");
@ -27,21 +26,19 @@ bool nsStyleText::NewlineIsSignificant(const nsTextFrame* aContextFrame) const {
bool nsStyleText::WhiteSpaceCanWrap(const nsIFrame* aContextFrame) const {
NS_ASSERTION(aContextFrame->StyleText() == this, "unexpected aContextFrame");
return WhiteSpaceCanWrapStyle() &&
!mozilla::SVGUtils::IsInSVGTextSubtree(aContextFrame) &&
return WhiteSpaceCanWrapStyle() && !aContextFrame->IsInSVGTextSubtree() &&
!aContextFrame->Style()->IsTextCombined();
}
bool nsStyleText::WordCanWrap(const nsIFrame* aContextFrame) const {
NS_ASSERTION(aContextFrame->StyleText() == this, "unexpected aContextFrame");
return WordCanWrapStyle() &&
!mozilla::SVGUtils::IsInSVGTextSubtree(aContextFrame);
return WordCanWrapStyle() && !aContextFrame->IsInSVGTextSubtree();
}
bool nsStyleDisplay::IsBlockOutside(const nsIFrame* aContextFrame) const {
NS_ASSERTION(aContextFrame->StyleDisplay() == this,
"unexpected aContextFrame");
if (mozilla::SVGUtils::IsInSVGTextSubtree(aContextFrame)) {
if (aContextFrame->IsInSVGTextSubtree()) {
return aContextFrame->IsBlockFrame();
}
return IsBlockOutsideStyle();
@ -50,7 +47,7 @@ bool nsStyleDisplay::IsBlockOutside(const nsIFrame* aContextFrame) const {
bool nsStyleDisplay::IsInlineOutside(const nsIFrame* aContextFrame) const {
NS_ASSERTION(aContextFrame->StyleDisplay() == this,
"unexpected aContextFrame");
if (mozilla::SVGUtils::IsInSVGTextSubtree(aContextFrame)) {
if (aContextFrame->IsInSVGTextSubtree()) {
return !aContextFrame->IsBlockFrame();
}
return IsInlineOutsideStyle();
@ -60,7 +57,7 @@ mozilla::StyleDisplay nsStyleDisplay::GetDisplay(
const nsIFrame* aContextFrame) const {
NS_ASSERTION(aContextFrame->StyleDisplay() == this,
"unexpected aContextFrame");
if (mozilla::SVGUtils::IsInSVGTextSubtree(aContextFrame) &&
if (aContextFrame->IsInSVGTextSubtree() &&
mDisplay != mozilla::StyleDisplay::None) {
return aContextFrame->IsBlockFrame() ? mozilla::StyleDisplay::Block
: mozilla::StyleDisplay::Inline;
@ -71,8 +68,7 @@ mozilla::StyleDisplay nsStyleDisplay::GetDisplay(
bool nsStyleDisplay::IsFloating(const nsIFrame* aContextFrame) const {
NS_ASSERTION(aContextFrame->StyleDisplay() == this,
"unexpected aContextFrame");
return IsFloatingStyle() &&
!mozilla::SVGUtils::IsInSVGTextSubtree(aContextFrame);
return IsFloatingStyle() && !aContextFrame->IsInSVGTextSubtree();
}
// If you change this function, also change the corresponding block in
@ -110,30 +106,27 @@ bool nsStyleDisplay::IsRelativelyOrStickyPositioned(
NS_ASSERTION(aContextFrame->StyleDisplay() == this,
"unexpected aContextFrame");
return IsRelativelyOrStickyPositionedStyle() &&
!mozilla::SVGUtils::IsInSVGTextSubtree(aContextFrame);
!aContextFrame->IsInSVGTextSubtree();
}
bool nsStyleDisplay::IsRelativelyPositioned(
const nsIFrame* aContextFrame) const {
NS_ASSERTION(aContextFrame->StyleDisplay() == this,
"unexpected aContextFrame");
return IsRelativelyPositionedStyle() &&
!mozilla::SVGUtils::IsInSVGTextSubtree(aContextFrame);
return IsRelativelyPositionedStyle() && !aContextFrame->IsInSVGTextSubtree();
}
bool nsStyleDisplay::IsStickyPositioned(const nsIFrame* aContextFrame) const {
NS_ASSERTION(aContextFrame->StyleDisplay() == this,
"unexpected aContextFrame");
return IsStickyPositionedStyle() &&
!mozilla::SVGUtils::IsInSVGTextSubtree(aContextFrame);
return IsStickyPositionedStyle() && !aContextFrame->IsInSVGTextSubtree();
}
bool nsStyleDisplay::IsAbsolutelyPositioned(
const nsIFrame* aContextFrame) const {
NS_ASSERTION(aContextFrame->StyleDisplay() == this,
"unexpected aContextFrame");
return IsAbsolutelyPositionedStyle() &&
!mozilla::SVGUtils::IsInSVGTextSubtree(aContextFrame);
return IsAbsolutelyPositionedStyle() && !aContextFrame->IsInSVGTextSubtree();
}
bool nsStyleBackground::HasLocalBackground() const {

View File

@ -494,9 +494,9 @@ void SVGTextPathObserver::OnRenderingChange() {
return;
}
MOZ_ASSERT(frame->IsFrameOfType(nsIFrame::eSVG) ||
SVGUtils::IsInSVGTextSubtree(frame),
"SVG frame expected");
MOZ_ASSERT(
frame->IsFrameOfType(nsIFrame::eSVG) || frame->IsInSVGTextSubtree(),
"SVG frame expected");
MOZ_ASSERT(frame->GetContent()->IsSVGElement(nsGkAtoms::textPath),
"expected frame for a <textPath> element");

View File

@ -105,7 +105,7 @@ bool SVGAutoRenderState::IsPaintingToWindow(DrawTarget* aDrawTarget) {
// GetCanvasTM().
static bool FrameDoesNotIncludePositionInTM(const nsIFrame* aFrame) {
return aFrame->IsSVGGeometryFrame() || aFrame->IsSVGImageFrame() ||
SVGUtils::IsInSVGTextSubtree(aFrame);
aFrame->IsInSVGTextSubtree();
}
nsRect SVGUtils::GetPostFilterInkOverflowRect(nsIFrame* aFrame,
@ -394,9 +394,9 @@ void SVGUtils::NotifyChildrenOfSVGChange(nsIFrame* aFrame, uint32_t aFlags) {
if (SVGFrame) {
SVGFrame->NotifySVGChanged(aFlags);
} else {
NS_ASSERTION(kid->IsFrameOfType(nsIFrame::eSVG) ||
SVGUtils::IsInSVGTextSubtree(kid),
"SVG frame expected");
NS_ASSERTION(
kid->IsFrameOfType(nsIFrame::eSVG) || kid->IsInSVGTextSubtree(),
"SVG frame expected");
// recurse into the children of container frames e.g. <clipPath>, <mask>
// in case they have child frames with transformation matrices
if (kid->IsFrameOfType(nsIFrame::eSVG)) {
@ -985,7 +985,7 @@ gfxRect SVGUtils::GetBBox(nsIFrame* aFrame, uint32_t aFlags,
aFrame = aFrame->GetParent();
}
if (SVGUtils::IsInSVGTextSubtree(aFrame)) {
if (aFrame->IsInSVGTextSubtree()) {
// It is possible to apply a gradient, pattern, clipping path, mask or
// filter to text. When one of these facilities is applied to text
// the bounding box is the entire text element in all cases.
@ -1263,7 +1263,7 @@ static gfxRect PathExtentsToMaxStrokeExtents(const gfxRect& aPathExtents,
gfxRect SVGUtils::PathExtentsToMaxStrokeExtents(const gfxRect& aPathExtents,
const nsTextFrame* aFrame,
const gfxMatrix& aMatrix) {
NS_ASSERTION(SVGUtils::IsInSVGTextSubtree(aFrame),
NS_ASSERTION(aFrame->IsInSVGTextSubtree(),
"expected an nsTextFrame for SVG text");
return mozilla::PathExtentsToMaxStrokeExtents(aPathExtents, aFrame, 0.5,
aMatrix);

View File

@ -588,11 +588,6 @@ class SVGUtils final {
*/
static gfxMatrix GetCSSPxToDevPxMatrix(const nsIFrame* aNonSVGFrame);
static bool IsInSVGTextSubtree(const nsIFrame* aFrame) {
// Returns true if the frame is an SVGTextFrame or one of its descendants.
return aFrame->HasAnyStateBits(NS_FRAME_IS_SVG_TEXT);
}
/**
* It is a replacement of
* SVGElement::PrependLocalTransformsTo(eUserSpaceToParent).