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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 #include "public/platform/WebScheduler.h" | 231 #include "public/platform/WebScheduler.h" |
232 #include "wtf/CurrentTime.h" | 232 #include "wtf/CurrentTime.h" |
233 #include "wtf/DateMath.h" | 233 #include "wtf/DateMath.h" |
234 #include "wtf/Functional.h" | 234 #include "wtf/Functional.h" |
235 #include "wtf/HashFunctions.h" | 235 #include "wtf/HashFunctions.h" |
236 #include "wtf/PtrUtil.h" | 236 #include "wtf/PtrUtil.h" |
237 #include "wtf/StdLibExtras.h" | 237 #include "wtf/StdLibExtras.h" |
238 #include "wtf/TemporaryChange.h" | 238 #include "wtf/TemporaryChange.h" |
239 #include "wtf/text/StringBuffer.h" | 239 #include "wtf/text/StringBuffer.h" |
240 #include "wtf/text/TextEncodingRegistry.h" | 240 #include "wtf/text/TextEncodingRegistry.h" |
241 #include <memory> | |
242 | 241 |
243 using namespace WTF; | 242 using namespace WTF; |
244 using namespace Unicode; | 243 using namespace Unicode; |
245 | 244 |
246 #ifndef NDEBUG | 245 #ifndef NDEBUG |
247 using WeakDocumentSet = blink::PersistentHeapHashSet<blink::WeakMember<blink::Do
cument>>; | 246 using WeakDocumentSet = blink::PersistentHeapHashSet<blink::WeakMember<blink::Do
cument>>; |
248 static WeakDocumentSet& liveDocumentSet(); | 247 static WeakDocumentSet& liveDocumentSet(); |
249 #endif | 248 #endif |
250 | 249 |
251 namespace blink { | 250 namespace blink { |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 DCHECK(!parentTreeScope()); | 513 DCHECK(!parentTreeScope()); |
515 // If a top document with a cache, verify that it was comprehensively | 514 // If a top document with a cache, verify that it was comprehensively |
516 // cleared during detach. | 515 // cleared during detach. |
517 DCHECK(!m_axObjectCache); | 516 DCHECK(!m_axObjectCache); |
518 InstanceCounters::decrementCounter(InstanceCounters::DocumentCounter); | 517 InstanceCounters::decrementCounter(InstanceCounters::DocumentCounter); |
519 } | 518 } |
520 | 519 |
521 SelectorQueryCache& Document::selectorQueryCache() | 520 SelectorQueryCache& Document::selectorQueryCache() |
522 { | 521 { |
523 if (!m_selectorQueryCache) | 522 if (!m_selectorQueryCache) |
524 m_selectorQueryCache = wrapUnique(new SelectorQueryCache()); | 523 m_selectorQueryCache = adoptPtr(new SelectorQueryCache()); |
525 return *m_selectorQueryCache; | 524 return *m_selectorQueryCache; |
526 } | 525 } |
527 | 526 |
528 MediaQueryMatcher& Document::mediaQueryMatcher() | 527 MediaQueryMatcher& Document::mediaQueryMatcher() |
529 { | 528 { |
530 if (!m_mediaQueryMatcher) | 529 if (!m_mediaQueryMatcher) |
531 m_mediaQueryMatcher = MediaQueryMatcher::create(*this); | 530 m_mediaQueryMatcher = MediaQueryMatcher::create(*this); |
532 return *m_mediaQueryMatcher; | 531 return *m_mediaQueryMatcher; |
533 } | 532 } |
534 | 533 |
(...skipping 2346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2881 DOMTimerCoordinator* Document::timers() | 2880 DOMTimerCoordinator* Document::timers() |
2882 { | 2881 { |
2883 return &m_timers; | 2882 return &m_timers; |
2884 } | 2883 } |
2885 | 2884 |
2886 EventTarget* Document::errorEventTarget() | 2885 EventTarget* Document::errorEventTarget() |
2887 { | 2886 { |
2888 return domWindow(); | 2887 return domWindow(); |
2889 } | 2888 } |
2890 | 2889 |
2891 void Document::logExceptionToConsole(const String& errorMessage, std::unique_ptr
<SourceLocation> location) | 2890 void Document::logExceptionToConsole(const String& errorMessage, PassOwnPtr<Sour
ceLocation> location) |
2892 { | 2891 { |
2893 ConsoleMessage* consoleMessage = ConsoleMessage::create(JSMessageSource, Err
orMessageLevel, errorMessage, std::move(location)); | 2892 ConsoleMessage* consoleMessage = ConsoleMessage::create(JSMessageSource, Err
orMessageLevel, errorMessage, std::move(location)); |
2894 addConsoleMessage(consoleMessage); | 2893 addConsoleMessage(consoleMessage); |
2895 } | 2894 } |
2896 | 2895 |
2897 void Document::setURL(const KURL& url) | 2896 void Document::setURL(const KURL& url) |
2898 { | 2897 { |
2899 const KURL& newURL = url.isEmpty() ? blankURL() : url; | 2898 const KURL& newURL = url.isEmpty() ? blankURL() : url; |
2900 if (newURL == m_url) | 2899 if (newURL == m_url) |
2901 return; | 2900 return; |
(...skipping 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3934 | 3933 |
3935 Document::EventFactorySet& Document::eventFactories() | 3934 Document::EventFactorySet& Document::eventFactories() |
3936 { | 3935 { |
3937 DEFINE_STATIC_LOCAL(EventFactorySet, s_eventFactory, ()); | 3936 DEFINE_STATIC_LOCAL(EventFactorySet, s_eventFactory, ()); |
3938 return s_eventFactory; | 3937 return s_eventFactory; |
3939 } | 3938 } |
3940 | 3939 |
3941 const OriginAccessEntry& Document::accessEntryFromURL() | 3940 const OriginAccessEntry& Document::accessEntryFromURL() |
3942 { | 3941 { |
3943 if (!m_accessEntryFromURL) { | 3942 if (!m_accessEntryFromURL) { |
3944 m_accessEntryFromURL = wrapUnique(new OriginAccessEntry(url().protocol()
, url().host(), OriginAccessEntry::AllowRegisterableDomains)); | 3943 m_accessEntryFromURL = adoptPtr(new OriginAccessEntry(url().protocol(),
url().host(), OriginAccessEntry::AllowRegisterableDomains)); |
3945 } | 3944 } |
3946 return *m_accessEntryFromURL; | 3945 return *m_accessEntryFromURL; |
3947 } | 3946 } |
3948 | 3947 |
3949 void Document::registerEventFactory(std::unique_ptr<EventFactoryBase> eventFacto
ry) | 3948 void Document::registerEventFactory(PassOwnPtr<EventFactoryBase> eventFactory) |
3950 { | 3949 { |
3951 DCHECK(!eventFactories().contains(eventFactory.get())); | 3950 DCHECK(!eventFactories().contains(eventFactory.get())); |
3952 eventFactories().add(std::move(eventFactory)); | 3951 eventFactories().add(std::move(eventFactory)); |
3953 } | 3952 } |
3954 | 3953 |
3955 Event* Document::createEvent(ExecutionContext* executionContext, const String& e
ventType, ExceptionState& exceptionState) | 3954 Event* Document::createEvent(ExecutionContext* executionContext, const String& e
ventType, ExceptionState& exceptionState) |
3956 { | 3955 { |
3957 Event* event = nullptr; | 3956 Event* event = nullptr; |
3958 for (const auto& factory : eventFactories()) { | 3957 for (const auto& factory : eventFactories()) { |
3959 event = factory->create(executionContext, eventType); | 3958 event = factory->create(executionContext, eventType); |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4371 // the <title> element. This function detects that situation and re-decodes
the | 4370 // the <title> element. This function detects that situation and re-decodes
the |
4372 // document's title so that the user doesn't see an incorrectly decoded titl
e | 4371 // document's title so that the user doesn't see an incorrectly decoded titl
e |
4373 // in the title bar. | 4372 // in the title bar. |
4374 if (m_titleElement | 4373 if (m_titleElement |
4375 && encoding() != newData.encoding() | 4374 && encoding() != newData.encoding() |
4376 && !ElementTraversal::firstWithin(*m_titleElement) | 4375 && !ElementTraversal::firstWithin(*m_titleElement) |
4377 && encoding() == Latin1Encoding() | 4376 && encoding() == Latin1Encoding() |
4378 && m_titleElement->textContent().containsOnlyLatin1()) { | 4377 && m_titleElement->textContent().containsOnlyLatin1()) { |
4379 | 4378 |
4380 CString originalBytes = m_titleElement->textContent().latin1(); | 4379 CString originalBytes = m_titleElement->textContent().latin1(); |
4381 std::unique_ptr<TextCodec> codec = newTextCodec(newData.encoding()); | 4380 OwnPtr<TextCodec> codec = newTextCodec(newData.encoding()); |
4382 String correctlyDecodedTitle = codec->decode(originalBytes.data(), origi
nalBytes.length(), DataEOF); | 4381 String correctlyDecodedTitle = codec->decode(originalBytes.data(), origi
nalBytes.length(), DataEOF); |
4383 m_titleElement->setTextContent(correctlyDecodedTitle); | 4382 m_titleElement->setTextContent(correctlyDecodedTitle); |
4384 } | 4383 } |
4385 | 4384 |
4386 DCHECK(newData.encoding().isValid()); | 4385 DCHECK(newData.encoding().isValid()); |
4387 m_encodingData = newData; | 4386 m_encodingData = newData; |
4388 | 4387 |
4389 // FIXME: Should be removed as part of https://code.google.com/p/chromium/is
sues/detail?id=319643 | 4388 // FIXME: Should be removed as part of https://code.google.com/p/chromium/is
sues/detail?id=319643 |
4390 bool shouldUseVisualOrdering = m_encodingData.encoding().usesVisualOrdering(
); | 4389 bool shouldUseVisualOrdering = m_encodingData.encoding().usesVisualOrdering(
); |
4391 if (shouldUseVisualOrdering != m_visuallyOrdered) { | 4390 if (shouldUseVisualOrdering != m_visuallyOrdered) { |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4587 DCHECK(isHTMLScriptElement(newCurrentScript) || isSVGScriptElement(newCurren
tScript)); | 4586 DCHECK(isHTMLScriptElement(newCurrentScript) || isSVGScriptElement(newCurren
tScript)); |
4588 m_currentScriptStack.append(newCurrentScript); | 4587 m_currentScriptStack.append(newCurrentScript); |
4589 } | 4588 } |
4590 | 4589 |
4591 void Document::popCurrentScript() | 4590 void Document::popCurrentScript() |
4592 { | 4591 { |
4593 DCHECK(!m_currentScriptStack.isEmpty()); | 4592 DCHECK(!m_currentScriptStack.isEmpty()); |
4594 m_currentScriptStack.removeLast(); | 4593 m_currentScriptStack.removeLast(); |
4595 } | 4594 } |
4596 | 4595 |
4597 void Document::setTransformSource(std::unique_ptr<TransformSource> source) | 4596 void Document::setTransformSource(PassOwnPtr<TransformSource> source) |
4598 { | 4597 { |
4599 m_transformSource = std::move(source); | 4598 m_transformSource = std::move(source); |
4600 } | 4599 } |
4601 | 4600 |
4602 String Document::designMode() const | 4601 String Document::designMode() const |
4603 { | 4602 { |
4604 return inDesignMode() ? "on" : "off"; | 4603 return inDesignMode() ? "on" : "off"; |
4605 } | 4604 } |
4606 | 4605 |
4607 void Document::setDesignMode(const String& value) | 4606 void Document::setDesignMode(const String& value) |
(...skipping 1410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6018 } | 6017 } |
6019 | 6018 |
6020 void showLiveDocumentInstances() | 6019 void showLiveDocumentInstances() |
6021 { | 6020 { |
6022 WeakDocumentSet& set = liveDocumentSet(); | 6021 WeakDocumentSet& set = liveDocumentSet(); |
6023 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 6022 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
6024 for (Document* document : set) | 6023 for (Document* document : set) |
6025 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get
String().utf8().data()); | 6024 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get
String().utf8().data()); |
6026 } | 6025 } |
6027 #endif | 6026 #endif |
OLD | NEW |