Skip to content
Snippets Groups Projects
  1. Nov 13, 2024
  2. Sep 06, 2024
  3. Jul 25, 2024
  4. Jun 05, 2024
  5. Jun 04, 2024
  6. May 31, 2024
    • Masayuki Nakano's avatar
      Bug 1898408 - Make our editor disconnect `<br>` element temporarily when its... · ed99e91e
      Masayuki Nakano authored
      Bug 1898408 - Make our editor disconnect `<br>` element temporarily when its type is changed from or to padding one r=m_kato
      
      Currently, the `<br>` element type -- whether normal `<br>` element or padding
      `<br>` element for empty editor or last line -- is managed by the flags of
      `nsINode`.  Therefore, changing the flag does not cause mutation, so
      `IMEContentObserver` cannot observe the type changes.  However,
      `ContentEventHandler` treats the padding `<br>` elements as invisible.
      Therefore, when a `<br>` element becomes a padding one, `IMEContentObserver`
      needs to notify IME of atext removed notification, and also when a `<br>`
      element becomes a normal one (i.e., visible), `IMEContentObserver` needs to
      notify IME of a text added notification.
      
      Therefore, this patch makes `EditorBase` disconnect the `<br>` element
      temporarily to make `IMEContentObserver` observable the type change.
      
      Depends on D211698
      
      Differential Revision: https://phabricator.services.mozilla.com/D211699
      ed99e91e
  7. May 30, 2024
  8. May 27, 2024
  9. Apr 27, 2024
    • Masayuki Nakano's avatar
      Bug 1877513 - Make `HTMLEditor` deletes only preceding lines of right child... · 398b556e
      Masayuki Nakano authored
      Bug 1877513 - Make `HTMLEditor` deletes only preceding lines of right child block if the range starts from start of a line r=m_kato
      
      Currently, the editor of Gecko always unwraps first line of the right child
      block after deleting selected range when the range starts in a parent block
      and ends in a child block.  This behavior is almost same as the other browsers,
      but the other browsers deletes only preceding lines of the right child block
      (i.e., without unwrapping the first line of the right child block) if the range
      starts from start of a preceding line, for example, when deleting
      `<div>abc<br>[def<p>g]hi<br>jkl`, Gecko moves "hi" to the parent `<div>`,
      but the other browsers keeps it in the child `<p>`.
      
      For emulating this special handling, we need to touch 2 paths.
      
      One is `Backspace` when selection is collapsed at start of the child block.  In
      this case, only when the preceding line is empty, i.e., there are 2 line breaks
      (either `<br>` or `\n` in `white-space: pre-*`), the following break should
      be deleted, but the child block should not be touched.
      
      The other is, deleting when selection is not collapsed or `Delete` when
      selection is collapsed at immediately before the child block.  In the latter
      case, `HTMLEditor::HandleDeleteSelection` extends `Selection` using
      `nsFrameSelection`.  Then, handle it with same path as deleting non-collapsed
      range.
      
      The former is handled with `HandleDeleteLineBreak` and
      `ComputeRangeToDeleteLineBreak`.  The latter is handled with
      `HandleDeleteNonCollapsedRange` and `ComputeRangeToDeleteNonCollapsedRange`.
      The new handlers use the `ComputeRangeToDelete*`.  Therefore, `beforeinput`
      reports exactly same range from `getTargetRanges`.  However, existing paths
      do not use same approach and this patch makes `HandleDeleteNonCollapsedRange`
      fall it back to `HandleDeleteNonCollapsedRange`.  Therefore, some `if` checks
      in `HandleDeleteNonCollapsedRange` are ugly, but I have no better idea to
      implement this smarter.
      
      Differential Revision: https://phabricator.services.mozilla.com/D207690
      398b556e
  10. Apr 26, 2024
    • pstanciu's avatar
      Backed out changeset 67a63b95c31e (bug 1877513) for causing build bustages on... · ba931d59
      pstanciu authored
      Backed out changeset 67a63b95c31e (bug 1877513) for causing build bustages on HTMLEditorDeleteHandler.cpp CLOSED TREE
      ba931d59
    • Masayuki Nakano's avatar
      Bug 1877513 - Make `HTMLEditor` deletes only preceding lines of right child... · 707ea2ca
      Masayuki Nakano authored
      Bug 1877513 - Make `HTMLEditor` deletes only preceding lines of right child block if the range starts from start of a line r=m_kato
      
      Currently, the editor of Gecko always unwraps first line of the right child
      block after deleting selected range when the range starts in a parent block
      and ends in a child block.  This behavior is almost same as the other browsers,
      but the other browsers deletes only preceding lines of the right child block
      (i.e., without unwrapping the first line of the right child block) if the range
      starts from start of a preceding line, for example, when deleting
      `<div>abc<br>[def<p>g]hi<br>jkl`, Gecko moves "hi" to the parent `<div>`,
      but the other browsers keeps it in the child `<p>`.
      
      For emulating this special handling, we need to touch 2 paths.
      
      One is `Backspace` when selection is collapsed at start of the child block.  In
      this case, only when the preceding line is empty, i.e., there are 2 line breaks
      (either `<br>` or `\n` in `white-space: pre-*`), the following break should
      be deleted, but the child block should not be touched.
      
      The other is, deleting when selection is not collapsed or `Delete` when
      selection is collapsed at immediately before the child block.  In the latter
      case, `HTMLEditor::HandleDeleteSelection` extends `Selection` using
      `nsFrameSelection`.  Then, handle it with same path as deleting non-collapsed
      range.
      
      The former is handled with `HandleDeleteLineBreak` and
      `ComputeRangeToDeleteLineBreak`.  The latter is handled with
      `HandleDeleteNonCollapsedRange` and `ComputeRangeToDeleteNonCollapsedRange`.
      The new handlers use the `ComputeRangeToDelete*`.  Therefore, `beforeinput`
      reports exactly same range from `getTargetRanges`.  However, existing paths
      do not use same approach and this patch makes `HandleDeleteNonCollapsedRange`
      fall it back to `HandleDeleteNonCollapsedRange`.  Therefore, some `if` checks
      in `HandleDeleteNonCollapsedRange` are ugly, but I have no better idea to
      implement this smarter.
      
      Differential Revision: https://phabricator.services.mozilla.com/D207690
      707ea2ca
  11. Apr 25, 2024
    • Masayuki Nakano's avatar
      Bug 1892376 - Make `EditorBase` and `HTMLEditor` not use `nsDOMAttributeMap` r=peterv,dom-core · af2207ae
      Masayuki Nakano authored
      `nsDOMAttributeMap::GetAttribute` creates `dom::Attr` so that it's not cheap.
      Instead it should access `Element::mAttrs` with the accessors or
      `BorrowedAttrInfo`.
      
      Differential Revision: https://phabricator.services.mozilla.com/D208087
      af2207ae
    • Masayuki Nakano's avatar
      Bug 1891659 - Make `AutoBlockElementsJoiner::DeleteTextAtStartAndEndOfRange()`... · ad9ca596
      Masayuki Nakano authored
      Bug 1891659 - Make `AutoBlockElementsJoiner::DeleteTextAtStartAndEndOfRange()` handle the case when the range in a text node r=m_kato
      
      It assumes that the range is always starts and ends in different node.  This
      is true for now, but this will be called with a text node to delete only
      preformatted line break.  Note that the only caller of it does not need the
      text node(s) if it becomes empty.  Therefore, this patch makes it remove the
      text node in such case.
      
      Note that the test changed in
      `input-events-get-target-ranges-deleting-in-list-items.tentative.html` was
      wrong and only Firefox passed it because the range description was
      `(#text "", 0) - (#text "", 10)` since the text nodes are removed after
      deleting the text data of them.  Now, they become
      `(#text "list-item1", 0) - (#text "list-item2", 10)`.
      
      Depends on D207688
      
      Differential Revision: https://phabricator.services.mozilla.com/D207689
      ad9ca596
    • Masayuki Nakano's avatar
      Bug 1891656 - Make... · 83e260a7
      Masayuki Nakano authored
      Bug 1891656 - Make `HTMLEditUtils::GetMostDistantAncestorEditableEmptyInlineElement()` use `Element::FromNode()` r=m_kato
      
      It uses `AsElement()` which always casts itself to `Element*`, however, the
      instance may be non-element node if there is no empty parent of `aEmptyContent`.
      
      Fortunately, all callers of this method uses the result as `nsIContent*` to
      call `DeleteNodeWithTransaction()`.  Therefore, we don't have crash bugs caused
      by this.
      
      Depends on D207687
      
      Differential Revision: https://phabricator.services.mozilla.com/D207688
      83e260a7
  12. Apr 24, 2024
  13. Apr 22, 2024
    • Masayuki Nakano's avatar
      Bug 1885822 - part 4: Add `WSType::InlineEditingHostBoundary` r=m_kato · 4bd29cb1
      Masayuki Nakano authored
      When `WSScanResult::ReachedCurrentBlockBoundary()` returns `true`, it may have
      reached inline editing host rather than editable block.  Therefore, the
      method name is definitely error-prone.  This patch adds new state and all
      users of `WSType::CurrentBlockBoundary` keeps checking the new type too for
      keeping current behavior.
      
      I think that we should make `WSRunScanner` aware of inline editing host next
      to block boundary before removing odd check of
      `ReachedInlineEditingHostBoundary()`, `StartsFromInlineEditingHostBoundary()`
      and `EndsByInlineEditingHostBoundary()` to avoid unexpected regressions in the
      wild.
      
      Depends on D207683
      
      Differential Revision: https://phabricator.services.mozilla.com/D207684
      4bd29cb1
    • Masayuki Nakano's avatar
      Bug 1885822 - part 3: Make `WSScanResult` always have editable element with... · a4a70a4e
      Masayuki Nakano authored
      Bug 1885822 - part 3: Make `WSScanResult` always have editable element with `mContent` if it reached current block boundary r=m_kato
      
      Different from the comment around setter of `WSType::CurrentBlockBoundary`,
      neither `HTMLEditUtils::GetNextLeafContentOrNextBlockElement` nor
      `HTMLEditUtils::GetPreviousLeafContentOrPreviousBlockElement` returns
      `nullptr` when it reaches non-editable element, and the setters always set
      `mContent` to `aEditableBlockParentOrTopmostEditableInlineElement`.  Therefore,
      `mContent` is always an editable element when `ReachedCurrentBlockBoundary()`
      returns `true`.
      
      Depends on D207682
      
      Differential Revision: https://phabricator.services.mozilla.com/D207683
      a4a70a4e
    • Masayuki Nakano's avatar
      Bug 1885822 - part 2: Make `WSScanResult` always have non-null `mContent` if... · 7edcf9c3
      Masayuki Nakano authored
      Bug 1885822 - part 2: Make `WSScanResult` always have non-null `mContent` if it reached something r=m_kato
      
      Currently, it checks whether `mContent` is `nullptr` or not even if the scanner
      reached something.  However, this makes the users of this object check whether
      it has reasonable content or not and that makes the users messy.  Therefore,
      the scanning method should guarantee that it's always error if it does not reach
      any content.
      
      Depends on D207681
      
      Differential Revision: https://phabricator.services.mozilla.com/D207682
      7edcf9c3
    • Masayuki Nakano's avatar
      Bug 1885822 - part 1: Make `WSScanResult` created with... · 83e6cf07
      Masayuki Nakano authored
      Bug 1885822 - part 1: Make `WSScanResult` created with `WSType::InUncomposedDoc` if the scan is tried in uncomposed tree r=m_kato
      
      This case should never happen because nobody can check proper editable state
      in uncomposed tree unless the uncomposed tree has its own editing host.
      Therefore, this patch adds assertions into the scanning methods too.
      
      Differential Revision: https://phabricator.services.mozilla.com/D207681
      83e6cf07
  14. Apr 15, 2024
  15. Apr 08, 2024
  16. Apr 04, 2024
  17. Mar 20, 2024
  18. Mar 11, 2024
  19. Mar 08, 2024
Loading