From 41b695192adb54dfcce420de7f99ed2d3069774d Mon Sep 17 00:00:00 2001 From: Simon Montagu Date: Tue, 5 Jul 2011 08:42:32 +0300 Subject: [PATCH] Undefine caret bidi level during reflow instead of on text entry. Bug 664087, r=roc --- editor/libeditor/html/nsHTMLEditRules.cpp | 20 -------------------- editor/libeditor/text/nsTextEditRules.cpp | 16 ---------------- layout/generic/nsTextFrameThebes.cpp | 13 +++++++++++++ 3 files changed, 13 insertions(+), 36 deletions(-) diff --git a/editor/libeditor/html/nsHTMLEditRules.cpp b/editor/libeditor/html/nsHTMLEditRules.cpp index 2cbbdd1987b8..2678bcbc1260 100644 --- a/editor/libeditor/html/nsHTMLEditRules.cpp +++ b/editor/libeditor/html/nsHTMLEditRules.cpp @@ -389,26 +389,6 @@ nsHTMLEditRules::AfterEdit(PRInt32 action, nsIEditor::EDirection aDirection) // free up selectionState range item (mHTMLEditor->mRangeUpdater).DropRangeItem(&mRangeItem); - /* After inserting text the cursor Bidi level must be set to the level of the inserted text. - * This is difficult, because we cannot know what the level is until after the Bidi algorithm - * is applied to the whole paragraph. - * - * So we set the cursor Bidi level to UNDEFINED here, and the caret code will set it correctly later - */ - if (action == nsEditor::kOpInsertText - || action == nsEditor::kOpInsertIMEText) { - - nsCOMPtr selection; - nsresult res = mHTMLEditor->GetSelection(getter_AddRefs(selection)); - NS_ENSURE_SUCCESS(res, res); - nsCOMPtr privateSelection(do_QueryInterface(selection)); - nsRefPtr frameSelection; - privateSelection->GetFrameSelection(getter_AddRefs(frameSelection)); - if (frameSelection) { - frameSelection->UndefineCaretBidiLevel(); - } - } - // Reset the contenteditable count to its previous value if (mRestoreContentEditableCount) { nsCOMPtr doc; diff --git a/editor/libeditor/text/nsTextEditRules.cpp b/editor/libeditor/text/nsTextEditRules.cpp index 8fffb584d92e..d1ad81ce1f79 100644 --- a/editor/libeditor/text/nsTextEditRules.cpp +++ b/editor/libeditor/text/nsTextEditRules.cpp @@ -231,22 +231,6 @@ nsTextEditRules::AfterEdit(PRInt32 action, nsIEditor::EDirection aDirection) // collapse the selection to the trailing BR if it's at the end of our text node CollapseSelectionToTrailingBRIfNeeded(selection); - - /* After inserting text the cursor Bidi level must be set to the level of the inserted text. - * This is difficult, because we cannot know what the level is until after the Bidi algorithm - * is applied to the whole paragraph. - * - * So we set the cursor Bidi level to UNDEFINED here, and the caret code will set it correctly later - */ - if (action == nsEditor::kOpInsertText - || action == nsEditor::kOpInsertIMEText) { - nsCOMPtr privateSelection(do_QueryInterface(selection)); - nsRefPtr frameSelection; - privateSelection->GetFrameSelection(getter_AddRefs(frameSelection)); - if (frameSelection) { - frameSelection->UndefineCaretBidiLevel(); - } - } } return res; } diff --git a/layout/generic/nsTextFrameThebes.cpp b/layout/generic/nsTextFrameThebes.cpp index 46d37b8ea48a..7cfb4746ba61 100644 --- a/layout/generic/nsTextFrameThebes.cpp +++ b/layout/generic/nsTextFrameThebes.cpp @@ -7637,6 +7637,19 @@ nsTextFrame::AdjustOffsetsForBidi(PRInt32 aStart, PRInt32 aEnd) mContentOffset = aStart; SetLength(aEnd - aStart, nsnull, 0); + + /** + * After inserting text the caret Bidi level must be set to the level of the + * inserted text.This is difficult, because we cannot know what the level is + * until after the Bidi algorithm is applied to the whole paragraph. + * + * So we set the caret Bidi level to UNDEFINED here, and the caret code will + * set it correctly later + */ + nsRefPtr frameSelection = GetFrameSelection(); + if (frameSelection) { + frameSelection->UndefineCaretBidiLevel(); + } } /**