Import Cobalt 19.lts.1.186193

Change-Id: I105353baddfdc9d7c29e0b896e2b43da7fd14b16
diff --git a/src/cobalt/bindings/contexts.py b/src/cobalt/bindings/contexts.py
index 23cd3d7..885f6e5 100644
--- a/src/cobalt/bindings/contexts.py
+++ b/src/cobalt/bindings/contexts.py
@@ -30,6 +30,7 @@
 from overload_context import get_overload_contexts
 from v8_attributes import is_constructor_attribute
 from v8_interface import method_overloads_by_name
+import v8_utilities
 
 
 def is_date_type(idl_type):
@@ -397,6 +398,12 @@
             self.typed_object_to_cobalt_type(interface, operation),
         'is_static':
             operation.is_static,
+        'on_instance':
+            v8_utilities.on_instance(interface, operation),
+        'on_interface':
+            v8_utilities.on_interface(interface, operation),
+        'on_prototype':
+            v8_utilities.on_prototype(interface, operation),
         'call_with':
             operation.extended_attributes.get('CallWith', None),
         'raises_exception':
@@ -406,7 +413,6 @@
         'unsupported':
             'NotSupported' in operation.extended_attributes,
     }
-
     context.update(self.partial_context(interface, operation))
     return context
 
@@ -486,6 +492,12 @@
             self.typed_object_to_cobalt_type(interface, attribute),
         'is_static':
             attribute.is_static,
+        'on_instance':
+            v8_utilities.on_instance(interface, attribute),
+        'on_interface':
+            v8_utilities.on_interface(interface, attribute),
+        'on_prototype':
+            v8_utilities.on_prototype(interface, attribute),
         'is_read_only':
             attribute.is_read_only,
         'call_with':
@@ -598,6 +610,9 @@
       context['idl_name'] = context['overloads'][0]['idl_name']
       context['conditional'] = context['overloads'][0]['conditional']
       context['unsupported'] = context['overloads'][0]['unsupported']
+      context['on_instance'] = context['overloads'][0]['on_instance']
+      context['on_interface'] = context['overloads'][0]['on_interface']
+      context['on_prototype'] = context['overloads'][0]['on_prototype']
       for overload in context['overloads']:
         assert context['conditional'] == overload['conditional'], (
             'All overloads must have the same conditional.')
diff --git a/src/cobalt/bindings/v8c/templates/interface.cc.template b/src/cobalt/bindings/v8c/templates/interface.cc.template
index a5dabfc..8d8736c 100644
--- a/src/cobalt/bindings/v8c/templates/interface.cc.template
+++ b/src/cobalt/bindings/v8c/templates/interface.cc.template
@@ -661,7 +661,7 @@
 {% endif %}
 
     // The location of the property is determined as follows:
-{% if attribute.is_static %}
+{% if attribute.on_interface %}
     // Operations installed on the interface object must be static methods, so
     // no need to specify a signature, i.e. no need to do type check against a
     // holder.
@@ -669,7 +669,7 @@
     // If the attribute is a static attribute, then there is a single
     // corresponding property and it exists on the interface's interface object.
     function_template->
-{% elif attribute.is_unforgeable or is_global_interface %}
+{% elif attribute.on_instance %}
     // Otherwise, if the attribute is unforgeable on the interface or if the
     // interface was declared with the [Global] extended attribute, then the
     // property exists on every object that implements the interface.
@@ -741,11 +741,11 @@
     method_template->SetLength({{operation.length}});
 
     // The location of the property is determined as follows:
-{% if operation.is_static %}
+{% if operation.on_interface %}
     // If the operation is static, then the property exists on the interface
     // object.
     function_template->
-{% elif operation.is_unforgeable or is_global_interface %}
+{% elif operation.on_instance %}
     // Otherwise, if the operation is unforgeable on the interface or if the
     // interface was declared with the [Global] extended attribute, then the
     // property exists on every object that implements the interface.
