Closed Bug 1416099 Opened 7 years ago Closed 7 years ago

HTMLEditRules::ReturnInParagraph() should take EditorRawDOMPoint

Categories

(Core :: DOM: Editor, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla59
Tracking Status
firefox58 --- wontfix
firefox59 --- fixed

People

(Reporter: masayuki, Assigned: masayuki)

References

Details

Attachments

(7 files)

59 bytes, text/x-review-board-request
m_kato
: review+
Details
59 bytes, text/x-review-board-request
m_kato
: review+
Details
59 bytes, text/x-review-board-request
m_kato
: review+
Details
59 bytes, text/x-review-board-request
m_kato
: review+
Details
59 bytes, text/x-review-board-request
m_kato
: review+
Details
59 bytes, text/x-review-board-request
m_kato
: review+
Details
59 bytes, text/x-review-board-request
m_kato
: review+
Details
This is another follow up bug of bug 1407305. Since the priority is less than bug 1415800 but perhaps, the patch might be big.
FYI: I'll request review for patches.  However, even if they won't be landed by next merge, it's no problem. Of course, including the patches in 58 makes us easier to uplift, though.
Comment on attachment 8927376 [details]
Bug 1416099 - part 1: Make HTMLEditRules::ReturnInParagraph() use EditActionResult

https://reviewboard.mozilla.org/r/198616/#review203932

::: editor/libeditor/HTMLEditRules.h:297
(Diff revision 1)
>                         Tables aTables = Tables::yes);
>    Element* IsInListItem(nsINode* aNode);
>    nsAtom& DefaultParagraphSeparator();
>    nsresult ReturnInHeader(Selection& aSelection, Element& aHeader,
>                            nsINode& aNode, int32_t aOffset);
> -  nsresult ReturnInParagraph(Selection* aSelection, nsINode* aHeader,
> +  EditActionResult ReturnInParagraph(Selection* aSelection, nsINode* aHeader,

Although I will handle by another bug, aHeader should be Element instead of nsINode.

::: editor/libeditor/HTMLEditRules.cpp:6832
(Diff revision 1)
>        selNode = GetAsDOMNode(parent);
>        selOffset = offset + 1;
>      }
>    }
> -  *aHandled = true;
> -  return SplitParagraph(GetAsDOMNode(aPara), sibling, aSelection,
> +  EditActionResult result(
> +    SplitParagraph(GetAsDOMNode(aPara), sibling, aSelection,

Ah, I will file a new bug that SplitParagraph should replace nsIDOMNode with nsINode (nsIContent).
Attachment #8927376 - Flags: review?(m_kato) → review+
Comment on attachment 8927377 [details]
Bug 1416099 - part 2: Rename |sibling| in HTMLEditRules::ReturnInParagraph() to |brNode|

https://reviewboard.mozilla.org/r/198618/#review203934

::: editor/libeditor/HTMLEditRules.cpp:6762
(Diff revision 1)
>      if (!aOffset) {
>        // is there a BR prior to it?
> -      sibling = htmlEditor->GetPriorHTMLSibling(node);
> -      if (!sibling ||
> -          !htmlEditor->IsVisibleBRElement(sibling) ||
> -          TextEditUtils::HasMozAttr(GetAsDOMNode(sibling))) {
> +      brNode = htmlEditor->GetPriorHTMLSibling(node);
> +      if (!brNode ||
> +          !htmlEditor->IsVisibleBRElement(brNode) ||
> +          TextEditUtils::HasMozAttr(GetAsDOMNode(brNode))) {

I will add nsINode version of HasMozAttr
Attachment #8927377 - Flags: review?(m_kato) → review+
Comment on attachment 8927378 [details]
Bug 1416099 - part 3: Rename aPara of HTMLEditRules::ReturnInParagraph() to aParentDivOrP and make it and aSelection as references

https://reviewboard.mozilla.org/r/198620/#review203936

::: editor/libeditor/HTMLEditRules.cpp:6729
(Diff revision 1)
>    if (NS_WARN_IF(!mHTMLEditor)) {
>      return EditActionResult(NS_ERROR_NOT_AVAILABLE);
>    }
>  
>    nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
> -  if (!aSelection || !aPara || !node) {
> +  if (!node) {

Use "if (!aNode)" and don't use QI (nsINode to nsINode)
Attachment #8927378 - Flags: review?(m_kato) → review+
Comment on attachment 8927379 [details]
Bug 1416099 - part 4: Make HTMLEditRules::ReturnInParagraph() use EditorRawDOMPoint to store point to insert new <br> element before splitting the parent block

https://reviewboard.mozilla.org/r/198622/#review203938
Attachment #8927379 - Flags: review?(m_kato) → review+
Comment on attachment 8927380 [details]
Bug 1416099 - part 5: Rename |selNode|, |selOffset| and |newSelNode| in HTMLEditRules::ReturnInParagraph() to proper names

https://reviewboard.mozilla.org/r/198624/#review203940
Attachment #8927380 - Flags: review?(m_kato) → review+
Comment on attachment 8927381 [details]
Bug 1416099 - part 6: Make HTMLEditRules::WillInsertBreak() use EditorDOMPoint to store selection start

https://reviewboard.mozilla.org/r/198626/#review203942
Attachment #8927381 - Flags: review?(m_kato) → review+
Comment on attachment 8927382 [details]
Bug 1416099 - part 7: Make HTMLEditRules::ReturnInParagraph() use start of selection to split parent block instead of receiving the point from arguments

https://reviewboard.mozilla.org/r/198628/#review203944

::: editor/libeditor/HTMLEditRules.cpp:6740
(Diff revision 1)
>    if (NS_WARN_IF(!mHTMLEditor)) {
>      return EditActionResult(NS_ERROR_NOT_AVAILABLE);
>    }
>  
> -  nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
> -  if (!node) {
> +  RefPtr<HTMLEditor> htmlEditor = mHTMLEditor;
> +

OK, OK.  node check is removed.  So please ignore previous commnet.
Attachment #8927382 - Flags: review?(m_kato) → review+
Pushed by masayuki@d-toybox.com:
https://hg.mozilla.org/integration/autoland/rev/e8347a35706c
part 1: Make HTMLEditRules::ReturnInParagraph() use EditActionResult r=m_kato
https://hg.mozilla.org/integration/autoland/rev/9d743e40fb77
part 2: Rename |sibling| in HTMLEditRules::ReturnInParagraph() to |brNode| r=m_kato
https://hg.mozilla.org/integration/autoland/rev/aaa09a3ca23c
part 3: Rename aPara of HTMLEditRules::ReturnInParagraph() to aParentDivOrP and make it and aSelection as references r=m_kato
https://hg.mozilla.org/integration/autoland/rev/874edea0da06
part 4: Make HTMLEditRules::ReturnInParagraph() use EditorRawDOMPoint to store point to insert new <br> element before splitting the parent block r=m_kato
https://hg.mozilla.org/integration/autoland/rev/1b14ca996bea
part 5: Rename |selNode|, |selOffset| and |newSelNode| in HTMLEditRules::ReturnInParagraph() to proper names r=m_kato
https://hg.mozilla.org/integration/autoland/rev/68a11434e53c
part 6: Make HTMLEditRules::WillInsertBreak() use EditorDOMPoint to store selection start r=m_kato
https://hg.mozilla.org/integration/autoland/rev/a6cae052d973
part 7: Make HTMLEditRules::ReturnInParagraph() use start of selection to split parent block instead of receiving the point from arguments r=m_kato
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: