OLD | NEW |
---|---|
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 Loading... | |
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 HashMap<AtomicString, StyleSheetContents*>& textToSheetCache() | 57 static WillBeHeapHashMap<AtomicString, RawPtrWillBeWeakMember<StyleSheetContents > >& textToSheetCache() |
zerny-chromium
2014/03/04 13:59:46
Nit: use the typedef here too.
Mads Ager (chromium)
2014/03/04 14:03:33
The typedefs are local to the methods. And typedef
| |
58 { | 58 { |
59 typedef HashMap<AtomicString, StyleSheetContents*> TextToSheetCache; | 59 typedef WillBeHeapHashMap<AtomicString, RawPtrWillBeWeakMember<StyleSheetCon tents> > TextToSheetCache; |
60 #if ENABLE(OILPAN) | |
61 DEFINE_STATIC_LOCAL(Persistent<TextToSheetCache>, cache, (new TextToSheetCac he)); | |
Erik Corry
2014/03/04 14:09:27
I think in another change we could use WillBePersi
Mads Ager (chromium)
2014/03/04 14:13:36
Yeah, it would be nice if we could do that. Let's
| |
62 return *cache; | |
63 #else | |
60 DEFINE_STATIC_LOCAL(TextToSheetCache, cache, ()); | 64 DEFINE_STATIC_LOCAL(TextToSheetCache, cache, ()); |
61 return cache; | 65 return cache; |
66 #endif | |
62 } | 67 } |
63 | 68 |
64 static HashMap<StyleSheetContents*, AtomicString>& sheetToTextCache() | 69 static WillBeHeapHashMap<RawPtrWillBeWeakMember<StyleSheetContents>, AtomicStrin g>& sheetToTextCache() |
zerny-chromium
2014/03/04 13:59:46
nit: ditto.
| |
65 { | 70 { |
66 typedef HashMap<StyleSheetContents*, AtomicString> SheetToTextCache; | 71 typedef WillBeHeapHashMap<RawPtrWillBeWeakMember<StyleSheetContents>, Atomic String> SheetToTextCache; |
72 #if ENABLE(OILPAN) | |
73 DEFINE_STATIC_LOCAL(Persistent<SheetToTextCache>, cache, (new SheetToTextCac he)); | |
74 return *cache; | |
75 #else | |
67 DEFINE_STATIC_LOCAL(SheetToTextCache, cache, ()); | 76 DEFINE_STATIC_LOCAL(SheetToTextCache, cache, ()); |
68 return cache; | 77 return cache; |
78 #endif | |
69 } | 79 } |
70 | 80 |
71 StyleEngine::StyleEngine(Document& document) | 81 StyleEngine::StyleEngine(Document& document) |
72 : m_document(document) | 82 : m_document(document) |
73 , m_isMaster(HTMLImport::isMaster(&document)) | 83 , m_isMaster(HTMLImport::isMaster(&document)) |
74 , m_pendingStylesheets(0) | 84 , m_pendingStylesheets(0) |
75 , m_injectedStyleSheetCacheValid(false) | 85 , m_injectedStyleSheetCacheValid(false) |
76 , m_documentStyleSheetCollection(document) | 86 , m_documentStyleSheetCollection(document) |
77 , m_documentScopeDirty(true) | 87 , m_documentScopeDirty(true) |
78 , m_usesSiblingRules(false) | 88 , m_usesSiblingRules(false) |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
572 | 582 |
573 PassRefPtr<CSSStyleSheet> StyleEngine::createSheet(Element* e, const String& tex t, TextPosition startPosition, bool createdByParser) | 583 PassRefPtr<CSSStyleSheet> StyleEngine::createSheet(Element* e, const String& tex t, TextPosition startPosition, bool createdByParser) |
574 { | 584 { |
575 RefPtr<CSSStyleSheet> styleSheet; | 585 RefPtr<CSSStyleSheet> styleSheet; |
576 | 586 |
577 e->document().styleEngine()->addPendingSheet(); | 587 e->document().styleEngine()->addPendingSheet(); |
578 | 588 |
579 if (!e->document().inQuirksMode()) { | 589 if (!e->document().inQuirksMode()) { |
580 AtomicString textContent(text); | 590 AtomicString textContent(text); |
581 | 591 |
582 HashMap<AtomicString, StyleSheetContents*>::AddResult result = textToShe etCache().add(textContent, 0); | 592 WillBeHeapHashMap<AtomicString, RawPtrWillBeWeakMember<StyleSheetContent s> >::AddResult result = textToSheetCache().add(textContent, nullptr); |
583 if (result.isNewEntry || !result.storedValue->value) { | 593 if (result.isNewEntry || !result.storedValue->value) { |
584 styleSheet = StyleEngine::parseSheet(e, text, startPosition, created ByParser); | 594 styleSheet = StyleEngine::parseSheet(e, text, startPosition, created ByParser); |
585 if (result.isNewEntry && styleSheet->contents()->maybeCacheable()) { | 595 if (result.isNewEntry && styleSheet->contents()->maybeCacheable()) { |
586 result.storedValue->value = styleSheet->contents(); | 596 result.storedValue->value = styleSheet->contents(); |
587 sheetToTextCache().add(styleSheet->contents(), textContent); | 597 sheetToTextCache().add(styleSheet->contents(), textContent); |
588 } | 598 } |
589 } else { | 599 } else { |
590 ASSERT(result.storedValue->value->maybeCacheable()); | 600 ASSERT(result.storedValue->value->maybeCacheable()); |
591 styleSheet = CSSStyleSheet::createInline(result.storedValue->value, e, startPosition); | 601 styleSheet = CSSStyleSheet::createInline(result.storedValue->value, e, startPosition); |
592 } | 602 } |
(...skipping 10 matching lines...) Expand all Loading... | |
603 PassRefPtr<CSSStyleSheet> StyleEngine::parseSheet(Element* e, const String& text , TextPosition startPosition, bool createdByParser) | 613 PassRefPtr<CSSStyleSheet> StyleEngine::parseSheet(Element* e, const String& text , TextPosition startPosition, bool createdByParser) |
604 { | 614 { |
605 RefPtr<CSSStyleSheet> styleSheet; | 615 RefPtr<CSSStyleSheet> styleSheet; |
606 styleSheet = CSSStyleSheet::createInline(e, KURL(), startPosition, e->docume nt().inputEncoding()); | 616 styleSheet = CSSStyleSheet::createInline(e, KURL(), startPosition, e->docume nt().inputEncoding()); |
607 styleSheet->contents()->parseStringAtPosition(text, startPosition, createdBy Parser); | 617 styleSheet->contents()->parseStringAtPosition(text, startPosition, createdBy Parser); |
608 return styleSheet; | 618 return styleSheet; |
609 } | 619 } |
610 | 620 |
611 void StyleEngine::removeSheet(StyleSheetContents* contents) | 621 void StyleEngine::removeSheet(StyleSheetContents* contents) |
612 { | 622 { |
613 HashMap<StyleSheetContents*, AtomicString>::iterator it = sheetToTextCache() .find(contents); | 623 WillBeHeapHashMap<RawPtrWillBeWeakMember<StyleSheetContents>, AtomicString>: :iterator it = sheetToTextCache().find(contents); |
614 if (it == sheetToTextCache().end()) | 624 if (it == sheetToTextCache().end()) |
615 return; | 625 return; |
616 | 626 |
617 textToSheetCache().remove(it->value); | 627 textToSheetCache().remove(it->value); |
618 sheetToTextCache().remove(contents); | 628 sheetToTextCache().remove(contents); |
619 } | 629 } |
620 | 630 |
621 } | 631 } |
OLD | NEW |