Beispiel #1
0
        public static JSEvent createEvent(string eventClassString, WrappedObject target)
        {
            JSEvent      evt        = null;
            EventClasses eventClass = EventClasses.Event;

            if (eventClassString == "Event")
            {
                eventClass = EventClasses.Event;
            }
            else if (eventClassString == "UIEvent")
            {
                eventClass = EventClasses.UIEvent;
            }
            else if (eventClassString == "MouseEvent")
            {
                eventClass = EventClasses.MouseEvent;
            }
            else
            {
                //Throw Unsupported error exception according to W3C createEvent documentation
            }
            evt = new JSEvent();
            evt.InitializeCreatedEvent(eventClass, target);

            return(evt);
        }
Beispiel #2
0
        /*
         * // This isn't compiling since we've moved away from using WrapperType.
         * // I'd update it, but apparently nobody is actually calling it. - SF
         * internal mdr.PropertyMap GetPropertyMapOfDomPrototype(WrapperType domClass)
         * {
         *  var mapIndex = (int)domClass;
         *  var map = _maps[mapIndex];
         *  if (map == null)
         *  {
         *      var prototype = DOMBinder.GetPrototype(mapIndex);
         *      map = GetRootMapOfPrototype(prototype);
         *      _maps[mapIndex] = map;
         *  }
         *  return map;
         * }
         */
        public mdr.PropertyMap GetPropertyMapOfEventPrototype(EventClasses eventClass)
        {
            var mapIndex = /*(int) WrapperType.LastWrapperType + */ (int)eventClass;
            var map      = _maps[mapIndex];

            if (map == null)
            {
                var prototype = JSEvent.GetPrototype(eventClass);
                map             = GetRootMapOfPrototype(prototype);
                _maps[mapIndex] = map;
            }
            return(map);
        }
Beispiel #3
0
        public static JSEvent createEvent(string eventClassString, WrappedObject target)
        {
            JSEvent evt = null;
            EventClasses eventClass = EventClasses.Event;
            if (eventClassString == "Event")
            {
                eventClass = EventClasses.Event;
            }
            else if (eventClassString == "UIEvent")
            {
                eventClass = EventClasses.UIEvent;
            }
            else if (eventClassString == "MouseEvent")
            {
                eventClass = EventClasses.MouseEvent;
            }
            else
            {
                //Throw Unsupported error exception according to W3C createEvent documentation
            }
            evt = new JSEvent();
            evt.InitializeCreatedEvent(eventClass, target);

            return evt;
        }
