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

Side by Side Diff: third_party/WebKit/Source/core/css/StyleSheetContents.cpp

Issue 2616093003: Make CSSParserContext be garbage collected. (Closed)
Patch Set: fix fuzzer compile again 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2006, 2007, 2012 Apple Inc. All rights reserved. 3 * Copyright (C) 2004, 2006, 2007, 2012 Apple Inc. All rights reserved.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 52
53 for (unsigned i = 0; i < m_importRules.size(); ++i) { 53 for (unsigned i = 0; i < m_importRules.size(); ++i) {
54 if (StyleSheetContents* sheet = m_importRules[i]->styleSheet()) 54 if (StyleSheetContents* sheet = m_importRules[i]->styleSheet())
55 size += sheet->estimatedSizeInBytes(); 55 size += sheet->estimatedSizeInBytes();
56 } 56 }
57 return size; 57 return size;
58 } 58 }
59 59
60 StyleSheetContents::StyleSheetContents(StyleRuleImport* ownerRule, 60 StyleSheetContents::StyleSheetContents(StyleRuleImport* ownerRule,
61 const String& originalURL, 61 const String& originalURL,
62 const CSSParserContext& context) 62 const CSSParserContext* context)
63 : m_ownerRule(ownerRule), 63 : m_ownerRule(ownerRule),
64 m_originalURL(originalURL), 64 m_originalURL(originalURL),
65 m_defaultNamespace(starAtom), 65 m_defaultNamespace(starAtom),
66 m_hasSyntacticallyValidCSSHeader(true), 66 m_hasSyntacticallyValidCSSHeader(true),
67 m_didLoadErrorOccur(false), 67 m_didLoadErrorOccur(false),
68 m_isMutable(false), 68 m_isMutable(false),
69 m_hasFontFaceRule(false), 69 m_hasFontFaceRule(false),
70 m_hasViewportRule(false), 70 m_hasViewportRule(false),
71 m_hasMediaQueries(false), 71 m_hasMediaQueries(false),
72 m_hasSingleOwnerDocument(true), 72 m_hasSingleOwnerDocument(true),
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 // remove this check. crbug.com/553535 339 // remove this check. crbug.com/553535
340 if (cachedStyleSheet->response().wasFetchedViaServiceWorker()) { 340 if (cachedStyleSheet->response().wasFetchedViaServiceWorker()) {
341 const KURL originalURL( 341 const KURL originalURL(
342 cachedStyleSheet->response().originalURLViaServiceWorker()); 342 cachedStyleSheet->response().originalURLViaServiceWorker());
343 // |originalURL| is empty when the response is created in the SW. 343 // |originalURL| is empty when the response is created in the SW.
344 if (!originalURL.isEmpty() && !securityOrigin->canRequest(originalURL)) 344 if (!originalURL.isEmpty() && !securityOrigin->canRequest(originalURL))
345 isSameOriginRequest = false; 345 isSameOriginRequest = false;
346 } 346 }
347 347
348 CSSStyleSheetResource::MIMETypeCheck mimeTypeCheck = 348 CSSStyleSheetResource::MIMETypeCheck mimeTypeCheck =
349 isQuirksModeBehavior(m_parserContext.mode()) && isSameOriginRequest 349 isQuirksModeBehavior(m_parserContext->mode()) && isSameOriginRequest
350 ? CSSStyleSheetResource::MIMETypeCheck::Lax 350 ? CSSStyleSheetResource::MIMETypeCheck::Lax
351 : CSSStyleSheetResource::MIMETypeCheck::Strict; 351 : CSSStyleSheetResource::MIMETypeCheck::Strict;
352 String sheetText = cachedStyleSheet->sheetText(mimeTypeCheck); 352 String sheetText = cachedStyleSheet->sheetText(mimeTypeCheck);
353 353
354 const ResourceResponse& response = cachedStyleSheet->response(); 354 const ResourceResponse& response = cachedStyleSheet->response();
355 m_sourceMapURL = response.httpHeaderField(HTTPNames::SourceMap); 355 m_sourceMapURL = response.httpHeaderField(HTTPNames::SourceMap);
356 if (m_sourceMapURL.isEmpty()) { 356 if (m_sourceMapURL.isEmpty()) {
357 // Try to get deprecated header. 357 // Try to get deprecated header.
358 m_sourceMapURL = response.httpHeaderField(HTTPNames::X_SourceMap); 358 m_sourceMapURL = response.httpHeaderField(HTTPNames::X_SourceMap);
359 } 359 }
360 360
361 CSSParserContext context(parserContext(), UseCounter::getFrom(this)); 361 const CSSParserContext* context =
362 CSSParserContext::createWithStyleSheetContents(parserContext(), this);
362 CSSParser::parseSheet(context, this, sheetText, 363 CSSParser::parseSheet(context, this, sheetText,
363 RuntimeEnabledFeatures::lazyParseCSSEnabled()); 364 RuntimeEnabledFeatures::lazyParseCSSEnabled());
364 365
365 DEFINE_STATIC_LOCAL(CustomCountHistogram, parseHistogram, 366 DEFINE_STATIC_LOCAL(CustomCountHistogram, parseHistogram,
366 ("Style.AuthorStyleSheet.ParseTime", 0, 10000000, 50)); 367 ("Style.AuthorStyleSheet.ParseTime", 0, 10000000, 50));
367 double parseDurationSeconds = (monotonicallyIncreasingTime() - startTime); 368 double parseDurationSeconds = (monotonicallyIncreasingTime() - startTime);
368 parseHistogram.count(parseDurationSeconds * 1000 * 1000); 369 parseHistogram.count(parseDurationSeconds * 1000 * 1000);
369 if (Document* document = singleOwnerDocument()) { 370 if (Document* document = singleOwnerDocument()) {
370 CSSTiming::from(*document).recordAuthorStyleSheetParseTime( 371 CSSTiming::from(*document).recordAuthorStyleSheetParseTime(
371 parseDurationSeconds); 372 parseDurationSeconds);
372 } 373 }
373 } 374 }
374 375
375 void StyleSheetContents::parseString(const String& sheetText) { 376 void StyleSheetContents::parseString(const String& sheetText) {
376 parseStringAtPosition(sheetText, TextPosition::minimumPosition()); 377 parseStringAtPosition(sheetText, TextPosition::minimumPosition());
377 } 378 }
378 379
379 void StyleSheetContents::parseStringAtPosition( 380 void StyleSheetContents::parseStringAtPosition(
380 const String& sheetText, 381 const String& sheetText,
381 const TextPosition& startPosition) { 382 const TextPosition& startPosition) {
382 CSSParserContext context(parserContext(), UseCounter::getFrom(this)); 383 const CSSParserContext* context =
384 CSSParserContext::createWithStyleSheetContents(parserContext(), this);
383 CSSParser::parseSheet(context, this, sheetText); 385 CSSParser::parseSheet(context, this, sheetText);
384 } 386 }
385 387
386 bool StyleSheetContents::isLoading() const { 388 bool StyleSheetContents::isLoading() const {
387 for (unsigned i = 0; i < m_importRules.size(); ++i) { 389 for (unsigned i = 0; i < m_importRules.size(); ++i) {
388 if (m_importRules[i]->isLoading()) 390 if (m_importRules[i]->isLoading())
389 return true; 391 return true;
390 } 392 }
391 return false; 393 return false;
392 } 394 }
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 688
687 DEFINE_TRACE(StyleSheetContents) { 689 DEFINE_TRACE(StyleSheetContents) {
688 visitor->trace(m_ownerRule); 690 visitor->trace(m_ownerRule);
689 visitor->trace(m_importRules); 691 visitor->trace(m_importRules);
690 visitor->trace(m_namespaceRules); 692 visitor->trace(m_namespaceRules);
691 visitor->trace(m_childRules); 693 visitor->trace(m_childRules);
692 visitor->trace(m_loadingClients); 694 visitor->trace(m_loadingClients);
693 visitor->trace(m_completedClients); 695 visitor->trace(m_completedClients);
694 visitor->trace(m_ruleSet); 696 visitor->trace(m_ruleSet);
695 visitor->trace(m_referencedFromResource); 697 visitor->trace(m_referencedFromResource);
698 visitor->trace(m_parserContext);
696 } 699 }
697 700
698 } // namespace blink 701 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698