CSSPreloadScanner should not depend on HTMLToken
authorabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Feb 2013 22:40:27 +0000 (22:40 +0000)
committerabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Feb 2013 22:40:27 +0000 (22:40 +0000)
https://bugs.webkit.org/show_bug.cgi?id=109742

Reviewed by Eric Seidel.

There's no need for the CSSPreloadScanner to depend on HTMLToken. On
the background thread, we'll likely want to use a CompactHTMLToken for
preload scanning, so this dependency is problematic. This patch also
teaches the CSSPreloadScanner how to scan LChars.

* html/parser/CSSPreloadScanner.cpp:
(WebCore::CSSPreloadScanner::~CSSPreloadScanner):
(WebCore):
(WebCore::CSSPreloadScanner::scan):
* html/parser/CSSPreloadScanner.h:
(CSSPreloadScanner):
* html/parser/HTMLPreloadScanner.cpp:
(WebCore::HTMLPreloadScanner::processToken):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@142803 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/html/parser/CSSPreloadScanner.cpp
Source/WebCore/html/parser/CSSPreloadScanner.h
Source/WebCore/html/parser/HTMLPreloadScanner.cpp

index 17195ee..e06965e 100644 (file)
@@ -1,3 +1,24 @@
+2013-02-13  Adam Barth  <abarth@webkit.org>
+
+        CSSPreloadScanner should not depend on HTMLToken
+        https://bugs.webkit.org/show_bug.cgi?id=109742
+
+        Reviewed by Eric Seidel.
+
+        There's no need for the CSSPreloadScanner to depend on HTMLToken. On
+        the background thread, we'll likely want to use a CompactHTMLToken for
+        preload scanning, so this dependency is problematic. This patch also
+        teaches the CSSPreloadScanner how to scan LChars.
+
+        * html/parser/CSSPreloadScanner.cpp:
+        (WebCore::CSSPreloadScanner::~CSSPreloadScanner):
+        (WebCore):
+        (WebCore::CSSPreloadScanner::scan):
+        * html/parser/CSSPreloadScanner.h:
+        (CSSPreloadScanner):
+        * html/parser/HTMLPreloadScanner.cpp:
+        (WebCore::HTMLPreloadScanner::processToken):
+
 2013-02-13  Julien Chaffraix  <jchaffraix@webkit.org>
 
         [CSS Grid Layout] Adding or removing grid items doesn't properly recompute the track sizes
index 3bfe816..9577079 100644 (file)
 #include "config.h"
 #include "CSSPreloadScanner.h"
 
-#include "CachedCSSStyleSheet.h"
-#include "CachedResourceLoader.h"
-#include "CachedResourceRequest.h"
 #include "CachedResourceRequestInitiators.h"
 #include "HTMLParserIdioms.h"
-#include "HTMLToken.h"
-#include <wtf/Functional.h>
-#include <wtf/MainThread.h>
 
 namespace WebCore {
 
@@ -45,6 +39,10 @@ CSSPreloadScanner::CSSPreloadScanner()
 {
 }
 
+CSSPreloadScanner::~CSSPreloadScanner()
+{
+}
+
 void CSSPreloadScanner::reset()
 {
     m_state = Initial;
@@ -52,12 +50,19 @@ void CSSPreloadScanner::reset()
     m_ruleValue.clear();
 }
 
-void CSSPreloadScanner::scan(const HTMLToken& token, Vector<OwnPtr<PreloadRequest> >& requests)
+void CSSPreloadScanner::scan(const UChar* begin, const UChar* end, Vector<OwnPtr<PreloadRequest> >& requests)
+{
+    m_requests = &requests;
+    for (const UChar* it = begin; it != end && m_state != DoneParsingImportRules; ++it)
+        tokenize(*it);
+    m_requests = 0;
+}
+
+void CSSPreloadScanner::scan(const LChar* begin, const LChar* end, Vector<OwnPtr<PreloadRequest> >& requests)
 {
     m_requests = &requests;
-    const HTMLToken::DataVector& characters = token.characters();
-    for (HTMLToken::DataVector::const_iterator iter = characters.begin(); iter != characters.end() && m_state != DoneParsingImportRules; ++iter)
-        tokenize(*iter);
+    for (const LChar* it = begin; it != end && m_state != DoneParsingImportRules; ++it)
+        tokenize(*it);
     m_requests = 0;
 }
 
index ff9496f..22f6fa8 100644 (file)
 #define CSSPreloadScanner_h
 
 #include "HTMLResourcePreloader.h"
-#include <wtf/WeakPtr.h>
 #include <wtf/text/StringBuilder.h>
 
 namespace WebCore {
 
-class HTMLToken;
-
 class CSSPreloadScanner {
     WTF_MAKE_NONCOPYABLE(CSSPreloadScanner);
 public:
-    explicit CSSPreloadScanner();
+    CSSPreloadScanner();
+    ~CSSPreloadScanner();
 
     void reset();
-    void scan(const HTMLToken&, Vector<OwnPtr<PreloadRequest> >& requests);
+
+    void scan(const UChar* begin, const UChar* end, Vector<OwnPtr<PreloadRequest> >&);
+    void scan(const LChar* begin, const LChar* end, Vector<OwnPtr<PreloadRequest> >&);
 
 private:
     enum State {
index f30a5b2..c5a3104 100644 (file)
@@ -283,7 +283,8 @@ void HTMLPreloadScanner::processToken(const HTMLToken& token, Vector<OwnPtr<Prel
     if (m_inStyle) {
         if (token.type() != HTMLToken::Character)
             return;
-        return m_cssScanner.scan(token, requests);
+        const HTMLToken::DataVector& characters = token.characters();
+        return m_cssScanner.scan(characters.begin(), characters.end(), requests);
     }
     if (!isStartOrEndTag(token))
         return;