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

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

Issue 2772723002: Add detailed use counters for document.registerElement use. (Closed)
Patch Set: Bring patch to head. Created 3 years, 8 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) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 20 matching lines...) Expand all
31 #include "core/dom/custom/V0CustomElementRegistry.h" 31 #include "core/dom/custom/V0CustomElementRegistry.h"
32 32
33 #include "bindings/core/v8/V0CustomElementConstructorBuilder.h" 33 #include "bindings/core/v8/V0CustomElementConstructorBuilder.h"
34 #include "bindings/core/v8/V8Binding.h" 34 #include "bindings/core/v8/V8Binding.h"
35 #include "core/HTMLNames.h" 35 #include "core/HTMLNames.h"
36 #include "core/SVGNames.h" 36 #include "core/SVGNames.h"
37 #include "core/dom/Document.h" 37 #include "core/dom/Document.h"
38 #include "core/dom/custom/CustomElementRegistry.h" 38 #include "core/dom/custom/CustomElementRegistry.h"
39 #include "core/dom/custom/V0CustomElementException.h" 39 #include "core/dom/custom/V0CustomElementException.h"
40 #include "core/dom/custom/V0CustomElementRegistrationContext.h" 40 #include "core/dom/custom/V0CustomElementRegistrationContext.h"
41 #include "core/frame/LocalDOMWindow.h" 41 #include "core/frame/UseCounter.h"
42 42
43 namespace blink { 43 namespace blink {
44 44
45 V0CustomElementDefinition* V0CustomElementRegistry::registerElement( 45 V0CustomElementDefinition* V0CustomElementRegistry::registerElement(
46 Document* document, 46 Document* document,
47 V0CustomElementConstructorBuilder* constructorBuilder, 47 V0CustomElementConstructorBuilder* constructorBuilder,
48 const AtomicString& userSuppliedName, 48 const AtomicString& userSuppliedName,
49 V0CustomElement::NameSet validNames, 49 V0CustomElement::NameSet validNames,
50 ExceptionState& exceptionState) { 50 ExceptionState& exceptionState) {
51 AtomicString type = userSuppliedName.lower(); 51 AtomicString type = userSuppliedName.lower();
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 m_definitions.insert(descriptor, definition); 102 m_definitions.insert(descriptor, definition);
103 m_registeredTypeNames.insert(descriptor.type()); 103 m_registeredTypeNames.insert(descriptor.type());
104 104
105 if (!constructorBuilder->didRegisterDefinition()) { 105 if (!constructorBuilder->didRegisterDefinition()) {
106 V0CustomElementException::throwException( 106 V0CustomElementException::throwException(
107 V0CustomElementException::ContextDestroyedRegisteringDefinition, type, 107 V0CustomElementException::ContextDestroyedRegisteringDefinition, type,
108 exceptionState); 108 exceptionState);
109 return 0; 109 return 0;
110 } 110 }
111 111
112 if (validNames & V0CustomElement::EmbedderNames) {
113 UseCounter::count(document,
114 UseCounter::V0CustomElementsRegisterEmbedderElement);
115 } else if (tagName.namespaceURI() == SVGNames::svgNamespaceURI) {
116 UseCounter::count(document, UseCounter::V0CustomElementsRegisterSVGElement);
117 } else {
118 UseCounter::count(
119 document, descriptor.isTypeExtension()
120 ? UseCounter::V0CustomElementsRegisterHTMLTypeExtension
121 : UseCounter::V0CustomElementsRegisterHTMLCustomTag);
122 }
123
112 return definition; 124 return definition;
113 } 125 }
114 126
115 V0CustomElementDefinition* V0CustomElementRegistry::find( 127 V0CustomElementDefinition* V0CustomElementRegistry::find(
116 const V0CustomElementDescriptor& descriptor) const { 128 const V0CustomElementDescriptor& descriptor) const {
117 return m_definitions.at(descriptor); 129 return m_definitions.at(descriptor);
118 } 130 }
119 131
120 bool V0CustomElementRegistry::nameIsDefined(const AtomicString& name) const { 132 bool V0CustomElementRegistry::nameIsDefined(const AtomicString& name) const {
121 return m_registeredTypeNames.contains(name); 133 return m_registeredTypeNames.contains(name);
122 } 134 }
123 135
124 void V0CustomElementRegistry::setV1(const CustomElementRegistry* v1) { 136 void V0CustomElementRegistry::setV1(const CustomElementRegistry* v1) {
125 DCHECK(!m_v1.get()); 137 DCHECK(!m_v1.get());
126 m_v1 = v1; 138 m_v1 = v1;
127 } 139 }
128 140
129 bool V0CustomElementRegistry::v1NameIsDefined(const AtomicString& name) const { 141 bool V0CustomElementRegistry::v1NameIsDefined(const AtomicString& name) const {
130 return m_v1.get() && m_v1->nameIsDefined(name); 142 return m_v1.get() && m_v1->nameIsDefined(name);
131 } 143 }
132 144
133 DEFINE_TRACE(V0CustomElementRegistry) { 145 DEFINE_TRACE(V0CustomElementRegistry) {
134 visitor->trace(m_definitions); 146 visitor->trace(m_definitions);
135 visitor->trace(m_v1); 147 visitor->trace(m_v1);
136 } 148 }
137 149
138 } // namespace blink 150 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/custom/V0CustomElement.cpp ('k') | third_party/WebKit/Source/core/frame/UseCounter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698