Backed out 5 changesets (bug 1058136) for S4 orange

Backed out changeset 713e1d6f09c4 (bug 1058136)
Backed out changeset 032246f68eaa (bug 1058136)
Backed out changeset 7e5502347731 (bug 1058136)
Backed out changeset 37addbdb5cd1 (bug 1058136)
Backed out changeset d9f97b62e3c4 (bug 1058136)
This commit is contained in:
Wes Kocher 2014-08-29 19:00:07 -07:00
Родитель 30e6573815
Коммит ac7b5a4b3b
7 изменённых файлов: 95 добавлений и 206 удалений

Просмотреть файл

@ -67,7 +67,7 @@ interface GeckoEditableListener {
void notifyIMEContext(int state, String typeHint,
String modeHint, String actionHint);
void onSelectionChange(int start, int end);
void onTextChange(CharSequence text, int start, int oldEnd, int newEnd);
void onTextChange(String text, int start, int oldEnd, int newEnd);
}
/*
@ -131,8 +131,6 @@ final class GeckoEditable
static final int TYPE_ACKNOWLEDGE_FOCUS = 5;
// For switching handler; use with IME_SYNCHRONIZE
static final int TYPE_SET_HANDLER = 6;
// For Editable.replace() call involving compositions; use with IME_COMPOSE_TEXT
static final int TYPE_COMPOSE_TEXT = 7;
final int mType;
int mStart;
@ -152,22 +150,7 @@ final class GeckoEditable
throw new IllegalArgumentException(
"invalid replace text offsets: " + start + " to " + end);
}
int actionType = TYPE_REPLACE_TEXT;
if (text instanceof Spanned) {
final Spanned spanned = (Spanned) text;
final Object[] spans = spanned.getSpans(0, spanned.length(), Object.class);
for (Object span : spans) {
if ((spanned.getSpanFlags(span) & Spanned.SPAN_COMPOSING) != 0) {
actionType = TYPE_COMPOSE_TEXT;
break;
}
}
}
final Action action = new Action(actionType);
final Action action = new Action(TYPE_REPLACE_TEXT);
action.mSequence = text;
action.mStart = start;
action.mEnd = end;
@ -246,7 +229,6 @@ final class GeckoEditable
mActionsActive.tryAcquire();
mActions.offer(action);
}
switch (action.mType) {
case Action.TYPE_EVENT:
case Action.TYPE_SET_SELECTION:
@ -256,29 +238,17 @@ final class GeckoEditable
GeckoAppShell.sendEventToGecko(GeckoEvent.createIMEEvent(
GeckoEvent.ImeAction.IME_SYNCHRONIZE));
break;
case Action.TYPE_COMPOSE_TEXT:
// Send different event for composing text.
GeckoAppShell.sendEventToGecko(GeckoEvent.createIMEComposeEvent(
action.mStart, action.mEnd, action.mSequence.toString()));
return;
case Action.TYPE_REPLACE_TEXT:
// try key events first
sendCharKeyEvents(action);
GeckoAppShell.sendEventToGecko(GeckoEvent.createIMEReplaceEvent(
action.mStart, action.mEnd, action.mSequence.toString()));
break;
case Action.TYPE_ACKNOWLEDGE_FOCUS:
GeckoAppShell.sendEventToGecko(GeckoEvent.createIMEEvent(
GeckoEvent.ImeAction.IME_ACKNOWLEDGE_FOCUS));
break;
default:
throw new IllegalStateException("Action not processed");
}
++mIcUpdateSeqno;
}
@ -337,10 +307,12 @@ final class GeckoEditable
throw new IllegalStateException("empty actions queue");
}
mActions.poll();
synchronized(this) {
if (mActions.isEmpty()) {
mActionsActive.release();
// Don't bother locking if queue is not empty yet
if (mActions.isEmpty()) {
synchronized(this) {
if (mActions.isEmpty()) {
mActionsActive.release();
}
}
}
}
@ -708,12 +680,6 @@ final class GeckoEditable
getConstantName(Action.class, "TYPE_", action.mType) + ")");
}
switch (action.mType) {
case Action.TYPE_COMPOSE_TEXT:
// Compositions don't trigger text change notification, so notify manually.
onTextChange(action.mSequence, action.mStart, action.mEnd,
action.mStart + action.mSequence.length());
break;
case Action.TYPE_SET_SELECTION:
final int len = mText.length();
final int curStart = Selection.getSelectionStart(mText);
@ -901,7 +867,7 @@ final class GeckoEditable
}
@Override
public void onTextChange(final CharSequence text, final int start,
public void onTextChange(final String text, final int start,
final int unboundedOldEnd, final int unboundedNewEnd) {
if (DEBUG) {
// GeckoEditableListener methods should all be called from the Gecko thread
@ -1068,13 +1034,11 @@ final class GeckoEditable
if (DEBUG) {
StringBuilder log = new StringBuilder(method.getName());
log.append("(");
if (args != null) {
for (Object arg : args) {
debugAppend(log, arg).append(", ");
}
if (args.length > 0) {
log.setLength(log.length() - 2);
}
for (Object arg : args) {
debugAppend(log, arg).append(", ");
}
if (args.length > 0) {
log.setLength(log.length() - 2);
}
if (method.getReturnType().equals(Void.TYPE)) {
log.append(")");

Просмотреть файл

@ -147,8 +147,7 @@ public class GeckoEvent {
IME_ADD_COMPOSITION_RANGE(3),
IME_UPDATE_COMPOSITION(4),
IME_REMOVE_COMPOSITION(5),
IME_ACKNOWLEDGE_FOCUS(6),
IME_COMPOSE_TEXT(7);
IME_ACKNOWLEDGE_FOCUS(6);
public final int value;
@ -601,17 +600,10 @@ public class GeckoEvent {
return event;
}
public static GeckoEvent createIMEReplaceEvent(int start, int end, String text) {
return createIMETextEvent(false, start, end, text);
}
public static GeckoEvent createIMEComposeEvent(int start, int end, String text) {
return createIMETextEvent(true, start, end, text);
}
private static GeckoEvent createIMETextEvent(boolean compose, int start, int end, String text) {
public static GeckoEvent createIMEReplaceEvent(int start, int end,
String text) {
GeckoEvent event = GeckoEvent.get(NativeGeckoEvent.IME_EVENT);
event.mAction = (compose ? ImeAction.IME_COMPOSE_TEXT : ImeAction.IME_REPLACE_TEXT).value;
event.mAction = ImeAction.IME_REPLACE_TEXT.value;
event.mStart = start;
event.mEnd = end;
event.mCharacters = text;

Просмотреть файл

@ -430,7 +430,7 @@ class GeckoInputConnection
}
@Override
public void onTextChange(CharSequence text, int start, int oldEnd, int newEnd) {
public void onTextChange(String text, int start, int oldEnd, int newEnd) {
if (mUpdateRequest == null) {
// Android always expects selection updates when not in extracted mode;
@ -1024,23 +1024,21 @@ final class DebugGeckoInputConnection
StringBuilder log = new StringBuilder(mCallLevel);
log.append("> ").append(method.getName()).append("(");
if (args != null) {
for (Object arg : args) {
// translate argument values to constant names
if ("notifyIME".equals(method.getName()) && arg == args[0]) {
log.append(GeckoEditable.getConstantName(
GeckoEditableListener.class, "NOTIFY_IME_", arg));
} else if ("notifyIMEContext".equals(method.getName()) && arg == args[0]) {
log.append(GeckoEditable.getConstantName(
GeckoEditableListener.class, "IME_STATE_", arg));
} else {
GeckoEditable.debugAppend(log, arg);
}
log.append(", ");
}
if (args.length > 0) {
log.setLength(log.length() - 2);
for (Object arg : args) {
// translate argument values to constant names
if ("notifyIME".equals(method.getName()) && arg == args[0]) {
log.append(GeckoEditable.getConstantName(
GeckoEditableListener.class, "NOTIFY_IME_", arg));
} else if ("notifyIMEContext".equals(method.getName()) && arg == args[0]) {
log.append(GeckoEditable.getConstantName(
GeckoEditableListener.class, "IME_STATE_", arg));
} else {
GeckoEditable.debugAppend(log, arg);
}
log.append(", ");
}
if (args.length > 0) {
log.setLength(log.length() - 2);
}
log.append(")");
Log.d(LOGTAG, log.toString());

Просмотреть файл

@ -471,8 +471,7 @@ AndroidGeckoEvent::Init(JNIEnv *jenv, jobject jobj)
mStart = jenv->GetIntField(jobj, jStartField);
mEnd = jenv->GetIntField(jobj, jEndField);
if (mAction == IME_REPLACE_TEXT ||
mAction == IME_COMPOSE_TEXT) {
if (mAction == IME_REPLACE_TEXT) {
ReadCharactersField(jenv);
} else if (mAction == IME_UPDATE_COMPOSITION ||
mAction == IME_ADD_COMPOSITION_RANGE) {

Просмотреть файл

@ -744,7 +744,6 @@ public:
IME_UPDATE_COMPOSITION = 4,
IME_REMOVE_COMPOSITION = 5,
IME_ACKNOWLEDGE_FOCUS = 6,
IME_COMPOSE_TEXT = 7,
dummy_ime_enum_list_end
};

Просмотреть файл

@ -177,7 +177,6 @@ nsWindow::nsWindow() :
mParent(nullptr),
mFocus(nullptr),
mIMEComposing(false),
mIMEComposingStart(-1),
mIMEMaskSelectionUpdate(false),
mIMEMaskTextUpdate(false),
mIMEMaskEventsCount(1), // Mask IME events since there's no focus yet
@ -680,7 +679,6 @@ nsWindow::DispatchEvent(WidgetGUIEvent* aEvent)
case NS_COMPOSITION_END:
MOZ_ASSERT(mIMEComposing);
mIMEComposing = false;
mIMEComposingStart = -1;
mIMEComposingText.Truncate();
break;
case NS_TEXT_TEXT:
@ -1712,7 +1710,6 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *ae)
}
mozilla::widget::android::GeckoAppShell::NotifyIME(AndroidBridge::NOTIFY_IME_REPLY_EVENT);
return;
} else if (ae->Action() == AndroidGeckoEvent::IME_UPDATE_CONTEXT) {
mozilla::widget::android::GeckoAppShell::NotifyIMEContext(mInputContext.mIMEState.mEnabled,
mInputContext.mHTMLInputType,
@ -1721,33 +1718,27 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *ae)
mIMEUpdatingContext = false;
return;
}
if (mIMEMaskEventsCount > 0) {
// Still reply to events, but don't do anything else
if (ae->Action() == AndroidGeckoEvent::IME_SYNCHRONIZE ||
ae->Action() == AndroidGeckoEvent::IME_COMPOSE_TEXT ||
ae->Action() == AndroidGeckoEvent::IME_REPLACE_TEXT) {
mozilla::widget::android::GeckoAppShell::NotifyIME(AndroidBridge::NOTIFY_IME_REPLY_EVENT);
}
return;
}
switch (ae->Action()) {
case AndroidGeckoEvent::IME_FLUSH_CHANGES:
{
FlushIMEChanges();
}
break;
case AndroidGeckoEvent::IME_SYNCHRONIZE:
{
FlushIMEChanges();
mozilla::widget::android::GeckoAppShell::NotifyIME(AndroidBridge::NOTIFY_IME_REPLY_EVENT);
}
break;
case AndroidGeckoEvent::IME_REPLACE_TEXT:
case AndroidGeckoEvent::IME_COMPOSE_TEXT:
{
/*
Replace text in Gecko thread from ae->Start() to ae->End()
@ -1760,48 +1751,31 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *ae)
Gecko text
*/
AutoIMEMask selMask(mIMEMaskSelectionUpdate);
if (!mIMEKeyEvents.IsEmpty() ||
mIMEComposingStart < 0 ||
ae->Start() != mIMEComposingStart ||
ae->End() != mIMEComposingStart +
int32_t(mIMEComposingText.Length())) {
// Only start a new composition if we have key events,
// if we don't have an existing composition, or
// the replaced text does not match our composition.
RemoveIMEComposition();
{
WidgetSelectionEvent event(true, NS_SELECTION_SET, this);
InitEvent(event, nullptr);
event.mOffset = uint32_t(ae->Start());
event.mLength = uint32_t(ae->End() - ae->Start());
event.mExpandToClusterBoundary = false;
DispatchEvent(&event);
}
if (!mIMEKeyEvents.IsEmpty()) {
for (uint32_t i = 0; i < mIMEKeyEvents.Length(); i++) {
OnKeyEvent(&mIMEKeyEvents[i]);
}
mIMEKeyEvents.Clear();
FlushIMEChanges();
mozilla::widget::android::GeckoAppShell::NotifyIME(
AndroidBridge::NOTIFY_IME_REPLY_EVENT);
// Break out of the switch block
break;
}
{
WidgetCompositionEvent event(
true, NS_COMPOSITION_START, this);
InitEvent(event, nullptr);
DispatchEvent(&event);
mIMEComposingStart = ae->Start();
}
RemoveIMEComposition();
{
WidgetSelectionEvent event(true, NS_SELECTION_SET, this);
InitEvent(event, nullptr);
event.mOffset = uint32_t(ae->Start());
event.mLength = uint32_t(ae->End() - ae->Start());
event.mExpandToClusterBoundary = false;
DispatchEvent(&event);
}
if (!mIMEKeyEvents.IsEmpty()) {
for (uint32_t i = 0; i < mIMEKeyEvents.Length(); i++) {
OnKeyEvent(&mIMEKeyEvents[i]);
}
mIMEKeyEvents.Clear();
FlushIMEChanges();
mozilla::widget::android::GeckoAppShell::NotifyIME(AndroidBridge::NOTIFY_IME_REPLY_EVENT);
break;
}
{
WidgetCompositionEvent event(true, NS_COMPOSITION_START, this);
InitEvent(event, nullptr);
DispatchEvent(&event);
}
{
WidgetCompositionEvent event(true, NS_COMPOSITION_UPDATE, this);
InitEvent(event, nullptr);
@ -1814,23 +1788,16 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *ae)
event.theText = ae->Characters();
DispatchEvent(&event);
}
// Don't end composition when composing text.
if (ae->Action() != AndroidGeckoEvent::IME_COMPOSE_TEXT)
{
WidgetCompositionEvent event(true, NS_COMPOSITION_END, this);
InitEvent(event, nullptr);
event.data = ae->Characters();
DispatchEvent(&event);
FlushIMEChanges();
}
mozilla::widget::android::GeckoAppShell::NotifyIME(
AndroidBridge::NOTIFY_IME_REPLY_EVENT);
FlushIMEChanges();
mozilla::widget::android::GeckoAppShell::NotifyIME(AndroidBridge::NOTIFY_IME_REPLY_EVENT);
}
break;
case AndroidGeckoEvent::IME_SET_SELECTION:
{
/*
@ -1907,6 +1874,7 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *ae)
*/
AutoIMEMask selMask(mIMEMaskSelectionUpdate);
AutoIMEMask textMask(mIMEMaskTextUpdate);
RemoveIMEComposition();
WidgetTextEvent event(true, NS_TEXT_TEXT, this);
InitEvent(event, nullptr);
@ -1914,49 +1882,28 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *ae)
event.mRanges = new TextRangeArray();
mIMERanges.swap(event.mRanges);
if (mIMEComposingStart < 0 ||
ae->Start() != mIMEComposingStart ||
ae->End() != mIMEComposingStart +
int32_t(mIMEComposingText.Length())) {
// Only start new composition if we don't have an existing one,
// or if the existing composition doesn't match the new one.
RemoveIMEComposition();
{
WidgetSelectionEvent event(true, NS_SELECTION_SET, this);
InitEvent(event, nullptr);
event.mOffset = uint32_t(ae->Start());
event.mLength = uint32_t(ae->End() - ae->Start());
event.mExpandToClusterBoundary = false;
DispatchEvent(&event);
}
{
WidgetQueryContentEvent queryEvent(true,
NS_QUERY_SELECTED_TEXT,
this);
InitEvent(queryEvent, nullptr);
DispatchEvent(&queryEvent);
MOZ_ASSERT(queryEvent.mSucceeded && !queryEvent.mWasAsync);
event.theText = queryEvent.mReply.mString;
mIMEComposingStart = queryEvent.mReply.mOffset;
}
{
WidgetCompositionEvent event(
true, NS_COMPOSITION_START, this);
InitEvent(event, nullptr);
DispatchEvent(&event);
}
} else {
// If the new composition matches the existing composition,
// reuse the old composition.
event.theText = mIMEComposingText;
{
WidgetSelectionEvent event(true, NS_SELECTION_SET, this);
InitEvent(event, nullptr);
event.mOffset = uint32_t(ae->Start());
event.mLength = uint32_t(ae->End() - ae->Start());
event.mExpandToClusterBoundary = false;
DispatchEvent(&event);
}
{
WidgetQueryContentEvent queryEvent(true,
NS_QUERY_SELECTED_TEXT,
this);
InitEvent(queryEvent, nullptr);
DispatchEvent(&queryEvent);
MOZ_ASSERT(queryEvent.mSucceeded && !queryEvent.mWasAsync);
event.theText = queryEvent.mReply.mString;
}
{
WidgetCompositionEvent event(true, NS_COMPOSITION_START, this);
InitEvent(event, nullptr);
DispatchEvent(&event);
}
{
WidgetCompositionEvent compositionUpdate(true,
NS_COMPOSITION_UPDATE,
@ -1977,14 +1924,12 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *ae)
// Notify SelectionHandler of final caret position
// Required in cases of keyboards providing autoCorrections
AndroidGeckoEvent* broadcastEvent =
AndroidGeckoEvent::MakeBroadcastEvent(
NS_LITERAL_CSTRING("TextSelection:UpdateCaretPos"),
NS_LITERAL_CSTRING(""));
AndroidGeckoEvent* broadcastEvent = AndroidGeckoEvent::MakeBroadcastEvent(
NS_LITERAL_CSTRING("TextSelection:UpdateCaretPos"),
NS_LITERAL_CSTRING(""));
nsAppShell::gAppShell->PostEvent(broadcastEvent);
}
break;
case AndroidGeckoEvent::IME_REMOVE_COMPOSITION:
{
/*
@ -2189,25 +2134,18 @@ nsWindow::FlushIMEChanges()
for (uint32_t i = 0; i < mIMETextChanges.Length(); i++) {
IMEChange &change = mIMETextChanges[i];
if (change.mStart == change.mOldEnd &&
change.mStart == change.mNewEnd) {
continue;
}
WidgetQueryContentEvent event(true, NS_QUERY_TEXT_CONTENT, this);
InitEvent(event, nullptr);
event.InitForQueryTextContent(change.mStart,
change.mNewEnd - change.mStart);
DispatchEvent(&event);
if (!event.mSucceeded)
return;
if (change.mNewEnd != change.mStart) {
InitEvent(event, nullptr);
event.InitForQueryTextContent(change.mStart,
change.mNewEnd - change.mStart);
DispatchEvent(&event);
if (!event.mSucceeded)
return;
}
mozilla::widget::android::GeckoAppShell::NotifyIMEChange(
event.mReply.mString, change.mStart,
change.mOldEnd, change.mNewEnd);
mozilla::widget::android::GeckoAppShell::NotifyIMEChange(event.mReply.mString,
change.mStart,
change.mOldEnd,
change.mNewEnd);
}
mIMETextChanges.Clear();

Просмотреть файл

@ -188,10 +188,9 @@ protected:
nsCOMPtr<nsIIdleServiceInternal> mIdleService;
bool mIMEComposing;
int32_t mIMEComposingStart;
nsString mIMEComposingText;
bool mIMEMaskSelectionUpdate, mIMEMaskTextUpdate;
int32_t mIMEMaskEventsCount; // Mask events when > 0
nsString mIMEComposingText;
nsRefPtr<mozilla::TextRangeArray> mIMERanges;
bool mIMEUpdatingContext;
nsAutoTArray<mozilla::AndroidGeckoEvent, 8> mIMEKeyEvents;