Giter Site home page Giter Site logo

saltarelleweb's People

Contributors

astrorenales avatar drysart avatar erik-kallen avatar jechojekov avatar prodigysim avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

saltarelleweb's Issues

Unable to create SVG elements (Element vs SVGElement)

I'm trying to create SVG elements and I'm struggling to figure out how it is meant to work.
There are three main problems.

Firstly Document.CreateElementNS("http://www.w3.org/2000/svg", "svg") works, but returns an Element, which I can't easily convert to an SVGSVGElement (which extends SVGGraphicsElement, SVGElement, and XmlElement). The Element.As<T>() method has a type constraint of Element.
Similarly, some of the other methods such as GetElementById() mean that even if the SVG element exists, you can't get it back as the right type.

I have a hack for this first issue, which essentially does what the As() does.

The second issue is a follow on of the above. How do I create sub nodes of the SVG? In JS you would just use document.createElementNS() again. The reason I mention it separately, is that in JS some SVG related objects have createXXX() methods on the SVGSVGElement.

The third aspect is that even when you have created, say, an SVGRectElement, the properties are read only, so you can't set the width/height,x,y,rx,ry. Limiting the usefulness of these classes.
The DOM interface : https://developer.mozilla.org/en-US/docs/Web/API/SVGRectElement also says the properties are readonly.
So how am I meant to set attributes of the SVGElement?

Ultimately, I guess that I'm just misunderstanding how to drive the interface.
So if there any examples of creating an element and some simple shapes inside that you could point me at, that would be a great help.

initEvent methods missing in 3.x

The event creation helpers, such as "initMouseEvent" and "initEvent" are missing in 3.x. While these APIs might be deprecated, they're needed for backwards compatibility with older browsers.

You can find their specification here.
http://www.w3.org/TR/DOM-Level-2-Events/events.html

The standard pattern is

var myEvent = document.createEvent('MyEventType');
myEvent.initEvent(...);
document.dispatchEvent(myEvent);

So ideally the parameter and return types of those methods should match up in a reasonable way.

WebGL unsigned long issue

Some WebGL code needs casting int/uint casting, for instance:

gl.TexParameteri(WebGLRenderingContext.TEXTURE_2D, WebGLRenderingContext.TEXTURE_WRAP_S, WebGLRenderingContext.CLAMP_TO_EDGE);

Since WebGLRenderingContext contains method with the last parameter of type int:

// IDL: void texParameteri(GLenum target, GLenum pname, GLint param); 
public void TexParameteri(uint target, uint pname, int param);

and uint constant:

// IDL: const GLenum CLAMP_TO_EDGE                  = 0x812F;
public const uint CLAMP_TO_EDGE = 33071;

The problem is caused because GLenum is defined in IDL as:

typedef unsigned long  GLenum;

There are more cases of casting problem in the spec, e.g. Uniform1i vs. TEXTURE_2D.

One possible workaround is to define alternative methods, such as:

public void TexParameteri(uint target, uint pname, uint param) { }
public void Uniform1i(WebGLUniformLocation location, uint x) { }

However similar problem is with:

GLint getAttribLocation(WebGLProgram? program, DOMString name)

vs.

void enableVertexAttribArray(GLuint index)

from WebGL specification.

I think that the spec considers unsigned long as non-negative integer implicitly convertible to common integer long.

So, the solution from my point of view is to translate IDL's unsigned long to C#'s int.

Usage of XmlElement over Element is inconvenient

Not exactly a bug, but I'm finding the new usage of XmlElement as a return type for various API functions as rather inconvenient, resulting in a lot of manual casting. I understand that these are probably perfectly valid type constraints in terms of the spec, but they're very inconvenient to work with since there are more relevant casts will pass in most common usage.

Some examples:

Element.ParentNode returns XmlElement instead of Element
Document.CreateElement returns XmlElement
Document.DocumentElement returns XmlElement

This means a line like

Document.DocumentElement.AddEventListener("event", ...);

has to turn into

((Element)Document.DocumentElement).AddEventListener("event, ...);

or be separated into two lines, or make use of an extension method to do the cast (which can be more inconvenient given namespace issues).

I don't particularly have a proposed solution, I just feel like the more simplified typing was a lot easier to work with.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.