Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Side by Side Diff: Source/core/dom/Document.cpp

Issue 129123002: Revert of "Revert of Moved text decoding to the parser thread" (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/dom/Document.h ('k') | Source/core/dom/DocumentEncodingData.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved.
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved.
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 #include "core/editing/SpellChecker.h" 102 #include "core/editing/SpellChecker.h"
103 #include "core/events/BeforeUnloadEvent.h" 103 #include "core/events/BeforeUnloadEvent.h"
104 #include "core/events/Event.h" 104 #include "core/events/Event.h"
105 #include "core/events/EventFactory.h" 105 #include "core/events/EventFactory.h"
106 #include "core/events/EventListener.h" 106 #include "core/events/EventListener.h"
107 #include "core/events/HashChangeEvent.h" 107 #include "core/events/HashChangeEvent.h"
108 #include "core/events/PageTransitionEvent.h" 108 #include "core/events/PageTransitionEvent.h"
109 #include "core/events/ScopedEventQueue.h" 109 #include "core/events/ScopedEventQueue.h"
110 #include "core/events/ThreadLocalEventNames.h" 110 #include "core/events/ThreadLocalEventNames.h"
111 #include "core/fetch/ResourceFetcher.h" 111 #include "core/fetch/ResourceFetcher.h"
112 #include "core/fetch/TextResourceDecoder.h"
113 #include "core/frame/ContentSecurityPolicy.h" 112 #include "core/frame/ContentSecurityPolicy.h"
114 #include "core/frame/DOMSecurityPolicy.h" 113 #include "core/frame/DOMSecurityPolicy.h"
115 #include "core/frame/DOMWindow.h" 114 #include "core/frame/DOMWindow.h"
116 #include "core/frame/Frame.h" 115 #include "core/frame/Frame.h"
117 #include "core/frame/FrameHost.h" 116 #include "core/frame/FrameHost.h"
118 #include "core/frame/FrameView.h" 117 #include "core/frame/FrameView.h"
119 #include "core/frame/History.h" 118 #include "core/frame/History.h"
120 #include "core/frame/PageConsole.h" 119 #include "core/frame/PageConsole.h"
121 #include "core/frame/Settings.h" 120 #include "core/frame/Settings.h"
122 #include "core/frame/animation/AnimationController.h" 121 #include "core/frame/animation/AnimationController.h"
(...skipping 11 matching lines...) Expand all
134 #include "core/html/HTMLLinkElement.h" 133 #include "core/html/HTMLLinkElement.h"
135 #include "core/html/HTMLNameCollection.h" 134 #include "core/html/HTMLNameCollection.h"
136 #include "core/html/HTMLScriptElement.h" 135 #include "core/html/HTMLScriptElement.h"
137 #include "core/html/HTMLStyleElement.h" 136 #include "core/html/HTMLStyleElement.h"
138 #include "core/html/HTMLTitleElement.h" 137 #include "core/html/HTMLTitleElement.h"
139 #include "core/html/PluginDocument.h" 138 #include "core/html/PluginDocument.h"
140 #include "core/html/forms/FormController.h" 139 #include "core/html/forms/FormController.h"
141 #include "core/html/parser/HTMLDocumentParser.h" 140 #include "core/html/parser/HTMLDocumentParser.h"
142 #include "core/html/parser/HTMLParserIdioms.h" 141 #include "core/html/parser/HTMLParserIdioms.h"
143 #include "core/html/parser/NestingLevelIncrementer.h" 142 #include "core/html/parser/NestingLevelIncrementer.h"
143 #include "core/html/parser/TextResourceDecoder.h"
144 #include "core/inspector/InspectorCounters.h" 144 #include "core/inspector/InspectorCounters.h"
145 #include "core/inspector/InspectorInstrumentation.h" 145 #include "core/inspector/InspectorInstrumentation.h"
146 #include "core/inspector/ScriptCallStack.h" 146 #include "core/inspector/ScriptCallStack.h"
147 #include "core/loader/CookieJar.h" 147 #include "core/loader/CookieJar.h"
148 #include "core/loader/DocumentLoader.h" 148 #include "core/loader/DocumentLoader.h"
149 #include "core/loader/FrameLoader.h" 149 #include "core/loader/FrameLoader.h"
150 #include "core/loader/FrameLoaderClient.h" 150 #include "core/loader/FrameLoaderClient.h"
151 #include "core/loader/ImageLoader.h" 151 #include "core/loader/ImageLoader.h"
152 #include "core/loader/appcache/ApplicationCacheHost.h" 152 #include "core/loader/appcache/ApplicationCacheHost.h"
153 #include "core/page/Chrome.h" 153 #include "core/page/Chrome.h"
(...skipping 950 matching lines...) Expand 10 before | Expand all | Expand 10 after
1104 1104
1105 void Document::setCharset(const String& charset) 1105 void Document::setCharset(const String& charset)
1106 { 1106 {
1107 if (DocumentLoader* documentLoader = loader()) 1107 if (DocumentLoader* documentLoader = loader())
1108 documentLoader->setUserChosenEncoding(charset); 1108 documentLoader->setUserChosenEncoding(charset);
1109 WTF::TextEncoding encoding(charset); 1109 WTF::TextEncoding encoding(charset);
1110 // In case the encoding didn't exist, we keep the old one (helps some sites specifying invalid encodings). 1110 // In case the encoding didn't exist, we keep the old one (helps some sites specifying invalid encodings).
1111 if (!encoding.isValid()) 1111 if (!encoding.isValid())
1112 return; 1112 return;
1113 DocumentEncodingData newEncodingData = m_encodingData; 1113 DocumentEncodingData newEncodingData = m_encodingData;
1114 newEncodingData.encoding = encoding; 1114 newEncodingData.setEncoding(encoding);
1115 setEncodingData(newEncodingData); 1115 setEncodingData(newEncodingData);
1116 } 1116 }
1117 1117
1118 void Document::setContentLanguage(const AtomicString& language) 1118 void Document::setContentLanguage(const AtomicString& language)
1119 { 1119 {
1120 if (m_contentLanguage == language) 1120 if (m_contentLanguage == language)
1121 return; 1121 return;
1122 m_contentLanguage = language; 1122 m_contentLanguage = language;
1123 1123
1124 // Document's style depends on the content language. 1124 // Document's style depends on the content language.
(...skipping 970 matching lines...) Expand 10 before | Expand all | Expand 10 after
2095 // If the document has already been detached, do not make a new axObjectCach e. 2095 // If the document has already been detached, do not make a new axObjectCach e.
2096 if (!topDocument->renderView()) 2096 if (!topDocument->renderView())
2097 return 0; 2097 return 0;
2098 2098
2099 ASSERT(topDocument == this || !m_axObjectCache); 2099 ASSERT(topDocument == this || !m_axObjectCache);
2100 if (!topDocument->m_axObjectCache) 2100 if (!topDocument->m_axObjectCache)
2101 topDocument->m_axObjectCache = adoptPtr(new AXObjectCache(topDocument)); 2101 topDocument->m_axObjectCache = adoptPtr(new AXObjectCache(topDocument));
2102 return topDocument->m_axObjectCache.get(); 2102 return topDocument->m_axObjectCache.get();
2103 } 2103 }
2104 2104
2105 void Document::setVisuallyOrdered()
2106 {
2107 m_visuallyOrdered = true;
2108 // FIXME: How is possible to not have a renderer here?
2109 if (renderView())
2110 renderView()->style()->setRTLOrdering(VisualOrder);
2111 setNeedsStyleRecalc();
2112 }
2113
2114 PassRefPtr<DocumentParser> Document::createParser() 2105 PassRefPtr<DocumentParser> Document::createParser()
2115 { 2106 {
2116 if (isHTMLDocument()) { 2107 if (isHTMLDocument()) {
2117 bool reportErrors = InspectorInstrumentation::collectingHTMLParseErrors( page()); 2108 bool reportErrors = InspectorInstrumentation::collectingHTMLParseErrors( page());
2118 return HTMLDocumentParser::create(toHTMLDocument(this), reportErrors); 2109 return HTMLDocumentParser::create(toHTMLDocument(this), reportErrors);
2119 } 2110 }
2120 // FIXME: this should probably pass the frame instead 2111 // FIXME: this should probably pass the frame instead
2121 return XMLDocumentParser::create(this, view()); 2112 return XMLDocumentParser::create(this, view());
2122 } 2113 }
2123 2114
(...skipping 1877 matching lines...) Expand 10 before | Expand all | Expand 10 after
4001 3992
4002 void Document::setEncodingData(const DocumentEncodingData& newData) 3993 void Document::setEncodingData(const DocumentEncodingData& newData)
4003 { 3994 {
4004 // It's possible for the encoding of the document to change while we're deco ding 3995 // It's possible for the encoding of the document to change while we're deco ding
4005 // data. That can only occur while we're processing the <head> portion of th e 3996 // data. That can only occur while we're processing the <head> portion of th e
4006 // document. There isn't much user-visible content in the <head>, but there is 3997 // document. There isn't much user-visible content in the <head>, but there is
4007 // the <title> element. This function detects that situation and re-decodes the 3998 // the <title> element. This function detects that situation and re-decodes the
4008 // document's title so that the user doesn't see an incorrectly decoded titl e 3999 // document's title so that the user doesn't see an incorrectly decoded titl e
4009 // in the title bar. 4000 // in the title bar.
4010 if (m_titleElement 4001 if (m_titleElement
4011 && encoding() != newData.encoding 4002 && encoding() != newData.encoding()
4012 && !m_titleElement->firstElementChild() 4003 && !m_titleElement->firstElementChild()
4013 && encoding() == Latin1Encoding() 4004 && encoding() == Latin1Encoding()
4014 && m_titleElement->textContent().containsOnlyLatin1()) { 4005 && m_titleElement->textContent().containsOnlyLatin1()) {
4015 4006
4016 CString originalBytes = m_titleElement->textContent().latin1(); 4007 CString originalBytes = m_titleElement->textContent().latin1();
4017 OwnPtr<TextCodec> codec = newTextCodec(newData.encoding); 4008 OwnPtr<TextCodec> codec = newTextCodec(newData.encoding());
4018 String correctlyDecodedTitle = codec->decode(originalBytes.data(), origi nalBytes.length(), true); 4009 String correctlyDecodedTitle = codec->decode(originalBytes.data(), origi nalBytes.length(), true);
4019 m_titleElement->setTextContent(correctlyDecodedTitle); 4010 m_titleElement->setTextContent(correctlyDecodedTitle);
4020 } 4011 }
4021 4012
4022 m_encodingData = newData; 4013 m_encodingData = newData;
4014
4015 // FIXME: Should be removed as part of https://code.google.com/p/chromium/is sues/detail?id=319643
4016 bool shouldUseVisualOrdering = m_encodingData.encoding().usesVisualOrdering( );
4017 if (shouldUseVisualOrdering != m_visuallyOrdered) {
4018 m_visuallyOrdered = shouldUseVisualOrdering;
4019 // FIXME: How is possible to not have a renderer here?
4020 if (renderView())
4021 renderView()->style()->setRTLOrdering(m_visuallyOrdered ? VisualOrde r : LogicalOrder);
4022 setNeedsStyleRecalc();
4023 }
4023 } 4024 }
4024 4025
4025 KURL Document::completeURLWithOverride(const String& url, const KURL& baseURLOve rride) const 4026 KURL Document::completeURLWithOverride(const String& url, const KURL& baseURLOve rride) const
4026 { 4027 {
4027 // Always return a null URL when passed a null string. 4028 // Always return a null URL when passed a null string.
4028 // FIXME: Should we change the KURL constructor to have this behavior? 4029 // FIXME: Should we change the KURL constructor to have this behavior?
4029 // See also [CSS]StyleSheet::completeURL(const String&) 4030 // See also [CSS]StyleSheet::completeURL(const String&)
4030 if (url.isNull()) 4031 if (url.isNull())
4031 return KURL(); 4032 return KURL();
4032 // This logic is deliberately spread over many statements in an attempt to t rack down http://crbug.com/312410. 4033 // This logic is deliberately spread over many statements in an attempt to t rack down http://crbug.com/312410.
(...skipping 1229 matching lines...) Expand 10 before | Expand all | Expand 10 after
5262 } 5263 }
5263 5264
5264 FastTextAutosizer* Document::fastTextAutosizer() 5265 FastTextAutosizer* Document::fastTextAutosizer()
5265 { 5266 {
5266 if (!m_fastTextAutosizer && RuntimeEnabledFeatures::fastTextAutosizingEnable d()) 5267 if (!m_fastTextAutosizer && RuntimeEnabledFeatures::fastTextAutosizingEnable d())
5267 m_fastTextAutosizer = FastTextAutosizer::create(this); 5268 m_fastTextAutosizer = FastTextAutosizer::create(this);
5268 return m_fastTextAutosizer.get(); 5269 return m_fastTextAutosizer.get();
5269 } 5270 }
5270 5271
5271 } // namespace WebCore 5272 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/Document.h ('k') | Source/core/dom/DocumentEncodingData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698