Re: [editing] We should update the spec with an ImmutableStaticRange that is a subset of the Range interface and return them via the getTargetRanges method. s/ImmutableStaticRange/StaticRange/ in the actual spec (#104)

Details of proposal here:

https://lists.w3.org/Archives/Public/public-webapps/2016JanMar/0027.html

---------- Forwarded message ----------
From: Ryosuke Niwa <rniwa@apple.com>
Date: Sun, Jan 10, 2016 at 12:42 AM
Subject: [Editing] [DOM] Adding static range API
To: public-webapps WG <public-webapps@w3.org>
Cc: public-editing-tf <public-editing-tf@w3.org>


Hi,

This is yet another feedback from multiple browser vendors (Apple, Google, Microsoft) that got together in Redmond last Thursday to discuss editing API and related events.

For editing APIs, it's desirable to have a variant of Range that is immutable.  For example, if apps were to create an undo stack of its own, then storing the selection state using Range would be problematic because those Ranges would get updated whenever DOM is mutated.  Furthermore, live ranges are expensive if browsers had to keep updating them as DOM is mutated.  This is analogous to how we're moving away form LiveNodeList/HTMLCollection to use StaticNodeList in various new DOM APIs.

So we came up with a proposal to add StaticRange: a static, immutable variant of Range defined as follows:

[Constructor,
 Exposed=Window]
interface StaticRange {
  readonly attribute Node startContainer;
  readonly attribute unsigned long startOffset;
  readonly attribute Node endContainer;
  readonly attribute unsigned long endOffset;
  readonly attribute boolean collapsed;
  readonly attribute Node commonAncestorContainer;

  const unsigned short START_TO_START = 0;
  const unsigned short START_TO_END = 1;
  const unsigned short END_TO_END = 2;
  const unsigned short END_TO_START = 3;
  short compareBoundaryPoints(unsigned short how, Range sourceRange);

  [NewObject]
Range cloneRange();

  boolean isPointInRange(Node node, unsigned long offset);
  short comparePoint(Node node, unsigned long offset);

  boolean intersectsNode(Node node);
};

Along with range extensions from CSS OM view also added as follows:
https://drafts.csswg.org/cssom-view/#extensions-to-the-range-interface

partial interface StaticRange
 {
  [NewObject] sequence<DOMRect> getClientRects();
  [NewObject] DOMRect getBoundingClientRect();
};

with one difference, which is to throw an exception (perhaps InvalidStateError?) when StaticRange's boundary points don't share a common ancestor, not in a document, or offsets are out of bounds.

- R. Niwa



---
Reply to this email directly or view it on GitHub:
https://github.com/w3c/editing/issues/104#issuecomment-175932789

Received on Thursday, 28 January 2016 03:04:09 UTC