Back out 99b749ea1fb9 (bug 863966) on suspicion of causing frequent Android robocop-2 crashes

This commit is contained in:
Phil Ringnalda 2013-10-04 19:36:53 -07:00
parent 27ca55de54
commit 1e33cf41ff
3 changed files with 10 additions and 120 deletions

View File

@ -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,61 +660,7 @@ public:
protected:
virtual Element *GetRootElementInternal() const = 0;
private:
class SelectorCacheKey
{
public:
SelectorCacheKey(const nsAString& aString) : mKey(aString)
{
MOZ_COUNT_CTOR(SelectorCacheKey);
}
nsString mKey;
nsExpirationState mState;
nsExpirationState* GetExpirationState() { return &mState; }
~SelectorCacheKey()
{
MOZ_COUNT_DTOR(SelectorCacheKey);
}
};
class SelectorCacheKeyDeleter;
public:
class SelectorCache MOZ_FINAL
: public nsExpirationTracker<SelectorCacheKey, 4>
{
public:
SelectorCache();
// CacheList takes ownership of aSelectorList.
void CacheList(const nsAString& aSelector, nsCSSSelectorList* aSelectorList);
virtual void NotifyExpired(SelectorCacheKey* aSelector) MOZ_OVERRIDE;
// 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);
}
~SelectorCache()
{
AgeAllGenerations();
}
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;
@ -2190,7 +2133,6 @@ public:
private:
uint64_t mWarnedAbout;
SelectorCache mSelectorCache;
protected:
~nsIDocument();

View File

@ -1315,49 +1315,6 @@ nsDOMStyleSheetSetList::GetSets(nsTArray<nsString>& aStyleSets)
}
// ==================================================================
nsIDocument::SelectorCache::SelectorCache()
: nsExpirationTracker<SelectorCacheKey, 4>(1000) { }
// 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);
}
class nsIDocument::SelectorCacheKeyDeleter MOZ_FINAL : public nsRunnable
{
public:
explicit SelectorCacheKeyDeleter(SelectorCacheKey* aToDelete)
: mSelector(aToDelete)
{
MOZ_COUNT_CTOR(SelectorCacheKeyDeleter);
}
~SelectorCacheKeyDeleter()
{
MOZ_COUNT_DTOR(SelectorCacheKeyDeleter);
}
NS_IMETHOD Run()
{
return NS_OK;
}
private:
nsAutoPtr<SelectorCacheKey> mSelector;
};
void nsIDocument::SelectorCache::NotifyExpired(SelectorCacheKey* aSelector)
{
RemoveObject(aSelector);
mTable.Remove(aSelector->mKey);
nsCOMPtr<nsIRunnable> runnable = new SelectorCacheKeyDeleter(aSelector);
NS_DispatchToCurrentThread(runnable);
}
struct nsIDocument::FrameRequest
{

View File

@ -2337,30 +2337,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();