Commit 982e1a60 authored by Jonathan Kew's avatar Jonathan Kew
Browse files

Bug 1734015 - Just return an error (without asserting) from PeekOffsetForLine...

Bug 1734015 - Just return an error (without asserting) from PeekOffsetForLine if line is not found. r=layout-reviewers,emilio

The assertion here was added during the iterator refactoring in bug 1732349,
but is actually bogus. The old code would have returned via the MOZ_TRY_VAR
that wrapped the call to blockFrame->GetLineNumber(); that's replaced by
iter->FindLineContaining(), so we should now check for an error there and
similarly just return to the caller, not assert.

Differential Revision: https://phabricator.services.mozilla.com/D134950
parent e01a3953
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
<!DOCTYPE html>
<html>
<head>
  <style>
      * {
          all: initial;
      }
  </style>
  <script>
    document.addEventListener("DOMContentLoaded", () => {
      const selection = document.getSelection()
      const option = document.getElementById("id_0")
      selection.setPosition(option)
      selection.modify("move", "backward", "line")
    })
  </script>
</head>
<select>
  <option id="id_0"></option>
</select>
</html>
+1 −0
Original line number Diff line number Diff line
@@ -800,3 +800,4 @@ pref(layout.css.aspect-ratio.enabled,true) load 1699468.html
load 1728319.html
asserts(2-8) load 1730506.html # asserts from integer overflow & bogus sizes
asserts(1-4) load 1730570.html # asserts from integer overflow & bogus sizes
load 1734015.html
+3 −1
Original line number Diff line number Diff line
@@ -8794,7 +8794,9 @@ nsresult nsIFrame::PeekOffsetForLine(nsPeekOffsetStruct* aPos) {
    blockFrame = newBlock;
    nsAutoLineIterator iter = blockFrame->GetLineIterator();
    int32_t thisLine = iter->FindLineContaining(lineFrame);
    MOZ_ASSERT(thisLine >= 0, "Failed to find line!");
    if (NS_WARN_IF(thisLine < 0)) {
      return NS_ERROR_FAILURE;
    }

    int edgeCase = 0;  // no edge case. this should look at thisLine