New issue
Advanced search Search tips

Issue 728441 link

Starred by 1 user

Issue metadata

Status: Duplicate
Merged: issue 729636
Owner: ----
Closed: Jun 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 2
Type: Bug



Sign in to add a comment

Inconsistent results between FrameSelection::ComputeVisibleSelectionInDOMTree and FrameSelection::ComputeVisibleSelectionInFlatTree

Project Member Reported by xiaoche...@chromium.org, Jun 1 2017

Issue description

There are some scenarios where FrameSelection::ComputeVisibleSelectionInDOMTree() returns a non-null selection, but FrameSelection::ComputeVisibleSelectionInFlatTree() returns null selection.

This is unexpected, and we should understand why.
 
One case is when shadow root is attached to svg elements (from issue 725457  #3 ):

<body contenteditable="plaintext-only">
<svg id="svgvar00001">
<text id="svgvar00005">
<font-face id="svgvar00011">
</text>
</svg>
<script>
var var00013 = svgvar00011.viewportElement; 
svgvar00005.selectSubString(0,-1); 
var00013.createShadowRoot(); 
</script>
</body>

However, this is quite unusual HTML.

We have observed crashes due to the inconsistency on Youtube without any devtools or extension. We need to understand what are the more common cases causing this inconsistency.

Comment 2 by yosin@chromium.org, Jun 1 2017

Culprit is:

PositionInFlatTree ToPositionInFlatTree(const Position& pos) {
  ...
  if (pos.IsBeforeAnchor() || pos.IsAfterAnchor()) {
    if (anchor->CanParticipateInFlatTree() &&
        !FlatTreeTraversal::Parent(*anchor)) {
      // For Before/AfterAnchor, if |anchor| doesn't have parent in the flat
      // tree, there is no valid corresponding PositionInFlatTree.
      // Since this function is a primitive function, we do not adjust |pos|
      // to somewhere else in flat tree.
      // Reached by unit test
      // FrameSelectionTest.SelectInvalidPositionInFlatTreeDoesntCrash.
      return PositionInFlatTree();
    }
  }
  // TODO(yosin): Once we have a test case for SLOT or active insertion point,
  // this function should handle it.
  return PositionInFlatTree(anchor, pos.AnchorType());
}
Mergedinto: 729636
Status: Duplicate (was: Available)

Sign in to add a comment