Beispiel #1
0
        private void AuxOnLoad()
        {
            OnLoadBinding = new JsBinding()
            {
                Name = "vvvvUtils"
            };
            DocumentSizeBaseSelector = OnLoadBinding.AddFunction(new DocSizeBaseSelector
            {
                Selector = BrowserSettings.DocumentSizeElementSelector
            });

            ResizeNotification              = OnLoadBinding.AddFunction(new ResizeNotificationFunction());
            ResizeNotification.SizeChanged += (sender, args) =>
            {
                if (!TextureSettings.AutoWidth && !TextureSettings.AutoHeight)
                {
                    return;
                }
                UpdateSize();
            };

            BindObject(OnLoadBinding);
            foreach (var code in Globals.ScriptsFromOnloadFolder.Values)
            {
                ExecuteJavascript(code);
            }
        }
Beispiel #2
0
        public virtual CfrV8Value Invoke(CfrV8HandlerExecuteEventArgs args, JsBinding binding, HtmlTextureWrapper wrapper)
        {
            var res = Function(args, binding, wrapper);

            Invoked?.Invoke(this, wrapper);
            InvokeCount++;
            return(res);
        }
Beispiel #3
0
        public bool BindObject(JsBinding binding)
        {
            if (Closed)
            {
                return(false);
            }
            if (RemoteBrowser == null)
            {
                return(false);
            }
            try
            {
                var jsBinding = binding;
                if (JsBindings.ContainsKey(binding.Name))
                {
                    jsBinding = JsBindings[binding.Name];
                    jsBinding.MigrateFunctions(binding);
                }
                else
                {
                    JsBindings.Add(binding.Name, binding);
                }

                var remoteCallContext = RemoteBrowser.CreateRemoteCallContext();
                remoteCallContext.Enter();
                try
                {
                    V8Handler = new CfrV8Handler();
                    jsBinding.Bind(this, V8Handler);
                    var taskrunner = CfrTaskRunner.GetForThread((CfxThreadId)6);
                    if (taskrunner == null)
                    {
                        LogError("Unsuccessful Binding, TaskRunner is null");
                        remoteCallContext.Exit();
                        return(false);
                    }
                    taskrunner.PostTask(new BindFunctionsTask(RemoteBrowser, jsBinding.Name, jsBinding.Functions.Keys.ToArray(), V8Handler));
                    remoteCallContext.Exit();
                    return(true);
                }
                catch (Exception ex)
                {
                    remoteCallContext.Exit();
                    LogError(ex.Message);
                    VvvvLogger?.Log(ex);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                LogError(ex.Message);
                VvvvLogger?.Log(ex);
                return(false);
            }
        }
Beispiel #4
0
 protected override CfrV8Value Function(CfrV8HandlerExecuteEventArgs args, JsBinding binding, HtmlTextureWrapper wrapper)
 {
     Result = Arguments.Select(a =>
     {
         var res = new ResultFromJs
         {
             Result  = a.CfrV8ValueToString(),
             Results = a.CfrV8ValueToStringArray(),
             Error   = ""
         };
         return(res);
     }).ToArray();
     return(ReturnObject.V8Serialize());
 }
Beispiel #5
0
 protected abstract CfrV8Value Function(CfrV8HandlerExecuteEventArgs args, JsBinding binding, HtmlTextureWrapper wrapper);
Beispiel #6
0
 protected override CfrV8Value Function(CfrV8HandlerExecuteEventArgs args, JsBinding binding, HtmlTextureWrapper wrapper)
 {
     if (Arguments.Length >= 1 && Arguments[0].IsString)
     {
         Selector = Arguments[0].StringValue;
     }
     return(CfrV8Value.CreateString(Selector));
 }
Beispiel #7
0
 protected override CfrV8Value Function(CfrV8HandlerExecuteEventArgs args, JsBinding binding, HtmlTextureWrapper wrapper)
 {
     if (wrapper == null)
     {
         return(CfrV8Value.CreateNull());
     }
     if (Arguments.Length >= 2 && (Arguments[0].IsInt && Arguments[1].IsInt))
     {
         Width  = Arguments[0].IntValue;
         Height = Arguments[1].IntValue;
         wrapper.DocumentSize = (Width, Height);
         SizeChanged?.Invoke(this, wrapper);
     }
     return(CfrV8Value.CreateNull());
 }