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

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

Issue 2050123002: Remove OwnPtr from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments from Kent; merge. Created 4 years, 6 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
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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
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
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 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
4379 // the <title> element. This function detects that situation and re-decodes the 4380 // the <title> element. This function detects that situation and re-decodes the
4380 // document's title so that the user doesn't see an incorrectly decoded titl e 4381 // document's title so that the user doesn't see an incorrectly decoded titl e
4381 // in the title bar. 4382 // in the title bar.
4382 if (m_titleElement 4383 if (m_titleElement
4383 && encoding() != newData.encoding() 4384 && encoding() != newData.encoding()
4384 && !ElementTraversal::firstWithin(*m_titleElement) 4385 && !ElementTraversal::firstWithin(*m_titleElement)
4385 && encoding() == Latin1Encoding() 4386 && encoding() == Latin1Encoding()
4386 && m_titleElement->textContent().containsOnlyLatin1()) { 4387 && m_titleElement->textContent().containsOnlyLatin1()) {
4387 4388
4388 CString originalBytes = m_titleElement->textContent().latin1(); 4389 CString originalBytes = m_titleElement->textContent().latin1();
4389 OwnPtr<TextCodec> codec = newTextCodec(newData.encoding()); 4390 std::unique_ptr<TextCodec> codec = newTextCodec(newData.encoding());
4390 String correctlyDecodedTitle = codec->decode(originalBytes.data(), origi nalBytes.length(), DataEOF); 4391 String correctlyDecodedTitle = codec->decode(originalBytes.data(), origi nalBytes.length(), DataEOF);
4391 m_titleElement->setTextContent(correctlyDecodedTitle); 4392 m_titleElement->setTextContent(correctlyDecodedTitle);
4392 } 4393 }
4393 4394
4394 DCHECK(newData.encoding().isValid()); 4395 DCHECK(newData.encoding().isValid());
4395 m_encodingData = newData; 4396 m_encodingData = newData;
4396 4397
4397 // FIXME: Should be removed as part of https://code.google.com/p/chromium/is sues/detail?id=319643 4398 // FIXME: Should be removed as part of https://code.google.com/p/chromium/is sues/detail?id=319643
4398 bool shouldUseVisualOrdering = m_encodingData.encoding().usesVisualOrdering( ); 4399 bool shouldUseVisualOrdering = m_encodingData.encoding().usesVisualOrdering( );
4399 if (shouldUseVisualOrdering != m_visuallyOrdered) { 4400 if (shouldUseVisualOrdering != m_visuallyOrdered) {
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
4580 DCHECK(isHTMLScriptElement(newCurrentScript) || isSVGScriptElement(newCurren tScript)); 4581 DCHECK(isHTMLScriptElement(newCurrentScript) || isSVGScriptElement(newCurren tScript));
4581 m_currentScriptStack.append(newCurrentScript); 4582 m_currentScriptStack.append(newCurrentScript);
4582 } 4583 }
4583 4584
4584 void Document::popCurrentScript() 4585 void Document::popCurrentScript()
4585 { 4586 {
4586 DCHECK(!m_currentScriptStack.isEmpty()); 4587 DCHECK(!m_currentScriptStack.isEmpty());
4587 m_currentScriptStack.removeLast(); 4588 m_currentScriptStack.removeLast();
4588 } 4589 }
4589 4590
4590 void Document::setTransformSource(PassOwnPtr<TransformSource> source) 4591 void Document::setTransformSource(std::unique_ptr<TransformSource> source)
4591 { 4592 {
4592 m_transformSource = std::move(source); 4593 m_transformSource = std::move(source);
4593 } 4594 }
4594 4595
4595 String Document::designMode() const 4596 String Document::designMode() const
4596 { 4597 {
4597 return inDesignMode() ? "on" : "off"; 4598 return inDesignMode() ? "on" : "off";
4598 } 4599 }
4599 4600
4600 void Document::setDesignMode(const String& value) 4601 void Document::setDesignMode(const String& value)
(...skipping 1407 matching lines...) Expand 10 before | Expand all | Expand 10 after
6008 } 6009 }
6009 6010
6010 void showLiveDocumentInstances() 6011 void showLiveDocumentInstances()
6011 { 6012 {
6012 WeakDocumentSet& set = liveDocumentSet(); 6013 WeakDocumentSet& set = liveDocumentSet();
6013 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 6014 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
6014 for (Document* document : set) 6015 for (Document* document : set)
6015 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get String().utf8().data()); 6016 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get String().utf8().data());
6016 } 6017 }
6017 #endif 6018 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698