Skip to content

Commit 10cc5d1

Browse files
Artem Kileevmagreenblatt
authored andcommitted
Add undo, redo, cut, copy and paste methods to CefFrame
1 parent 2fd177c commit 10cc5d1

File tree

4 files changed

+165
-0
lines changed

4 files changed

+165
-0
lines changed

java/org/cef/browser/CefFrame.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,29 @@ public interface CefFrame {
7373
* @param line The base line number to use for error reporting.
7474
*/
7575
public void executeJavaScript(String code, String url, int line);
76+
77+
/**
78+
* Execute undo in this frame.
79+
*/
80+
public void undo();
81+
82+
/**
83+
* Execute redo in this frame.
84+
*/
85+
public void redo();
86+
87+
/**
88+
* Execute cut in this frame.
89+
*/
90+
public void cut();
91+
92+
/**
93+
* Execute copy in this frame.
94+
*/
95+
public void copy();
96+
97+
/**
98+
* Execute paste in this frame.
99+
*/
100+
public void paste();
76101
}

java/org/cef/browser/CefFrame_N.java

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,46 @@ public void executeJavaScript(String code, String url, int line) {
108108
}
109109
}
110110

111+
public void undo() {
112+
try {
113+
N_Undo(getNativeRef(null));
114+
} catch (UnsatisfiedLinkError ule) {
115+
ule.printStackTrace();
116+
}
117+
}
118+
119+
public void redo() {
120+
try {
121+
N_Redo(getNativeRef(null));
122+
} catch (UnsatisfiedLinkError ule) {
123+
ule.printStackTrace();
124+
}
125+
}
126+
127+
public void cut() {
128+
try {
129+
N_Cut(getNativeRef(null));
130+
} catch (UnsatisfiedLinkError ule) {
131+
ule.printStackTrace();
132+
}
133+
}
134+
135+
public void copy() {
136+
try {
137+
N_Copy(getNativeRef(null));
138+
} catch (UnsatisfiedLinkError ule) {
139+
ule.printStackTrace();
140+
}
141+
}
142+
143+
public void paste() {
144+
try {
145+
N_Paste(getNativeRef(null));
146+
} catch (UnsatisfiedLinkError ule) {
147+
ule.printStackTrace();
148+
}
149+
}
150+
111151
private final native void N_Dispose(long self);
112152
private final native long N_GetIdentifier(long self);
113153
private final native String N_GetURL(long self);
@@ -117,4 +157,9 @@ public void executeJavaScript(String code, String url, int line) {
117157
private final native boolean N_IsFocused(long self);
118158
private final native CefFrame N_GetParent(long self);
119159
private final native void N_ExecuteJavaScript(long self, String code, String url, int line);
160+
private final native void N_Undo(long self);
161+
private final native void N_Redo(long self);
162+
private final native void N_Cut(long self);
163+
private final native void N_Copy(long self);
164+
private final native void N_Paste(long self);
120165
}

native/CefFrame_N.cpp

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,53 @@ Java_org_cef_browser_CefFrame_1N_N_1ExecuteJavaScript(JNIEnv* env,
114114
frame->ExecuteJavaScript(GetJNIString(env, code), GetJNIString(env, url),
115115
line);
116116
}
117+
118+
JNIEXPORT void JNICALL Java_org_cef_browser_CefFrame_1N_N_1Undo(JNIEnv* env,
119+
jobject obj,
120+
jlong self) {
121+
CefRefPtr<CefFrame> frame = GetSelf(self);
122+
if (!frame)
123+
return;
124+
125+
frame->Undo();
126+
}
127+
128+
JNIEXPORT void JNICALL Java_org_cef_browser_CefFrame_1N_N_1Redo(JNIEnv* env,
129+
jobject obj,
130+
jlong self) {
131+
CefRefPtr<CefFrame> frame = GetSelf(self);
132+
if (!frame)
133+
return;
134+
135+
frame->Redo();
136+
}
137+
138+
JNIEXPORT void JNICALL Java_org_cef_browser_CefFrame_1N_N_1Cut(JNIEnv* env,
139+
jobject obj,
140+
jlong self) {
141+
CefRefPtr<CefFrame> frame = GetSelf(self);
142+
if (!frame)
143+
return;
144+
145+
frame->Cut();
146+
}
147+
148+
JNIEXPORT void JNICALL Java_org_cef_browser_CefFrame_1N_N_1Copy(JNIEnv* env,
149+
jobject obj,
150+
jlong self) {
151+
CefRefPtr<CefFrame> frame = GetSelf(self);
152+
if (!frame)
153+
return;
154+
155+
frame->Copy();
156+
}
157+
158+
JNIEXPORT void JNICALL Java_org_cef_browser_CefFrame_1N_N_1Paste(JNIEnv* env,
159+
jobject obj,
160+
jlong self) {
161+
CefRefPtr<CefFrame> frame = GetSelf(self);
162+
if (!frame)
163+
return;
164+
165+
frame->Paste();
166+
}

native/CefFrame_N.h

Lines changed: 45 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)