Beispiel #4
0
        public bool ProcessEvents(IntPtr filterPtr)
        {
            //Debug.Assert(filterPtr != IntPtr.Zero, "filterPtr is not valid");
#if ENABLE_RR
            if (RecordReplayManager.Instance.RecordEnabled)
            {
                RecordReplayManager.Instance.Record("HTMLRuntime", null, "ProcessEvents", false, filterPtr.ToInt64());
            }
#endif
            var filter = new DOM.EventFilter(filterPtr);
            while (true)
            {
                try
                {
                  Debug.WriteLine("**** MEM USAGE = {0} bytes, GC collection counts: G0={1}, G1={2}, G2={3}", System.GC.GetTotalMemory(false), System.GC.CollectionCount(0), System.GC.CollectionCount(1), System.GC.CollectionCount(2));
                //Process timer queue here and find the nextActiveTimer
                    var epoch = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
                    var nextActiveTimer = TimerQueue.NextActivationTime();
                    var span = nextActiveTimer - epoch;
                    var curr = nextActiveTimer - DateTime.UtcNow;
                    Debug.WriteLine("Requested next wakeup time " + curr.Ticks + " ticks which is " + curr.Ticks / (10000) + " miliSec ");

                    var nextWakeuptime = (UInt64) span.Ticks; //C++ will convert ticks (1 / 100 ns) to (sec, ns)
                    var ev = new JSEvent();
                    Debug.WriteLine("Asking for next event");
#if ENABLE_RR
                    if (RecordReplayManager.Instance.ReplayEnabled)
                    {
                        RecordReplayManager.Instance.OutputBindingReplay("Page", "GetNextEvent", ev.Data, nextWakeuptime);
                        ev.Data = RecordReplayManager.Instance.EventData;
                    }
                    else
                        if (RecordReplayManager.Instance.RecordEnabled)
                        {
                            _page.GetNextEvent(filter, ref ev.Data, nextWakeuptime);
                            RecordReplayManager.Instance.Record("Page", null, "GetNextEvent", true, ev.Data, nextWakeuptime);
                        }
                        else
                        {
                            _page.GetNextEvent(filter, ref ev.Data, nextWakeuptime);
                        }
#else
                    _page.GetNextEvent(filter, ref ev.Data, nextWakeuptime);
#endif


                    Debug.WriteLine("Event type={0} event screenX/Y ({1} {2}) clientX/Y ({3} {4})", ev.Data.Type,
                        ev.Data.screenX, ev.Data.screenY, ev.Data.clientX, ev.Data.clientY);
                    switch (ev.Data.Type)
                    {//we handle special cases right here!
                        case EventTypes.ZoommTimeout:
                        case EventTypes.ZoommUnpaused:
                          {
                            var timer = StartTimer(Configuration.ProfileTimerTime, "JS/Event/Timer");
                            
                            TimerQueue.ProcessEvents();
                            
                            StopTimer(timer);
                            break;
                          }
                        case EventTypes.ZoommStop:
                            Debug.WriteLine("Exiting ProcessEvents loop!");
                            return true;
                        case EventTypes.ZoommYield:
                            Debug.WriteLine("ProcessEvents yielding back to caller");
                            return false;
                        default:
                          {
                            var timer = StartTimer(Configuration.ProfileTimerTime, "JS/Event/" + ev.Data.Type.ToString());

                            //Now we have a valid DOMEvent
                            Debug.WriteLine("Start processing the event!");
                            ev.CurrentTarget = ev.Data.Target;
                            ev.Target = ev.Data.Target;
                            ev.InitializeEventFlags();
                            if (ev.Data.Type == EventTypes.Load && ev.CurrentTarget == GlobalContext)
                            {
                                if (_pageLoaded)
                                {
                                    Console.Out.WriteLine("Recieving multiple onload events!\n Aborting!");
                                    throw (new InvalidProgramException("Recieving multiple onload events!\n Aborting!"));
                                }
                                _pageLoaded = true;
                            }
                            Debug.Assert(ev.Data.Type < EventTypes.ZoommEmpty, "Invalid dome event type {0}", ev.Data.Type);
                            Debug.Assert(ev.Data.Target != null, "DOM event has no target!");
                            ev.UpdateMap(); //To make sure we have the right prototype chain and event property setup
                            ev.Dispatch();
                            Debug.WriteLine("Dispatch completed!");

                            StopTimer(timer);
                            break;
                          }
                    }
                    _page.CleanupAfterScript();
                }
#if ENABLE_RR
                catch (mwr.RecordReplayManager.RRException ex)
                {
                    throw (ex);
                }
#endif
                catch (mjr.JSException e)
                {
                  WriteJSException(e);
                }
                catch (Exception ex)
                {
                  Diagnostics.WriteException(ex, "when processing event");
                }
            }
        }
