HTMLPreloadScanner should understand the <base> element
authorabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 Feb 2012 04:07:52 +0000 (04:07 +0000)
committerabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 Feb 2012 04:07:52 +0000 (04:07 +0000)
commite18d059717c3007bb1ff92620646f33a4f7e21cb
tree8f9858cd62a1ea44bb8a58f35a9f5167afd365c2
parentb92146d2b9d27ea082246dd32ed7c1c2e7525a64
HTMLPreloadScanner should understand the <base> element
https://bugs.webkit.org/show_bug.cgi?id=77231

Reviewed by Eric Seidel.

Source/WebCore:

Previously, the HTMLPreloadScanner would ignore the <base> element when
preloading resources.  If there was a <base> tag, this could cause the
preload scanner to make a bunch of useless requests.

This patch teaches the preload scanner to use <base> tags to better
predict which URLs will be used by the document.

Tests: fast/preloader/first-base-tag-scanned-wins.html
       fast/preloader/first-base-tag-wins.html
       fast/preloader/understands-base-tag.html

* dom/Document.cpp:
(WebCore::Document::completeURL):
(WebCore):
* dom/Document.h:
(Document):
(WebCore::Document::baseElementURL):
* html/parser/HTMLPreloadScanner.cpp:
(WebCore::HTMLNames::PreloadTask::PreloadTask):
(WebCore::HTMLNames::PreloadTask::processAttributes):
(WebCore::HTMLNames::PreloadTask::preload):
(WebCore::HTMLNames::PreloadTask::baseElementHref):
(PreloadTask):
(WebCore::HTMLPreloadScanner::scan):
(WebCore::HTMLPreloadScanner::processToken):
(WebCore::HTMLPreloadScanner::updatePredictedBaseElementURL):
(WebCore):
* html/parser/HTMLPreloadScanner.h:
(HTMLPreloadScanner):

LayoutTests:

These tests ensure that we understand the <base> element and that we
understand that the first <base> element is the one that maters.

* fast/preloader/first-base-tag-scanned-wins-expected.txt: Added.
* fast/preloader/first-base-tag-scanned-wins.html: Added.
* fast/preloader/first-base-tag-wins-expected.txt: Added.
* fast/preloader/first-base-tag-wins.html: Added.
* fast/preloader/resources/base-image1.png: Copied from LayoutTests/fast/preloader/resources/image1.png.
* fast/preloader/resources/base-image2.png: Copied from LayoutTests/fast/preloader/resources/image1.png.
* fast/preloader/resources/base-image3.png: Copied from LayoutTests/fast/preloader/resources/image1.png.
* fast/preloader/understands-base-tag-expected.txt: Added.
* fast/preloader/understands-base-tag.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@106426 268f45cc-cd09-0410-ab3c-d52691b4dbfc
15 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/preloader/first-base-tag-scanned-wins-expected.txt [new file with mode: 0644]
LayoutTests/fast/preloader/first-base-tag-scanned-wins.html [new file with mode: 0644]
LayoutTests/fast/preloader/first-base-tag-wins-expected.txt [new file with mode: 0644]
LayoutTests/fast/preloader/first-base-tag-wins.html [new file with mode: 0644]
LayoutTests/fast/preloader/resources/base-image1.png [new file with mode: 0644]
LayoutTests/fast/preloader/resources/base-image2.png [new file with mode: 0644]
LayoutTests/fast/preloader/resources/base-image3.png [new file with mode: 0644]
LayoutTests/fast/preloader/understands-base-tag-expected.txt [new file with mode: 0644]
LayoutTests/fast/preloader/understands-base-tag.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/html/parser/HTMLPreloadScanner.cpp
Source/WebCore/html/parser/HTMLPreloadScanner.h