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

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

Issue 59463007: Have Element::ensureUserAgentShadowRoot() return a reference (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add extra assertion Created 7 years, 1 month 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 | « Source/core/dom/Element.h ('k') | Source/core/dom/shadow/ElementShadow.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 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 1672 matching lines...) Expand 10 before | Expand all | Expand 10 after
1683 if (ElementShadow* elementShadow = shadowWhereNodeCanBeDistributed(*this)) 1683 if (ElementShadow* elementShadow = shadowWhereNodeCanBeDistributed(*this))
1684 elementShadow->didAffectSelector(mask); 1684 elementShadow->didAffectSelector(mask);
1685 } 1685 }
1686 1686
1687 PassRefPtr<ShadowRoot> Element::createShadowRoot(ExceptionState& es) 1687 PassRefPtr<ShadowRoot> Element::createShadowRoot(ExceptionState& es)
1688 { 1688 {
1689 if (alwaysCreateUserAgentShadowRoot()) 1689 if (alwaysCreateUserAgentShadowRoot())
1690 ensureUserAgentShadowRoot(); 1690 ensureUserAgentShadowRoot();
1691 1691
1692 if (RuntimeEnabledFeatures::authorShadowDOMForAnyElementEnabled()) 1692 if (RuntimeEnabledFeatures::authorShadowDOMForAnyElementEnabled())
1693 return ensureShadow().addShadowRoot(*this, ShadowRoot::AuthorShadowRoot) ; 1693 return PassRefPtr<ShadowRoot>(ensureShadow().addShadowRoot(*this, Shadow Root::AuthorShadowRoot));
1694 1694
1695 // Since some elements recreates shadow root dynamically, multiple shadow 1695 // Since some elements recreates shadow root dynamically, multiple shadow
1696 // subtrees won't work well in that element. Until they are fixed, we disabl e 1696 // subtrees won't work well in that element. Until they are fixed, we disabl e
1697 // adding author shadow root for them. 1697 // adding author shadow root for them.
1698 if (!areAuthorShadowsAllowed()) { 1698 if (!areAuthorShadowsAllowed()) {
1699 es.throwUninformativeAndGenericDOMException(HierarchyRequestError); 1699 es.throwUninformativeAndGenericDOMException(HierarchyRequestError);
1700 return 0; 1700 return 0;
1701 } 1701 }
1702 return ensureShadow().addShadowRoot(*this, ShadowRoot::AuthorShadowRoot); 1702 return PassRefPtr<ShadowRoot>(ensureShadow().addShadowRoot(*this, ShadowRoot ::AuthorShadowRoot));
1703 } 1703 }
1704 1704
1705 ShadowRoot* Element::shadowRoot() const 1705 ShadowRoot* Element::shadowRoot() const
1706 { 1706 {
1707 ElementShadow* elementShadow = shadow(); 1707 ElementShadow* elementShadow = shadow();
1708 if (!elementShadow) 1708 if (!elementShadow)
1709 return 0; 1709 return 0;
1710 ShadowRoot* shadowRoot = elementShadow->youngestShadowRoot(); 1710 ShadowRoot* shadowRoot = elementShadow->youngestShadowRoot();
1711 if (shadowRoot->type() == ShadowRoot::AuthorShadowRoot) 1711 if (shadowRoot->type() == ShadowRoot::AuthorShadowRoot)
1712 return shadowRoot; 1712 return shadowRoot;
1713 return 0; 1713 return 0;
1714 } 1714 }
1715 1715
1716 void Element::didAddShadowRoot(ShadowRoot&) 1716 void Element::didAddShadowRoot(ShadowRoot&)
1717 { 1717 {
1718 } 1718 }
1719 1719
1720 ShadowRoot* Element::userAgentShadowRoot() const 1720 ShadowRoot* Element::userAgentShadowRoot() const
1721 { 1721 {
1722 if (ElementShadow* elementShadow = shadow()) { 1722 if (ElementShadow* elementShadow = shadow()) {
1723 if (ShadowRoot* shadowRoot = elementShadow->oldestShadowRoot()) { 1723 if (ShadowRoot* shadowRoot = elementShadow->oldestShadowRoot()) {
1724 ASSERT(shadowRoot->type() == ShadowRoot::UserAgentShadowRoot); 1724 ASSERT(shadowRoot->type() == ShadowRoot::UserAgentShadowRoot);
1725 return shadowRoot; 1725 return shadowRoot;
1726 } 1726 }
1727 } 1727 }
1728 1728
1729 return 0; 1729 return 0;
1730 } 1730 }
1731 1731
1732 ShadowRoot* Element::ensureUserAgentShadowRoot() 1732 ShadowRoot& Element::ensureUserAgentShadowRoot()
1733 { 1733 {
1734 if (ShadowRoot* shadowRoot = userAgentShadowRoot()) 1734 if (ShadowRoot* shadowRoot = userAgentShadowRoot())
1735 return shadowRoot; 1735 return *shadowRoot;
1736 ShadowRoot* shadowRoot = ensureShadow().addShadowRoot(*this, ShadowRoot::Use rAgentShadowRoot); 1736 ShadowRoot& shadowRoot = ensureShadow().addShadowRoot(*this, ShadowRoot::Use rAgentShadowRoot);
1737 didAddUserAgentShadowRoot(shadowRoot); 1737 didAddUserAgentShadowRoot(shadowRoot);
1738 return shadowRoot; 1738 return shadowRoot;
1739 } 1739 }
1740 1740
1741 bool Element::childTypeAllowed(NodeType type) const 1741 bool Element::childTypeAllowed(NodeType type) const
1742 { 1742 {
1743 switch (type) { 1743 switch (type) {
1744 case ELEMENT_NODE: 1744 case ELEMENT_NODE:
1745 case TEXT_NODE: 1745 case TEXT_NODE:
1746 case COMMENT_NODE: 1746 case COMMENT_NODE:
(...skipping 1750 matching lines...) Expand 10 before | Expand all | Expand 10 after
3497 // Before doing so, we need to resolve issues in HTMLSelectElement::recalcLi stItems 3497 // Before doing so, we need to resolve issues in HTMLSelectElement::recalcLi stItems
3498 // and RenderMenuList::setText. See also https://bugs.webkit.org/show_bug.cg i?id=88405 3498 // and RenderMenuList::setText. See also https://bugs.webkit.org/show_bug.cg i?id=88405
3499 if (hasTagName(optionTag) || hasTagName(optgroupTag)) 3499 if (hasTagName(optionTag) || hasTagName(optgroupTag))
3500 return false; 3500 return false;
3501 if (FullscreenElementStack::isActiveFullScreenElement(this)) 3501 if (FullscreenElementStack::isActiveFullScreenElement(this))
3502 return false; 3502 return false;
3503 return true; 3503 return true;
3504 } 3504 }
3505 3505
3506 } // namespace WebCore 3506 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/Element.h ('k') | Source/core/dom/shadow/ElementShadow.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698