Beispiel #5
0
        public bool ProcessEvents(IntPtr filterPtr)
        {
            //Debug.Assert(filterPtr != IntPtr.Zero, "filterPtr is not valid");
#if ENABLE_RR
            if (RecordReplayManager.Instance.RecordEnabled)
            {
                RecordReplayManager.Instance.Record("HTMLRuntime", null, "ProcessEvents", false, filterPtr.ToInt64());
            }
#endif
            var filter = new DOM.EventFilter(filterPtr);
            while (true)
            {
                try
                {
                    Debug.WriteLine("**** MEM USAGE = {0} bytes, GC collection counts: G0={1}, G1={2}, G2={3}", System.GC.GetTotalMemory(false), System.GC.CollectionCount(0), System.GC.CollectionCount(1), System.GC.CollectionCount(2));
                    //Process timer queue here and find the nextActiveTimer
                    var epoch           = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
                    var nextActiveTimer = TimerQueue.NextActivationTime();
                    var span            = nextActiveTimer - epoch;
                    var curr            = nextActiveTimer - DateTime.UtcNow;
                    Debug.WriteLine("Requested next wakeup time " + curr.Ticks + " ticks which is " + curr.Ticks / (10000) + " miliSec ");

                    var nextWakeuptime = (UInt64)span.Ticks;  //C++ will convert ticks (1 / 100 ns) to (sec, ns)
                    var ev             = new JSEvent();
                    Debug.WriteLine("Asking for next event");
#if ENABLE_RR
                    if (RecordReplayManager.Instance.ReplayEnabled)
                    {
                        RecordReplayManager.Instance.OutputBindingReplay("Page", "GetNextEvent", ev.Data, nextWakeuptime);
                        ev.Data = RecordReplayManager.Instance.EventData;
                    }
                    else
                    if (RecordReplayManager.Instance.RecordEnabled)
                    {
                        _page.GetNextEvent(filter, ref ev.Data, nextWakeuptime);
                        RecordReplayManager.Instance.Record("Page", null, "GetNextEvent", true, ev.Data, nextWakeuptime);
                    }
                    else
                    {
                        _page.GetNextEvent(filter, ref ev.Data, nextWakeuptime);
                    }
#else
                    _page.GetNextEvent(filter, ref ev.Data, nextWakeuptime);
#endif


                    Debug.WriteLine("Event type={0} event screenX/Y ({1} {2}) clientX/Y ({3} {4})", ev.Data.Type,
                                    ev.Data.screenX, ev.Data.screenY, ev.Data.clientX, ev.Data.clientY);
                    switch (ev.Data.Type)
                    {//we handle special cases right here!
                    case EventTypes.ZoommTimeout:
                    case EventTypes.ZoommUnpaused:
                    {
                        var timer = StartTimer(Configuration.ProfileTimerTime, "JS/Event/Timer");

                        TimerQueue.ProcessEvents();

                        StopTimer(timer);
                        break;
                    }

                    case EventTypes.ZoommStop:
                        Debug.WriteLine("Exiting ProcessEvents loop!");
                        return(true);

                    case EventTypes.ZoommYield:
                        Debug.WriteLine("ProcessEvents yielding back to caller");
                        return(false);

                    default:
                    {
                        var timer = StartTimer(Configuration.ProfileTimerTime, "JS/Event/" + ev.Data.Type.ToString());

                        //Now we have a valid DOMEvent
                        Debug.WriteLine("Start processing the event!");
                        ev.CurrentTarget = ev.Data.Target;
                        ev.Target        = ev.Data.Target;
                        ev.InitializeEventFlags();
                        if (ev.Data.Type == EventTypes.Load && ev.CurrentTarget == GlobalContext)
                        {
                            if (_pageLoaded)
                            {
                                Console.Out.WriteLine("Recieving multiple onload events!\n Aborting!");
                                throw (new InvalidProgramException("Recieving multiple onload events!\n Aborting!"));
                            }
                            _pageLoaded = true;
                        }
                        Debug.Assert(ev.Data.Type < EventTypes.ZoommEmpty, "Invalid dome event type {0}", ev.Data.Type);
                        Debug.Assert(ev.Data.Target != null, "DOM event has no target!");
                        ev.UpdateMap();     //To make sure we have the right prototype chain and event property setup
                        ev.Dispatch();
                        Debug.WriteLine("Dispatch completed!");

                        StopTimer(timer);
                        break;
                    }
                    }
                    _page.CleanupAfterScript();
                }
#if ENABLE_RR
                catch (mwr.RecordReplayManager.RRException ex)
                {
                    throw (ex);
                }
#endif
                catch (mjr.JSException e)
                {
                    WriteJSException(e);
                }
                catch (Exception ex)
                {
                    Diagnostics.WriteException(ex, "when processing event");
                }
            }
        }