Backed out 6 changesets (bug 1342303) for build bustage a=backout

Backed out changeset 89137679a68c (bug 1342303)
Backed out changeset 20a1bcb47c33 (bug 1342303)
Backed out changeset bc3b2e7a383b (bug 1342303)
Backed out changeset bdc491b9ebde (bug 1342303)
Backed out changeset 5c6042dee665 (bug 1342303)
Backed out changeset b5de1dfff82f (bug 1342303)

MozReview-Commit-ID: BjlVAX480jI
This commit is contained in:
Wes Kocher 2017-03-02 16:35:43 -08:00
Родитель 1297589623
Коммит 5bb9a497ef
11 изменённых файлов: 244 добавлений и 252 удалений

Просмотреть файл

@ -59,14 +59,19 @@ nsSHEntry::nsSHEntry(const nsSHEntry& aOther)
{
}
static bool
ClearParentPtr(nsISHEntry* aEntry, void* /* aData */)
{
if (aEntry) {
aEntry->SetParent(nullptr);
}
return true;
}
nsSHEntry::~nsSHEntry()
{
// Null out the mParent pointers on all our kids.
for (nsISHEntry* entry : mChildren) {
if (entry) {
entry->SetParent(nullptr);
}
}
mChildren.EnumerateForwards(ClearParentPtr, nullptr);
}
NS_IMPL_ISUPPORTS(nsSHEntry, nsISHContainer, nsISHEntry, nsISHEntryInternal)

Просмотреть файл

