Skip to content
Snippets Groups Projects
  1. Dec 01, 2023
  2. Jul 12, 2023
    • Masayuki Nakano's avatar
      Bug 1840500 - Make `HTMLEditor::ClearStyleAt()` remove `<br>` for reuse before... · 30e100a8
      Masayuki Nakano authored
      Bug 1840500 - Make `HTMLEditor::ClearStyleAt()` remove `<br>` for reuse before removing its parent from the tree. r=m_kato, a=RyanVM
      
      Once a parent node is removed from the tree, the node may become not editable
      because editable state "inherits" from ancestor nodes.
      `HTMLEditor::ClearStyleAt` cleans up unnecessary parent inline elements first,
      but if `<br>` element which should be reused in the block parent is contained
      the inline elements, `HTMLEditUtils::IsRemovableNode()` will start returning
      `false` for the `<br>` element because of in a document fragment which do not
      contain an element whose `contenteditable` is `true`.  Then,
      `MoveNodeWithTransaction` fails to move it because of unremovable.
      
      Therefore, this patch makes the method move `<br>` element before removing
      inline elements and use `InsertNodeWithTransaction` instead if `<br>` element
      is an orphan node.
      
      Differential Revision: https://phabricator.services.mozilla.com/D182640
      30e100a8
  3. Oct 07, 2023
  4. Jun 30, 2023
    • Masayuki Nakano's avatar
      Bug 1840804 - Make `TextEditor::OnBlur` stop finalizing `Selection` if new... · d0189a6d
      Masayuki Nakano authored
      Bug 1840804 - Make `TextEditor::OnBlur` stop finalizing `Selection` if new element already gets focus r=m_kato, a=dsmith
      
      Before bug 1770874, `EditorBase::OnBlur` checked that for both `TextEditor`
      and `HTMLEditor`.  However, accidentally, I removed the check from `TextEditor`.
      Therefore, a call of `EditorBase::FinalizeSelection()` will hide the caret
      even after another editor gets focus.
      
      Therefore, this patch just take it back into `TextEditor::OnBlur`.
      
      Note that I don't think the design mode handling is required there because
      `TextEditor`s shouldn't be created in the design mode document.
      
      Differential Revision: https://phabricator.services.mozilla.com/D182468
      d0189a6d
  5. Jun 15, 2023
  6. Jun 12, 2023
  7. May 31, 2023
  8. May 28, 2023
  9. May 24, 2023
  10. May 23, 2023
    • Sean Feng's avatar
      Bug 1817723 - Allow HTMLEditor can receive events when the focus is switched... · df6c9aef
      Sean Feng authored
      Bug 1817723 - Allow HTMLEditor can receive events when the focus is switched between elements in the same shadow tree. r=masayuki
      
      The EditorEventListener for HTMLEditor is registered on document,
      which is problematic because it can't receive events when the focus is
      switched between elements in the same shadow tree due to shadow dom
      encapsulation.
      
      We fix this by moving the EditorEventListener to nsWindowRoot so the
      events can always be received.
      
      Differential Revision: https://phabricator.services.mozilla.com/D178215
      df6c9aef
    • Masayuki Nakano's avatar
      Bug 1833320 - Make `HTMLEditor::HandleInsertParagraphInListItemElement`... · fb4359c2
      Masayuki Nakano authored
      Bug 1833320 - Make `HTMLEditor::HandleInsertParagraphInListItemElement` consider caret position without `WSScanResult` if it reaches a block boundary r=m_kato
      
      When `WSRunScanner::ScanNextVisibleNodeOrBlockBoundary` reaches a block
      boundary, it may return `WSScanResult` without valid position value from
      this path:
      https://searchfox.org/mozilla-central/rev/11a4d97a7b5cdfa133f4bda4525649f651703018/editor/libeditor/WSRunObject.cpp#1777-1782
      
      That happens if the reason is `WSType::CurrentBlockBoundary` or
      `WSType::OtherBlockBoundary` even in usual cases.
      
      If it's `WSType::CurrentBlockBoundary`, `TextFragmentDataAtStartRef().EndRef()`
      may point in a text node in the block, but its `GetEndReasonContent()` returns
      the block.  I'm not sure whether this is intentional result. (I guess t's a
      bug.)
      
      If it's `WSType::OtherBlockBoundary`, `TextFragmentDataAtStartRef().EndRef()`
      may point in the list item, but `GetEndReasonContent()` returns a child block.
      
      Those scan result change needs to understand `TextFragmentData` behavior again,
      but it's difficult as you know. Therefore, this fixes the caller side not to
      use `WSScanResult::Point()` if it meets a block boundary since start of the
      block boundary is a good place to put caret.
      
      Differential Revision: https://phabricator.services.mozilla.com/D178281
      fb4359c2
  11. May 20, 2023
  12. May 19, 2023
  13. May 18, 2023
  14. May 16, 2023
    • Masayuki Nakano's avatar
      Bug 1832710 - Make `EditorBase::DispatchClipboardEventAndUpdateClipboard`... · 859144ba
      Masayuki Nakano authored
      Bug 1832710 - Make `EditorBase::DispatchClipboardEventAndUpdateClipboard` handle `ePasteNoFormatting` event message r=m_kato
      
      Just a mistake, it should treat `ePasteNoFormatting` as an equivalent of `ePaste`.
      
      Differential Revision: https://phabricator.services.mozilla.com/D177988
      859144ba
    • Masayuki Nakano's avatar
      Bug 1828078 - part 2: Stop moving comment nodes when deleting a block/line boundary r=m_kato · 34b8e92a
      Masayuki Nakano authored
      With the preceding patch, comment nodes are also moved at deleting a block/line
      boundary.  However, this causes some WPT failures.  Therefore, this adds an
      option to the related methods.
      
      Note that Chrome removes all comment nodes in moving nodes.  However, I don't
      have the motivation to do that because it requires additional cost and I have
      no idea to improve the compatibility in usual web apps.  So I believe that
      doing it wastes the runtime performance unless we'd get a bug reports by the
      difference.
      
      Therefore, this patch does not update WPTs too.
      
      Differential Revision: https://phabricator.services.mozilla.com/D176767
      34b8e92a
    • Masayuki Nakano's avatar
      Bug 1828078 - part 1: Make `HTMLEditUtils::CanNodeContain` handle comment node r=m_kato · 95e22b6d
      Masayuki Nakano authored
      `HTMLEditUtils::CanNodeContain` does not handle comment nodes and cdata section
      nodes (the latter one is available only in XHTML documents, it's treated as a
      comment node in HTML documents).
      
      When copying HTML from Word on Windows, that contains 2 comment nodes at
      start of pasting body (which does not appear in clipboard viewer, so, Gecko
      creates them somewhere) and that causes `HTMLEditUtils::CanNodeContain` returns
      `false` for any parents.  Therefore,
      `HTMLEditor::InsertNodeIntoProperAncestorWithTransaction` returns error
      and the pasting fails with odd state and unexpectedly split the list item in
      `HTMLWithContextInserter::InsertContents`.  Finally, undoing fails to do some
      of them and causes destroying the editable nodes.
      
      This patch makes `HTMLEditUtils::CanNodeContain` work with comment nodes
      and cdata section nodes (the latter is treated as a comment node since there
      is no "cdata" tag definition of `nsHTMLTag`) and
      `HTMLEditor::InsertNodeIntoProperAncestorWithTransaction` just return
      "not handled" result for some other types of nodes which cannot be inserted
      in any elements.
      
      Note that the result of pasting from Word is different from Chrome's result.
      Chrome does not paste such comment nodes (but inserts comment nodes with
      `insertHTML` command).  For now, I don't want to work on fixing this
      compatibility issue since comment nodes does not cause any known troubles.
      Therefore, this patch does not contain WPT updates.
      
      Differential Revision: https://phabricator.services.mozilla.com/D176766
      95e22b6d
  15. May 10, 2023
  16. May 03, 2023
  17. Apr 25, 2023
  18. Apr 21, 2023
  19. Apr 11, 2023
    • Masayuki Nakano's avatar
      Bug 1807495 - part 1: Make `Document` notify `HTMLEditor` and... · e4a81444
      Masayuki Nakano authored
      Bug 1807495 - part 1: Make `Document` notify `HTMLEditor` and `IMEStateManager` of pseudo focus change when editing state of focused editing host or document is changed r=smaug,m_kato
      
      `IMEStateManager` basically runs at focus change.  However, when `designMode`
      is set to `"off"` or focused editing host becomes non-editable (removing
      `contenteditable` attribute or `contenteditable` attribute is set to `false`),
      IME may be disabled without a focus change.  Therefore, `Document` needs to
      notify `IMEStateManager` of the timing.
      
      Additionally, `nsFocusManager` does not change focus when focused element
      becomes not focusable (bug 1807597).  Therefore, `Document` needs to kick
      `focus` or `blur` event handler of `HTMLEditor` when active editing host
      becomes not editable.
      
      However, if an ancestor of focused element becomes editable, I think that
      `HTMLEditor` does not work well without focus move because it computes
      editing host with current editing state in a lot of places, but `Selection`
      and `nsFocusManager::GetFocusedElement` keeps working with previous focused
      element which is now a editable child of editing host.  Therefore, this patch
      marks them as `todo` in the new tests.
      
      Differential Revision: https://phabricator.services.mozilla.com/D171196
      e4a81444
  20. Apr 05, 2023
    • Emilio Cobos Álvarez's avatar
      Bug 1825825 - Simplify NAC setup. r=smaug · 641fa207
      Emilio Cobos Álvarez authored
      Make all UA widgets also NAC.
      
      Keep the UA widget flag but break at anonymous subtree boundaries, so
      that only nodes inside the UA widget directly (and not NAC from those)
      get the flag.
      
      This is important because two callers depend on this difference:
      
       * The style system, since we still want to match content rules from
         stylesheets in the UA widget. We also match user rules, which is a
         bit sketchy, but that was the previous behavior, will file a
         follow-up for that.
      
       * The reflector code, since we want the scope for UA widgets to not
         include the NAC nodes inside that UA widget. nsINode::IsInUAWidget
         got it wrong.
      
      After this patch, ChromeOnlyAccess is equivalent to
      IsInNativeAnonymousSubtree, so we should probably unify the naming.
      That's left for a follow-up patch because I don't have a strong
      preference.
      
      Differential Revision: https://phabricator.services.mozilla.com/D174310
      641fa207
  21. Mar 22, 2023
  22. Mar 21, 2023
    • Masayuki Nakano's avatar
      Bug 1810663 - Add Gecko specific command to enable new join/split node direction r=smaug,m_kato · 050517a4
      Masayuki Nakano authored
      This API is temporarily available and useful for web app developers who want to
      stop supporting Gecko specific join/split direction handling as soon as possible
      and who do not want Mozilla block their release schedule by rescheduling of
      shipping the new behavior.  Additionally, adding this command allows web apps
      detects whether Gecko supports the new behavior and whether it's enabled.
      
      On the other hand, We don't want to ship opt-out API because it's hard to keep
      maintaining the legacy behavior specific paths.  Therefore, the command does
      nothing if web app calls
      `Document.execCommand("enableCompatibleJoinSplitDirection", false "false")` if
      the new behavior is enabled by default.
      
      Differential Revision: https://phabricator.services.mozilla.com/D172351
      050517a4
Loading