Diff
Modified: trunk/Source/WebCore/ChangeLog (183194 => 183195)
--- trunk/Source/WebCore/ChangeLog 2015-04-23 17:48:37 UTC (rev 183194)
+++ trunk/Source/WebCore/ChangeLog 2015-04-23 17:52:21 UTC (rev 183195)
@@ -1,3 +1,54 @@
+2015-04-23 Brady Eidson <[email protected]>
+
+ Content extension with oft-repeated rules can cause slowdown.
+ rdar://problem/20618511 and https://bugs.webkit.org/show_bug.cgi?id=144010
+
+ Reviewed by Alex Christensen.
+
+ No new tests (Behavior covered by existing tests).
+
+ * WebCore.xcodeproj/project.pbxproj:
+
+ * contentextensions/ContentExtension.cpp:
+ (WebCore::ContentExtensions::ContentExtension::globalDisplayNoneStyleSheet):
+
+ Add the String identifier for the extension and the rule action ID to Actions:
+ * contentextensions/ContentExtensionRule.cpp:
+ (WebCore::ContentExtensions::Action::deserialize):
+ * contentextensions/ContentExtensionRule.h:
+ (WebCore::ContentExtensions::Action::Action):
+ (WebCore::ContentExtensions::Action::operator==):
+ (WebCore::ContentExtensions::Action::setExtensionIdentifier):
+ (WebCore::ContentExtensions::Action::extensionIdentifier):
+ (WebCore::ContentExtensions::Action::actionID):
+ (WebCore::ContentExtensions::Action::type): Deleted.
+
+ Object to manage a CSSStyleSheet and selectors identified by ID:
+ * contentextensions/ContentExtensionStyleSheet.cpp:
+ (WebCore::ContentExtensions::ContentExtensionStyleSheet::ContentExtensionStyleSheet):
+ (WebCore::ContentExtensions::ContentExtensionStyleSheet::addDisplayNoneSelector):
+ * contentextensions/ContentExtensionStyleSheet.h:
+ (WebCore::ContentExtensions::ContentExtensionStyleSheet::create):
+ (WebCore::ContentExtensions::ContentExtensionStyleSheet::styleSheet):
+
+ Instead of globbing selectors together into a String and making a new stylesheet,
+ add new unique selectors to an already existing sheet:
+ * contentextensions/ContentExtensionsBackend.cpp:
+ (WebCore::ContentExtensions::ContentExtensionsBackend::actionsForResourceLoad):
+ (WebCore::ContentExtensions::ContentExtensionsBackend::processContentExtensionRulesForLoad):
+ (WebCore::ContentExtensions::ContentExtensionsBackend::displayNoneCSSRule):
+
+ * dom/DocumentStyleSheetCollection.cpp:
+ (WebCore::DocumentStyleSheetCollection::addDisplayNoneSelector):
+ (WebCore::DocumentStyleSheetCollection::addContentExtensionUserSheet): Deleted.
+ * dom/DocumentStyleSheetCollection.h:
+
+ * loader/DocumentLoader.cpp:
+ (WebCore::DocumentLoader::commitData):
+ (WebCore::DocumentLoader::addPendingContentExtensionDisplayNoneSelector):
+ (WebCore::DocumentLoader::addPendingContentExtensionSheet): Deleted.
+ * loader/DocumentLoader.h:
+
2015-04-23 Antti Koivisto <[email protected]>
Memory cache live resources repeatedly purged during painting
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (183194 => 183195)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2015-04-23 17:48:37 UTC (rev 183194)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2015-04-23 17:52:21 UTC (rev 183195)
@@ -2077,6 +2077,8 @@
51FA2D78152132B300C1BA0B /* DOMWindowExtension.h in Headers */ = {isa = PBXBuildFile; fileRef = 517FBA18151AA71B00B57959 /* DOMWindowExtension.h */; settings = {ATTRIBUTES = (Private, ); }; };
51FB5504113E3E9100821176 /* JSCloseEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 51FB5502113E3E9100821176 /* JSCloseEvent.h */; };
51FB5505113E3E9100821176 /* JSCloseEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51FB5503113E3E9100821176 /* JSCloseEvent.cpp */; };
+ 51FB67DB1AE6B82B00D06C5A /* ContentExtensionStyleSheet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51FB67D91AE6B5E400D06C5A /* ContentExtensionStyleSheet.cpp */; };
+ 51FB67DC1AE6B82F00D06C5A /* ContentExtensionStyleSheet.h in Headers */ = {isa = PBXBuildFile; fileRef = 51FB67DA1AE6B5E400D06C5A /* ContentExtensionStyleSheet.h */; settings = {ATTRIBUTES = (Private, ); }; };
521D46F611AEC98100514613 /* KillRingMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 521D46F511AEC98100514613 /* KillRingMac.mm */; };
521D46F811AEC9B100514613 /* KillRing.h in Headers */ = {isa = PBXBuildFile; fileRef = 521D46F711AEC9B100514613 /* KillRing.h */; };
52B6C9C215E3F4DF00690B05 /* DOMNamedFlowCollection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 52B6C9BD15E3F4DF00690B05 /* DOMNamedFlowCollection.cpp */; };
@@ -9293,6 +9295,8 @@
51F6A3D60663BF04004D2919 /* HTMLCanvasElement.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = HTMLCanvasElement.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
51FB5502113E3E9100821176 /* JSCloseEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCloseEvent.h; sourceTree = "<group>"; };
51FB5503113E3E9100821176 /* JSCloseEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCloseEvent.cpp; sourceTree = "<group>"; };
+ 51FB67D91AE6B5E400D06C5A /* ContentExtensionStyleSheet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ContentExtensionStyleSheet.cpp; sourceTree = "<group>"; };
+ 51FB67DA1AE6B5E400D06C5A /* ContentExtensionStyleSheet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContentExtensionStyleSheet.h; sourceTree = "<group>"; };
521D46F511AEC98100514613 /* KillRingMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = KillRingMac.mm; sourceTree = "<group>"; };
521D46F711AEC9B100514613 /* KillRing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KillRing.h; sourceTree = "<group>"; };
52B6C9BD15E3F4DF00690B05 /* DOMNamedFlowCollection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DOMNamedFlowCollection.cpp; sourceTree = "<group>"; };
@@ -15569,6 +15573,8 @@
26F0C8961A2E724B002794F8 /* ContentExtensionParser.h */,
26F0C8991A2EC110002794F8 /* ContentExtensionRule.cpp */,
26F0C89A1A2EC110002794F8 /* ContentExtensionRule.h */,
+ 51FB67D91AE6B5E400D06C5A /* ContentExtensionStyleSheet.cpp */,
+ 51FB67DA1AE6B5E400D06C5A /* ContentExtensionStyleSheet.h */,
26F0C89D1A2EC3BE002794F8 /* ContentExtensionsBackend.cpp */,
26F0C89E1A2EC3BE002794F8 /* ContentExtensionsBackend.h */,
262391351A648CEE007251A3 /* ContentExtensionsDebugging.h */,
@@ -26904,6 +26910,7 @@
26F0C8A01A2EC3BE002794F8 /* ContentExtensionsBackend.h in Headers */,
49E911C40EF86D47009D0CAF /* TransformationMatrix.h in Headers */,
FB484F4D171F821E00040755 /* TransformFunctions.h in Headers */,
+ 51FB67DC1AE6B82F00D06C5A /* ContentExtensionStyleSheet.h in Headers */,
49E911CE0EF86D47009D0CAF /* TransformOperation.h in Headers */,
49E911D00EF86D47009D0CAF /* TransformOperations.h in Headers */,
5DB1BC6A10715A6400EFAA49 /* TransformSource.h in Headers */,
@@ -27595,6 +27602,7 @@
FDC54F041399B0DA008D9117 /* BiquadFilterNode.cpp in Sources */,
FD31602612B0267600C1A359 /* BiquadProcessor.cpp in Sources */,
A89943290B42338800D7C802 /* BitmapImage.cpp in Sources */,
+ 51FB67DB1AE6B82B00D06C5A /* ContentExtensionStyleSheet.cpp in Sources */,
377A3A9015EFCE9B0059F5C7 /* BitmapImageCG.cpp in Sources */,
976D6C78122B8A3D001FD1F7 /* Blob.cpp in Sources */,
2EDEF1F3121B0EFC00726DB2 /* BlobData.cpp in Sources */,
Modified: trunk/Source/WebCore/contentextensions/ContentExtension.cpp (183194 => 183195)
--- trunk/Source/WebCore/contentextensions/ContentExtension.cpp 2015-04-23 17:48:37 UTC (rev 183194)
+++ trunk/Source/WebCore/contentextensions/ContentExtension.cpp 2015-04-23 17:52:21 UTC (rev 183195)
@@ -62,7 +62,9 @@
StringBuilder css;
for (auto& selector : selectors) {
css.append(selector);
+ css.append("{");
css.append(ContentExtensionsBackend::displayNoneCSSRule());
+ css.append("}");
}
m_globalDisplayNoneStyleSheet = StyleSheetContents::create();
Modified: trunk/Source/WebCore/contentextensions/ContentExtensionRule.cpp (183194 => 183195)
--- trunk/Source/WebCore/contentextensions/ContentExtensionRule.cpp 2015-04-23 17:48:37 UTC (rev 183194)
+++ trunk/Source/WebCore/contentextensions/ContentExtensionRule.cpp 2015-04-23 17:52:21 UTC (rev 183195)
@@ -43,11 +43,11 @@
{
switch (static_cast<ActionType>(actions[location])) {
case ActionType::BlockCookies:
- return ActionType::BlockCookies;
+ return Action(ActionType::BlockCookies, location);
case ActionType::BlockLoad:
- return ActionType::BlockLoad;
+ return Action(ActionType::BlockLoad, location);
case ActionType::IgnorePreviousRules:
- return ActionType::IgnorePreviousRules;
+ return Action(ActionType::IgnorePreviousRules, location);
case ActionType::CSSDisplayNoneSelector: {
unsigned stringStartIndex = location + sizeof(ActionType) + sizeof(unsigned) + sizeof(bool);
RELEASE_ASSERT(actionsLength >= stringStartIndex);
@@ -56,10 +56,10 @@
if (wideCharacters) {
RELEASE_ASSERT(actionsLength >= stringStartIndex + selectorLength * sizeof(UChar));
- return Action(ActionType::CSSDisplayNoneSelector, String(reinterpret_cast<const UChar*>(&actions[stringStartIndex]), selectorLength));
+ return Action(ActionType::CSSDisplayNoneSelector, String(reinterpret_cast<const UChar*>(&actions[stringStartIndex]), selectorLength), location);
}
RELEASE_ASSERT(actionsLength >= stringStartIndex + selectorLength * sizeof(LChar));
- return Action(ActionType::CSSDisplayNoneSelector, String(reinterpret_cast<const LChar*>(&actions[stringStartIndex]), selectorLength));
+ return Action(ActionType::CSSDisplayNoneSelector, String(reinterpret_cast<const LChar*>(&actions[stringStartIndex]), selectorLength), location);
}
case ActionType::CSSDisplayNoneStyleSheet:
case ActionType::InvalidAction:
Modified: trunk/Source/WebCore/contentextensions/ContentExtensionRule.h (183194 => 183195)
--- trunk/Source/WebCore/contentextensions/ContentExtensionRule.h 2015-04-23 17:48:37 UTC (rev 183194)
+++ trunk/Source/WebCore/contentextensions/ContentExtensionRule.h 2015-04-23 17:52:21 UTC (rev 183195)
@@ -56,18 +56,21 @@
struct Action {
Action()
: m_type(ActionType::InvalidAction)
+ , m_actionID(std::numeric_limits<uint32_t>::max())
{
}
- Action(ActionType type, const String& stringArgument)
+ Action(ActionType type, const String& stringArgument, uint32_t actionID = std::numeric_limits<uint32_t>::max())
: m_type(type)
+ , m_actionID(actionID)
, m_stringArgument(stringArgument)
{
ASSERT(type == ActionType::CSSDisplayNoneSelector || type == ActionType::CSSDisplayNoneStyleSheet);
}
- Action(ActionType type)
+ Action(ActionType type, uint32_t actionID = std::numeric_limits<uint32_t>::max())
: m_type(type)
+ , m_actionID(actionID)
{
ASSERT(type != ActionType::CSSDisplayNoneSelector && type != ActionType::CSSDisplayNoneStyleSheet);
}
@@ -75,16 +78,23 @@
bool operator==(const Action& other) const
{
return m_type == other.m_type
+ && m_extensionIdentifier == other.m_extensionIdentifier
+ && m_actionID == other.m_actionID
&& m_stringArgument == other.m_stringArgument;
}
- static Action deserialize(const SerializedActionByte* actions, const unsigned actionsLength, unsigned location);
+ static Action deserialize(const SerializedActionByte* actions, const unsigned actionsLength, uint32_t location);
+ void setExtensionIdentifier(const String& extensionIdentifier) { m_extensionIdentifier = extensionIdentifier; }
+ const String& extensionIdentifier() const { return m_extensionIdentifier; }
ActionType type() const { return m_type; }
+ uint32_t actionID() const { return m_actionID; }
const String& stringArgument() const { return m_stringArgument; }
-
+
private:
+ String m_extensionIdentifier;
ActionType m_type;
+ uint32_t m_actionID;
String m_stringArgument;
};
Copied: trunk/Source/WebCore/contentextensions/ContentExtensionStyleSheet.cpp (from rev 183194, trunk/Source/WebCore/contentextensions/ContentExtension.cpp) (0 => 183195)
--- trunk/Source/WebCore/contentextensions/ContentExtensionStyleSheet.cpp (rev 0)
+++ trunk/Source/WebCore/contentextensions/ContentExtensionStyleSheet.cpp 2015-04-23 17:52:21 UTC (rev 183195)
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ContentExtensionStyleSheet.h"
+
+#if ENABLE(CONTENT_EXTENSIONS)
+
+#include "CSSStyleSheet.h"
+#include "ContentExtensionsBackend.h"
+#include "Document.h"
+#include "StyleSheetContents.h"
+
+namespace WebCore {
+namespace ContentExtensions {
+
+ContentExtensionStyleSheet::ContentExtensionStyleSheet(Document& document)
+ : m_styleSheet(CSSStyleSheet::create(StyleSheetContents::create(), &document))
+{
+ m_styleSheet->contents().setIsUserStyleSheet(true);
+}
+
+void ContentExtensionStyleSheet::addDisplayNoneSelector(const String& selector, uint32_t selectorID)
+{
+ ASSERT(selectorID != std::numeric_limits<uint32_t>::max());
+
+ if (!m_addedSelectorIDs.add(selectorID).isNewEntry)
+ return;
+
+ ExceptionCode ec;
+ m_styleSheet->addRule(selector, ContentExtensionsBackend::displayNoneCSSRule(), ec);
+}
+
+} // namespace ContentExtensions
+} // namespace WebCore
+
+#endif // ENABLE(CONTENT_EXTENSIONS)
Copied: trunk/Source/WebCore/contentextensions/ContentExtensionStyleSheet.h (from rev 183194, trunk/Source/WebCore/contentextensions/ContentExtension.cpp) (0 => 183195)
--- trunk/Source/WebCore/contentextensions/ContentExtensionStyleSheet.h (rev 0)
+++ trunk/Source/WebCore/contentextensions/ContentExtensionStyleSheet.h 2015-04-23 17:52:21 UTC (rev 183195)
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef ContentExtensionStyleSheet_h
+#define ContentExtensionStyleSheet_h
+
+#if ENABLE(CONTENT_EXTENSIONS)
+
+#include "CSSStyleSheet.h"
+#include <wtf/HashSet.h>
+#include <wtf/Ref.h>
+#include <wtf/RefCounted.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+class Document;
+
+namespace ContentExtensions {
+
+class ContentExtensionStyleSheet : public RefCounted<ContentExtensionStyleSheet> {
+public:
+ static Ref<ContentExtensionStyleSheet> create(Document& document)
+ {
+ return adoptRef(*new ContentExtensionStyleSheet(document));
+ }
+
+ void addDisplayNoneSelector(const String& selector, uint32_t selectorID);
+
+ CSSStyleSheet& styleSheet() { return m_styleSheet.get(); }
+
+private:
+ ContentExtensionStyleSheet(Document&);
+
+ Ref<CSSStyleSheet> m_styleSheet;
+ HashSet<uint32_t, DefaultHash<uint32_t>::Hash, WTF::UnsignedWithZeroKeyHashTraits<uint32_t>> m_addedSelectorIDs;
+};
+
+} // namespace ContentExtensions
+} // namespace WebCore
+
+#endif // ENABLE(CONTENT_EXTENSIONS)
+#endif // ContentExtensionStyleSheet_h
Modified: trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp (183194 => 183195)
--- trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp 2015-04-23 17:48:37 UTC (rev 183194)
+++ trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp 2015-04-23 17:52:21 UTC (rev 183195)
@@ -105,6 +105,7 @@
// Add actions in reverse order to properly deal with IgnorePreviousRules.
for (unsigned i = actionLocations.size(); i; i--) {
Action action = "" actionsLength, actionLocations[i - 1]);
+ action.setExtensionIdentifier(contentExtension->identifier());
if (action.type() == ActionType::IgnorePreviousRules) {
sawIgnorePreviousRules = true;
break;
@@ -116,12 +117,14 @@
DFABytecodeInterpreter::Actions universalActions = interpreter.actionsFromDFARoot();
for (auto actionLocation : universalActions) {
Action action = "" actionsLength, static_cast<unsigned>(actionLocation));
-
+ action.setExtensionIdentifier(contentExtension->identifier());
+
// CSS selectors were already compiled into a stylesheet using globalDisplayNoneSelectors.
if (action.type() != ActionType::CSSDisplayNoneSelector)
finalActions.append(action);
}
finalActions.append(Action(ActionType::CSSDisplayNoneStyleSheet, contentExtension->identifier()));
+ finalActions.last().setExtensionIdentifier(contentExtension->identifier());
}
}
#if CONTENT_EXTENSIONS_PERFORMANCE_REPORTING
@@ -163,8 +166,10 @@
request.setAllowCookies(false);
break;
case ContentExtensions::ActionType::CSSDisplayNoneSelector:
- css.append(action.stringArgument());
- css.append(displayNoneCSSRule());
+ if (resourceType == ResourceType::Document)
+ initiatingDocumentLoader.addPendingContentExtensionDisplayNoneSelector(action.extensionIdentifier(), action.stringArgument(), action.actionID());
+ else if (currentDocument)
+ currentDocument->styleSheetCollection().addDisplayNoneSelector(action.extensionIdentifier(), action.stringArgument(), action.actionID());
break;
case ContentExtensions::ActionType::CSSDisplayNoneStyleSheet: {
StyleSheetContents* styleSheetContents = globalDisplayNoneStyleSheet(action.stringArgument());
@@ -182,25 +187,13 @@
}
}
- if (css.length()) {
- Ref<StyleSheetContents> styleSheet = StyleSheetContents::create();
- styleSheet->setIsUserStyleSheet(true);
-
- if (styleSheet->parseString(css.toString())) {
- if (resourceType == ResourceType::Document)
- initiatingDocumentLoader.addPendingContentExtensionSheet(styleSheet);
- else if (currentDocument)
- currentDocument->styleSheetCollection().addContentExtensionUserSheet(WTF::move(styleSheet));
- }
- }
-
if (willBlockLoad)
request = ResourceRequest();
}
const String& ContentExtensionsBackend::displayNoneCSSRule()
{
- static NeverDestroyed<const String> rule(ASCIILiteral("{display:none !important;}\n"));
+ static NeverDestroyed<const String> rule(ASCIILiteral("display:none !important;"));
return rule;
}
Modified: trunk/Source/WebCore/dom/DocumentStyleSheetCollection.cpp (183194 => 183195)
--- trunk/Source/WebCore/dom/DocumentStyleSheetCollection.cpp 2015-04-23 17:48:37 UTC (rev 183194)
+++ trunk/Source/WebCore/dom/DocumentStyleSheetCollection.cpp 2015-04-23 17:52:21 UTC (rev 183195)
@@ -49,6 +49,7 @@
namespace WebCore {
+using namespace ContentExtensions;
using namespace HTMLNames;
DocumentStyleSheetCollection::DocumentStyleSheetCollection(Document& document)
@@ -192,10 +193,16 @@
m_document.styleResolverChanged(RecalcStyleImmediately);
}
-void DocumentStyleSheetCollection::addContentExtensionUserSheet(Ref<StyleSheetContents>&& userSheet)
+#if ENABLE(CONTENT_EXTENSIONS)
+void DocumentStyleSheetCollection::addDisplayNoneSelector(const String& identifier, const String& selector, uint32_t selectorID)
{
- ASSERT(userSheet.get().isUserStyleSheet());
- m_userStyleSheets.append(CSSStyleSheet::create(WTF::move(userSheet), &m_document));
+ auto result = m_contentExtensionSelectorSheets.add(identifier, nullptr);
+ if (result.isNewEntry) {
+ result.iterator->value = ContentExtensionStyleSheet::create(m_document);
+ m_userStyleSheets.append(&result.iterator->value->styleSheet());
+ }
+
+ result.iterator->value->addDisplayNoneSelector(selector, selectorID);
m_styleResolverChangedTimer.startOneShot(0);
}
@@ -211,6 +218,7 @@
m_userStyleSheets.append(adoptRef(cssSheet.leakRef()));
m_styleResolverChangedTimer.startOneShot(0);
}
+#endif // ENABLE(CONTENT_EXTENSIONS)
void DocumentStyleSheetCollection::styleResolverChangedTimerFired()
{
Modified: trunk/Source/WebCore/dom/DocumentStyleSheetCollection.h (183194 => 183195)
--- trunk/Source/WebCore/dom/DocumentStyleSheetCollection.h 2015-04-23 17:48:37 UTC (rev 183194)
+++ trunk/Source/WebCore/dom/DocumentStyleSheetCollection.h 2015-04-23 17:52:21 UTC (rev 183195)
@@ -37,6 +37,10 @@
#include <wtf/Vector.h>
#include <wtf/text/WTFString.h>
+#if ENABLE(CONTENT_EXTENSIONS)
+#include "ContentExtensionStyleSheet.h"
+#endif
+
namespace WebCore {
class CSSStyleSheet;
@@ -71,8 +75,11 @@
WEBCORE_EXPORT void addAuthorSheet(Ref<StyleSheetContents>&& authorSheet);
WEBCORE_EXPORT void addUserSheet(Ref<StyleSheetContents>&& userSheet);
- void addContentExtensionUserSheet(Ref<StyleSheetContents>&& userSheet);
+
+#if ENABLE(CONTENT_EXTENSIONS)
+ void addDisplayNoneSelector(const String& identifier, const String& selector, uint32_t selectorID);
void maybeAddContentExtensionSheet(const String& identifier, StyleSheetContents&);
+#endif
enum UpdateFlag { NoUpdate = 0, OptimizedUpdate, FullUpdate };
@@ -152,7 +159,11 @@
Vector<RefPtr<CSSStyleSheet>> m_userStyleSheets;
Vector<RefPtr<CSSStyleSheet>> m_authorStyleSheets;
+
+#if ENABLE(CONTENT_EXTENSIONS)
HashMap<String, RefPtr<CSSStyleSheet>> m_contentExtensionSheets;
+ HashMap<String, RefPtr<ContentExtensions::ContentExtensionStyleSheet>> m_contentExtensionSelectorSheets;
+#endif
bool m_hadActiveLoadingStylesheet;
UpdateFlag m_pendingUpdateType;
Modified: trunk/Source/WebCore/loader/DocumentLoader.cpp (183194 => 183195)
--- trunk/Source/WebCore/loader/DocumentLoader.cpp 2015-04-23 17:48:37 UTC (rev 183194)
+++ trunk/Source/WebCore/loader/DocumentLoader.cpp 2015-04-23 17:52:21 UTC (rev 183195)
@@ -832,11 +832,11 @@
for (auto& pendingStyleSheet : m_pendingNamedContentExtensionStyleSheets)
styleSheetCollection.maybeAddContentExtensionSheet(pendingStyleSheet.key, *pendingStyleSheet.value);
- for (auto& pendingStyleSheet : m_pendingUnnamedContentExtensionStyleSheets)
- styleSheetCollection.addUserSheet(*pendingStyleSheet);
+ for (auto& pendingSelector : m_pendingContentExtensionDisplayNoneSelectors)
+ styleSheetCollection.addDisplayNoneSelector(pendingSelector.key, pendingSelector.value.first, pendingSelector.value.second);
m_pendingNamedContentExtensionStyleSheets.clear();
- m_pendingUnnamedContentExtensionStyleSheets.clear();
+ m_pendingContentExtensionDisplayNoneSelectors.clear();
#endif
ASSERT(m_frame->document()->parsing());
@@ -1558,10 +1558,10 @@
m_pendingNamedContentExtensionStyleSheets.set(identifier, &sheet);
}
-void DocumentLoader::addPendingContentExtensionSheet(StyleSheetContents& sheet)
+void DocumentLoader::addPendingContentExtensionDisplayNoneSelector(const String& identifier, const String& selector, uint32_t selectorID)
{
ASSERT(!m_gotFirstByte);
- m_pendingUnnamedContentExtensionStyleSheets.add(&sheet);
+ m_pendingContentExtensionDisplayNoneSelectors.set(identifier, std::make_pair(selector, selectorID));
}
#endif
Modified: trunk/Source/WebCore/loader/DocumentLoader.h (183194 => 183195)
--- trunk/Source/WebCore/loader/DocumentLoader.h 2015-04-23 17:48:37 UTC (rev 183194)
+++ trunk/Source/WebCore/loader/DocumentLoader.h 2015-04-23 17:52:21 UTC (rev 183195)
@@ -271,7 +271,7 @@
#if ENABLE(CONTENT_EXTENSIONS)
void addPendingContentExtensionSheet(const String& identifier, StyleSheetContents&);
- void addPendingContentExtensionSheet(StyleSheetContents&);
+ void addPendingContentExtensionDisplayNoneSelector(const String& identifier, const String& selector, uint32_t selectorID);
#endif
protected:
@@ -440,7 +440,7 @@
#if ENABLE(CONTENT_EXTENSIONS)
HashMap<String, RefPtr<StyleSheetContents>> m_pendingNamedContentExtensionStyleSheets;
- HashSet<RefPtr<StyleSheetContents>> m_pendingUnnamedContentExtensionStyleSheets;
+ HashMap<String, std::pair<String, uint32_t>> m_pendingContentExtensionDisplayNoneSelectors;
#endif
};