mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 799094 - Refactor handle-picking code into a reusable method. r=margaret
This commit is contained in:
parent
65733730db
commit
86ffca961d
@ -54,6 +54,16 @@ class TextSelection extends Layer implements GeckoEventListener {
|
|||||||
unregisterEventListener("TextSelection:PositionHandles");
|
unregisterEventListener("TextSelection:PositionHandles");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private TextSelectionHandle getHandle(String name) {
|
||||||
|
if (name.equals("START")) {
|
||||||
|
return mStartHandle;
|
||||||
|
} else if (name.equals("MIDDLE")) {
|
||||||
|
return mMiddleHandle;
|
||||||
|
} else {
|
||||||
|
return mEndHandle;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void handleMessage(String event, JSONObject message) {
|
public void handleMessage(String event, JSONObject message) {
|
||||||
try {
|
try {
|
||||||
if (event.equals("TextSelection:ShowHandles")) {
|
if (event.equals("TextSelection:ShowHandles")) {
|
||||||
@ -63,13 +73,7 @@ class TextSelection extends Layer implements GeckoEventListener {
|
|||||||
try {
|
try {
|
||||||
for (int i=0; i < handles.length(); i++) {
|
for (int i=0; i < handles.length(); i++) {
|
||||||
String handle = handles.getString(i);
|
String handle = handles.getString(i);
|
||||||
|
getHandle(handle).setVisibility(View.VISIBLE);
|
||||||
if (handle.equals("START"))
|
|
||||||
mStartHandle.setVisibility(View.VISIBLE);
|
|
||||||
else if (handle.equals("MIDDLE"))
|
|
||||||
mMiddleHandle.setVisibility(View.VISIBLE);
|
|
||||||
else
|
|
||||||
mEndHandle.setVisibility(View.VISIBLE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mViewLeft = 0.0f;
|
mViewLeft = 0.0f;
|
||||||
@ -94,12 +98,7 @@ class TextSelection extends Layer implements GeckoEventListener {
|
|||||||
|
|
||||||
for (int i=0; i < handles.length(); i++) {
|
for (int i=0; i < handles.length(); i++) {
|
||||||
String handle = handles.getString(i);
|
String handle = handles.getString(i);
|
||||||
if (handle.equals("START"))
|
getHandle(handle).setVisibility(View.GONE);
|
||||||
mStartHandle.setVisibility(View.GONE);
|
|
||||||
else if (handle.equals("MIDDLE"))
|
|
||||||
mMiddleHandle.setVisibility(View.GONE);
|
|
||||||
else
|
|
||||||
mEndHandle.setVisibility(View.GONE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch(Exception e) {}
|
} catch(Exception e) {}
|
||||||
@ -116,12 +115,7 @@ class TextSelection extends Layer implements GeckoEventListener {
|
|||||||
int left = position.getInt("left");
|
int left = position.getInt("left");
|
||||||
int top = position.getInt("top");
|
int top = position.getInt("top");
|
||||||
|
|
||||||
if (handle.equals("START"))
|
getHandle(handle).positionFromGecko(left, top);
|
||||||
mStartHandle.positionFromGecko(left, top);
|
|
||||||
else if (handle.equals("MIDDLE"))
|
|
||||||
mMiddleHandle.positionFromGecko(left, top);
|
|
||||||
else
|
|
||||||
mEndHandle.positionFromGecko(left, top);
|
|
||||||
}
|
}
|
||||||
} catch (Exception e) { }
|
} catch (Exception e) { }
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user