OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "core/page/Page.h" | 32 #include "core/page/Page.h" |
33 | 33 |
34 namespace WebCore { | 34 namespace WebCore { |
35 | 35 |
36 PageGroup::PageGroup() | 36 PageGroup::PageGroup() |
37 { | 37 { |
38 } | 38 } |
39 | 39 |
40 PageGroup::~PageGroup() | 40 PageGroup::~PageGroup() |
41 { | 41 { |
42 removeAllUserContent(); | 42 removeInjectedStyleSheets(); |
43 } | 43 } |
44 | 44 |
45 PageGroup* PageGroup::sharedGroup() | 45 PageGroup* PageGroup::sharedGroup() |
46 { | 46 { |
47 static PageGroup* staticSharedGroup = create().leakRef(); | 47 static PageGroup* staticSharedGroup = create().leakRef(); |
48 return staticSharedGroup; | 48 return staticSharedGroup; |
49 } | 49 } |
50 | 50 |
51 PageGroup* PageGroup::inspectorGroup() | 51 PageGroup* PageGroup::inspectorGroup() |
52 { | 52 { |
53 static PageGroup* staticInspectorGroup = create().leakRef(); | 53 static PageGroup* staticInspectorGroup = create().leakRef(); |
54 return staticInspectorGroup; | 54 return staticInspectorGroup; |
55 } | 55 } |
56 | 56 |
57 void PageGroup::addPage(Page* page) | 57 void PageGroup::addPage(Page* page) |
58 { | 58 { |
59 ASSERT(page); | 59 ASSERT(page); |
60 ASSERT(!m_pages.contains(page)); | 60 ASSERT(!m_pages.contains(page)); |
61 m_pages.add(page); | 61 m_pages.add(page); |
62 } | 62 } |
63 | 63 |
64 void PageGroup::removePage(Page* page) | 64 void PageGroup::removePage(Page* page) |
65 { | 65 { |
66 ASSERT(page); | 66 ASSERT(page); |
67 ASSERT(m_pages.contains(page)); | 67 ASSERT(m_pages.contains(page)); |
68 m_pages.remove(page); | 68 m_pages.remove(page); |
69 } | 69 } |
70 | 70 |
71 void PageGroup::addUserStyleSheet(const String& source, const KURL& url, | 71 void PageGroup::injectStyleSheet(const String& source, const Vector<String>& whi
telist, StyleInjectionTarget injectIn) |
72 const Vector<String>& whitelist, const Vector<
String>& blacklist, | |
73 UserContentInjectedFrames injectedFrames, | |
74 UserStyleLevel level, | |
75 UserStyleInjectionTime injectionTime) | |
76 { | 72 { |
77 m_userStyleSheets.append(adoptPtr(new UserStyleSheet(source, url, whitelist,
blacklist, injectedFrames, level))); | 73 m_injectedStyleSheets.append(adoptPtr(new InjectedStyleSheet(source, whiteli
st, injectIn))); |
78 | |
79 if (injectionTime == InjectInExistingDocuments) | |
80 invalidatedInjectedStyleSheetCacheInAllFrames(); | |
81 } | |
82 | |
83 void PageGroup::removeAllUserContent() | |
84 { | |
85 m_userStyleSheets.clear(); | |
86 invalidatedInjectedStyleSheetCacheInAllFrames(); | 74 invalidatedInjectedStyleSheetCacheInAllFrames(); |
87 } | 75 } |
88 | 76 |
| 77 void PageGroup::removeInjectedStyleSheets() |
| 78 { |
| 79 m_injectedStyleSheets.clear(); |
| 80 invalidatedInjectedStyleSheetCacheInAllFrames(); |
| 81 } |
| 82 |
89 void PageGroup::invalidatedInjectedStyleSheetCacheInAllFrames() | 83 void PageGroup::invalidatedInjectedStyleSheetCacheInAllFrames() |
90 { | 84 { |
91 // Clear our cached sheets and have them just reparse. | 85 // Clear our cached sheets and have them just reparse. |
92 HashSet<Page*>::const_iterator end = m_pages.end(); | 86 HashSet<Page*>::const_iterator end = m_pages.end(); |
93 for (HashSet<Page*>::const_iterator it = m_pages.begin(); it != end; ++it) { | 87 for (HashSet<Page*>::const_iterator it = m_pages.begin(); it != end; ++it) { |
94 for (Frame* frame = (*it)->mainFrame(); frame; frame = frame->tree()->tr
averseNext()) | 88 for (Frame* frame = (*it)->mainFrame(); frame; frame = frame->tree()->tr
averseNext()) |
95 frame->document()->styleEngine()->invalidateInjectedStyleSheetCache(
); | 89 frame->document()->styleEngine()->invalidateInjectedStyleSheetCache(
); |
96 } | 90 } |
97 } | 91 } |
98 | 92 |
99 } // namespace WebCore | 93 } // namespace WebCore |
OLD | NEW |