@@ -589,7 +589,7 @@ uint32_t ContentEventHandler::GetNativeTextLengthBefore(nsIContent* aContent,
589589 if (NS_WARN_IF(aContent->IsText ())) {
590590 return 0 ;
591591 }
592- return ShouldBreakLineBefore (aContent, aRootNode)
592+ return ShouldBreakLineBefore (* aContent, aRootNode)
593593 ? GetBRLength (LINE_BREAK_TYPE_NATIVE)
594594 : 0 ;
595595}
@@ -641,33 +641,33 @@ static uint32_t ConvertToXPOffset(nsIContent* aContent,
641641}
642642
643643/* static */
644- bool ContentEventHandler::ShouldBreakLineBefore (nsIContent* aContent,
645- nsINode* aRootNode ) {
644+ bool ContentEventHandler::ShouldBreakLineBefore (
645+ const nsIContent& aContent, const nsINode* aRootNode /* = nullptr */ ) {
646646 // We don't need to append linebreak at the start of the root element.
647- if (aContent == aRootNode) {
647+ if (& aContent == aRootNode) {
648648 return false ;
649649 }
650650
651651 // If it's not an HTML element (including other markup language's elements),
652652 // we shouldn't insert like break before that for now. Becoming this is a
653653 // problem must be edge case. E.g., when ContentEventHandler is used with
654654 // MathML or SVG elements.
655- if (!aContent-> IsHTMLElement ()) {
655+ if (!aContent. IsHTMLElement ()) {
656656 return false ;
657657 }
658658
659659 // If the element is <br>, we need to check if the <br> is caused by web
660660 // content. Otherwise, i.e., it's caused by internal reason of Gecko,
661661 // it shouldn't be exposed as a line break to flatten text.
662- if (aContent-> IsHTMLElement (nsGkAtoms::br)) {
663- return IsContentBR (* aContent);
662+ if (aContent. IsHTMLElement (nsGkAtoms::br)) {
663+ return IsContentBR (aContent);
664664 }
665665
666666 // Note that ideally, we should refer the style of the primary frame of
667667 // aContent for deciding if it's an inline. However, it's difficult
668668 // IMEContentObserver to notify IME of text change caused by style change.
669669 // Therefore, currently, we should check only from the tag for now.
670- if (aContent-> IsAnyOfHTMLElements (
670+ if (aContent. IsAnyOfHTMLElements (
671671 nsGkAtoms::a, nsGkAtoms::abbr, nsGkAtoms::acronym, nsGkAtoms::b,
672672 nsGkAtoms::bdi, nsGkAtoms::bdo, nsGkAtoms::big, nsGkAtoms::cite,
673673 nsGkAtoms::code, nsGkAtoms::data, nsGkAtoms::del, nsGkAtoms::dfn,
@@ -681,7 +681,8 @@ bool ContentEventHandler::ShouldBreakLineBefore(nsIContent* aContent,
681681
682682 // If the element is unknown element, we shouldn't insert line breaks before
683683 // it since unknown elements should be ignored.
684- RefPtr<HTMLUnknownElement> unknownHTMLElement = do_QueryObject (aContent);
684+ RefPtr<HTMLUnknownElement> unknownHTMLElement =
685+ do_QueryObject (const_cast <nsIContent*>(&aContent));
685686 return !unknownHTMLElement;
686687}
687688
@@ -743,7 +744,7 @@ nsresult ContentEventHandler::GenerateFlatTextContent(
743744 } else {
744745 AppendString (aString, *textNode);
745746 }
746- } else if (ShouldBreakLineBefore (node->AsContent (), mRootContent )) {
747+ } else if (ShouldBreakLineBefore (* node->AsContent (), mRootContent )) {
747748 aString.Append (char16_t (' \n ' ));
748749 }
749750 }
@@ -916,7 +917,7 @@ nsresult ContentEventHandler::GenerateFlatFontRanges(
916917 aLineBreakType);
917918 baseOffset +=
918919 GetTextLengthInRange (content, startOffset, endOffset, aLineBreakType);
919- } else if (ShouldBreakLineBefore (content, mRootContent )) {
920+ } else if (ShouldBreakLineBefore (* content, mRootContent )) {
920921 if (aFontRanges.IsEmpty ()) {
921922 MOZ_ASSERT (baseOffset == 0 );
922923 FontRange* fontRange = AppendFontRange (aFontRanges, baseOffset);
@@ -1055,7 +1056,7 @@ nsresult ContentEventHandler::SetRawRangeFromFlatTextOffset(
10551056
10561057 uint32_t textLength =
10571058 content->IsText () ? GetTextLength (*content->AsText (), aLineBreakType)
1058- : (ShouldBreakLineBefore (content, mRootContent )
1059+ : (ShouldBreakLineBefore (* content, mRootContent )
10591060 ? GetBRLength (aLineBreakType)
10601061 : 0 );
10611062 if (!textLength) {
@@ -1182,7 +1183,7 @@ nsresult ContentEventHandler::SetRawRangeFromFlatTextOffset(
11821183 }
11831184
11841185 if (content->HasChildren () &&
1185- ShouldBreakLineBefore (content, mRootContent )) {
1186+ ShouldBreakLineBefore (* content, mRootContent )) {
11861187 // Rule #2.3: </element>]
11871188 rv = aRawRange->SetEnd (content, 0 );
11881189 if (NS_WARN_IF(NS_FAILED(rv))) {
@@ -1513,7 +1514,7 @@ ContentEventHandler::GetFirstFrameInRangeForTextRect(
15131514
15141515 // If the element node causes a line break before it, it's the first
15151516 // node causing text.
1516- if (ShouldBreakLineBefore (node->AsContent (), mRootContent ) ||
1517+ if (ShouldBreakLineBefore (* node->AsContent (), mRootContent ) ||
15171518 IsPaddingBR (*node->AsContent ())) {
15181519 nodePosition = {node, 0 };
15191520 }
@@ -1606,7 +1607,7 @@ ContentEventHandler::GetLastFrameInRangeForTextRect(const RawRange& aRawRange) {
16061607 break ;
16071608 }
16081609
1609- if (ShouldBreakLineBefore (node->AsContent (), mRootContent ) ||
1610+ if (ShouldBreakLineBefore (* node->AsContent (), mRootContent ) ||
16101611 IsPaddingBR (*node->AsContent ())) {
16111612 nodePosition = {node, 0 };
16121613 break ;
@@ -1667,8 +1668,9 @@ ContentEventHandler::GetLineBreakerRectBefore(nsIFrame* aFrame) {
16671668 // Note that this method should be called only with an element's frame whose
16681669 // open tag causes a line break or moz-<br> for computing empty last line's
16691670 // rect.
1670- MOZ_ASSERT (ShouldBreakLineBefore (aFrame->GetContent (), mRootContent ) ||
1671- (aFrame->GetContent () && IsPaddingBR (*aFrame->GetContent ())));
1671+ MOZ_ASSERT (aFrame->GetContent ());
1672+ MOZ_ASSERT (ShouldBreakLineBefore (*aFrame->GetContent (), mRootContent ) ||
1673+ IsPaddingBR (*aFrame->GetContent ()));
16721674
16731675 nsIFrame* frameForFontMetrics = aFrame;
16741676
@@ -1929,7 +1931,7 @@ nsresult ContentEventHandler::OnQueryTextRectArray(
19291931 // Note that moz-<br> element does not cause any text, however,
19301932 // it represents empty line at the last of current block. Therefore,
19311933 // we need to compute its rect too.
1932- else if (ShouldBreakLineBefore (firstContent, mRootContent ) ||
1934+ else if (ShouldBreakLineBefore (* firstContent, mRootContent ) ||
19331935 IsPaddingBR (*firstContent)) {
19341936 nsRect brRect;
19351937 // If the frame is not a <br> frame, we need to compute the caret rect
@@ -2860,7 +2862,7 @@ nsresult ContentEventHandler::GetFlatTextLengthInRange(
28602862 } else {
28612863 *aLength += GetTextLength (*textNode, aLineBreakType);
28622864 }
2863- } else if (ShouldBreakLineBefore (content, aRootContent)) {
2865+ } else if (ShouldBreakLineBefore (* content, aRootContent)) {
28642866 // If the start position is start of this node but doesn't include the
28652867 // open tag, don't append the line break length.
28662868 if (node == aStartPosition.Container () &&
0 commit comments