| 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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 DCHECK(!parentTreeScope()); | 523 DCHECK(!parentTreeScope()); |
| 523 // If a top document with a cache, verify that it was comprehensively | 524 // If a top document with a cache, verify that it was comprehensively |
| 524 // cleared during detach. | 525 // cleared during detach. |
| 525 DCHECK(!m_axObjectCache); | 526 DCHECK(!m_axObjectCache); |
| 526 InstanceCounters::decrementCounter(InstanceCounters::DocumentCounter); | 527 InstanceCounters::decrementCounter(InstanceCounters::DocumentCounter); |
| 527 } | 528 } |
| 528 | 529 |
| 529 SelectorQueryCache& Document::selectorQueryCache() | 530 SelectorQueryCache& Document::selectorQueryCache() |
| 530 { | 531 { |
| 531 if (!m_selectorQueryCache) | 532 if (!m_selectorQueryCache) |
| 532 m_selectorQueryCache = adoptPtr(new SelectorQueryCache()); | 533 m_selectorQueryCache = wrapUnique(new SelectorQueryCache()); |
| 533 return *m_selectorQueryCache; | 534 return *m_selectorQueryCache; |
| 534 } | 535 } |
| 535 | 536 |
| 536 MediaQueryMatcher& Document::mediaQueryMatcher() | 537 MediaQueryMatcher& Document::mediaQueryMatcher() |
| 537 { | 538 { |
| 538 if (!m_mediaQueryMatcher) | 539 if (!m_mediaQueryMatcher) |
| 539 m_mediaQueryMatcher = MediaQueryMatcher::create(*this); | 540 m_mediaQueryMatcher = MediaQueryMatcher::create(*this); |
| 540 return *m_mediaQueryMatcher; | 541 return *m_mediaQueryMatcher; |
| 541 } | 542 } |
| 542 | 543 |
| (...skipping 2341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2884 DOMTimerCoordinator* Document::timers() | 2885 DOMTimerCoordinator* Document::timers() |
| 2885 { | 2886 { |
| 2886 return &m_timers; | 2887 return &m_timers; |
| 2887 } | 2888 } |
| 2888 | 2889 |
| 2889 EventTarget* Document::errorEventTarget() | 2890 EventTarget* Document::errorEventTarget() |
| 2890 { | 2891 { |
| 2891 return domWindow(); | 2892 return domWindow(); |
| 2892 } | 2893 } |
| 2893 | 2894 |
| 2894 void Document::logExceptionToConsole(const String& errorMessage, PassOwnPtr<Sour
ceLocation> location) | 2895 void Document::logExceptionToConsole(const String& errorMessage, std::unique_ptr
<SourceLocation> location) |
| 2895 { | 2896 { |
| 2896 ConsoleMessage* consoleMessage = ConsoleMessage::create(JSMessageSource, Err
orMessageLevel, errorMessage, std::move(location)); | 2897 ConsoleMessage* consoleMessage = ConsoleMessage::create(JSMessageSource, Err
orMessageLevel, errorMessage, std::move(location)); |
| 2897 addConsoleMessage(consoleMessage); | 2898 addConsoleMessage(consoleMessage); |
| 2898 } | 2899 } |
| 2899 | 2900 |
| 2900 void Document::setURL(const KURL& url) | 2901 void Document::setURL(const KURL& url) |
| 2901 { | 2902 { |
| 2902 const KURL& newURL = url.isEmpty() ? blankURL() : url; | 2903 const KURL& newURL = url.isEmpty() ? blankURL() : url; |
| 2903 if (newURL == m_url) | 2904 if (newURL == m_url) |
| 2904 return; | 2905 return; |
| (...skipping 1037 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3942 | 3943 |
| 3943 Document::EventFactorySet& Document::eventFactories() | 3944 Document::EventFactorySet& Document::eventFactories() |
| 3944 { | 3945 { |
| 3945 DEFINE_STATIC_LOCAL(EventFactorySet, s_eventFactory, ()); | 3946 DEFINE_STATIC_LOCAL(EventFactorySet, s_eventFactory, ()); |
| 3946 return s_eventFactory; | 3947 return s_eventFactory; |
| 3947 } | 3948 } |
| 3948 | 3949 |
| 3949 const OriginAccessEntry& Document::accessEntryFromURL() | 3950 const OriginAccessEntry& Document::accessEntryFromURL() |
| 3950 { | 3951 { |
| 3951 if (!m_accessEntryFromURL) { | 3952 if (!m_accessEntryFromURL) { |
| 3952 m_accessEntryFromURL = adoptPtr(new OriginAccessEntry(url().protocol(),
url().host(), OriginAccessEntry::AllowRegisterableDomains)); | 3953 m_accessEntryFromURL = wrapUnique(new OriginAccessEntry(url().protocol()
, url().host(), OriginAccessEntry::AllowRegisterableDomains)); |
| 3953 } | 3954 } |
| 3954 return *m_accessEntryFromURL; | 3955 return *m_accessEntryFromURL; |
| 3955 } | 3956 } |
| 3956 | 3957 |
| 3957 void Document::registerEventFactory(PassOwnPtr<EventFactoryBase> eventFactory) | 3958 void Document::registerEventFactory(std::unique_ptr<EventFactoryBase> eventFacto
ry) |
| 3958 { | 3959 { |
| 3959 DCHECK(!eventFactories().contains(eventFactory.get())); | 3960 DCHECK(!eventFactories().contains(eventFactory.get())); |
| 3960 eventFactories().add(std::move(eventFactory)); | 3961 eventFactories().add(std::move(eventFactory)); |
| 3961 } | 3962 } |
| 3962 | 3963 |
| 3963 Event* Document::createEvent(ExecutionContext* executionContext, const String& e
ventType, ExceptionState& exceptionState) | 3964 Event* Document::createEvent(ExecutionContext* executionContext, const String& e
ventType, ExceptionState& exceptionState) |
| 3964 { | 3965 { |
| 3965 Event* event = nullptr; | 3966 Event* event = nullptr; |
| 3966 for (const auto& factory : eventFactories()) { | 3967 for (const auto& factory : eventFactories()) { |
| 3967 event = factory->create(executionContext, eventType); | 3968 event = factory->create(executionContext, eventType); |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4377 // the <title> element. This function detects that situation and re-decodes
the | 4378 // the <title> element. This function detects that situation and re-decodes
the |
| 4378 // document's title so that the user doesn't see an incorrectly decoded titl
e | 4379 // document's title so that the user doesn't see an incorrectly decoded titl
e |
| 4379 // in the title bar. | 4380 // in the title bar. |
| 4380 if (m_titleElement | 4381 if (m_titleElement |
| 4381 && encoding() != newData.encoding() | 4382 && encoding() != newData.encoding() |
| 4382 && !ElementTraversal::firstWithin(*m_titleElement) | 4383 && !ElementTraversal::firstWithin(*m_titleElement) |
| 4383 && encoding() == Latin1Encoding() | 4384 && encoding() == Latin1Encoding() |
| 4384 && m_titleElement->textContent().containsOnlyLatin1()) { | 4385 && m_titleElement->textContent().containsOnlyLatin1()) { |
| 4385 | 4386 |
| 4386 CString originalBytes = m_titleElement->textContent().latin1(); | 4387 CString originalBytes = m_titleElement->textContent().latin1(); |
| 4387 OwnPtr<TextCodec> codec = newTextCodec(newData.encoding()); | 4388 std::unique_ptr<TextCodec> codec = newTextCodec(newData.encoding()); |
| 4388 String correctlyDecodedTitle = codec->decode(originalBytes.data(), origi
nalBytes.length(), DataEOF); | 4389 String correctlyDecodedTitle = codec->decode(originalBytes.data(), origi
nalBytes.length(), DataEOF); |
| 4389 m_titleElement->setTextContent(correctlyDecodedTitle); | 4390 m_titleElement->setTextContent(correctlyDecodedTitle); |
| 4390 } | 4391 } |
| 4391 | 4392 |
| 4392 DCHECK(newData.encoding().isValid()); | 4393 DCHECK(newData.encoding().isValid()); |
| 4393 m_encodingData = newData; | 4394 m_encodingData = newData; |
| 4394 | 4395 |
| 4395 // FIXME: Should be removed as part of https://code.google.com/p/chromium/is
sues/detail?id=319643 | 4396 // FIXME: Should be removed as part of https://code.google.com/p/chromium/is
sues/detail?id=319643 |
| 4396 bool shouldUseVisualOrdering = m_encodingData.encoding().usesVisualOrdering(
); | 4397 bool shouldUseVisualOrdering = m_encodingData.encoding().usesVisualOrdering(
); |
| 4397 if (shouldUseVisualOrdering != m_visuallyOrdered) { | 4398 if (shouldUseVisualOrdering != m_visuallyOrdered) { |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4578 DCHECK(isHTMLScriptElement(newCurrentScript) || isSVGScriptElement(newCurren
tScript)); | 4579 DCHECK(isHTMLScriptElement(newCurrentScript) || isSVGScriptElement(newCurren
tScript)); |
| 4579 m_currentScriptStack.append(newCurrentScript); | 4580 m_currentScriptStack.append(newCurrentScript); |
| 4580 } | 4581 } |
| 4581 | 4582 |
| 4582 void Document::popCurrentScript() | 4583 void Document::popCurrentScript() |
| 4583 { | 4584 { |
| 4584 DCHECK(!m_currentScriptStack.isEmpty()); | 4585 DCHECK(!m_currentScriptStack.isEmpty()); |
| 4585 m_currentScriptStack.removeLast(); | 4586 m_currentScriptStack.removeLast(); |
| 4586 } | 4587 } |
| 4587 | 4588 |
| 4588 void Document::setTransformSource(PassOwnPtr<TransformSource> source) | 4589 void Document::setTransformSource(std::unique_ptr<TransformSource> source) |
| 4589 { | 4590 { |
| 4590 m_transformSource = std::move(source); | 4591 m_transformSource = std::move(source); |
| 4591 } | 4592 } |
| 4592 | 4593 |
| 4593 String Document::designMode() const | 4594 String Document::designMode() const |
| 4594 { | 4595 { |
| 4595 return inDesignMode() ? "on" : "off"; | 4596 return inDesignMode() ? "on" : "off"; |
| 4596 } | 4597 } |
| 4597 | 4598 |
| 4598 void Document::setDesignMode(const String& value) | 4599 void Document::setDesignMode(const String& value) |
| (...skipping 1407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6006 } | 6007 } |
| 6007 | 6008 |
| 6008 void showLiveDocumentInstances() | 6009 void showLiveDocumentInstances() |
| 6009 { | 6010 { |
| 6010 WeakDocumentSet& set = liveDocumentSet(); | 6011 WeakDocumentSet& set = liveDocumentSet(); |
| 6011 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 6012 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
| 6012 for (Document* document : set) | 6013 for (Document* document : set) |
| 6013 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get
String().utf8().data()); | 6014 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get
String().utf8().data()); |
| 6014 } | 6015 } |
| 6015 #endif | 6016 #endif |
| OLD | NEW |