Commit 81dd8384 authored by ager@chromium.org's avatar ager@chromium.org

Revert of Oilpan: Use weak pointers in StyleSheetContents caches....

Revert of Oilpan: Use weak pointers in StyleSheetContents caches. (https://codereview.chromium.org/185403016/)

Reason for revert:
This patch seems to have made a number of layout tests fail on the oilpan bots. Reverting while I investigate.

Original issue's description:
> Oilpan: Use weak pointers in StyleSheetContents caches.
> 
> This fixes use-after-free that could occur when StyleSheetContents
> dies when an allocation happens during insertion of a new
> StyleSheetContents. Using the built-in weak processing this will
> not happen because the iterator used during insertion will keep
> the StyleSheetContents alive.
> 
> R=erik.corry@gmail.com, haraken@chromium.org, vegorov@chromium.org
> NOTRY=true
> 
> Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=168444

TBR=erik.corry@gmail.com,haraken@chromium.org,vegorov@chromium.org,zerny@chromium.org
NOTREECHECKS=true
NOTRY=true

Review URL: https://codereview.chromium.org/187473003

git-svn-id: svn://svn.chromium.org/blink/trunk@168458 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 8fec9e3e
......@@ -97,8 +97,8 @@ StyleSheetContents::StyleSheetContents(const StyleSheetContents& o)
StyleSheetContents::~StyleSheetContents()
{
#if !ENABLE(OILPAN)
StyleEngine::removeSheet(this);
#if !ENABLE(OILPAN)
clearRules();
#endif
}
......
......@@ -54,28 +54,18 @@ namespace WebCore {
using namespace HTMLNames;
static WillBeHeapHashMap<AtomicString, RawPtrWillBeWeakMember<StyleSheetContents> >& textToSheetCache()
static HashMap<AtomicString, StyleSheetContents*>& textToSheetCache()
{
typedef WillBeHeapHashMap<AtomicString, RawPtrWillBeWeakMember<StyleSheetContents> > TextToSheetCache;
#if ENABLE(OILPAN)
DEFINE_STATIC_LOCAL(Persistent<TextToSheetCache>, cache, (new TextToSheetCache));
return *cache;
#else
typedef HashMap<AtomicString, StyleSheetContents*> TextToSheetCache;
DEFINE_STATIC_LOCAL(TextToSheetCache, cache, ());
return cache;
#endif
}
static WillBeHeapHashMap<RawPtrWillBeWeakMember<StyleSheetContents>, AtomicString>& sheetToTextCache()
static HashMap<StyleSheetContents*, AtomicString>& sheetToTextCache()
{
typedef WillBeHeapHashMap<RawPtrWillBeWeakMember<StyleSheetContents>, AtomicString> SheetToTextCache;
#if ENABLE(OILPAN)
DEFINE_STATIC_LOCAL(Persistent<SheetToTextCache>, cache, (new SheetToTextCache));
return *cache;
#else
typedef HashMap<StyleSheetContents*, AtomicString> SheetToTextCache;
DEFINE_STATIC_LOCAL(SheetToTextCache, cache, ());
return cache;
#endif
}
StyleEngine::StyleEngine(Document& document)
......@@ -589,7 +579,7 @@ PassRefPtr<CSSStyleSheet> StyleEngine::createSheet(Element* e, const String& tex
if (!e->document().inQuirksMode()) {
AtomicString textContent(text);
WillBeHeapHashMap<AtomicString, RawPtrWillBeWeakMember<StyleSheetContents> >::AddResult result = textToSheetCache().add(textContent, RawPtrWillBeWeakMember<StyleSheetContents>(nullptr));
HashMap<AtomicString, StyleSheetContents*>::AddResult result = textToSheetCache().add(textContent, 0);
if (result.isNewEntry || !result.storedValue->value) {
styleSheet = StyleEngine::parseSheet(e, text, startPosition, createdByParser);
if (result.isNewEntry && styleSheet->contents()->maybeCacheable()) {
......@@ -620,7 +610,7 @@ PassRefPtr<CSSStyleSheet> StyleEngine::parseSheet(Element* e, const String& text
void StyleEngine::removeSheet(StyleSheetContents* contents)
{
WillBeHeapHashMap<RawPtrWillBeWeakMember<StyleSheetContents>, AtomicString>::iterator it = sheetToTextCache().find(contents);
HashMap<StyleSheetContents*, AtomicString>::iterator it = sheetToTextCache().find(contents);
if (it == sheetToTextCache().end())
return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment