OLD | NEW |
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 Loading... |
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 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1102 case Complete: | 1102 case Complete: |
1103 if (!m_documentTiming.domComplete) | 1103 if (!m_documentTiming.domComplete) |
1104 m_documentTiming.domComplete = monotonicallyIncreasingTime(); | 1104 m_documentTiming.domComplete = monotonicallyIncreasingTime(); |
1105 break; | 1105 break; |
1106 } | 1106 } |
1107 | 1107 |
1108 m_readyState = readyState; | 1108 m_readyState = readyState; |
1109 dispatchEvent(Event::create(eventNames().readystatechangeEvent, false, false
)); | 1109 dispatchEvent(Event::create(eventNames().readystatechangeEvent, false, false
)); |
1110 } | 1110 } |
1111 | 1111 |
1112 String Document::encoding() const | 1112 String Document::encodingName() const |
1113 { | 1113 { |
1114 // TextEncoding::domName() returns a char*, no need to allocate a new | 1114 // TextEncoding::domName() returns a char*, no need to allocate a new |
1115 // String for it each time. | 1115 // String for it each time. |
1116 // FIXME: We should fix TextEncoding to speak AtomicString anyway. | 1116 // FIXME: We should fix TextEncoding to speak AtomicString anyway. |
1117 if (TextResourceDecoder* d = decoder()) | 1117 return AtomicString(m_encoding.domName()); |
1118 return AtomicString(d->encoding().domName()); | |
1119 return String(); | |
1120 } | 1118 } |
1121 | 1119 |
1122 String Document::defaultCharset() const | 1120 String Document::defaultCharset() const |
1123 { | 1121 { |
1124 if (Settings* settings = this->settings()) | 1122 if (Settings* settings = this->settings()) |
1125 return settings->defaultTextEncodingName(); | 1123 return settings->defaultTextEncodingName(); |
1126 return String(); | 1124 return String(); |
1127 } | 1125 } |
1128 | 1126 |
1129 void Document::setCharset(const String& charset) | 1127 void Document::setCharset(const String& charset) |
1130 { | 1128 { |
1131 if (!decoder()) | 1129 if (!decoder()) |
1132 return; | 1130 return; |
1133 decoder()->setEncoding(charset, TextResourceDecoder::UserChosenEncoding); | 1131 decoder()->setEncoding(charset, TextResourceDecoder::UserChosenEncoding); |
| 1132 setEncoding(m_decoder->encoding()); |
1134 } | 1133 } |
1135 | 1134 |
1136 void Document::setContentLanguage(const String& language) | 1135 void Document::setContentLanguage(const String& language) |
1137 { | 1136 { |
1138 if (m_contentLanguage == language) | 1137 if (m_contentLanguage == language) |
1139 return; | 1138 return; |
1140 m_contentLanguage = language; | 1139 m_contentLanguage = language; |
1141 | 1140 |
1142 // Document's style depends on the content language. | 1141 // Document's style depends on the content language. |
1143 setNeedsStyleRecalc(); | 1142 setNeedsStyleRecalc(); |
(...skipping 2790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3934 } | 3933 } |
3935 | 3934 |
3936 if (qualifiedName.is8Bit()) | 3935 if (qualifiedName.is8Bit()) |
3937 return parseQualifiedNameInternal(qualifiedName, qualifiedName.character
s8(), length, prefix, localName, es); | 3936 return parseQualifiedNameInternal(qualifiedName, qualifiedName.character
s8(), length, prefix, localName, es); |
3938 return parseQualifiedNameInternal(qualifiedName, qualifiedName.characters16(
), length, prefix, localName, es); | 3937 return parseQualifiedNameInternal(qualifiedName, qualifiedName.characters16(
), length, prefix, localName, es); |
3939 } | 3938 } |
3940 | 3939 |
3941 void Document::setDecoder(PassRefPtr<TextResourceDecoder> decoder) | 3940 void Document::setDecoder(PassRefPtr<TextResourceDecoder> decoder) |
3942 { | 3941 { |
3943 m_decoder = decoder; | 3942 m_decoder = decoder; |
| 3943 setEncoding(m_decoder ? m_decoder->encoding() : WTF::TextEncoding()); |
| 3944 } |
| 3945 |
| 3946 void Document::setEncoding(const WTF::TextEncoding& encoding) |
| 3947 { |
| 3948 m_encoding = encoding; |
3944 } | 3949 } |
3945 | 3950 |
3946 KURL Document::completeURL(const String& url, const KURL& baseURLOverride) const | 3951 KURL Document::completeURL(const String& url, const KURL& baseURLOverride) const |
3947 { | 3952 { |
3948 // Always return a null URL when passed a null string. | 3953 // Always return a null URL when passed a null string. |
3949 // FIXME: Should we change the KURL constructor to have this behavior? | 3954 // FIXME: Should we change the KURL constructor to have this behavior? |
3950 // See also [CSS]StyleSheet::completeURL(const String&) | 3955 // See also [CSS]StyleSheet::completeURL(const String&) |
3951 if (url.isNull()) | 3956 if (url.isNull()) |
3952 return KURL(); | 3957 return KURL(); |
3953 const KURL& baseURL = ((baseURLOverride.isEmpty() || baseURLOverride == blan
kURL()) && parentDocument()) ? parentDocument()->baseURL() : baseURLOverride; | 3958 const KURL& baseURL = ((baseURLOverride.isEmpty() || baseURLOverride == blan
kURL()) && parentDocument()) ? parentDocument()->baseURL() : baseURLOverride; |
(...skipping 1291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5245 { | 5250 { |
5246 return DocumentLifecycleNotifier::create(this); | 5251 return DocumentLifecycleNotifier::create(this); |
5247 } | 5252 } |
5248 | 5253 |
5249 DocumentLifecycleNotifier* Document::lifecycleNotifier() | 5254 DocumentLifecycleNotifier* Document::lifecycleNotifier() |
5250 { | 5255 { |
5251 return static_cast<DocumentLifecycleNotifier*>(ScriptExecutionContext::lifec
ycleNotifier()); | 5256 return static_cast<DocumentLifecycleNotifier*>(ScriptExecutionContext::lifec
ycleNotifier()); |
5252 } | 5257 } |
5253 | 5258 |
5254 } // namespace WebCore | 5259 } // namespace WebCore |
OLD | NEW |