layout/svg/nsSVGStopFrame.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/svg/nsSVGStopFrame.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,115 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +// Keep in (case-insensitive) order:
    1.10 +#include "nsFrame.h"
    1.11 +#include "nsGkAtoms.h"
    1.12 +#include "nsStyleContext.h"
    1.13 +#include "nsSVGEffects.h"
    1.14 +
    1.15 +// This is a very simple frame whose only purpose is to capture style change
    1.16 +// events and propagate them to the parent.  Most of the heavy lifting is done
    1.17 +// within the nsSVGGradientFrame, which is the parent for this frame
    1.18 +
    1.19 +typedef nsFrame  nsSVGStopFrameBase;
    1.20 +
    1.21 +class nsSVGStopFrame : public nsSVGStopFrameBase
    1.22 +{
    1.23 +  friend nsIFrame*
    1.24 +  NS_NewSVGStopFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
    1.25 +protected:
    1.26 +  nsSVGStopFrame(nsStyleContext* aContext)
    1.27 +    : nsSVGStopFrameBase(aContext)
    1.28 +  {
    1.29 +    AddStateBits(NS_FRAME_IS_NONDISPLAY);
    1.30 +  }
    1.31 +
    1.32 +public:
    1.33 +  NS_DECL_FRAMEARENA_HELPERS
    1.34 +
    1.35 +  // nsIFrame interface:
    1.36 +#ifdef DEBUG
    1.37 +  virtual void Init(nsIContent*      aContent,
    1.38 +                    nsIFrame*        aParent,
    1.39 +                    nsIFrame*        aPrevInFlow) MOZ_OVERRIDE;
    1.40 +#endif
    1.41 +
    1.42 +  void BuildDisplayList(nsDisplayListBuilder*   aBuilder,
    1.43 +                        const nsRect&           aDirtyRect,
    1.44 +                        const nsDisplayListSet& aLists) MOZ_OVERRIDE {}
    1.45 +
    1.46 +  virtual nsresult AttributeChanged(int32_t         aNameSpaceID,
    1.47 +                                    nsIAtom*        aAttribute,
    1.48 +                                    int32_t         aModType) MOZ_OVERRIDE;
    1.49 +
    1.50 +  /**
    1.51 +   * Get the "type" of the frame
    1.52 +   *
    1.53 +   * @see nsGkAtoms::svgStopFrame
    1.54 +   */
    1.55 +  virtual nsIAtom* GetType() const MOZ_OVERRIDE;
    1.56 +
    1.57 +  virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE
    1.58 +  {
    1.59 +    return nsSVGStopFrameBase::IsFrameOfType(aFlags & ~(nsIFrame::eSVG));
    1.60 +  }
    1.61 +
    1.62 +#ifdef DEBUG_FRAME_DUMP
    1.63 +  virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE
    1.64 +  {
    1.65 +    return MakeFrameName(NS_LITERAL_STRING("SVGStop"), aResult);
    1.66 +  }
    1.67 +#endif
    1.68 +};
    1.69 +
    1.70 +//----------------------------------------------------------------------
    1.71 +// Implementation
    1.72 +
    1.73 +NS_IMPL_FRAMEARENA_HELPERS(nsSVGStopFrame)
    1.74 +
    1.75 +//----------------------------------------------------------------------
    1.76 +// nsIFrame methods:
    1.77 +
    1.78 +#ifdef DEBUG
    1.79 +void
    1.80 +nsSVGStopFrame::Init(nsIContent* aContent,
    1.81 +                     nsIFrame* aParent,
    1.82 +                     nsIFrame* aPrevInFlow)
    1.83 +{
    1.84 +  NS_ASSERTION(aContent->IsSVG(nsGkAtoms::stop), "Content is not a stop element");
    1.85 +
    1.86 +  nsSVGStopFrameBase::Init(aContent, aParent, aPrevInFlow);
    1.87 +}
    1.88 +#endif /* DEBUG */
    1.89 +
    1.90 +nsIAtom *
    1.91 +nsSVGStopFrame::GetType() const
    1.92 +{
    1.93 +  return nsGkAtoms::svgStopFrame;
    1.94 +}
    1.95 +
    1.96 +nsresult
    1.97 +nsSVGStopFrame::AttributeChanged(int32_t         aNameSpaceID,
    1.98 +                                 nsIAtom*        aAttribute,
    1.99 +                                 int32_t         aModType)
   1.100 +{
   1.101 +  if (aNameSpaceID == kNameSpaceID_None &&
   1.102 +      aAttribute == nsGkAtoms::offset) {
   1.103 +    nsSVGEffects::InvalidateRenderingObservers(this);
   1.104 +  }
   1.105 +
   1.106 +  return nsSVGStopFrameBase::AttributeChanged(aNameSpaceID,
   1.107 +                                              aAttribute, aModType);
   1.108 +}
   1.109 +
   1.110 +// -------------------------------------------------------------------------
   1.111 +// Public functions
   1.112 +// -------------------------------------------------------------------------
   1.113 +
   1.114 +nsIFrame* NS_NewSVGStopFrame(nsIPresShell*   aPresShell,
   1.115 +                             nsStyleContext* aContext)
   1.116 +{
   1.117 +  return new (aPresShell) nsSVGStopFrame(aContext);
   1.118 +}

mercurial