| OLD | NEW |
| 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, |
| 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 * Library General Public License for more details. | 13 * Library General Public License for more details. |
| 14 * | 14 * |
| 15 * You should have received a copy of the GNU Library General Public License | 15 * You should have received a copy of the GNU Library General Public License |
| 16 * along with this library; see the file COPYING.LIB. If not, write to | 16 * along with this library; see the file COPYING.LIB. If not, write to |
| 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 18 * Boston, MA 02110-1301, USA. | 18 * Boston, MA 02110-1301, USA. |
| 19 */ | 19 */ |
| 20 | 20 |
| 21 #include "core/css/StyleSheetContents.h" | 21 #include "core/css/StyleSheetContents.h" |
| 22 | 22 |
| 23 #include "core/css/CSSStyleSheet.h" | 23 #include "core/css/CSSStyleSheet.h" |
| 24 #include "core/css/CSSTiming.h" |
| 24 #include "core/css/StylePropertySet.h" | 25 #include "core/css/StylePropertySet.h" |
| 25 #include "core/css/StyleRule.h" | 26 #include "core/css/StyleRule.h" |
| 26 #include "core/css/StyleRuleImport.h" | 27 #include "core/css/StyleRuleImport.h" |
| 27 #include "core/css/StyleRuleNamespace.h" | 28 #include "core/css/StyleRuleNamespace.h" |
| 28 #include "core/css/parser/CSSParser.h" | 29 #include "core/css/parser/CSSParser.h" |
| 29 #include "core/dom/Document.h" | 30 #include "core/dom/Document.h" |
| 30 #include "core/dom/Node.h" | 31 #include "core/dom/Node.h" |
| 31 #include "core/dom/StyleEngine.h" | 32 #include "core/dom/StyleEngine.h" |
| 32 #include "core/fetch/CSSStyleSheetResource.h" | 33 #include "core/fetch/CSSStyleSheetResource.h" |
| 33 #include "core/frame/UseCounter.h" | 34 #include "core/frame/UseCounter.h" |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 const AtomicString& StyleSheetContents::namespaceURIFromPrefix( | 321 const AtomicString& StyleSheetContents::namespaceURIFromPrefix( |
| 321 const AtomicString& prefix) { | 322 const AtomicString& prefix) { |
| 322 return m_namespaces.get(prefix); | 323 return m_namespaces.get(prefix); |
| 323 } | 324 } |
| 324 | 325 |
| 325 void StyleSheetContents::parseAuthorStyleSheet( | 326 void StyleSheetContents::parseAuthorStyleSheet( |
| 326 const CSSStyleSheetResource* cachedStyleSheet, | 327 const CSSStyleSheetResource* cachedStyleSheet, |
| 327 const SecurityOrigin* securityOrigin) { | 328 const SecurityOrigin* securityOrigin) { |
| 328 TRACE_EVENT1("blink,devtools.timeline", "ParseAuthorStyleSheet", "data", | 329 TRACE_EVENT1("blink,devtools.timeline", "ParseAuthorStyleSheet", "data", |
| 329 InspectorParseAuthorStyleSheetEvent::data(cachedStyleSheet)); | 330 InspectorParseAuthorStyleSheetEvent::data(cachedStyleSheet)); |
| 330 SCOPED_BLINK_UMA_HISTOGRAM_TIMER("Style.AuthorStyleSheet.ParseTime"); | 331 double startTimeMS = monotonicallyIncreasingTimeMS(); |
| 331 | 332 |
| 332 bool isSameOriginRequest = | 333 bool isSameOriginRequest = |
| 333 securityOrigin && securityOrigin->canRequest(baseURL()); | 334 securityOrigin && securityOrigin->canRequest(baseURL()); |
| 334 | 335 |
| 335 // When the response was fetched via the Service Worker, the original URL may | 336 // When the response was fetched via the Service Worker, the original URL may |
| 336 // not be same as the base URL. | 337 // not be same as the base URL. |
| 337 // TODO(horo): When we will use the original URL as the base URL, we can | 338 // TODO(horo): When we will use the original URL as the base URL, we can |
| 338 // remove this check. crbug.com/553535 | 339 // remove this check. crbug.com/553535 |
| 339 if (cachedStyleSheet->response().wasFetchedViaServiceWorker()) { | 340 if (cachedStyleSheet->response().wasFetchedViaServiceWorker()) { |
| 340 const KURL originalURL( | 341 const KURL originalURL( |
| (...skipping 12 matching lines...) Expand all Loading... |
| 353 const ResourceResponse& response = cachedStyleSheet->response(); | 354 const ResourceResponse& response = cachedStyleSheet->response(); |
| 354 m_sourceMapURL = response.httpHeaderField(HTTPNames::SourceMap); | 355 m_sourceMapURL = response.httpHeaderField(HTTPNames::SourceMap); |
| 355 if (m_sourceMapURL.isEmpty()) { | 356 if (m_sourceMapURL.isEmpty()) { |
| 356 // Try to get deprecated header. | 357 // Try to get deprecated header. |
| 357 m_sourceMapURL = response.httpHeaderField(HTTPNames::X_SourceMap); | 358 m_sourceMapURL = response.httpHeaderField(HTTPNames::X_SourceMap); |
| 358 } | 359 } |
| 359 | 360 |
| 360 CSSParserContext context(parserContext(), UseCounter::getFrom(this)); | 361 CSSParserContext context(parserContext(), UseCounter::getFrom(this)); |
| 361 CSSParser::parseSheet(context, this, sheetText, | 362 CSSParser::parseSheet(context, this, sheetText, |
| 362 RuntimeEnabledFeatures::lazyParseCSSEnabled()); | 363 RuntimeEnabledFeatures::lazyParseCSSEnabled()); |
| 364 |
| 365 DEFINE_STATIC_LOCAL(CustomCountHistogram, parseHistogram, |
| 366 ("Style.AuthorStyleSheet.ParseTime", 0, 10000000, 50)); |
| 367 double parseDurationMS = (monotonicallyIncreasingTimeMS() - startTimeMS); |
| 368 parseHistogram.count(parseDurationMS * 1000); |
| 369 if (Document* document = singleOwnerDocument()) { |
| 370 // CSSTiming expects time in seconds. |
| 371 CSSTiming::from(*document).recordAuthorStyleSheetParseTime(parseDurationMS / |
| 372 1000); |
| 373 } |
| 363 } | 374 } |
| 364 | 375 |
| 365 void StyleSheetContents::parseString(const String& sheetText) { | 376 void StyleSheetContents::parseString(const String& sheetText) { |
| 366 parseStringAtPosition(sheetText, TextPosition::minimumPosition()); | 377 parseStringAtPosition(sheetText, TextPosition::minimumPosition()); |
| 367 } | 378 } |
| 368 | 379 |
| 369 void StyleSheetContents::parseStringAtPosition( | 380 void StyleSheetContents::parseStringAtPosition( |
| 370 const String& sheetText, | 381 const String& sheetText, |
| 371 const TextPosition& startPosition) { | 382 const TextPosition& startPosition) { |
| 372 CSSParserContext context(parserContext(), UseCounter::getFrom(this)); | 383 CSSParserContext context(parserContext(), UseCounter::getFrom(this)); |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 674 visitor->trace(m_importRules); | 685 visitor->trace(m_importRules); |
| 675 visitor->trace(m_namespaceRules); | 686 visitor->trace(m_namespaceRules); |
| 676 visitor->trace(m_childRules); | 687 visitor->trace(m_childRules); |
| 677 visitor->trace(m_loadingClients); | 688 visitor->trace(m_loadingClients); |
| 678 visitor->trace(m_completedClients); | 689 visitor->trace(m_completedClients); |
| 679 visitor->trace(m_ruleSet); | 690 visitor->trace(m_ruleSet); |
| 680 visitor->trace(m_referencedFromResource); | 691 visitor->trace(m_referencedFromResource); |
| 681 } | 692 } |
| 682 | 693 |
| 683 } // namespace blink | 694 } // namespace blink |
| OLD | NEW |