@ -165,8 +165,7 @@ struct ChildSheetListBuilder {
};
bool
CSSStyleSheet::RebuildChildList(css::Rule* aRule,
ChildSheetListBuilder* aBuilder)
CSSStyleSheet::RebuildChildList(css::Rule* aRule, void* aBuilder)
{
int32_t type = aRule->GetType();
if (type < css::Rule::IMPORT_RULE) {
@ -179,6 +178,9 @@ CSSStyleSheet::RebuildChildList(css::Rule* aRule,
return false;
}
ChildSheetListBuilder* builder =
static_cast<ChildSheetListBuilder*>(aBuilder);
// XXXbz We really need to decomtaminate all this stuff. Is there a reason
// that I can't just QI to ImportRule and get a CSSStyleSheet
// directly from it?
@ -195,9 +197,9 @@ CSSStyleSheet::RebuildChildList(css::Rule* aRule,
return true;
}
(*aBuilder->sheetSlot) = sheet;
aBuilder->SetParentLinks(*aBuilder->sheetSlot);
aBuilder->sheetSlot = &(*aBuilder->sheetSlot)->mNext;
(*builder->sheetSlot) = sheet;
builder->SetParentLinks(*builder->sheetSlot);
builder->sheetSlot = &(*builder->sheetSlot)->mNext;
return true;
}
@ -236,18 +238,11 @@ CSSStyleSheetInner::CSSStyleSheetInner(CSSStyleSheetInner& aCopy,
: StyleSheetInfo(aCopy, aPrimarySheet)
{
MOZ_COUNT_CTOR(CSSStyleSheetInner);
for (css::Rule* rule : aCopy.mOrderedRules) {
RefPtr<css::Rule> clone = rule->Clone();
mOrderedRules.AppendObject(clone);
clone->SetStyleSheet(aPrimarySheet);
}
aCopy.mOrderedRules.EnumerateForwards(css::GroupRule::CloneRuleInto, &mOrderedRules);
mOrderedRules.EnumerateForwards(SetStyleSheetReference, aPrimarySheet);
ChildSheetListBuilder builder = { &mFirstChild, aPrimarySheet };
for (css::Rule* rule : mOrderedRules) {
if (!CSSStyleSheet::RebuildChildList(rule, &builder)) {
break;
}
}
mOrderedRules.EnumerateForwards(CSSStyleSheet::RebuildChildList, &builder);
RebuildNameSpaces();
}
@ -255,9 +250,7 @@ CSSStyleSheetInner::CSSStyleSheetInner(CSSStyleSheetInner& aCopy,
CSSStyleSheetInner::~CSSStyleSheetInner()
{
MOZ_COUNT_DTOR(CSSStyleSheetInner);
for (css::Rule* rule : mOrderedRules) {
rule->SetStyleSheet(nullptr);
}
mOrderedRules.EnumerateForwards(SetStyleSheetReference, nullptr);
}
CSSStyleSheetInner*
@ -269,11 +262,8 @@ CSSStyleSheetInner::CloneFor(CSSStyleSheet* aPrimarySheet)
void
CSSStyleSheetInner::RemoveSheet(StyleSheet* aSheet)
{
if (aSheet == mSheets.ElementAt(0) && mSheets.Length() > 1) {
StyleSheet* sheet = mSheets[1];
for (css::Rule* rule : mOrderedRules) {
rule->SetStyleSheet(sheet);
}
if ((aSheet == mSheets.ElementAt(0)) && (mSheets.Length() > 1)) {
mOrderedRules.EnumerateForwards(SetStyleSheetReference, mSheets[1]);
ChildSheetListBuilder::ReparentChildList(mSheets[1], mFirstChild);
}
@ -315,17 +305,7 @@ CSSStyleSheetInner::RebuildNameSpaces()
{
// Just nuke our existing namespace map, if any
if (NS_SUCCEEDED(CreateNamespaceMap())) {
for (css::Rule* rule : mOrderedRules) {
switch (rule->GetType()) {
case css::Rule::NAMESPACE_RULE:
AddNamespaceRuleToMap(rule, mNameSpaceMap);
continue;
case css::Rule::CHARSET_RULE:
case css::Rule::IMPORT_RULE:
continue;
}
break;
}
mOrderedRules.EnumerateForwards(CreateNameSpace, mNameSpaceMap);
}
}
@ -457,9 +437,7 @@ CSSStyleSheet::UnlinkInner()
return;
}
for (css::Rule* rule : Inner()->mOrderedRules) {
rule->SetStyleSheet(nullptr);
}
Inner()->mOrderedRules.EnumerateForwards(SetStyleSheetReference, nullptr);
Inner()->mOrderedRules.Clear();
StyleSheet::UnlinkInner();

Просмотреть файл

@ -38,7 +38,6 @@ class nsXMLNameSpaceMap;
namespace mozilla {
class CSSStyleSheet;
struct ChildSheetListBuilder;
namespace css {
class GroupRule;
@ -165,8 +164,7 @@ public:
// Function used as a callback to rebuild our inner's child sheet
// list after we clone a unique inner for ourselves.
static bool RebuildChildList(css::Rule* aRule,
ChildSheetListBuilder* aBuilder);
static bool RebuildChildList(css::Rule* aRule, void* aBuilder);
size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const override;

Просмотреть файл

@ -58,7 +58,7 @@ public:
int32_t StyleRuleCount() const { return mRules.Count(); }
Rule* GetStyleRuleAt(int32_t aIndex) const;
typedef bool (*RuleEnumFunc)(Rule* aElement, void* aData);
typedef IncrementalClearCOMRuleArray::nsCOMArrayEnumFunc RuleEnumFunc;
bool EnumerateRulesForwards(RuleEnumFunc aFunc, void * aData) const;
/*
@ -76,6 +76,14 @@ public:
size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const override = 0;
static bool
CloneRuleInto(Rule* aRule, void* aArray)
{
RefPtr<Rule> clone = aRule->Clone();
static_cast<IncrementalClearCOMRuleArray*>(aArray)->AppendObject(clone);
return true;
}
// WebIDL API
dom::CSSRuleList* CssRules();
uint32_t InsertRule(const nsAString& aRule, uint32_t aIndex,

Просмотреть файл

@ -3673,11 +3673,9 @@ nsCSSRuleProcessor::CascadeSheet(CSSStyleSheet* aSheet, CascadeEnumData* aData)
child = child->mNext;
}
for (css::Rule* rule : aSheet->Inner()->mOrderedRules) {
if (!CascadeRuleEnumFunc(rule, aData)) {
return false;
}
}
if (!aSheet->Inner()->mOrderedRules.EnumerateForwards(CascadeRuleEnumFunc,
aData))
return false;
}
return true;
}

Просмотреть файл

@ -431,22 +431,25 @@ GroupRule::GroupRule(uint32_t aLineNumber, uint32_t aColumnNumber)
{
}
static bool
SetParentRuleReference(Rule* aRule, void* aParentRule)
{
GroupRule* parentRule = static_cast<GroupRule*>(aParentRule);
aRule->SetParentRule(parentRule);
return true;
}
GroupRule::GroupRule(const GroupRule& aCopy)
: Rule(aCopy)
{
for (const Rule* rule : aCopy.mRules) {
RefPtr<Rule> clone = rule->Clone();
mRules.AppendObject(clone);
clone->SetParentRule(this);
}
const_cast<GroupRule&>(aCopy).mRules.EnumerateForwards(GroupRule::CloneRuleInto, &mRules);
mRules.EnumerateForwards(SetParentRuleReference, this);
}
GroupRule::~GroupRule()
{
MOZ_ASSERT(!mSheet, "SetStyleSheet should have been called");
for (Rule* rule : mRules) {
rule->SetParentRule(nullptr);
}
mRules.EnumerateForwards(SetParentRuleReference, nullptr);
if (mRuleCollection) {
mRuleCollection->DropReference();
}
@ -465,12 +468,17 @@ GroupRule::IsCCLeaf() const
return false;
}
static bool
SetStyleSheetReference(Rule* aRule, void* aSheet)
{
aRule->SetStyleSheet(reinterpret_cast<StyleSheet*>(aSheet));
return true;
}
NS_IMPL_CYCLE_COLLECTION_CLASS(GroupRule)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(GroupRule, Rule)
for (Rule* rule : tmp->mRules) {
rule->SetParentRule(nullptr);
}
tmp->mRules.EnumerateForwards(SetParentRuleReference, nullptr);
// If tmp does not have a stylesheet, neither do its descendants. In that
// case, don't try to null out their stylesheet, to avoid O(N^2) behavior in
// depth of group rule nesting. But if tmp _does_ have a stylesheet (which
@ -478,9 +486,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(GroupRule, Rule)
// need to null out the stylesheet pointer on descendants now, before we clear
// tmp->mRules.
if (tmp->GetStyleSheet()) {
for (Rule* rule : tmp->mRules) {
rule->SetStyleSheet(nullptr);
}
tmp->mRules.EnumerateForwards(SetStyleSheetReference, nullptr);
}
tmp->mRules.Clear();
if (tmp->mRuleCollection) {
@ -508,9 +514,7 @@ GroupRule::SetStyleSheet(StyleSheet* aSheet)
// depth when seting the sheet to null during unlink, if we happen to unlin in
// order from most nested rule up to least nested rule.
if (aSheet != GetStyleSheet()) {
for (Rule* rule : mRules) {
rule->SetStyleSheet(aSheet);
}
mRules.EnumerateForwards(SetStyleSheetReference, aSheet);
Rule::SetStyleSheet(aSheet);
}
}
@ -546,12 +550,8 @@ GroupRule::GetStyleRuleAt(int32_t aIndex) const
bool
GroupRule::EnumerateRulesForwards(RuleEnumFunc aFunc, void * aData) const
{
for (const Rule* rule : mRules) {
if (!aFunc(const_cast<Rule*>(rule), aData)) {
return false;
}
}
return true;
return
const_cast<GroupRule*>(this)->mRules.EnumerateForwards(aFunc, aData);
}
/*

Просмотреть файл

@ -1,140 +0,0 @@
/* -*- 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/. */
// Common iterator implementation for array classes e.g. nsTArray.
#ifndef mozilla_ArrayIterator_h
#define mozilla_ArrayIterator_h
#include <iterator>
#include "mozilla/TypeTraits.h"
namespace mozilla {
// We have implemented a custom iterator class for array rather than using
// raw pointers into the backing storage to improve the safety of C++11-style
// range based iteration in the presence of array mutation, or script execution
// (bug 1299489).
//
// Mutating an array which is being iterated is still wrong, and will either
// cause elements to be missed or firefox to crash, but will not trigger memory
// safety problems due to the release-mode bounds checking found in ElementAt.
//
// Dereferencing this iterator returns type Element. When Element is a reference
// type, this iterator implements the full standard random access iterator spec,
// and can be treated in many ways as though it is a pointer. Otherwise, it is
// just enough to be used in range-based for loop.
template<class Element, class ArrayType>
class ArrayIterator
{
public:
typedef ArrayType array_type;
typedef ArrayIterator<Element, ArrayType> iterator_type;
typedef typename array_type::index_type index_type;
typedef typename RemoveReference<Element>::Type value_type;
typedef ptrdiff_t difference_type;
typedef value_type* pointer;
typedef value_type& reference;
typedef std::random_access_iterator_tag iterator_category;
private:
const array_type* mArray;
index_type mIndex;
public:
ArrayIterator() : mArray(nullptr), mIndex(0) {}
ArrayIterator(const iterator_type& aOther)
: mArray(aOther.mArray), mIndex(aOther.mIndex) {}
ArrayIterator(const array_type& aArray, index_type aIndex)
: mArray(&aArray), mIndex(aIndex) {}
iterator_type& operator=(const iterator_type& aOther) {
mArray = aOther.mArray;
mIndex = aOther.mIndex;
return *this;
}
bool operator==(const iterator_type& aRhs) const {
return mIndex == aRhs.mIndex;
}
bool operator!=(const iterator_type& aRhs) const {
return !(*this == aRhs);
}
bool operator<(const iterator_type& aRhs) const {
return mIndex < aRhs.mIndex;
}
bool operator>(const iterator_type& aRhs) const {
return mIndex > aRhs.mIndex;
}
bool operator<=(const iterator_type& aRhs) const {
return mIndex <= aRhs.mIndex;
}
bool operator>=(const iterator_type& aRhs) const {
return mIndex >= aRhs.mIndex;
}
// These operators depend on the release mode bounds checks in
// ArrayIterator::ElementAt for safety.
value_type* operator->() const {
return const_cast<value_type*>(&mArray->ElementAt(mIndex));
}
Element operator*() const {
return const_cast<Element>(mArray->ElementAt(mIndex));
}
iterator_type& operator++() {
++mIndex;
return *this;
}
iterator_type operator++(int) {
iterator_type it = *this;
++*this;
return it;
}
iterator_type& operator--() {
--mIndex;
return *this;
}
iterator_type operator--(int) {
iterator_type it = *this;
--*this;
return it;
}
iterator_type& operator+=(difference_type aDiff) {
mIndex += aDiff;
return *this;
}
iterator_type& operator-=(difference_type aDiff) {
mIndex -= aDiff;
return *this;
}
iterator_type operator+(difference_type aDiff) const {
iterator_type it = *this;
it += aDiff;
return it;
}
iterator_type operator-(difference_type aDiff) const {
iterator_type it = *this;
it -= aDiff;
return it;
}
difference_type operator-(const iterator_type& aOther) const {
return static_cast<difference_type>(mIndex) -
static_cast<difference_type>(aOther.mIndex);
}
Element operator[](difference_type aIndex) const {
return *this->operator+(aIndex);
}
};
} // namespace mozilla
#endif // mozilla_ArrayIterator_h

Просмотреть файл

@ -83,7 +83,6 @@ EXPORTS += [
]
EXPORTS.mozilla += [
'ArrayIterator.h',
'IncrementalTokenizer.h',
'Observer.h',
'StickyTimeDuration.h',

Просмотреть файл

@ -8,9 +8,7 @@
#define nsCOMArray_h__
#include "mozilla/Attributes.h"
#include "mozilla/ArrayIterator.h"
#include "mozilla/MemoryReporting.h"
#include "mozilla/ReverseIterator.h"
#include "nsCycleCollectionNoteChild.h"
#include "nsTArray.h"
@ -233,12 +231,6 @@ template<class T>
class nsCOMArray : public nsCOMArray_base
{
public:
typedef int32_t index_type;
typedef mozilla::ArrayIterator<T*, nsCOMArray> iterator;
typedef mozilla::ArrayIterator<const T*, nsCOMArray> const_iterator;
typedef mozilla::ReverseIterator<iterator> reverse_iterator;
typedef mozilla::ReverseIterator<const_iterator> const_reverse_iterator;
nsCOMArray() {}
explicit nsCOMArray(int32_t aCount) : nsCOMArray_base(aCount) {}
explicit nsCOMArray(const nsCOMArray<T>& aOther) : nsCOMArray_base(aOther) {}
@ -344,6 +336,24 @@ public:
nsCOMArray_base::ReplaceElementAt(aIndex, aElement);
}
// Enumerator callback function. Return false to stop
// Here's a more readable form:
// bool enumerate(T* aElement, void* aData)
typedef bool (*nsCOMArrayEnumFunc)(T* aElement, void* aData);
// enumerate through the array with a callback.
bool EnumerateForwards(nsCOMArrayEnumFunc aFunc, void* aData)
{
return nsCOMArray_base::EnumerateForwards(nsBaseArrayEnumFunc(aFunc),
aData);
}
bool EnumerateBackwards(nsCOMArrayEnumFunc aFunc, void* aData)
{
return nsCOMArray_base::EnumerateBackwards(nsBaseArrayEnumFunc(aFunc),
aData);
}
typedef int (*nsCOMArrayComparatorFunc)(T* aElement1, T* aElement2,
void* aData);
@ -433,22 +443,6 @@ public:
return nsCOMArray_base::Forget(reinterpret_cast<nsISupports***>(aElements));
}
// Methods for range-based for loops.
iterator begin() { return iterator(*this, 0); }
const_iterator begin() const { return const_iterator(*this, 0); }
const_iterator cbegin() const { return begin(); }
iterator end() { return iterator(*this, Length()); }
const_iterator end() const { return const_iterator(*this, Length()); }
const_iterator cend() const { return end(); }
// Methods for reverse iterating.
reverse_iterator rbegin() { return reverse_iterator(end()); }
const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); }
const_reverse_iterator crbegin() const { return rbegin(); }
reverse_iterator rend() { return reverse_iterator(begin()); }
const_reverse_iterator rend() const { return const_reverse_iterator(begin()); }
const_reverse_iterator crend() const { return rend(); }
private:
// don't implement these!

Просмотреть файл

@ -9,7 +9,6 @@
#include "nsTArrayForwardDeclare.h"
#include "mozilla/Alignment.h"
#include "mozilla/ArrayIterator.h"
#include "mozilla/Assertions.h"
#include "mozilla/Attributes.h"
#include "mozilla/BinarySearch.h"
@ -32,6 +31,7 @@
#include <functional>
#include <initializer_list>
#include <new>
#include <iterator>
namespace JS {
template<class T>
@ -357,6 +357,124 @@ struct nsTArray_SafeElementAtHelper<mozilla::OwningNonNull<E>, Derived>
}
};
// We have implemented a custom iterator class for nsTArray rather than using
// raw pointers into the backing storage to improve the safety of C++11-style
// range based iteration in the presence of array mutation, or script execution
// (bug 1299489).
//
// Mutating an array which is being iterated is still wrong, and will either
// cause elements to be missed or firefox to crash, but will not trigger memory
// safety problems due to the release-mode bounds checking found in ElementAt.
//
// This iterator implements the full standard random access iterator spec, and
// can be treated in may ways as though it is a pointer.
template<class Element>
class nsTArrayIterator
{
public:
typedef nsTArray<typename mozilla::RemoveConst<Element>::Type> array_type;
typedef nsTArrayIterator<Element> iterator_type;
typedef typename array_type::index_type index_type;
typedef Element value_type;
typedef ptrdiff_t difference_type;
typedef value_type* pointer;
typedef value_type& reference;
typedef std::random_access_iterator_tag iterator_category;
private:
const array_type* mArray;
index_type mIndex;
public:
nsTArrayIterator() : mArray(nullptr), mIndex(0) {}
nsTArrayIterator(const iterator_type& aOther)
: mArray(aOther.mArray), mIndex(aOther.mIndex) {}
nsTArrayIterator(const array_type& aArray, index_type aIndex)
: mArray(&aArray), mIndex(aIndex) {}
iterator_type& operator=(const iterator_type& aOther) {
mArray = aOther.mArray;
mIndex = aOther.mIndex;
return *this;
}
bool operator==(const iterator_type& aRhs) const {
return mIndex == aRhs.mIndex;
}
bool operator!=(const iterator_type& aRhs) const {
return !(*this == aRhs);
}
bool operator<(const iterator_type& aRhs) const {
return mIndex < aRhs.mIndex;
}
bool operator>(const iterator_type& aRhs) const {
return mIndex > aRhs.mIndex;
}
bool operator<=(const iterator_type& aRhs) const {
return mIndex <= aRhs.mIndex;
}
bool operator>=(const iterator_type& aRhs) const {
return mIndex >= aRhs.mIndex;
}
// These operators depend on the release mode bounds checks in
// nsTArray::ElementAt for safety.
value_type* operator->() const {
return const_cast<value_type*>(&(*mArray)[mIndex]);
}
value_type& operator*() const {
return const_cast<value_type&>((*mArray)[mIndex]);
}
iterator_type& operator++() {
++mIndex;
return *this;
}
iterator_type operator++(int) {
iterator_type it = *this;
++*this;
return it;
}
iterator_type& operator--() {
--mIndex;
return *this;
}
iterator_type operator--(int) {
iterator_type it = *this;
--*this;
return it;
}
iterator_type& operator+=(difference_type aDiff) {
mIndex += aDiff;
return *this;
}
iterator_type& operator-=(difference_type aDiff) {
mIndex -= aDiff;
return *this;
}
iterator_type operator+(difference_type aDiff) const {
iterator_type it = *this;
it += aDiff;
return it;
}
iterator_type operator-(difference_type aDiff) const {
iterator_type it = *this;
it -= aDiff;
return it;
}
difference_type operator-(const iterator_type& aOther) const {
return static_cast<difference_type>(mIndex) -
static_cast<difference_type>(aOther.mIndex);
}
value_type& operator[](difference_type aIndex) const {
return *this->operator+(aIndex);
}
};
// Servo bindings.
extern "C" void Gecko_EnsureTArrayCapacity(void* aArray,
size_t aCapacity,
@ -860,8 +978,8 @@ public:
typedef nsTArray_Impl<E, Alloc> self_type;
typedef nsTArrayElementTraits<E> elem_traits;
typedef nsTArray_SafeElementAtHelper<E, self_type> safeelementat_helper_type;
typedef mozilla::ArrayIterator<elem_type&, nsTArray<E>> iterator;
typedef mozilla::ArrayIterator<const elem_type&, nsTArray<E>> const_iterator;
typedef nsTArrayIterator<elem_type> iterator;
typedef nsTArrayIterator<const elem_type> const_iterator;
typedef mozilla::ReverseIterator<iterator> reverse_iterator;
typedef mozilla::ReverseIterator<const_iterator> const_reverse_iterator;

Просмотреть файл

@ -27,6 +27,16 @@
using namespace mozilla;
static bool notifyOpenWindow(nsIWindowMediatorListener *aElement, void* aData);
static bool notifyCloseWindow(nsIWindowMediatorListener *aElement, void* aData);
static bool notifyWindowTitleChange(nsIWindowMediatorListener *aElement, void* aData);
// for notifyWindowTitleChange
struct WindowTitleData {
nsIXULWindow* mWindow;
const char16_t *mTitle;
};
nsresult
nsWindowMediator::GetDOMWindow(nsIXULWindow* inWindow,
nsCOMPtr<nsPIDOMWindowOuter>& outDOMWindow)
@ -81,10 +91,9 @@ NS_IMETHODIMP nsWindowMediator::RegisterWindow(nsIXULWindow* inWindow)
// Create window info struct and add to list of windows
nsWindowInfo* windowInfo = new nsWindowInfo(inWindow, mTimeStamp);
for (nsIWindowMediatorListener* listener : mListeners) {
listener->OnOpenWindow(inWindow);
}
WindowTitleData winData = { inWindow, nullptr };
mListeners.EnumerateForwards(notifyOpenWindow, &winData);
if (mOldestWindow)
windowInfo->InsertAfter(mOldestWindow->mOlder, nullptr);
else
@ -114,9 +123,8 @@ nsWindowMediator::UnregisterWindow(nsWindowInfo *inInfo)
index++;
}
for (nsIWindowMediatorListener* listener : mListeners) {
listener->OnCloseWindow(inInfo->mWindow.get());
}
WindowTitleData winData = { inInfo->mWindow.get(), nullptr };
mListeners.EnumerateForwards(notifyCloseWindow, &winData);
// Remove from the lists and free up
if (inInfo == mOldestWindow)
@ -399,9 +407,8 @@ nsWindowMediator::UpdateWindowTitle(nsIXULWindow* inWindow,
MOZ_RELEASE_ASSERT(NS_IsMainThread());
NS_ENSURE_STATE(mReady);
if (GetInfoFor(inWindow)) {
for (nsIWindowMediatorListener* listener : mListeners) {
listener->OnWindowTitleChange(inWindow, inTitle);
}
WindowTitleData winData = { inWindow, inTitle };
mListeners.EnumerateForwards(notifyWindowTitleChange, &winData);
}
return NS_OK;
@ -810,3 +817,30 @@ nsWindowMediator::Observe(nsISupports* aSubject,
}
return NS_OK;
}
bool
notifyOpenWindow(nsIWindowMediatorListener *aListener, void* aData)
{
WindowTitleData* winData = static_cast<WindowTitleData*>(aData);
aListener->OnOpenWindow(winData->mWindow);
return true;
}
bool
notifyCloseWindow(nsIWindowMediatorListener *aListener, void* aData)
{
WindowTitleData* winData = static_cast<WindowTitleData*>(aData);
aListener->OnCloseWindow(winData->mWindow);
return true;
}
bool
notifyWindowTitleChange(nsIWindowMediatorListener *aListener, void* aData)
{
WindowTitleData* titleData = reinterpret_cast<WindowTitleData*>(aData);
aListener->OnWindowTitleChange(titleData->mWindow, titleData->mTitle);
return true;
}