IDL compiler: Drop support of serializer in WebIDL

Serializer was deprecated in spec, and we no longer have it in other than test IDLs.
This CL drops support of it from our IDL compiler.


Change-Id: I7734e10f76283e387156f79f4e518dc158d0c265
Reviewed-on: https://chromium-review.googlesource.com/c/1429364
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Reviewed-by: Yuki Shiino <yukishiino@chromium.org>
Commit-Queue: Hitoshi Yoshida <peria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#625165}
diff --git a/third_party/blink/renderer/bindings/scripts/idl_definitions.py b/third_party/blink/renderer/bindings/scripts/idl_definitions.py
index b7980d1..2707361 100644
--- a/third_party/blink/renderer/bindings/scripts/idl_definitions.py
+++ b/third_party/blink/renderer/bindings/scripts/idl_definitions.py
@@ -49,7 +49,6 @@
         IdlLiteral
         IdlOperation < TypedObject
             IdlArgument < TypedObject
-        IdlSerializer
         IdlStringifier
         IdlIterable < IdlIterableOrMaplikeOrSetlike
         IdlMaplike < IdlIterableOrMaplikeOrSetlike
@@ -298,7 +297,6 @@
         self.extended_attributes = {}
         self.operations = []
         self.parent = None
-        self.serializer = None
         self.stringifier = None
         self.iterable = None
         self.has_indexed_elements = False
@@ -350,9 +348,6 @@
                 self.operations.append(op)
             elif child_class == 'Inherit':
                 self.parent = child.GetName()
-            elif child_class == 'Serializer':
-                self.serializer = IdlSerializer(child)
-                self.process_serializer()
             elif child_class == 'Stringifier':
                 self.stringifier = IdlStringifier(child)
                 self.process_stringifier()
@@ -406,12 +401,6 @@
         elif self.setlike:
             self.setlike.accept(visitor)
 
-    def process_serializer(self):
-        """Add the serializer's named operation child, if it has one, as a regular
-        operation of this interface."""
-        if self.serializer.operation:
-            self.operations.append(self.serializer.operation)
-
     def process_stringifier(self):
         """Add the stringifier's attribute or named operation child, if it has
         one, as a regular attribute/operation of this interface."""
@@ -425,8 +414,6 @@
         self.attributes.extend(other.attributes)
         self.constants.extend(other.constants)
         self.operations.extend(other.operations)
-        if self.serializer is None:
-            self.serializer = other.serializer
         if self.stringifier is None:
             self.stringifier = other.stringifier
 
@@ -649,42 +636,6 @@
 
 
 ################################################################################
-# Serializers
-################################################################################
-
-class IdlSerializer(object):
-    def __init__(self, node):
-        self.attribute_name = node.GetProperty('ATTRIBUTE')
-        self.attribute_names = None
-        self.operation = None
-        self.extended_attributes = {}
-        self.is_attribute = False
-        self.is_getter = False
-        self.is_inherit = False
-        self.is_list = False
-        self.is_map = False
-
-        for child in node.GetChildren():
-            child_class = child.GetClass()
-            if child_class == 'Operation':
-                self.operation = IdlOperation(child)
-            elif child_class == 'List':
-                self.is_list = True
-                self.is_getter = bool(child.GetProperty('GETTER'))
-                self.attributes = child.GetProperty('ATTRIBUTES')
-            elif child_class == 'Map':
-                self.is_map = True
-                self.is_attribute = bool(child.GetProperty('ATTRIBUTE'))
-                self.is_getter = bool(child.GetProperty('GETTER'))
-                self.is_inherit = bool(child.GetProperty('INHERIT'))
-                self.attributes = child.GetProperty('ATTRIBUTES')
-            elif child_class == 'ExtAttributes':
-                self.extended_attributes = ext_attributes_node_to_extended_attributes(child)
-            else:
-                raise ValueError('Unrecognized node class: %s' % child_class)
-
-
-################################################################################
 # Stringifiers
 ################################################################################
 
