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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
45 #include "core/inspector/InspectorInstrumentation.h" | 45 #include "core/inspector/InspectorInstrumentation.h" |
46 #include "core/page/Page.h" | 46 #include "core/page/Page.h" |
47 #include "core/page/PageGroup.h" | 47 #include "core/page/PageGroup.h" |
48 #include "core/svg/SVGStyleElement.h" | 48 #include "core/svg/SVGStyleElement.h" |
49 #include "platform/URLPatternMatcher.h" | 49 #include "platform/URLPatternMatcher.h" |
50 | 50 |
51 namespace WebCore { | 51 namespace WebCore { |
52 | 52 |
53 using namespace HTMLNames; | 53 using namespace HTMLNames; |
54 | 54 |
55 | |
56 static HashMap<AtomicString, StyleSheetContents*>& textToSheetCache() | |
57 { | |
58 typedef HashMap<AtomicString, StyleSheetContents*> TextToSheetCache; | |
59 DEFINE_STATIC_LOCAL(TextToSheetCache, cache, ()); | |
60 return cache; | |
61 } | |
62 | |
63 static HashMap<StyleSheetContents*, AtomicString>& sheetToTextCache() | |
64 { | |
65 typedef HashMap<StyleSheetContents*, AtomicString> SheetToTextCache; | |
66 DEFINE_STATIC_LOCAL(SheetToTextCache, cache, ()); | |
67 return cache; | |
68 } | |
69 | |
55 StyleEngine::StyleEngine(Document& document) | 70 StyleEngine::StyleEngine(Document& document) |
56 : m_document(document) | 71 : m_document(document) |
57 , m_isMaster(HTMLImport::isMaster(&document)) | 72 , m_isMaster(HTMLImport::isMaster(&document)) |
58 , m_pendingStylesheets(0) | 73 , m_pendingStylesheets(0) |
59 , m_injectedStyleSheetCacheValid(false) | 74 , m_injectedStyleSheetCacheValid(false) |
60 , m_needsUpdateActiveStylesheetsOnStyleRecalc(false) | 75 , m_needsUpdateActiveStylesheetsOnStyleRecalc(false) |
61 , m_documentStyleSheetCollection(document) | 76 , m_documentStyleSheetCollection(document) |
62 , m_documentScopeDirty(true) | 77 , m_documentScopeDirty(true) |
63 , m_usesSiblingRules(false) | 78 , m_usesSiblingRules(false) |
64 , m_usesSiblingRulesOverride(false) | 79 , m_usesSiblingRulesOverride(false) |
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
577 m_dirtyTreeScopes.add(&scope); | 592 m_dirtyTreeScopes.add(&scope); |
578 } | 593 } |
579 | 594 |
580 void StyleEngine::markDocumentDirty() | 595 void StyleEngine::markDocumentDirty() |
581 { | 596 { |
582 m_documentScopeDirty = true; | 597 m_documentScopeDirty = true; |
583 if (!HTMLImport::isMaster(&m_document)) | 598 if (!HTMLImport::isMaster(&m_document)) |
584 m_document.import()->master()->styleEngine()->markDocumentDirty(); | 599 m_document.import()->master()->styleEngine()->markDocumentDirty(); |
585 } | 600 } |
586 | 601 |
602 PassRefPtr<CSSStyleSheet> StyleEngine::createSheet(Element* e, const String& tex t, TextPosition startPosition, bool createdByParser) | |
603 { | |
604 AtomicString textContent(text); | |
605 | |
606 HashMap<AtomicString, StyleSheetContents*>::AddResult result = textToSheetCa che().add(textContent, 0); | |
607 | |
608 e->document().styleEngine()->addPendingSheet(); | |
609 | |
610 RefPtr<CSSStyleSheet> styleSheet; | |
611 if (result.isNewEntry || !result.iterator->value) { | |
612 styleSheet = CSSStyleSheet::createInline(e, KURL(), startPosition, e->do cument().inputEncoding()); | |
613 styleSheet->contents()->parseStringAtPosition(text, startPosition, creat edByParser); | |
614 | |
615 if (result.isNewEntry && styleSheet->contents()->maybeCacheable()) { | |
616 result.iterator->value = styleSheet->contents(); | |
617 sheetToTextCache().add(styleSheet->contents(), textContent); | |
618 } | |
619 } else { | |
620 ASSERT(result.iterator->value->maybeCacheable()); | |
621 styleSheet = CSSStyleSheet::createInline(result.iterator->value, e, star tPosition); | |
622 } | |
623 | |
624 ASSERT(styleSheet); | |
625 styleSheet->setTitle(e->title()); | |
626 | |
627 return styleSheet; | |
587 } | 628 } |
629 | |
630 void StyleEngine::removeSheet(StyleSheetContents* contents) | |
631 { | |
632 HashMap<StyleSheetContents*, AtomicString>::iterator it = sheetToTextCache() .find(contents); | |
633 if (it == sheetToTextCache().end()) | |
634 return; | |
635 | |
636 textToSheetCache().remove(it->value); | |
637 sheetToTextCache().remove(contents); | |
638 } | |
639 | |
640 void StyleEngine::clearSheetCache() | |
esprehn
2014/01/09 10:05:32
This method can't exist.
tasak
2014/01/09 11:59:05
Done.
| |
641 { | |
642 textToSheetCache().clear(); | |
643 sheetToTextCache().clear(); | |
644 } | |
645 | |
646 } | |
OLD | NEW |