зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1425874
- Implement HTMLMarqueeElement r=bzbarsky
This adds a new class for the marquee tag, instead of overloading HTMLDivElement. It removes some of the XBL that was used to expose properties to web content. Differential Revision: https://phabricator.services.mozilla.com/D3824 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
dfc58833c0
Коммит
35b0511c9a
|
@ -34,25 +34,8 @@ HTMLDivElement::ParseAttribute(int32_t aNamespaceID,
|
|||
nsIPrincipal* aMaybeScriptedPrincipal,
|
||||
nsAttrValue& aResult)
|
||||
{
|
||||
if (aNamespaceID == kNameSpaceID_None) {
|
||||
if (mNodeInfo->Equals(nsGkAtoms::marquee)) {
|
||||
if ((aAttribute == nsGkAtoms::width) ||
|
||||
(aAttribute == nsGkAtoms::height)) {
|
||||
return aResult.ParseSpecialIntValue(aValue);
|
||||
}
|
||||
if (aAttribute == nsGkAtoms::bgcolor) {
|
||||
return aResult.ParseColor(aValue);
|
||||
}
|
||||
if ((aAttribute == nsGkAtoms::hspace) ||
|
||||
(aAttribute == nsGkAtoms::vspace)) {
|
||||
return aResult.ParseIntWithBounds(aValue, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (mNodeInfo->Equals(nsGkAtoms::div) &&
|
||||
aAttribute == nsGkAtoms::align) {
|
||||
return ParseDivAlignValue(aValue, aResult);
|
||||
}
|
||||
if (aNamespaceID == kNameSpaceID_None && aAttribute == nsGkAtoms::align) {
|
||||
return ParseDivAlignValue(aValue, aResult);
|
||||
}
|
||||
|
||||
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
|
||||
|
@ -67,47 +50,20 @@ HTMLDivElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|||
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aDecls);
|
||||
}
|
||||
|
||||
static void
|
||||
MapMarqueeAttributesIntoRule(const nsMappedAttributes* aAttributes, MappedDeclarations& aDecls)
|
||||
{
|
||||
nsGenericHTMLElement::MapImageMarginAttributeInto(aAttributes, aDecls);
|
||||
nsGenericHTMLElement::MapImageSizeAttributesInto(aAttributes, aDecls);
|
||||
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aDecls);
|
||||
nsGenericHTMLElement::MapBGColorInto(aAttributes, aDecls);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(bool)
|
||||
HTMLDivElement::IsAttributeMapped(const nsAtom* aAttribute) const
|
||||
{
|
||||
if (mNodeInfo->Equals(nsGkAtoms::div)) {
|
||||
static const MappedAttributeEntry* const map[] = {
|
||||
sDivAlignAttributeMap,
|
||||
sCommonAttributeMap
|
||||
};
|
||||
return FindAttributeDependence(aAttribute, map);
|
||||
}
|
||||
if (mNodeInfo->Equals(nsGkAtoms::marquee)) {
|
||||
static const MappedAttributeEntry* const map[] = {
|
||||
sImageMarginSizeAttributeMap,
|
||||
sBackgroundColorAttributeMap,
|
||||
sCommonAttributeMap
|
||||
};
|
||||
return FindAttributeDependence(aAttribute, map);
|
||||
}
|
||||
|
||||
return nsGenericHTMLElement::IsAttributeMapped(aAttribute);
|
||||
static const MappedAttributeEntry* const map[] = {
|
||||
sDivAlignAttributeMap,
|
||||
sCommonAttributeMap
|
||||
};
|
||||
return FindAttributeDependence(aAttribute, map);
|
||||
}
|
||||
|
||||
nsMapRuleToAttributesFunc
|
||||
HTMLDivElement::GetAttributeMappingFunction() const
|
||||
{
|
||||
if (mNodeInfo->Equals(nsGkAtoms::div)) {
|
||||
return &MapAttributesIntoRule;
|
||||
}
|
||||
if (mNodeInfo->Equals(nsGkAtoms::marquee)) {
|
||||
return &MapMarqueeAttributesIntoRule;
|
||||
}
|
||||
return nsGenericHTMLElement::GetAttributeMappingFunction();
|
||||
return &MapAttributesIntoRule;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
|
|
|
@ -18,6 +18,7 @@ public:
|
|||
explicit HTMLDivElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
|
||||
: nsGenericHTMLElement(std::move(aNodeInfo))
|
||||
{
|
||||
MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::div), "HTMLDivElement should be a div");
|
||||
}
|
||||
|
||||
void GetAlign(DOMString& aAlign)
|
||||
|
|
|
@ -0,0 +1,161 @@
|
|||
/* -*- 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/. */
|
||||
|
||||
#include "mozilla/dom/HTMLMarqueeElement.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsMappedAttributes.h"
|
||||
#include "mozilla/dom/HTMLMarqueeElementBinding.h"
|
||||
#include "mozilla/dom/CustomEvent.h"
|
||||
// This is to pick up the definition of FunctionStringCallback:
|
||||
#include "mozilla/dom/DataTransferItemBinding.h"
|
||||
|
||||
NS_IMPL_NS_NEW_HTML_ELEMENT(Marquee)
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
HTMLMarqueeElement::~HTMLMarqueeElement()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_INHERITED(HTMLMarqueeElement, nsGenericHTMLElement,
|
||||
mStartStopCallback)
|
||||
|
||||
NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED_0(HTMLMarqueeElement, nsGenericHTMLElement)
|
||||
|
||||
|
||||
NS_IMPL_ELEMENT_CLONE(HTMLMarqueeElement)
|
||||
|
||||
static const nsAttrValue::EnumTable kBehaviorTable[] = {
|
||||
{ "scroll", 1 },
|
||||
{ "slide", 2 },
|
||||
{ "alternate", 3 },
|
||||
{ nullptr, 0 }
|
||||
};
|
||||
|
||||
// Default behavior value is "scroll".
|
||||
static const nsAttrValue::EnumTable* kDefaultBehavior = &kBehaviorTable[0];
|
||||
|
||||
static const nsAttrValue::EnumTable kDirectionTable[] = {
|
||||
{ "left", 1 },
|
||||
{ "right", 2 },
|
||||
{ "up", 3 },
|
||||
{ "down", 4 },
|
||||
{ nullptr, 0 }
|
||||
};
|
||||
|
||||
// Default direction value is "left".
|
||||
static const nsAttrValue::EnumTable* kDefaultDirection = &kDirectionTable[0];
|
||||
|
||||
JSObject*
|
||||
HTMLMarqueeElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
|
||||
{
|
||||
return dom::HTMLMarqueeElement_Binding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
void
|
||||
HTMLMarqueeElement::SetStartStopCallback(FunctionStringCallback* aCallback)
|
||||
{
|
||||
mStartStopCallback = aCallback;
|
||||
}
|
||||
|
||||
void
|
||||
HTMLMarqueeElement::GetBehavior(nsAString& aValue)
|
||||
{
|
||||
GetEnumAttr(nsGkAtoms::behavior, kDefaultBehavior->tag, aValue);
|
||||
}
|
||||
|
||||
void
|
||||
HTMLMarqueeElement::GetDirection(nsAString& aValue)
|
||||
{
|
||||
GetEnumAttr(nsGkAtoms::direction, kDefaultDirection->tag, aValue);
|
||||
}
|
||||
|
||||
bool
|
||||
HTMLMarqueeElement::ParseAttribute(int32_t aNamespaceID,
|
||||
nsAtom* aAttribute,
|
||||
const nsAString& aValue,
|
||||
nsIPrincipal* aMaybeScriptedPrincipal,
|
||||
nsAttrValue& aResult)
|
||||
{
|
||||
if (aNamespaceID == kNameSpaceID_None) {
|
||||
if ((aAttribute == nsGkAtoms::width) ||
|
||||
(aAttribute == nsGkAtoms::height)) {
|
||||
return aResult.ParseSpecialIntValue(aValue);
|
||||
}
|
||||
if (aAttribute == nsGkAtoms::bgcolor) {
|
||||
return aResult.ParseColor(aValue);
|
||||
}
|
||||
if (aAttribute == nsGkAtoms::behavior) {
|
||||
return aResult.ParseEnumValue(aValue, kBehaviorTable, false, kDefaultBehavior);
|
||||
}
|
||||
if (aAttribute == nsGkAtoms::direction) {
|
||||
return aResult.ParseEnumValue(aValue, kDirectionTable, false, kDefaultDirection);
|
||||
}
|
||||
if ((aAttribute == nsGkAtoms::hspace) ||
|
||||
(aAttribute == nsGkAtoms::vspace)) {
|
||||
return aResult.ParseIntWithBounds(aValue, 0);
|
||||
}
|
||||
|
||||
if (aAttribute == nsGkAtoms::loop) {
|
||||
return aResult.ParseIntValue(aValue);
|
||||
}
|
||||
|
||||
if (aAttribute == nsGkAtoms::scrollamount ||
|
||||
aAttribute == nsGkAtoms::scrolldelay) {
|
||||
return aResult.ParseNonNegativeIntValue(aValue);
|
||||
}
|
||||
}
|
||||
|
||||
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
|
||||
aMaybeScriptedPrincipal, aResult);
|
||||
}
|
||||
|
||||
void
|
||||
HTMLMarqueeElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes, MappedDeclarations& aDecls)
|
||||
{
|
||||
nsGenericHTMLElement::MapImageMarginAttributeInto(aAttributes, aDecls);
|
||||
nsGenericHTMLElement::MapImageSizeAttributesInto(aAttributes, aDecls);
|
||||
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aDecls);
|
||||
nsGenericHTMLElement::MapBGColorInto(aAttributes, aDecls);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(bool)
|
||||
HTMLMarqueeElement::IsAttributeMapped(const nsAtom* aAttribute) const
|
||||
{
|
||||
static const MappedAttributeEntry* const map[] = {
|
||||
sImageMarginSizeAttributeMap,
|
||||
sBackgroundColorAttributeMap,
|
||||
sCommonAttributeMap
|
||||
};
|
||||
return FindAttributeDependence(aAttribute, map);
|
||||
}
|
||||
|
||||
nsMapRuleToAttributesFunc
|
||||
HTMLMarqueeElement::GetAttributeMappingFunction() const
|
||||
{
|
||||
return &MapAttributesIntoRule;
|
||||
}
|
||||
|
||||
void
|
||||
HTMLMarqueeElement::Start()
|
||||
{
|
||||
if (mStartStopCallback) {
|
||||
mStartStopCallback->Call(NS_LITERAL_STRING("start"));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
HTMLMarqueeElement::Stop()
|
||||
{
|
||||
if (mStartStopCallback) {
|
||||
mStartStopCallback->Call(NS_LITERAL_STRING("stop"));
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
|
@ -0,0 +1,155 @@
|
|||
/* -*- 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 FunctionStringCallback;
|
||||
|
||||
class HTMLMarqueeElement final : public nsGenericHTMLElement
|
||||
{
|
||||
public:
|
||||
explicit HTMLMarqueeElement(already_AddRefed<dom::NodeInfo>&& aNodeInfo)
|
||||
: nsGenericHTMLElement(std::move(aNodeInfo))
|
||||
{
|
||||
}
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLMarqueeElement,
|
||||
nsGenericHTMLElement)
|
||||
|
||||
static const int kDefaultLoop = -1;
|
||||
static const int kDefaultScrollAmount = 6;
|
||||
static const int kDefaultScrollDelayMS = 85;
|
||||
|
||||
void SetStartStopCallback(FunctionStringCallback* aCallback);
|
||||
|
||||
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);
|
||||
}
|
||||
uint32_t Hspace()
|
||||
{
|
||||
return GetIntAttr(nsGkAtoms::hspace, 0);
|
||||
}
|
||||
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);
|
||||
}
|
||||
uint32_t Vspace()
|
||||
{
|
||||
return GetIntAttr(nsGkAtoms::vspace, 0);
|
||||
}
|
||||
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;
|
||||
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:
|
||||
RefPtr<FunctionStringCallback> mStartStopCallback;
|
||||
static void MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
||||
MappedDeclarations&);
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif /* HTMLMarqueeElement_h___ */
|
|
@ -7,6 +7,10 @@
|
|||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/HTMLMediaElement.h"
|
||||
#include "mozilla/dom/HTMLTrackElement.h"
|
||||
#ifdef XP_WIN
|
||||
// HTMLTrackElement.webidl defines ERROR, but so does windows.h:
|
||||
#undef ERROR
|
||||
#endif
|
||||
#include "mozilla/dom/HTMLTrackElementBinding.h"
|
||||
#include "mozilla/dom/HTMLUnknownElement.h"
|
||||
#include "nsIContentPolicy.h"
|
||||
|
|
|
@ -87,6 +87,7 @@ EXPORTS.mozilla.dom += [
|
|||
'HTMLLIElement.h',
|
||||
'HTMLLinkElement.h',
|
||||
'HTMLMapElement.h',
|
||||
'HTMLMarqueeElement.h',
|
||||
'HTMLMediaElement.h',
|
||||
'HTMLMenuElement.h',
|
||||
'HTMLMenuItemElement.h',
|
||||
|
@ -167,6 +168,7 @@ UNIFIED_SOURCES += [
|
|||
'HTMLLIElement.cpp',
|
||||
'HTMLLinkElement.cpp',
|
||||
'HTMLMapElement.cpp',
|
||||
'HTMLMarqueeElement.cpp',
|
||||
'HTMLMediaElement.cpp',
|
||||
'HTMLMenuElement.cpp',
|
||||
'HTMLMenuItemElement.cpp',
|
||||
|
|
|
@ -1308,6 +1308,7 @@ NS_DECLARE_NS_NEW_HTML_ELEMENT(LI)
|
|||
NS_DECLARE_NS_NEW_HTML_ELEMENT(Label)
|
||||
NS_DECLARE_NS_NEW_HTML_ELEMENT(Legend)
|
||||
NS_DECLARE_NS_NEW_HTML_ELEMENT(Link)
|
||||
NS_DECLARE_NS_NEW_HTML_ELEMENT(Marquee)
|
||||
NS_DECLARE_NS_NEW_HTML_ELEMENT(Map)
|
||||
NS_DECLARE_NS_NEW_HTML_ELEMENT(Menu)
|
||||
NS_DECLARE_NS_NEW_HTML_ELEMENT(MenuItem)
|
||||
|
|
|
@ -150,7 +150,7 @@ HTML_TAG("listing", "Pre");
|
|||
HTML_TAG("main", "");
|
||||
HTML_TAG("map", "Map");
|
||||
HTML_TAG("mark", "");
|
||||
HTML_TAG("marquee", "Div");
|
||||
HTML_TAG("marquee", "Marquee");
|
||||
HTML_TAG("menu", "Menu");
|
||||
HTML_TAG("meta", "Meta");
|
||||
HTML_TAG("meter", "Meter");
|
||||
|
|
|
@ -42,32 +42,19 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1160342
|
|||
|
||||
x.behavior = 'alternate';
|
||||
is(x.behavior, "alternate", "Wrong behavior value");
|
||||
try {
|
||||
x.behavior = 'invalid';
|
||||
todo_is(false, true, "marquee.behavior = 'invalid' should throw");
|
||||
} catch(e) {
|
||||
ok(true, "Exception was raised");
|
||||
}
|
||||
is(x.behavior, "alternate", "Wrong behavior value");
|
||||
is(x.getAttribute('behavior'), "alternate", "Wrong behavior attribute");
|
||||
x.behavior = 'invalid';
|
||||
is(x.behavior, "scroll", "Wrong behavior value");
|
||||
is(x.getAttribute('behavior'), "invalid", "Wrong behavior attribute");
|
||||
x.behavior = 'Slide';
|
||||
is(x.behavior, "slide", "Wrong behavior value");
|
||||
is(x.getAttribute('behavior'), "slide", "Wrong behavior attribute");
|
||||
try {
|
||||
x.behavior = 'invalid';
|
||||
todo_is(false, true, "marquee.behavior = 'invalid' should throw");
|
||||
} catch(e) {
|
||||
ok(true, "Exception was raised");
|
||||
}
|
||||
try {
|
||||
x.behavior = null;
|
||||
x.behavior = undefined;
|
||||
todo_is(false, true, "marquee.behavior = 'invalid' should throw");
|
||||
} catch(e) {
|
||||
ok(true, "Exception was raised");
|
||||
}
|
||||
is(x.behavior, "slide", "Wrong behavior value");
|
||||
is(x.getAttribute('behavior'), "slide", "Wrong behavior attribute");
|
||||
is(x.getAttribute('behavior'), "Slide", "Wrong behavior attribute");
|
||||
x.behavior = 'invalid';
|
||||
is(x.behavior, "scroll", "Wrong behavior value");
|
||||
x.behavior = null;
|
||||
is(x.behavior, "scroll", "Wrong behavior value");
|
||||
x.behavior = undefined;
|
||||
is(x.behavior, "scroll", "Wrong behavior value");
|
||||
is(x.getAttribute('behavior'), 'undefined', "Wrong behavior attribute");
|
||||
// This doesn't work in Mozilla due to chrome XBL security issues
|
||||
x.behavior = { toString: function _toString() { return "scroll"} }
|
||||
is(x.behavior, x.getAttribute('behavior'), "Wrong behavior value");
|
||||
|
@ -86,7 +73,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1160342
|
|||
x.setAttribute('loop', '1000');
|
||||
is(x.loop, 1000, "Wrong loop value");
|
||||
x.setAttribute('loop', '-0.123');
|
||||
is(x.loop, 1000, "Wrong loop value");
|
||||
is(x.loop, -1, "Wrong loop value");
|
||||
x.setAttribute('loop', '-1.123');
|
||||
is(x.loop, -1, "Wrong loop value");
|
||||
x.setAttribute('loop', '-1');
|
||||
|
@ -132,7 +119,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1160342
|
|||
is(x.getAttribute('loop'), "100", "Wrong loop attribute");
|
||||
try {
|
||||
x.loop = -0.123;
|
||||
todo_is(false, true, "marquee.loop = null should throw");
|
||||
todo_is(false, true, "marquee.loop = -0.123 should throw");
|
||||
} catch(e) {
|
||||
ok(true, "Exception was raised");
|
||||
}
|
||||
|
@ -140,7 +127,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1160342
|
|||
is(x.getAttribute('loop'), "100", "Wrong loop attribute");
|
||||
try {
|
||||
x.loop = 0;
|
||||
todo_is(false, true, "marquee.loop = null should throw");
|
||||
todo_is(false, true, "marquee.loop = 0 should throw");
|
||||
} catch(e) {
|
||||
ok(true, "Exception was raised");
|
||||
}
|
||||
|
@ -159,7 +146,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1160342
|
|||
x.setAttribute('scrollAmount', '1000');
|
||||
is(x.scrollAmount, 1000, "Wrong scrollAmount value");
|
||||
x.setAttribute('scrollAmount', '-1');
|
||||
is(x.scrollAmount, 1000, "Wrong scrollAmount value");
|
||||
is(x.scrollAmount, 6, "Wrong scrollAmount value");
|
||||
x.setAttribute('scrollAmount', '999');
|
||||
is(x.scrollAmount, 999, "Wrong scrollAmount value");
|
||||
x.setAttribute('scrollAmount', '');
|
||||
|
@ -171,26 +158,20 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1160342
|
|||
|
||||
x.scrollAmount = 1;
|
||||
is(x.scrollAmount, 1, "Wrong scrollAmount value");
|
||||
is(x.getAttribute('scrollamount'), "1", "Wrong scrolldelay attribute");
|
||||
try {
|
||||
x.scrollAmount = -2;
|
||||
todo_is(false, true, "marquee.scrollAmount = -2 should throw");
|
||||
} catch(e) {
|
||||
ok(true, "Exception was raised");
|
||||
}
|
||||
is(x.scrollAmount, 1, "Wrong scrollAmount value");
|
||||
is(x.getAttribute('scrollamount'), "1", "Wrong scrolldelay attribute");
|
||||
is(x.getAttribute('scrollamount'), "1", "Wrong scrollamount attribute");
|
||||
x.scrollAmount = -2;
|
||||
is(x.scrollAmount, 6, "Wrong scrollAmount value");
|
||||
is(x.getAttribute('scrollamount'), "6", "Wrong scrollamount attribute");
|
||||
x.scrollAmount = 'invalid';
|
||||
is(x.scrollAmount, 0, "Wrong scrollAmount value");
|
||||
is(x.getAttribute('scrollamount'), "0", "Wrong scrolldelay attribute");
|
||||
is(x.getAttribute('scrollamount'), "0", "Wrong scrollamount attribute");
|
||||
x.scrollAmount = 1;
|
||||
x.scrollAmount = null;
|
||||
is(x.scrollAmount, 0, "Wrong scrollAmount value");
|
||||
is(x.getAttribute('scrollamount'), "0", "Wrong scrolldelay attribute");
|
||||
is(x.getAttribute('scrollamount'), "0", "Wrong scrollamount attribute");
|
||||
x.scrollAmount = '2';
|
||||
is(x.scrollAmount, 2, "Wrong scrollAmount value");
|
||||
is(x.getAttribute('scrollamount'), "2", "Wrong scrolldelay attribute");
|
||||
|
||||
is(x.getAttribute('scrollamount'), "2", "Wrong scrollamount attribute");
|
||||
|
||||
is(x.scrollDelay, 85, "Wrong scrollDelay value");
|
||||
x.setAttribute('scrollDelay', '1');
|
||||
|
@ -204,7 +185,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1160342
|
|||
x.setAttribute('scrollDelay', '1000');
|
||||
is(x.scrollDelay, 1000, "Wrong scrollDelay value");
|
||||
x.setAttribute('scrollDelay', '-1');
|
||||
is(x.scrollDelay, 1000, "Wrong scrollDelay value");
|
||||
is(x.scrollDelay, 85, "Wrong scrollDelay value");
|
||||
x.setAttribute('scrollDelay', '');
|
||||
is(x.scrollDelay, 85, "Wrong scrollDelay value");
|
||||
x.setAttribute('scrollDelay', '1000');
|
||||
|
@ -215,38 +196,18 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1160342
|
|||
x.scrollDelay = 100;
|
||||
is(x.scrollDelay, 100, "Wrong scrollDelay value");
|
||||
is(x.getAttribute('scrolldelay'), "100", "Wrong scrolldelay attribute");
|
||||
try {
|
||||
x.scrollDelay = -2;
|
||||
todo_is(false, true, "marquee.scrollDelay = -2 should throw");
|
||||
} catch(e) {
|
||||
ok(true, "Exception was raised");
|
||||
}
|
||||
is(x.scrollDelay, 100, "Wrong scrollDelay value");
|
||||
is(x.getAttribute('scrolldelay'), "100", "Wrong scrolldelay attribute");
|
||||
try {
|
||||
x.scrollDelay = 'invalid';
|
||||
todo_is(false, true, "marquee.scrollDelay = 'invalid' should throw");
|
||||
} catch(e) {
|
||||
ok(true, "Exception was raised");
|
||||
}
|
||||
is(x.scrollDelay, 100, "Wrong scrollDelay value");
|
||||
is(x.getAttribute('scrolldelay'), "100", "Wrong scrolldelay attribute");
|
||||
try {
|
||||
x.scrollDelay = null;
|
||||
todo_is(false, true, "marquee.scrollDelay = null should throw");
|
||||
} catch(e) {
|
||||
ok(true, "Exception was raised");
|
||||
}
|
||||
is(x.scrollDelay, 100, "Wrong scrollDelay value");
|
||||
is(x.getAttribute('scrolldelay'), "100", "Wrong scrolldelay attribute");
|
||||
try {
|
||||
x.scrollDelay = -1;
|
||||
todo_is(false, true, "marquee.scrollDelay = -1 should throw");
|
||||
} catch(e) {
|
||||
ok(true, "Exception was raised");
|
||||
}
|
||||
is(x.scrollDelay, 100, "Wrong scrollDelay value");
|
||||
is(x.getAttribute('scrolldelay'), "100", "Wrong scrolldelay attribute");
|
||||
x.scrollDelay = -2;
|
||||
is(x.scrollDelay, 85, "Wrong scrollDelay value");
|
||||
is(x.getAttribute('scrolldelay'), "85", "Wrong scrolldelay attribute");
|
||||
x.scrollDelay = 'invalid';
|
||||
is(x.scrollDelay, 0, "Wrong scrollDelay value");
|
||||
is(x.getAttribute('scrolldelay'), "0", "Wrong scrolldelay attribute");
|
||||
x.scrollDelay = null;
|
||||
is(x.scrollDelay, 0, "Wrong scrollDelay value");
|
||||
is(x.getAttribute('scrolldelay'), "0", "Wrong scrolldelay attribute");
|
||||
x.scrollDelay = -1;
|
||||
is(x.scrollDelay, 85, "Wrong scrollDelay value");
|
||||
is(x.getAttribute('scrolldelay'), "85", "Wrong scrolldelay attribute");
|
||||
x.scrollDelay = '50';
|
||||
is(x.scrollDelay, 50, "Wrong scrollDelay value");
|
||||
is(x.getAttribute('scrolldelay'), "50", "Wrong scrolldelay attribute");
|
||||
|
@ -307,22 +268,12 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1160342
|
|||
x.direction = 'down';
|
||||
is(x.direction, "down", "Wrong direction value");
|
||||
is(x.getAttribute('direction'), "down", "Wrong direction attribute");
|
||||
try {
|
||||
x.direction = 1;
|
||||
todo_is(false, true, "marquee.direction = 1 should throw");
|
||||
} catch(e) {
|
||||
ok(true, "Exception was raised");
|
||||
}
|
||||
is(x.direction, "down", "Wrong direction value");
|
||||
is(x.getAttribute('direction'), "down", "Wrong direction attribute");
|
||||
try {
|
||||
x.direction = null;
|
||||
todo_is(false, true, "marquee.direction = null should throw");
|
||||
} catch(e) {
|
||||
ok(true, "Exception was raised");
|
||||
}
|
||||
is(x.direction, "down", "Wrong direction value");
|
||||
is(x.getAttribute('direction'), "down", "Wrong direction attribute");
|
||||
x.direction = 1;
|
||||
is(x.direction, "left", "Wrong direction value");
|
||||
is(x.getAttribute('direction'), "1", "Wrong direction attribute");
|
||||
x.direction = null;
|
||||
is(x.direction, "left", "Wrong direction value");
|
||||
is(x.getAttribute('direction'), "null", "Wrong direction attribute");
|
||||
// This doesn't work in Mozilla due to chrome XBL security issues
|
||||
x.direction = { toString: function _toString() { return "right"} }
|
||||
is(x.direction, x.getAttribute('direction'), "Wrong direction value");
|
||||
|
|
|
@ -472,6 +472,8 @@ var interfaceNamesInGlobalScope =
|
|||
{name: "HTMLLinkElement", insecureContext: true},
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{name: "HTMLMapElement", insecureContext: true},
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{name: "HTMLMarqueeElement", insecureContext: true},
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{name: "HTMLMediaElement", insecureContext: true},
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
|
|
|
@ -70,7 +70,7 @@
|
|||
['main', ''],
|
||||
['map', 'Map'],
|
||||
['mark', ''],
|
||||
['marquee', 'Div'],
|
||||
['marquee', 'Marquee'],
|
||||
['menu', 'Menu'],
|
||||
['menuitem', 'MenuItem'],
|
||||
['meta', 'Meta'],
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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/.
|
||||
*
|
||||
* The origin of this IDL file is
|
||||
* https://html.spec.whatwg.org/multipage/obsolete.html#the-marquee-element
|
||||
* © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and
|
||||
* Opera Software ASA. You are granted a license to use, reproduce
|
||||
* and create derivative works of this document.
|
||||
*/
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/obsolete.html#the-marquee-element
|
||||
|
||||
[HTMLConstructor]
|
||||
interface HTMLMarqueeElement : HTMLElement {
|
||||
[CEReactions, SetterThrows] attribute DOMString behavior;
|
||||
[CEReactions, SetterThrows] attribute DOMString bgColor;
|
||||
[CEReactions, SetterThrows] attribute DOMString direction;
|
||||
[CEReactions, SetterThrows] attribute DOMString height;
|
||||
[CEReactions, SetterThrows] attribute unsigned long hspace;
|
||||
[CEReactions, SetterThrows] attribute long loop;
|
||||
[CEReactions, SetterThrows] attribute unsigned long scrollAmount;
|
||||
[CEReactions, SetterThrows] attribute unsigned long scrollDelay;
|
||||
[CEReactions, SetterThrows] attribute boolean trueSpeed;
|
||||
[CEReactions, SetterThrows] attribute unsigned long vspace;
|
||||
[CEReactions, SetterThrows] attribute DOMString width;
|
||||
|
||||
//attribute EventHandler onbounce;
|
||||
//attribute EventHandler onfinish;
|
||||
//attribute EventHandler onstart;
|
||||
|
||||
void start();
|
||||
void stop();
|
||||
|
||||
[Func="IsChromeOrXBL"]
|
||||
void setStartStopCallback(FunctionStringCallback? callback);
|
||||
};
|
||||
|
|
@ -561,6 +561,7 @@ WEBIDL_FILES = [
|
|||
'HTMLLIElement.webidl',
|
||||
'HTMLLinkElement.webidl',
|
||||
'HTMLMapElement.webidl',
|
||||
'HTMLMarqueeElement.webidl',
|
||||
'HTMLMediaElement.webidl',
|
||||
'HTMLMenuElement.webidl',
|
||||
'HTMLMenuItemElement.webidl',
|
||||
|
|
|
@ -16,125 +16,6 @@
|
|||
<stylesheet src="chrome://xbl-marquee/content/xbl-marquee.css"/>
|
||||
</resources>
|
||||
<implementation>
|
||||
|
||||
<property name="scrollAmount" exposeToUntrustedContent="true">
|
||||
<getter>
|
||||
<![CDATA[
|
||||
this._mutationActor(this._mutationObserver.takeRecords());
|
||||
return this._scrollAmount;
|
||||
]]>
|
||||
</getter>
|
||||
<setter>
|
||||
<![CDATA[
|
||||
var val = parseInt(val);
|
||||
if (val < 0) {
|
||||
return;
|
||||
}
|
||||
if (isNaN(val)) {
|
||||
val = 0;
|
||||
}
|
||||
this.setAttribute("scrollamount", val);
|
||||
]]>
|
||||
</setter>
|
||||
</property>
|
||||
|
||||
<property name="scrollDelay" exposeToUntrustedContent="true">
|
||||
<getter>
|
||||
<![CDATA[
|
||||
this._mutationActor(this._mutationObserver.takeRecords());
|
||||
var val = parseInt(this.getAttribute("scrolldelay"));
|
||||
|
||||
if (val <= 0 || isNaN(val)) {
|
||||
return this._scrollDelay;
|
||||
}
|
||||
|
||||
return val;
|
||||
]]>
|
||||
</getter>
|
||||
<setter>
|
||||
var val = parseInt(val);
|
||||
if (val > 0 ) {
|
||||
this.setAttribute("scrolldelay", val);
|
||||
}
|
||||
</setter>
|
||||
</property>
|
||||
|
||||
<property name="trueSpeed" exposeToUntrustedContent="true">
|
||||
<getter>
|
||||
<![CDATA[
|
||||
if (!this.hasAttribute("truespeed")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
]]>
|
||||
</getter>
|
||||
<setter>
|
||||
<![CDATA[
|
||||
if (val) {
|
||||
this.setAttribute("truespeed", "");
|
||||
} else {
|
||||
this.removeAttribute('truespeed');
|
||||
}
|
||||
]]>
|
||||
</setter>
|
||||
</property>
|
||||
|
||||
<property name="direction" exposeToUntrustedContent="true">
|
||||
<getter>
|
||||
this._mutationActor(this._mutationObserver.takeRecords());
|
||||
return this._direction;
|
||||
</getter>
|
||||
<setter>
|
||||
<![CDATA[
|
||||
if (typeof val == 'string') {
|
||||
val = val.toLowerCase();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
if (val != 'left' && val != 'right' && val != 'up' && val != 'down') {
|
||||
val = 'left';
|
||||
}
|
||||
|
||||
this.setAttribute("direction", val);
|
||||
]]>
|
||||
</setter>
|
||||
</property>
|
||||
|
||||
<property name="behavior" exposeToUntrustedContent="true">
|
||||
<getter>
|
||||
this._mutationActor(this._mutationObserver.takeRecords());
|
||||
return this._behavior;
|
||||
</getter>
|
||||
<setter>
|
||||
if (typeof val == 'string') {
|
||||
val = val.toLowerCase();
|
||||
}
|
||||
if (val == "alternate" || val == "slide" || val == 'scroll') {
|
||||
this.setAttribute("behavior", val);
|
||||
}
|
||||
</setter>
|
||||
</property>
|
||||
|
||||
|
||||
<property name="loop" exposeToUntrustedContent="true">
|
||||
<getter>
|
||||
<![CDATA[
|
||||
this._mutationActor(this._mutationObserver.takeRecords());
|
||||
return this._loop;
|
||||
]]>
|
||||
</getter>
|
||||
<setter>
|
||||
<![CDATA[
|
||||
var val = parseInt(val);
|
||||
if (val == -1 || val > 0) {
|
||||
this.setAttribute("loop", val);
|
||||
}
|
||||
]]>
|
||||
</setter>
|
||||
</property>
|
||||
|
||||
|
||||
<property name="onstart" exposeToUntrustedContent="true">
|
||||
<getter>
|
||||
return this.getAttribute("onstart");
|
||||
|
@ -173,102 +54,38 @@
|
|||
onget="return document.getAnonymousElementByAttribute(this, 'class', 'innerDiv');"
|
||||
/>
|
||||
|
||||
<property name="height" exposeToUntrustedContent="true"
|
||||
onget="return this.getAttribute('height');"
|
||||
onset="this.setAttribute('height', val);"
|
||||
/>
|
||||
|
||||
<property name="width" exposeToUntrustedContent="true"
|
||||
onget="return this.getAttribute('width');"
|
||||
onset="this.setAttribute('width', val);"
|
||||
/>
|
||||
|
||||
<method name="_set_scrollDelay">
|
||||
<parameter name="aValue"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
aValue = parseInt(aValue);
|
||||
if (aValue <= 0) {
|
||||
return;
|
||||
} else if (isNaN(aValue)) {
|
||||
this._scrollDelay = 85;
|
||||
} else if (aValue < 60) {
|
||||
if (this.trueSpeed == true) {
|
||||
this._scrollDelay = aValue;
|
||||
} else {
|
||||
this._scrollDelay = 60;
|
||||
}
|
||||
} else {
|
||||
this._scrollDelay = aValue;
|
||||
}
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="_set_scrollAmount">
|
||||
<parameter name="aValue"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
aValue = parseInt(aValue);
|
||||
if (isNaN(aValue)) {
|
||||
this._scrollAmount = 6;
|
||||
} else if (aValue < 0) {
|
||||
return;
|
||||
} else {
|
||||
this._scrollAmount = aValue;
|
||||
}
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="_set_behavior">
|
||||
<parameter name="aValue"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
if (typeof aValue == 'string') {
|
||||
aValue = aValue.toLowerCase();
|
||||
}
|
||||
if (aValue != 'alternate' && aValue != 'slide' && aValue != 'scroll') {
|
||||
this._behavior = 'scroll';
|
||||
} else {
|
||||
this._behavior = aValue;
|
||||
}
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="_set_direction">
|
||||
<parameter name="aValue"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
if (typeof aValue == 'string') {
|
||||
aValue = aValue.toLowerCase();
|
||||
}
|
||||
if (aValue != 'left' && aValue != 'right' && aValue != 'up' && aValue != 'down') {
|
||||
aValue = 'left';
|
||||
}
|
||||
|
||||
if (aValue != this._direction) {
|
||||
this.startNewDirection = true;
|
||||
}
|
||||
this._direction = aValue;
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="_set_loop">
|
||||
<parameter name="aValue"/>
|
||||
<body>
|
||||
<property name="scrollDelayWithTruespeed">
|
||||
<getter>
|
||||
<![CDATA[
|
||||
var aValue = parseInt(aValue);
|
||||
if (aValue == 0) {
|
||||
return;
|
||||
if (this.scrollDelay < 60 && !this.trueSpeed) {
|
||||
return 60;
|
||||
}
|
||||
if (isNaN(aValue) || aValue <= -1) {
|
||||
aValue = -1;
|
||||
}
|
||||
this._loop = aValue;
|
||||
return this.scrollDelay;
|
||||
]]>
|
||||
</getter>
|
||||
</property>
|
||||
|
||||
<method name="doStart">
|
||||
<body>
|
||||
<![CDATA[
|
||||
if (this.runId == 0) {
|
||||
var lambda = () => this._doMove(false);
|
||||
this.runId = window.setTimeout(lambda, this.scrollDelayWithTruespeed - this._deltaStartStop);
|
||||
this._deltaStartStop = 0;
|
||||
}
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
<method name="doStop">
|
||||
<body>
|
||||
<![CDATA[
|
||||
if (this.runId != 0) {
|
||||
this._deltaStartStop = Date.now()- this._lastMoveDate;
|
||||
clearTimeout(this.runId);
|
||||
}
|
||||
|
||||
this.runId = 0;
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
|
@ -352,45 +169,20 @@
|
|||
</body>
|
||||
</method>
|
||||
|
||||
<method name="start" exposeToUntrustedContent="true">
|
||||
<body>
|
||||
<![CDATA[
|
||||
if (this.runId == 0) {
|
||||
var myThis = this;
|
||||
var lambda = function myTimeOutFunction(){myThis._doMove(false);}
|
||||
this.runId = window.setTimeout(lambda, this._scrollDelay - this._deltaStartStop);
|
||||
this._deltaStartStop = 0;
|
||||
}
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="stop" exposeToUntrustedContent="true">
|
||||
<body>
|
||||
<![CDATA[
|
||||
if (this.runId != 0) {
|
||||
this._deltaStartStop = Date.now()- this._lastMoveDate;
|
||||
clearTimeout(this.runId);
|
||||
}
|
||||
|
||||
this.runId = 0;
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="_doMove">
|
||||
<parameter name="aResetPosition"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
this._lastMoveDate = Date.now();
|
||||
|
||||
//startNewDirection is true at first load and whenever the direction is changed
|
||||
if (this.startNewDirection) {
|
||||
this.startNewDirection = false; //we only want this to run once every scroll direction change
|
||||
// invalidateCache is true at first load and whenever an attribute
|
||||
// is changed
|
||||
if (this.invalidateCache) {
|
||||
this.invalidateCache = false; //we only want this to run once every scroll direction change
|
||||
|
||||
var corrvalue = 0;
|
||||
|
||||
switch (this._direction)
|
||||
switch (this._currentDirection)
|
||||
{
|
||||
case "up":
|
||||
var height = document.defaultView.getComputedStyle(this).height;
|
||||
|
@ -400,8 +192,8 @@
|
|||
}
|
||||
this.innerDiv.style.padding = height + " 0";
|
||||
this.dirsign = 1;
|
||||
this.startAt = (this._behavior == 'alternate') ? (this.originalHeight - corrvalue) : 0;
|
||||
this.stopAt = (this._behavior == 'alternate' || this._behavior == 'slide') ?
|
||||
this.startAt = (this.behavior == 'alternate') ? (this.originalHeight - corrvalue) : 0;
|
||||
this.stopAt = (this.behavior == 'alternate' || this.behavior == 'slide') ?
|
||||
(parseInt(height) + corrvalue) : (this.originalHeight + parseInt(height));
|
||||
break;
|
||||
|
||||
|
@ -413,9 +205,9 @@
|
|||
}
|
||||
this.innerDiv.style.padding = height + " 0";
|
||||
this.dirsign = -1;
|
||||
this.startAt = (this._behavior == 'alternate') ?
|
||||
this.startAt = (this.behavior == 'alternate') ?
|
||||
(parseInt(height) + corrvalue) : (this.originalHeight + parseInt(height));
|
||||
this.stopAt = (this._behavior == 'alternate' || this._behavior == 'slide') ?
|
||||
this.stopAt = (this.behavior == 'alternate' || this.behavior == 'slide') ?
|
||||
(this.originalHeight - corrvalue) : 0;
|
||||
break;
|
||||
|
||||
|
@ -424,9 +216,9 @@
|
|||
corrvalue = this.innerDiv.offsetWidth - this.outerDiv.offsetWidth;
|
||||
}
|
||||
this.dirsign = -1;
|
||||
this.stopAt = (this._behavior == 'alternate' || this._behavior == 'slide') ?
|
||||
this.stopAt = (this.behavior == 'alternate' || this.behavior == 'slide') ?
|
||||
(this.innerDiv.offsetWidth - corrvalue) : 0;
|
||||
this.startAt = this.outerDiv.offsetWidth + ((this._behavior == 'alternate') ?
|
||||
this.startAt = this.outerDiv.offsetWidth + ((this.behavior == 'alternate') ?
|
||||
corrvalue : (this.innerDiv.offsetWidth + this.stopAt));
|
||||
break;
|
||||
|
||||
|
@ -436,9 +228,9 @@
|
|||
corrvalue = this.innerDiv.offsetWidth - this.outerDiv.offsetWidth;
|
||||
}
|
||||
this.dirsign = 1;
|
||||
this.startAt = (this._behavior == 'alternate') ? (this.innerDiv.offsetWidth - corrvalue) : 0;
|
||||
this.startAt = (this.behavior == 'alternate') ? (this.innerDiv.offsetWidth - corrvalue) : 0;
|
||||
this.stopAt = this.outerDiv.offsetWidth +
|
||||
((this._behavior == 'alternate' || this._behavior == 'slide') ?
|
||||
((this.behavior == 'alternate' || this.behavior == 'slide') ?
|
||||
corrvalue : (this.innerDiv.offsetWidth + this.startAt));
|
||||
}
|
||||
|
||||
|
@ -448,35 +240,35 @@
|
|||
}
|
||||
} //end if
|
||||
|
||||
this.newPosition = this.newPosition + (this.dirsign * this._scrollAmount);
|
||||
this.newPosition = this.newPosition + (this.dirsign * this.scrollAmount);
|
||||
|
||||
if ((this.dirsign == 1 && this.newPosition > this.stopAt) ||
|
||||
(this.dirsign == -1 && this.newPosition < this.stopAt))
|
||||
{
|
||||
switch (this._behavior)
|
||||
switch (this.behavior)
|
||||
{
|
||||
case 'alternate':
|
||||
// lets start afresh
|
||||
this.startNewDirection = true;
|
||||
this.invalidateCache = true;
|
||||
|
||||
// swap direction
|
||||
const swap = {left: "right", down: "up", up: "down", right: "left"};
|
||||
this._direction = swap[this._direction];
|
||||
this._currentDirection = swap[this._currentDirection] || "left";
|
||||
this.newPosition = this.stopAt;
|
||||
|
||||
if ((this._direction == "up") || (this._direction == "down")) {
|
||||
if ((this._currentDirection == "up") || (this._currentDirection == "down")) {
|
||||
this.outerDiv.scrollTop = this.newPosition;
|
||||
} else {
|
||||
this.outerDiv.scrollLeft = this.newPosition;
|
||||
}
|
||||
|
||||
if (this._loop != 1) {
|
||||
if (this._currentLoop != 1) {
|
||||
this._fireEvent("bounce", false, true);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'slide':
|
||||
if (this._loop > 1) {
|
||||
if (this._currentLoop > 1) {
|
||||
this.newPosition = this.startAt;
|
||||
}
|
||||
break;
|
||||
|
@ -484,20 +276,20 @@
|
|||
default:
|
||||
this.newPosition = this.startAt;
|
||||
|
||||
if ((this._direction == "up") || (this._direction == "down")) {
|
||||
if ((this._currentDirection == "up") || (this._currentDirection == "down")) {
|
||||
this.outerDiv.scrollTop = this.newPosition;
|
||||
} else {
|
||||
this.outerDiv.scrollLeft = this.newPosition;
|
||||
}
|
||||
|
||||
//dispatch start event, even when this._loop == 1, comp. with IE6
|
||||
//dispatch start event, even when this._currentLoop == 1, comp. with IE6
|
||||
this._fireEvent("start", false, false);
|
||||
}
|
||||
|
||||
if (this._loop > 1) {
|
||||
this._loop--;
|
||||
} else if (this._loop == 1) {
|
||||
if ((this._direction == "up") || (this._direction == "down")) {
|
||||
if (this._currentLoop > 1) {
|
||||
this._currentLoop--;
|
||||
} else if (this._currentLoop == 1) {
|
||||
if ((this._currentDirection == "up") || (this._currentDirection == "down")) {
|
||||
this.outerDiv.scrollTop = this.stopAt;
|
||||
} else {
|
||||
this.outerDiv.scrollLeft = this.stopAt;
|
||||
|
@ -508,7 +300,7 @@
|
|||
}
|
||||
}
|
||||
else {
|
||||
if ((this._direction == "up") || (this._direction == "down")) {
|
||||
if ((this._currentDirection == "up") || (this._currentDirection == "down")) {
|
||||
this.outerDiv.scrollTop = this.newPosition;
|
||||
} else {
|
||||
this.outerDiv.scrollLeft = this.newPosition;
|
||||
|
@ -517,7 +309,7 @@
|
|||
|
||||
var myThis = this;
|
||||
var lambda = function myTimeOutFunction(){myThis._doMove(false);}
|
||||
this.runId = window.setTimeout(lambda, this._scrollDelay);
|
||||
this.runId = window.setTimeout(lambda, this.scrollDelayWithTruespeed);
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
@ -527,7 +319,7 @@
|
|||
<![CDATA[
|
||||
this.stop();
|
||||
|
||||
if ((this._direction != "up") && (this._direction != "down")) {
|
||||
if ((this._currentDirection != "up") && (this._currentDirection != "down")) {
|
||||
var width = window.getComputedStyle(this).width;
|
||||
this.innerDiv.parentNode.style.margin = '0 ' + width;
|
||||
|
||||
|
@ -564,45 +356,13 @@
|
|||
var newValue = target.getAttribute(attrName);
|
||||
|
||||
if (oldValue != newValue) {
|
||||
target.invalidateCache = true;
|
||||
switch (attrName) {
|
||||
case "loop":
|
||||
target._set_loop(newValue);
|
||||
if (target.rundId == 0) {
|
||||
target.start();
|
||||
}
|
||||
break;
|
||||
case "scrollamount":
|
||||
target._set_scrollAmount(newValue);
|
||||
break;
|
||||
case "scrolldelay":
|
||||
target._set_scrollDelay(newValue);
|
||||
target.stop();
|
||||
target.start();
|
||||
break;
|
||||
case "truespeed":
|
||||
//needed to update target._scrollDelay
|
||||
var myThis = target;
|
||||
var lambda = function() {myThis._set_scrollDelay(myThis.getAttribute('scrolldelay'));}
|
||||
window.setTimeout(lambda, 0);
|
||||
break;
|
||||
case "behavior":
|
||||
target._set_behavior(newValue);
|
||||
target.startNewDirection = true;
|
||||
if ((oldValue == "slide" && target.newPosition == target.stopAt) ||
|
||||
newValue == "alternate" || newValue == "slide") {
|
||||
target.stop();
|
||||
target._doMove(true);
|
||||
}
|
||||
target._currentLoop = target.loop;
|
||||
break;
|
||||
case "direction":
|
||||
if (!newValue) {
|
||||
newValue = "left";
|
||||
}
|
||||
target._set_direction(newValue);
|
||||
break;
|
||||
case "width":
|
||||
case "height":
|
||||
target.startNewDirection = true;
|
||||
target._currentDirection = target.direction;
|
||||
break;
|
||||
case "onstart":
|
||||
target._setEventListener("start", newValue);
|
||||
|
@ -622,38 +382,38 @@
|
|||
|
||||
<constructor>
|
||||
<![CDATA[
|
||||
this.setStartStopCallback(val => {
|
||||
if (val == "start") {
|
||||
this.doStart();
|
||||
} else if (val == "stop") {
|
||||
this.doStop();
|
||||
} else {
|
||||
throw new Error(`setStartStopCallback passed an invalid value: ${val}`);
|
||||
}
|
||||
});
|
||||
// Set up state.
|
||||
this._scrollAmount = 6;
|
||||
this._scrollDelay = 85;
|
||||
this._direction = "left";
|
||||
this._behavior = "scroll";
|
||||
this._loop = -1;
|
||||
this._currentDirection = this.direction || "left";
|
||||
this._currentLoop = this.loop;
|
||||
this.dirsign = 1;
|
||||
this.startAt = 0;
|
||||
this.stopAt = 0;
|
||||
this.newPosition = 0;
|
||||
this.runId = 0;
|
||||
this.originalHeight = 0;
|
||||
this.startNewDirection = true;
|
||||
this.invalidateCache = true;
|
||||
|
||||
// hack needed to fix js error, see bug 386470
|
||||
var myThis = this;
|
||||
var lambda = function myScopeFunction() { if (myThis.init) myThis.init(); }
|
||||
|
||||
this._set_direction(this.getAttribute('direction'));
|
||||
this._set_behavior(this.getAttribute('behavior'));
|
||||
this._set_scrollDelay(this.getAttribute('scrolldelay'));
|
||||
this._set_scrollAmount(this.getAttribute('scrollamount'));
|
||||
this._set_loop(this.getAttribute('loop'));
|
||||
this._setEventListener("start", this.getAttribute("onstart"));
|
||||
this._setEventListener("finish", this.getAttribute("onfinish"));
|
||||
this._setEventListener("bounce", this.getAttribute("onbounce"));
|
||||
this.startNewDirection = true;
|
||||
|
||||
this._mutationObserver = new MutationObserver(this._mutationActor);
|
||||
this._mutationObserver.observe(this, { attributes: true,
|
||||
attributeOldValue: true,
|
||||
attributeFilter: ['loop', 'scrollamount', 'scrolldelay', '', 'truespeed', 'behavior',
|
||||
attributeFilter: ['loop', '', 'behavior',
|
||||
'direction', 'width', 'height', 'onstart', 'onfinish', 'onbounce'] });
|
||||
|
||||
// init needs to be run after the page has loaded in order to calculate
|
||||
|
@ -665,6 +425,11 @@
|
|||
}
|
||||
]]>
|
||||
</constructor>
|
||||
<destructor>
|
||||
<![CDATA[
|
||||
this.setStartStopCallback(null);
|
||||
]]>
|
||||
</destructor>
|
||||
</implementation>
|
||||
|
||||
</binding>
|
||||
|
@ -673,7 +438,7 @@
|
|||
extends="chrome://xbl-marquee/content/xbl-marquee.xml#marquee"
|
||||
inheritstyle="false">
|
||||
|
||||
<!-- White-space isn't allowed because a marquee could be
|
||||
<!-- White-space isn't allowed because a marquee could be
|
||||
inside 'white-space: pre' -->
|
||||
<content>
|
||||
<html:div style="display: -moz-box; overflow: hidden; width: -moz-available;"
|
||||
|
@ -693,7 +458,7 @@
|
|||
extends="chrome://xbl-marquee/content/xbl-marquee.xml#marquee"
|
||||
inheritstyle="false">
|
||||
|
||||
<!-- White-space isn't allowed because a marquee could be
|
||||
<!-- White-space isn't allowed because a marquee could be
|
||||
inside 'white-space: pre' -->
|
||||
<content>
|
||||
<html:div style="overflow: hidden; width: -moz-available;"
|
||||
|
|
|
@ -774,7 +774,7 @@ nsHtml5ElementName::initializeStatics()
|
|||
nsHtml5TreeBuilder::OTHER);
|
||||
ELT_MARQUEE = new nsHtml5ElementName(nsGkAtoms::marquee,
|
||||
nsGkAtoms::marquee,
|
||||
NS_NewHTMLDivElement,
|
||||
NS_NewHTMLMarqueeElement,
|
||||
NS_NewSVGUnknownElement,
|
||||
nsHtml5TreeBuilder::MARQUEE_OR_APPLET |
|
||||
SPECIAL | SCOPING);
|
||||
|
|
|
@ -121,7 +121,7 @@ HTML_TAG(listing, Pre, Pre)
|
|||
HTML_HTMLELEMENT_TAG(main)
|
||||
HTML_TAG(map, Map, Map)
|
||||
HTML_HTMLELEMENT_TAG(mark)
|
||||
HTML_TAG(marquee, Div, Div)
|
||||
HTML_TAG(marquee, Marquee, Marquee)
|
||||
HTML_TAG(menu, Menu, Menu)
|
||||
HTML_TAG(menuitem, MenuItem, MenuItem)
|
||||
HTML_TAG(meta, Meta, Meta)
|
||||
|
|
|
@ -618,57 +618,6 @@
|
|||
[HTMLCanvasElement interface: document.createElement("canvas") must inherit property "transferControlToOffscreen()" with the proper type]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLMarqueeElement interface: existence and properties of interface object]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLMarqueeElement interface object length]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLMarqueeElement interface object name]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLMarqueeElement interface: existence and properties of interface prototype object]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLMarqueeElement interface: existence and properties of interface prototype object's "constructor" property]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLMarqueeElement interface: existence and properties of interface prototype object's @@unscopables property]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLMarqueeElement interface: attribute behavior]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLMarqueeElement interface: attribute bgColor]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLMarqueeElement interface: attribute direction]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLMarqueeElement interface: attribute height]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLMarqueeElement interface: attribute hspace]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLMarqueeElement interface: attribute loop]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLMarqueeElement interface: attribute scrollAmount]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLMarqueeElement interface: attribute scrollDelay]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLMarqueeElement interface: attribute trueSpeed]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLMarqueeElement interface: attribute vspace]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLMarqueeElement interface: attribute width]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLMarqueeElement interface: attribute onbounce]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -678,51 +627,6 @@
|
|||
[HTMLMarqueeElement interface: attribute onstart]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLMarqueeElement interface: operation start()]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLMarqueeElement interface: operation stop()]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLMarqueeElement must be primary interface of document.createElement("marquee")]
|
||||
expected: FAIL
|
||||
|
||||
[Stringification of document.createElement("marquee")]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLMarqueeElement interface: document.createElement("marquee") must inherit property "behavior" with the proper type]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLMarqueeElement interface: document.createElement("marquee") must inherit property "bgColor" with the proper type]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLMarqueeElement interface: document.createElement("marquee") must inherit property "direction" with the proper type]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLMarqueeElement interface: document.createElement("marquee") must inherit property "height" with the proper type]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLMarqueeElement interface: document.createElement("marquee") must inherit property "hspace" with the proper type]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLMarqueeElement interface: document.createElement("marquee") must inherit property "loop" with the proper type]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLMarqueeElement interface: document.createElement("marquee") must inherit property "scrollAmount" with the proper type]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLMarqueeElement interface: document.createElement("marquee") must inherit property "scrollDelay" with the proper type]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLMarqueeElement interface: document.createElement("marquee") must inherit property "trueSpeed" with the proper type]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLMarqueeElement interface: document.createElement("marquee") must inherit property "vspace" with the proper type]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLMarqueeElement interface: document.createElement("marquee") must inherit property "width" with the proper type]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLMarqueeElement interface: document.createElement("marquee") must inherit property "onbounce" with the proper type]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -732,12 +636,6 @@
|
|||
[HTMLMarqueeElement interface: document.createElement("marquee") must inherit property "onstart" with the proper type]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLMarqueeElement interface: document.createElement("marquee") must inherit property "start()" with the proper type]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLMarqueeElement interface: document.createElement("marquee") must inherit property "stop()" with the proper type]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLFrameSetElement interface: attribute onrejectionhandled]
|
||||
expected: FAIL
|
||||
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,10 +0,0 @@
|
|||
[marquee-loop.html]
|
||||
[marquee_loop_string]
|
||||
expected: FAIL
|
||||
|
||||
[marquee_loop_less_than_1]
|
||||
expected: FAIL
|
||||
|
||||
[marquee_loop_normal]
|
||||
expected: FAIL
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
[marquee-scrollamount.html]
|
||||
[The scrollamount is a string]
|
||||
expected: FAIL
|
||||
|
||||
[The scrollamount is a negative]
|
||||
expected: FAIL
|
||||
|
||||
[The scrollamount is a normal value]
|
||||
expected: FAIL
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
[marquee-scrolldelay.html]
|
||||
[The scrolldelay attribute is a string]
|
||||
expected: FAIL
|
||||
|
||||
[The scrolldelay attribute is a negative]
|
||||
expected: FAIL
|
||||
|
||||
[The scrolldelay attribute is less than 60]
|
||||
expected: FAIL
|
||||
|
||||
[The scrolldelay attribute is greater than 60]
|
||||
expected: FAIL
|
||||
|
|
@ -6,18 +6,12 @@
|
|||
[Interfaces for keygen]
|
||||
expected: FAIL
|
||||
|
||||
[Interfaces for marquee]
|
||||
expected: FAIL
|
||||
|
||||
[Interfaces for IMAGE]
|
||||
expected: FAIL
|
||||
|
||||
[Interfaces for KEYGEN]
|
||||
expected: FAIL
|
||||
|
||||
[Interfaces for MARQUEE]
|
||||
expected: FAIL
|
||||
|
||||
[Interfaces for å-bar]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -13,9 +13,21 @@ var obsoleteElements = {
|
|||
width: "string",
|
||||
},
|
||||
marquee: {
|
||||
behavior: "string",
|
||||
behavior: {
|
||||
type: {
|
||||
type: "enum",
|
||||
keywords: ["scroll", "slide", "alternate"],
|
||||
defaultVal: "scroll"
|
||||
},
|
||||
},
|
||||
bgColor: "string",
|
||||
direction: "string",
|
||||
direction: {
|
||||
type: {
|
||||
type: "enum",
|
||||
keywords: ["up", "right", "down", "left"],
|
||||
defaultVal: "left"
|
||||
},
|
||||
},
|
||||
height: "string",
|
||||
hspace: "unsigned long",
|
||||
scrollAmount: {type: "unsigned long", defaultVal: 6},
|
||||
|
|
|
@ -162,6 +162,7 @@ STATIC_ATOMS = [
|
|||
Atom("bdi", "bdi"),
|
||||
Atom("bdo", "bdo"),
|
||||
Atom("before", "before"),
|
||||
Atom("behavior", "behavior"),
|
||||
Atom("bgcolor", "bgcolor"),
|
||||
Atom("bgsound", "bgsound"),
|
||||
Atom("big", "big"),
|
||||
|
@ -1015,6 +1016,7 @@ STATIC_ATOMS = [
|
|||
Atom("script", "script"),
|
||||
Atom("scriptEnabledBeforePrintOrPreview", "scriptEnabledBeforePrintOrPreview"),
|
||||
Atom("scrollbar", "scrollbar"),
|
||||
Atom("scrollamount", "scrollamount"),
|
||||
Atom("scrollbarbutton", "scrollbarbutton"),
|
||||
Atom("scrollbarDownBottom", "scrollbar-down-bottom"),
|
||||
Atom("scrollbarDownTop", "scrollbar-down-top"),
|
||||
|
@ -1022,6 +1024,7 @@ STATIC_ATOMS = [
|
|||
Atom("scrollbarUpTop", "scrollbar-up-top"),
|
||||
Atom("scrollbox", "scrollbox"),
|
||||
Atom("scrollcorner", "scrollcorner"),
|
||||
Atom("scrolldelay", "scrolldelay"),
|
||||
Atom("scrolling", "scrolling"),
|
||||
Atom("scrollPosition", "scroll-position"),
|
||||
Atom("section", "section"),
|
||||
|
@ -1157,6 +1160,7 @@ STATIC_ATOMS = [
|
|||
Atom("treerow", "treerow"),
|
||||
Atom("treeseparator", "treeseparator"),
|
||||
Atom("_true", "true"),
|
||||
Atom("truespeed", "truespeed"),
|
||||
Atom("tt", "tt"),
|
||||
Atom("type", "type"),
|
||||
Atom("typemustmatch", "typemustmatch"),
|
||||
|
|
Загрузка…
Ссылка в новой задаче