diff --git a/third_party/blink/renderer/bindings/scripts/v8_interface.py b/third_party/blink/renderer/bindings/scripts/v8_interface.py
index 343b168b..e3c8373 100644
--- a/third_party/blink/renderer/bindings/scripts/v8_interface.py
+++ b/third_party/blink/renderer/bindings/scripts/v8_interface.py
@@ -762,24 +762,6 @@
         # FIXME: maplike<> and setlike<> should also imply the presence of a
         # 'size' attribute.
 
-    # Serializer
-    if interface.serializer:
-        serializer = interface.serializer
-        serializer_ext_attrs = serializer.extended_attributes.copy()
-        if serializer.operation:
-            return_type = serializer.operation.idl_type
-            implemented_as = serializer.operation.name
-        else:
-            return_type = IdlType('any')
-            implemented_as = None
-            if 'CallWith' not in serializer_ext_attrs:
-                serializer_ext_attrs['CallWith'] = 'ScriptState'
-        methods.append(generated_method(
-            return_type=return_type,
-            name='toJSON',
-            extended_attributes=serializer_ext_attrs,
-            implemented_as=implemented_as))
-
     # Stringifier
     if interface.stringifier:
         stringifier = interface.stringifier
diff --git a/third_party/blink/renderer/bindings/tests/idls/core/test_implements.idl b/third_party/blink/renderer/bindings/tests/idls/core/test_implements.idl
index 0581e63b..4b6bc98 100644
--- a/third_party/blink/renderer/bindings/tests/idls/core/test_implements.idl
+++ b/third_party/blink/renderer/bindings/tests/idls/core/test_implements.idl
@@ -47,5 +47,4 @@
     [RuntimeEnabled=ImplementsFeatureName] attribute Node implementsRuntimeEnabledNodeAttribute;
 
     [NotEnumerable] stringifier;
-    serializer;
 };
diff --git a/third_party/blink/renderer/bindings/tests/idls/core/test_object.idl b/third_party/blink/renderer/bindings/tests/idls/core/test_object.idl
index 3969e02..2dab559 100644
--- a/third_party/blink/renderer/bindings/tests/idls/core/test_object.idl
+++ b/third_party/blink/renderer/bindings/tests/idls/core/test_object.idl
@@ -550,8 +550,6 @@
     [NewObject] Promise<TestInterface> newObjectTestInterfacePromiseMethod();
     [RuntimeCallStatsCounter=RuntimeCallStatsCounterMethod] void RuntimeCallStatsCounterMethod();
 
-    serializer = { attribute };
-
     // Extended attributes on referenced interfaces
     // (not self; self-reference tests at interface themselves)
     attribute TestInterface testInterfaceAttribute; // [ImplementedAs]
diff --git a/third_party/blink/renderer/bindings/tests/results/core/v8_test_interface.cc b/third_party/blink/renderer/bindings/tests/results/core/v8_test_interface.cc
index 4d7061f..872638a 100644
--- a/third_party/blink/renderer/bindings/tests/results/core/v8_test_interface.cc
+++ b/third_party/blink/renderer/bindings/tests/results/core/v8_test_interface.cc
@@ -2436,15 +2436,6 @@
   }
 }
 
-static void ToJSONMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
-  TestInterfaceImplementation* impl = V8TestInterface::ToImpl(info.Holder());
-
-  ScriptState* script_state = ScriptState::ForRelevantRealm(info);
-
-  ScriptValue result = impl->toJSONForBinding(script_state);
-  V8SetReturnValue(info, result.V8Value());
-}
-
 static void ToStringMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
   TestInterfaceImplementation* impl = V8TestInterface::ToImpl(info.Holder());
 
@@ -3779,12 +3770,6 @@
   test_interface_implementation_v8_internal::ForEachMethod(info);
 }
 
-void V8TestInterface::ToJSONMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
-  RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterfaceImplementation_toJSON");
-
-  test_interface_implementation_v8_internal::ToJSONMethod(info);
-}
-
 void V8TestInterface::ToStringMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
   RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterfaceImplementation_toString");
 
