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