Changeset 36650 in webkit
- Timestamp:
- Sep 18, 2008 9:15:14 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 5 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r36627 r36650 1 2008-09-18 Collin Jackson <collinj@webkit.org> 2 3 Reviewed by Antti Koivisto and Mark Rowe. 4 5 https://bugs.webkit.org/show_bug.cgi?id=20690 6 7 Add test for DNS prefetch control. 8 9 * http/tests/misc/dns-prefetch-control-expected.txt: Added. 10 * http/tests/misc/dns-prefetch-control.html: Added. 11 * http/tests/misc/resources/dns-prefetch-control.php: Added. 12 1 13 2008-09-18 Chris Fleizach <cfleizach@apple.com> 2 14 -
trunk/WebCore/ChangeLog
r36649 r36650 1 2008-09-18 Collin Jackson <collinj@webkit.org> 2 3 Reviewed by Antti Koivisto and Mark Rowe. 4 5 Test: http/tests/misc/dns-prefetch-control.html 6 7 https://bugs.webkit.org/show_bug.cgi?id=20690 8 9 Invoke WebCore::prefetchDNS() on host names that appear in 10 in the href of hyperlinks and <link rel="dns-prefetch">. This 11 can be used to implement DNS prefetching. 12 13 * WebCore.vcproj/WebCore.vcproj: 14 * WebCore.xcodeproj/project.pbxproj: 15 * dom/Document.cpp: 16 (WebCore::Document::Document): 17 (WebCore::Document::processHttpEquiv): 18 (WebCore::Document::setSecurityOrigin): 19 (WebCore::Document::initDNSPrefetch): 20 (WebCore::Document::parseDNSPrefetchControlHeader): 21 * dom/Document.h: 22 (WebCore::Document::isDNSPrefetchEnabled): 23 * html/HTMLAnchorElement.cpp: 24 (WebCore::HTMLAnchorElement::parseMappedAttribute): 25 * html/HTMLLinkElement.cpp: 26 (WebCore::HTMLLinkElement::HTMLLinkElement): 27 (WebCore::HTMLLinkElement::parseMappedAttribute): 28 (WebCore::HTMLLinkElement::tokenizeRelAttribute): 29 (WebCore::HTMLLinkElement::process): 30 * html/HTMLLinkElement.h: 31 * html/PreloadScanner.cpp: 32 (WebCore::PreloadScanner::processAttribute): 33 * loader/FrameLoader.cpp: 34 (WebCore::FrameLoader::begin): 35 * platform/gtk/TemporaryLinkStubs.cpp: 36 (WebCore::prefetchDNS): 37 * platform/network/DNS.h: Added. 38 * platform/network/cf/DNSCFNet.cpp: Added. 39 (WebCore::prefetchDNS): 40 * platform/qt/TemporaryLinkStubs.cpp: 41 (WebCore::prefetchDNS): 42 * platform/wx/TemporaryLinkStubs.cpp: 43 (WebCore::prefetchDNS): 44 1 45 2008-09-18 David Hyatt <hyatt@apple.com> 2 46 -
trunk/WebCore/WebCore.vcproj/WebCore.vcproj
r36630 r36650 5589 5589 </File> 5590 5590 <File 5591 RelativePath="..\platform\network\cf\DNSCFNet.cpp" 5592 > 5593 <FileConfiguration 5594 Name="Debug_Cairo|Win32" 5595 ExcludedFromBuild="true" 5596 > 5597 <Tool 5598 Name="VCCLCompilerTool" 5599 /> 5600 </FileConfiguration> 5601 <FileConfiguration 5602 Name="Release_Cairo|Win32" 5603 ExcludedFromBuild="true" 5604 > 5605 <Tool 5606 Name="VCCLCompilerTool" 5607 /> 5608 </FileConfiguration> 5609 </File> 5610 <File 5591 5611 RelativePath="..\platform\network\cf\ResourceRequestCFNet.h" 5592 5612 > -
trunk/WebCore/WebCore.xcodeproj/project.pbxproj
r36635 r36650 3382 3382 B2EBDC9D0AF77E3400AE4A68 /* SVGRenderTreeAsText.h in Headers */ = {isa = PBXBuildFile; fileRef = B2EBDC9B0AF77E3400AE4A68 /* SVGRenderTreeAsText.h */; }; 3383 3383 B2ED97710B1F55CE00257D0F /* GraphicsContextCG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2ED97700B1F55CE00257D0F /* GraphicsContextCG.cpp */; }; 3384 B2F34FE60E82F81400F627CD /* DNS.h in Headers */ = {isa = PBXBuildFile; fileRef = B2F34FE50E82F81400F627CD /* DNS.h */; }; 3385 B2F34FE90E82F82700F627CD /* DNSCFNet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2F34FE80E82F82700F627CD /* DNSCFNet.cpp */; }; 3384 3386 B2FA3D360AB75A6F000E5AC4 /* JSSVGAnimateColorElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2FA3C4E0AB75A6E000E5AC4 /* JSSVGAnimateColorElement.cpp */; }; 3385 3387 B2FA3D370AB75A6F000E5AC4 /* JSSVGAnimateColorElement.h in Headers */ = {isa = PBXBuildFile; fileRef = B2FA3C4F0AB75A6E000E5AC4 /* JSSVGAnimateColorElement.h */; }; … … 7886 7888 B2EBDC9B0AF77E3400AE4A68 /* SVGRenderTreeAsText.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SVGRenderTreeAsText.h; sourceTree = "<group>"; }; 7887 7889 B2ED97700B1F55CE00257D0F /* GraphicsContextCG.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsContextCG.cpp; sourceTree = "<group>"; }; 7890 B2F34FE50E82F81400F627CD /* DNS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DNS.h; sourceTree = "<group>"; }; 7891 B2F34FE80E82F82700F627CD /* DNSCFNet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DNSCFNet.cpp; path = cf/DNSCFNet.cpp; sourceTree = "<group>"; }; 7888 7892 B2FA3C4E0AB75A6E000E5AC4 /* JSSVGAnimateColorElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSSVGAnimateColorElement.cpp; sourceTree = "<group>"; }; 7889 7893 B2FA3C4F0AB75A6E000E5AC4 /* JSSVGAnimateColorElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSSVGAnimateColorElement.h; sourceTree = "<group>"; }; … … 9299 9303 isa = PBXGroup; 9300 9304 children = ( 9305 B2F34FE70E82F81700F627CD /* cf */, 9301 9306 656B84E70AEA1DAE00A095B4 /* mac */, 9302 9307 934F71370D5A6EFF00018D69 /* AuthenticationChallengeBase.cpp */, … … 9304 9309 514C76580CE923A1007EF3CD /* Credential.cpp */, 9305 9310 514C76590CE923A1007EF3CD /* Credential.h */, 9311 B2F34FE50E82F81400F627CD /* DNS.h */, 9306 9312 514C765A0CE923A1007EF3CD /* FormData.cpp */, 9307 9313 514C765B0CE923A1007EF3CD /* FormData.h */, … … 12588 12594 sourceTree = "<group>"; 12589 12595 }; 12596 B2F34FE70E82F81700F627CD /* cf */ = { 12597 isa = PBXGroup; 12598 children = ( 12599 B2F34FE80E82F82700F627CD /* DNSCFNet.cpp */, 12600 ); 12601 name = cf; 12602 sourceTree = "<group>"; 12603 }; 12590 12604 BC1A3790097C6F970019F3D8 /* bindings */ = { 12591 12605 isa = PBXGroup; … … 15824 15838 BC2272E40E82EE9B00E7F975 /* StyleRareInheritedData.h in Headers */, 15825 15839 BC2273040E82F1E600E7F975 /* StyleInheritedData.h in Headers */, 15840 B2F34FE60E82F81400F627CD /* DNS.h in Headers */, 15826 15841 ); 15827 15842 runOnlyForDeploymentPostprocessing = 0; … … 17655 17670 BC2272E30E82EE9B00E7F975 /* StyleRareInheritedData.cpp in Sources */, 17656 17671 BC2273030E82F1E600E7F975 /* StyleInheritedData.cpp in Sources */, 17672 B2F34FE90E82F82700F627CD /* DNSCFNet.cpp in Sources */, 17657 17673 ); 17658 17674 runOnlyForDeploymentPostprocessing = 0; -
trunk/WebCore/dom/Document.cpp
r36466 r36650 352 352 353 353 initSecurityContext(); 354 initDNSPrefetch(); 354 355 355 356 static int docID = 0; … … 1953 1954 } else if (equalIgnoringCase(equiv, "content-language")) 1954 1955 setContentLanguage(content); 1956 else if (equalIgnoringCase(equiv, "x-dns-prefetch-control")) 1957 parseDNSPrefetchControlHeader(content); 1955 1958 } 1956 1959 … … 4031 4034 { 4032 4035 m_securityOrigin = securityOrigin; 4036 initDNSPrefetch(); 4033 4037 } 4034 4038 … … 4317 4321 } 4318 4322 4323 void Document::initDNSPrefetch() 4324 { 4325 m_haveExplicitlyDisabledDNSPrefetch = false; 4326 m_isDNSPrefetchEnabled = securityOrigin()->protocol() == "http"; 4327 4328 // Inherit DNS prefetch opt-out from parent frame 4329 if (Document* parent = parentDocument()) { 4330 if (!parent->isDNSPrefetchEnabled()) 4331 m_isDNSPrefetchEnabled = false; 4332 } 4333 } 4334 4335 void Document::parseDNSPrefetchControlHeader(const String& dnsPrefetchControl) 4336 { 4337 if (equalIgnoringCase(dnsPrefetchControl, "on") && !m_haveExplicitlyDisabledDNSPrefetch) { 4338 m_isDNSPrefetchEnabled = true; 4339 return; 4340 } 4341 4342 m_isDNSPrefetchEnabled = false; 4343 m_haveExplicitlyDisabledDNSPrefetch = true; 4344 } 4345 4319 4346 } // namespace WebCore -
trunk/WebCore/dom/Document.h
r36466 r36650 763 763 HTMLCanvasElement* getCSSCanvasElement(const String& name); 764 764 765 bool isDNSPrefetchEnabled() const { return m_isDNSPrefetchEnabled; } 766 void initDNSPrefetch(); 767 void parseDNSPrefetchControlHeader(const String&); 768 765 769 protected: 766 770 Document(Frame*, bool isXHTML); … … 867 871 bool m_gotoAnchorNeededAfterStylesheetsLoad; 868 872 873 bool m_isDNSPrefetchEnabled; 874 bool m_haveExplicitlyDisabledDNSPrefetch; 875 869 876 String m_title; 870 877 bool m_titleSetExplicitly; -
trunk/WebCore/html/HTMLAnchorElement.cpp
r35304 r36650 26 26 27 27 #include "CSSHelper.h" 28 #include "DNS.h" 28 29 #include "Document.h" 29 30 #include "Event.h" … … 32 33 #include "Frame.h" 33 34 #include "FrameLoader.h" 35 #include "FrameLoaderClient.h" 34 36 #include "HTMLImageElement.h" 35 37 #include "HTMLNames.h" … … 275 277 if (wasLink != isLink()) 276 278 setChanged(); 279 if (isLink() && document()->isDNSPrefetchEnabled()) { 280 String value = attr->value(); 281 if (protocolIs(value, "http") || protocolIs(value, "https") || value.startsWith("//")) 282 prefetchDNS(document()->completeURL(value).host()); 283 } 277 284 } else if (attr->name() == nameAttr || 278 285 attr->name() == titleAttr || -
trunk/WebCore/html/HTMLLinkElement.cpp
r36406 r36650 26 26 #include "CSSHelper.h" 27 27 #include "CachedCSSStyleSheet.h" 28 #include "DNS.h" 28 29 #include "DocLoader.h" 29 30 #include "Document.h" 30 31 #include "Frame.h" 31 32 #include "FrameLoader.h" 33 #include "FrameLoaderClient.h" 32 34 #include "FrameTree.h" 33 35 #include "HTMLNames.h" … … 49 51 , m_isStyleSheet(false) 50 52 , m_isIcon(false) 53 , m_isDNSPrefetch(false) 51 54 , m_createdByParser(false) 52 55 { … … 108 111 { 109 112 if (attr->name() == relAttr) { 110 tokenizeRelAttribute(attr->value(), m_isStyleSheet, m_alternate, m_isIcon );113 tokenizeRelAttribute(attr->value(), m_isStyleSheet, m_alternate, m_isIcon, m_isDNSPrefetch); 111 114 process(); 112 115 } else if (attr->name() == hrefAttr) { … … 128 131 } 129 132 130 void HTMLLinkElement::tokenizeRelAttribute(const AtomicString& rel, bool& styleSheet, bool& alternate, bool& icon )133 void HTMLLinkElement::tokenizeRelAttribute(const AtomicString& rel, bool& styleSheet, bool& alternate, bool& icon, bool& dnsPrefetch) 131 134 { 132 135 styleSheet = false; 133 136 icon = false; 134 137 alternate = false; 138 dnsPrefetch = false; 135 139 if (equalIgnoringCase(rel, "stylesheet")) 136 140 styleSheet = true; 137 141 else if (equalIgnoringCase(rel, "icon") || equalIgnoringCase(rel, "shortcut icon")) 138 142 icon = true; 143 else if (equalIgnoringCase(rel, "dns-prefetch")) 144 dnsPrefetch = true; 139 145 else if (equalIgnoringCase(rel, "alternate stylesheet") || equalIgnoringCase(rel, "stylesheet alternate")) { 140 146 styleSheet = true; … … 169 175 if (m_isIcon && !m_url.isEmpty()) 170 176 document()->setIconURL(m_url, type); 177 178 if (m_isDNSPrefetch && !m_url.isEmpty()) 179 prefetchDNS(KURL(m_url).host()); 171 180 172 181 // Stylesheet -
trunk/WebCore/html/HTMLLinkElement.h
r36109 r36650 94 94 virtual bool isURLAttribute(Attribute*) const; 95 95 96 static void tokenizeRelAttribute(const AtomicString& value, bool& stylesheet, bool& alternate, bool& icon );96 static void tokenizeRelAttribute(const AtomicString& value, bool& stylesheet, bool& alternate, bool& icon, bool& dnsPrefetch); 97 97 98 98 virtual void getSubresourceAttributeStrings(Vector<String>&) const; … … 112 112 bool m_isStyleSheet; 113 113 bool m_isIcon; 114 bool m_isDNSPrefetch; 114 115 bool m_createdByParser; 115 116 }; -
trunk/WebCore/html/PreloadScanner.cpp
r35801 r36650 701 701 bool alternate = false; 702 702 bool icon = false; 703 HTMLLinkElement::tokenizeRelAttribute(value, styleSheet, alternate, icon); 704 m_linkIsStyleSheet = styleSheet && !alternate && !icon; 703 bool dnsPrefetch = false; 704 HTMLLinkElement::tokenizeRelAttribute(value, styleSheet, alternate, icon, dnsPrefetch); 705 m_linkIsStyleSheet = styleSheet && !alternate && !icon && !dnsPrefetch; 705 706 } else if (attribute == charsetAttr) 706 707 m_charset = value; -
trunk/WebCore/loader/FrameLoader.cpp
r36266 r36650 953 953 document->docLoader()->setAutoLoadImages(settings && settings->loadsImagesAutomatically()); 954 954 955 if (m_documentLoader) { 956 String dnsPrefetchControl = m_documentLoader->response().httpHeaderField("X-DNS-Prefetch-Control"); 957 if (!dnsPrefetchControl.isEmpty()) 958 document->parseDNSPrefetchControlHeader(dnsPrefetchControl); 959 } 960 955 961 #if FRAME_LOADS_USER_STYLESHEET 956 962 KURL userStyleSheet = settings ? settings->userStyleSheetLocation() : KURL(); -
trunk/WebCore/platform/gtk/TemporaryLinkStubs.cpp
r35469 r36650 29 29 30 30 #include "AXObjectCache.h" 31 #include "DNS.h" 31 32 #include "Editor.h" 32 33 #include "FrameView.h" … … 72 73 PassRefPtr<SharedBuffer> SharedBuffer::createWithContentsOfFile(const String&) { notImplemented(); return 0; } 73 74 75 void prefetchDNS(const String& hostname) { notImplemented(); } 76 74 77 } 75 78 -
trunk/WebCore/platform/qt/TemporaryLinkStubs.cpp
r35469 r36650 34 34 35 35 #include "AXObjectCache.h" 36 #include "DNS.h" 36 37 #include "CString.h" 37 38 #include "CachedResource.h" … … 113 114 PassRefPtr<SharedBuffer> SharedBuffer::createWithContentsOfFile(const String&) { notImplemented(); return 0; } 114 115 116 void prefetchDNS(const String& hostname) { notImplemented(); } 117 115 118 } 116 119 -
trunk/WebCore/platform/wx/TemporaryLinkStubs.cpp
r36532 r36650 40 40 #include "CookieJar.h" 41 41 #include "Cursor.h" 42 #include "DNS.h" 42 43 #include "DocumentFragment.h" 43 44 #include "DocumentLoader.h" … … 184 185 185 186 PassRefPtr<SharedBuffer> SharedBuffer::createWithContentsOfFile(const String&) { notImplemented(); return 0; } 187 188 void prefetchDNS(const String& hostname) { notImplemented(); } 189 186 190 }
Note: See TracChangeset
for help on using the changeset viewer.