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

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

Issue 1698183003: Allow attachShadow only for elements in the safelist (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 4 years, 10 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
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/dom/shadow/v1-attachShadow-safelist.html ('k') | no next file » | 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 Peter Kelly (pmk@post.com) 4 * (C) 2001 Peter Kelly (pmk@post.com)
5 * (C) 2001 Dirk Mueller (mueller@kde.org) 5 * (C) 2001 Dirk Mueller (mueller@kde.org)
6 * (C) 2007 David Smith (catfish.man@gmail.com) 6 * (C) 2007 David Smith (catfish.man@gmail.com)
7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved. 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved.
8 * (C) 2007 Eric Seidel (eric@webkit.org) 8 * (C) 2007 Eric Seidel (eric@webkit.org)
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 1895 matching lines...) Expand 10 before | Expand all | Expand 10 after
1906 } 1906 }
1907 return createShadowRootInternal(ShadowRootType::V0, exceptionState); 1907 return createShadowRootInternal(ShadowRootType::V0, exceptionState);
1908 } 1908 }
1909 1909
1910 PassRefPtrWillBeRawPtr<ShadowRoot> Element::attachShadow(const ScriptState* scri ptState, const ShadowRootInit& shadowRootInitDict, ExceptionState& exceptionStat e) 1910 PassRefPtrWillBeRawPtr<ShadowRoot> Element::attachShadow(const ScriptState* scri ptState, const ShadowRootInit& shadowRootInitDict, ExceptionState& exceptionStat e)
1911 { 1911 {
1912 ASSERT(RuntimeEnabledFeatures::shadowDOMV1Enabled()); 1912 ASSERT(RuntimeEnabledFeatures::shadowDOMV1Enabled());
1913 1913
1914 OriginsUsingFeatures::countMainWorldOnly(scriptState, document(), OriginsUsi ngFeatures::Feature::ElementAttachShadow); 1914 OriginsUsingFeatures::countMainWorldOnly(scriptState, document(), OriginsUsi ngFeatures::Feature::ElementAttachShadow);
1915 1915
1916 const AtomicString& tagName = localName();
1917 bool tagNameIsSupported = isCustomElement()
kochi 2016/02/16 06:56:13 Is isCustomElement() guaranteed to work when attac
kochi 2016/02/16 06:56:13 Can you add a reference URL as a comment?
hayato 2016/02/16 07:11:13 I do not think we need to refer it. It is obvious
hayato 2016/02/16 07:11:13 Could you elaborate the case? I do not understand
kochi 2016/02/16 07:28:15 I thought a real custom element is an element whic
kochi 2016/02/16 07:28:15 Acknowledged.
1918 || tagName == HTMLNames::articleTag
1919 || tagName == HTMLNames::asideTag
1920 || tagName == HTMLNames::blockquoteTag
1921 || tagName == HTMLNames::bodyTag
1922 || tagName == HTMLNames::divTag
1923 || tagName == HTMLNames::footerTag
1924 || tagName == HTMLNames::h1Tag
1925 || tagName == HTMLNames::h2Tag
1926 || tagName == HTMLNames::h3Tag
1927 || tagName == HTMLNames::h4Tag
1928 || tagName == HTMLNames::h5Tag
1929 || tagName == HTMLNames::h6Tag
1930 || tagName == HTMLNames::headerTag
1931 || tagName == HTMLNames::navTag
1932 || tagName == HTMLNames::pTag
1933 || tagName == HTMLNames::sectionTag
1934 || tagName == HTMLNames::spanTag;
1935 if (!tagNameIsSupported) {
1936 exceptionState.throwDOMException(NotSupportedError, "This element does n ot support attachShadow");
1937 return nullptr;
1938 }
1939
1916 if (shadowRootInitDict.hasMode() && shadowRoot()) { 1940 if (shadowRootInitDict.hasMode() && shadowRoot()) {
1917 exceptionState.throwDOMException(InvalidStateError, "Shadow root cannot be created on a host which already hosts a shadow tree."); 1941 exceptionState.throwDOMException(InvalidStateError, "Shadow root cannot be created on a host which already hosts a shadow tree.");
1918 return nullptr; 1942 return nullptr;
1919 } 1943 }
1920 1944
1921 ShadowRootType type = ShadowRootType::V0; 1945 ShadowRootType type = ShadowRootType::V0;
1922 if (shadowRootInitDict.hasMode()) 1946 if (shadowRootInitDict.hasMode())
1923 type = shadowRootInitDict.mode() == "open" ? ShadowRootType::Open : Shad owRootType::Closed; 1947 type = shadowRootInitDict.mode() == "open" ? ShadowRootType::Open : Shad owRootType::Closed;
1924 1948
1925 if (type == ShadowRootType::Closed) 1949 if (type == ShadowRootType::Closed)
(...skipping 1689 matching lines...) Expand 10 before | Expand all | Expand 10 after
3615 { 3639 {
3616 #if ENABLE(OILPAN) 3640 #if ENABLE(OILPAN)
3617 if (hasRareData()) 3641 if (hasRareData())
3618 visitor->trace(elementRareData()); 3642 visitor->trace(elementRareData());
3619 visitor->trace(m_elementData); 3643 visitor->trace(m_elementData);
3620 #endif 3644 #endif
3621 ContainerNode::trace(visitor); 3645 ContainerNode::trace(visitor);
3622 } 3646 }
3623 3647
3624 } // namespace blink 3648 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/dom/shadow/v1-attachShadow-safelist.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698