@@ -3971,7 +3956,6 @@
     {"keys", V8TestInterface::KeysMethodCallback, 0, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds},
     {"values", V8TestInterface::ValuesMethodCallback, 0, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds},
     {"forEach", V8TestInterface::ForEachMethodCallback, 1, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds},
-    {"toJSON", V8TestInterface::ToJSONMethodCallback, 0, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds},
     {"toString", V8TestInterface::ToStringMethodCallback, 0, static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds},
 };
 
diff --git a/third_party/blink/renderer/bindings/tests/results/core/v8_test_interface.h b/third_party/blink/renderer/bindings/tests/results/core/v8_test_interface.h
index 3fee62c..c859d00 100644
--- a/third_party/blink/renderer/bindings/tests/results/core/v8_test_interface.h
+++ b/third_party/blink/renderer/bindings/tests/results/core/v8_test_interface.h
@@ -241,7 +241,6 @@
   CORE_EXPORT static void KeysMethodCallback(const v8::FunctionCallbackInfo<v8::Value>&);
   CORE_EXPORT static void ValuesMethodCallback(const v8::FunctionCallbackInfo<v8::Value>&);
   CORE_EXPORT static void ForEachMethodCallback(const v8::FunctionCallbackInfo<v8::Value>&);
-  CORE_EXPORT static void ToJSONMethodCallback(const v8::FunctionCallbackInfo<v8::Value>&);
   CORE_EXPORT static void ToStringMethodCallback(const v8::FunctionCallbackInfo<v8::Value>&);
   CORE_EXPORT static void IteratorMethodCallback(const v8::FunctionCallbackInfo<v8::Value>&);
 
diff --git a/third_party/blink/renderer/bindings/tests/results/core/v8_test_object.cc b/third_party/blink/renderer/bindings/tests/results/core/v8_test_object.cc
index 3f4864e2..1a1f226 100644
--- a/third_party/blink/renderer/bindings/tests/results/core/v8_test_object.cc
+++ b/third_party/blink/renderer/bindings/tests/results/core/v8_test_object.cc
@@ -9331,15 +9331,6 @@
   V8SetReturnValue(info, result);
 }
 
-static void ToJSONMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
-  TestObject* impl = V8TestObject::ToImpl(info.Holder());
-
-  ScriptState* script_state = ScriptState::ForRelevantRealm(info);
-
-  ScriptValue result = impl->toJSONForBinding(script_state);
-  V8SetReturnValue(info, result.V8Value());
-}
-
 static void ToStringMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
   TestObject* impl = V8TestObject::ToImpl(info.Holder());
 
@@ -13284,12 +13275,6 @@
   test_object_v8_internal::SetMethod(info);
 }
 
-void V8TestObject::ToJSONMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
-  RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestObject_toJSON");
-
-  test_object_v8_internal::ToJSONMethod(info);
-}
-
 void V8TestObject::ToStringMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
   RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestObject_toString");
 
@@ -13798,7 +13783,6 @@
     {"get", V8TestObject::GetMethodCallback, 1, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds},
     {"delete", V8TestObject::DeleteMethodCallback, 1, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds},
     {"set", V8TestObject::SetMethodCallback, 2, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds},
-    {"toJSON", V8TestObject::ToJSONMethodCallback, 0, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds},
     {"toString", V8TestObject::ToStringMethodCallback, 0, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds},
 };
 
diff --git a/third_party/blink/renderer/bindings/tests/results/core/v8_test_object.h b/third_party/blink/renderer/bindings/tests/results/core/v8_test_object.h
index 29c82e4..88ea6f5 100644
--- a/third_party/blink/renderer/bindings/tests/results/core/v8_test_object.h
+++ b/third_party/blink/renderer/bindings/tests/results/core/v8_test_object.h
@@ -620,7 +620,6 @@
   CORE_EXPORT static void GetMethodCallback(const v8::FunctionCallbackInfo<v8::Value>&);
   CORE_EXPORT static void DeleteMethodCallback(const v8::FunctionCallbackInfo<v8::Value>&);
   CORE_EXPORT static void SetMethodCallback(const v8::FunctionCallbackInfo<v8::Value>&);
