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

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

Issue 22909053: Store the Document's encoding on the Document (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 4 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 | Annotate | Revision Log
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 518 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 // generally keep at least one reference to an Element which would in turn 529 // generally keep at least one reference to an Element which would in turn
530 // has a reference to the Document. If you hit this ASSERT, then that 530 // has a reference to the Document. If you hit this ASSERT, then that
531 // assumption is wrong. DocumentParser::detach() should ensure that even 531 // assumption is wrong. DocumentParser::detach() should ensure that even
532 // if the DocumentParser outlives the Document it won't cause badness. 532 // if the DocumentParser outlives the Document it won't cause badness.
533 ASSERT(!m_parser || m_parser->refCount() == 1); 533 ASSERT(!m_parser || m_parser->refCount() == 1);
534 detachParser(); 534 detachParser();
535 535
536 if (this == topDocument()) 536 if (this == topDocument())
537 clearAXObjectCache(); 537 clearAXObjectCache();
538 538
539 m_decoder = 0; 539 setDecoder(PassRefPtr<TextResourceDecoder>());
540 540
541 if (m_styleSheetList) 541 if (m_styleSheetList)
542 m_styleSheetList->detachFromDocument(); 542 m_styleSheetList->detachFromDocument();
543 543
544 if (m_import) { 544 if (m_import) {
545 m_import->wasDetachedFromDocument(); 545 m_import->wasDetachedFromDocument();
546 m_import = 0; 546 m_import = 0;
547 } 547 }
548 548
549 m_styleSheetCollection.clear(); 549 m_styleSheetCollection.clear();
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 case Complete: 1097 case Complete:
1098 if (!m_documentTiming.domComplete) 1098 if (!m_documentTiming.domComplete)
1099 m_documentTiming.domComplete = monotonicallyIncreasingTime(); 1099 m_documentTiming.domComplete = monotonicallyIncreasingTime();
1100 break; 1100 break;
1101 } 1101 }
1102 1102
1103 m_readyState = readyState; 1103 m_readyState = readyState;
1104 dispatchEvent(Event::create(eventNames().readystatechangeEvent, false, false )); 1104 dispatchEvent(Event::create(eventNames().readystatechangeEvent, false, false ));
1105 } 1105 }
1106 1106
1107 String Document::encoding() const 1107 String Document::encodingName() const
1108 { 1108 {
1109 // TextEncoding::domName() returns a char*, no need to allocate a new 1109 // TextEncoding::domName() returns a char*, no need to allocate a new
1110 // String for it each time. 1110 // String for it each time.
1111 // FIXME: We should fix TextEncoding to speak AtomicString anyway. 1111 // FIXME: We should fix TextEncoding to speak AtomicString anyway.
1112 if (TextResourceDecoder* d = decoder()) 1112 return AtomicString(m_encoding.domName());
abarth-chromium 2013/08/23 21:58:01 This used to be able to return the null string. D
1113 return AtomicString(d->encoding().domName());
1114 return String();
1115 } 1113 }
1116 1114
1117 String Document::defaultCharset() const 1115 String Document::defaultCharset() const
1118 { 1116 {
1119 if (Settings* settings = this->settings()) 1117 if (Settings* settings = this->settings())
1120 return settings->defaultTextEncodingName(); 1118 return settings->defaultTextEncodingName();
1121 return String(); 1119 return String();
1122 } 1120 }
1123 1121
1124 void Document::setCharset(const String& charset) 1122 void Document::setCharset(const String& charset)
1125 { 1123 {
1126 if (!decoder()) 1124 if (!decoder())
1127 return; 1125 return;
1128 decoder()->setEncoding(charset, TextResourceDecoder::UserChosenEncoding); 1126 decoder()->setEncoding(charset, TextResourceDecoder::UserChosenEncoding);
1127 m_encoding = m_decoder->encoding();
1129 } 1128 }
1130 1129
1131 void Document::setContentLanguage(const String& language) 1130 void Document::setContentLanguage(const String& language)
1132 { 1131 {
1133 if (m_contentLanguage == language) 1132 if (m_contentLanguage == language)
1134 return; 1133 return;
1135 m_contentLanguage = language; 1134 m_contentLanguage = language;
1136 1135
1137 // Document's style depends on the content language. 1136 // Document's style depends on the content language.
1138 setNeedsStyleRecalc(); 1137 setNeedsStyleRecalc();
(...skipping 2793 matching lines...) Expand 10 before | Expand all | Expand 10 after
3932 } 3931 }
3933 3932
3934 if (qualifiedName.is8Bit()) 3933 if (qualifiedName.is8Bit())
3935 return parseQualifiedNameInternal(qualifiedName, qualifiedName.character s8(), length, prefix, localName, es); 3934 return parseQualifiedNameInternal(qualifiedName, qualifiedName.character s8(), length, prefix, localName, es);
3936 return parseQualifiedNameInternal(qualifiedName, qualifiedName.characters16( ), length, prefix, localName, es); 3935 return parseQualifiedNameInternal(qualifiedName, qualifiedName.characters16( ), length, prefix, localName, es);
3937 } 3936 }
3938 3937
3939 void Document::setDecoder(PassRefPtr<TextResourceDecoder> decoder) 3938 void Document::setDecoder(PassRefPtr<TextResourceDecoder> decoder)
3940 { 3939 {
3941 m_decoder = decoder; 3940 m_decoder = decoder;
3941 setEncoding(m_decoder ? m_decoder->encoding() : WTF::TextEncoding());
3942 }
3943
3944 void Document::setEncoding(const WTF::TextEncoding& encoding)
3945 {
3946 m_encoding = encoding;
3942 } 3947 }
3943 3948
3944 KURL Document::completeURL(const String& url, const KURL& baseURLOverride) const 3949 KURL Document::completeURL(const String& url, const KURL& baseURLOverride) const
3945 { 3950 {
3946 // Always return a null URL when passed a null string. 3951 // Always return a null URL when passed a null string.
3947 // FIXME: Should we change the KURL constructor to have this behavior? 3952 // FIXME: Should we change the KURL constructor to have this behavior?
3948 // See also [CSS]StyleSheet::completeURL(const String&) 3953 // See also [CSS]StyleSheet::completeURL(const String&)
3949 if (url.isNull()) 3954 if (url.isNull())
3950 return KURL(); 3955 return KURL();
3951 const KURL& baseURL = ((baseURLOverride.isEmpty() || baseURLOverride == blan kURL()) && parentDocument()) ? parentDocument()->baseURL() : baseURLOverride; 3956 const KURL& baseURL = ((baseURLOverride.isEmpty() || baseURLOverride == blan kURL()) && parentDocument()) ? parentDocument()->baseURL() : baseURLOverride;
(...skipping 1290 matching lines...) Expand 10 before | Expand all | Expand 10 after
5242 { 5247 {
5243 return DocumentLifecycleNotifier::create(this); 5248 return DocumentLifecycleNotifier::create(this);
5244 } 5249 }
5245 5250
5246 DocumentLifecycleNotifier* Document::lifecycleNotifier() 5251 DocumentLifecycleNotifier* Document::lifecycleNotifier()
5247 { 5252 {
5248 return static_cast<DocumentLifecycleNotifier*>(ScriptExecutionContext::lifec ycleNotifier()); 5253 return static_cast<DocumentLifecycleNotifier*>(ScriptExecutionContext::lifec ycleNotifier());
5249 } 5254 }
5250 5255
5251 } // namespace WebCore 5256 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698