-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Define "affected ranges" clearer at InputEvent.getTargetRanges()
definition
#112
Comments
There are no automated tests for `InputEvent.getTargetRanges()` because it is set only when `beforeinput` event, but it's defined as not dispatched by `document.execCommand`. However, we can synthesize `beforeinput` event with test driver. On the other hand, the definition in Input Events spec is not clear. Therefore, most of the tests won't be passed on any browsers for now. There are some spec issues which I filed: * w3c/input-events#112 * w3c/input-events#113 * w3c/input-events#114 These new test must be useful when browser vendors discuss the issues. Differential Revision: https://phabricator.services.mozilla.com/D85527 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1655393 gecko-commit: 12f21ad909371384939bb38d65cf1dbc797b5bf9 gecko-integration-branch: autoland gecko-reviewers: smaug
There are no automated tests for `InputEvent.getTargetRanges()` because it is set only when `beforeinput` event, but it's defined as not dispatched by `document.execCommand`. However, we can synthesize `beforeinput` event with test driver. On the other hand, the definition in Input Events spec is not clear. Therefore, most of the tests won't be passed on any browsers for now. There are some spec issues which I filed: * w3c/input-events#112 * w3c/input-events#113 * w3c/input-events#114 These new test must be useful when browser vendors discuss the issues. Differential Revision: https://phabricator.services.mozilla.com/D85527
There are no automated tests for `InputEvent.getTargetRanges()` because it is set only when `beforeinput` event, but it's defined as not dispatched by `document.execCommand`. However, we can synthesize `beforeinput` event with test driver. On the other hand, the definition in Input Events spec is not clear. Therefore, most of the tests won't be passed on any browsers for now. There are some spec issues which I filed: * w3c/input-events#112 * w3c/input-events#113 * w3c/input-events#114 These new test must be useful when browser vendors discuss the issues. Differential Revision: https://phabricator.services.mozilla.com/D85527 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1655393 gecko-commit: 12f21ad909371384939bb38d65cf1dbc797b5bf9 gecko-integration-branch: autoland gecko-reviewers: smaug
There are no automated tests for `InputEvent.getTargetRanges()` because it is set only when `beforeinput` event, but it's defined as not dispatched by `document.execCommand`. However, we can synthesize `beforeinput` event with test driver. On the other hand, the definition in Input Events spec is not clear. Therefore, most of the tests won't be passed on any browsers for now. There are some spec issues which I filed: * w3c/input-events#112 * w3c/input-events#113 * w3c/input-events#114 These new test must be useful when browser vendors discuss the issues. Differential Revision: https://phabricator.services.mozilla.com/D85527
There are no automated tests for `InputEvent.getTargetRanges()` because it is set only when `beforeinput` event, but it's defined as not dispatched by `document.execCommand`. However, we can synthesize `beforeinput` event with test driver. On the other hand, the definition in Input Events spec is not clear. Therefore, most of the tests won't be passed on any browsers for now. There are some spec issues which I filed: * w3c/input-events#112 * w3c/input-events#113 * w3c/input-events#114 These new test must be useful when browser vendors discuss the issues. Differential Revision: https://phabricator.services.mozilla.com/D85527 UltraBlame original commit: 12f21ad909371384939bb38d65cf1dbc797b5bf9
There are no automated tests for `InputEvent.getTargetRanges()` because it is set only when `beforeinput` event, but it's defined as not dispatched by `document.execCommand`. However, we can synthesize `beforeinput` event with test driver. On the other hand, the definition in Input Events spec is not clear. Therefore, most of the tests won't be passed on any browsers for now. There are some spec issues which I filed: * w3c/input-events#112 * w3c/input-events#113 * w3c/input-events#114 These new test must be useful when browser vendors discuss the issues. Differential Revision: https://phabricator.services.mozilla.com/D85527 UltraBlame original commit: 12f21ad909371384939bb38d65cf1dbc797b5bf9
There are no automated tests for `InputEvent.getTargetRanges()` because it is set only when `beforeinput` event, but it's defined as not dispatched by `document.execCommand`. However, we can synthesize `beforeinput` event with test driver. On the other hand, the definition in Input Events spec is not clear. Therefore, most of the tests won't be passed on any browsers for now. There are some spec issues which I filed: * w3c/input-events#112 * w3c/input-events#113 * w3c/input-events#114 These new test must be useful when browser vendors discuss the issues. Differential Revision: https://phabricator.services.mozilla.com/D85527 UltraBlame original commit: 12f21ad909371384939bb38d65cf1dbc797b5bf9
Gecko compute "affected ranges" as the following rules for shipping in Nightly channel: If
|
And there is an issue if deleting block boundaries:
If the |
@RByers @whsieh could you work with @masayuki-nakano to improve this definition and interoperability between implementations? (Or find someone within your organization with the relevant expertise.) |
I added a lot of tentative tests to WPT, but it's not enough (editor has too many features!!) |
It seems that when a target range boundary is at start of a block, Blink adjusts it as 0 of the block, but when a target boundary is at end of a block whose last content is a text node, Blink adjusts it as end of the text node, rather than end of the block. This inconsistency does not make sense. And I guess that pointing in a leaf node is more convenient for web apps. E.g., scanning ancestor block is easier than scanning first editable leaf. |
Hey,
Is that correctly understood? |
I am not sure how that selection could be set like that through human input, but putting it either here This looks like one of those examples where browser in the past might have moved the dom nodes around (merging the |
I think the cost argument should not be important here. The target ranges only need to be calculated if the We could also say that we don't care whether the range starts in the parent node or the text node because we know that adjacent text nodes as a result of browser native insertion/deletion will always be merged. |
I agree with that. I think that it should be based on the platform manner. But I don't like the current definition because it's almost same as "undefined".
If we don't take care of inline elements, it might be explained as the range should start from a DOM point whose data is deleted and end by a DOM point whose data will keep alive even in different node. (But as you say, it's really difficult thing and I understand why you haven't tackled it.) So, affected range is defined as a range between data in text nodes, it could be defined simpler (except when deleting an element like
I think so. But ideally spec defines it with some text which make web developers understand as such invisible white-spaces should be included in the "affected range".
I don't have any concrete idea of web developers. So, I don't know whether the difference of container of target range boundary becomes a trouble or not. But as an implementer, the different is a painful point for web-compat. I just want more detail in the spec for explaining why such incompatible thing may occur with pointing a spec's section. Ideally, inline element boundaries which will be joined with another element should be included in the "affected ranges", but I think that this is probably impossible in some cases. E.g., backspacing at
Yeah, it's not a realistic case for every change has a specific
Yes. My point is, it should be defined as far as possible how to represented as the affected ranges for coming DOM mutation.
I think so.
Thank you for the testing. But IIRC, in some cases, inline elements may be joined. Although I don't have examples.
Oh, the definition sounds reasonable to me for explaining "affected ranges" except when expanding the range to delete surrounding invisible white-spaces.
Yeah, it might be reasonable if browsers can ignore the runtime cost to walk the tree.
Yeah. |
OK just to understand why a clarification is needed here: For example right now it will return something like
to join two inline nodes when they are next to each other is likely fine in many situations. It's the restacking that can cause problems though as the browser may not always understand the significance of everything. Take for example something like this: <div><p><i><b>abc<span class="citation" data-id="14" contenteditable="false">(Einstein 1998: p. 45)</span>[]</b></i></p><p><b><span class="reference" data-id="a45">def</span></b></p></div> If I hit Delete, this will move the contents of the second paragraph into the first paragraph and remove the second paragraph. But if it were to additionally move the inline dom nodes around without destroying the content? Now knowing what the meaning of the additional span is, it would likely come up with something like: <div><p><b><i>abc(Einstein 1998: p. 45)[]</i>def</b></p></div> or <div><p><b><i>abc</i><span class="citation reference"><i>(Einstein 1998: p. 45)[]</i>def</span></b></p></div> This is one of the reasons why JS editors have asked browsers to please not try to "be smart" about it and just do the minimum required changes. And as far as I am aware, browsers are much better about this now than they used to be.
Ok, but this cost is only there in case the user runs the
Ok, how about we ask for language suggestions on that from the participants of the February call. I think there is no actual disagreement about what we are trying to express at this stage. It's just a matter of putting it into the right words.
Ok, I'll try to obtain some feedback on just that point from JS editor developers. If they don't care, then I think we should be free to define this in a very simple way, for example by always preferring a reference into the parent node rather than the text node if it is on a boundary. If they do care, then we probably should take their views into account as well even if that means ending up with a slightly more complex definition. |
In my understanding,
Thank you for the interesting example. And you're right. If inline elements have different style and/or editable state, they should never be joined. But as a web browser engine developer, I'd like to join inline elements if it safe to do it because it saves footprint and cost of walking DOM tree at following operations. Perhaps, when doing it, browsers should be more careful.
No, as far as I've tested, The 2nd test in it is important. And this behavior is consistent with untrusted So, when FYI: Firefox 87 will be the first version to support |
Ah, but according to the test result, Chrome computes |
I've been asked to give our opinion here. I'll try to reply based on the two scenarios I've been given. I hope it helps.
Such things are completely transparent for us. For CKEditor's data model this is one thing anyway – a position before a text node and at position In my experience, such things require normalization in our code because there are many selection/position-related browser APIs and one of the browsers will always return something slightly different. Perfect alignment between browsers would be nice, but it's not on the top of my priority list.
Interestingly, this does not apply to our case. We'll never render a normal space at the end of a block. If there's a trailing space in our data model, we're going to render it as nbsp. Otherwise, the browser will not be able to show a caret after that space. The space is removed from the visual representation – it means that normalization is applied at this stage anyway. Naturally, when pressing Backspace, the browser must do more than just merge two paragraphs. It needs to remove that space that wasn't visible anyway, but would now be visible between "abc" and "def". Do we need that space inside the Do I think it should be inside So, to me – |
Currently,
getTargetRanges()
is defined as:Currently, I'm implementing computation of "affected ranges" for shipping
beforeinput
event of Firefox. However, this definition is really unclear.For example, when
Backspace
ing in<p>abc</p><p>[]def</p>
, then, the paragraphs will be joined so that("abc", 3)
-("def", 0)
must be expected by web apps even though new empty first or second<p>
element is removed (i.e., affected).Another example: when there is invisible white-spaces at start of second paragraph and/or end of first paragraph in the previous example, i.e.,
<p>abc </p><p> []def</p>
, browsers removes the invisible white-spaces too, i.e., becomes<p>abcdef</p>
. So, in this case,getTargetRanges()
should include the invisible white-spaces, but at least Blink does not include the invisible white-spaces.On the other hand, if there is an invisible
<br>
element in the first paragraph, i.e., in the case of<p>abc<br></p><p>[]def</p>
, Blink returns(p, 1) - (p, 0)
. I.e., including the invisible<br>
element.So, at least the first example, "affect range" may not be good information which web apps want to know. However, at the latter 2 cases, invisible things which will be removed should be contained by the result of
getTargetRanges()
.The text was updated successfully, but these errors were encountered: