| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
| 3 * Copyright (C) 2009 Torch Mobile, Inc. http://www.torchmobile.com/ | 3 * Copyright (C) 2009 Torch Mobile, Inc. http://www.torchmobile.com/ |
| 4 * Copyright (C) 2010 Google Inc. All Rights Reserved. | 4 * Copyright (C) 2010 Google Inc. All Rights Reserved. |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 template<typename Token> | 519 template<typename Token> |
| 520 void TokenPreloadScanner::updatePredictedBaseURL(const Token& token) | 520 void TokenPreloadScanner::updatePredictedBaseURL(const Token& token) |
| 521 { | 521 { |
| 522 ASSERT(m_predictedBaseElementURL.isEmpty()); | 522 ASSERT(m_predictedBaseElementURL.isEmpty()); |
| 523 if (const typename Token::Attribute* hrefAttribute = token.getAttributeItem(
hrefAttr)) { | 523 if (const typename Token::Attribute* hrefAttribute = token.getAttributeItem(
hrefAttr)) { |
| 524 KURL url(m_documentURL, stripLeadingAndTrailingHTMLSpaces(hrefAttribute-
>value)); | 524 KURL url(m_documentURL, stripLeadingAndTrailingHTMLSpaces(hrefAttribute-
>value)); |
| 525 m_predictedBaseElementURL = url.isValid() ? url.copy() : KURL(); | 525 m_predictedBaseElementURL = url.isValid() ? url.copy() : KURL(); |
| 526 } | 526 } |
| 527 } | 527 } |
| 528 | 528 |
| 529 PassOwnPtr<HTMLPreloadScanner> HTMLPreloadScanner::create(const HTMLParserOption
s& options, const KURL& documentURL, PassRefPtr<MediaValues> mediaValues) |
| 530 { |
| 531 return adoptPtr(new HTMLPreloadScanner(options, documentURL, mediaValues)); |
| 532 } |
| 533 |
| 529 HTMLPreloadScanner::HTMLPreloadScanner(const HTMLParserOptions& options, const K
URL& documentURL, PassRefPtr<MediaValues> mediaValues) | 534 HTMLPreloadScanner::HTMLPreloadScanner(const HTMLParserOptions& options, const K
URL& documentURL, PassRefPtr<MediaValues> mediaValues) |
| 530 : m_scanner(documentURL, mediaValues) | 535 : m_scanner(documentURL, mediaValues) |
| 531 , m_tokenizer(HTMLTokenizer::create(options)) | 536 , m_tokenizer(HTMLTokenizer::create(options)) |
| 532 { | 537 { |
| 533 } | 538 } |
| 534 | 539 |
| 535 HTMLPreloadScanner::~HTMLPreloadScanner() | 540 HTMLPreloadScanner::~HTMLPreloadScanner() |
| 536 { | 541 { |
| 537 } | 542 } |
| 538 | 543 |
| 539 void HTMLPreloadScanner::appendToEnd(const SegmentedString& source) | 544 void HTMLPreloadScanner::appendToEnd(const SegmentedString& source) |
| 540 { | 545 { |
| 541 m_source.append(source); | 546 m_source.append(source); |
| 542 } | 547 } |
| 543 | 548 |
| 544 void HTMLPreloadScanner::scan(HTMLResourcePreloader* preloader, const KURL& star
tingBaseElementURL) | 549 void HTMLPreloadScanner::scan(ResourcePreloader* preloader, const KURL& starting
BaseElementURL) |
| 545 { | 550 { |
| 546 ASSERT(isMainThread()); // HTMLTokenizer::updateStateFor only works on the m
ain thread. | 551 ASSERT(isMainThread()); // HTMLTokenizer::updateStateFor only works on the m
ain thread. |
| 547 | 552 |
| 548 TRACE_EVENT1("blink", "HTMLPreloadScanner::scan", "source_length", m_source.
length()); | 553 TRACE_EVENT1("blink", "HTMLPreloadScanner::scan", "source_length", m_source.
length()); |
| 549 | 554 |
| 550 // When we start scanning, our best prediction of the baseElementURL is the
real one! | 555 // When we start scanning, our best prediction of the baseElementURL is the
real one! |
| 551 if (!startingBaseElementURL.isEmpty()) | 556 if (!startingBaseElementURL.isEmpty()) |
| 552 m_scanner.setPredictedBaseElementURL(startingBaseElementURL); | 557 m_scanner.setPredictedBaseElementURL(startingBaseElementURL); |
| 553 | 558 |
| 554 PreloadRequestStream requests; | 559 PreloadRequestStream requests; |
| 555 | 560 |
| 556 while (m_tokenizer->nextToken(m_source, m_token)) { | 561 while (m_tokenizer->nextToken(m_source, m_token)) { |
| 557 if (m_token.type() == HTMLToken::StartTag) | 562 if (m_token.type() == HTMLToken::StartTag) |
| 558 m_tokenizer->updateStateFor(attemptStaticStringCreation(m_token.name
(), Likely8Bit)); | 563 m_tokenizer->updateStateFor(attemptStaticStringCreation(m_token.name
(), Likely8Bit)); |
| 559 m_scanner.scan(m_token, m_source, requests); | 564 m_scanner.scan(m_token, m_source, requests); |
| 560 m_token.clear(); | 565 m_token.clear(); |
| 561 } | 566 } |
| 562 | 567 |
| 563 preloader->takeAndPreload(requests); | 568 preloader->takeAndPreload(requests); |
| 564 } | 569 } |
| 565 | 570 |
| 566 } | 571 } |
| OLD | NEW |