本文整理汇总了Java中org.waveprotocol.wave.client.common.util.UserAgent.isFirefox方法的典型用法代码示例。如果您正苦于以下问题:Java UserAgent.isFirefox方法的具体用法?Java UserAgent.isFirefox怎么用?Java UserAgent.isFirefox使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.waveprotocol.wave.client.common.util.UserAgent
的用法示例。
在下文中一共展示了UserAgent.isFirefox方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSelectionGuarded
import org.waveprotocol.wave.client.common.util.UserAgent; //导入方法依赖的package包/类
/**
* Gets the current selection, trying to place it in correspond actual DOM when the selection
* itself is reported as not being in the actual document.
* @return The selection in the page's DOM document, or null if it cannot be calculated.
*/
public static SelectionW3CNative getSelectionGuarded() {
SelectionW3CNative selection = getSelectionUnsafe();
// NOTE(patcoleman) -
// It is possible for the selection to be in a node in the shadow, which
// causes errors whenever you try to read attributes.
if (selection != null && DomHelper.isUnreadable(selection.anchorNode())) {
if (UserAgent.isFirefox()) {
// In firefox, the focus can be practically anywhere, so we give up:
return null;
} else if (UserAgent.isWebkit()) {
// In webkit, the focus should be on the element the shadow dom comes from:
selection.setCaret(NativeSelectionUtil.getActiveElement(), 0);
return selection;
}
return null; // not sure what anything else does, so be safe and assume we're beyond repair.
}
return selection;
}
示例2: setFocusElement
import org.waveprotocol.wave.client.common.util.UserAgent; //导入方法依赖的package包/类
/**
* Ensure that the rendered content view's DOM has focus
*
* NOTE(patcoleman): Fixes firefox bug that causes invalid selections while
* mutating DOM that doesn't have focus - fixed by finding the next parent element directly
* editable, and forcing this to have the focus.
*/
private static void setFocusElement(Node node) {
if (UserAgent.isFirefox()) {
// adjust to parent if node is a text node
Element toFocus;
if (DomHelper.isTextNode(node)) {
toFocus = node.getParentElement();
} else {
toFocus = node.<Element>cast();
}
// traverse up until we have a concretely editable element:
while (toFocus != null &&
DomHelper.getContentEditability(toFocus) != ElementEditability.EDITABLE) {
toFocus = toFocus.getParentElement();
}
// then focus it:
if (toFocus != null) {
DomHelper.focus(toFocus);
}
}
}
示例3: create
import org.waveprotocol.wave.client.common.util.UserAgent; //导入方法依赖的package包/类
/**
* Factory constructor, creates and attaches the buffer to the DOM.
*
* @return Browser specific implementation of a paste buffer.
*/
static PasteBufferImpl create() {
PasteBufferImpl pasteBuffer;
if (UserAgent.isSafari() || QuirksConstants.FIREFOX_GREATER_THAN_VER_15) {
pasteBuffer = new PasteBufferImplSafariAndNewFirefox();
} else if (UserAgent.isFirefox() && !QuirksConstants.SANITIZES_PASTED_CONTENT) {
// Older versions of firefox doesn't sanitize pasted content and requires the
// paste buffer to be an iframe to prevent XSS.
pasteBuffer = new PasteBufferImplOldFirefox();
} else {
pasteBuffer = new PasteBufferImpl();
}
pasteBuffer.setupDom();
return pasteBuffer;
}
示例4: waveEnable
import org.waveprotocol.wave.client.common.util.UserAgent; //导入方法依赖的package包/类
@Override
public void waveEnable(String waveApiVersion) {
if (!isActive()) {
return;
}
// HACK: See substituteIframeId() description.
// TODO(user): Remove when the Firefox bug is fixed.
if (UserAgent.isFirefox()) {
substituteIframeId();
}
waveEnabled = true;
this.waveApiVersion = waveApiVersion;
log("Wave-enabled gadget registered with API version ", waveApiVersion);
sendWaveGadgetInitialization();
setupModePolling();
}
示例5: setFocusElement
import org.waveprotocol.wave.client.common.util.UserAgent; //导入方法依赖的package包/类
/**
* Ensure that the rendered content view's DOM has focus
*
* NOTE(patcoleman): Fixes firefox bug that causes invalid selections while
* mutating DOM that doesn't have focus - fixed by finding the next parent element directly
* editable, and forcing this to have the focus.
*/
private static void setFocusElement(Node node) {
if (UserAgent.isFirefox()) {
// adjust to parent if node is a text node
Element toFocus = null;
if (DomHelper.isTextNode(node)) {
toFocus = node.getParentElement();
} else {
toFocus = node.<Element>cast();
}
// traverse up until we have a concretely editable element:
while (toFocus != null &&
DomHelper.getContentEditability(toFocus) != ElementEditability.EDITABLE) {
toFocus = toFocus.getParentElement();
}
// then focus it:
if (toFocus != null) {
DomHelper.focus(toFocus);
}
}
}
示例6: waveEnable
import org.waveprotocol.wave.client.common.util.UserAgent; //导入方法依赖的package包/类
@Override
public void waveEnable(String waveApiVersion) {
if (!isActive()) {
return;
}
log("GW.waveEnable: waveApiVersion=" + waveApiVersion);
waveEnabled = true;
// HACK: See substituteIframeId() description.
// TODO(user): Remove when the Firefox bug is fixed.
if (UserAgent.isFirefox()) {
substituteIframeId();
}
sendWaveGadgetInitialization();
GadgetWidget.this.element.getMutableDoc().addListener(
new CMutableDocument.EditingModeChangeListener() {
@Override
public void onEditingModeChanged(boolean editingMode) {
sendMode();
}
});
ui.showAsLoaded();
}
示例7: createTokenizer
import org.waveprotocol.wave.client.common.util.UserAgent; //导入方法依赖的package包/类
/** Utility for creating tokenizer based on UA. */
private RichTextTokenizer createTokenizer(Element container) {
if (UserAgent.isFirefox()) {
return new RichTextTokenizerImplFirefox<Node, Element, Text>(new HtmlViewImpl(container));
} else {
return new RichTextTokenizerImpl<Node, Element, Text>(new HtmlViewImpl(container));
}
}
示例8: handleNormalTyping
import org.waveprotocol.wave.client.common.util.UserAgent; //导入方法依赖的package包/类
private boolean handleNormalTyping(EditorEvent event, Point<ContentNode> caret, boolean isReplace)
throws SelectionLostException {
// Note that caret may be null if this is called during typing extraction
// Normal typing
selectionAffinityMaybeChanged = false;
// NOTE(danilatos): We can't tell if a key event is IME in firefox, so
// we just always do typing extraction instead.
// Additionally, even for normal key strokes, firefox has strange
// behaviour when handling them programmatically. The cursor appears
// to lag a character behind, and there are selection half-disappearing
// issues when deleting around annotation boundaries.
boolean useTypingExtractor = event.isImeKeyEvent() || UserAgent.isFirefox();
if (useTypingExtractor) {
// Just normal typing. Send to typing extractor.
if (editorInteractor.isTyping()) {
// NOTE(patcoleman): Do not change affinity while normal typing, our affinity should
// remain consistent across normal typing.
logger.trace().log("Not notifying typing extractor, already notified");
} else {
if (UserAgent.isFirefox()) {
// NOTE(user): This is one way of handling the affinity problem.
// The other method is to detect where the selection is, and modify
// the behaviour of typing extractor/document such that when the
// typing is extracted, the formatting applied to the content doc
// matches the html impl.
// TODO(user): This doesn't handle the case for persistent inline
// elements where the browser may automatically place the cursor. We
// don't currently have such elements, but we'll need to consider
// this case in the future.
refreshEditorWithCaret(event);
caret = maybeSetSelectionLeftAffinity(event.getCaret().asPoint());
event.setCaret(ContentPoint.fromPoint(caret));
} else {
// Caret might be null
}
logger.trace().log("Notifying typing extractor");
return editorInteractor.notifyTypingExtractor(caret, caret == null, isReplace);
}
return false;
} else {
char c = (char) event.getKeyCode();
refreshEditorWithCaret(event);
caret = cachedSelection.getFocus(); // Is it safe to delete this line?
caret = editorInteractor.insertText(caret, String.valueOf(c), isReplace);
caret = editorInteractor.normalizePoint(caret);
setCaret(caret);
editorInteractor.rebiasSelection(CursorDirection.FROM_LEFT);
return true;
}
}
示例9: isBlackListedCombo
import org.waveprotocol.wave.client.common.util.UserAgent; //导入方法依赖的package包/类
private boolean isBlackListedCombo(SignalEvent event) {
KeyCombo keyCombo = EventWrapper.getKeyCombo(event);
switch (keyCombo) {
// Disallow undo
case META_Z:
case CTRL_Z:
return true;
}
if (UserAgent.isMac()) {
switch (keyCombo) {
case CTRL_D: // Deletes a character, needs to be handled manually
case CTRL_H: // Deletes a character backwards
case CTRL_K: // Deletes to end of line, needs to be handled manually
return true;
}
if (UserAgent.isFirefox()) {
switch (keyCombo) {
case CTRL_W: // Deletes a word backwards
return true;
case CTRL_U: // Kills line
// NOTE(user): Implement this when Firefox updates their selection API.
return true;
}
}
if (UserAgent.isWebkit()) {
switch (keyCombo) {
case CTRL_O: // Inserts a new line
return true;
}
}
}
if (QuirksConstants.PLAINTEXT_PASTE_DOES_NOT_EMIT_PASTE_EVENT
&& (keyCombo == KeyCombo.META_ALT_SHIFT_V || keyCombo == KeyCombo.CTRL_ALT_SHIFT_V)) {
return true;
}
return false;
}
示例10: isBlackListedCombo
import org.waveprotocol.wave.client.common.util.UserAgent; //导入方法依赖的package包/类
private boolean isBlackListedCombo(SignalEvent event) {
KeyCombo keyCombo = EventWrapper.getKeyCombo(event);
switch (keyCombo) {
// Disallow undo
case ORDER_Z:
return true;
}
if (UserAgent.isMac()) {
switch (keyCombo) {
case CTRL_D: // Deletes a character, needs to be handled manually
case CTRL_H: // Deletes a character backwards
case CTRL_K: // Deletes to end of line, needs to be handled manually
return true;
}
if (UserAgent.isFirefox()) {
switch (keyCombo) {
case CTRL_W: // Deletes a word backwards
return true;
case CTRL_U: // Kills line
// NOTE(user): Implement this when Firefox updates their selection API.
return true;
}
}
if (UserAgent.isWebkit()) {
switch (keyCombo) {
case CTRL_O: // Inserts a new line
return true;
}
}
}
if (QuirksConstants.PLAINTEXT_PASTE_DOES_NOT_EMIT_PASTE_EVENT
&& keyCombo == KeyCombo.ORDER_ALT_SHIFT_V) {
return true;
}
return false;
}