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

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

Issue 74513003: Moved text decoding to the parser thread (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@parserthread_step25
Patch Set: DocumentEncodingData is now constructed from a decoder Created 7 years, 1 month 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
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 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after
1100 1100
1101 void Document::setCharset(const String& charset) 1101 void Document::setCharset(const String& charset)
1102 { 1102 {
1103 if (DocumentLoader* documentLoader = loader()) 1103 if (DocumentLoader* documentLoader = loader())
1104 documentLoader->setUserChosenEncoding(charset); 1104 documentLoader->setUserChosenEncoding(charset);
1105 WTF::TextEncoding encoding(charset); 1105 WTF::TextEncoding encoding(charset);
1106 // In case the encoding didn't exist, we keep the old one (helps some sites specifying invalid encodings). 1106 // In case the encoding didn't exist, we keep the old one (helps some sites specifying invalid encodings).
1107 if (!encoding.isValid()) 1107 if (!encoding.isValid())
1108 return; 1108 return;
1109 DocumentEncodingData newEncodingData = m_encodingData; 1109 DocumentEncodingData newEncodingData = m_encodingData;
1110 newEncodingData.encoding = encoding; 1110 newEncodingData.setEncoding(encoding);
1111 setEncodingData(newEncodingData); 1111 setEncodingData(newEncodingData);
1112 } 1112 }
1113 1113
1114 void Document::setContentLanguage(const String& language) 1114 void Document::setContentLanguage(const String& language)
1115 { 1115 {
1116 if (m_contentLanguage == language) 1116 if (m_contentLanguage == language)
1117 return; 1117 return;
1118 m_contentLanguage = language; 1118 m_contentLanguage = language;
1119 1119
1120 // Document's style depends on the content language. 1120 // Document's style depends on the content language.
(...skipping 2847 matching lines...) Expand 10 before | Expand all | Expand 10 after
3968 3968
3969 void Document::setEncodingData(const DocumentEncodingData& newData) 3969 void Document::setEncodingData(const DocumentEncodingData& newData)
3970 { 3970 {
3971 // It's possible for the encoding of the document to change while we're deco ding 3971 // It's possible for the encoding of the document to change while we're deco ding
3972 // data. That can only occur while we're processing the <head> portion of th e 3972 // data. That can only occur while we're processing the <head> portion of th e
3973 // document. There isn't much user-visible content in the <head>, but there is 3973 // document. There isn't much user-visible content in the <head>, but there is
3974 // the <title> element. This function detects that situation and re-decodes the 3974 // the <title> element. This function detects that situation and re-decodes the
3975 // document's title so that the user doesn't see an incorrectly decoded titl e 3975 // document's title so that the user doesn't see an incorrectly decoded titl e
3976 // in the title bar. 3976 // in the title bar.
3977 if (m_titleElement 3977 if (m_titleElement
3978 && encoding() != newData.encoding 3978 && encoding() != newData.encoding()
3979 && !m_titleElement->firstElementChild() 3979 && !m_titleElement->firstElementChild()
3980 && encoding() == Latin1Encoding() 3980 && encoding() == Latin1Encoding()
3981 && m_titleElement->textContent().containsOnlyLatin1()) { 3981 && m_titleElement->textContent().containsOnlyLatin1()) {
3982 3982
3983 CString originalBytes = m_titleElement->textContent().latin1(); 3983 CString originalBytes = m_titleElement->textContent().latin1();
3984 OwnPtr<TextCodec> codec = newTextCodec(newData.encoding); 3984 OwnPtr<TextCodec> codec = newTextCodec(newData.encoding());
3985 String correctlyDecodedTitle = codec->decode(originalBytes.data(), origi nalBytes.length(), true); 3985 String correctlyDecodedTitle = codec->decode(originalBytes.data(), origi nalBytes.length(), true);
3986 m_titleElement->setTextContent(correctlyDecodedTitle, IGNORE_EXCEPTION); 3986 m_titleElement->setTextContent(correctlyDecodedTitle, IGNORE_EXCEPTION);
3987 } 3987 }
3988 3988
3989 m_encodingData = newData; 3989 m_encodingData = newData;
3990 } 3990 }
3991 3991
3992 KURL Document::completeURL(const String& url, const KURL& baseURLOverride) const 3992 KURL Document::completeURL(const String& url, const KURL& baseURLOverride) const
3993 { 3993 {
3994 // Always return a null URL when passed a null string. 3994 // Always return a null URL when passed a null string.
(...skipping 1214 matching lines...) Expand 10 before | Expand all | Expand 10 after
5209 void Document::modifiedStyleSheet(StyleSheet* sheet, RecalcStyleTime when, Style ResolverUpdateMode updateMode) 5209 void Document::modifiedStyleSheet(StyleSheet* sheet, RecalcStyleTime when, Style ResolverUpdateMode updateMode)
5210 { 5210 {
5211 if (!isActive()) 5211 if (!isActive())
5212 return; 5212 return;
5213 5213
5214 styleEngine()->modifiedStyleSheet(sheet); 5214 styleEngine()->modifiedStyleSheet(sheet);
5215 styleResolverChanged(when, updateMode); 5215 styleResolverChanged(when, updateMode);
5216 } 5216 }
5217 5217
5218 } // namespace WebCore 5218 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698