| OLD | NEW |
| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 if (!constructorBuilder->isFeatureAllowed()) { | 72 if (!constructorBuilder->isFeatureAllowed()) { |
| 73 CustomElementException::throwException(CustomElementException::CannotReg
isterFromExtension, type, exceptionState); | 73 CustomElementException::throwException(CustomElementException::CannotReg
isterFromExtension, type, exceptionState); |
| 74 return 0; | 74 return 0; |
| 75 } | 75 } |
| 76 | 76 |
| 77 if (!CustomElement::isValidName(type, validNames)) { | 77 if (!CustomElement::isValidName(type, validNames)) { |
| 78 CustomElementException::throwException(CustomElementException::InvalidNa
me, type, exceptionState); | 78 CustomElementException::throwException(CustomElementException::InvalidNa
me, type, exceptionState); |
| 79 return 0; | 79 return 0; |
| 80 } | 80 } |
| 81 | 81 |
| 82 if (m_registeredTypeNames.contains(type)) { | 82 if (m_definitions.contains(type)) { |
| 83 CustomElementException::throwException(CustomElementException::TypeAlrea
dyRegistered, type, exceptionState); | 83 CustomElementException::throwException(CustomElementException::TypeAlrea
dyRegistered, type, exceptionState); |
| 84 return 0; | 84 return 0; |
| 85 } | 85 } |
| 86 | 86 |
| 87 QualifiedName tagName = nullName; | 87 QualifiedName tagName = nullName; |
| 88 if (!constructorBuilder->validateOptions(type, tagName, exceptionState)) | 88 if (!constructorBuilder->validateOptions(type, tagName, exceptionState)) |
| 89 return 0; | 89 return 0; |
| 90 | 90 |
| 91 ASSERT(!observer.registrationContextWentAway()); | 91 ASSERT(!observer.registrationContextWentAway()); |
| 92 | 92 |
| 93 RefPtr<CustomElementLifecycleCallbacks> lifecycleCallbacks = constructorBuil
der->createCallbacks(); | 93 RefPtr<CustomElementLifecycleCallbacks> lifecycleCallbacks = constructorBuil
der->createCallbacks(); |
| 94 | 94 |
| 95 // Consulting the constructor builder could execute script and | 95 // Consulting the constructor builder could execute script and |
| 96 // kill the document. | 96 // kill the document. |
| 97 if (observer.registrationContextWentAway()) { | 97 if (observer.registrationContextWentAway()) { |
| 98 CustomElementException::throwException(CustomElementException::ContextDe
stroyedCreatingCallbacks, type, exceptionState); | 98 CustomElementException::throwException(CustomElementException::ContextDe
stroyedCreatingCallbacks, type, exceptionState); |
| 99 return 0; | 99 return 0; |
| 100 } | 100 } |
| 101 | 101 |
| 102 const CustomElementDescriptor descriptor(type, tagName.localName()); | 102 const CustomElementDescriptor descriptor(tagName.localName()); |
| 103 RefPtr<CustomElementDefinition> definition = CustomElementDefinition::create
(descriptor, lifecycleCallbacks); | 103 RefPtr<CustomElementDefinition> definition = CustomElementDefinition::create
(descriptor, lifecycleCallbacks); |
| 104 | 104 |
| 105 if (!constructorBuilder->createConstructor(document, definition.get(), excep
tionState)) | 105 if (!constructorBuilder->createConstructor(document, definition.get(), excep
tionState)) |
| 106 return 0; | 106 return 0; |
| 107 | 107 |
| 108 m_definitions.add(descriptor, definition); | 108 m_definitions.add(descriptor, definition); |
| 109 m_registeredTypeNames.add(descriptor.type()); | |
| 110 | 109 |
| 111 if (!constructorBuilder->didRegisterDefinition(definition.get())) { | 110 if (!constructorBuilder->didRegisterDefinition(definition.get())) { |
| 112 CustomElementException::throwException(CustomElementException::ContextDe
stroyedRegisteringDefinition, type, exceptionState); | 111 CustomElementException::throwException(CustomElementException::ContextDe
stroyedRegisteringDefinition, type, exceptionState); |
| 113 return 0; | 112 return 0; |
| 114 } | 113 } |
| 115 | 114 |
| 116 return definition.get(); | 115 return definition.get(); |
| 117 } | 116 } |
| 118 | 117 |
| 119 CustomElementDefinition* CustomElementRegistry::find(const CustomElementDescript
or& descriptor) const | 118 CustomElementDefinition* CustomElementRegistry::find(const CustomElementDescript
or& descriptor) const |
| 120 { | 119 { |
| 121 return m_definitions.get(descriptor); | 120 return m_definitions.get(descriptor); |
| 122 } | 121 } |
| 123 | 122 |
| 124 } // namespace blink | 123 } // namespace blink |
| OLD | NEW |