@Override public Element createElement() { Element elem = super.createElement(); elem.setPropertyString("src", "about:blank"); return elem; }
public void setJustification(Justification justification) { if (justification == Justification.CENTER) { execCommand("JustifyCenter", null); } else if (justification == Justification.FULL) { execCommand("JustifyFull", null); } else if (justification == Justification.LEFT) { execCommand("JustifyLeft", null); } else if (justification == Justification.RIGHT) { execCommand("JustifyRight", null); } }
void execCommand(String cmd, String param) { assert isReady : INACTIVE_MESSAGE; if (isReady) { // When executing a command, focus the iframe first, since some commands // don't take properly when it's not focused. setFocus(true); try { execCommandAssumingFocus(cmd, param); } catch (JavaScriptException e) { // In mozilla, editing throws a JS exception if the iframe is // *hidden, but attached*. } } }
boolean queryCommandState(String cmd) { if (isReady) { // When executing a command, focus the iframe first, since some commands // don't take properly when it's not focused. setFocus(true); try { return queryCommandStateAssumingFocus(cmd); } catch (JavaScriptException e) { return false; } } return false; }
@Override @SuppressIsSafeHtmlCastCheck protected void onElementInitialized() { // Issue 1897: This method is called after a timeout, during which time the // element might by detached. if (!initializing) { return; } initializing = false; isReady = true; // When the iframe is ready, ensure cached content is set. if (beforeInitPlaceholder != null) { setHTMLImpl(beforeInitPlaceholder.getInnerHTML()); setEnabledImpl(isEnabled()); beforeInitPlaceholder = null; } super.onElementInitialized(); // Focus on the element now that it is initialized if (isPendingFocus) { isPendingFocus = false; setFocus(true); } }
@Override @SuppressIsSafeHtmlCastCheck public void uninitElement() { isReady = false; // Issue 1897: initElement uses a timeout, so its possible to call this // method after calling initElement, but before the event system is in // place. if (initializing) { initializing = false; return; } // Unhook all custom event handlers when the element is detached. unhookEvents(); // Recreate the placeholder element and store the iframe's contents and the // enabled status in it. This is necessary because some browsers will wipe // the iframe's contents when it is removed from the DOM. @IsSafeHtml String html = getHTML(); // TODO: mXSS boolean enabled = isEnabled(); beforeInitPlaceholder = DOM.createDiv(); beforeInitPlaceholder.setInnerHTML(html); setEnabled(enabled); }
public boolean isItalic() { return queryCommandState("Italic"); }
@Override public boolean isEnabled() { return beforeInitPlaceholder == null ? isEnabledImpl() : !beforeInitPlaceholder.getPropertyBoolean("disabled"); }
@Override public final String getText() { return beforeInitPlaceholder == null ? getTextImpl() : beforeInitPlaceholder.getInnerText(); }
@Override public final String getHTML() { return beforeInitPlaceholder == null ? getHTMLImpl() : beforeInitPlaceholder.getInnerHTML(); }
@Override protected void onElementInitialized() { // Issue 1897: This method is called after a timeout, during which time the // element might by detached. if (!initializing) { return; } initializing = false; isReady = true; // When the iframe is ready, ensure cached content is set. if (beforeInitPlaceholder != null) { setHTMLImpl(beforeInitPlaceholder.getInnerHTML()); setEnabledImpl(isEnabled()); beforeInitPlaceholder = null; } super.onElementInitialized(); // Focus on the element now that it is initialized if (isPendingFocus) { isPendingFocus = false; setFocus(true); } }
@Override public void uninitElement() { isReady = false; // Issue 1897: initElement uses a timeout, so its possible to call this // method after calling initElement, but before the event system is in // place. if (initializing) { initializing = false; return; } // Unhook all custom event handlers when the element is detached. unhookEvents(); // Recreate the placeholder element and store the iframe's contents and the // enabled status in it. This is necessary because some browsers will wipe // the iframe's contents when it is removed from the DOM. String html = getHTML(); boolean enabled = isEnabled(); beforeInitPlaceholder = DOM.createDiv(); beforeInitPlaceholder.setInnerHTML(html); setEnabled(enabled); }
public boolean isStrikethrough() { return queryCommandState("Strikethrough"); }
boolean queryCommandState(String cmd) { if (isReady) { // When executing a command, focus the iframe first, since some commands // don't take properly when it's not focused. setFocus(true); try { return queryCommandStateAssumingFocus(cmd); } catch (JavaScriptException e) { return false; } } return false; }
@Override public boolean isEnabled() { return beforeInitPlaceholder == null ? isEnabledImpl() : !beforeInitPlaceholder.getPropertyBoolean("disabled"); }
@Override public final String getText() { return beforeInitPlaceholder == null ? getTextImpl() : beforeInitPlaceholder.getInnerText(); }
@Override public final String getHTML() { return beforeInitPlaceholder == null ? getHTMLImpl() : beforeInitPlaceholder.getInnerHTML(); }
public void createLink(String url) { execCommand("CreateLink", url); }
@Override protected void onElementInitialized() { // Issue 1897: This method is called after a timeout, during which time the // element might by detached. if (!initializing) { return; } initializing = false; isReady = true; // When the iframe is ready, ensure cached content is set. if (beforeInitPlaceholder != null) { setHTMLImpl(beforeInitPlaceholder.getInnerHTML()); setEnabledImpl(isEnabled()); beforeInitPlaceholder = null; } super.onElementInitialized(); // Focus on the element now that it is initialized if (isPendingFocus) { isPendingFocus = false; setFocus(true); } }
@Override public void uninitElement() { isReady = false; // Issue 1897: initElement uses a timeout, so its possible to call this // method after calling initElement, but before the event system is in // place. if (initializing) { initializing = false; return; } // Unhook all custom event handlers when the element is detached. unhookEvents(); // Recreate the placeholder element and store the iframe's contents and the // enabled status in it. This is necessary because some browsers will wipe // the iframe's contents when it is removed from the DOM. String html = getHTML(); boolean enabled = isEnabled(); beforeInitPlaceholder = DOM.createDiv(); beforeInitPlaceholder.setInnerHTML(html); setEnabled(enabled); }