--- old/runtime/javafx-ui-webnode/src/com/sun/webpane/platform/Pasteboard.java 2011-08-28 16:09:15.950095400 +0400 +++ new/runtime/javafx-ui-webnode/src/com/sun/webpane/platform/Pasteboard.java 2011-08-28 16:09:15.756084300 +0400 @@ -4,6 +4,7 @@ public interface Pasteboard { public String getPlainText(); + public String getHtml(); public void writePlainText(String text); public void writeSelection(boolean canSmartCopyOrDelete, String text, String html); public void writeImage(WCImageFrame img); --- old/runtime/javafx-ui-webnode/src/com/sun/webpane/platform/PasteboardSimple.java 2011-08-28 16:09:20.188337800 +0400 +++ new/runtime/javafx-ui-webnode/src/com/sun/webpane/platform/PasteboardSimple.java 2011-08-28 16:09:19.925322700 +0400 @@ -22,6 +22,10 @@ return html; } + public synchronized String getHtml() { + return html; + } + public void writePlainText(String text) { this.text = text; } --- old/runtime/javafx-ui-webnode/src/com/sun/webpane/sg/PasteboardImpl.java 2011-08-28 16:09:25.136620800 +0400 +++ new/runtime/javafx-ui-webnode/src/com/sun/webpane/sg/PasteboardImpl.java 2011-08-28 16:09:24.920608400 +0400 @@ -20,6 +20,10 @@ return clipboard.getString(); } + @Override public String getHtml() { + return clipboard.getHtml(); + } + @Override public void writePlainText(String text) { ClipboardContent content = new ClipboardContent(); content.putString(text); --- old/runtime/javafx-ui-webnode/src/com/sun/webpane/webkit/WCPasteboard.java 2011-08-28 16:09:29.002841900 +0400 +++ new/runtime/javafx-ui-webnode/src/com/sun/webpane/webkit/WCPasteboard.java 2011-08-28 16:09:28.780829200 +0400 @@ -28,6 +28,11 @@ return pasteboard.getPlainText(); } + public static String getHtml() { + log.fine("getHtml()"); + return pasteboard.getHtml(); + } + public static void writePlainText(String text) { log.log(Level.FINE, "writePlainText(): text = {0}", new Object[] {text}); pasteboard.writePlainText(text); --- old/webnode/Source/WebCore/platform/Pasteboard.h 2011-08-28 16:09:33.316088600 +0400 +++ new/webnode/Source/WebCore/platform/Pasteboard.h 2011-08-28 16:09:33.106076600 +0400 @@ -145,6 +145,8 @@ #endif #if PLATFORM(JAVA) + String html() const; + JGClass m_pasteboardClass; #endif --- old/webnode/Source/WebCore/platform/java/EditorClientJava.cpp 2011-08-28 16:09:38.178366700 +0400 +++ new/webnode/Source/WebCore/platform/java/EditorClientJava.cpp 2011-08-28 16:09:37.964354500 +0400 @@ -398,7 +398,7 @@ bool EditorClientJava::shouldInsertNode(Node*, Range*, EditorInsertAction) { notImplemented(); - return false; + return true; } bool EditorClientJava::smartInsertDeleteEnabled() --- old/webnode/Source/WebCore/platform/java/PasteboardJava.cpp 2011-08-28 16:09:42.426609700 +0400 +++ new/webnode/Source/WebCore/platform/java/PasteboardJava.cpp 2011-08-28 16:09:42.202596900 +0400 @@ -16,6 +16,7 @@ #include "com_sun_webpane_webkit_WCPasteboard.h" static jmethodID wcGetPlainTextMID; +static jmethodID wcGetHtmlMID; static jmethodID wcWritePlainTextMID; static jmethodID wcWriteSelectionMID; static jmethodID wcWriteImageMID; @@ -109,12 +110,32 @@ bool allowPlainText, bool &chosePlainText) { - // TODO: need to check html format in clipboard first, but there is no - // good way to test this method, so only plain text for now + ASSERT(frame); + + chosePlainText = false; + + String htmlString = html(); + if (!htmlString.isNull()) { + PassRefPtr fragment = createFragmentFromMarkup( + frame->document(), htmlString, String(), + FragmentScriptingNotAllowed); + if (fragment) { + return fragment; + } + } + if (allowPlainText) { - chosePlainText = true; - return createFragmentFromText(range.get(), plainText(frame)); + String plainTextString = plainText(frame); + if (!plainTextString.isNull()) { + chosePlainText = true; + PassRefPtr fragment = createFragmentFromText( + range.get(), plainTextString); + if (fragment) { + return fragment; + } + } } + return 0; } @@ -126,7 +147,18 @@ m_pasteboardClass, wcGetPlainTextMID))); CheckAndClearException(env); - return String(env, text); + return text ? String(env, text) : String(); +} + +String Pasteboard::html() const +{ + JNIEnv* env = WebCore_GetJavaEnv(); + + JLString html(static_cast(env->CallStaticObjectMethod( + m_pasteboardClass, wcGetHtmlMID))); + CheckAndClearException(env); + + return html ? String(env, html) : String(); } void Pasteboard::writePlainText(const String& text) @@ -153,6 +185,8 @@ { wcGetPlainTextMID = env->GetStaticMethodID(clazz, "getPlainText", "()Ljava/lang/String;"); ASSERT(wcGetPlainTextMID); + wcGetHtmlMID = env->GetStaticMethodID(clazz, "getHtml", "()Ljava/lang/String;"); + ASSERT(wcGetHtmlMID); wcWritePlainTextMID = env->GetStaticMethodID(clazz, "writePlainText", "(Ljava/lang/String;)V"); ASSERT(wcWritePlainTextMID); wcWriteSelectionMID = env->GetStaticMethodID(clazz, "writeSelection", "(ZLjava/lang/String;Ljava/lang/String;)V");