mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Bug 1067788 - Part 4: Update test_bug496275.html. Add setCaretBidiLevel method to Selection. r=smontagu r=ehsan
This commit is contained in:
parent
bc4f5395cc
commit
be8a64fc3b
@ -66,6 +66,9 @@ partial interface Selection {
|
||||
[ChromeOnly,Throws]
|
||||
attribute boolean interlinePosition;
|
||||
|
||||
[Throws]
|
||||
attribute short? caretBidiLevel;
|
||||
|
||||
[ChromeOnly,Throws]
|
||||
DOMString toStringWithFormat(DOMString formatType, unsigned long flags, long wrapColumn);
|
||||
[ChromeOnly,Throws]
|
||||
|
@ -179,6 +179,9 @@ public:
|
||||
bool GetInterlinePosition(mozilla::ErrorResult& aRv);
|
||||
void SetInterlinePosition(bool aValue, mozilla::ErrorResult& aRv);
|
||||
|
||||
Nullable<int16_t> GetCaretBidiLevel(mozilla::ErrorResult& aRv) const;
|
||||
void SetCaretBidiLevel(const Nullable<int16_t>& aCaretBidiLevel, mozilla::ErrorResult& aRv);
|
||||
|
||||
void ToStringWithFormat(const nsAString& aFormatType,
|
||||
uint32_t aFlags,
|
||||
int32_t aWrapColumn,
|
||||
|
@ -713,6 +713,12 @@ nsFrameSelection::SetCaretBidiLevel(nsBidiLevel aLevel)
|
||||
// If the current level is undefined, we have just inserted new text.
|
||||
// In this case, we don't want to reset the keyboard language
|
||||
mCaretBidiLevel = aLevel;
|
||||
|
||||
nsRefPtr<nsCaret> caret;
|
||||
if (mShell && (caret = mShell->GetCaret())) {
|
||||
caret->SchedulePaint();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1188,6 +1194,32 @@ Selection::GetInterlinePosition(ErrorResult& aRv)
|
||||
return mFrameSelection->GetHint() == CARET_ASSOCIATE_AFTER;
|
||||
}
|
||||
|
||||
Nullable<int16_t>
|
||||
Selection::GetCaretBidiLevel(mozilla::ErrorResult& aRv) const
|
||||
{
|
||||
if (!mFrameSelection) {
|
||||
aRv.Throw(NS_ERROR_NOT_INITIALIZED);
|
||||
return Nullable<int16_t>();
|
||||
}
|
||||
nsBidiLevel caretBidiLevel = mFrameSelection->GetCaretBidiLevel();
|
||||
return (caretBidiLevel & BIDI_LEVEL_UNDEFINED) ?
|
||||
Nullable<int16_t>() : Nullable<int16_t>(caretBidiLevel);
|
||||
}
|
||||
|
||||
void
|
||||
Selection::SetCaretBidiLevel(const Nullable<int16_t>& aCaretBidiLevel, mozilla::ErrorResult& aRv)
|
||||
{
|
||||
if (!mFrameSelection) {
|
||||
aRv.Throw(NS_ERROR_NOT_INITIALIZED);
|
||||
return;
|
||||
}
|
||||
if (aCaretBidiLevel.IsNull()) {
|
||||
mFrameSelection->UndefineCaretBidiLevel();
|
||||
} else {
|
||||
mFrameSelection->SetCaretBidiLevel(aCaretBidiLevel.Value());
|
||||
}
|
||||
}
|
||||
|
||||
nsPrevNextBidiLevels
|
||||
nsFrameSelection::GetPrevNextBidiLevels(nsIContent *aNode,
|
||||
uint32_t aContentOffset,
|
||||
|
@ -145,6 +145,7 @@ function run() {
|
||||
//
|
||||
$("ltr").focus();
|
||||
sel.collapse($("l1"), 0);
|
||||
SpecialPowers.wrap(sel).caretBidiLevel = 1;
|
||||
isAt("l1", 0, "l1", 0, "test 6a");
|
||||
sel.modify("Move", "Left", "Character");
|
||||
isAt("l1", 1, "l1", 1, "test 6b");
|
||||
@ -156,6 +157,7 @@ function run() {
|
||||
isAt("l1", 1, "l1", 0, "test 6e");
|
||||
|
||||
sel.collapse($("l1"), 0);
|
||||
SpecialPowers.wrap(sel).caretBidiLevel = 1;
|
||||
sel.modify("move", "left", "character");
|
||||
sel.modify("extend", "right", "Word");
|
||||
isAt("l1", 1, "l1", 3, "test 7a");
|
||||
@ -169,6 +171,7 @@ function run() {
|
||||
isAt("l1", 3, "l1", 3, "test 7e");
|
||||
|
||||
sel.collapse($("l1"), 0);
|
||||
SpecialPowers.wrap(sel).caretBidiLevel = 1;
|
||||
sel.modify("extend", "left", "lineboundary");
|
||||
isAt("l1", 0, "l1", 3, "test 8a");
|
||||
sel.modify("move", "forward", "lineboundary");
|
||||
@ -183,6 +186,7 @@ function run() {
|
||||
// Put the cursor at the left edge of the first line so that when we go up
|
||||
// and down, where we end up doesn't depend on how the characters line up.
|
||||
sel.collapse($("l1"), 0);
|
||||
SpecialPowers.wrap(sel).caretBidiLevel = 1;
|
||||
sel.modify("move", "left", "lineboundary");
|
||||
isAt("l1", 3, "l1", 3, "test 9a");
|
||||
sel.modify("move", "forward", "Line");
|
||||
@ -195,6 +199,7 @@ function run() {
|
||||
|
||||
// Same test as above, now with absolute directions.
|
||||
sel.collapse($("l1"), 0);
|
||||
SpecialPowers.wrap(sel).caretBidiLevel = 1;
|
||||
sel.modify("move", "left", "lineboundary");
|
||||
isAt("l1", 3, "l1", 3, "test 10a");
|
||||
sel.modify("move", "right", "line");
|
||||
|
Loading…
Reference in New Issue
Block a user