Changeset 61366 in webkit


Ignore:
Timestamp:
Jun 17, 2010, 7:01:00 PM (15 years ago)
Author:
abarth@webkit.org
Message:

2010-06-17 Adam Barth <abarth@webkit.org>

Reviewed by Eric Seidel.

Add CSS scanning to HTML5PreloadScanner
https://bugs.webkit.org/show_bug.cgi?id=40802

This patch just cribs the CSS preload scanning algorithm from the old
preload scanner. We also invented a way of testing the preload
scanner.

Tests: fast/preloader/image.html

fast/preloader/link.html
fast/preloader/script.html
fast/preloader/style.html

  • Android.mk:
  • GNUmakefile.am:
  • WebCore.gypi:
  • WebCore.pro:
  • WebCore.vcproj/WebCore.vcproj:
  • WebCore.xcodeproj/project.pbxproj:
  • html/CSSPreloadScanner.cpp: Added. (WebCore::isWhitespace): (WebCore::CSSPreloadScanner::CSSPreloadScanner): (WebCore::CSSPreloadScanner::reset): (WebCore::CSSPreloadScanner::scan): (WebCore::CSSPreloadScanner::tokenize): (WebCore::CSSPreloadScanner::emitRule):
  • html/CSSPreloadScanner.h: Added. (WebCore::CSSPreloadScanner::):
  • html/HTML5PreloadScanner.cpp: (WebCore::HTML5PreloadScanner::HTML5PreloadScanner): (WebCore::HTML5PreloadScanner::processToken): (WebCore::HTML5PreloadScanner::scanningBody):
  • html/HTML5PreloadScanner.h:

2010-06-17 Adam Barth <abarth@webkit.org>

Reviewed by Eric Seidel.

Add CSS scanning to HTML5PreloadScanner
https://bugs.webkit.org/show_bug.cgi?id=40802

Add a testing framework for the preload scanner. These test cover
basic preloader behavior. They have a small hack to work around a bug
in the preload scanner discovered while writing the tests. I'll fix
the bug and remove the hack in a followup patch.

  • fast/preloader/image-expected.txt: Added.
  • fast/preloader/image.html: Added.
  • fast/preloader/link-expected.txt: Added.
  • fast/preloader/link.html: Added.
  • fast/preloader/resources/image1.png: Added.
  • fast/preloader/resources/link1.css: Added.
  • fast/preloader/resources/script1.js: Added.
  • fast/preloader/resources/style1.css: Added.
  • fast/preloader/script-expected.txt: Added.
  • fast/preloader/script.html: Added.
  • fast/preloader/style-expected.txt: Added.
  • fast/preloader/style.html: Added.
