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

Unified Diff: third_party/WebKit/Source/core/css/StyleSheetContents.cpp

Issue 1481383002: [Experimental] CSSSerializer Proof-of-concept Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: snapshot: top_25 sites ser/dser now works Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/css/StyleSheetContents.cpp
diff --git a/third_party/WebKit/Source/core/css/StyleSheetContents.cpp b/third_party/WebKit/Source/core/css/StyleSheetContents.cpp
index a29c1cc394709908380ffd419c1f4f54b27eca78..4f78f6cce45dd07b57ca8c68b7d79f52bd321d51 100644
--- a/third_party/WebKit/Source/core/css/StyleSheetContents.cpp
+++ b/third_party/WebKit/Source/core/css/StyleSheetContents.cpp
@@ -26,6 +26,8 @@
#include "core/css/StyleRuleImport.h"
#include "core/css/StyleRuleNamespace.h"
#include "core/css/parser/CSSParser.h"
+#include "core/css/serializer/CSSDeserializeStream.h"
+#include "core/css/serializer/CSSSerializeStream.h"
#include "core/dom/Document.h"
#include "core/dom/Node.h"
#include "core/dom/StyleEngine.h"
@@ -123,8 +125,11 @@ bool StyleSheetContents::isCacheable() const
// differently depending on the context of the parent CSSStyleSheet (e.g.
// if they are in differently sized iframes). Once RuleSets are media query
// agnostic, we can restore sharing of StyleSheetContents with medea queries.
- if (m_hasMediaQueries)
- return false;
+ CSDEBUG("hasMediaQueries: %d, m_importRules not empty %d, m_ownerRule %d\n",
+ m_hasMediaQueries, !m_importRules.isEmpty(), (bool)m_ownerRule);
+ CSDEBUG("loaderr: %d, mutable: %d, css h invalid: %d\n", m_didLoadErrorOccur, m_isMutable, !m_hasSyntacticallyValidCSSHeader);
+ //if (m_hasMediaQueries)
+ // return false;
// FIXME: Support copying import rules.
if (!m_importRules.isEmpty())
return false;
@@ -143,6 +148,26 @@ bool StyleSheetContents::isCacheable() const
return true;
}
+void StyleSheetContents::deserialize(CSSDeserializeStream* stream)
+{
+ CSDEBUG("StyleSheetContents::deserialize\n");
+
+ unsigned numChildRules = stream->readUnsigned();
+ for (unsigned i = 0; i < numChildRules; ++i) {
+ parserAppendRule(StyleRuleBase::deserialize(stream));
+ }
+}
+
+void StyleSheetContents::serialize(CSSSerializeStream* stream)
+{
+ CSDEBUG("StyleSheetContents::serialize isCacheable: %d\n", isCacheable());
+
+ stream->writeUnsigned(m_childRules.size());
+ for (auto childRule : m_childRules) {
+ childRule->serialize(stream);
+ }
+}
+
void StyleSheetContents::parserAppendRule(PassRefPtrWillBeRawPtr<StyleRuleBase> rule)
{
if (rule->isImportRule()) {

Powered by Google App Engine
This is Rietveld 408576698