⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 editorclientqt.cpp

📁 linux下开源浏览器WebKit的源码,市面上的很多商用浏览器都是移植自WebKit
💻 CPP
📖 第 1 页 / 共 2 页
字号:
    m_inUndoRedo = true;    m_page->undoStack()->redo();    m_inUndoRedo = false;#endif}bool EditorClientQt::shouldInsertNode(Node* node, Range* range, EditorInsertAction action){    if (dumpEditingCallbacks) {        static const char *insertactionstring[] = {            "WebViewInsertActionTyped",            "WebViewInsertActionPasted",            "WebViewInsertActionDropped",        };        printf("EDITING DELEGATE: shouldInsertNode:%s replacingDOMRange:%s givenAction:%s\n", dumpPath(node).toUtf8().constData(),               dumpRange(range).toUtf8().constData(), insertactionstring[action]);    }    return acceptsEditing;}void EditorClientQt::pageDestroyed(){    delete this;}bool EditorClientQt::smartInsertDeleteEnabled(){    notImplemented();    return false;}bool EditorClientQt::isSelectTrailingWhitespaceEnabled(){    notImplemented();    return false;}void EditorClientQt::toggleContinuousSpellChecking(){    notImplemented();}void EditorClientQt::toggleGrammarChecking(){    notImplemented();}void EditorClientQt::handleKeyboardEvent(KeyboardEvent* event){    Frame* frame = m_page->d->page->focusController()->focusedOrMainFrame();    if (!frame || !frame->document()->focusedNode())        return;    const PlatformKeyboardEvent* kevent = event->keyEvent();    if (!kevent || kevent->type() == PlatformKeyboardEvent::KeyUp)        return;    Node* start = frame->selection()->start().node();    if (!start)        return;    // FIXME: refactor all of this to use Actions or something like them    if (start->isContentEditable()) {#ifndef QT_NO_SHORTCUT        QWebPage::WebAction action = QWebPagePrivate::editorActionForKeyEvent(kevent->qtEvent());        if (action != QWebPage::NoWebAction) {            const char* cmd = QWebPagePrivate::editorCommandForWebActions(action);            // WebKit doesn't have enough information about mode to decide how commands that just insert text if executed via Editor should be treated,            // so we leave it upon WebCore to either handle them immediately (e.g. Tab that changes focus) or let a keypress event be generated            // (e.g. Tab that inserts a Tab character, or Enter).            if (cmd && frame->editor()->command(cmd).isTextInsertion()                && kevent->type() == PlatformKeyboardEvent::RawKeyDown)                return;            m_page->triggerAction(action);        } else#endif // QT_NO_SHORTCUT        switch (kevent->windowsVirtualKeyCode()) {#if QT_VERSION < 0x040500            case VK_RETURN:#ifdef QT_WS_MAC                if (kevent->shiftKey() || kevent->metaKey())#else                if (kevent->shiftKey())#endif                    frame->editor()->command("InsertLineBreak").execute();                else                    frame->editor()->command("InsertNewline").execute();                break;#endif            case VK_BACK:                frame->editor()->deleteWithDirection(SelectionController::BACKWARD,                        CharacterGranularity, false, true);                break;            case VK_DELETE:                frame->editor()->deleteWithDirection(SelectionController::FORWARD,                        CharacterGranularity, false, true);                break;            case VK_LEFT:                if (kevent->shiftKey())                    frame->editor()->command("MoveLeftAndModifySelection").execute();                else frame->editor()->command("MoveLeft").execute();                break;            case VK_RIGHT:                if (kevent->shiftKey())                    frame->editor()->command("MoveRightAndModifySelection").execute();                else frame->editor()->command("MoveRight").execute();                break;            case VK_UP:                if (kevent->shiftKey())                    frame->editor()->command("MoveUpAndModifySelection").execute();                else frame->editor()->command("MoveUp").execute();                break;            case VK_DOWN:                if (kevent->shiftKey())                    frame->editor()->command("MoveDownAndModifySelection").execute();                else frame->editor()->command("MoveDown").execute();                break;            case VK_PRIOR:  // PageUp                frame->editor()->command("MovePageUp").execute();                break;            case VK_NEXT:  // PageDown                frame->editor()->command("MovePageDown").execute();                break;            case VK_TAB:                return;            default:                if (kevent->type() != PlatformKeyboardEvent::KeyDown && !kevent->ctrlKey()#ifndef Q_WS_MAC                    // We need to exclude checking for Alt because it is just a different Shift                    && !kevent->altKey()#endif                    && !kevent->text().isEmpty()) {                    frame->editor()->insertText(kevent->text(), event);                } else if (kevent->ctrlKey()) {                    switch (kevent->windowsVirtualKeyCode()) {                        case VK_A:                            frame->editor()->command("SelectAll").execute();                            break;                        case VK_B:                            frame->editor()->command("ToggleBold").execute();                            break;                        case VK_I:                            frame->editor()->command("ToggleItalic").execute();                            break;                        default:                            // catch combination AltGr+key or Ctrl+Alt+key                            if (kevent->type() != PlatformKeyboardEvent::KeyDown && kevent->altKey() && !kevent->text().isEmpty()) {                                frame->editor()->insertText(kevent->text(), event);                                break;                            }                            return;                    }                } else return;        }    } else {#ifndef QT_NO_SHORTCUT        if (kevent->qtEvent() == QKeySequence::Copy) {            m_page->triggerAction(QWebPage::Copy);        } else#endif // QT_NO_SHORTCUT        switch (kevent->windowsVirtualKeyCode()) {            case VK_UP:                frame->editor()->command("MoveUp").execute();                break;            case VK_DOWN:                frame->editor()->command("MoveDown").execute();                break;            case VK_PRIOR:  // PageUp                frame->editor()->command("MovePageUp").execute();                break;            case VK_NEXT:  // PageDown                frame->editor()->command("MovePageDown").execute();                break;            case VK_HOME:                if (kevent->ctrlKey())                    frame->editor()->command("MoveToBeginningOfDocument").execute();                break;            case VK_END:                if (kevent->ctrlKey())                    frame->editor()->command("MoveToEndOfDocument").execute();                break;            default:                if (kevent->ctrlKey()) {                    switch (kevent->windowsVirtualKeyCode()) {                        case VK_A:                            frame->editor()->command("SelectAll").execute();                            break;                        default:                            return;                    }                } else return;        }    }    event->setDefaultHandled();}void EditorClientQt::handleInputMethodKeydown(KeyboardEvent*){}EditorClientQt::EditorClientQt(QWebPage* page)    : m_page(page), m_editing(false), m_inUndoRedo(false){}void EditorClientQt::textFieldDidBeginEditing(Element*){    m_editing = true;}void EditorClientQt::textFieldDidEndEditing(Element*){    m_editing = false;}void EditorClientQt::textDidChangeInTextField(Element*){}bool EditorClientQt::doTextFieldCommandFromEvent(Element*, KeyboardEvent*){    return false;}void EditorClientQt::textWillBeDeletedInTextField(Element*){}void EditorClientQt::textDidChangeInTextArea(Element*){}void EditorClientQt::ignoreWordInSpellDocument(const String&){    notImplemented();}void EditorClientQt::learnWord(const String&){    notImplemented();}void EditorClientQt::checkSpellingOfString(const UChar*, int, int*, int*){    notImplemented();}void EditorClientQt::checkGrammarOfString(const UChar*, int, Vector<GrammarDetail>&, int*, int*){    notImplemented();}void EditorClientQt::updateSpellingUIWithGrammarString(const String&, const GrammarDetail&){    notImplemented();}void EditorClientQt::updateSpellingUIWithMisspelledWord(const String&){    notImplemented();}void EditorClientQt::showSpellingUI(bool){    notImplemented();}bool EditorClientQt::spellingUIIsShowing(){    notImplemented();    return false;}void EditorClientQt::getGuessesForWord(const String&, Vector<String>&){    notImplemented();}bool EditorClientQt::isEditing() const{    return m_editing;}void EditorClientQt::setInputMethodState(bool active){    QWidget *view = m_page->view();    if (view) {        view->setAttribute(Qt::WA_InputMethodEnabled, active);        emit m_page->microFocusChanged();    }}}// vim: ts=4 sw=4 et

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -