Example #1
0
        /// <summary>
        /// Attaching and dettaching nodes into the WrappedObject tree.
        /// This tree reflects the parent/child relation between the DOM node in the C++ side and is used for communication between the two side
        /// </summary>
        public void SetParent(WrappedObject newParent)
        {
            // If there hasn't been a change, do nothing
            if (newParent == Parent)
            {
                return;
            }

            // Remove self from children of existing parent, if any
            if (Parent != null)
            {
                Parent.Children.Remove(this);
            }

            // Record new parent (we are detaching ourselves if new parent is null)
            Parent = newParent;

            // If new parent is non-null, update its child list
            if (Parent != null)
            {
                Parent.Children.Add(this);
            }
#if ENABLE_RR
            if (mwr.RecordReplayManager.Instance != null && mwr.RecordReplayManager.Instance.RecordEnabled)
            {
                RecordReplayManager.Instance.Record("WrappedObject", null, "SetParent", false, this, newParent);
            }
#endif
        }
 /// <summary>
 /// Specialized replay for SetParent
 /// </summary>
 /// <param name="currentInstance"></param>
 /// <param name="currentReplayInstanceIndex"></param>
 private void ReplayWrappedObjectSetParent(BindingInstance currentInstance, int currentReplayInstanceIndex)
 {
     if (currentInstance.Parameters.Length >= 1)
     {
         DOM.WrappedObject wobj = currentInstance.Parameters[0] as DOM.WrappedObject;
         DOM.WrappedObject parentWobj;
         if (currentInstance.Parameters.Length == 2)
         {
             parentWobj = currentInstance.Parameters[1] as DOM.WrappedObject;
         }
         else
         {
             parentWobj = null;
         }
         if (parentWobj != null)
         {
             wobj.SetParent(parentWobj);
         }
     }
     else
     {
         string exceptionString = "Replaying binding instance " + currentReplayInstanceIndex + " error : SetParent requies at least two arguments!";
         ReplayStateConsistent = false;
         throw new RRException(exceptionString);
     }
 }
        /// <summary>
        /// Specialized replay for WrappedObject ctor
        /// </summary>
        /// <param name="currentInstance"></param>
        /// <param name="currentReplayInstanceIndex"></param>
        private void ReplayWrappedObjectCtor(BindingInstance currentInstance, int currentReplayInstanceIndex)
        {
            Type type = System.Reflection.Assembly.GetExecutingAssembly().GetType((string)currentInstance.Parameters[1]);

            if (type != null)
            {
                //Using reflection to call the correct DOMWrapper object
                Type[]            cArgTypes = { typeof(IntPtr) };
                ConstructorInfo   cInfo     = type.GetConstructor(cArgTypes);
                DOM.WrappedObject wobj      = null;
                if (cInfo != null)
                {
                    IntPtr   intPtr = new IntPtr(0);
                    object[] cArgs  = { intPtr };
                    wobj = cInfo.Invoke(cArgs) as DOM.WrappedObject;
                    if (wobj != null)
                    {
                        _recordReplayWrapperPtrMap.Add((long)currentInstance.Parameters[0], wobj);
                    }
                }
            }
            else
            {
                string exceptionString = "Replaying binding instance " + currentReplayInstanceIndex + " error : type of recorded WrapperObject ctor is unknown";
                ReplayStateConsistent = false;

                throw new RRException(exceptionString);
            }
        }
 public WrappedObjectRecordProxy(DOM.WrappedObject wobj)
 {
     if (wobj != null)
     {
         WrappedTypeString = wobj.GetType().ToString();
         DomID             = wobj.Domptr.ToInt64();
     }
 }
 //Converting a wrapped id to a wrapped object in the replay mode (wrapped ids remain the same between record replay)
 static public DOM.WrappedObject ConvertPtrIDToWrapper(long id)
 {
     DOM.WrappedObject value = null;
     if (_recordReplayWrapperPtrMap.TryGetValue(id, out value))
     {
         return(value);
     }
     return(null);
 }
Example #6
0
        /// <summary>
        /// Constructs a wrapper in the managed world for a DOM/CSS node residing in the unmanaged world
        /// </summary>
        /// <param name="domptr">pointer to a DOM/CSS object in the unmanaged world</param>
        public WrappedObject(IntPtr objPtr)
            : base(mdr.Runtime.Instance.EmptyPropertyMapMetadata.Root)
        {
            Map      = HTMLRuntime.Instance.GetPropertyMapOfWrappedObjectType(this.GetType());
            Domptr   = objPtr;
            Parent   = null;
            Children = new HashSet <WrappedObject>();
#if ENABLE_RR
            if (mwr.RecordReplayManager.Instance != null && mwr.RecordReplayManager.Instance.RecordEnabled)
            {
                RecordReplayManager.Instance.Record("WrappedObject", null, "ctor", false, objPtr.ToInt64(), GetType().ToString());
            }
#endif
        }
