mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backed out changeset d20b53c907ee (bug 863966) for leaks.
This commit is contained in:
parent
40682fda49
commit
a042ae2926
@ -27,8 +27,6 @@
|
||||
#include "nsTHashtable.h" // for member
|
||||
#include "mozilla/dom/DocumentBinding.h"
|
||||
#include "Units.h"
|
||||
#include "nsExpirationTracker.h"
|
||||
#include "nsClassHashtable.h"
|
||||
|
||||
class imgIRequest;
|
||||
class nsAString;
|
||||
@ -82,7 +80,6 @@ class nsDOMCaretPosition;
|
||||
class nsViewportInfo;
|
||||
class nsDOMEvent;
|
||||
class nsIGlobalObject;
|
||||
class nsCSSSelectorList;
|
||||
|
||||
namespace mozilla {
|
||||
class ErrorResult;
|
||||
@ -663,56 +660,7 @@ public:
|
||||
protected:
|
||||
virtual Element *GetRootElementInternal() const = 0;
|
||||
|
||||
private:
|
||||
class SelectorCacheKey
|
||||
{
|
||||
public:
|
||||
SelectorCacheKey(const nsAString& aString) : mKey(aString) { }
|
||||
|
||||
nsString mKey;
|
||||
nsExpirationState mState;
|
||||
|
||||
nsExpirationState* GetExpirationState() { return &mState; }
|
||||
};
|
||||
|
||||
public:
|
||||
class SelectorCache MOZ_FINAL
|
||||
: public nsExpirationTracker<SelectorCacheKey, 4>
|
||||
{
|
||||
public:
|
||||
SelectorCache();
|
||||
|
||||
// CacheList takes ownership of aSelectorList.
|
||||
void CacheList(const nsAString& aSelector, nsCSSSelectorList* aSelectorList);
|
||||
|
||||
// We do not call MarkUsed because it would just slow down lookups and
|
||||
// because we're OK expiring things after a few seconds even if they're
|
||||
// being used.
|
||||
nsCSSSelectorList* GetList(const nsAString& aSelector)
|
||||
{
|
||||
return mTable.Get(aSelector);
|
||||
}
|
||||
|
||||
virtual void NotifyExpired(SelectorCacheKey* aSelector)
|
||||
{
|
||||
RemoveObject(aSelector);
|
||||
mTable.Remove(aSelector->mKey);
|
||||
delete aSelector;
|
||||
}
|
||||
|
||||
~SelectorCache()
|
||||
{
|
||||
MOZ_COUNT_DTOR(SelectorCache);
|
||||
}
|
||||
|
||||
private:
|
||||
nsClassHashtable<nsStringHashKey, nsCSSSelectorList> mTable;
|
||||
};
|
||||
|
||||
SelectorCache& GetSelectorCache()
|
||||
{
|
||||
return mSelectorCache;
|
||||
}
|
||||
// Get the root <html> element, or return null if there isn't one (e.g.
|
||||
// if the root isn't <html>)
|
||||
Element* GetHtmlElement() const;
|
||||
@ -2185,7 +2133,6 @@ public:
|
||||
|
||||
private:
|
||||
uint64_t mWarnedAbout;
|
||||
SelectorCache mSelectorCache;
|
||||
|
||||
protected:
|
||||
~nsIDocument();
|
||||
|
@ -1315,20 +1315,6 @@ nsDOMStyleSheetSetList::GetSets(nsTArray<nsString>& aStyleSets)
|
||||
}
|
||||
|
||||
// ==================================================================
|
||||
nsIDocument::SelectorCache::SelectorCache()
|
||||
: nsExpirationTracker<SelectorCacheKey, 4>(1000)
|
||||
{
|
||||
MOZ_COUNT_CTOR(SelectorCache);
|
||||
}
|
||||
|
||||
// CacheList takes ownership of aSelectorList.
|
||||
void nsIDocument::SelectorCache::CacheList(const nsAString& aSelector,
|
||||
nsCSSSelectorList* aSelectorList)
|
||||
{
|
||||
SelectorCacheKey* key = new SelectorCacheKey(aSelector);
|
||||
mTable.Put(key->mKey, aSelectorList);
|
||||
AddObject(key);
|
||||
}
|
||||
|
||||
struct nsIDocument::FrameRequest
|
||||
{
|
||||
|
@ -2338,30 +2338,21 @@ template<bool onlyFirstMatch, class T>
|
||||
inline static nsresult
|
||||
FindMatchingElements(nsINode* aRoot, const nsAString& aSelector, T &aList)
|
||||
{
|
||||
|
||||
nsIDocument* doc = aRoot->OwnerDoc();
|
||||
nsIDocument::SelectorCache& cache = doc->GetSelectorCache();
|
||||
nsCSSSelectorList* selectorList = cache.GetList(aSelector);
|
||||
|
||||
if (!selectorList) {
|
||||
nsresult rv = ParseSelectorList(aRoot, aSelector,
|
||||
&selectorList);
|
||||
if (NS_FAILED(rv)) {
|
||||
delete selectorList;
|
||||
// We hit this for syntax errors, which are quite common, so don't
|
||||
// use NS_ENSURE_SUCCESS. (For example, jQuery has an extended set
|
||||
// of selectors, but it sees if we can parse them first.)
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_ENSURE_TRUE(selectorList, NS_OK);
|
||||
|
||||
cache.CacheList(aSelector, selectorList);
|
||||
nsAutoPtr<nsCSSSelectorList> selectorList;
|
||||
nsresult rv = ParseSelectorList(aRoot, aSelector,
|
||||
getter_Transfers(selectorList));
|
||||
if (NS_FAILED(rv)) {
|
||||
// We hit this for syntax errors, which are quite common, so don't
|
||||
// use NS_ENSURE_SUCCESS. (For example, jQuery has an extended set
|
||||
// of selectors, but it sees if we can parse them first.)
|
||||
return rv;
|
||||
}
|
||||
NS_ENSURE_TRUE(selectorList, NS_OK);
|
||||
|
||||
NS_ASSERTION(selectorList->mSelectors,
|
||||
"How can we not have any selectors?");
|
||||
|
||||
nsIDocument* doc = aRoot->OwnerDoc();
|
||||
TreeMatchContext matchingContext(false, nsRuleWalker::eRelevantLinkUnvisited,
|
||||
doc, TreeMatchContext::eNeverMatchVisited);
|
||||
doc->FlushPendingLinkUpdates();
|
||||
|
Loading…
Reference in New Issue
Block a user