зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1631533 - Allow to get old value in synced field's DidSet. r=nika
This is needed for zoom because it only fires events when values actually change for example, but seems useful more generally to potentially avoid wasted work. We can't just notify on change because user activation depends on the time on which DidSet gets called. Differential Revision: https://phabricator.services.mozilla.com/D71646
This commit is contained in:
Родитель
44e838a5c5
Коммит
47c40173d7
|
@ -688,8 +688,13 @@ class BrowsingContext : public nsILoadContext, public nsWrapperCache {
|
|||
return true;
|
||||
}
|
||||
|
||||
// Overload `DidSet` to get notifications for a particular field being set.
|
||||
//
|
||||
// You can also overload the variant that gets the old value if you need it.
|
||||
template <size_t I>
|
||||
void DidSet(FieldIndex<I>) {}
|
||||
template <size_t I, typename T>
|
||||
void DidSet(FieldIndex<I>, T&& aOldValue) {}
|
||||
|
||||
// True if the process attemping to set field is the same as the owning
|
||||
// process.
|
||||
|
|
|
@ -131,8 +131,10 @@ template <typename Context>
|
|||
void Transaction<Context>::Apply(Context* aOwner) {
|
||||
EachIndex([&](auto idx) {
|
||||
if (auto& txnField = GetAt(idx, mMaybeFields)) {
|
||||
GetAt(idx, GetFieldStorage(aOwner).mFields) = std::move(*txnField);
|
||||
auto& ownerField = GetAt(idx, GetFieldStorage(aOwner).mFields);
|
||||
std::swap(ownerField, *txnField);
|
||||
aOwner->DidSet(idx);
|
||||
aOwner->DidSet(idx, std::move(*txnField));
|
||||
txnField.reset();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -90,8 +90,12 @@ class WindowContext : public nsISupports, public nsWrapperCache {
|
|||
}
|
||||
|
||||
// Overload `DidSet` to get notifications for a particular field being set.
|
||||
//
|
||||
// You can also overload the variant that gets the old value if you need it.
|
||||
template <size_t I>
|
||||
void DidSet(FieldIndex<I>) {}
|
||||
template <size_t I, typename T>
|
||||
void DidSet(FieldIndex<I>, T&& aOldValue) {}
|
||||
|
||||
uint64_t mInnerWindowId;
|
||||
RefPtr<BrowsingContext> mBrowsingContext;
|
||||
|
|
Загрузка…
Ссылка в новой задаче