Changeset 57468 in webkit
- Timestamp:
- Apr 11, 2010 9:20:23 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 41 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/Android.mk
r57215 r57468 286 286 loader/DocumentLoader.cpp \ 287 287 loader/DocumentThreadableLoader.cpp \ 288 loader/DocumentWriter.cpp \ 288 289 loader/FormState.cpp \ 289 290 loader/FrameLoader.cpp \ -
trunk/WebCore/ChangeLog
r57464 r57468 1 2010-04-11 Adam Barth <abarth@webkit.org> 2 3 Reviewed by Eric Seidel. 4 5 Factor DocumentWriter out of FrameLoader 6 https://bugs.webkit.org/show_bug.cgi?id=37175 7 8 This patch separates the begin/write/end cycle of decoding network 9 bytes and putting them into a document from the rest of the loading 10 machinery. The code and state required to write bytes into a document 11 doesn't interact very much with the rest of the loading machinery. 12 13 No tests because there is no behavior change (hopefully!). 14 15 * Android.mk: 16 * GNUmakefile.am: 17 * WebCore.base.exp: 18 * WebCore.gypi: 19 * WebCore.pro: 20 * WebCore.vcproj/WebCore.vcproj: 21 * WebCore.xcodeproj/project.pbxproj: 22 * bindings/ScriptControllerBase.cpp: 23 (WebCore::ScriptController::executeIfJavaScriptURL): 24 * dom/Document.cpp: 25 (WebCore::Document::close): 26 * dom/ProcessingInstruction.cpp: 27 (WebCore::ProcessingInstruction::checkStyleSheet): 28 * dom/ScriptElement.cpp: 29 (WebCore::ScriptElementData::scriptCharset): 30 * html/HTMLLinkElement.cpp: 31 (WebCore::HTMLLinkElement::process): 32 * loader/DocLoader.cpp: 33 (WebCore::DocLoader::requestPreload): 34 * loader/DocumentLoader.cpp: 35 (WebCore::DocumentLoader::finishedLoading): 36 (WebCore::DocumentLoader::setupForReplaceByMIMEType): 37 * loader/DocumentWriter.cpp: Added. 38 * loader/DocumentWriter.h: Added. 39 * loader/FrameLoader.cpp: 40 (WebCore::FrameLoader::FrameLoader): 41 (WebCore::FrameLoader::init): 42 (WebCore::FrameLoader::clear): 43 (WebCore::FrameLoader::receivedFirstData): 44 (WebCore::FrameLoader::setURL): 45 (WebCore::FrameLoader::didBeginDocument): 46 (WebCore::FrameLoader::didEndDocument): 47 (WebCore::FrameLoader::willSetEncoding): 48 (WebCore::FrameLoader::addData): 49 (WebCore::FrameLoader::transitionToCommitted): 50 (WebCore::FrameLoader::open): 51 (WebCore::FrameLoader::finishedLoadingDocument): 52 (WebCore::FrameLoader::addExtraFieldsToRequest): 53 * loader/FrameLoader.h: 54 (WebCore::FrameLoader::writer): 55 (WebCore::FrameLoader::isDisplayingInitialEmptyDocument): 56 * loader/MediaDocument.cpp: 57 (WebCore::MediaDocument::replaceMediaElementTimerFired): 58 * loader/PluginDocument.cpp: 59 (WebCore::PluginTokenizer::createDocumentStructure): 60 * platform/network/FormDataBuilder.cpp: 61 (WebCore::FormDataBuilder::dataEncoding): 62 * svg/graphics/SVGImage.cpp: 63 (WebCore::SVGImage::dataChanged): 64 1 65 2010-04-07 Tony Chang <tony@chromium.org> 2 66 -
trunk/WebCore/GNUmakefile.am
r57288 r57468 1307 1307 WebCore/loader/DocumentThreadableLoader.cpp \ 1308 1308 WebCore/loader/DocumentThreadableLoader.h \ 1309 WebCore/loader/DocumentWriter.cpp \ 1310 WebCore/loader/DocumentWriter.h \ 1309 1311 WebCore/loader/EmptyClients.h \ 1310 1312 WebCore/loader/FTPDirectoryDocument.cpp \ -
trunk/WebCore/WebCore.base.exp
r57373 r57468 158 158 __ZN7WebCore11FrameLoader11completeURLERKNS_6StringE 159 159 __ZN7WebCore11FrameLoader11loadArchiveEN3WTF10PassRefPtrINS_7ArchiveEEE 160 __ZN7WebCore11FrameLoader11setEncodingERKNS_6StringEb161 160 __ZN7WebCore11FrameLoader12shouldReloadERKNS_4KURLES3_ 162 161 __ZN7WebCore11FrameLoader14detachChildrenEv … … 303 302 __ZN7WebCore14DocumentLoaderC2ERKNS_15ResourceRequestERKNS_14SubstituteDataE 304 303 __ZN7WebCore14DocumentLoaderD2Ev 304 __ZN7WebCore14DocumentWriter11setEncodingERKNS_6StringEb 305 305 __ZN7WebCore14ResourceHandle12releaseProxyEv 306 306 __ZN7WebCore14ResourceHandle20forceContentSniffingEv … … 814 814 __ZNK7WebCore11FrameLoader15firstLayoutDoneEv 815 815 __ZNK7WebCore11FrameLoader16outgoingReferrerEv 816 __ZNK7WebCore11FrameLoader16responseMIMETypeEv817 816 __ZNK7WebCore11FrameLoader20activeDocumentLoaderEv 818 817 __ZNK7WebCore11FrameLoader27numPendingOrLoadingRequestsEb -
trunk/WebCore/WebCore.gypi
r57436 r57468 1733 1733 'loader/DocumentThreadableLoader.cpp', 1734 1734 'loader/DocumentThreadableLoader.h', 1735 'loader/DocumentWriter.cpp', 1736 'loader/DocumentWriter.h', 1735 1737 'loader/EmptyClients.h', 1736 1738 'loader/FTPDirectoryDocument.cpp', -
trunk/WebCore/WebCore.pro
r57433 r57468 735 735 loader/DocumentLoader.cpp \ 736 736 loader/DocumentThreadableLoader.cpp \ 737 loader/DocumentWriter.cpp \ 737 738 loader/FormState.cpp \ 738 739 loader/FrameLoader.cpp \ -
trunk/WebCore/WebCore.vcproj/WebCore.vcproj
r57229 r57468 21398 21398 </File> 21399 21399 <File 21400 RelativePath="..\loader\DocumentWriter.cpp" 21401 > 21402 </File> 21403 <File 21404 RelativePath="..\loader\DocumentWriter.h" 21405 > 21406 </File> 21407 <File 21400 21408 RelativePath="..\loader\DocumentThreadableLoader.cpp" 21401 21409 > -
trunk/WebCore/WebCore.xcodeproj/project.pbxproj
r57441 r57468 2483 2483 97059979107D975200A50A7C /* PolicyChecker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 97059975107D975200A50A7C /* PolicyChecker.cpp */; }; 2484 2484 9705997A107D975200A50A7C /* PolicyChecker.h in Headers */ = {isa = PBXBuildFile; fileRef = 97059976107D975200A50A7C /* PolicyChecker.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2485 973889A0116EA9DC00ADF313 /* DocumentWriter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9738899E116EA9DC00ADF313 /* DocumentWriter.cpp */; }; 2486 973889A1116EA9DC00ADF313 /* DocumentWriter.h in Headers */ = {isa = PBXBuildFile; fileRef = 9738899F116EA9DC00ADF313 /* DocumentWriter.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2485 2487 973E325610883B7C005BC493 /* ResourceLoadNotifier.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 973E325410883B7C005BC493 /* ResourceLoadNotifier.cpp */; }; 2486 2488 973E325710883B7C005BC493 /* ResourceLoadNotifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 973E325510883B7C005BC493 /* ResourceLoadNotifier.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 7916 7918 97059975107D975200A50A7C /* PolicyChecker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PolicyChecker.cpp; sourceTree = "<group>"; }; 7917 7919 97059976107D975200A50A7C /* PolicyChecker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PolicyChecker.h; sourceTree = "<group>"; }; 7920 9738899E116EA9DC00ADF313 /* DocumentWriter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DocumentWriter.cpp; sourceTree = "<group>"; }; 7921 9738899F116EA9DC00ADF313 /* DocumentWriter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DocumentWriter.h; sourceTree = "<group>"; }; 7918 7922 973E325410883B7C005BC493 /* ResourceLoadNotifier.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceLoadNotifier.cpp; sourceTree = "<group>"; }; 7919 7923 973E325510883B7C005BC493 /* ResourceLoadNotifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceLoadNotifier.h; sourceTree = "<group>"; }; … … 15216 15220 0B9056150F2578BE0095FF6A /* DocumentThreadableLoader.cpp */, 15217 15221 0B9056160F2578BE0095FF6A /* DocumentThreadableLoader.h */, 15222 9738899E116EA9DC00ADF313 /* DocumentWriter.cpp */, 15223 9738899F116EA9DC00ADF313 /* DocumentWriter.h */, 15218 15224 B255990D0D00D8B900BB825C /* EmptyClients.h */, 15219 15225 656D37230ADBA5DE00A4554D /* FormState.cpp */, … … 21062 21068 C5D4AA79116BAFB60069CA93 /* GlyphMetricsMap.cpp in Sources */, 21063 21069 895253D7116C4C6800CABF00 /* FileStream.cpp in Sources */, 21070 973889A0116EA9DC00ADF313 /* DocumentWriter.cpp in Sources */, 21064 21071 ); 21065 21072 runOnlyForDeploymentPostprocessing = 0; -
trunk/WebCore/bindings/ScriptControllerBase.cpp
r55207 r57468 102 102 // http://bugs.webkit.org/show_bug.cgi?id=16782 103 103 if (replaceDocument) 104 m_frame->loader()-> replaceDocument(scriptResult);104 m_frame->loader()->writer()->replaceDocument(scriptResult); 105 105 106 106 return true; -
trunk/WebCore/dom/Document.cpp
r57391 r57468 1770 1770 // This code calls implicitClose() if all loading has completed. 1771 1771 FrameLoader* frameLoader = frame->loader(); 1772 frameLoader-> endIfNotLoadingMainResource();1772 frameLoader->writer()->endIfNotLoadingMainResource(); 1773 1773 frameLoader->checkCompleted(); 1774 1774 } else { -
trunk/WebCore/dom/ProcessingInstruction.cpp
r54645 r57468 166 166 String charset = attrs.get("charset"); 167 167 if (charset.isEmpty()) 168 charset = document()->frame()->loader()-> encoding();168 charset = document()->frame()->loader()->writer()->encoding(); 169 169 170 170 m_cachedSheet = document()->docLoader()->requestCSSStyleSheet(url, charset); -
trunk/WebCore/dom/ScriptElement.cpp
r55428 r57468 264 264 if (charset.isEmpty()) { 265 265 if (Frame* frame = m_element->document()->frame()) 266 charset = frame->loader()-> encoding();266 charset = frame->loader()->writer()->encoding(); 267 267 } 268 268 -
trunk/WebCore/html/HTMLLinkElement.cpp
r56128 r57468 195 195 String charset = getAttribute(charsetAttr); 196 196 if (charset.isEmpty() && document()->frame()) 197 charset = document()->frame()->loader()-> encoding();197 charset = document()->frame()->loader()->writer()->encoding(); 198 198 199 199 if (m_cachedSheet) { -
trunk/WebCore/loader/DocLoader.cpp
r56825 r57468 405 405 String encoding; 406 406 if (type == CachedResource::Script || type == CachedResource::CSSStyleSheet) 407 encoding = charset.isEmpty() ? m_doc->frame()->loader()-> encoding() : charset;407 encoding = charset.isEmpty() ? m_doc->frame()->loader()->writer()->encoding() : charset; 408 408 409 409 CachedResource* resource = requestResource(type, url, encoding, true); -
trunk/WebCore/loader/DocumentLoader.cpp
r52944 r57468 266 266 if (FrameLoader* loader = frameLoader()) { 267 267 loader->finishedLoadingDocument(this); 268 loader-> end();268 loader->writer()->end(); 269 269 } 270 270 } … … 308 308 309 309 frameLoader()->finishedLoadingDocument(this); 310 m_frame->loader()-> end();310 m_frame->loader()->writer()->end(); 311 311 312 312 frameLoader()->setReplacing(); -
trunk/WebCore/loader/FrameLoader.cpp
r57445 r57468 165 165 } 166 166 167 static inline bool canReferToParentFrameEncoding(const Frame* frame, const Frame* parentFrame)168 {169 return parentFrame && parentFrame->document()->securityOrigin()->canAccess(frame->document()->securityOrigin());170 }171 172 167 FrameLoader::FrameLoader(Frame* frame, FrameLoaderClient* client) 173 168 : m_frame(frame) … … 176 171 , m_history(frame) 177 172 , m_notifer(frame) 173 , m_writer(frame) 178 174 , m_state(FrameStateCommittedPage) 179 175 , m_loadType(FrameLoadTypeStandard) … … 190 186 , m_isLoadingMainResource(false) 191 187 , m_needsClear(false) 192 , m_receivedData(false)193 , m_encodingWasChosenByUser(false)194 188 , m_containsPlugIns(false) 195 189 , m_checkTimer(this, &FrameLoader::checkTimerFired) … … 232 226 m_provisionalDocumentLoader->setResponse(ResourceResponse(KURL(), "text/html", 0, String(), String())); 233 227 m_provisionalDocumentLoader->finishedLoading(); 234 begin(KURL(), false);235 end();228 writer()->begin(KURL(), false); 229 writer()->end(); 236 230 m_frame->document()->cancelParsing(); 237 231 m_creatingInitialEmptyDocument = false; … … 706 700 } 707 701 708 void FrameLoader::replaceDocument(const String& html)709 {710 stopAllLoaders();711 begin(m_URL, true, m_frame->document()->securityOrigin());712 write(html);713 end();714 }715 716 702 void FrameLoader::clear(bool clearWindowProperties, bool clearScriptObjects, bool clearFrameView) 717 703 { … … 747 733 // as some destructors might still try to access the document. 748 734 m_frame->setDocument(0); 749 m_decoder = 0;735 writer()->clear(); 750 736 751 737 m_containsPlugIns = false; … … 759 745 m_shouldCallCheckCompleted = false; 760 746 m_shouldCallCheckLoadComplete = false; 761 762 m_receivedData = false;763 747 m_isDisplayingInitialEmptyDocument = false; 764 765 if (!m_encodingWasChosenByUser)766 m_encoding = String();767 748 } 768 749 769 750 void FrameLoader::receivedFirstData() 770 751 { 771 begin(m_workingURL, false);752 writer()->begin(m_workingURL, false); 772 753 773 754 dispatchDidCommitLoad(); … … 800 781 } 801 782 802 const String& FrameLoader::responseMIMEType() const 803 { 804 return m_responseMIMEType; 805 } 806 807 void FrameLoader::setResponseMIMEType(const String& type) 808 { 809 m_responseMIMEType = type; 810 } 811 812 void FrameLoader::begin() 813 { 814 begin(KURL()); 815 } 816 817 void FrameLoader::begin(const KURL& url, bool dispatch, SecurityOrigin* origin) 818 { 819 // We need to take a reference to the security origin because |clear| 820 // might destroy the document that owns it. 821 RefPtr<SecurityOrigin> forcedSecurityOrigin = origin; 822 823 RefPtr<Document> document; 824 825 // Create a new document before clearing the frame, because it may need to inherit an aliased security context. 826 if (!m_isDisplayingInitialEmptyDocument && m_client->shouldUsePluginDocument(m_responseMIMEType)) 827 document = PluginDocument::create(m_frame); 828 else if (!m_client->hasHTMLView()) 829 document = PlaceholderDocument::create(m_frame); 830 else 831 document = DOMImplementation::createDocument(m_responseMIMEType, m_frame, m_frame->inViewSourceMode()); 832 833 bool resetScripting = !(m_isDisplayingInitialEmptyDocument && m_frame->document()->securityOrigin()->isSecureTransitionTo(url)); 834 clear(resetScripting, resetScripting); 835 if (resetScripting) 836 m_frame->script()->updatePlatformScriptObjects(); 837 838 m_needsClear = true; 839 m_isComplete = false; 840 m_didCallImplicitClose = false; 841 m_isLoadingMainResource = true; 842 m_isDisplayingInitialEmptyDocument = m_creatingInitialEmptyDocument; 843 783 void FrameLoader::setURL(const KURL& url) 784 { 844 785 KURL ref(url); 845 786 ref.setUser(String()); … … 848 789 m_outgoingReferrer = ref.string(); 849 790 m_URL = url; 850 851 document->setURL(m_URL); 852 m_frame->setDocument(document); 853 791 } 792 793 void FrameLoader::didBeginDocument(bool dispatch) 794 { 854 795 if (m_pendingStateObject) { 855 document->statePopped(m_pendingStateObject.get());796 m_frame->document()->statePopped(m_pendingStateObject.get()); 856 797 m_pendingStateObject.clear(); 857 798 } 858 859 if (m_decoder) 860 document->setDecoder(m_decoder.get()); 861 if (forcedSecurityOrigin) 862 document->setSecurityOrigin(forcedSecurityOrigin.get()); 863 864 m_frame->domWindow()->setURL(document->url()); 865 m_frame->domWindow()->setSecurityOrigin(document->securityOrigin()); 799 800 m_needsClear = true; 801 m_isComplete = false; 802 m_didCallImplicitClose = false; 803 m_isLoadingMainResource = true; 804 m_isDisplayingInitialEmptyDocument = m_creatingInitialEmptyDocument; 866 805 867 806 if (dispatch) 868 807 dispatchDidClearWindowObjectsInAllWorlds(); 869 808 870 809 updateFirstPartyForCookies(); 871 810 872 Settings* settings = document->settings();873 document->docLoader()->setAutoLoadImages(settings && settings->loadsImagesAutomatically());811 Settings* settings = m_frame->document()->settings(); 812 m_frame->document()->docLoader()->setAutoLoadImages(settings && settings->loadsImagesAutomatically()); 874 813 875 814 if (m_documentLoader) { 876 815 String dnsPrefetchControl = m_documentLoader->response().httpHeaderField("X-DNS-Prefetch-Control"); 877 816 if (!dnsPrefetchControl.isEmpty()) 878 document->parseDNSPrefetchControlHeader(dnsPrefetchControl);817 m_frame->document()->parseDNSPrefetchControlHeader(dnsPrefetchControl); 879 818 } 880 819 881 820 history()->restoreDocumentState(); 882 883 document->implicitOpen(); 884 885 if (m_frame->view() && m_client->hasHTMLView()) 886 m_frame->view()->setContentsSize(IntSize()); 887 } 888 889 void FrameLoader::write(const char* str, int len, bool flush) 890 { 891 if (len == 0 && !flush) 892 return; 893 894 if (len == -1) 895 len = strlen(str); 896 897 Tokenizer* tokenizer = m_frame->document()->tokenizer(); 898 if (tokenizer && tokenizer->wantsRawData()) { 899 if (len > 0) 900 tokenizer->writeRawData(str, len); 901 return; 902 } 903 904 if (!m_decoder) { 905 if (Settings* settings = m_frame->settings()) { 906 m_decoder = TextResourceDecoder::create(m_responseMIMEType, 907 settings->defaultTextEncodingName(), 908 settings->usesEncodingDetector()); 909 Frame* parentFrame = m_frame->tree()->parent(); 910 // Set the hint encoding to the parent frame encoding only if 911 // the parent and the current frames share the security origin. 912 // We impose this condition because somebody can make a child frame 913 // containing a carefully crafted html/javascript in one encoding 914 // that can be mistaken for hintEncoding (or related encoding) by 915 // an auto detector. When interpreted in the latter, it could be 916 // an attack vector. 917 // FIXME: This might be too cautious for non-7bit-encodings and 918 // we may consider relaxing this later after testing. 919 if (canReferToParentFrameEncoding(m_frame, parentFrame)) 920 m_decoder->setHintEncoding(parentFrame->document()->decoder()); 921 } else 922 m_decoder = TextResourceDecoder::create(m_responseMIMEType, String()); 923 Frame* parentFrame = m_frame->tree()->parent(); 924 if (m_encoding.isEmpty()) { 925 if (canReferToParentFrameEncoding(m_frame, parentFrame)) 926 m_decoder->setEncoding(parentFrame->document()->inputEncoding(), TextResourceDecoder::EncodingFromParentFrame); 927 } else { 928 m_decoder->setEncoding(m_encoding, 929 m_encodingWasChosenByUser ? TextResourceDecoder::UserChosenEncoding : TextResourceDecoder::EncodingFromHTTPHeader); 930 } 931 m_frame->document()->setDecoder(m_decoder.get()); 932 } 933 934 String decoded = m_decoder->decode(str, len); 935 if (flush) 936 decoded += m_decoder->flush(); 937 if (decoded.isEmpty()) 938 return; 939 940 if (!m_receivedData) { 941 m_receivedData = true; 942 if (m_decoder->encoding().usesVisualOrdering()) 943 m_frame->document()->setVisuallyOrdered(); 944 m_frame->document()->recalcStyle(Node::Force); 945 } 946 947 if (tokenizer) { 948 ASSERT(!tokenizer->wantsRawData()); 949 tokenizer->write(decoded, true); 950 } 951 } 952 953 void FrameLoader::write(const String& str) 954 { 955 if (str.isNull()) 956 return; 957 958 if (!m_receivedData) { 959 m_receivedData = true; 960 m_frame->document()->setParseMode(Document::Strict); 961 } 962 963 if (Tokenizer* tokenizer = m_frame->document()->tokenizer()) 964 tokenizer->write(str, true); 965 } 966 967 void FrameLoader::end() 821 } 822 823 void FrameLoader::didEndDocument() 968 824 { 969 825 m_isLoadingMainResource = false; 970 endIfNotLoadingMainResource();971 }972 973 void FrameLoader::endIfNotLoadingMainResource()974 {975 if (m_isLoadingMainResource || !m_frame->page() || !m_frame->document())976 return;977 978 // http://bugs.webkit.org/show_bug.cgi?id=10854979 // The frame's last ref may be removed and it can be deleted by checkCompleted(),980 // so we'll add a protective refcount981 RefPtr<Frame> protector(m_frame);982 983 // make sure nothing's left in there984 write(0, 0, true);985 m_frame->document()->finishParsing();986 826 } 987 827 … … 1261 1101 } 1262 1102 1263 String FrameLoader::encoding() const1264 {1265 if (m_encodingWasChosenByUser && !m_encoding.isEmpty())1266 return m_encoding;1267 if (m_decoder && m_decoder->encoding().isValid())1268 return m_decoder->encoding().name();1269 Settings* settings = m_frame->settings();1270 return settings ? settings->defaultTextEncodingName() : String();1271 }1272 1273 1103 bool FrameLoader::requestObject(RenderEmbeddedObject* renderer, const String& url, const AtomicString& frameName, 1274 1104 const String& mimeType, const Vector<String>& paramNames, const Vector<String>& paramValues) … … 1534 1364 } 1535 1365 1536 void FrameLoader:: setEncoding(const String& name, bool userChosen)1366 void FrameLoader::willSetEncoding() 1537 1367 { 1538 1368 if (!m_workingURL.isEmpty()) 1539 1369 receivedFirstData(); 1540 m_encoding = name;1541 m_encodingWasChosenByUser = userChosen;1542 1370 } 1543 1371 … … 1547 1375 ASSERT(m_frame->document()); 1548 1376 ASSERT(m_frame->document()->parsing()); 1549 write (bytes, length);1377 writer()->addData(bytes, length); 1550 1378 } 1551 1379 … … 2659 2487 } 2660 2488 2661 m_responseMIMEType = dl->responseMIMEType();2489 writer()->setMIMEType(dl->responseMIMEType()); 2662 2490 2663 2491 // Tell the client we've committed this URL. … … 2776 2604 m_workingURL = url; 2777 2605 2778 started();2779 clear(true, true, cachedFrame.isMainFrame());2606 m_frame->loader()->started(); 2607 m_frame->loader()->clear(true, true, cachedFrame.isMainFrame()); 2780 2608 2781 2609 Document* document = cachedFrame.document(); … … 2804 2632 m_frame->domWindow()->setSecurityOrigin(document->securityOrigin()); 2805 2633 2806 m_decoder = document->decoder(); 2634 // FIXME: I would have expected us to restore the value of 2635 // DocumentWriter::m_encoding here, but we don't seem to. I wonder if 2636 // that's a bug. One way to test is to look at the fallback array of 2637 // encodings for decoding content disposition. 2638 writer()->setDecoder(document->decoder()); 2807 2639 2808 2640 updateFirstPartyForCookies(); … … 2896 2728 loader->setParsedArchiveData(mainResource->data()); 2897 2729 2898 m_responseMIMEType = mainResource->mimeType();2730 writer()->setMIMEType(mainResource->mimeType()); 2899 2731 2900 2732 closeURL(); … … 2903 2735 String userChosenEncoding = documentLoader()->overrideEncoding(); 2904 2736 bool encodingIsUserChosen = !userChosenEncoding.isNull(); 2905 setEncoding(encodingIsUserChosen ? userChosenEncoding : mainResource->textEncoding(), encodingIsUserChosen);2737 writer()->setEncoding(encodingIsUserChosen ? userChosenEncoding : mainResource->textEncoding(), encodingIsUserChosen); 2906 2738 2907 2739 ASSERT(m_frame->document()); … … 3310 3142 // Always try UTF-8. If that fails, try frame encoding (if any) and then the default. 3311 3143 // For a newly opened frame with an empty URL, encoding() should not be used, because this methods asks decoder, which uses ISO-8859-1. 3312 Settings* settings = m_frame->settings(); 3313 request.setResponseContentDispositionEncodingFallbackArray("UTF-8", m_URL.isEmpty() ? m_encoding : encoding(), settings ? settings->defaultTextEncodingName() : String()); 3144 String encoding1 = "UTF-8"; 3145 String encoding2 = writer()->depricatedFrameEncoding(); 3146 String encoding3; 3147 if (Settings* settings = m_frame->settings()) 3148 encoding3 = settings->defaultTextEncodingName(); 3149 request.setResponseContentDispositionEncodingFallbackArray(encoding1, encoding2, encoding3); 3314 3150 } 3315 3151 -
trunk/WebCore/loader/FrameLoader.h
r57445 r57468 33 33 34 34 #include "CachePolicy.h" 35 #include "DocumentWriter.h" 35 36 #include "FrameLoaderTypes.h" 36 37 #include "HistoryController.h" … … 100 101 HistoryController* history() const { return &m_history; } 101 102 ResourceLoadNotifier* notifier() const { return &m_notifer; } 103 DocumentWriter* writer() const { return &m_writer; } 102 104 103 105 // FIXME: This is not cool, people. There are too many different functions that all start loads. … … 227 229 void didExplicitOpen(); 228 230 231 // Callbacks from DocumentWriter 232 void didBeginDocument(bool dispatchWindowObjectAvailable); 233 void didEndDocument(); 234 void willSetEncoding(); 235 229 236 KURL iconURL(); 230 237 void commitIconURLToIconDatabase(const KURL&); 231 238 232 239 KURL baseURL() const; 233 234 void replaceDocument(const String&);235 236 void begin();237 void begin(const KURL&, bool dispatchWindowObjectAvailable = true, SecurityOrigin* forcedSecurityOrigin = 0);238 239 void write(const char* string, int length = -1, bool flush = false);240 void write(const String&);241 void end();242 void endIfNotLoadingMainResource();243 244 void setEncoding(const String& encoding, bool userChosen);245 String encoding() const;246 240 247 241 void tokenizerProcessedData(); … … 284 278 const KURL& url() const { return m_URL; } 285 279 286 void setResponseMIMEType(const String&);287 const String& responseMIMEType() const;280 // setURL is a low-level setter and does not trigger loading. 281 void setURL(const KURL&); 288 282 289 283 bool allowPlugins(ReasonForCallingAllowPlugins); … … 304 298 305 299 void cancelAndClear(); 300 void clear(bool clearWindowProperties = true, bool clearScriptObjects = true, bool clearFrameView = true); 306 301 307 302 void setTitle(const String&); … … 348 343 static ObjectContentType defaultObjectContentType(const KURL& url, const String& mimeType); 349 344 345 bool isDisplayingInitialEmptyDocument() const { return m_isDisplayingInitialEmptyDocument; } 346 350 347 private: 351 348 bool canCachePageContainingThisFrame(); … … 412 409 void updateHistoryAfterClientRedirect(); 413 410 414 void clear(bool clearWindowProperties = true, bool clearScriptObjects = true, bool clearFrameView = true);415 416 411 bool shouldReloadToHandleUnreachableURL(DocumentLoader*); 417 412 … … 466 461 mutable HistoryController m_history; 467 462 mutable ResourceLoadNotifier m_notifer; 463 mutable DocumentWriter m_writer; 468 464 469 465 FrameState m_state; … … 489 485 bool m_isExecutingJavaScriptFormAction; 490 486 491 String m_responseMIMEType;492 493 487 bool m_didCallImplicitClose; 494 488 bool m_wasUnloadEventEmitted; … … 508 502 509 503 bool m_needsClear; 510 bool m_receivedData;511 512 bool m_encodingWasChosenByUser;513 String m_encoding;514 RefPtr<TextResourceDecoder> m_decoder;515 504 516 505 bool m_containsPlugIns; -
trunk/WebCore/loader/MediaDocument.cpp
r54182 r57468 228 228 embedElement->setAttribute(nameAttr, "plugin"); 229 229 embedElement->setAttribute(srcAttr, url().string()); 230 embedElement->setAttribute(typeAttr, frame()->loader()-> responseMIMEType());230 embedElement->setAttribute(typeAttr, frame()->loader()->writer()->mimeType()); 231 231 232 232 ExceptionCode ec; -
trunk/WebCore/loader/PluginDocument.cpp
r56096 r57468 106 106 m_embedElement->setAttribute(nameAttr, "plugin"); 107 107 m_embedElement->setAttribute(srcAttr, m_doc->url().string()); 108 m_embedElement->setAttribute(typeAttr, m_doc->frame()->loader()-> responseMIMEType());108 m_embedElement->setAttribute(typeAttr, m_doc->frame()->loader()->writer()->mimeType()); 109 109 110 110 body->appendChild(embedElement, ec); -
trunk/WebCore/platform/network/FormDataBuilder.cpp
r56825 r57468 88 88 89 89 if (Frame* frame = document->frame()) 90 return frame->loader()-> encoding();90 return frame->loader()->writer()->encoding(); 91 91 92 92 return Latin1Encoding(); -
trunk/WebCore/svg/graphics/SVGImage.cpp
r57445 r57468 260 260 loader->policyChecker()->cancelCheck(); // cancel any policy checks 261 261 loader->commitProvisionalLoad(0); 262 loader-> setResponseMIMEType("image/svg+xml");263 loader-> begin(KURL()); // create the empty document264 loader->write (data()->data(), data()->size());265 loader-> end();262 loader->writer()->setMIMEType("image/svg+xml"); 263 loader->writer()->begin(KURL()); // create the empty document 264 loader->writer()->addData(data()->data(), data()->size()); 265 loader->writer()->end(); 266 266 frame->view()->setTransparent(true); // SVG Images are transparent. 267 267 } -
trunk/WebKit/chromium/ChangeLog
r57461 r57468 1 2010-04-11 Adam Barth <abarth@webkit.org> 2 3 Reviewed by Eric Seidel. 4 5 Factor DocumentWriter out of FrameLoader 6 https://bugs.webkit.org/show_bug.cgi?id=37175 7 8 Update these callsites because the method moved to DocumentWriter. 9 10 * src/ContextMenuClientImpl.cpp: 11 (WebKit::ContextMenuClientImpl::getCustomMenuFromDefaultItems): 12 * src/FrameLoaderClientImpl.cpp: 13 (WebKit::FrameLoaderClientImpl::finishedLoading): 14 * src/WebFrameImpl.cpp: 15 (WebKit::WebFrameImpl::encoding): 16 (WebKit::WebFrameImpl::commitDocumentData): 17 * src/WebPageSerializerImpl.cpp: 18 (WebKit::WebPageSerializerImpl::preActionBeforeSerializeOpenTag): 19 (WebKit::WebPageSerializerImpl::serialize): 20 * src/WebSearchableFormData.cpp: 21 (WebCore::GetFormEncoding): 22 * src/WebViewImpl.cpp: 23 (WebKit::WebViewImpl::pageEncoding): 24 1 25 2010-04-11 Sheriff Bot <webkit.review.bot@gmail.com> 2 26 -
trunk/WebKit/chromium/src/ContextMenuClientImpl.cpp
r56415 r57468 193 193 // If it's not a link, an image, a media element, or an image/media link, 194 194 // show a selection menu or a more generic page menu. 195 data.frameEncoding = selectedFrame->loader()-> encoding();195 data.frameEncoding = selectedFrame->loader()->writer()->encoding(); 196 196 197 197 // Send the frame and page URLs in any case. -
trunk/WebKit/chromium/src/FrameLoaderClientImpl.cpp
r57210 r57468 1067 1067 // match the behavior on the Mac. 1068 1068 if (m_hasRepresentation) 1069 dl->frameLoader()-> setEncoding("", false);1069 dl->frameLoader()->writer()->setEncoding("", false); 1070 1070 } 1071 1071 } -
trunk/WebKit/chromium/src/WebFrameImpl.cpp
r57402 r57468 523 523 WebString WebFrameImpl::encoding() const 524 524 { 525 return frame()->loader()-> encoding();525 return frame()->loader()->writer()->encoding(); 526 526 } 527 527 … … 1017 1017 encoding = documentLoader->response().textEncodingName(); 1018 1018 } 1019 m_frame->loader()-> setEncoding(encoding, userChosen);1019 m_frame->loader()->writer()->setEncoding(encoding, userChosen); 1020 1020 1021 1021 // NOTE: mac only does this if there is a document -
trunk/WebKit/chromium/src/WebPageSerializerImpl.cpp
r52268 r57468 171 171 String xmlEncoding = param->doc->xmlEncoding(); 172 172 if (xmlEncoding.isEmpty()) 173 xmlEncoding = param->doc->frame()->loader()-> encoding();173 xmlEncoding = param->doc->frame()->loader()->writer()->encoding(); 174 174 if (xmlEncoding.isEmpty()) 175 175 xmlEncoding = UTF8Encoding().name(); … … 515 515 didSerialization = true; 516 516 // Get target encoding for current document. 517 String encoding = currentFrame->frame()->loader()-> encoding();517 String encoding = currentFrame->frame()->loader()->writer()->encoding(); 518 518 // Create the text encoding object with target encoding. 519 519 TextEncoding textEncoding(encoding); -
trunk/WebKit/chromium/src/WebSearchableFormData.cpp
r50723 r57468 63 63 } 64 64 const Frame* frame = form->document()->frame(); 65 *encoding = frame ? TextEncoding(frame->loader()-> encoding()) : Latin1Encoding();65 *encoding = frame ? TextEncoding(frame->loader()->writer()->encoding()) : Latin1Encoding(); 66 66 } 67 67 -
trunk/WebKit/chromium/src/WebViewImpl.cpp
r57176 r57468 1283 1283 return WebString(); 1284 1284 1285 return m_page->mainFrame()->loader()-> encoding();1285 return m_page->mainFrame()->loader()->writer()->encoding(); 1286 1286 } 1287 1287 -
trunk/WebKit/gtk/ChangeLog
r57210 r57468 1 2010-04-11 Adam Barth <abarth@webkit.org> 2 3 Reviewed by Eric Seidel. 4 5 Factor DocumentWriter out of FrameLoader 6 https://bugs.webkit.org/show_bug.cgi?id=37175 7 8 Update these callsites because the method moved to DocumentWriter. 9 10 * WebCoreSupport/FrameLoaderClientGtk.cpp: 11 (WebKit::FrameLoaderClient::committedLoad): 12 (WebKit::FrameLoaderClient::finishedLoading): 13 * webkit/webkitwebview.cpp: 14 (webkit_web_view_get_encoding): 15 1 16 2010-04-07 Andrey Kosyakov <caseq@chromium.org> 2 17 -
trunk/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp
r57210 r57468 150 150 151 151 FrameLoader* frameLoader = loader->frameLoader(); 152 frameLoader-> setEncoding(encoding, userChosen);152 frameLoader->writer()->setEncoding(encoding, userChosen); 153 153 if (data) 154 154 frameLoader->addData(data, length); … … 869 869 if (!m_pluginView) { 870 870 FrameLoader* loader = documentLoader->frameLoader(); 871 loader-> setEncoding(m_response.textEncodingName(), false);871 loader->writer()->setEncoding(m_response.textEncodingName(), false); 872 872 } else { 873 873 m_pluginView->didFinishLoading(); -
trunk/WebKit/gtk/webkit/webkitwebview.cpp
r56916 r57468 4012 4012 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), NULL); 4013 4013 4014 String encoding = core(webView)->mainFrame()->loader()-> encoding();4014 String encoding = core(webView)->mainFrame()->loader()->writer()->encoding(); 4015 4015 4016 4016 if (!encoding.isEmpty()) { -
trunk/WebKit/haiku/ChangeLog
r57210 r57468 1 2010-04-11 Adam Barth <abarth@webkit.org> 2 3 Reviewed by Eric Seidel. 4 5 Factor DocumentWriter out of FrameLoader 6 https://bugs.webkit.org/show_bug.cgi?id=37175 7 8 Update these callsites because the method moved to DocumentWriter. 9 10 * WebCoreSupport/FrameLoaderClientHaiku.cpp: 11 (WebCore::FrameLoaderClientHaiku::committedLoad): 12 1 13 2010-04-07 Andrey Kosyakov <caseq@chromium.org> 2 14 -
trunk/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.cpp
r57210 r57468 511 511 512 512 FrameLoader* frameLoader = loader->frameLoader(); 513 frameLoader-> setEncoding(m_response.textEncodingName(), false);513 frameLoader->writer()->setEncoding(m_response.textEncodingName(), false); 514 514 frameLoader->addData(data, length); 515 515 } -
trunk/WebKit/mac/ChangeLog
r57441 r57468 1 2010-04-11 Adam Barth <abarth@webkit.org> 2 3 Reviewed by Eric Seidel. 4 5 Factor DocumentWriter out of FrameLoader 6 https://bugs.webkit.org/show_bug.cgi?id=37175 7 8 Update these callsites because the method moved to DocumentWriter. 9 10 * WebView/WebFrame.mm: 11 (-[WebFrame _canProvideDocumentSource]): 12 (-[WebFrame _receivedData:textEncodingName:]): 13 1 14 2010-04-10 Mark Rowe <mrowe@apple.com> 2 15 -
trunk/WebKit/mac/WebView/WebFrame.mm
r56934 r57468 962 962 { 963 963 Frame* frame = _private->coreFrame; 964 String mimeType = frame->loader()-> responseMIMEType();964 String mimeType = frame->loader()->writer()->mimeType(); 965 965 PluginData* pluginData = frame->page() ? frame->page()->pluginData() : 0; 966 966 … … 987 987 if (encoding.isNull()) 988 988 encoding = textEncodingName; 989 _private->coreFrame->loader()-> setEncoding(encoding, userChosen);989 _private->coreFrame->loader()->writer()->setEncoding(encoding, userChosen); 990 990 [self _addData:data]; 991 991 } -
trunk/WebKit/qt/ChangeLog
r57449 r57468 1 2010-04-11 Adam Barth <abarth@webkit.org> 2 3 Reviewed by Eric Seidel. 4 5 Factor DocumentWriter out of FrameLoader 6 https://bugs.webkit.org/show_bug.cgi?id=37175 7 8 Update these callsites because the method moved to DocumentWriter. 9 10 * WebCoreSupport/FrameLoaderClientQt.cpp: 11 (WebCore::FrameLoaderClientQt::finishedLoading): 12 (WebCore::FrameLoaderClientQt::setMainDocumentError): 13 (WebCore::FrameLoaderClientQt::committedLoad): 14 (WebCore::FrameLoaderClientQt::dispatchDidFailLoading): 15 1 16 2010-04-11 Robert Hogan <robert@webkit.org> 2 17 -
trunk/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
r57449 r57468 537 537 if(m_firstData) { 538 538 FrameLoader *fl = loader->frameLoader(); 539 fl-> setEncoding(m_response.textEncodingName(), false);539 fl->writer()->setEncoding(m_response.textEncodingName(), false); 540 540 m_firstData = false; 541 541 } … … 728 728 if (!m_pluginView) { 729 729 if (m_firstData) { 730 loader->frameLoader()-> setEncoding(m_response.textEncodingName(), false);730 loader->frameLoader()->writer()->setEncoding(m_response.textEncodingName(), false); 731 731 m_firstData = false; 732 732 } … … 746 746 FrameLoader *fl = loader->frameLoader(); 747 747 if (m_firstData) { 748 fl-> setEncoding(m_response.textEncodingName(), false);748 fl->writer()->setEncoding(m_response.textEncodingName(), false); 749 749 m_firstData = false; 750 750 } … … 932 932 if (m_firstData) { 933 933 FrameLoader *fl = loader->frameLoader(); 934 fl-> setEncoding(m_response.textEncodingName(), false);934 fl->writer()->setEncoding(m_response.textEncodingName(), false); 935 935 m_firstData = false; 936 936 } -
trunk/WebKit/win/ChangeLog
r57336 r57468 1 2010-04-11 Adam Barth <abarth@webkit.org> 2 3 Reviewed by Eric Seidel. 4 5 Factor DocumentWriter out of FrameLoader 6 https://bugs.webkit.org/show_bug.cgi?id=37175 7 8 Update these callsites because the method moved to DocumentWriter. 9 10 * WebCoreSupport/WebFrameLoaderClient.cpp: 11 (WebFrameLoaderClient::receivedData): 12 1 13 2010-04-09 Adam Roben <aroben@apple.com> 2 14 -
trunk/WebKit/win/WebCoreSupport/WebFrameLoaderClient.cpp
r57210 r57468 510 510 if (encoding.isNull()) 511 511 encoding = textEncoding; 512 coreFrame->loader()-> setEncoding(encoding, userChosen);512 coreFrame->loader()->writer()->setEncoding(encoding, userChosen); 513 513 514 514 coreFrame->loader()->addData(data, length); -
trunk/WebKit/wx/ChangeLog
r57210 r57468 1 2010-04-11 Adam Barth <abarth@webkit.org> 2 3 Reviewed by Eric Seidel. 4 5 Factor DocumentWriter out of FrameLoader 6 https://bugs.webkit.org/show_bug.cgi?id=37175 7 8 Update these callsites because the method moved to DocumentWriter. 9 10 * WebKitSupport/FrameLoaderClientWx.cpp: 11 (WebCore::FrameLoaderClientWx::committedLoad): 12 1 13 2010-04-07 Andrey Kosyakov <caseq@chromium.org> 2 14 -
trunk/WebKit/wx/WebKitSupport/FrameLoaderClientWx.cpp
r57210 r57468 605 605 if (!m_pluginView) { 606 606 FrameLoader* fl = loader->frameLoader(); 607 fl-> setEncoding(m_response.textEncodingName(), false);607 fl->writer()->setEncoding(m_response.textEncodingName(), false); 608 608 fl->addData(data, length); 609 609 }
Note: See TracChangeset
for help on using the changeset viewer.