Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(923)

Side by Side Diff: Source/core/dom/StyleEngine.cpp

Issue 187473003: Revert of Oilpan: Use weak pointers in StyleSheetContents caches. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/css/StyleSheetContents.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved.
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 #include "core/page/InjectedStyleSheets.h" 47 #include "core/page/InjectedStyleSheets.h"
48 #include "core/page/Page.h" 48 #include "core/page/Page.h"
49 #include "core/frame/Settings.h" 49 #include "core/frame/Settings.h"
50 #include "core/svg/SVGStyleElement.h" 50 #include "core/svg/SVGStyleElement.h"
51 #include "platform/URLPatternMatcher.h" 51 #include "platform/URLPatternMatcher.h"
52 52
53 namespace WebCore { 53 namespace WebCore {
54 54
55 using namespace HTMLNames; 55 using namespace HTMLNames;
56 56
57 static WillBeHeapHashMap<AtomicString, RawPtrWillBeWeakMember<StyleSheetContents > >& textToSheetCache() 57 static HashMap<AtomicString, StyleSheetContents*>& textToSheetCache()
58 { 58 {
59 typedef WillBeHeapHashMap<AtomicString, RawPtrWillBeWeakMember<StyleSheetCon tents> > TextToSheetCache; 59 typedef HashMap<AtomicString, StyleSheetContents*> TextToSheetCache;
60 #if ENABLE(OILPAN)
61 DEFINE_STATIC_LOCAL(Persistent<TextToSheetCache>, cache, (new TextToSheetCac he));
62 return *cache;
63 #else
64 DEFINE_STATIC_LOCAL(TextToSheetCache, cache, ()); 60 DEFINE_STATIC_LOCAL(TextToSheetCache, cache, ());
65 return cache; 61 return cache;
66 #endif
67 } 62 }
68 63
69 static WillBeHeapHashMap<RawPtrWillBeWeakMember<StyleSheetContents>, AtomicStrin g>& sheetToTextCache() 64 static HashMap<StyleSheetContents*, AtomicString>& sheetToTextCache()
70 { 65 {
71 typedef WillBeHeapHashMap<RawPtrWillBeWeakMember<StyleSheetContents>, Atomic String> SheetToTextCache; 66 typedef HashMap<StyleSheetContents*, AtomicString> SheetToTextCache;
72 #if ENABLE(OILPAN)
73 DEFINE_STATIC_LOCAL(Persistent<SheetToTextCache>, cache, (new SheetToTextCac he));
74 return *cache;
75 #else
76 DEFINE_STATIC_LOCAL(SheetToTextCache, cache, ()); 67 DEFINE_STATIC_LOCAL(SheetToTextCache, cache, ());
77 return cache; 68 return cache;
78 #endif
79 } 69 }
80 70
81 StyleEngine::StyleEngine(Document& document) 71 StyleEngine::StyleEngine(Document& document)
82 : m_document(document) 72 : m_document(document)
83 , m_isMaster(HTMLImport::isMaster(&document)) 73 , m_isMaster(HTMLImport::isMaster(&document))
84 , m_pendingStylesheets(0) 74 , m_pendingStylesheets(0)
85 , m_injectedStyleSheetCacheValid(false) 75 , m_injectedStyleSheetCacheValid(false)
86 , m_documentStyleSheetCollection(document) 76 , m_documentStyleSheetCollection(document)
87 , m_documentScopeDirty(true) 77 , m_documentScopeDirty(true)
88 , m_usesSiblingRules(false) 78 , m_usesSiblingRules(false)
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 572
583 PassRefPtr<CSSStyleSheet> StyleEngine::createSheet(Element* e, const String& tex t, TextPosition startPosition, bool createdByParser) 573 PassRefPtr<CSSStyleSheet> StyleEngine::createSheet(Element* e, const String& tex t, TextPosition startPosition, bool createdByParser)
584 { 574 {
585 RefPtr<CSSStyleSheet> styleSheet; 575 RefPtr<CSSStyleSheet> styleSheet;
586 576
587 e->document().styleEngine()->addPendingSheet(); 577 e->document().styleEngine()->addPendingSheet();
588 578
589 if (!e->document().inQuirksMode()) { 579 if (!e->document().inQuirksMode()) {
590 AtomicString textContent(text); 580 AtomicString textContent(text);
591 581
592 WillBeHeapHashMap<AtomicString, RawPtrWillBeWeakMember<StyleSheetContent s> >::AddResult result = textToSheetCache().add(textContent, RawPtrWillBeWeakMem ber<StyleSheetContents>(nullptr)); 582 HashMap<AtomicString, StyleSheetContents*>::AddResult result = textToShe etCache().add(textContent, 0);
593 if (result.isNewEntry || !result.storedValue->value) { 583 if (result.isNewEntry || !result.storedValue->value) {
594 styleSheet = StyleEngine::parseSheet(e, text, startPosition, created ByParser); 584 styleSheet = StyleEngine::parseSheet(e, text, startPosition, created ByParser);
595 if (result.isNewEntry && styleSheet->contents()->maybeCacheable()) { 585 if (result.isNewEntry && styleSheet->contents()->maybeCacheable()) {
596 result.storedValue->value = styleSheet->contents(); 586 result.storedValue->value = styleSheet->contents();
597 sheetToTextCache().add(styleSheet->contents(), textContent); 587 sheetToTextCache().add(styleSheet->contents(), textContent);
598 } 588 }
599 } else { 589 } else {
600 ASSERT(result.storedValue->value->maybeCacheable()); 590 ASSERT(result.storedValue->value->maybeCacheable());
601 styleSheet = CSSStyleSheet::createInline(result.storedValue->value, e, startPosition); 591 styleSheet = CSSStyleSheet::createInline(result.storedValue->value, e, startPosition);
602 } 592 }
(...skipping 10 matching lines...) Expand all
613 PassRefPtr<CSSStyleSheet> StyleEngine::parseSheet(Element* e, const String& text , TextPosition startPosition, bool createdByParser) 603 PassRefPtr<CSSStyleSheet> StyleEngine::parseSheet(Element* e, const String& text , TextPosition startPosition, bool createdByParser)
614 { 604 {
615 RefPtr<CSSStyleSheet> styleSheet; 605 RefPtr<CSSStyleSheet> styleSheet;
616 styleSheet = CSSStyleSheet::createInline(e, KURL(), startPosition, e->docume nt().inputEncoding()); 606 styleSheet = CSSStyleSheet::createInline(e, KURL(), startPosition, e->docume nt().inputEncoding());
617 styleSheet->contents()->parseStringAtPosition(text, startPosition, createdBy Parser); 607 styleSheet->contents()->parseStringAtPosition(text, startPosition, createdBy Parser);
618 return styleSheet; 608 return styleSheet;
619 } 609 }
620 610
621 void StyleEngine::removeSheet(StyleSheetContents* contents) 611 void StyleEngine::removeSheet(StyleSheetContents* contents)
622 { 612 {
623 WillBeHeapHashMap<RawPtrWillBeWeakMember<StyleSheetContents>, AtomicString>: :iterator it = sheetToTextCache().find(contents); 613 HashMap<StyleSheetContents*, AtomicString>::iterator it = sheetToTextCache() .find(contents);
624 if (it == sheetToTextCache().end()) 614 if (it == sheetToTextCache().end())
625 return; 615 return;
626 616
627 textToSheetCache().remove(it->value); 617 textToSheetCache().remove(it->value);
628 sheetToTextCache().remove(contents); 618 sheetToTextCache().remove(contents);
629 } 619 }
630 620
631 } 621 }
OLDNEW
« no previous file with comments | « Source/core/css/StyleSheetContents.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698