2018-11-14 08:29:11 +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: */
|
|
|
|
/* 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/. */
|
|
|
|
#ifndef HTMLMarqueeElement_h___
|
|
|
|
#define HTMLMarqueeElement_h___
|
|
|
|
|
|
|
|
#include "mozilla/Attributes.h"
|
|
|
|
#include "nsGenericHTMLElement.h"
|
|
|
|
#include "nsContentUtils.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
class HTMLMarqueeElement final : public nsGenericHTMLElement {
|
|
|
|
public:
|
|
|
|
explicit HTMLMarqueeElement(already_AddRefed<dom::NodeInfo>&& aNodeInfo)
|
|
|
|
: nsGenericHTMLElement(std::move(aNodeInfo)) {}
|
|
|
|
|
Bug 1555216 - Change the signature of BindToTree to be (BindContext&, nsINode& aParentNode). r=bzbarsky
BindContext was going to have way more information at first, but then I realized
that most of the things I wanted to know were basically a flag away using the
parent node.
Still I think it's worth it, now experimenting with BindToTree will only mean
adding a field to a struct that's included from a couple cpp files, instead of a
massive pain.
I also think this is clearer, and doing this highlights quite a few
inconsistencies in our code which I've left untouched, but commented with
FIXMEs.
Steps are:
$ for file in $(rg 'nsresult BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#nsresult BindToTree(Document\* aDocument, nsIContent\* aParent,#nsresult BindToTree(BindContext\&, nsINode\& aParent)#g' $file; done
$ for file in $(rg 'nsresult BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's# nsIContent\* aBindingParent) override#override#g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#::BindToTree(Document\* aDocument, nsIContent\* aParent,#::BindToTree(BindContext\& aContext, nsINode\& aParent)#g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#nsIContent\* aBindingParent)##g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#::BindToTree(aDocument, aParent, aBindingParent)#::BindToTree(aContext, aParent)#g' $file; done
$ ./mach clang-format
Then manual fixups.
Depends on D32948
Differential Revision: https://phabricator.services.mozilla.com/D32949
2019-05-29 07:27:04 +03:00
|
|
|
nsresult BindToTree(BindContext&, nsINode& aParent) override;
|
2019-05-29 01:47:08 +03:00
|
|
|
void UnbindFromTree(bool aNullParent = true) override;
|
2018-11-18 04:23:52 +03:00
|
|
|
|
2018-11-14 08:29:11 +03:00
|
|
|
static const int kDefaultLoop = -1;
|
|
|
|
static const int kDefaultScrollAmount = 6;
|
|
|
|
static const int kDefaultScrollDelayMS = 85;
|
|
|
|
|
2018-11-08 17:46:45 +03:00
|
|
|
bool IsEventAttributeNameInternal(nsAtom* aName) override;
|
|
|
|
|
2018-11-14 08:29:11 +03:00
|
|
|
void GetBehavior(nsAString& aValue);
|
|
|
|
void SetBehavior(const nsAString& aValue, ErrorResult& aError) {
|
|
|
|
SetHTMLAttr(nsGkAtoms::behavior, aValue, aError);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GetDirection(nsAString& aValue);
|
|
|
|
void SetDirection(const nsAString& aValue, ErrorResult& aError) {
|
|
|
|
SetHTMLAttr(nsGkAtoms::direction, aValue, aError);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GetBgColor(DOMString& aBgColor) {
|
|
|
|
GetHTMLAttr(nsGkAtoms::bgcolor, aBgColor);
|
|
|
|
}
|
|
|
|
void SetBgColor(const nsAString& aBgColor, ErrorResult& aError) {
|
|
|
|
SetHTMLAttr(nsGkAtoms::bgcolor, aBgColor, aError);
|
|
|
|
}
|
|
|
|
void GetHeight(DOMString& aHeight) {
|
|
|
|
GetHTMLAttr(nsGkAtoms::height, aHeight);
|
|
|
|
}
|
|
|
|
void SetHeight(const nsAString& aHeight, ErrorResult& aError) {
|
|
|
|
SetHTMLAttr(nsGkAtoms::height, aHeight, aError);
|
|
|
|
}
|
Bug 1562257 part 4. Fix style mapping of hspace and vspace attributes to match the spec. r=mccr8
Per spec, "hspace" and "vspace" are parsed as dimension attributes and are
supported on the following elements: embed, iframe, img, object,
<input type="image">, marquee. Except no one implements this for iframe.
https://github.com/whatwg/html/issues/4742 tracks the spec changing accordingly.
As far as hspace/vpace on <table> go, Safari supports them in both quirks and
standards mode, while Chrome doesn't support them in either mode. The HTML spec
doesn't have them supported at all, and neither does the quirks mode spec, so
I'm removing the quirks-only support we had to align with the specs and Chrome.
Differential Revision: https://phabricator.services.mozilla.com/D36375
--HG--
extra : moz-landing-system : lando
2019-06-29 02:51:43 +03:00
|
|
|
uint32_t Hspace() {
|
|
|
|
return GetDimensionAttrAsUnsignedInt(nsGkAtoms::hspace, 0);
|
|
|
|
}
|
2018-11-14 08:29:11 +03:00
|
|
|
void SetHspace(uint32_t aValue, ErrorResult& aError) {
|
|
|
|
SetUnsignedIntAttr(nsGkAtoms::hspace, aValue, 0, aError);
|
|
|
|
}
|
|
|
|
int32_t Loop() {
|
|
|
|
int loop = GetIntAttr(nsGkAtoms::loop, kDefaultLoop);
|
|
|
|
if (loop <= 0) {
|
|
|
|
loop = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return loop;
|
|
|
|
}
|
|
|
|
void SetLoop(int32_t aValue, ErrorResult& aError) {
|
|
|
|
if (aValue == -1 || aValue > 0) {
|
|
|
|
SetHTMLIntAttr(nsGkAtoms::loop, aValue, aError);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
uint32_t ScrollAmount() {
|
|
|
|
return GetUnsignedIntAttr(nsGkAtoms::scrollamount, kDefaultScrollAmount);
|
|
|
|
}
|
|
|
|
void SetScrollAmount(uint32_t aValue, ErrorResult& aError) {
|
|
|
|
SetUnsignedIntAttr(nsGkAtoms::scrollamount, aValue, kDefaultScrollAmount,
|
|
|
|
aError);
|
|
|
|
}
|
|
|
|
uint32_t ScrollDelay() {
|
|
|
|
return GetUnsignedIntAttr(nsGkAtoms::scrolldelay, kDefaultScrollDelayMS);
|
|
|
|
}
|
|
|
|
void SetScrollDelay(uint32_t aValue, ErrorResult& aError) {
|
|
|
|
SetUnsignedIntAttr(nsGkAtoms::scrolldelay, aValue, kDefaultScrollDelayMS,
|
|
|
|
aError);
|
|
|
|
}
|
|
|
|
bool TrueSpeed() const { return GetBoolAttr(nsGkAtoms::truespeed); }
|
|
|
|
void SetTrueSpeed(bool aValue, ErrorResult& aError) {
|
|
|
|
SetHTMLBoolAttr(nsGkAtoms::truespeed, aValue, aError);
|
|
|
|
}
|
|
|
|
void GetWidth(DOMString& aWidth) { GetHTMLAttr(nsGkAtoms::width, aWidth); }
|
|
|
|
void SetWidth(const nsAString& aWidth, ErrorResult& aError) {
|
|
|
|
SetHTMLAttr(nsGkAtoms::width, aWidth, aError);
|
|
|
|
}
|
Bug 1562257 part 4. Fix style mapping of hspace and vspace attributes to match the spec. r=mccr8
Per spec, "hspace" and "vspace" are parsed as dimension attributes and are
supported on the following elements: embed, iframe, img, object,
<input type="image">, marquee. Except no one implements this for iframe.
https://github.com/whatwg/html/issues/4742 tracks the spec changing accordingly.
As far as hspace/vpace on <table> go, Safari supports them in both quirks and
standards mode, while Chrome doesn't support them in either mode. The HTML spec
doesn't have them supported at all, and neither does the quirks mode spec, so
I'm removing the quirks-only support we had to align with the specs and Chrome.
Differential Revision: https://phabricator.services.mozilla.com/D36375
--HG--
extra : moz-landing-system : lando
2019-06-29 02:51:43 +03:00
|
|
|
uint32_t Vspace() {
|
|
|
|
return GetDimensionAttrAsUnsignedInt(nsGkAtoms::vspace, 0);
|
|
|
|
}
|
2018-11-14 08:29:11 +03:00
|
|
|
void SetVspace(uint32_t aValue, ErrorResult& aError) {
|
|
|
|
SetUnsignedIntAttr(nsGkAtoms::vspace, aValue, 0, aError);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Start();
|
|
|
|
void Stop();
|
|
|
|
|
|
|
|
bool ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
|
|
|
|
const nsAString& aValue,
|
|
|
|
nsIPrincipal* aMaybeScriptedPrincipal,
|
|
|
|
nsAttrValue& aResult) override;
|
2018-11-18 04:23:52 +03:00
|
|
|
virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,
|
|
|
|
const nsAttrValue* aValue,
|
|
|
|
const nsAttrValue* aOldValue,
|
|
|
|
nsIPrincipal* aMaybeScriptedPrincipal,
|
|
|
|
bool aNotify) override;
|
2018-11-14 08:29:11 +03:00
|
|
|
NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom* aAttribute) const override;
|
|
|
|
nsMapRuleToAttributesFunc GetAttributeMappingFunction() const override;
|
|
|
|
|
|
|
|
nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual ~HTMLMarqueeElement();
|
|
|
|
|
|
|
|
JSObject* WrapNode(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
static void MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|
|
|
MappedDeclarations&);
|
2018-11-18 04:23:52 +03:00
|
|
|
|
|
|
|
void DispatchEventToShadowRoot(const nsAString& aEventTypeArg);
|
2018-11-14 08:29:11 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif /* HTMLMarqueeElement_h___ */
|