-  CORE_EXPORT static void ToJSONMethodCallback(const v8::FunctionCallbackInfo<v8::Value>&);
   CORE_EXPORT static void ToStringMethodCallback(const v8::FunctionCallbackInfo<v8::Value>&);
   CORE_EXPORT static void IteratorMethodCallback(const v8::FunctionCallbackInfo<v8::Value>&);
 
diff --git a/tools/idl_parser/idl_lexer.py b/tools/idl_parser/idl_lexer.py
index c144681..a4a6f76 100755
--- a/tools/idl_parser/idl_lexer.py
+++ b/tools/idl_parser/idl_lexer.py
@@ -95,7 +95,6 @@
     'record' : 'RECORD',
     'required' : 'REQUIRED',
     'sequence' : 'SEQUENCE',
-    'serializer' : 'SERIALIZER',
     'setlike' : 'SETLIKE',
     'setter': 'SETTER',
     'short' : 'SHORT',
diff --git a/tools/idl_parser/idl_parser.py b/tools/idl_parser/idl_parser.py
index d614245..216c190 100755
--- a/tools/idl_parser/idl_parser.py
+++ b/tools/idl_parser/idl_parser.py
@@ -336,11 +336,9 @@
     """InterfaceMembers : error"""
     p[0] = self.BuildError(p, 'InterfaceMembers')
 
