Skip to content

Commit

Permalink
Bug 1067788 - Part 1: Don't invalidate bidi cursor directionality dur…
Browse files Browse the repository at this point in the history
…ing a delete. r=smontagu

--HG--
extra : rebase_source : e7800dac174b1bd155dc2630a410f55eadef0f6b
  • Loading branch information
tedders1 committed Jun 1, 2015
1 parent 210b785 commit 20737c0
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 13 deletions.
2 changes: 2 additions & 0 deletions editor/libeditor/nsHTMLEditRules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -614,11 +614,13 @@ nsHTMLEditRules::WillDoAction(Selection* aSelection,
switch (info->action) {
case EditAction::insertText:
case EditAction::insertIMEText:
UndefineCaretBidiLevel(aSelection);
return WillInsertText(info->action, aSelection, aCancel, aHandled,
info->inString, info->outString, info->maxLength);
case EditAction::loadHTML:
return WillLoadHTML(aSelection, aCancel);
case EditAction::insertBreak:
UndefineCaretBidiLevel(aSelection);
return WillInsertBreak(aSelection, aCancel, aHandled);
case EditAction::deleteSelection:
return WillDeleteSelection(aSelection, info->collapsedAction,
Expand Down
2 changes: 2 additions & 0 deletions editor/libeditor/nsTextEditRules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,11 @@ nsTextEditRules::WillDoAction(Selection* aSelection,

switch (info->action) {
case EditAction::insertBreak:
UndefineCaretBidiLevel(aSelection);
return WillInsertBreak(aSelection, aCancel, aHandled, info->maxLength);
case EditAction::insertText:
case EditAction::insertIMEText:
UndefineCaretBidiLevel(aSelection);
return WillInsertText(info->action, aSelection, aCancel, aHandled,
info->inString, info->outString, info->maxLength);
case EditAction::deleteSelection:
Expand Down
2 changes: 2 additions & 0 deletions editor/libeditor/nsTextEditRules.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ class nsTextEditRules : public nsIEditRules, public nsITimerCallback
nsresult CreateMozBR(nsIDOMNode* inParent, int32_t inOffset,
nsIDOMNode** outBRNode = nullptr);

void UndefineCaretBidiLevel(Selection* aSelection);

nsresult CheckBidiLevelForDeletion(mozilla::dom::Selection* aSelection,
nsIDOMNode *aSelNode,
int32_t aSelOffset,
Expand Down
16 changes: 16 additions & 0 deletions editor/libeditor/nsTextEditRulesBidi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,19 @@ nsTextEditRules::CheckBidiLevelForDeletion(Selection* aSelection,
return NS_OK;
}

void
nsTextEditRules::UndefineCaretBidiLevel(Selection* aSelection)
{
/**
* 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<nsFrameSelection> frameSelection = aSelection->GetFrameSelection();
if (frameSelection) {
frameSelection->UndefineCaretBidiLevel();
}
}
13 changes: 0 additions & 13 deletions layout/generic/nsTextFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8995,19 +8995,6 @@ nsTextFrame::AdjustOffsetsForBidi(int32_t aStart, int32_t aEnd)

mContentOffset = aStart;
SetLength(aEnd - aStart, nullptr, 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<nsFrameSelection> frameSelection = GetFrameSelection();
if (frameSelection) {
frameSelection->UndefineCaretBidiLevel();
}
}

/**
Expand Down

0 comments on commit 20737c0

Please sign in to comment.