示例#1
0
        // Sends an event called |event_name| to javascript, with an event.detail that contains
        // the fields and values of the |detail| structure.
        public void DispatchToJS(JSEvent e)
        {
            JObject ev = new JObject();

            ev["type"]   = e.EventName();
            ev["detail"] = JObject.FromObject(e);
            DispatchEvent(ev);
        }
示例#2
0
 // Sends an event called |event_name| to javascript, with an event.detail that contains
 // the fields and values of the |detail| structure.
 public void DispatchToJS(JSEvent e) {
   dispatch_string_builder_.Append("document.dispatchEvent(new CustomEvent('");
   dispatch_string_builder_.Append(e.EventName());
   dispatch_string_builder_.Append("', { detail: ");
   dispatch_serializer_.Serialize(dispatch_json_writer_, e);
   dispatch_string_builder_.Append(" }));");
   this.Overlay.Renderer.ExecuteScript(dispatch_string_builder_.ToString());
   dispatch_string_builder_.Clear();
 }
示例#3
0
 // Sends an event called |event_name| to javascript, with an event.detail that contains
 // the fields and values of the |detail| structure.
 public void DispatchToJS(JSEvent e)
 {
     // DispatchToJS can be called from multiple threads (both fast and main).
     // OverlayMessage also calls this, which can be on other threads as well.
     // Could consider adding per-thread builders in TLS to avoid a lock, but maybe overkill.
     lock (this.dispatch_lock_) {
         dispatch_string_builder_.Append("document.dispatchEvent(new CustomEvent('");
         dispatch_string_builder_.Append(e.EventName());
         dispatch_string_builder_.Append("', { detail: ");
         dispatch_serializer_.Serialize(dispatch_json_writer_, e);
         dispatch_string_builder_.Append(" }));");
         this.Overlay.Renderer.ExecuteScript(dispatch_string_builder_.ToString());
         dispatch_string_builder_.Clear();
     }
 }