google / elemental2

Type checked access to browser APIs for Java code.
Apache License 2.0
150 stars 38 forks source link

Missing properties of HTMLTextAreaElement and TextMetrics #160

Closed jiakuan closed 9 months ago

jiakuan commented 1 year ago

Some important properties such as selectionStart and selectionEnd are missing in elemental2.dom.HTMLTextAreaElement.

https://developer.mozilla.org/en-US/docs/Web/API/HTMLTextAreaElement

zbynek commented 1 year ago

These are defined in gecko_dom extern so it would be solved by https://github.com/google/elemental2/issues/86 or by moving standard definitions from gecko_dom to the default extern as suggested in https://github.com/google/closure-compiler/issues/2478

gkdn commented 1 year ago

@jDramaix Given reluctance in closure compiler to move them; maybe we should just include gecko_dom. Are they any negatives to that?

zbynek commented 1 year ago

One downside of including gecko_dom as is that it would expose many non-standard or nonexistent APIs, e.g. Element.prototype.firebugIgnore, Window.prototype.controller, ...

I think it would be nice to not clutter Elemental2 with all those deprecated APIs, so I created a PR for closure compiler instead: https://github.com/google/closure-compiler/pull/4102

jiakuan commented 1 year ago

Similarly, most properties are missing in TextMetrics except width being there.

As a temporary workaround, I created a new type to use:

import elemental2.dom.TextMetrics;
import jsinterop.annotations.JsPackage;
import jsinterop.annotations.JsType;

@JsType(isNative = true, name = "TextMetrics", namespace = JsPackage.GLOBAL)
public class TextMetrics2 extends TextMetrics {

  public double actualBoundingBoxAscent;
  public double actualBoundingBoxDescent;
  public double actualBoundingBoxLeft;
  public double actualBoundingBoxRight;
  public double fontBoundingBoxAscent;
  public double fontBoundingBoxDescent;
}
zbynek commented 1 year ago

https://github.com/google/closure-compiler/blob/master/externs/browser/html5.js#L989 already has most of these so they should be included in next elemental release. The remaining ones (fontBoundingBoxAscent/fontBoundingBoxDescent) are not yet supported in FireFox.

jDramaix commented 9 months ago

I double checked and all missing api are now part of Elemental2. A new release is needed though.