Bug 1647101 - Move SVGTextFrame SVGViewFrame SVGFEContainerFrame SVGFEImageFrame SVGFELeafFrame SVGFEUnstyledLeafFrame into the mozilla namespace r=dholbert

Differential Revision: https://phabricator.services.mozilla.com/D80383
This commit is contained in:
longsonr 2020-06-23 22:59:34 +00:00
Родитель 366e3067b4
Коммит 0a29054e26
19 изменённых файлов: 186 добавлений и 122 удалений

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

@ -10,19 +10,19 @@
#include "SVGFilters.h" #include "SVGFilters.h"
#include "SVGAnimatedPreserveAspectRatio.h" #include "SVGAnimatedPreserveAspectRatio.h"
class SVGFEImageFrame;
nsresult NS_NewSVGFEImageElement( nsresult NS_NewSVGFEImageElement(
nsIContent** aResult, already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo); nsIContent** aResult, already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
namespace mozilla { namespace mozilla {
class SVGFEImageFrame;
namespace dom { namespace dom {
typedef SVGFE SVGFEImageElementBase; typedef SVGFE SVGFEImageElementBase;
class SVGFEImageElement final : public SVGFEImageElementBase, class SVGFEImageElement final : public SVGFEImageElementBase,
public nsImageLoadingContent { public nsImageLoadingContent {
friend class ::SVGFEImageFrame; friend class mozilla::SVGFEImageFrame;
protected: protected:
friend nsresult(::NS_NewSVGFEImageElement( friend nsresult(::NS_NewSVGFEImageElement(

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

@ -12,10 +12,10 @@
#include "SVGAnimatedEnumeration.h" #include "SVGAnimatedEnumeration.h"
#include "SVGAnimatedLength.h" #include "SVGAnimatedLength.h"
class SVGTextFrame;
namespace mozilla { namespace mozilla {
class SVGTextFrame;
namespace dom { namespace dom {
struct DOMPointInit; struct DOMPointInit;
@ -25,7 +25,7 @@ class SVGRect;
typedef SVGGraphicsElement SVGTextContentElementBase; typedef SVGGraphicsElement SVGTextContentElementBase;
class SVGTextContentElement : public SVGTextContentElementBase { class SVGTextContentElement : public SVGTextContentElementBase {
friend class ::SVGTextFrame; friend class mozilla::SVGTextFrame;
public: public:
using FragmentOrElement::TextLength; using FragmentOrElement::TextLength;

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

@ -29,7 +29,7 @@ static const uint16_t TEXTPATH_SIDETYPE_RIGHT = 2;
typedef SVGTextContentElement SVGTextPathElementBase; typedef SVGTextContentElement SVGTextPathElementBase;
class SVGTextPathElement final : public SVGTextPathElementBase { class SVGTextPathElement final : public SVGTextPathElementBase {
friend class ::SVGTextFrame; friend class mozilla::SVGTextFrame;
protected: protected:
friend nsresult(::NS_NewSVGTextPathElement( friend nsresult(::NS_NewSVGTextPathElement(

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

@ -11,11 +11,11 @@
#include "mozilla/DebugOnly.h" #include "mozilla/DebugOnly.h"
#include "mozilla/EffectCompositor.h" #include "mozilla/EffectCompositor.h"
#include "mozilla/StaticPrefs_gfx.h" #include "mozilla/StaticPrefs_gfx.h"
#include "mozilla/SVGGeometryFrame.h"
#include "mozilla/UniquePtr.h" #include "mozilla/UniquePtr.h"
#include "mozilla/gfx/2D.h" #include "mozilla/gfx/2D.h"
#include "mozilla/gfx/Logging.h" #include "mozilla/gfx/Logging.h"
#include "mozilla/gfx/Types.h" #include "mozilla/gfx/Types.h"
#include "mozilla/layout/SVGGeometryFrame.h"
#include "mozilla/layers/AnimationHelper.h" #include "mozilla/layers/AnimationHelper.h"
#include "mozilla/layers/ClipManager.h" #include "mozilla/layers/ClipManager.h"
#include "mozilla/layers/ImageClient.h" #include "mozilla/layers/ImageClient.h"
@ -1113,7 +1113,7 @@ static bool IsItemProbablyActive(
return true; return true;
} }
case DisplayItemType::TYPE_SVG_GEOMETRY: { case DisplayItemType::TYPE_SVG_GEOMETRY: {
auto* svgItem = static_cast<nsDisplaySVGGeometry*>(aItem); auto* svgItem = static_cast<DisplaySVGGeometry*>(aItem);
return svgItem->ShouldBeActive(aBuilder, aResources, aSc, aManager, return svgItem->ShouldBeActive(aBuilder, aResources, aSc, aManager,
aDisplayListBuilder); aDisplayListBuilder);
} }

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

@ -33,6 +33,7 @@
#include "mozilla/StaticPrefs_image.h" #include "mozilla/StaticPrefs_image.h"
#include "mozilla/StaticPrefs_layers.h" #include "mozilla/StaticPrefs_layers.h"
#include "mozilla/StaticPrefs_layout.h" #include "mozilla/StaticPrefs_layout.h"
#include "mozilla/SVGTextFrame.h"
#include "mozilla/Unused.h" #include "mozilla/Unused.h"
#include "mozilla/ViewportFrame.h" #include "mozilla/ViewportFrame.h"
#include "mozilla/ViewportUtils.h" #include "mozilla/ViewportUtils.h"
@ -108,7 +109,6 @@
#include "nsSVGIntegrationUtils.h" #include "nsSVGIntegrationUtils.h"
#include "nsSVGUtils.h" #include "nsSVGUtils.h"
#include "SVGImageContext.h" #include "SVGImageContext.h"
#include "SVGTextFrame.h"
#include "nsStyleStructInlines.h" #include "nsStyleStructInlines.h"
#include "nsStyleTransformMatrix.h" #include "nsStyleTransformMatrix.h"
#include "nsIFrameInlines.h" #include "nsIFrameInlines.h"
@ -860,21 +860,22 @@ static nsRect GetDisplayPortFromMarginsData(
posAlignment = ScreenSize(1, 1); posAlignment = ScreenSize(1, 1);
sizeAlignment = ScreenSize(1, 1); sizeAlignment = ScreenSize(1, 1);
} else if (useWebRender) { } else if (useWebRender) {
// With WebRender we benefit from updating the displaylist and scene less often. // With WebRender we benefit from updating the displaylist and scene less
// For this we need to move the displayport less often which we achieve by using // often. For this we need to move the displayport less often which we
// larger alignments for the displayport's position. // achieve by using larger alignments for the displayport's position.
float w = screenRect.width; float w = screenRect.width;
float h = screenRect.height; float h = screenRect.height;
// Scale the alignment so that we never move by more than a quarter of the total // Scale the alignment so that we never move by more than a quarter of the
// unaligned displayport size. At most (1.0) we move by a screenful of content. // total unaligned displayport size. At most (1.0) we move by a screenful of
// content.
float sx = fmin(1.0, (aMarginsData->mMargins.LeftRight() + w) / w * 0.25); float sx = fmin(1.0, (aMarginsData->mMargins.LeftRight() + w) / w * 0.25);
float sy = fmin(1.0, (aMarginsData->mMargins.TopBottom() + h) / h * 0.25); float sy = fmin(1.0, (aMarginsData->mMargins.TopBottom() + h) / h * 0.25);
posAlignment.width = fmax(128.0, 512.0 * round(sx * w / 512.0)); posAlignment.width = fmax(128.0, 512.0 * round(sx * w / 512.0));
posAlignment.height = fmax(128.0, 512.0 * round(sy * h / 512.0)); posAlignment.height = fmax(128.0, 512.0 * round(sy * h / 512.0));
// tscrollx is very sensitive to the size of the displayport. We could just accept // tscrollx is very sensitive to the size of the displayport. We could just
// the regression and change it to something larger if need be, however smaller // accept the regression and change it to something larger if need be,
// displayports also means less CPU work for most stages in webrender so we generally // however smaller displayports also means less CPU work for most stages in
// want to avoid very large displayports. // webrender so we generally want to avoid very large displayports.
sizeAlignment = ScreenSize(128, 128); sizeAlignment = ScreenSize(128, 128);
} else if (StaticPrefs::layers_enable_tiles_AtStartup()) { } else if (StaticPrefs::layers_enable_tiles_AtStartup()) {
// Don't align to tiles if they are too large, because we could expand // Don't align to tiles if they are too large, because we could expand
@ -963,8 +964,10 @@ static nsRect GetDisplayPortFromMarginsData(
screenRect += scrollPosScreen; screenRect += scrollPosScreen;
float x = posAlignment.width * floor(screenRect.x / posAlignment.width); float x = posAlignment.width * floor(screenRect.x / posAlignment.width);
float y = posAlignment.height * floor(screenRect.y / posAlignment.height); float y = posAlignment.height * floor(screenRect.y / posAlignment.height);
float w = sizeAlignment.width * ceil(screenRect.width / sizeAlignment.width + 1); float w =
float h = sizeAlignment.height * ceil(screenRect.height / sizeAlignment.height + 1); sizeAlignment.width * ceil(screenRect.width / sizeAlignment.width + 1);
float h =
sizeAlignment.height * ceil(screenRect.height / sizeAlignment.height + 1);
screenRect = ScreenRect(x, y, w, h); screenRect = ScreenRect(x, y, w, h);
screenRect -= scrollPosScreen; screenRect -= scrollPosScreen;

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

@ -21,6 +21,7 @@
#include "mozilla/StaticPrefs_layout.h" #include "mozilla/StaticPrefs_layout.h"
#include "mozilla/StaticPrefs_svg.h" #include "mozilla/StaticPrefs_svg.h"
#include "mozilla/StaticPresData.h" #include "mozilla/StaticPresData.h"
#include "mozilla/SVGTextFrame.h"
#include "mozilla/TextEditor.h" #include "mozilla/TextEditor.h"
#include "mozilla/TextEvents.h" #include "mozilla/TextEvents.h"
#include "mozilla/BinarySearch.h" #include "mozilla/BinarySearch.h"
@ -40,7 +41,6 @@
#include "nsStyleConsts.h" #include "nsStyleConsts.h"
#include "nsStyleStruct.h" #include "nsStyleStruct.h"
#include "nsStyleStructInlines.h" #include "nsStyleStructInlines.h"
#include "SVGTextFrame.h"
#include "nsCoord.h" #include "nsCoord.h"
#include "gfxContext.h" #include "gfxContext.h"
#include "nsTArray.h" #include "nsTArray.h"

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

@ -31,11 +31,11 @@
class nsTextPaintStyle; class nsTextPaintStyle;
struct SelectionDetails; struct SelectionDetails;
class nsTextFragment; class nsTextFragment;
class SVGTextFrame;
namespace mozilla { namespace mozilla {
class SVGContextPaint; class SVGContextPaint;
}; class SVGTextFrame;
} // namespace mozilla
class nsTextFrame : public nsFrame { class nsTextFrame : public nsFrame {
typedef mozilla::LayoutDeviceRect LayoutDeviceRect; typedef mozilla::LayoutDeviceRect LayoutDeviceRect;

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

@ -13,15 +13,18 @@
#include "SVGObserverUtils.h" #include "SVGObserverUtils.h"
#include "SVGFilters.h" #include "SVGFilters.h"
using namespace mozilla; nsIFrame* NS_NewSVGFEContainerFrame(mozilla::PresShell* aPresShell,
mozilla::ComputedStyle* aStyle);
namespace mozilla {
/* /*
* This frame is used by filter primitive elements that * This frame is used by filter primitive elements that
* have special child elements that provide parameters. * have special child elements that provide parameters.
*/ */
class SVGFEContainerFrame final : public nsContainerFrame { class SVGFEContainerFrame final : public nsContainerFrame {
friend nsIFrame* NS_NewSVGFEContainerFrame(mozilla::PresShell* aPresShell, friend nsIFrame* ::NS_NewSVGFEContainerFrame(mozilla::PresShell* aPresShell,
ComputedStyle* aStyle); ComputedStyle* aStyle);
protected: protected:
explicit SVGFEContainerFrame(ComputedStyle* aStyle, explicit SVGFEContainerFrame(ComputedStyle* aStyle,
@ -62,12 +65,16 @@ class SVGFEContainerFrame final : public nsContainerFrame {
} }
}; };
nsIFrame* NS_NewSVGFEContainerFrame(PresShell* aPresShell, } // namespace mozilla
ComputedStyle* aStyle) {
nsIFrame* NS_NewSVGFEContainerFrame(mozilla::PresShell* aPresShell,
mozilla::ComputedStyle* aStyle) {
return new (aPresShell) return new (aPresShell)
SVGFEContainerFrame(aStyle, aPresShell->GetPresContext()); mozilla::SVGFEContainerFrame(aStyle, aPresShell->GetPresContext());
} }
namespace mozilla {
NS_IMPL_FRAMEARENA_HELPERS(SVGFEContainerFrame) NS_IMPL_FRAMEARENA_HELPERS(SVGFEContainerFrame)
#ifdef DEBUG #ifdef DEBUG
@ -94,3 +101,5 @@ nsresult SVGFEContainerFrame::AttributeChanged(int32_t aNameSpaceID,
return nsContainerFrame::AttributeChanged(aNameSpaceID, aAttribute, aModType); return nsContainerFrame::AttributeChanged(aNameSpaceID, aAttribute, aModType);
} }
} // namespace mozilla

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

@ -15,12 +15,16 @@
#include "SVGObserverUtils.h" #include "SVGObserverUtils.h"
#include "SVGFilters.h" #include "SVGFilters.h"
using namespace mozilla;
using namespace mozilla::dom; using namespace mozilla::dom;
nsIFrame* NS_NewSVGFEImageFrame(mozilla::PresShell* aPresShell,
mozilla::ComputedStyle* aStyle);
namespace mozilla {
class SVGFEImageFrame final : public nsFrame { class SVGFEImageFrame final : public nsFrame {
friend nsIFrame* NS_NewSVGFEImageFrame(mozilla::PresShell* aPresShell, friend nsIFrame* ::NS_NewSVGFEImageFrame(mozilla::PresShell* aPresShell,
ComputedStyle* aStyle); ComputedStyle* aStyle);
protected: protected:
explicit SVGFEImageFrame(ComputedStyle* aStyle, nsPresContext* aPresContext) explicit SVGFEImageFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
@ -69,10 +73,16 @@ class SVGFEImageFrame final : public nsFrame {
} }
}; };
nsIFrame* NS_NewSVGFEImageFrame(PresShell* aPresShell, ComputedStyle* aStyle) { } // namespace mozilla
return new (aPresShell) SVGFEImageFrame(aStyle, aPresShell->GetPresContext());
nsIFrame* NS_NewSVGFEImageFrame(mozilla::PresShell* aPresShell,
mozilla::ComputedStyle* aStyle) {
return new (aPresShell)
mozilla::SVGFEImageFrame(aStyle, aPresShell->GetPresContext());
} }
namespace mozilla {
NS_IMPL_FRAMEARENA_HELPERS(SVGFEImageFrame) NS_IMPL_FRAMEARENA_HELPERS(SVGFEImageFrame)
/* virtual */ /* virtual */
@ -159,3 +169,5 @@ void SVGFEImageFrame::OnVisibilityChange(
nsFrame::OnVisibilityChange(aNewVisibility, aNonvisibleAction); nsFrame::OnVisibilityChange(aNewVisibility, aNonvisibleAction);
} }
} // namespace mozilla

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

@ -13,15 +13,17 @@
#include "SVGObserverUtils.h" #include "SVGObserverUtils.h"
#include "SVGFilters.h" #include "SVGFilters.h"
using namespace mozilla; nsIFrame* NS_NewSVGFELeafFrame(mozilla::PresShell* aPresShell,
mozilla::ComputedStyle* aStyle);
namespace mozilla {
/* /*
* This frame is used by filter primitive elements that don't * This frame is used by filter primitive elements that don't
* have special child elements that provide parameters. * have special child elements that provide parameters.
*/ */
class SVGFELeafFrame final : public nsFrame { class SVGFELeafFrame final : public nsFrame {
friend nsIFrame* NS_NewSVGFELeafFrame(mozilla::PresShell* aPresShell, friend nsIFrame* ::NS_NewSVGFELeafFrame(mozilla::PresShell* aPresShell,
ComputedStyle* aStyle); ComputedStyle* aStyle);
protected: protected:
explicit SVGFELeafFrame(ComputedStyle* aStyle, nsPresContext* aPresContext) explicit SVGFELeafFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
@ -60,10 +62,16 @@ class SVGFELeafFrame final : public nsFrame {
} }
}; };
nsIFrame* NS_NewSVGFELeafFrame(PresShell* aPresShell, ComputedStyle* aStyle) { } // namespace mozilla
return new (aPresShell) SVGFELeafFrame(aStyle, aPresShell->GetPresContext());
nsIFrame* NS_NewSVGFELeafFrame(mozilla::PresShell* aPresShell,
mozilla::ComputedStyle* aStyle) {
return new (aPresShell)
mozilla::SVGFELeafFrame(aStyle, aPresShell->GetPresContext());
} }
namespace mozilla {
NS_IMPL_FRAMEARENA_HELPERS(SVGFELeafFrame) NS_IMPL_FRAMEARENA_HELPERS(SVGFELeafFrame)
#ifdef DEBUG #ifdef DEBUG
@ -90,3 +98,5 @@ nsresult SVGFELeafFrame::AttributeChanged(int32_t aNameSpaceID,
return nsFrame::AttributeChanged(aNameSpaceID, aAttribute, aModType); return nsFrame::AttributeChanged(aNameSpaceID, aAttribute, aModType);
} }
} // namespace mozilla

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

@ -12,11 +12,14 @@
#include "SVGObserverUtils.h" #include "SVGObserverUtils.h"
#include "SVGFilters.h" #include "SVGFilters.h"
using namespace mozilla; nsIFrame* NS_NewSVGFEUnstyledLeafFrame(mozilla::PresShell* aPresShell,
mozilla::ComputedStyle* aStyle);
namespace mozilla {
class SVGFEUnstyledLeafFrame final : public nsFrame { class SVGFEUnstyledLeafFrame final : public nsFrame {
friend nsIFrame* NS_NewSVGFEUnstyledLeafFrame(mozilla::PresShell* aPresShell, friend nsIFrame* ::NS_NewSVGFEUnstyledLeafFrame(
ComputedStyle* aStyle); mozilla::PresShell* aPresShell, ComputedStyle* aStyle);
protected: protected:
explicit SVGFEUnstyledLeafFrame(ComputedStyle* aStyle, explicit SVGFEUnstyledLeafFrame(ComputedStyle* aStyle,
@ -54,12 +57,16 @@ class SVGFEUnstyledLeafFrame final : public nsFrame {
} }
}; };
nsIFrame* NS_NewSVGFEUnstyledLeafFrame(PresShell* aPresShell, } // namespace mozilla
ComputedStyle* aStyle) {
nsIFrame* NS_NewSVGFEUnstyledLeafFrame(mozilla::PresShell* aPresShell,
mozilla::ComputedStyle* aStyle) {
return new (aPresShell) return new (aPresShell)
SVGFEUnstyledLeafFrame(aStyle, aPresShell->GetPresContext()); mozilla::SVGFEUnstyledLeafFrame(aStyle, aPresShell->GetPresContext());
} }
namespace mozilla {
NS_IMPL_FRAMEARENA_HELPERS(SVGFEUnstyledLeafFrame) NS_IMPL_FRAMEARENA_HELPERS(SVGFEUnstyledLeafFrame)
nsresult SVGFEUnstyledLeafFrame::AttributeChanged(int32_t aNameSpaceID, nsresult SVGFEUnstyledLeafFrame::AttributeChanged(int32_t aNameSpaceID,
@ -77,3 +84,5 @@ nsresult SVGFEUnstyledLeafFrame::AttributeChanged(int32_t aNameSpaceID,
return nsFrame::AttributeChanged(aNameSpaceID, aAttribute, aModType); return nsFrame::AttributeChanged(aNameSpaceID, aAttribute, aModType);
} }
} // namespace mozilla

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

@ -53,9 +53,9 @@ NS_QUERYFRAME_HEAD(SVGGeometryFrame)
NS_QUERYFRAME_ENTRY(SVGGeometryFrame) NS_QUERYFRAME_ENTRY(SVGGeometryFrame)
NS_QUERYFRAME_TAIL_INHERITING(nsFrame) NS_QUERYFRAME_TAIL_INHERITING(nsFrame)
void nsDisplaySVGGeometry::HitTest(nsDisplayListBuilder* aBuilder, void DisplaySVGGeometry::HitTest(nsDisplayListBuilder* aBuilder,
const nsRect& aRect, HitTestState* aState, const nsRect& aRect, HitTestState* aState,
nsTArray<nsIFrame*>* aOutFrames) { nsTArray<nsIFrame*>* aOutFrames) {
SVGGeometryFrame* frame = static_cast<SVGGeometryFrame*>(mFrame); SVGGeometryFrame* frame = static_cast<SVGGeometryFrame*>(mFrame);
nsPoint pointRelativeToReferenceFrame = aRect.Center(); nsPoint pointRelativeToReferenceFrame = aRect.Center();
// ToReferenceFrame() includes frame->GetPosition(), our user space position. // ToReferenceFrame() includes frame->GetPosition(), our user space position.
@ -69,8 +69,8 @@ void nsDisplaySVGGeometry::HitTest(nsDisplayListBuilder* aBuilder,
} }
} }
void nsDisplaySVGGeometry::Paint(nsDisplayListBuilder* aBuilder, void DisplaySVGGeometry::Paint(nsDisplayListBuilder* aBuilder,
gfxContext* aCtx) { gfxContext* aCtx) {
uint32_t appUnitsPerDevPixel = mFrame->PresContext()->AppUnitsPerDevPixel(); uint32_t appUnitsPerDevPixel = mFrame->PresContext()->AppUnitsPerDevPixel();
// ToReferenceFrame includes our mRect offset, but painting takes // ToReferenceFrame includes our mRect offset, but painting takes
@ -89,7 +89,7 @@ void nsDisplaySVGGeometry::Paint(nsDisplayListBuilder* aBuilder,
nsDisplayItemGenericImageGeometry::UpdateDrawResult(this, imgParams.result); nsDisplayItemGenericImageGeometry::UpdateDrawResult(this, imgParams.result);
} }
void nsDisplaySVGGeometry::ComputeInvalidationRegion( void DisplaySVGGeometry::ComputeInvalidationRegion(
nsDisplayListBuilder* aBuilder, const nsDisplayItemGeometry* aGeometry, nsDisplayListBuilder* aBuilder, const nsDisplayItemGeometry* aGeometry,
nsRegion* aInvalidRegion) const { nsRegion* aInvalidRegion) const {
auto geometry = auto geometry =
@ -205,7 +205,7 @@ void SVGGeometryFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
return; return;
} }
DisplayOutline(aBuilder, aLists); DisplayOutline(aBuilder, aLists);
aLists.Content()->AppendNewToTop<nsDisplaySVGGeometry>(aBuilder, this); aLists.Content()->AppendNewToTop<DisplaySVGGeometry>(aBuilder, this);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

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

@ -18,12 +18,16 @@
#include "nsSVGUtils.h" #include "nsSVGUtils.h"
namespace mozilla { namespace mozilla {
class DisplaySVGGeometry;
class PresShell;
class SVGGeometryFrame; class SVGGeometryFrame;
class SVGMarkerObserver; class SVGMarkerObserver;
class nsDisplaySVGGeometry;
namespace gfx { namespace gfx {
class DrawTarget; class DrawTarget;
} // namespace gfx } // namespace gfx
} // namespace mozilla } // namespace mozilla
class gfxContext; class gfxContext;
@ -33,10 +37,6 @@ class nsSVGMarkerFrame;
struct nsRect; struct nsRect;
namespace mozilla {
class PresShell;
} // namespace mozilla
nsIFrame* NS_NewSVGGeometryFrame(mozilla::PresShell* aPresShell, nsIFrame* NS_NewSVGGeometryFrame(mozilla::PresShell* aPresShell,
mozilla::ComputedStyle* aStyle); mozilla::ComputedStyle* aStyle);
@ -48,7 +48,7 @@ class SVGGeometryFrame : public nsFrame, public nsSVGDisplayableFrame {
friend nsIFrame* ::NS_NewSVGGeometryFrame(mozilla::PresShell* aPresShell, friend nsIFrame* ::NS_NewSVGGeometryFrame(mozilla::PresShell* aPresShell,
ComputedStyle* aStyle); ComputedStyle* aStyle);
friend class nsDisplaySVGGeometry; friend class DisplaySVGGeometry;
protected: protected:
SVGGeometryFrame(ComputedStyle* aStyle, nsPresContext* aPresContext, SVGGeometryFrame(ComputedStyle* aStyle, nsPresContext* aPresContext,
@ -124,7 +124,7 @@ class SVGGeometryFrame : public nsFrame, public nsSVGDisplayableFrame {
mozilla::wr::IpcResourceUpdateQueue& aResources, mozilla::wr::IpcResourceUpdateQueue& aResources,
const mozilla::layers::StackingContextHelper& aSc, const mozilla::layers::StackingContextHelper& aSc,
mozilla::layers::RenderRootStateManager* aManager, mozilla::layers::RenderRootStateManager* aManager,
nsDisplayListBuilder* aDisplayListBuilder, nsDisplaySVGGeometry* aItem, nsDisplayListBuilder* aDisplayListBuilder, DisplaySVGGeometry* aItem,
bool aDryRun) { bool aDryRun) {
MOZ_RELEASE_ASSERT(aDryRun, "You shouldn't be calling this directly"); MOZ_RELEASE_ASSERT(aDryRun, "You shouldn't be calling this directly");
return false; return false;
@ -140,20 +140,20 @@ class SVGGeometryFrame : public nsFrame, public nsSVGDisplayableFrame {
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// Display list item: // Display list item:
class nsDisplaySVGGeometry final : public nsPaintedDisplayItem { class DisplaySVGGeometry final : public nsPaintedDisplayItem {
typedef mozilla::image::imgDrawingParams imgDrawingParams; typedef mozilla::image::imgDrawingParams imgDrawingParams;
public: public:
nsDisplaySVGGeometry(nsDisplayListBuilder* aBuilder, SVGGeometryFrame* aFrame) DisplaySVGGeometry(nsDisplayListBuilder* aBuilder, SVGGeometryFrame* aFrame)
: nsPaintedDisplayItem(aBuilder, aFrame) { : nsPaintedDisplayItem(aBuilder, aFrame) {
MOZ_COUNT_CTOR(nsDisplaySVGGeometry); MOZ_COUNT_CTOR(DisplaySVGGeometry);
MOZ_ASSERT(aFrame, "Must have a frame!"); MOZ_ASSERT(aFrame, "Must have a frame!");
} }
#ifdef NS_BUILD_REFCNT_LOGGING #ifdef NS_BUILD_REFCNT_LOGGING
virtual ~nsDisplaySVGGeometry() { MOZ_COUNT_DTOR(nsDisplaySVGGeometry); } virtual ~DisplaySVGGeometry() { MOZ_COUNT_DTOR(DisplaySVGGeometry); }
#endif #endif
NS_DISPLAY_DECL_NAME("nsDisplaySVGGeometry", TYPE_SVG_GEOMETRY) NS_DISPLAY_DECL_NAME("DisplaySVGGeometry", TYPE_SVG_GEOMETRY)
virtual void HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect, virtual void HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect,
HitTestState* aState, HitTestState* aState,

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

@ -54,12 +54,13 @@
#include <cmath> #include <cmath>
#include <limits> #include <limits>
using namespace mozilla;
using namespace mozilla::dom; using namespace mozilla::dom;
using namespace mozilla::dom::SVGTextContentElement_Binding; using namespace mozilla::dom::SVGTextContentElement_Binding;
using namespace mozilla::gfx; using namespace mozilla::gfx;
using namespace mozilla::image; using namespace mozilla::image;
namespace mozilla {
// ============================================================================ // ============================================================================
// Utility functions // Utility functions
@ -364,8 +365,6 @@ static double GetContextScale(const gfxMatrix& aMatrix) {
// ============================================================================ // ============================================================================
// Utility classes // Utility classes
namespace mozilla {
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// TextRenderedRun // TextRenderedRun
@ -2675,26 +2674,24 @@ void SVGTextDrawPathCallbacks::StrokeGeometry() {
} }
} }
} // namespace mozilla
// ============================================================================ // ============================================================================
// SVGTextFrame // SVGTextFrame
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Display list item // Display list item
class nsDisplaySVGText final : public nsPaintedDisplayItem { class DisplaySVGText final : public nsPaintedDisplayItem {
public: public:
nsDisplaySVGText(nsDisplayListBuilder* aBuilder, SVGTextFrame* aFrame) DisplaySVGText(nsDisplayListBuilder* aBuilder, SVGTextFrame* aFrame)
: nsPaintedDisplayItem(aBuilder, aFrame) { : nsPaintedDisplayItem(aBuilder, aFrame) {
MOZ_COUNT_CTOR(nsDisplaySVGText); MOZ_COUNT_CTOR(DisplaySVGText);
MOZ_ASSERT(aFrame, "Must have a frame!"); MOZ_ASSERT(aFrame, "Must have a frame!");
} }
#ifdef NS_BUILD_REFCNT_LOGGING #ifdef NS_BUILD_REFCNT_LOGGING
MOZ_COUNTED_DTOR_OVERRIDE(nsDisplaySVGText) MOZ_COUNTED_DTOR_OVERRIDE(DisplaySVGText)
#endif #endif
NS_DISPLAY_DECL_NAME("nsDisplaySVGText", TYPE_SVG_TEXT) NS_DISPLAY_DECL_NAME("DisplaySVGText", TYPE_SVG_TEXT)
virtual void HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect, virtual void HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect,
HitTestState* aState, HitTestState* aState,
@ -2712,9 +2709,9 @@ class nsDisplaySVGText final : public nsPaintedDisplayItem {
} }
}; };
void nsDisplaySVGText::HitTest(nsDisplayListBuilder* aBuilder, void DisplaySVGText::HitTest(nsDisplayListBuilder* aBuilder,
const nsRect& aRect, HitTestState* aState, const nsRect& aRect, HitTestState* aState,
nsTArray<nsIFrame*>* aOutFrames) { nsTArray<nsIFrame*>* aOutFrames) {
SVGTextFrame* frame = static_cast<SVGTextFrame*>(mFrame); SVGTextFrame* frame = static_cast<SVGTextFrame*>(mFrame);
nsPoint pointRelativeToReferenceFrame = aRect.Center(); nsPoint pointRelativeToReferenceFrame = aRect.Center();
// ToReferenceFrame() includes frame->GetPosition(), our user space position. // ToReferenceFrame() includes frame->GetPosition(), our user space position.
@ -2731,7 +2728,7 @@ void nsDisplaySVGText::HitTest(nsDisplayListBuilder* aBuilder,
} }
} }
void nsDisplaySVGText::Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) { void DisplaySVGText::Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) {
DrawTargetAutoDisableSubpixelAntialiasing disable(aCtx->GetDrawTarget(), DrawTargetAutoDisableSubpixelAntialiasing disable(aCtx->GetDrawTarget(),
IsSubpixelAADisabled()); IsSubpixelAADisabled());
@ -2761,13 +2758,18 @@ NS_QUERYFRAME_HEAD(SVGTextFrame)
NS_QUERYFRAME_ENTRY(SVGTextFrame) NS_QUERYFRAME_ENTRY(SVGTextFrame)
NS_QUERYFRAME_TAIL_INHERITING(nsSVGDisplayContainerFrame) NS_QUERYFRAME_TAIL_INHERITING(nsSVGDisplayContainerFrame)
} // namespace mozilla
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
// Implementation // Implementation
nsIFrame* NS_NewSVGTextFrame(PresShell* aPresShell, ComputedStyle* aStyle) { nsIFrame* NS_NewSVGTextFrame(PresShell* aPresShell, ComputedStyle* aStyle) {
return new (aPresShell) SVGTextFrame(aStyle, aPresShell->GetPresContext()); return new (aPresShell)
mozilla::SVGTextFrame(aStyle, aPresShell->GetPresContext());
} }
namespace mozilla {
NS_IMPL_FRAMEARENA_HELPERS(SVGTextFrame) NS_IMPL_FRAMEARENA_HELPERS(SVGTextFrame)
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
@ -2803,7 +2805,7 @@ void SVGTextFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
return; return;
} }
DisplayOutline(aBuilder, aLists); DisplayOutline(aBuilder, aLists);
aLists.Content()->AppendNewToTop<nsDisplaySVGText>(aBuilder, this); aLists.Content()->AppendNewToTop<DisplaySVGText>(aBuilder, this);
} }
nsresult SVGTextFrame::AttributeChanged(int32_t aNameSpaceID, nsresult SVGTextFrame::AttributeChanged(int32_t aNameSpaceID,
@ -5372,3 +5374,5 @@ void SVGTextFrame::AppendDirectlyOwnedAnonBoxes(
MOZ_ASSERT(PrincipalChildList().FirstChild(), "Must have our anon box"); MOZ_ASSERT(PrincipalChildList().FirstChild(), "Must have our anon box");
aResult.AppendElement(OwnedAnonBox(PrincipalChildList().FirstChild())); aResult.AppendElement(OwnedAnonBox(PrincipalChildList().FirstChild()));
} }
} // namespace mozilla

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

@ -20,12 +20,12 @@
#include "nsTextFrame.h" #include "nsTextFrame.h"
class gfxContext; class gfxContext;
class nsDisplaySVGText;
class SVGTextFrame;
namespace mozilla { namespace mozilla {
class CharIterator; class CharIterator;
class DisplaySVGText;
class SVGTextFrame;
class TextFrameIterator; class TextFrameIterator;
class TextNodeCorrespondenceRecorder; class TextNodeCorrespondenceRecorder;
struct TextRenderedRun; struct TextRenderedRun;
@ -37,6 +37,12 @@ class nsISVGPoint;
class SVGRect; class SVGRect;
class SVGGeometryElement; class SVGGeometryElement;
} // namespace dom } // namespace dom
} // namespace mozilla
nsIFrame* NS_NewSVGTextFrame(mozilla::PresShell* aPresShell,
mozilla::ComputedStyle* aStyle);
namespace mozilla {
/** /**
* Information about the positioning for a single character in an SVG <text> * Information about the positioning for a single character in an SVG <text>
@ -123,8 +129,6 @@ class GlyphMetricsUpdater : public Runnable {
SVGTextFrame* mFrame; SVGTextFrame* mFrame;
}; };
} // namespace mozilla
/** /**
* Frame class for SVG <text> elements. * Frame class for SVG <text> elements.
* *
@ -159,22 +163,22 @@ class GlyphMetricsUpdater : public Runnable {
* PaintText so that we can fill the text geometry with SVG paint servers. * PaintText so that we can fill the text geometry with SVG paint servers.
*/ */
class SVGTextFrame final : public nsSVGDisplayContainerFrame { class SVGTextFrame final : public nsSVGDisplayContainerFrame {
friend nsIFrame* NS_NewSVGTextFrame(mozilla::PresShell* aPresShell, friend nsIFrame* ::NS_NewSVGTextFrame(mozilla::PresShell* aPresShell,
ComputedStyle* aStyle); ComputedStyle* aStyle);
friend class mozilla::CharIterator; friend class CharIterator;
friend class mozilla::GlyphMetricsUpdater; friend class DisplaySVGText;
friend class mozilla::TextFrameIterator; friend class GlyphMetricsUpdater;
friend class mozilla::TextNodeCorrespondenceRecorder;
friend struct mozilla::TextRenderedRun;
friend class mozilla::TextRenderedRunIterator;
friend class MutationObserver; friend class MutationObserver;
friend class nsDisplaySVGText; friend class TextFrameIterator;
friend class TextNodeCorrespondenceRecorder;
friend struct TextRenderedRun;
friend class TextRenderedRunIterator;
typedef gfxTextRun::Range Range; typedef gfxTextRun::Range Range;
typedef mozilla::gfx::DrawTarget DrawTarget; typedef gfx::DrawTarget DrawTarget;
typedef mozilla::gfx::Path Path; typedef gfx::Path Path;
typedef mozilla::gfx::Point Point; typedef gfx::Point Point;
protected: protected:
explicit SVGTextFrame(ComputedStyle* aStyle, nsPresContext* aPresContext) explicit SVGTextFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
@ -233,21 +237,23 @@ class SVGTextFrame final : public nsSVGDisplayContainerFrame {
uint32_t GetNumberOfChars(nsIContent* aContent); uint32_t GetNumberOfChars(nsIContent* aContent);
float GetComputedTextLength(nsIContent* aContent); float GetComputedTextLength(nsIContent* aContent);
void SelectSubString(nsIContent* aContent, uint32_t charnum, uint32_t nchars, void SelectSubString(nsIContent* aContent, uint32_t charnum, uint32_t nchars,
mozilla::ErrorResult& aRv); ErrorResult& aRv);
MOZ_CAN_RUN_SCRIPT MOZ_CAN_RUN_SCRIPT
float GetSubStringLength(nsIContent* aContent, uint32_t charnum, float GetSubStringLength(nsIContent* aContent, uint32_t charnum,
uint32_t nchars, mozilla::ErrorResult& aRv); uint32_t nchars, ErrorResult& aRv);
int32_t GetCharNumAtPosition(nsIContent* aContent, int32_t GetCharNumAtPosition(nsIContent* aContent,
const mozilla::dom::DOMPointInit& aPoint); const dom::DOMPointInit& aPoint);
already_AddRefed<mozilla::dom::nsISVGPoint> GetStartPositionOfChar( already_AddRefed<dom::nsISVGPoint> GetStartPositionOfChar(
nsIContent* aContent, uint32_t aCharNum, mozilla::ErrorResult& aRv); nsIContent* aContent, uint32_t aCharNum, ErrorResult& aRv);
already_AddRefed<mozilla::dom::nsISVGPoint> GetEndPositionOfChar( already_AddRefed<dom::nsISVGPoint> GetEndPositionOfChar(nsIContent* aContent,
nsIContent* aContent, uint32_t aCharNum, mozilla::ErrorResult& aRv); uint32_t aCharNum,
already_AddRefed<mozilla::dom::SVGRect> GetExtentOfChar( ErrorResult& aRv);
nsIContent* aContent, uint32_t aCharNum, mozilla::ErrorResult& aRv); already_AddRefed<dom::SVGRect> GetExtentOfChar(nsIContent* aContent,
uint32_t aCharNum,
ErrorResult& aRv);
float GetRotationOfChar(nsIContent* aContent, uint32_t aCharNum, float GetRotationOfChar(nsIContent* aContent, uint32_t aCharNum,
mozilla::ErrorResult& aRv); ErrorResult& aRv);
// SVGTextFrame methods: // SVGTextFrame methods:
@ -255,7 +261,7 @@ class SVGTextFrame final : public nsSVGDisplayContainerFrame {
* Handles a base or animated attribute value change to a descendant * Handles a base or animated attribute value change to a descendant
* text content element. * text content element.
*/ */
void HandleAttributeChangeInDescendant(mozilla::dom::Element* aElement, void HandleAttributeChangeInDescendant(dom::Element* aElement,
int32_t aNameSpaceID, int32_t aNameSpaceID,
nsAtom* aAttribute); nsAtom* aAttribute);
@ -299,7 +305,7 @@ class SVGTextFrame final : public nsSVGDisplayContainerFrame {
* animated SVG-in-OpenType glyphs), in which case aReason will be eResize, * animated SVG-in-OpenType glyphs), in which case aReason will be eResize,
* since layout doesn't need to be recomputed. * since layout doesn't need to be recomputed.
*/ */
void ScheduleReflowSVGNonDisplayText(mozilla::IntrinsicDirty aReason); void ScheduleReflowSVGNonDisplayText(IntrinsicDirty aReason);
/** /**
* Updates the mFontSizeScaleFactor value by looking at the range of * Updates the mFontSizeScaleFactor value by looking at the range of
@ -396,8 +402,7 @@ class SVGTextFrame final : public nsSVGDisplayContainerFrame {
*/ */
MOZ_CAN_RUN_SCRIPT MOZ_CAN_RUN_SCRIPT
float GetSubStringLengthSlowFallback(nsIContent* aContent, uint32_t charnum, float GetSubStringLengthSlowFallback(nsIContent* aContent, uint32_t charnum,
uint32_t nchars, uint32_t nchars, ErrorResult& aRv);
mozilla::ErrorResult& aRv);
/** /**
* Converts the specified index into mPositions to an addressable * Converts the specified index into mPositions to an addressable
@ -527,7 +532,7 @@ class SVGTextFrame final : public nsSVGDisplayContainerFrame {
/** /**
* Computed position information for each DOM character within the <text>. * Computed position information for each DOM character within the <text>.
*/ */
nsTArray<mozilla::CharPosition> mPositions; nsTArray<CharPosition> mPositions;
/** /**
* mFontSizeScaleFactor is used to cause the nsTextFrames to create text * mFontSizeScaleFactor is used to cause the nsTextFrames to create text
@ -567,4 +572,6 @@ class SVGTextFrame final : public nsSVGDisplayContainerFrame {
float mLengthAdjustScaleFactor; float mLengthAdjustScaleFactor;
}; };
} // namespace mozilla
#endif #endif

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

@ -12,9 +12,13 @@
#include "nsGkAtoms.h" #include "nsGkAtoms.h"
#include "nsSVGOuterSVGFrame.h" #include "nsSVGOuterSVGFrame.h"
using namespace mozilla;
using namespace mozilla::dom; using namespace mozilla::dom;
nsIFrame* NS_NewSVGViewFrame(mozilla::PresShell* aPresShell,
ComputedStyle* aStyle);
namespace mozilla {
/** /**
* While views are not directly rendered in SVG they can be linked to * While views are not directly rendered in SVG they can be linked to
* and thereby override attributes of an <svg> element via a fragment * and thereby override attributes of an <svg> element via a fragment
@ -22,8 +26,8 @@ using namespace mozilla::dom;
* the view receives to the overridden <svg> element (if there is one). * the view receives to the overridden <svg> element (if there is one).
**/ **/
class SVGViewFrame final : public nsFrame { class SVGViewFrame final : public nsFrame {
friend nsIFrame* NS_NewSVGViewFrame(mozilla::PresShell* aPresShell, friend nsIFrame* ::NS_NewSVGViewFrame(mozilla::PresShell* aPresShell,
ComputedStyle* aStyle); ComputedStyle* aStyle);
protected: protected:
explicit SVGViewFrame(ComputedStyle* aStyle, nsPresContext* aPresContext) explicit SVGViewFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
@ -62,10 +66,16 @@ class SVGViewFrame final : public nsFrame {
} }
}; };
nsIFrame* NS_NewSVGViewFrame(PresShell* aPresShell, ComputedStyle* aStyle) { } // namespace mozilla
return new (aPresShell) SVGViewFrame(aStyle, aPresShell->GetPresContext());
nsIFrame* NS_NewSVGViewFrame(mozilla::PresShell* aPresShell,
ComputedStyle* aStyle) {
return new (aPresShell)
mozilla::SVGViewFrame(aStyle, aPresShell->GetPresContext());
} }
namespace mozilla {
NS_IMPL_FRAMEARENA_HELPERS(SVGViewFrame) NS_IMPL_FRAMEARENA_HELPERS(SVGViewFrame)
#ifdef DEBUG #ifdef DEBUG
@ -104,3 +114,5 @@ nsresult SVGViewFrame::AttributeChanged(int32_t aNameSpaceID,
return nsFrame::AttributeChanged(aNameSpaceID, aAttribute, aModType); return nsFrame::AttributeChanged(aNameSpaceID, aAttribute, aModType);
} }
} // namespace mozilla

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

@ -30,10 +30,8 @@ EXPORTS += [
EXPORTS.mozilla += [ EXPORTS.mozilla += [
'SVGContextPaint.h', 'SVGContextPaint.h',
]
EXPORTS.mozilla.layout += [
'SVGGeometryFrame.h', 'SVGGeometryFrame.h',
'SVGTextFrame.h'
] ]
UNIFIED_SOURCES += [ UNIFIED_SOURCES += [

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

@ -408,7 +408,7 @@ bool nsSVGImageFrame::CreateWebRenderCommands(
mozilla::wr::IpcResourceUpdateQueue& aResources, mozilla::wr::IpcResourceUpdateQueue& aResources,
const mozilla::layers::StackingContextHelper& aSc, const mozilla::layers::StackingContextHelper& aSc,
mozilla::layers::RenderRootStateManager* aManager, mozilla::layers::RenderRootStateManager* aManager,
nsDisplayListBuilder* aDisplayListBuilder, nsDisplaySVGGeometry* aItem, nsDisplayListBuilder* aDisplayListBuilder, DisplaySVGGeometry* aItem,
bool aDryRun) { bool aDryRun) {
if (!StyleVisibility()->IsVisible()) { if (!StyleVisibility()->IsVisible()) {
return true; return true;

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

@ -56,7 +56,7 @@ class nsSVGImageFrame final : public mozilla::SVGGeometryFrame,
const mozilla::layers::StackingContextHelper& aSc, const mozilla::layers::StackingContextHelper& aSc,
mozilla::layers::RenderRootStateManager* aManager, mozilla::layers::RenderRootStateManager* aManager,
nsDisplayListBuilder* aDisplayListBuilder, nsDisplayListBuilder* aDisplayListBuilder,
mozilla::nsDisplaySVGGeometry* aItem, bool aDryRun) override; mozilla::DisplaySVGGeometry* aItem, bool aDryRun) override;
protected: protected:
explicit nsSVGImageFrame(ComputedStyle* aStyle, nsPresContext* aPresContext) explicit nsSVGImageFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)