void CSSPreloadScanner::scan(const HTMLToken& token, bool scanningBody) { m_scanningBody = scanningBody; const HTMLToken::DataVector& characters = token.characters(); for (HTMLToken::DataVector::const_iterator iter = characters.begin(); iter != characters.end() && m_state != DoneParsingImportRules; ++iter) tokenize(*iter); }
void CSSPreloadScanner::scan(const HTMLToken& token, bool scanningBody) { m_scanningBody = scanningBody; const HTMLToken::DataVector& characters = token.characters(); for (HTMLToken::DataVector::const_iterator iter = characters.begin(); iter != characters.end(); ++iter) { tokenize(*iter); } }
void TokenPreloadScanner::scan(const HTMLToken& token, Vector<std::unique_ptr<PreloadRequest>>& requests, Document& document) { switch (token.type()) { case HTMLToken::Character: if (!m_inStyle) return; m_cssScanner.scan(token.characters(), requests); return; case HTMLToken::EndTag: { TagId tagId = tagIdFor(token.name()); #if ENABLE(TEMPLATE_ELEMENT) if (tagId == TagId::Template) { if (m_templateCount) --m_templateCount; return; } #endif if (tagId == TagId::Style) { if (m_inStyle) m_cssScanner.reset(); m_inStyle = false; } else if (tagId == TagId::Picture && !m_pictureSourceState.isEmpty()) m_pictureSourceState.removeLast(); return; } case HTMLToken::StartTag: { #if ENABLE(TEMPLATE_ELEMENT) if (m_templateCount) return; #endif TagId tagId = tagIdFor(token.name()); #if ENABLE(TEMPLATE_ELEMENT) if (tagId == TagId::Template) { ++m_templateCount; return; } #endif if (tagId == TagId::Style) { m_inStyle = true; return; } if (tagId == TagId::Base) { // The first <base> element is the one that wins. if (!m_predictedBaseElementURL.isEmpty()) return; updatePredictedBaseURL(token); return; } if (tagId == TagId::Picture) { m_pictureSourceState.append(false); return; } StartTagScanner scanner(tagId, m_deviceScaleFactor); scanner.processAttributes(token.attributes(), document, m_pictureSourceState); if (auto request = scanner.createPreloadRequest(m_predictedBaseElementURL)) requests.append(WTFMove(request)); return; } default: return; } }