Example #7
0
        /// <summary>
        /// Constructs a wrapper in the managed world for a DOM/CSS node residing in the unmanaged world
        /// </summary>
        /// <param name="domptr">pointer to a DOM/CSS object in the unmanaged world</param>
        public WrappedObject(IntPtr objPtr)
            : base(mdr.Runtime.Instance.EmptyPropertyMapMetadata.Root) 
        {
            Map = HTMLRuntime.Instance.GetPropertyMapOfWrappedObjectType(this.GetType());
            Domptr = objPtr;
            Parent = null;
            Children = new HashSet<WrappedObject>();
#if ENABLE_RR
            if (mwr.RecordReplayManager.Instance != null && mwr.RecordReplayManager.Instance.RecordEnabled)
            {
                RecordReplayManager.Instance.Record("WrappedObject", null, "ctor", false, objPtr.ToInt64(), GetType().ToString());

            }
#endif
        }
Example #8
0
        /// <summary>
        /// Attaching and dettaching nodes into the WrappedObject tree. 
        /// This tree reflects the parent/child relation between the DOM node in the C++ side and is used for communication between the two side
        /// </summary>
        public void SetParent(WrappedObject newParent)
        {
            // If there hasn't been a change, do nothing
            if (newParent == Parent)
              return;

            // Remove self from children of existing parent, if any
            if (Parent != null)
              Parent.Children.Remove(this);

            // Record new parent (we are detaching ourselves if new parent is null)
            Parent = newParent;

            // If new parent is non-null, update its child list
            if (Parent != null)
              Parent.Children.Add(this);
#if ENABLE_RR
            if (mwr.RecordReplayManager.Instance != null && mwr.RecordReplayManager.Instance.RecordEnabled)
            {
                RecordReplayManager.Instance.Record("WrappedObject", null, "SetParent", false, this, newParent);

            }
#endif
        }
Example #9
0
 public static JSException CreateException(WrappedObject inner)
 {
   return new JSException(inner);
 }
Example #10
0
 /// <summary>
 /// Functions called by the C++ side to generate and maintain the wrapper tree in the JS engine        
 /// </summary>
 public static void SetParent(WrappedObject child, WrappedObject newParent)
 {
     child.SetParent(newParent);
 }
Example #11
0
        public bool Dispatch()
        {
            //Initializing event progress flags
            PropagationStopped = false;
            ImmediatePropagationStopped = false;
            DefaultPrevented = false;
            var eventTarget = CurrentTarget as DOM.EventTarget;
             if (eventTarget != null)
            {
                Debug.WriteLine("TARGET = " + eventTarget.ToString());
            }
            else
            {
                Debug.WriteLine("TARGET IS NULL");
            }

            Phase = JSEvent.Phases.AtTarget;
            bool eventBubblingCancelled = false;
            if (eventTarget != null)
            {
                var eventListeners = eventTarget.GetEventListeners(Data.Type, false);
                if (eventListeners != null)
                    eventBubblingCancelled = eventListeners.HandleEvent(this);
                if (eventListeners == null)
                {
                    Debug.WriteLine("Listener list is null!");
                }

                CurrentTarget = eventTarget.Parent as DOM.EventTarget;
            }
            //Implementing bubbling accroding to HTML Spec (Document Object Model Events section 1.2.3). 
            if (this.Bubbles && eventTarget != null)
            {
                Debug.WriteLine("EVENT BUBBLING");
                //Bubbling loop (outer loop)
                Phase = JSEvent.Phases.Bubbling;

                var bubllingTargetList = new List<DOM.EventTarget>();
                var tempTarget = eventTarget.Parent as DOM.EventTarget;
                while (tempTarget != null)
                {
                    bubllingTargetList.Add(tempTarget);
                    tempTarget = tempTarget.Parent as DOM.EventTarget;
                }
                for (int i = 0; (i < bubllingTargetList.Count) && (!eventBubblingCancelled); i++)
                {
                    CurrentTarget = bubllingTargetList[i];
                    tempTarget = CurrentTarget as DOM.EventTarget;
                    if (tempTarget != null)
                    {
                        Debug.WriteLine("curr TARGET = " + CurrentTarget.ToString());
                    }
                    var eventListeners = tempTarget.GetEventListeners(Data.Type, false);
                    if (eventListeners != null)
                        eventBubblingCancelled = eventListeners.HandleEvent(this);

                    CurrentTarget = CurrentTarget.Parent;
                }

            }

            bool cancelled = (DefaultPrevented && Cancelable);
            if (hasDefaultAction)
            {
                if (!cancelled)
                {
                    Debug.WriteLine("Performing default action!");
                    DefaultAction();
                }
                else
                {
                    Debug.WriteLine("Ignoring the default action as event Cancelable is {0} and cancelled flag is {1}", Cancelable, cancelled);
                }
            
            }

            //According to SPEC the return value is false if the default action is cancelled
            return cancelled;
        }
Example #12
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;
        }
Example #13
0
 public void InitializeCreatedEvent(EventClasses eventClass, WrappedObject target)
 {
     Data.EventClass = eventClass;
     Data.Type = EventTypes.ZoommInvalid;
     Data.Target = target;
     CurrentTarget = target;
     Bubbles = false;
     Cancelable = true;
     DefaultPrevented = false;
     IsTrusted = false;
     Phase = Phases.AtTarget;
     InitializeEventFlags();
     UpdateMap();
 }