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

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 SecurityContext::isolatedCopy instead and domain change test Created 7 years, 2 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
« no previous file with comments | « Source/core/dom/Document.h ('k') | Source/core/html/HTMLDocument.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 3085 matching lines...) Expand 10 before | Expand all | Expand 10 after
3096 break; 3096 break;
3097 } 3097 }
3098 } 3098 }
3099 3099
3100 if (numElements > 1 || numDoctypes > 1) 3100 if (numElements > 1 || numDoctypes > 1)
3101 return false; 3101 return false;
3102 3102
3103 return true; 3103 return true;
3104 } 3104 }
3105 3105
3106 PassRefPtr<Node> Document::cloneNode(bool /*deep*/) 3106 PassRefPtr<Node> Document::cloneNode(bool deep)
3107 { 3107 {
3108 // Spec says cloning Document nodes is "implementation dependent" 3108 RefPtr<Document> clone = cloneDocumentWithoutChildren();
3109 // so we do not support it... 3109 clone->cloneDataFromDocument(*this);
3110 return 0; 3110 if (deep)
3111 cloneChildNodes(clone.get());
3112 return clone.release();
3113 }
3114
3115 PassRefPtr<Document> Document::cloneDocumentWithoutChildren()
3116 {
3117 DocumentInit init(url());
3118 if (isXHTMLDocument())
3119 return createXHTML(init.withRegistrationContext(registrationContext()));
3120 return create(init);
3121 }
3122
3123 void Document::cloneDataFromDocument(const Document& other)
3124 {
3125 setCompatibilityMode(other.compatibilityMode());
3126 setEncoding(other.encoding());
3127 setContextFeatures(other.contextFeatures());
3128 setSecurityOrigin(other.securityOrigin()->isolatedCopy());
3111 } 3129 }
3112 3130
3113 StyleSheetList* Document::styleSheets() 3131 StyleSheetList* Document::styleSheets()
3114 { 3132 {
3115 if (!m_styleSheetList) 3133 if (!m_styleSheetList)
3116 m_styleSheetList = StyleSheetList::create(this); 3134 m_styleSheetList = StyleSheetList::create(this);
3117 return m_styleSheetList.get(); 3135 return m_styleSheetList.get();
3118 } 3136 }
3119 3137
3120 String Document::preferredStylesheetSet() const 3138 String Document::preferredStylesheetSet() const
(...skipping 2169 matching lines...) Expand 10 before | Expand all | Expand 10 after
5290 { 5308 {
5291 return DocumentLifecycleNotifier::create(this); 5309 return DocumentLifecycleNotifier::create(this);
5292 } 5310 }
5293 5311
5294 DocumentLifecycleNotifier* Document::lifecycleNotifier() 5312 DocumentLifecycleNotifier* Document::lifecycleNotifier()
5295 { 5313 {
5296 return static_cast<DocumentLifecycleNotifier*>(ExecutionContext::lifecycleNo tifier()); 5314 return static_cast<DocumentLifecycleNotifier*>(ExecutionContext::lifecycleNo tifier());
5297 } 5315 }
5298 5316
5299 } // namespace WebCore 5317 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/Document.h ('k') | Source/core/html/HTMLDocument.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698