diff --git a/src/cobalt/build/build.id b/src/cobalt/build/build.id
index 8972928..6e8f51e 100644
--- a/src/cobalt/build/build.id
+++ b/src/cobalt/build/build.id
@@ -1 +1 @@
-185964
\ No newline at end of file
+186193
\ No newline at end of file
diff --git a/src/cobalt/dom/rule_matching.cc b/src/cobalt/dom/rule_matching.cc
index 736efae..86ae85b 100644
--- a/src/cobalt/dom/rule_matching.cc
+++ b/src/cobalt/dom/rule_matching.cc
@@ -600,12 +600,13 @@
   // |parent_nodes| and |matching_nodes|, as these two containers are kept in
   // sync.
   for (const auto& parent_node_to_remove : parent_nodes_to_remove) {
-    for (size_t index = 0; index < parent_nodes->size(); ++index) {
+    for (size_t index = 0; index < parent_nodes->size();) {
       if (parent_node_to_remove == (*parent_nodes)[index]) {
         node_removed = true;
         parent_nodes->erase(parent_nodes->begin() + index);
         matching_nodes->erase(matching_nodes->begin() + index);
-        break;
+      } else {
+        ++index;
       }
     }
   }
diff --git a/src/cobalt/media/base/drm_system.cc b/src/cobalt/media/base/drm_system.cc
index 5cf1eb6..6ac8145 100644
--- a/src/cobalt/media/base/drm_system.cc
+++ b/src/cobalt/media/base/drm_system.cc
@@ -207,8 +207,9 @@
 
 void DrmSystem::CloseSession(const std::string& session_id) {
   DCHECK(message_loop_->BelongsToCurrentThread());
-
+#if !SB_HAS(DRM_SESSION_CLOSED)
   id_to_session_map_.erase(session_id);
+#endif  // !SB_HAS(DRM_SESSION_CLOSED)
   SbDrmCloseSession(wrapped_drm_system_, session_id.c_str(), session_id.size());
 }
 
diff --git a/src/starboard/contrib/creator/README.md b/src/starboard/contrib/creator/README.md
index f6f57f0..6e66ee0 100644
--- a/src/starboard/contrib/creator/README.md
+++ b/src/starboard/contrib/creator/README.md
@@ -1,7 +1,7 @@
 # MIPS support
 
 starboard/contrib/creator directory contains port of Cobalt for Creator CI20 platform:
-https://creatordev.io/ci20.html
+https://www.elinux.org/MIPS_Creator_CI20
 
 
 # Building Cobalt for CI20
diff --git a/src/starboard/contrib/creator/shared/media_is_video_supported.cc b/src/starboard/contrib/creator/shared/media_is_video_supported.cc
index 67f03f3..1b13fa7 100644
--- a/src/starboard/contrib/creator/shared/media_is_video_supported.cc
+++ b/src/starboard/contrib/creator/shared/media_is_video_supported.cc
@@ -21,7 +21,12 @@
                                        int frame_width,
                                        int frame_height,
                                        int64_t bitrate,
-                                       int fps) {
+                                       int fps,
+                                       bool decode_to_texture_required) {
+  if (decode_to_texture_required) {
+    // There is no Creator CI20 360 video implementation.
+    return false;
+  }
   return video_codec == kSbMediaVideoCodecH264 && frame_width <= 1920 &&
          frame_height <= 1080 &&
          bitrate <= SB_MEDIA_MAX_VIDEO_BITRATE_IN_BITS_PER_SECOND && fps <= 30;
diff --git a/src/starboard/contrib/creator/shared/starboard_platform.gypi b/src/starboard/contrib/creator/shared/starboard_platform.gypi
index 0353a9e..c53674c 100644
--- a/src/starboard/contrib/creator/shared/starboard_platform.gypi
+++ b/src/starboard/contrib/creator/shared/starboard_platform.gypi
@@ -12,8 +12,12 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 {
+  'includes': [
+    '<(DEPTH)/starboard/shared/starboard/player/filter/player_filter.gypi',
+  ],
   'variables': {
     'starboard_platform_sources': [
+      '<@(filter_based_player_sources)',
       '<(DEPTH)/starboard/contrib/creator/shared/media_is_video_supported.cc',
       '<(DEPTH)/starboard/contrib/creator/shared/player_components_impl.cc',
       '<(DEPTH)/starboard/linux/shared/atomic_public.h',
@@ -247,38 +251,6 @@
       '<(DEPTH)/starboard/shared/starboard/new.cc',
       '<(DEPTH)/starboard/shared/starboard/player/decoded_audio_internal.cc',
       '<(DEPTH)/starboard/shared/starboard/player/decoded_audio_internal.h',
-      '<(DEPTH)/starboard/shared/starboard/player/filter/audio_decoder_internal.h',
-      '<(DEPTH)/starboard/shared/starboard/player/filter/audio_frame_tracker.cc',
-      '<(DEPTH)/starboard/shared/starboard/player/filter/audio_frame_tracker.h',
-      '<(DEPTH)/starboard/shared/starboard/player/filter/audio_time_stretcher.h',
-      '<(DEPTH)/starboard/shared/starboard/player/filter/audio_time_stretcher.cc',
-      '<(DEPTH)/starboard/shared/starboard/player/filter/audio_renderer_internal.cc',
-      '<(DEPTH)/starboard/shared/starboard/player/filter/audio_renderer_internal.h',
-      '<(DEPTH)/starboard/shared/starboard/player/filter/audio_renderer_sink.h',
-      '<(DEPTH)/starboard/shared/starboard/player/filter/audio_renderer_sink_impl.cc',
-      '<(DEPTH)/starboard/shared/starboard/player/filter/audio_renderer_sink_impl.h',
-      '<(DEPTH)/starboard/shared/starboard/player/filter/audio_resampler_impl.cc',
-      '<(DEPTH)/starboard/shared/starboard/player/filter/cpu_video_frame.cc',
-      '<(DEPTH)/starboard/shared/starboard/player/filter/cpu_video_frame.h',
-      '<(DEPTH)/starboard/shared/starboard/player/filter/decoded_audio_queue.h',
-      '<(DEPTH)/starboard/shared/starboard/player/filter/decoded_audio_queue.cc',
-      '<(DEPTH)/starboard/shared/starboard/player/filter/filter_based_player_worker_handler.cc',
-      '<(DEPTH)/starboard/shared/starboard/player/filter/filter_based_player_worker_handler.h',
-      '<(DEPTH)/starboard/shared/starboard/player/filter/media_time_provider.h',
-      '<(DEPTH)/starboard/shared/starboard/player/filter/media_time_provider_impl.cc',
-      '<(DEPTH)/starboard/shared/starboard/player/filter/media_time_provider_impl.h',
-      '<(DEPTH)/starboard/shared/starboard/player/filter/player_components.h',
-      '<(DEPTH)/starboard/shared/starboard/player/filter/punchout_video_renderer_sink.cc',
-      '<(DEPTH)/starboard/shared/starboard/player/filter/punchout_video_renderer_sink.h',
-      '<(DEPTH)/starboard/shared/starboard/player/filter/video_decoder_internal.h',
-      '<(DEPTH)/starboard/shared/starboard/player/filter/video_frame_internal.h',
-      '<(DEPTH)/starboard/shared/starboard/player/filter/video_render_algorithm.h',
-      '<(DEPTH)/starboard/shared/starboard/player/filter/video_render_algorithm_impl.cc',
-      '<(DEPTH)/starboard/shared/starboard/player/filter/video_render_algorithm_impl.h',
-      '<(DEPTH)/starboard/shared/starboard/player/filter/video_renderer_internal.cc',
-      '<(DEPTH)/starboard/shared/starboard/player/filter/video_renderer_internal.h',
-      '<(DEPTH)/starboard/shared/starboard/player/filter/wsola_internal.h',
-      '<(DEPTH)/starboard/shared/starboard/player/filter/wsola_internal.cc',
       '<(DEPTH)/starboard/shared/starboard/player/input_buffer_internal.cc',
       '<(DEPTH)/starboard/shared/starboard/player/input_buffer_internal.h',
       '<(DEPTH)/starboard/shared/starboard/player/job_queue.cc',
diff --git a/src/starboard/shared/directfb/application_directfb.cc b/src/starboard/shared/directfb/application_directfb.cc
index da8d63b..152bc31 100644
--- a/src/starboard/shared/directfb/application_directfb.cc
+++ b/src/starboard/shared/directfb/application_directfb.cc
@@ -459,7 +459,8 @@
       sigemptyset(&sigaction_config.sa_mask);
       sigaction_config.sa_flags = 0;
 
-      // Unblock SIGSEGV, which has been blocked earlier (perhaps by libdirectfb)
+      // Unblock SIGSEGV, which has been blocked earlier (perhaps by
+      // libdirectfb)
       sigset_t set;
       sigemptyset(&set);
       sigaddset(&set, SIGSEGV);
@@ -523,6 +524,9 @@
 
     SbInputData* data = new SbInputData();
     SbMemorySet(data, 0, sizeof(*data));
+#if SB_API_VERSION >= 10
+    data->timestamp = SbTimeGetMonotonicNow();
+#endif  // SB_API_VERSION >= 10
     data->window = window_;
     SB_DCHECK(SbWindowIsValid(data->window));
     data->type = (event.type == DIET_KEYPRESS ? kSbInputEventTypePress
diff --git a/src/starboard/shared/linux/dev_input/dev_input.cc b/src/starboard/shared/linux/dev_input/dev_input.cc
index ec46365..2ef71fb 100644
--- a/src/starboard/shared/linux/dev_input/dev_input.cc
+++ b/src/starboard/shared/linux/dev_input/dev_input.cc
@@ -892,6 +892,9 @@
 
   SbInputData* data = new SbInputData();
   SbMemorySet(data, 0, sizeof(*data));
+#if SB_API_VERSION >= 10
+  data->timestamp = SbTimeGetMonotonicNow();
+#endif  // SB_API_VERSION >= 10
   data->window = window;
   data->type = type;
   data->device_type = kSbInputDeviceTypeGamepad;
@@ -912,6 +915,9 @@
   SbInputData* data = new SbInputData();
   SbMemorySet(data, 0, sizeof(*data));
 
+#if SB_API_VERSION >= 10
+  data->timestamp = SbTimeGetMonotonicNow();
+#endif  // SB_API_VERSION >= 10
   data->window = window;
   data->type = kSbInputEventTypeMove;
   data->device_type = kSbInputDeviceTypeGamepad;
@@ -940,6 +946,9 @@
   SbInputData* data = new SbInputData();
   SbMemorySet(data, 0, sizeof(*data));
 
+#if SB_API_VERSION >= 10
+  data->timestamp = SbTimeGetMonotonicNow();
+#endif  // SB_API_VERSION >= 10
   data->window = window;
   data->type = type;
   data->device_type = kSbInputDeviceTypeTouchPad;
@@ -1120,6 +1129,9 @@
   SB_DCHECK(event.value <= 2);
   SbInputData* data = new SbInputData();
   SbMemorySet(data, 0, sizeof(*data));
+#if SB_API_VERSION >= 10
+  data->timestamp = SbTimeGetMonotonicNow();
+#endif  // SB_API_VERSION >= 10
   data->window = window_;
   data->type =
       (event.value == 0 ? kSbInputEventTypeUnpress : kSbInputEventTypePress);
diff --git a/src/starboard/shared/wayland/dev_input.cc b/src/starboard/shared/wayland/dev_input.cc
index 2531e5e..2a1e102 100644
--- a/src/starboard/shared/wayland/dev_input.cc
+++ b/src/starboard/shared/wayland/dev_input.cc
@@ -524,6 +524,9 @@
 void DevInput::CreateKey(int key, int state, bool is_repeat) {
   SbInputData* data = new SbInputData();
   SbMemorySet(data, 0, sizeof(*data));
+#if SB_API_VERSION >= 10
+  data->timestamp = SbTimeGetMonotonicNow();
+#endif  // SB_API_VERSION >= 10
   data->window = window_;
   data->type = (state == 0 ? kSbInputEventTypeUnpress : kSbInputEventTypePress);
   data->device_type = kSbInputDeviceTypeRemote;
diff --git a/src/starboard/shared/x11/application_x11.cc b/src/starboard/shared/x11/application_x11.cc
index b52f730..5d45828 100644
--- a/src/starboard/shared/x11/application_x11.cc
+++ b/src/starboard/shared/x11/application_x11.cc
@@ -1119,6 +1119,9 @@
 
   scoped_ptr<SbInputData> data(new SbInputData());
   SbMemorySet(data.get(), 0, sizeof(*data));
+#if SB_API_VERSION >= 10
+  data->timestamp = SbTimeGetMonotonicNow();
+#endif  // SB_API_VERSION >= 10
   data->window = windows_[0];
   SB_DCHECK(SbWindowIsValid(data->window));
   data->type = paste_buffer_key_release_pending_ ? kSbInputEventTypeUnpress
@@ -1184,6 +1187,9 @@
 
       scoped_ptr<SbInputData> data(new SbInputData());
       SbMemorySet(data.get(), 0, sizeof(*data));
+#if SB_API_VERSION >= 10
+      data->timestamp = SbTimeGetMonotonicNow();
+#endif  // SB_API_VERSION >= 10
       data->window = FindWindow(x_key_event->window);
       SB_DCHECK(SbWindowIsValid(data->window));
       data->type = x_event->type == KeyPress ? kSbInputEventTypePress
@@ -1211,6 +1217,9 @@
 #endif
       scoped_ptr<SbInputData> data(new SbInputData());
       SbMemorySet(data.get(), 0, sizeof(*data));
+#if SB_API_VERSION >= 10
+      data->timestamp = SbTimeGetMonotonicNow();
+#endif  // SB_API_VERSION >= 10
       data->window = FindWindow(x_button_event->window);
       SB_DCHECK(SbWindowIsValid(data->window));
       data->key = XButtonEventToSbKey(x_button_event);
@@ -1241,6 +1250,9 @@
       XMotionEvent* x_motion_event = reinterpret_cast<XMotionEvent*>(x_event);
       scoped_ptr<SbInputData> data(new SbInputData());
       SbMemorySet(data.get(), 0, sizeof(*data));
+#if SB_API_VERSION >= 10
+      data->timestamp = SbTimeGetMonotonicNow();
+#endif  // SB_API_VERSION >= 10
       data->window = FindWindow(x_motion_event->window);
       SB_DCHECK(SbWindowIsValid(data->window));
 #if SB_API_VERSION >= 6