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

Unified Diff: third_party/WebKit/Source/core/css/parser/CSSParserContext.cpp

Issue 2616093003: Make CSSParserContext be garbage collected. (Closed)
Patch Set: comments 1 Created 3 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/parser/CSSParserContext.cpp
diff --git a/third_party/WebKit/Source/core/css/parser/CSSParserContext.cpp b/third_party/WebKit/Source/core/css/parser/CSSParserContext.cpp
index 66e3d2a87849e6ecf7608494b46e1e38a03c872a..a7498ec0998f85303827176861ba37648cb79638 100644
--- a/third_party/WebKit/Source/core/css/parser/CSSParserContext.cpp
+++ b/third_party/WebKit/Source/core/css/parser/CSSParserContext.cpp
@@ -4,25 +4,37 @@
#include "core/css/parser/CSSParserContext.h"
+#include "core/css/CSSStyleSheet.h"
+#include "core/css/StyleSheetContents.h"
#include "core/frame/Settings.h"
#include "core/frame/csp/ContentSecurityPolicy.h"
#include "core/html/imports/HTMLImportsController.h"
namespace blink {
-CSSParserContext::CSSParserContext(CSSParserMode mode,
- UseCounter* useCounter,
- SelectorProfile profile)
+// static
+CSSParserContext* CSSParserContext::create(const CSSParserContext* other,
+ const CSSStyleSheet* styleSheet) {
+ return new CSSParserContext(other, UseCounter::getFrom(styleSheet));
+}
+
+// static
+CSSParserContext* CSSParserContext::create(
+ const CSSParserContext* other,
+ const StyleSheetContents* styleSheetContents) {
+ return new CSSParserContext(other, UseCounter::getFrom(styleSheetContents));
+}
+
+CSSParserContext::CSSParserContext(CSSParserMode mode, SelectorProfile profile)
: m_mode(mode),
m_matchMode(mode),
m_profile(profile),
m_isHTMLDocument(false),
m_useLegacyBackgroundSizeShorthandBehavior(false),
m_shouldCheckContentSecurityPolicy(DoNotCheckContentSecurityPolicy),
- m_useCounter(useCounter) {}
+ m_useCounter(nullptr) {}
CSSParserContext::CSSParserContext(const Document& document,
- UseCounter* useCounter,
const KURL& baseURL,
const String& charset,
SelectorProfile profile)
@@ -39,7 +51,7 @@ CSSParserContext::CSSParserContext(const Document& document,
->getUseLegacyBackgroundSizeShorthandBehavior()
: false),
m_shouldCheckContentSecurityPolicy(DoNotCheckContentSecurityPolicy),
- m_useCounter(useCounter) {
+ m_useCounter(nullptr) {
if (ContentSecurityPolicy::shouldBypassMainWorld(&document))
m_shouldCheckContentSecurityPolicy = DoNotCheckContentSecurityPolicy;
else
@@ -54,19 +66,19 @@ CSSParserContext::CSSParserContext(const Document& document,
}
}
-CSSParserContext::CSSParserContext(const CSSParserContext& other,
+CSSParserContext::CSSParserContext(const CSSParserContext* other,
UseCounter* useCounter)
- : m_baseURL(other.m_baseURL),
- m_charset(other.m_charset),
- m_mode(other.m_mode),
- m_matchMode(other.m_matchMode),
- m_profile(other.m_profile),
- m_referrer(other.m_referrer),
- m_isHTMLDocument(other.m_isHTMLDocument),
+ : m_baseURL(other->m_baseURL),
+ m_charset(other->m_charset),
+ m_mode(other->m_mode),
+ m_matchMode(other->m_matchMode),
+ m_profile(other->m_profile),
+ m_referrer(other->m_referrer),
+ m_isHTMLDocument(other->m_isHTMLDocument),
m_useLegacyBackgroundSizeShorthandBehavior(
- other.m_useLegacyBackgroundSizeShorthandBehavior),
+ other->m_useLegacyBackgroundSizeShorthandBehavior),
m_shouldCheckContentSecurityPolicy(
- other.m_shouldCheckContentSecurityPolicy),
+ other->m_shouldCheckContentSecurityPolicy),
m_useCounter(useCounter) {}
bool CSSParserContext::operator==(const CSSParserContext& other) const {
@@ -78,10 +90,10 @@ bool CSSParserContext::operator==(const CSSParserContext& other) const {
other.m_useLegacyBackgroundSizeShorthandBehavior;
}
-const CSSParserContext& strictCSSParserContext() {
+const CSSParserContext* strictCSSParserContext() {
DEFINE_STATIC_LOCAL(CSSParserContext, strictContext,
- (HTMLStandardMode, nullptr));
- return strictContext;
+ (new CSSParserContext(HTMLStandardMode)));
+ return &strictContext;
haraken 2017/01/12 04:51:13 Or you can change the type of the return value to
Bret 2017/01/13 02:15:28 I think this is okay, as long as it isn't wrong. T
}
KURL CSSParserContext::completeURL(const String& url) const {

Powered by Google App Engine
This is Rietveld 408576698