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