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

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

Issue 23437003: Implement cloneNode for Document (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Use encoding/setEncoding instead Created 7 years, 3 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 | Annotate | Revision Log
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 3071 matching lines...) Expand 10 before | Expand all | Expand 10 after
3082 break; 3082 break;
3083 } 3083 }
3084 } 3084 }
3085 3085
3086 if (numElements > 1 || numDoctypes > 1) 3086 if (numElements > 1 || numDoctypes > 1)
3087 return false; 3087 return false;
3088 3088
3089 return true; 3089 return true;
3090 } 3090 }
3091 3091
3092 PassRefPtr<Node> Document::cloneNode(bool /*deep*/) 3092 PassRefPtr<Node> Document::cloneNode(bool deep)
3093 { 3093 {
3094 // Spec says cloning Document nodes is "implementation dependent" 3094 RefPtr<Document> clone = cloneDocumentWithoutChildren();
3095 // so we do not support it... 3095 clone->cloneDataFromDocument(*this);
3096 return 0; 3096 if (deep)
3097 cloneChildNodes(clone.get());
3098 return clone.release();
3099 }
3100
3101 PassRefPtr<Document> Document::cloneDocumentWithoutChildren()
3102 {
3103 DocumentInit init(url());
3104 if (isXHTMLDocument())
3105 return createXHTML(init.withRegistrationContext(registrationContext()));
3106 return create(init);
3107 }
3108
3109 void Document::cloneDataFromDocument(const Document& other)
3110 {
3111 setCompatibilityMode(other.compatibilityMode());
3112 setEncoding(other.encoding());
3113 setContextFeatures(other.contextFeatures());
3114 setSecurityOrigin(other.securityOrigin());
abarth-chromium 2013/08/30 06:56:42 Shouldn't this be a copy of the security origin?
3097 } 3115 }
3098 3116
3099 StyleSheetList* Document::styleSheets() 3117 StyleSheetList* Document::styleSheets()
3100 { 3118 {
3101 if (!m_styleSheetList) 3119 if (!m_styleSheetList)
3102 m_styleSheetList = StyleSheetList::create(this); 3120 m_styleSheetList = StyleSheetList::create(this);
3103 return m_styleSheetList.get(); 3121 return m_styleSheetList.get();
3104 } 3122 }
3105 3123
3106 String Document::preferredStylesheetSet() const 3124 String Document::preferredStylesheetSet() const
(...skipping 2187 matching lines...) Expand 10 before | Expand all | Expand 10 after
5294 { 5312 {
5295 return DocumentLifecycleNotifier::create(this); 5313 return DocumentLifecycleNotifier::create(this);
5296 } 5314 }
5297 5315
5298 DocumentLifecycleNotifier* Document::lifecycleNotifier() 5316 DocumentLifecycleNotifier* Document::lifecycleNotifier()
5299 { 5317 {
5300 return static_cast<DocumentLifecycleNotifier*>(ScriptExecutionContext::lifec ycleNotifier()); 5318 return static_cast<DocumentLifecycleNotifier*>(ScriptExecutionContext::lifec ycleNotifier());
5301 } 5319 }
5302 5320
5303 } // namespace WebCore 5321 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698