diff --git a/Runtime/ChromeDevtools/BrowserTab.cs b/Runtime/ChromeDevtools/BrowserTab.cs index 0dc5ea47d01d5f9aedfdce2e641167ddd7a400ff..ca04f7cd06a22d9585f511984949ff9fdf27c0c9 100644 --- a/Runtime/ChromeDevtools/BrowserTab.cs +++ b/Runtime/ChromeDevtools/BrowserTab.cs @@ -116,7 +116,7 @@ namespace bessw.Unity.WebView.ChromeDevTools } /// <summary> - /// Adds a mathod with the given name that takes a string as argument to the browser's js runtime, and calls the given handler when the method is called. + /// Adds a method with the given name that takes a string as argument to the browser's js runtime, and calls the given handler when the method is called. /// </summary> /// <param name="name"></param> /// <param name="handler"></param> diff --git a/Runtime/ChromeDevtools/DevtoolsProtocolHandler.cs b/Runtime/ChromeDevtools/DevtoolsProtocolHandler.cs index aa2bcb434ccfd8eef1e6ac0d7462725826c0e30e..56866a0b82604f0eed9bd991deedbdaf67baf323 100644 --- a/Runtime/ChromeDevtools/DevtoolsProtocolHandler.cs +++ b/Runtime/ChromeDevtools/DevtoolsProtocolHandler.cs @@ -65,21 +65,21 @@ namespace bessw.Unity.WebView.ChromeDevTools break; } - var mesgStr = task.GetAwaiter().GetResult(); - Debug.Log($"ws reseived: '{mesgStr}'"); - ParseMessage(mesgStr); + var msgStr = task.GetAwaiter().GetResult(); + Debug.Log($"ws received: '{msgStr}'"); + ParseMessage(msgStr); } } /// <summary> /// Parses devtools the message, detects if its a command response or an event and calls the corresponding handler. /// </summary> - /// <param name="mesgStr"></param> + /// <param name="msgStr"></param> /// <exception cref="UnexpectedMessageException"></exception> - private void ParseMessage(string mesgStr) + private void ParseMessage(string msgStr) { // deserialize the devtools response wrapper - var message = JObject.Parse(mesgStr); + var message = JObject.Parse(msgStr); if (message.ContainsKey("id")) { @@ -91,7 +91,7 @@ namespace bessw.Unity.WebView.ChromeDevTools } else { - throw new UnexpectedMessageException(mesgStr); + throw new UnexpectedMessageException(msgStr); } } @@ -215,7 +215,7 @@ namespace bessw.Unity.WebView.ChromeDevTools /// json serializes and sends a command over the devtools websocket /// </summary> /// <typeparam name="C">IDevtoolsCommand</typeparam> - /// <returns>Task that resoves then the command is send</returns> + /// <returns>Task that resolves when the command is send</returns> public Task<DevtoolsResponse> SendCommandAsync<C>(C command) where C : IDevtoolsCommand => SendCommandAsync<C, DevtoolsResponse>(command); /// <summary> @@ -224,7 +224,7 @@ namespace bessw.Unity.WebView.ChromeDevTools /// <typeparam name="C">IDevtoolsCommandWithResponse</typeparam> /// <typeparam name="R">IDevtoolsResponse</typeparam> /// <param name="command"></param> - /// <returns>Task that resoves with the response</returns> + /// <returns>Task that resolves with the response</returns> public Task<R> SendCommandAsync<C, R>(C command) where C : IDevtoolsCommand where R : class, IDevtoolsResponse { // apply the message wrapper diff --git a/Runtime/ChromeDevtools/DevtoolsWebsocket.cs b/Runtime/ChromeDevtools/DevtoolsWebsocket.cs index b6565d6db24a1a39001269e78c3873f18e2067b7..b0acb780dc044ad2672439bc3d3a4804b2bb1dae 100644 --- a/Runtime/ChromeDevtools/DevtoolsWebsocket.cs +++ b/Runtime/ChromeDevtools/DevtoolsWebsocket.cs @@ -35,7 +35,7 @@ namespace bessw.Unity.WebView.ChromeDevTools } /// <summary> - /// Experimential! synchronisation with Unity coroutines is not jet implemented. Call ReadAsync from a coroutine instead. + /// Experimental! Synchronisation with Unity coroutines is not jet implemented. Call ReadAsync from a coroutine instead. /// </summary> /// <returns></returns> [Obsolete] @@ -57,7 +57,7 @@ namespace bessw.Unity.WebView.ChromeDevTools { WebSocketReceiveResult result; - /* A part of the message will be read into the message buffer and than be transfered + /* A part of the message will be read into the message buffer and than be transferred * to the MemoryStream. This will be repeated until the complete message has been received. */ do @@ -86,7 +86,7 @@ namespace bessw.Unity.WebView.ChromeDevTools /// Sends a json serialized command over the devtools websocket /// </summary> /// <param name="command"></param> - /// <returns>Task that resoves then the command is send</returns> + /// <returns>Task that resolves when the command is send</returns> public Task SendCommandAsync(string command) { // check that the websocket is open diff --git a/Runtime/ChromeDevtools/DomNodeWrapper.cs b/Runtime/ChromeDevtools/DomNodeWrapper.cs index 5f367ee351e3f0ec7a6dc6700979c6d0c4960e9a..e900336114dc693359c7f3c32422442dbe349454 100644 --- a/Runtime/ChromeDevtools/DomNodeWrapper.cs +++ b/Runtime/ChromeDevtools/DomNodeWrapper.cs @@ -29,7 +29,7 @@ namespace bessw.Unity.WebView.ChromeDevTools } /// <summary> - /// The `Node`object returend by the browser + /// The `Node`object returned by the browser /// </summary> /// <remarks>May be null if it has not jet been requested from the browser</remarks> public Node Node { get; protected set; } @@ -91,7 +91,7 @@ namespace bessw.Unity.WebView.ChromeDevTools domNode.Node.attributes[eventData.name] = eventData.value; domNode.OnAttributeModified?.Invoke(eventData); } else { - throw new InvalidOperationException("AttributeModified event was fired, the node info has not yet been recieved"); + throw new InvalidOperationException("AttributeModified event was fired, the node info has not yet been received"); } } @@ -103,7 +103,7 @@ namespace bessw.Unity.WebView.ChromeDevTools domNode.Node.attributes.Remove(eventData.name); domNode.OnDomAttributeRemoved?.Invoke(eventData); } else { - throw new InvalidOperationException("AttributeRemoved event was fired, the node info has not yet been recieved"); + throw new InvalidOperationException("AttributeRemoved event was fired, the node info has not yet been received"); } } @@ -115,7 +115,7 @@ namespace bessw.Unity.WebView.ChromeDevTools domNode.Node.nodeValue = eventData.characterData; domNode.OnDomCharacterDataModified?.Invoke(eventData); } else { - throw new InvalidOperationException("CharacterDataModified event was fired, the node info has not yet been recieved"); + throw new InvalidOperationException("CharacterDataModified event was fired, the node info has not yet been received"); } } @@ -127,7 +127,7 @@ namespace bessw.Unity.WebView.ChromeDevTools domNode.Node.childNodeCount = eventData.childNodeCount; domNode.OnDomChildNodeCountUpdated?.Invoke(eventData); } else { - throw new InvalidOperationException("ChildNodeCountUpdated event was fired, the node info has not yet been recieved"); + throw new InvalidOperationException("ChildNodeCountUpdated event was fired, the node info has not yet been received"); } } @@ -141,7 +141,7 @@ namespace bessw.Unity.WebView.ChromeDevTools parentNode.Node.children.Insert(idx, childNode.Node); parentNode.OnDomChildNodeInserted?.Invoke(eventData); } else { - throw new InvalidOperationException("ChildNodeInserted event was fired, the node info has not yet been recieved"); + throw new InvalidOperationException("ChildNodeInserted event was fired, the node info has not yet been received"); } } @@ -156,7 +156,7 @@ namespace bessw.Unity.WebView.ChromeDevTools parentNode.Node.children.Remove(childNode.Node); parentNode.OnDomChildNodeRemoved?.Invoke(eventData); } else { - //throw new InvalidOperationException("ChildNodeRemoved event was fired, the node info has not yet been recieved"); + //throw new InvalidOperationException("ChildNodeRemoved event was fired, the node info has not yet been received"); } } @@ -172,7 +172,7 @@ namespace bessw.Unity.WebView.ChromeDevTools parentNode.Node.children = new(eventData.nodes); parentNode.OnDomSetChildNodes?.Invoke(eventData); } else { - throw new InvalidOperationException("SetChildNodes event was fired, the node info has not yet been recieved"); + throw new InvalidOperationException("SetChildNodes event was fired, the node info has not yet been received"); } } @@ -546,7 +546,7 @@ namespace bessw.Unity.WebView.ChromeDevTools /// Get the root node of the document, the root node is returned as an argument to the callback. /// </summary> /// <param name="tab"></param> - /// <param name="callback">The callback recieves the root node as argument</param> + /// <param name="callback">The callback receives the root node as argument</param> /// <returns><see cref="DomNodeWrapper"/></returns> public static IEnumerator getDocument(BrowserTab tab, Action<DomNodeWrapper> callback) { @@ -570,7 +570,7 @@ namespace bessw.Unity.WebView.ChromeDevTools /// Describes the node, does not require domain to be enabled. Does not start tracking any /// objects, can be used for automation. /// </summary> - /// <param name="callback">The callback recieves the node as argument</param> + /// <param name="callback">The callback receives the node as argument</param> public IEnumerator describeNode(Action<Node> callback, int? depth = null, bool? pierce = null) { var describeNodeCommand = new describeNode @@ -608,10 +608,10 @@ namespace bessw.Unity.WebView.ChromeDevTools }; return tab.devtools.SendCommand(attributesCommand, (response) => { - var attibutes = ((getAttributesCommandResponse)response).attributes; - tab.domNodes[NodeId].Node.attributes = attibutes; + var attributes = ((getAttributesCommandResponse)response).attributes; + tab.domNodes[NodeId].Node.attributes = attributes; - callback(attibutes); + callback(attributes); }); } diff --git a/Runtime/ChromeDevtools/IDevtoolsConnection.cs b/Runtime/ChromeDevtools/IDevtoolsConnection.cs index c75221f2a75ca326900b877d1253dde7baa5c049..122c5699fe5c9f4f717fe3c48a712fac399762d0 100644 --- a/Runtime/ChromeDevtools/IDevtoolsConnection.cs +++ b/Runtime/ChromeDevtools/IDevtoolsConnection.cs @@ -20,7 +20,7 @@ namespace bessw.Unity.WebView.ChromeDevTools public Task<string> ReadAsync(); /// <summary> - /// experimential + /// experimental /// </summary> /// <returns></returns> [Obsolete] diff --git a/Runtime/WebViewComponent.cs b/Runtime/WebViewComponent.cs index 35fbe1e77eb5ba08142d36079792a6f6f27033a2..9448ef654fbbbf8a47f044fd99aaaf3caa16e4fc 100644 --- a/Runtime/WebViewComponent.cs +++ b/Runtime/WebViewComponent.cs @@ -19,7 +19,7 @@ namespace bessw.Unity.WebView #region json serializer /// <summary> - /// Json serializer settings for the user space objects (e.g. transfering objects that have been droped on the BrowserView) + /// Json serializer settings for the user space objects (e.g. transferring objects that have been dropped on the BrowserView) /// Users are allowed to change serializer settings to their liking. /// </summary> public static JsonSerializerSettings serializerSettings = new JsonSerializerSettings @@ -34,7 +34,7 @@ namespace bessw.Unity.WebView } }; /// <summary> - /// JsonSerializer for the user space objects (e.g. transfering objects that have been droped on the BrowserView) + /// JsonSerializer for the user space objects (e.g. transferring objects that have been dropped on the BrowserView) /// Users are allowed to change serializer settings to their liking. /// </summary> public static JsonSerializer serializer = JsonSerializer.Create(serializerSettings); @@ -183,7 +183,7 @@ namespace bessw.Unity.WebView private void createDragEvent(DragEventType dragEventType, PointerEventData eventData) { - if (eventData.pointerDrag.TryGetComponent(out BrowserDropable dropable)) + if (eventData.pointerDrag.TryGetComponent(out IBrowserDroppable droppable)) { var position = toBrowserCoordinates(eventData.position); var dragEvent = new dispatchDragEvent @@ -196,7 +196,7 @@ namespace bessw.Unity.WebView new DragDataItem { mimeType = "application/json", - data = JsonConvert.SerializeObject(dropable, serializerSettings) + data = JsonConvert.SerializeObject(droppable, serializerSettings) } }, dragOperationsMask = DragOperationsMask.Copy @@ -218,9 +218,9 @@ namespace bessw.Unity.WebView // invert y because the browser has y=0 on the top Vector2 invertedLocalPos = new Vector2(localPoint.x, rectTransform.rect.size.y - localPoint.y); Vector2 textureScale = tab.StreamSize / rectTransform.rect.size; - Vector2 browserCoorinate = invertedLocalPos * textureScale;// / tab.ViewportScaleFactor; - Debug.Log($"eventPos: {eventPos}, invertedLocalPos: {invertedLocalPos}, browserCoordinate: {browserCoorinate}"); - return new Vector2Int((int) browserCoorinate.x, (int) browserCoorinate.y); + Vector2 browserCoordinate = invertedLocalPos * textureScale;// / tab.ViewportScaleFactor; + Debug.Log($"eventPos: {eventPos}, invertedLocalPos: {invertedLocalPos}, browserCoordinate: {browserCoordinate}"); + return new Vector2Int((int) browserCoordinate.x, (int) browserCoordinate.y); } private void OnDisable() @@ -245,6 +245,6 @@ namespace bessw.Unity.WebView } } - public interface BrowserDropable { } + public interface IBrowserDroppable { } } \ No newline at end of file