2017-10-27 20:33:53 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-02-22 15:38:12 +03:00
|
|
|
|
2012-03-26 15:58:59 +04:00
|
|
|
// Keep in (case-insensitive) order:
|
|
|
|
#include "gfxMatrix.h"
|
2013-01-10 09:30:13 +04:00
|
|
|
#include "mozilla/dom/SVGAElement.h"
|
2016-06-07 23:10:18 +03:00
|
|
|
#include "nsAutoPtr.h"
|
2017-05-06 22:32:14 +03:00
|
|
|
#include "nsIDOMMutationEvent.h"
|
2013-11-18 18:29:53 +04:00
|
|
|
#include "nsSVGContainerFrame.h"
|
2012-06-30 15:20:46 +04:00
|
|
|
#include "nsSVGIntegrationUtils.h"
|
2007-02-22 15:38:12 +03:00
|
|
|
#include "nsSVGUtils.h"
|
2010-07-17 01:42:12 +04:00
|
|
|
#include "SVGLengthList.h"
|
2007-02-22 15:38:12 +03:00
|
|
|
|
2010-07-17 01:42:12 +04:00
|
|
|
using namespace mozilla;
|
|
|
|
|
2016-04-18 09:52:46 +03:00
|
|
|
class nsSVGAFrame : public nsSVGDisplayContainerFrame
|
2007-02-22 15:38:12 +03:00
|
|
|
{
|
|
|
|
friend nsIFrame*
|
2009-01-19 21:31:34 +03:00
|
|
|
NS_NewSVGAFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
|
2007-02-22 15:38:12 +03:00
|
|
|
protected:
|
2016-04-18 09:52:46 +03:00
|
|
|
explicit nsSVGAFrame(nsStyleContext* aContext)
|
2017-05-26 13:11:11 +03:00
|
|
|
: nsSVGDisplayContainerFrame(aContext, kClassID)
|
2017-04-30 18:30:08 +03:00
|
|
|
{}
|
2007-02-22 15:38:12 +03:00
|
|
|
|
|
|
|
public:
|
2017-05-26 13:11:11 +03:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS(nsSVGAFrame)
|
2009-09-12 20:49:24 +04:00
|
|
|
|
2009-01-19 21:31:34 +03:00
|
|
|
#ifdef DEBUG
|
2014-05-25 02:20:40 +04:00
|
|
|
virtual void Init(nsIContent* aContent,
|
|
|
|
nsContainerFrame* aParent,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsIFrame* aPrevInFlow) override;
|
2009-01-19 21:31:34 +03:00
|
|
|
#endif
|
|
|
|
|
2007-02-22 15:38:12 +03:00
|
|
|
// nsIFrame:
|
2014-02-18 11:47:48 +04:00
|
|
|
virtual nsresult AttributeChanged(int32_t aNameSpaceID,
|
2017-10-03 01:05:19 +03:00
|
|
|
nsAtom* aAttribute,
|
2015-03-21 19:28:04 +03:00
|
|
|
int32_t aModType) override;
|
2007-02-22 15:38:12 +03:00
|
|
|
|
2014-01-06 03:31:14 +04:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsresult GetFrameName(nsAString& aResult) const override
|
2007-02-22 15:38:12 +03:00
|
|
|
{
|
|
|
|
return MakeFrameName(NS_LITERAL_STRING("SVGA"), aResult);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Implementation
|
|
|
|
|
|
|
|
nsIFrame*
|
2009-01-19 21:31:34 +03:00
|
|
|
NS_NewSVGAFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
2007-02-22 15:38:12 +03:00
|
|
|
{
|
|
|
|
return new (aPresShell) nsSVGAFrame(aContext);
|
|
|
|
}
|
|
|
|
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsSVGAFrame)
|
|
|
|
|
2007-02-22 15:38:12 +03:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIFrame methods
|
2009-01-19 21:31:34 +03:00
|
|
|
#ifdef DEBUG
|
2013-03-20 05:47:48 +04:00
|
|
|
void
|
2014-05-25 02:20:40 +04:00
|
|
|
nsSVGAFrame::Init(nsIContent* aContent,
|
|
|
|
nsContainerFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow)
|
2009-01-19 21:31:34 +03:00
|
|
|
{
|
2015-03-03 14:08:59 +03:00
|
|
|
NS_ASSERTION(aContent->IsSVGElement(nsGkAtoms::a),
|
2009-01-19 21:31:34 +03:00
|
|
|
"Trying to construct an SVGAFrame for a "
|
|
|
|
"content element that doesn't support the right interfaces");
|
|
|
|
|
2016-04-18 09:52:46 +03:00
|
|
|
nsSVGDisplayContainerFrame::Init(aContent, aParent, aPrevInFlow);
|
2009-01-19 21:31:34 +03:00
|
|
|
}
|
|
|
|
#endif /* DEBUG */
|
2007-02-22 15:38:12 +03:00
|
|
|
|
2014-02-18 11:47:48 +04:00
|
|
|
nsresult
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSVGAFrame::AttributeChanged(int32_t aNameSpaceID,
|
2017-10-03 01:05:19 +03:00
|
|
|
nsAtom* aAttribute,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aModType)
|
2007-02-22 15:38:12 +03:00
|
|
|
{
|
2012-01-28 17:58:17 +04:00
|
|
|
if (aNameSpaceID == kNameSpaceID_None &&
|
|
|
|
aAttribute == nsGkAtoms::transform) {
|
2013-05-23 11:04:21 +04:00
|
|
|
// We don't invalidate for transform changes (the layers code does that).
|
|
|
|
// Also note that SVGTransformableElement::GetAttributeChangeHint will
|
|
|
|
// return nsChangeHint_UpdateOverflow for "transform" attribute changes
|
|
|
|
// and cause DoApplyRenderingChangeToTree to make the SchedulePaint call.
|
2012-01-28 17:58:17 +04:00
|
|
|
NotifySVGChanged(TRANSFORM_CHANGED);
|
2007-02-22 15:38:12 +03:00
|
|
|
}
|
|
|
|
|
2017-05-06 22:32:14 +03:00
|
|
|
// Currently our SMIL implementation does not modify the DOM attributes. Once
|
|
|
|
// we implement the SVG 2 SMIL behaviour this can be removed
|
|
|
|
// SVGAElement::SetAttr/UnsetAttr's ResetLinkState() call will be sufficient.
|
|
|
|
if (aModType == nsIDOMMutationEvent::SMIL &&
|
|
|
|
aAttribute == nsGkAtoms::href &&
|
|
|
|
(aNameSpaceID == kNameSpaceID_None ||
|
|
|
|
aNameSpaceID == kNameSpaceID_XLink)) {
|
|
|
|
|
2017-08-27 01:58:38 +03:00
|
|
|
dom::SVGAElement* content = static_cast<dom::SVGAElement*>(GetContent());
|
2017-05-06 22:32:14 +03:00
|
|
|
|
|
|
|
// SMIL may change whether an <a> element is a link, in which case we will
|
|
|
|
// need to update the link state.
|
|
|
|
content->ResetLinkState(true, content->ElementHasHref());
|
|
|
|
}
|
|
|
|
|
2007-02-22 15:38:12 +03:00
|
|
|
return NS_OK;
|
2017-09-05 12:26:46 +03:00
|
|
|
}
|