-  # Removed unsupported: Serializer
   def p_InterfaceMember(self, p):
     """InterfaceMember : Const
                        | Operation
-                       | Serializer
                        | Stringifier
                        | StaticMember
                        | Iterable
@@ -545,70 +543,6 @@
     p[0] = ListFromConcat(self.BuildAttribute('TYPE', 'float'),
                           self.BuildAttribute('VALUE', val))
 
-  def p_Serializer(self, p):
-    """Serializer : SERIALIZER SerializerRest"""
-    p[0] = self.BuildProduction('Serializer', p, 1, p[2])
-
-  # TODO(jl): This adds ReturnType and ';', missing from the spec's grammar.
-  # https://www.w3.org/Bugs/Public/show_bug.cgi?id=20361
-  def p_SerializerRest(self, p):
-    """SerializerRest : ReturnType OperationRest
-                      | '=' SerializationPattern ';'
-                      | ';'"""
-    if len(p) == 3:
-      p[2].AddChildren(p[1])
-      p[0] = p[2]
-    elif len(p) == 4:
-      p[0] = p[2]
-
-  def p_SerializationPattern(self, p):
-    """SerializationPattern : '{' SerializationPatternMap '}'
-                            | '[' SerializationPatternList ']'
-                            | identifier"""
-    if len(p) > 2:
-      p[0] = p[2]
-    else:
-      p[0] = self.BuildAttribute('ATTRIBUTE', p[1])
-
-  # TODO(jl): This adds the "ATTRIBUTE" and "INHERIT ',' ATTRIBUTE" variants,
-  # missing from the spec's grammar.
-  # https://www.w3.org/Bugs/Public/show_bug.cgi?id=20361
-  def p_SerializationPatternMap(self, p):
-    """SerializationPatternMap : GETTER
-                               | ATTRIBUTE
-                               | INHERIT ',' ATTRIBUTE
-                               | INHERIT Identifiers
-                               | identifier Identifiers
-                               |"""
-    p[0] = self.BuildProduction('Map', p, 0)
-    if len(p) == 4:
-      p[0].AddChildren(self.BuildTrue('INHERIT'))
-      p[0].AddChildren(self.BuildTrue('ATTRIBUTE'))
-    elif len(p) > 1:
-      if p[1] == 'getter':
-        p[0].AddChildren(self.BuildTrue('GETTER'))
-      elif p[1] == 'attribute':
-        p[0].AddChildren(self.BuildTrue('ATTRIBUTE'))
-      else:
-        if p[1] == 'inherit':
-          p[0].AddChildren(self.BuildTrue('INHERIT'))
-          attributes = p[2]
-        else:
-          attributes = ListFromConcat(p[1], p[2])
-        p[0].AddChildren(self.BuildAttribute('ATTRIBUTES', attributes))
-
-  def p_SerializationPatternList(self, p):
-    """SerializationPatternList : GETTER
-                                | identifier Identifiers
-                                |"""
-    p[0] = self.BuildProduction('List', p, 0)
-    if len(p) > 1:
-      if p[1] == 'getter':
-        p[0].AddChildren(self.BuildTrue('GETTER'))
-      else:
-        attributes = ListFromConcat(p[1], p[2])
-        p[0].AddChildren(self.BuildAttribute('ATTRIBUTES', attributes))
-
   def p_Stringifier(self, p):
     """Stringifier : STRINGIFIER StringifierRest"""
     p[0] = self.BuildProduction('Stringifier', p, 1, p[2])
@@ -893,7 +827,6 @@
                            | LEGACYCALLER
                            | NAMESPACE
                            | PARTIAL
-                           | SERIALIZER
                            | SETTER
                            | STATIC
                            | STRINGIFIER
diff --git a/tools/idl_parser/test_lexer/keywords.in b/tools/idl_parser/test_lexer/keywords.in
index 0926ce4..612facf 100644
--- a/tools/idl_parser/test_lexer/keywords.in
+++ b/tools/idl_parser/test_lexer/keywords.in
@@ -37,7 +37,6 @@
 REGEXP RegExp
 REQUIRED required
 SEQUENCE sequence
-SERIALIZER serializer
 SETLIKE setlike
 SETTER setter
 SHORT short
diff --git a/tools/idl_parser/test_parser/interface_web.idl b/tools/idl_parser/test_parser/interface_web.idl
index 555e5d1..7256bcb 100644
--- a/tools/idl_parser/test_parser/interface_web.idl
+++ b/tools/idl_parser/test_parser/interface_web.idl
@@ -447,64 +447,6 @@
 };
 
 /** TREE
- *Interface(MyIfaceSerializer)
- *  Serializer()
- *  Serializer()
- *    Operation(toJSON)
- *      Arguments()
- *      Type()
- *        Any()
- *  Serializer()
- *    ATTRIBUTE: name
- *  Serializer()
- *    Map()
- *  Serializer()
- *    Map()
- *      GETTER: True
- *  Serializer()
- *    Map()
- *      ATTRIBUTE: True
- *  Serializer()
- *    Map()
- *      ATTRIBUTE: True
- *      INHERIT: True
- *  Serializer()
- *    Map()
- *      INHERIT: True
- *      ATTRIBUTES: None
- *  Serializer()
- *    Map()
- *      INHERIT: True
- *      ATTRIBUTES: ['name1', 'name2']
- *  Serializer()
- *    Map()
- *      ATTRIBUTES: ['name1', 'name2']
- *  Serializer()
- *    List()
- *  Serializer()
- *    List()
- *      GETTER: True
- *  Serializer()
- *    List()
- *      ATTRIBUTES: ['name1', 'name2']
- */
-interface MyIfaceSerializer {
-  serializer;
-  serializer any toJSON();
-  serializer = name;
-  serializer = {};
-  serializer = { getter };
-  serializer = { attribute };
-  serializer = { inherit, attribute };
-  serializer = { inherit };
-  serializer = { inherit, name1, name2 };
-  serializer = { name1, name2 };
-  serializer = [];
-  serializer = [getter];
-  serializer = [name1, name2];
-};
-
-/** TREE
  *Interface(MyIfaceFrozenArray)
  *  Attribute(foo)
  *    READONLY: True