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"
|
2019-04-16 10:24:49 +03:00
|
|
|
#include "mozilla/PresShell.h"
|
2020-07-09 04:33:33 +03:00
|
|
|
#include "mozilla/SVGContainerFrame.h"
|
2013-01-10 09:30:13 +04:00
|
|
|
#include "mozilla/dom/SVGAElement.h"
|
2018-02-09 19:17:10 +03:00
|
|
|
#include "mozilla/dom/MutationEventBinding.h"
|
2010-07-17 01:42:12 +04:00
|
|
|
#include "SVGLengthList.h"
|
2007-02-22 15:38:12 +03:00
|
|
|
|
2020-06-27 08:39:42 +03:00
|
|
|
nsIFrame* NS_NewSVGAFrame(mozilla::PresShell* aPresShell,
|
|
|
|
mozilla::ComputedStyle* aStyle);
|
2010-07-17 01:42:12 +04:00
|
|
|
|
2020-06-27 08:39:42 +03:00
|
|
|
namespace mozilla {
|
|
|
|
|
2020-07-09 04:33:33 +03:00
|
|
|
class SVGAFrame final : public SVGDisplayContainerFrame {
|
2020-06-27 08:39:42 +03:00
|
|
|
friend nsIFrame* ::NS_NewSVGAFrame(mozilla::PresShell* aPresShell,
|
|
|
|
ComputedStyle* aStyle);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2007-02-22 15:38:12 +03:00
|
|
|
protected:
|
2020-06-27 08:39:42 +03:00
|
|
|
explicit SVGAFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
|
2020-07-09 04:33:33 +03:00
|
|
|
: SVGDisplayContainerFrame(aStyle, aPresContext, kClassID) {}
|
2007-02-22 15:38:12 +03:00
|
|
|
|
|
|
|
public:
|
2020-06-27 08:39:42 +03:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS(SVGAFrame)
|
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, 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(u"SVGA"_ns, aResult);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2020-06-27 08:39:42 +03:00
|
|
|
} // namespace mozilla
|
|
|
|
|
2007-02-22 15:38:12 +03:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Implementation
|
|
|
|
|
2020-06-27 08:39:42 +03:00
|
|
|
nsIFrame* NS_NewSVGAFrame(mozilla::PresShell* aPresShell,
|
|
|
|
mozilla::ComputedStyle* aStyle) {
|
|
|
|
return new (aPresShell)
|
|
|
|
mozilla::SVGAFrame(aStyle, aPresShell->GetPresContext());
|
2007-02-22 15:38:12 +03:00
|
|
|
}
|
|
|
|
|
2020-06-27 08:39:42 +03:00
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(SVGAFrame)
|
2009-09-12 20:49:24 +04:00
|
|
|
|
2007-02-22 15:38:12 +03:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIFrame methods
|
2009-01-19 21:31:34 +03:00
|
|
|
#ifdef DEBUG
|
2020-06-27 08:39:42 +03:00
|
|
|
void SVGAFrame::Init(nsIContent* aContent, nsContainerFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow) {
|
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");
|
|
|
|
|
2020-07-09 04:33:33 +03:00
|
|
|
SVGDisplayContainerFrame::Init(aContent, aParent, aPrevInFlow);
|
2009-01-19 21:31:34 +03:00
|
|
|
}
|
|
|
|
#endif /* DEBUG */
|
2007-02-22 15:38:12 +03:00
|
|
|
|
2020-06-27 08:39:42 +03:00
|
|
|
nsresult SVGAFrame::AttributeChanged(int32_t aNameSpaceID, nsAtom* aAttribute,
|
|
|
|
int32_t aModType) {
|
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.
|
2018-06-26 00:20:54 +03:00
|
|
|
if (aModType == dom::MutationEvent_Binding::SMIL &&
|
2017-05-06 22:32:14 +03:00
|
|
|
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;
|
2018-02-09 19:17:10 +03:00
|
|
|
}
|
2020-06-27 08:39:42 +03:00
|
|
|
|
|
|
|
} // namespace mozilla
|