Changeset 141313 in webkit
- Timestamp:
- Jan 30, 2013 2:30:54 PM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r141306 r141313 1 2013-01-30 Elliott Sprehn <esprehn@chromium.org> 2 3 Clean up interface to ShadowRoot 4 https://bugs.webkit.org/show_bug.cgi?id=108300 5 6 Reviewed by Dimitri Glazkov. 7 8 Lots of general clean up to ShadowRoot removing unused headers and forward 9 declarations, moving short inline methods into the class definition so it's 10 easier to understand what methods do what, and replacing macros with methods 11 with inline methods. 12 13 No new tests, just refactoring. 14 15 * dom/ElementShadow.cpp: 16 (WebCore::ElementShadow::addShadowRoot): 17 (WebCore::ElementShadow::removeAllShadowRoots): 18 * dom/ShadowRoot.cpp: 19 (WebCore::ShadowRoot::ShadowRoot): 20 (WebCore::ShadowRoot::setInnerHTML): Use isOrphan instead of macro. 21 (WebCore::ShadowRoot::setApplyAuthorStyles): Use isOrphan instead of macro. 22 (WebCore::ShadowRoot::setResetStyleInheritance): Use isOrphan instead of macro. 23 (WebCore::ShadowRoot::childrenChanged): Use isOrphan instead of macro. 24 * dom/ShadowRoot.h: 25 (WebCore::ShadowRoot::setHost): Removed. 26 (WebCore::ShadowRoot::host): 27 (WebCore::ShadowRoot::owner): 28 (ShadowRoot): 29 (WebCore::ShadowRoot::isOrphan): Replacement of GuardOrphanShadowRoot macro. 30 1 31 2013-01-30 Ryosuke Niwa <rniwa@webkit.org> 2 32 -
trunk/Source/WebCore/dom/ElementShadow.cpp
r141292 r141313 37 37 RefPtr<ShadowRoot> shadowRoot = ShadowRoot::create(shadowHost->document(), type); 38 38 39 shadowRoot->setHost(shadowHost); 39 shadowRoot->setParentOrHostNode(shadowHost); 40 shadowRoot->setParentTreeScope(shadowHost->treeScope()); 40 41 m_shadowRoots.push(shadowRoot.get()); 41 42 m_distributor.didShadowBoundaryChange(shadowHost); … … 69 70 70 71 m_shadowRoots.removeHead(); 71 oldRoot->set Host(0);72 oldRoot->setParentOrHostNode(0); 72 73 oldRoot->setParentTreeScope(shadowHost->document()); 73 74 oldRoot->setPrev(0); -
trunk/Source/WebCore/dom/ShadowRoot.cpp
r141218 r141313 29 29 30 30 #include "ContentDistributor.h" 31 #include "DOMSelection.h"32 #include "DOMWindow.h"33 #include "Document.h"34 #include "DocumentFragment.h"35 #include "Element.h"36 31 #include "ElementShadow.h" 37 #include "HTMLContentElement.h"38 #include "HTMLInputElement.h"39 #include "HTMLNames.h"40 #include "HTMLTextAreaElement.h"41 32 #include "HistogramSupport.h" 42 33 #include "InsertionPoint.h" 43 #include "NodeRareData.h"44 34 #include "RuntimeEnabledFeatures.h" 45 #include "SVGNames.h"46 35 #include "StyleResolver.h" 47 36 #include "Text.h" 48 37 #include "markup.h" 49 50 // FIXME: This shouldn't happen. https://bugs.webkit.org/show_bug.cgi?id=8883451 #define GuardOrphanShadowRoot(rejectStatement) \52 if (!this->host()) { \53 rejectStatement; \54 return; \55 }56 38 57 39 namespace WebCore { … … 67 49 ShadowRootUsageOriginWeb = 0, 68 50 ShadowRootUsageOriginNotWeb, 69 ShadowRootUsageOrigin Types51 ShadowRootUsageOriginMax 70 52 }; 71 72 static inline ShadowRootUsageOriginType determineUsageType(Document* document)73 {74 // Enables only on CHROMIUM since this cost won't worth paying for platforms which don't collect this metrics.75 #if PLATFORM(CHROMIUM)76 return document->url().string().startsWith("http") ? ShadowRootUsageOriginWeb : ShadowRootUsageOriginNotWeb;77 #else78 UNUSED_PARAM(document);79 return ShadowRootUsageOriginWeb;80 #endif81 }82 53 83 54 ShadowRoot::ShadowRoot(Document* document, ShadowRootType type) … … 95 66 setTreeScope(this); 96 67 97 if (type == ShadowRoot::AuthorShadowRoot) 98 HistogramSupport::histogramEnumeration("WebCore.ShadowRoot.constructor", determineUsageType(document), ShadowRootUsageOriginTypes); 68 #if PLATFORM(CHROMIUM) 69 if (type == ShadowRoot::AuthorShadowRoot) { 70 ShadowRootUsageOriginType usageType = document->url().protocolIsInHTTPFamily() ? ShadowRootUsageOriginWeb : ShadowRootUsageOriginNotWeb; 71 HistogramSupport::histogramEnumeration("WebCore.ShadowRoot.constructor", usageType, ShadowRootUsageOriginMax); 72 } 73 #endif 99 74 } 100 75 … … 115 90 } 116 91 117 PassRefPtr<Node> ShadowRoot::cloneNode(bool)118 {119 // ShadowRoot should not be arbitrarily cloned.120 return 0;121 }122 123 92 PassRefPtr<Node> ShadowRoot::cloneNode(bool, ExceptionCode& ec) 124 93 { … … 134 103 void ShadowRoot::setInnerHTML(const String& markup, ExceptionCode& ec) 135 104 { 136 GuardOrphanShadowRoot(ec = INVALID_ACCESS_ERR); 105 if (isOrphan()) { 106 ec = INVALID_ACCESS_ERR; 107 return; 108 } 137 109 138 110 if (RefPtr<DocumentFragment> fragment = createFragmentForInnerOuterHTML(markup, host(), AllowScriptingContent, ec)) … … 175 147 } 176 148 177 ElementShadow* ShadowRoot::owner() const178 {179 if (host())180 return host()->shadow();181 return 0;182 }183 184 bool ShadowRoot::applyAuthorStyles() const185 {186 return m_applyAuthorStyles;187 }188 189 149 void ShadowRoot::setApplyAuthorStyles(bool value) 190 150 { 191 GuardOrphanShadowRoot({ }); 151 if (isOrphan()) 152 return; 192 153 193 154 if (m_applyAuthorStyles != value) { … … 197 158 } 198 159 199 bool ShadowRoot::resetStyleInheritance() const200 {201 return m_resetStyleInheritance;202 }203 204 160 void ShadowRoot::setResetStyleInheritance(bool value) 205 161 { 206 GuardOrphanShadowRoot({ }); 162 if (isOrphan()) 163 return; 207 164 208 165 if (value != m_resetStyleInheritance) { … … 259 216 void ShadowRoot::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta) 260 217 { 261 GuardOrphanShadowRoot({ }); 218 if (isOrphan()) 219 return; 262 220 263 221 ContainerNode::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta); -
trunk/Source/WebCore/dom/ShadowRoot.h
r141218 r141313 38 38 namespace WebCore { 39 39 40 class Document;41 class DOMSelection;42 40 class ElementShadow; 43 class InsertionPoint;44 41 class ScopeContentDistribution; 45 42 … … 63 60 void recalcStyle(StyleChange); 64 61 65 virtual bool applyAuthorStyles() const OVERRIDE ;62 virtual bool applyAuthorStyles() const OVERRIDE { return m_applyAuthorStyles; } 66 63 void setApplyAuthorStyles(bool); 67 virtual bool resetStyleInheritance() const OVERRIDE ;64 virtual bool resetStyleInheritance() const OVERRIDE { return m_resetStyleInheritance; } 68 65 void setResetStyleInheritance(bool); 69 66 70 Element* host() const; 71 void setHost(Element*); 72 ElementShadow* owner() const; 67 Element* host() const { return toElement(parentOrHostNode()); } 68 ElementShadow* owner() const { return host() ? host()->shadow() : 0; } 73 69 74 70 String innerHTML() const; … … 104 100 ShadowRoot(Document*, ShadowRootType); 105 101 virtual ~ShadowRoot(); 106 virtual PassRefPtr<Node> cloneNode(bool deep); 107 virtual bool childTypeAllowed(NodeType) const ;102 103 virtual bool childTypeAllowed(NodeType) const OVERRIDE; 108 104 virtual void childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta) OVERRIDE; 105 106 // ShadowRoots should never be cloned. 107 virtual PassRefPtr<Node> cloneNode(bool) OVERRIDE { return 0; } 108 109 // FIXME: This shouldn't happen. https://bugs.webkit.org/show_bug.cgi?id=88834 110 bool isOrphan() const { return !host(); } 109 111 110 112 ShadowRoot* m_prev; … … 117 119 unsigned m_registeredWithParentShadowRoot : 1; 118 120 }; 119 120 inline Element* ShadowRoot::host() const121 {122 return toElement(parentOrHostNode());123 }124 125 inline void ShadowRoot::setHost(Element* host)126 {127 setParentOrHostNode(host);128 if (host)129 setParentTreeScope(host->treeScope());130 }131 121 132 122 inline Element* ShadowRoot::activeElement() const
Note: See TracChangeset
for help on using the changeset viewer.