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

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

Issue 1408443003: Add Element.attachShadow under the ShadowDOMV1 runtime flag (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rewrite a test Created 5 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
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 1900 matching lines...) Expand 10 before | Expand all | Expand 10 after
1911 { 1911 {
1912 OriginsUsingFeatures::countMainWorldOnly(scriptState, document(), OriginsUsi ngFeatures::Feature::ElementCreateShadowRoot); 1912 OriginsUsingFeatures::countMainWorldOnly(scriptState, document(), OriginsUsi ngFeatures::Feature::ElementCreateShadowRoot);
1913 ShadowRoot* root = shadowRoot(); 1913 ShadowRoot* root = shadowRoot();
1914 if (root && (root->type() == ShadowRootType::Open || root->type() == ShadowR ootType::Closed)) { 1914 if (root && (root->type() == ShadowRootType::Open || root->type() == ShadowR ootType::Closed)) {
1915 exceptionState.throwDOMException(InvalidStateError, "Shadow root cannot be created on a host which already hosts this type of shadow tree."); 1915 exceptionState.throwDOMException(InvalidStateError, "Shadow root cannot be created on a host which already hosts this type of shadow tree.");
1916 return nullptr; 1916 return nullptr;
1917 } 1917 }
1918 return createShadowRootInternal(ShadowRootType::OpenByDefault, exceptionStat e); 1918 return createShadowRootInternal(ShadowRootType::OpenByDefault, exceptionStat e);
1919 } 1919 }
1920 1920
1921 PassRefPtrWillBeRawPtr<ShadowRoot> Element::createShadowRoot(const ScriptState* scriptState, const ShadowRootInit& shadowRootInitDict, ExceptionState& exception State) 1921 PassRefPtrWillBeRawPtr<ShadowRoot> Element::attachShadow(const ScriptState* scri ptState, const ShadowRootInit& shadowRootInitDict, ExceptionState& exceptionStat e)
1922 { 1922 {
1923 ASSERT(RuntimeEnabledFeatures::shadowDOMV1Enabled()); 1923 ASSERT(RuntimeEnabledFeatures::shadowDOMV1Enabled());
1924 UseCounter::count(document(), UseCounter::ElementCreateShadowRootWithParamet er);
1925 1924
1926 OriginsUsingFeatures::countMainWorldOnly(scriptState, document(), OriginsUsi ngFeatures::Feature::ElementCreateShadowRoot); 1925 OriginsUsingFeatures::countMainWorldOnly(scriptState, document(), OriginsUsi ngFeatures::Feature::ElementAttachShadow);
1927 1926
1928 if (shadowRootInitDict.hasMode() && shadowRoot()) { 1927 if (shadowRootInitDict.hasMode() && shadowRoot()) {
1929 exceptionState.throwDOMException(InvalidStateError, "Shadow root cannot be created on a host which already hosts a shadow tree."); 1928 exceptionState.throwDOMException(InvalidStateError, "Shadow root cannot be created on a host which already hosts a shadow tree.");
1930 return nullptr; 1929 return nullptr;
1931 } 1930 }
1932 1931
1933 ShadowRootType type = ShadowRootType::OpenByDefault; 1932 ShadowRootType type = ShadowRootType::OpenByDefault;
1934 if (shadowRootInitDict.hasMode()) 1933 if (shadowRootInitDict.hasMode())
1935 type = shadowRootInitDict.mode() == "open" ? ShadowRootType::Open : Shad owRootType::Closed; 1934 type = shadowRootInitDict.mode() == "open" ? ShadowRootType::Open : Shad owRootType::Closed;
1936 1935
1937 if (type == ShadowRootType::Closed) { 1936 if (type == ShadowRootType::Closed) {
1938 if (!RuntimeEnabledFeatures::shadowRootClosedModeEnabled()) { 1937 if (!RuntimeEnabledFeatures::shadowRootClosedModeEnabled()) {
1939 exceptionState.throwDOMException(NotSupportedError, "Closed shadow r oot is not supported yet."); 1938 exceptionState.throwDOMException(NotSupportedError, "Closed shadow r oot is not supported yet.");
1940 return nullptr; 1939 return nullptr;
1941 } 1940 }
1942 UseCounter::count(document(), UseCounter::ElementCreateShadowRootClosed) ; 1941 UseCounter::count(document(), UseCounter::ElementAttachShadowClosed);
1943 } else if (type == ShadowRootType::Open) { 1942 } else if (type == ShadowRootType::Open) {
1944 UseCounter::count(document(), UseCounter::ElementCreateShadowRootOpen); 1943 UseCounter::count(document(), UseCounter::ElementAttachShadowOpen);
1945 } 1944 }
1946 1945
1947 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = createShadowRootInternal(type, e xceptionState); 1946 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = createShadowRootInternal(type, e xceptionState);
1948 1947
1949 if (shadowRootInitDict.hasDelegatesFocus()) 1948 if (shadowRootInitDict.hasDelegatesFocus())
1950 shadowRoot->setDelegatesFocus(shadowRootInitDict.delegatesFocus()); 1949 shadowRoot->setDelegatesFocus(shadowRootInitDict.delegatesFocus());
1951 1950
1952 return shadowRoot.release(); 1951 return shadowRoot.release();
1953 } 1952 }
1954 1953
(...skipping 1609 matching lines...) Expand 10 before | Expand all | Expand 10 after
3564 { 3563 {
3565 #if ENABLE(OILPAN) 3564 #if ENABLE(OILPAN)
3566 if (hasRareData()) 3565 if (hasRareData())
3567 visitor->trace(elementRareData()); 3566 visitor->trace(elementRareData());
3568 visitor->trace(m_elementData); 3567 visitor->trace(m_elementData);
3569 #endif 3568 #endif
3570 ContainerNode::trace(visitor); 3569 ContainerNode::trace(visitor);
3571 } 3570 }
3572 3571
3573 } // namespace blink 3572 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Element.h ('k') | third_party/WebKit/Source/core/dom/Element.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698