Location:
trunk
Files:
16 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r61356 r61366  
     12010-06-17  Adam Barth  <abarth@webkit.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Add CSS scanning to HTML5PreloadScanner
     6        https://bugs.webkit.org/show_bug.cgi?id=40802
     7
     8        Add a testing framework for the preload scanner.  These test cover
     9        basic preloader behavior.  They have a small hack to work around a bug
     10        in the preload scanner discovered while writing the tests.  I'll fix
     11        the bug and remove the hack in a followup patch.
     12
     13        * fast/preloader/image-expected.txt: Added.
     14        * fast/preloader/image.html: Added.
     15        * fast/preloader/link-expected.txt: Added.
     16        * fast/preloader/link.html: Added.
     17        * fast/preloader/resources/image1.png: Added.
     18        * fast/preloader/resources/link1.css: Added.
     19        * fast/preloader/resources/script1.js: Added.
     20        * fast/preloader/resources/style1.css: Added.
     21        * fast/preloader/script-expected.txt: Added.
     22        * fast/preloader/script.html: Added.
     23        * fast/preloader/style-expected.txt: Added.
     24        * fast/preloader/style.html: Added.
     25
    1262010-06-17  Dimitri Glazkov  <dglazkov@chromium.org>
    227
  • trunk/WebCore/Android.mk

    r61255 r61366  
    245245        html/Blob.cpp \
    246246        html/CollectionCache.cpp \
     247        html/CSSPreloadScanner.cpp \
    247248        html/DOMFormData.cpp \
    248249        html/File.cpp \
  • trunk/WebCore/ChangeLog

    r61365 r61366  
     12010-06-17  Adam Barth  <abarth@webkit.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Add CSS scanning to HTML5PreloadScanner
     6        https://bugs.webkit.org/show_bug.cgi?id=40802
     7
     8        This patch just cribs the CSS preload scanning algorithm from the old
     9        preload scanner.  We also invented a way of testing the preload
     10        scanner.
     11
     12        Tests: fast/preloader/image.html
     13               fast/preloader/link.html
     14               fast/preloader/script.html
     15               fast/preloader/style.html
     16
     17        * Android.mk:
     18        * GNUmakefile.am:
     19        * WebCore.gypi:
     20        * WebCore.pro:
     21        * WebCore.vcproj/WebCore.vcproj:
     22        * WebCore.xcodeproj/project.pbxproj:
     23        * html/CSSPreloadScanner.cpp: Added.
     24        (WebCore::isWhitespace):
     25        (WebCore::CSSPreloadScanner::CSSPreloadScanner):
     26        (WebCore::CSSPreloadScanner::reset):
     27        (WebCore::CSSPreloadScanner::scan):
     28        (WebCore::CSSPreloadScanner::tokenize):
     29        (WebCore::CSSPreloadScanner::emitRule):
     30        * html/CSSPreloadScanner.h: Added.
     31        (WebCore::CSSPreloadScanner::):
     32        * html/HTML5PreloadScanner.cpp:
     33        (WebCore::HTML5PreloadScanner::HTML5PreloadScanner):
     34        (WebCore::HTML5PreloadScanner::processToken):
     35        (WebCore::HTML5PreloadScanner::scanningBody):
     36        * html/HTML5PreloadScanner.h:
     37
    1382010-06-17  Abhishek Arya  <inferno@chromium.org>
    239
  • trunk/WebCore/GNUmakefile.am

    r61255 r61366  
    10551055        WebCore/html/CollectionCache.h \
    10561056        WebCore/html/CollectionType.h \
     1057        WebCore/html/CSSPreloadScanner.cpp \
     1058        WebCore/html/CSSPreloadScanner.h \
    10571059        WebCore/html/DataGridColumn.cpp \
    10581060        WebCore/html/DataGridColumn.h \
  • trunk/WebCore/WebCore.gypi

    r61255 r61366  
    14401440            'html/CollectionCache.h',
    14411441            'html/CollectionType.h',
     1442            'html/CSSPreloadScanner.cpp',
     1443            'html/CSSPreloadScanner.h',
    14421444            'html/DataGridColumn.cpp',
    14431445            'html/DataGridColumn.h',
  • trunk/WebCore/WebCore.pro

    r61319 r61366  
    599599    html/canvas/CanvasStyle.cpp \
    600600    html/CollectionCache.cpp \
     601    html/CSSPreloadScanner.cpp \
    601602    html/DataGridColumn.cpp \
    602603    html/DataGridColumnList.cpp \
  • trunk/WebCore/WebCore.vcproj/WebCore.vcproj

    r61255 r61366  
    3320933209                                >
    3321033210                        </File>
     33211                        <File
     33212                                RelativePath="..\html\CSSPreloadScanner.cpp"
     33213                                >
     33214                        </File>
     33215                        <File
     33216                                RelativePath="..\html\CSSPreloadScanner.h"
     33217                                >
     33218                        </File>
    3321133219                        <File
    3321233220                                RelativePath="..\html\DataGridColumn.cpp"
  • trunk/WebCore/WebCore.xcodeproj/project.pbxproj

    r61269 r61366  
    25412541                973E325610883B7C005BC493 /* ResourceLoadNotifier.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 973E325410883B7C005BC493 /* ResourceLoadNotifier.cpp */; };
    25422542                973E325710883B7C005BC493 /* ResourceLoadNotifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 973E325510883B7C005BC493 /* ResourceLoadNotifier.h */; settings = {ATTRIBUTES = (Private, ); }; };
     2543                976E2BA711CAE4DE006C56A0 /* CSSPreloadScanner.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 976E2BA511CAE4DE006C56A0 /* CSSPreloadScanner.cpp */; };
     2544                976E2BA811CAE4DE006C56A0 /* CSSPreloadScanner.h in Headers */ = {isa = PBXBuildFile; fileRef = 976E2BA611CAE4DE006C56A0 /* CSSPreloadScanner.h */; };
    25432545                976E896011C0CA3A00EA9CA9 /* HTML5EntityParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 976E895E11C0CA3A00EA9CA9 /* HTML5EntityParser.cpp */; };
    25442546                976E896111C0CA3A00EA9CA9 /* HTML5EntityParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 976E895F11C0CA3A00EA9CA9 /* HTML5EntityParser.h */; };
     
    81218123                973E325410883B7C005BC493 /* ResourceLoadNotifier.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceLoadNotifier.cpp; sourceTree = "<group>"; };
    81228124                973E325510883B7C005BC493 /* ResourceLoadNotifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceLoadNotifier.h; sourceTree = "<group>"; };
     8125                976E2BA511CAE4DE006C56A0 /* CSSPreloadScanner.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSPreloadScanner.cpp; sourceTree = "<group>"; };
     8126                976E2BA611CAE4DE006C56A0 /* CSSPreloadScanner.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSPreloadScanner.h; sourceTree = "<group>"; };
    81238127                976E895E11C0CA3A00EA9CA9 /* HTML5EntityParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTML5EntityParser.cpp; sourceTree = "<group>"; };
    81248128                976E895F11C0CA3A00EA9CA9 /* HTML5EntityParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTML5EntityParser.h; sourceTree = "<group>"; };
     
    1340013404                                2ED609BB1145B07100C8684E /* DOMFormData.h */,
    1340113405                                2E0888C3114883A900AF4265 /* DOMFormData.idl */,
     13406                                976E2BA511CAE4DE006C56A0 /* CSSPreloadScanner.cpp */,
     13407                                976E2BA611CAE4DE006C56A0 /* CSSPreloadScanner.h */,
    1340213408                                BCDBB8CC0E08958400C60FF6 /* File.cpp */,
    1340313409                                BCDBB8CB0E08958400C60FF6 /* File.h */,
     
    1942619432                                0853D73411C9109000B2FD42 /* SVGTextQuery.h in Headers */,
    1942719433                                49FFBF3F11C93EE3006A7118 /* WebGLLayer.h in Headers */,
     19434                                976E2BA811CAE4DE006C56A0 /* CSSPreloadScanner.h in Headers */,
    1942819435                        );
    1942919436                        runOnlyForDeploymentPostprocessing = 0;
     
    2173321740                                0853D73311C9109000B2FD42 /* SVGTextQuery.cpp in Sources */,
    2173421741                                49FFBF4011C93EE3006A7118 /* WebGLLayer.mm in Sources */,
     21742                                976E2BA711CAE4DE006C56A0 /* CSSPreloadScanner.cpp in Sources */,
    2173521743                        );
    2173621744                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/WebCore/html/HTML5PreloadScanner.cpp

    r61163 r61366  
    120120HTML5PreloadScanner::HTML5PreloadScanner(Document* document)
    121121    : m_document(document)
     122    , m_cssScanner(document)
    122123    , m_bodySeen(false)
     124    , m_inStyle(false)
    123125{
    124126}
     
    141143void HTML5PreloadScanner::processToken()
    142144{
     145    if (m_inStyle) {
     146        if (m_token.type() == HTML5Token::Character)
     147            m_cssScanner.scan(m_token, scanningBody());
     148        else if (m_token.type() == HTML5Token::EndTag) {
     149            m_inStyle = false;
     150            m_cssScanner.reset();
     151        }
     152    }
     153
    143154    if (m_token.type() != HTML5Token::StartTag)
    144155        return;
     
    150161        m_bodySeen = true;
    151162
    152     task.preload(m_document, m_document->body() || m_bodySeen);
     163    if (task.tagName() == styleTag)
     164        m_inStyle = true;
     165
     166    task.preload(m_document, scanningBody());
     167}
     168
     169bool HTML5PreloadScanner::scanningBody() const
     170{
     171    return m_document->body() || m_bodySeen;
    153172}
    154173
  • trunk/WebCore/html/HTML5PreloadScanner.h

    r61163 r61366  
    2828#define HTML5PreloadScanner_h
    2929
     30#include "CSSPreloadScanner.h"
    3031#include "HTML5Lexer.h"
    3132#include "HTML5Token.h"
     
    4849private:
    4950    void processToken();
     51    bool scanningBody() const;
    5052
    5153    Document* m_document;
     
    5355    HTML5Lexer m_lexer;
    5456    HTML5Token m_token;
     57    CSSPreloadScanner m_cssScanner;
    5558    bool m_bodySeen;
     59    bool m_inStyle;
    5660};
    5761
Note: See TracChangeset for help on using the changeset viewer.