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/. */
|
2001-11-07 10:06:31 +03:00
|
|
|
|
2006-03-25 08:47:31 +03:00
|
|
|
/* DOM object for element.style */
|
|
|
|
|
2010-08-24 11:06:20 +04:00
|
|
|
#ifndef nsDOMCSSAttributeDeclaration_h
|
|
|
|
#define nsDOMCSSAttributeDeclaration_h
|
2001-11-07 10:06:31 +03:00
|
|
|
|
2012-09-14 20:10:08 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2017-12-15 01:03:14 +03:00
|
|
|
#include "mozilla/dom/DocGroup.h"
|
2001-11-07 10:06:31 +03:00
|
|
|
#include "nsDOMCSSDeclaration.h"
|
|
|
|
|
Bug 1428246 - The attributeChangedCallback is fired twice for the *first* style attribute change, r=peterv
The idea with this patch is that style code will first call
InlineStyleDeclarationWillChange before style declaration has changed, and SetInlineStyleDeclaration once it has changed.
In order to be able to report old attribute value, InlineStyleDeclarationWillChange reads the value and also calls AttributeWillChange (so that DOMMutationObserser can grab the old value). Later SetInlineStyleDeclaration passes the old value to
SetAttrAndNotify so that mutation events and attributeChanged callbacks are handled correctly.
Because of performance, declaration can't be cloned for reading the old value. And that is why the recently-added callback is used to detect when declaration is about to change (bug 1466963 and followup bug 1468665).
To keep the expected existing behavior, even if declaration isn't changed, but just a new declaration was created (since there wasn't any), we need to still run all these
willchange/set calls. That is when the code has 'if (created)' checks.
Since there are several declaration implementation and only nsDOMCSSAttributeDeclaration needs the about-to-change callback, GetPropertyChangeClosure is the one to initialize the callback closure, and the struct which is then passes as data to the closure.
Apparently we lost mutation event testing on style attribute when the pref was added, so test_style_attr_listener.html is modified to test both pref values.
--HG--
extra : rebase_source : 9e605d43f22e650ac3912fbfb41abb8d5a2a0c8f
2018-06-26 12:54:00 +03:00
|
|
|
struct RawServoUnlockedDeclarationBlock;
|
2019-01-23 16:48:08 +03:00
|
|
|
|
2010-03-03 00:00:53 +03:00
|
|
|
namespace mozilla {
|
2019-01-23 16:48:08 +03:00
|
|
|
|
|
|
|
class SMILValue;
|
2019-05-16 16:21:20 +03:00
|
|
|
class SVGAnimatedLength;
|
2019-01-23 16:48:08 +03:00
|
|
|
|
2010-08-27 11:03:36 +04:00
|
|
|
namespace dom {
|
2018-01-08 16:05:07 +03:00
|
|
|
class DomGroup;
|
2010-08-27 11:03:36 +04:00
|
|
|
class Element;
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2001-11-07 10:06:31 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class nsDOMCSSAttributeDeclaration final : public nsDOMCSSDeclaration {
|
2001-11-07 10:06:31 +03:00
|
|
|
public:
|
2010-08-27 11:03:36 +04:00
|
|
|
typedef mozilla::dom::Element Element;
|
2019-01-23 16:48:08 +03:00
|
|
|
typedef mozilla::SMILValue SMILValue;
|
2019-05-16 16:21:20 +03:00
|
|
|
typedef mozilla::SVGAnimatedLength SVGAnimatedLength;
|
2011-11-05 14:32:52 +04:00
|
|
|
nsDOMCSSAttributeDeclaration(Element* aContent, bool aIsSMILOverride);
|
2001-11-07 10:06:31 +03:00
|
|
|
|
2009-07-13 15:14:57 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
2012-08-06 06:16:30 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS_AMBIGUOUS(
|
|
|
|
nsDOMCSSAttributeDeclaration, nsICSSDeclaration)
|
2003-09-24 07:34:27 +04:00
|
|
|
|
Bug 1428246 - The attributeChangedCallback is fired twice for the *first* style attribute change, r=peterv
The idea with this patch is that style code will first call
InlineStyleDeclarationWillChange before style declaration has changed, and SetInlineStyleDeclaration once it has changed.
In order to be able to report old attribute value, InlineStyleDeclarationWillChange reads the value and also calls AttributeWillChange (so that DOMMutationObserser can grab the old value). Later SetInlineStyleDeclaration passes the old value to
SetAttrAndNotify so that mutation events and attributeChanged callbacks are handled correctly.
Because of performance, declaration can't be cloned for reading the old value. And that is why the recently-added callback is used to detect when declaration is about to change (bug 1466963 and followup bug 1468665).
To keep the expected existing behavior, even if declaration isn't changed, but just a new declaration was created (since there wasn't any), we need to still run all these
willchange/set calls. That is when the code has 'if (created)' checks.
Since there are several declaration implementation and only nsDOMCSSAttributeDeclaration needs the about-to-change callback, GetPropertyChangeClosure is the one to initialize the callback closure, and the struct which is then passes as data to the closure.
Apparently we lost mutation event testing on style attribute when the pref was added, so test_style_attr_listener.html is modified to test both pref values.
--HG--
extra : rebase_source : 9e605d43f22e650ac3912fbfb41abb8d5a2a0c8f
2018-06-26 12:54:00 +03:00
|
|
|
mozilla::DeclarationBlock* GetOrCreateCSSDeclaration(
|
|
|
|
Operation aOperation, mozilla::DeclarationBlock** aCreated) final;
|
2018-05-03 18:41:48 +03:00
|
|
|
|
2018-05-14 19:22:20 +03:00
|
|
|
nsDOMCSSDeclaration::ParsingEnvironment GetParsingEnvironment(
|
|
|
|
nsIPrincipal* aSubjectPrincipal) const final;
|
2018-05-03 18:41:48 +03:00
|
|
|
|
2018-05-02 19:06:48 +03:00
|
|
|
mozilla::css::Rule* GetParentRule() override { return nullptr; }
|
2001-11-07 10:06:31 +03:00
|
|
|
|
2018-05-02 19:06:48 +03:00
|
|
|
nsINode* GetParentObject() override { return mElement; }
|
2009-07-13 15:14:57 +04:00
|
|
|
|
2019-05-16 16:21:20 +03:00
|
|
|
nsresult SetSMILValue(const nsCSSPropertyID aPropID, const SMILValue& aValue);
|
|
|
|
nsresult SetSMILValue(const nsCSSPropertyID aPropID,
|
|
|
|
const SVGAnimatedLength& aLength);
|
2018-05-02 19:08:24 +03:00
|
|
|
|
2020-02-03 23:35:54 +03:00
|
|
|
void SetPropertyValue(const nsCSSPropertyID aPropID, const nsACString& aValue,
|
|
|
|
nsIPrincipal* aSubjectPrincipal,
|
|
|
|
mozilla::ErrorResult& aRv) override;
|
2013-09-04 15:47:23 +04:00
|
|
|
|
Bug 1428246 - The attributeChangedCallback is fired twice for the *first* style attribute change, r=peterv
The idea with this patch is that style code will first call
InlineStyleDeclarationWillChange before style declaration has changed, and SetInlineStyleDeclaration once it has changed.
In order to be able to report old attribute value, InlineStyleDeclarationWillChange reads the value and also calls AttributeWillChange (so that DOMMutationObserser can grab the old value). Later SetInlineStyleDeclaration passes the old value to
SetAttrAndNotify so that mutation events and attributeChanged callbacks are handled correctly.
Because of performance, declaration can't be cloned for reading the old value. And that is why the recently-added callback is used to detect when declaration is about to change (bug 1466963 and followup bug 1468665).
To keep the expected existing behavior, even if declaration isn't changed, but just a new declaration was created (since there wasn't any), we need to still run all these
willchange/set calls. That is when the code has 'if (created)' checks.
Since there are several declaration implementation and only nsDOMCSSAttributeDeclaration needs the about-to-change callback, GetPropertyChangeClosure is the one to initialize the callback closure, and the struct which is then passes as data to the closure.
Apparently we lost mutation event testing on style attribute when the pref was added, so test_style_attr_listener.html is modified to test both pref values.
--HG--
extra : rebase_source : 9e605d43f22e650ac3912fbfb41abb8d5a2a0c8f
2018-06-26 12:54:00 +03:00
|
|
|
static void MutationClosureFunction(void* aData);
|
|
|
|
|
2018-10-14 03:05:56 +03:00
|
|
|
void GetPropertyChangeClosure(
|
|
|
|
mozilla::DeclarationBlockMutationClosure* aClosure,
|
2018-04-13 21:04:47 +03:00
|
|
|
mozilla::MutationClosureData* aClosureData) final {
|
2018-07-12 13:04:26 +03:00
|
|
|
if (!mIsSMILOverride) {
|
|
|
|
aClosure->function = MutationClosureFunction;
|
|
|
|
aClosure->data = aClosureData;
|
|
|
|
aClosureData->mClosure = MutationClosureFunction;
|
|
|
|
aClosureData->mElement = mElement;
|
|
|
|
}
|
Bug 1428246 - The attributeChangedCallback is fired twice for the *first* style attribute change, r=peterv
The idea with this patch is that style code will first call
InlineStyleDeclarationWillChange before style declaration has changed, and SetInlineStyleDeclaration once it has changed.
In order to be able to report old attribute value, InlineStyleDeclarationWillChange reads the value and also calls AttributeWillChange (so that DOMMutationObserser can grab the old value). Later SetInlineStyleDeclaration passes the old value to
SetAttrAndNotify so that mutation events and attributeChanged callbacks are handled correctly.
Because of performance, declaration can't be cloned for reading the old value. And that is why the recently-added callback is used to detect when declaration is about to change (bug 1466963 and followup bug 1468665).
To keep the expected existing behavior, even if declaration isn't changed, but just a new declaration was created (since there wasn't any), we need to still run all these
willchange/set calls. That is when the code has 'if (created)' checks.
Since there are several declaration implementation and only nsDOMCSSAttributeDeclaration needs the about-to-change callback, GetPropertyChangeClosure is the one to initialize the callback closure, and the struct which is then passes as data to the closure.
Apparently we lost mutation event testing on style attribute when the pref was added, so test_style_attr_listener.html is modified to test both pref values.
--HG--
extra : rebase_source : 9e605d43f22e650ac3912fbfb41abb8d5a2a0c8f
2018-06-26 12:54:00 +03:00
|
|
|
}
|
|
|
|
|
2001-11-07 10:06:31 +03:00
|
|
|
protected:
|
2014-06-24 02:40:01 +04:00
|
|
|
~nsDOMCSSAttributeDeclaration();
|
|
|
|
|
2019-01-02 16:05:23 +03:00
|
|
|
nsresult SetCSSDeclaration(
|
Bug 1428246 - The attributeChangedCallback is fired twice for the *first* style attribute change, r=peterv
The idea with this patch is that style code will first call
InlineStyleDeclarationWillChange before style declaration has changed, and SetInlineStyleDeclaration once it has changed.
In order to be able to report old attribute value, InlineStyleDeclarationWillChange reads the value and also calls AttributeWillChange (so that DOMMutationObserser can grab the old value). Later SetInlineStyleDeclaration passes the old value to
SetAttrAndNotify so that mutation events and attributeChanged callbacks are handled correctly.
Because of performance, declaration can't be cloned for reading the old value. And that is why the recently-added callback is used to detect when declaration is about to change (bug 1466963 and followup bug 1468665).
To keep the expected existing behavior, even if declaration isn't changed, but just a new declaration was created (since there wasn't any), we need to still run all these
willchange/set calls. That is when the code has 'if (created)' checks.
Since there are several declaration implementation and only nsDOMCSSAttributeDeclaration needs the about-to-change callback, GetPropertyChangeClosure is the one to initialize the callback closure, and the struct which is then passes as data to the closure.
Apparently we lost mutation event testing on style attribute when the pref was added, so test_style_attr_listener.html is modified to test both pref values.
--HG--
extra : rebase_source : 9e605d43f22e650ac3912fbfb41abb8d5a2a0c8f
2018-06-26 12:54:00 +03:00
|
|
|
mozilla::DeclarationBlock* aDecl,
|
2018-04-13 21:04:47 +03:00
|
|
|
mozilla::MutationClosureData* aClosureData) override;
|
2019-01-02 16:05:23 +03:00
|
|
|
mozilla::dom::Document* DocToUpdate() override;
|
2010-03-02 23:59:32 +03:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<Element> mElement;
|
2009-09-03 04:28:37 +04:00
|
|
|
|
|
|
|
/* If true, this indicates that this nsDOMCSSAttributeDeclaration
|
|
|
|
* should interact with mContent's SMIL override style rule (rather
|
|
|
|
* than the inline style rule).
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
const bool mIsSMILOverride;
|
2019-05-16 16:21:20 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
template <typename SetterFunc>
|
|
|
|
nsresult SetSMILValueHelper(SetterFunc aFunc);
|
2001-11-07 10:06:31 +03:00
|
|
|
};
|
|
|
|
|
2010-08-24 11:06:20 +04:00
|
|
|
#endif /* nsDOMCSSAttributeDeclaration_h */
|