| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 } | 59 } |
| 60 | 60 |
| 61 void CustomElement::addEmbedderCustomElementName(const AtomicString& name) | 61 void CustomElement::addEmbedderCustomElementName(const AtomicString& name) |
| 62 { | 62 { |
| 63 AtomicString lower = name.lower(); | 63 AtomicString lower = name.lower(); |
| 64 if (isValidName(lower, EmbedderNames)) | 64 if (isValidName(lower, EmbedderNames)) |
| 65 return; | 65 return; |
| 66 embedderCustomElementNames().append(lower); | 66 embedderCustomElementNames().append(lower); |
| 67 } | 67 } |
| 68 | 68 |
| 69 static inline bool isValidNCName(const AtomicString& name) |
| 70 { |
| 71 if (kNotFound != name.find(':')) |
| 72 return false; |
| 73 |
| 74 if (!name.string().is8Bit()) { |
| 75 const UChar32 c = name.characters16()[0]; |
| 76 // These characters comes under CombiningChar in NCName and according to |
| 77 // NCName only BaseChar and Ideodgraphic can come as first chars. |
| 78 // Also these characters come under Letter_Other in UnicodeData, thats |
| 79 // why they pass as valid document name. |
| 80 if (c == 0x0B83 || c == 0x0F88 || c == 0x0F89 || c == 0x0F8A || c == 0x0
F8B) |
| 81 return false; |
| 82 } |
| 83 |
| 84 return Document::isValidName(name.string()); |
| 85 } |
| 86 |
| 69 bool CustomElement::isValidName(const AtomicString& name, NameSet validNames) | 87 bool CustomElement::isValidName(const AtomicString& name, NameSet validNames) |
| 70 { | 88 { |
| 71 if ((validNames & EmbedderNames) && kNotFound != embedderCustomElementNames(
).find(name)) | 89 if ((validNames & EmbedderNames) && kNotFound != embedderCustomElementNames(
).find(name)) |
| 72 return Document::isValidName(name); | 90 return Document::isValidName(name); |
| 73 | 91 |
| 74 if ((validNames & StandardNames) && kNotFound != name.find('-')) { | 92 if ((validNames & StandardNames) && kNotFound != name.find('-')) { |
| 75 DEFINE_STATIC_LOCAL(Vector<AtomicString>, reservedNames, ()); | 93 DEFINE_STATIC_LOCAL(Vector<AtomicString>, reservedNames, ()); |
| 76 if (reservedNames.isEmpty()) { | 94 if (reservedNames.isEmpty()) { |
| 77 // FIXME(crbug.com/426605): We should be able to remove this. | 95 // FIXME(crbug.com/426605): We should be able to remove this. |
| 78 reservedNames.append(MathMLNames::annotation_xmlTag.localName()); | 96 reservedNames.append(MathMLNames::annotation_xmlTag.localName()); |
| 79 } | 97 } |
| 80 | 98 |
| 81 if (kNotFound == reservedNames.find(name)) | 99 if (kNotFound == reservedNames.find(name)) |
| 82 return Document::isValidName(name.string()); | 100 return isValidNCName(name); |
| 83 } | 101 } |
| 84 | 102 |
| 85 return false; | 103 return false; |
| 86 } | 104 } |
| 87 | 105 |
| 88 void CustomElement::define(Element* element, PassRefPtr<CustomElementDefinition>
passDefinition) | 106 void CustomElement::define(Element* element, PassRefPtr<CustomElementDefinition>
passDefinition) |
| 89 { | 107 { |
| 90 RefPtr<CustomElementDefinition> definition(passDefinition); | 108 RefPtr<CustomElementDefinition> definition(passDefinition); |
| 91 | 109 |
| 92 switch (element->customElementState()) { | 110 switch (element->customElementState()) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 break; | 150 break; |
| 133 | 151 |
| 134 case Element::WaitingForUpgrade: | 152 case Element::WaitingForUpgrade: |
| 135 case Element::Upgraded: | 153 case Element::Upgraded: |
| 136 CustomElementObserver::notifyElementWasDestroyed(element); | 154 CustomElementObserver::notifyElementWasDestroyed(element); |
| 137 break; | 155 break; |
| 138 } | 156 } |
| 139 } | 157 } |
| 140 | 158 |
| 141 } // namespace blink | 159 } // namespace blink |
| OLD | NEW |