Ejemplo n.º 1
0
        public static string GetEventHandlerAttr(mdr.DObject obj, string name)
        {
            var ehp = obj.GetPropertyDescriptor(name).GetProperty() as EventHandlerProperty;

            if (ehp == null)
            {
                throw new Exception("Invalid Event " + name);
            }
            return(GetEventHandlerAttr(obj, ehp.EventType, name));
        }
Ejemplo n.º 2
0
        public static void SetEventHandlerAttr(mdr.DObject obj, EventTypes type,
                                               string name, string script)
        {
            var targetElement = obj.FirstInPrototypeChainAs <HTMLElement>();

            targetElement.PrimSetEventHandlerAttr(type, script);
            var prgFunc = HTMLRuntime.Instance.PrepareScript(script);
            var pd      = obj.GetPropertyDescriptor(name);

            pd.Set(obj, prgFunc);
        }
Ejemplo n.º 3
0
        public static void SetEventHandlerAttr(mdr.DObject obj, string name, string script)
        {
#if ENABLE_RR
            if (RecordReplayManager.Instance != null && RecordReplayManager.Instance.RecordEnabled)
            {
                RecordReplayManager.Instance.Record("Element", null, "SetEventHandlerAttr", false, obj, name, script);
            }
#endif
            var ehp = obj.GetPropertyDescriptor(name).GetProperty() as EventHandlerProperty;
            if (ehp == null)
            {
                throw new Exception("Invalid Event " + name);
            }
            SetEventHandlerAttr(obj, ehp.EventType, name, script);
        }
Ejemplo n.º 4
0
        public static EventListeners GetEventListeners(mdr.DObject obj, string eventName)
        {
            Debug.Assert(obj != null, "invalid null object for adding event '{0}' listener", eventName);
            var pd = obj.GetPropertyDescriptor(eventName);

            Debug.Assert(pd != null, "cannot find property descriptor for event {0}", eventName);
            Debug.Assert(pd.IsAccessorDescriptor && pd.IsInherited, "invalid property descriptor type {0} for event {1}", pd.GetAttributes(), eventName);
            // Debug.Assert(pd.IsAccessorDescriptor, "invalid property discriptor type {0} for event {1}", pd.GetAttributes(), eventName);
            var eventHandler = pd.GetProperty() as EventHandlerProperty;

            Debug.Assert(eventHandler != null, "invalid event handler at index {0}", pd.Index);
            var eventTarget = obj as EventTarget;

            Debug.Assert(eventTarget != null, "Invalid event target object type {0}", obj.GetType().FullName);
            if (eventHandler == null || eventTarget == null)
            {
                return(null);
            }
            var eventListeners = eventTarget.GetEventListeners(eventHandler.EventType, true);

            return(eventListeners);
        }