Changeset 217864 in webkit
- Timestamp:
- Jun 6, 2017 3:38:27 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r217863 r217864 1 2017-06-06 Darin Adler <darin@apple.com> 2 3 Update to slightly stricter rules for custom element names from more recent standard draft 4 https://bugs.webkit.org/show_bug.cgi?id=173019 5 6 Reviewed by Ryosuke Niwa. 7 8 * platform/ios-wk2/imported/w3c/web-platform-tests/html/semantics/interfaces-expected.txt: Expect more PASS. 9 * platform/ios/imported/w3c/web-platform-tests/html/semantics/interfaces-expected.txt: Ditto. 10 1 11 2017-06-06 Yoav Weiss <yoav@yoav.ws> 2 12 -
trunk/LayoutTests/imported/w3c/ChangeLog
r217767 r217864 1 2017-06-06 Darin Adler <darin@apple.com> 2 3 Update to slightly stricter rules for custom element names from more recent standard draft 4 https://bugs.webkit.org/show_bug.cgi?id=173019 5 6 Reviewed by Ryosuke Niwa. 7 8 * web-platform-tests/html/semantics/interfaces-expected.txt: Expect more PASS. 9 1 10 2017-06-04 Chris Dumez <cdumez@apple.com> 2 11 -
trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/interfaces-expected.txt
r210823 r217864 293 293 PASS Interfaces for xmp 294 294 PASS Interfaces for XMP 295 FAIL Interfaces for å-bar assert_equals: Element å-bar should have HTMLUnknownElement as its primary interface. expected "[object HTMLUnknownElement]" but got "[object HTMLElement]" 296 FAIL Interfaces for Å-BAR assert_equals: Element Å-BAR should have HTMLUnknownElement as its primary interface. expected "[object HTMLUnknownElement]" but got "[object HTMLElement]" 295 PASS Interfaces for å-bar 296 PASS Interfaces for Å-BAR 297 297 -
trunk/LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/html/semantics/interfaces-expected.txt
r210823 r217864 293 293 PASS Interfaces for xmp 294 294 PASS Interfaces for XMP 295 FAIL Interfaces for å-bar assert_equals: Element å-bar should have HTMLUnknownElement as its primary interface. expected "[object HTMLUnknownElement]" but got "[object HTMLElement]" 296 FAIL Interfaces for Å-BAR assert_equals: Element Å-BAR should have HTMLUnknownElement as its primary interface. expected "[object HTMLUnknownElement]" but got "[object HTMLElement]" 295 PASS Interfaces for å-bar 296 PASS Interfaces for Å-BAR 297 297 -
trunk/LayoutTests/platform/ios/imported/w3c/web-platform-tests/html/semantics/interfaces-expected.txt
r205579 r217864 293 293 PASS Interfaces for xmp 294 294 PASS Interfaces for XMP 295 FAIL Interfaces for å-bar assert_equals: Element å-bar should have HTMLUnknownElement as its primary interface. expected "[object HTMLUnknownElement]" but got "[object HTMLElement]" 296 FAIL Interfaces for Å-BAR assert_equals: Element Å-BAR should have HTMLUnknownElement as its primary interface. expected "[object HTMLUnknownElement]" but got "[object HTMLElement]" 295 PASS Interfaces for å-bar 296 PASS Interfaces for Å-BAR 297 297 -
trunk/Source/WebCore/ChangeLog
r217863 r217864 1 2017-06-06 Darin Adler <darin@apple.com> 2 3 Update to slightly stricter rules for custom element names from more recent standard draft 4 https://bugs.webkit.org/show_bug.cgi?id=173019 5 6 Reviewed by Ryosuke Niwa. 7 8 * bindings/js/JSCustomElementRegistryCustom.cpp: 9 (WebCore::validateCustomElementNameAndThrowIfNeeded): Add more error strings for various error cases. 10 11 * dom/Document.cpp: 12 (WebCore::isPotentialCustomElementNameCharacter): Added. Implements the PCENChar production 13 from the standard by listing all the ranges exactly as they appear in the standard. 14 (WebCore::Document::validateCustomElementName): Added a check that the first character is 15 a lowercase ASCII letter. Added a check that all characters are potential custom element 16 name characters. 17 18 * dom/Document.h: Update the CustomElementNameValidationStatus with new values for 19 the various new error cases. Not sure that validateCustomElementName really belongs 20 in the Document class in the first place. Also seems that the error strings could be 21 in validateCustomElementName rather than in a separate bindings function, obviating 22 the need for the enum. 23 1 24 2017-06-06 Yoav Weiss <yoav@yoav.ws> 2 25 -
trunk/Source/WebCore/bindings/js/JSCustomElementRegistryCustom.cpp
r216501 r217864 58 58 { 59 59 auto scope = DECLARE_THROW_SCOPE(state.vm()); 60 61 60 switch (Document::validateCustomElementName(name)) { 62 61 case CustomElementNameValidationStatus::Valid: 63 62 return true; 64 case CustomElementNameValidationStatus::ConflictsWithBuiltinNames: 65 throwSyntaxError(&state, scope, ASCIILiteral("Custom element name cannot be same as one of the builtin elements")); 66 return false; 67 case CustomElementNameValidationStatus::NoHyphen: 63 case CustomElementNameValidationStatus::FirstCharacterIsNotLowercaseASCIILetter: 64 throwSyntaxError(&state, scope, ASCIILiteral("Custom element name must have a lowercase ASCII letter as its first character")); 65 return false; 66 case CustomElementNameValidationStatus::ContainsUppercaseASCIILetter: 67 throwSyntaxError(&state, scope, ASCIILiteral("Custom element name cannot contain an uppercase ASCII letter")); 68 return false; 69 case CustomElementNameValidationStatus::ContainsNoHyphen: 68 70 throwSyntaxError(&state, scope, ASCIILiteral("Custom element name must contain a hyphen")); 69 71 return false; 70 case CustomElementNameValidationStatus::ContainsUpperCase: 71 throwSyntaxError(&state, scope, ASCIILiteral("Custom element name cannot contain an upper case letter")); 72 case CustomElementNameValidationStatus::ContainsDisallowedCharacter: 73 throwSyntaxError(&state, scope, ASCIILiteral("Custom element name contains a character that is not allowed")); 74 return false; 75 case CustomElementNameValidationStatus::ConflictsWithStandardElementName: 76 throwSyntaxError(&state, scope, ASCIILiteral("Custom element name cannot be same as one of the standard elements")); 72 77 return false; 73 78 } -
trunk/Source/WebCore/dom/Document.cpp
r217860 r217864 1063 1063 } 1064 1064 1065 // https://html.spec.whatwg.org/#valid-custom-element-name 1066 1067 struct UnicodeCodePointRange { 1068 UChar32 minimum; 1069 UChar32 maximum; 1070 }; 1071 1072 #if !ASSERT_DISABLED 1073 1074 static inline bool operator<(const UnicodeCodePointRange& a, const UnicodeCodePointRange& b) 1075 { 1076 ASSERT(a.minimum <= a.maximum); 1077 ASSERT(b.minimum <= b.maximum); 1078 return a.maximum < b.minimum; 1079 } 1080 1081 #endif 1082 1083 static inline bool operator<(const UnicodeCodePointRange& a, UChar32 b) 1084 { 1085 ASSERT(a.minimum <= a.maximum); 1086 return a.maximum < b; 1087 } 1088 1089 static inline bool operator<(UChar32 a, const UnicodeCodePointRange& b) 1090 { 1091 ASSERT(b.minimum <= b.maximum); 1092 return a < b.minimum; 1093 } 1094 1095 static inline bool isPotentialCustomElementNameCharacter(UChar32 character) 1096 { 1097 static const UnicodeCodePointRange ranges[] = { 1098 { '-', '.' }, 1099 { '0', '9' }, 1100 { '_', '_' }, 1101 { 'a', 'z' }, 1102 { 0xB7, 0xB7 }, 1103 { 0xC0, 0xD6 }, 1104 { 0xD8, 0xF6 }, 1105 { 0xF8, 0x37D }, 1106 { 0x37F, 0x1FFF }, 1107 { 0x200C, 0x200D }, 1108 { 0x203F, 0x2040 }, 1109 { 0x2070, 0x218F }, 1110 { 0x2C00, 0x2FEF }, 1111 { 0x3001, 0xD7FF }, 1112 { 0xF900, 0xFDCF }, 1113 { 0xFDF0, 0xFFFD }, 1114 { 0x10000, 0xEFFFF }, 1115 }; 1116 1117 ASSERT(std::is_sorted(std::begin(ranges), std::end(ranges))); 1118 return std::binary_search(std::begin(ranges), std::end(ranges), character); 1119 } 1120 1065 1121 CustomElementNameValidationStatus Document::validateCustomElementName(const AtomicString& localName) 1066 1122 { 1123 if (!isASCIILower(localName[0])) 1124 return CustomElementNameValidationStatus::FirstCharacterIsNotLowercaseASCIILetter; 1125 1067 1126 bool containsHyphen = false; 1068 for (auto character : StringView(localName).code Units()) {1127 for (auto character : StringView(localName).codePoints()) { 1069 1128 if (isASCIIUpper(character)) 1070 return CustomElementNameValidationStatus::ContainsUpperCase; 1129 return CustomElementNameValidationStatus::ContainsUppercaseASCIILetter; 1130 if (!isPotentialCustomElementNameCharacter(character)) 1131 return CustomElementNameValidationStatus::ContainsDisallowedCharacter; 1071 1132 if (character == '-') 1072 1133 containsHyphen = true; … … 1074 1135 1075 1136 if (!containsHyphen) 1076 return CustomElementNameValidationStatus:: NoHyphen;1137 return CustomElementNameValidationStatus::ContainsNoHyphen; 1077 1138 1078 1139 #if ENABLE(MATHML) … … 1090 1151 || localName == SVGNames::missing_glyphTag.localName() 1091 1152 || localName == annotationXmlLocalName) 1092 return CustomElementNameValidationStatus::ConflictsWith BuiltinNames;1153 return CustomElementNameValidationStatus::ConflictsWithStandardElementName; 1093 1154 1094 1155 return CustomElementNameValidationStatus::Valid; -
trunk/Source/WebCore/dom/Document.h
r217734 r217864 276 276 }; 277 277 278 enum class CustomElementNameValidationStatus { Valid, ConflictsWithBuiltinNames, NoHyphen, ContainsUpperCase }; 278 enum class CustomElementNameValidationStatus { 279 Valid, 280 FirstCharacterIsNotLowercaseASCIILetter, 281 ContainsNoHyphen, 282 ContainsUppercaseASCIILetter, 283 ContainsDisallowedCharacter, 284 ConflictsWithStandardElementName 285 }; 279 286 280 287 class Document
Note: See TracChangeset
for help on using the changeset viewer.