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

📄 editorcommand.cpp

📁 linux下开源浏览器WebKit的源码,市面上的很多商用浏览器都是移植自WebKit
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    return true;}static bool executeCut(Frame* frame, Event*, EditorCommandSource, const String&){    frame->editor()->cut();    return true;}static bool executeDelete(Frame* frame, Event*, EditorCommandSource source, const String&){    switch (source) {        case CommandFromMenuOrKeyBinding:            // Doesn't modify the text if the current selection isn't a range.            frame->editor()->performDelete();            return true;        case CommandFromDOM:        case CommandFromDOMWithUserInterface:            // If the current selection is a caret, delete the preceding character. IE performs forwardDelete, but we currently side with Firefox.            // Doesn't scroll to make the selection visible, or modify the kill ring (this time, siding with IE, not Firefox).            TypingCommand::deleteKeyPressed(frame->document(), frame->selectionGranularity() == WordGranularity);            return true;    }    ASSERT_NOT_REACHED();    return false;}static bool executeDeleteBackward(Frame* frame, Event*, EditorCommandSource, const String&){    frame->editor()->deleteWithDirection(SelectionController::BACKWARD, CharacterGranularity, false, true);    return true;}static bool executeDeleteBackwardByDecomposingPreviousCharacter(Frame* frame, Event*, EditorCommandSource, const String&){    LOG_ERROR("DeleteBackwardByDecomposingPreviousCharacter is not implemented, doing DeleteBackward instead");    frame->editor()->deleteWithDirection(SelectionController::BACKWARD, CharacterGranularity, false, true);    return true;}static bool executeDeleteForward(Frame* frame, Event*, EditorCommandSource, const String&){    frame->editor()->deleteWithDirection(SelectionController::FORWARD, CharacterGranularity, false, true);    return true;}static bool executeDeleteToBeginningOfLine(Frame* frame, Event*, EditorCommandSource, const String&){    frame->editor()->deleteWithDirection(SelectionController::BACKWARD, LineBoundary, true, false);    return true;}static bool executeDeleteToBeginningOfParagraph(Frame* frame, Event*, EditorCommandSource, const String&){    frame->editor()->deleteWithDirection(SelectionController::BACKWARD, ParagraphBoundary, true, false);    return true;}static bool executeDeleteToEndOfLine(Frame* frame, Event*, EditorCommandSource, const String&){    // Despite its name, this command should delete the newline at the end of    // a paragraph if you are at the end of a paragraph (like DeleteToEndOfParagraph).    frame->editor()->deleteWithDirection(SelectionController::FORWARD, LineBoundary, true, false);    return true;}static bool executeDeleteToEndOfParagraph(Frame* frame, Event*, EditorCommandSource, const String&){    // Despite its name, this command should delete the newline at the end of    // a paragraph if you are at the end of a paragraph.    frame->editor()->deleteWithDirection(SelectionController::FORWARD, ParagraphBoundary, true, false);    return true;}static bool executeDeleteToMark(Frame* frame, Event*, EditorCommandSource, const String&){    RefPtr<Range> mark = frame->mark().toNormalizedRange();    if (mark) {        SelectionController* selection = frame->selection();        bool selected = selection->setSelectedRange(unionDOMRanges(mark.get(), frame->editor()->selectedRange().get()).get(), DOWNSTREAM, true);        ASSERT(selected);        if (!selected)            return false;    }    frame->editor()->performDelete();    frame->setMark(frame->selection()->selection());    return true;}static bool executeDeleteWordBackward(Frame* frame, Event*, EditorCommandSource, const String&){    frame->editor()->deleteWithDirection(SelectionController::BACKWARD, WordGranularity, true, false);    return true;}static bool executeDeleteWordForward(Frame* frame, Event*, EditorCommandSource, const String&){    frame->editor()->deleteWithDirection(SelectionController::FORWARD, WordGranularity, true, false);    return true;}static bool executeFindString(Frame* frame, Event*, EditorCommandSource, const String& value){    return frame->findString(value, true, false, true, false);}static bool executeFontName(Frame* frame, Event*, EditorCommandSource source, const String& value){    return executeApplyStyle(frame, source, EditActionSetFont, CSSPropertyFontFamily, value);}static bool executeFontSize(Frame* frame, Event*, EditorCommandSource source, const String& value){    int size;    if (!HTMLFontElement::cssValueFromFontSizeNumber(value, size))        return false;    return executeApplyStyle(frame, source, EditActionChangeAttributes, CSSPropertyFontSize, size);}static bool executeFontSizeDelta(Frame* frame, Event*, EditorCommandSource source, const String& value){    return executeApplyStyle(frame, source, EditActionChangeAttributes, CSSPropertyWebkitFontSizeDelta, value);}static bool executeForeColor(Frame* frame, Event*, EditorCommandSource source, const String& value){    return executeApplyStyle(frame, source, EditActionSetColor, CSSPropertyColor, value);}static bool executeFormatBlock(Frame* frame, Event*, EditorCommandSource, const String& value){    String tagName = value.lower();    if (tagName[0] == '<' && tagName[tagName.length() - 1] == '>')        tagName = tagName.substring(1, tagName.length() - 2);    if (!validBlockTag(tagName))        return false;    applyCommand(FormatBlockCommand::create(frame->document(), tagName));    return true;}static bool executeForwardDelete(Frame* frame, Event*, EditorCommandSource source, const String&){    switch (source) {        case CommandFromMenuOrKeyBinding:            frame->editor()->deleteWithDirection(SelectionController::FORWARD, CharacterGranularity, false, true);            return true;        case CommandFromDOM:        case CommandFromDOMWithUserInterface:            // Doesn't scroll to make the selection visible, or modify the kill ring.            // ForwardDelete is not implemented in IE or Firefox, so this behavior is only needed for            // backward compatibility with ourselves, and for consistency with Delete.            TypingCommand::forwardDeleteKeyPressed(frame->document());            return true;    }    ASSERT_NOT_REACHED();    return false;}static bool executeIgnoreSpelling(Frame* frame, Event*, EditorCommandSource, const String&){    frame->editor()->ignoreSpelling();    return true;}static bool executeIndent(Frame* frame, Event*, EditorCommandSource, const String&){    applyCommand(IndentOutdentCommand::create(frame->document(), IndentOutdentCommand::Indent));    return true;}static bool executeInsertBacktab(Frame* frame, Event* event, EditorCommandSource, const String&){    return targetFrame(frame, event)->eventHandler()->handleTextInputEvent("\t", event, false, true);}static bool executeInsertHorizontalRule(Frame* frame, Event*, EditorCommandSource, const String& value){    RefPtr<HTMLElement> hr = new HTMLElement(hrTag, frame->document());    if (!value.isEmpty())        hr->setId(value);    return executeInsertNode(frame, hr.release());}static bool executeInsertHTML(Frame* frame, Event*, EditorCommandSource, const String& value){    return executeInsertFragment(frame, createFragmentFromMarkup(frame->document(), value, ""));}static bool executeInsertImage(Frame* frame, Event*, EditorCommandSource, const String& value){    // FIXME: If userInterface is true, we should display a dialog box and let the user choose a local image.    RefPtr<HTMLImageElement> image = new HTMLImageElement(imgTag, frame->document());    image->setSrc(value);    return executeInsertNode(frame, image.release());}static bool executeInsertLineBreak(Frame* frame, Event* event, EditorCommandSource source, const String&){    switch (source) {        case CommandFromMenuOrKeyBinding:            return targetFrame(frame, event)->eventHandler()->handleTextInputEvent("\n", event, true);        case CommandFromDOM:        case CommandFromDOMWithUserInterface:            // Doesn't scroll to make the selection visible, or modify the kill ring.            // InsertLineBreak is not implemented in IE or Firefox, so this behavior is only needed for            // backward compatibility with ourselves, and for consistency with other commands.            TypingCommand::insertLineBreak(frame->document());            return true;    }    ASSERT_NOT_REACHED();    return false;}static bool executeInsertNewline(Frame* frame, Event* event, EditorCommandSource, const String&){    Frame* targetFrame = WebCore::targetFrame(frame, event);    return targetFrame->eventHandler()->handleTextInputEvent("\n", event, !targetFrame->editor()->canEditRichly());}static bool executeInsertNewlineInQuotedContent(Frame* frame, Event*, EditorCommandSource, const String&){    TypingCommand::insertParagraphSeparatorInQuotedContent(frame->document());    return true;}static bool executeInsertOrderedList(Frame* frame, Event*, EditorCommandSource, const String&){    applyCommand(InsertListCommand::create(frame->document(), InsertListCommand::OrderedList));    return true;}static bool executeInsertParagraph(Frame* frame, Event*, EditorCommandSource, const String&){    TypingCommand::insertParagraphSeparator(frame->document());    return true;}static bool executeInsertTab(Frame* frame, Event* event, EditorCommandSource, const String&){    return targetFrame(frame, event)->eventHandler()->handleTextInputEvent("\t", event, false, false);}static bool executeInsertText(Frame* frame, Event*, EditorCommandSource, const String& value){    TypingCommand::insertText(frame->document(), value);    return true;}static bool executeInsertUnorderedList(Frame* frame, Event*, EditorCommandSource, const String&){    applyCommand(InsertListCommand::create(frame->document(), InsertListCommand::UnorderedList));    return true;}static bool executeJustifyCenter(Frame* frame, Event*, EditorCommandSource source, const String&){    return executeApplyParagraphStyle(frame, source, EditActionCenter, CSSPropertyTextAlign, "center");}static bool executeJustifyFull(Frame* frame, Event*, EditorCommandSource source, const String&){    return executeApplyParagraphStyle(frame, source, EditActionJustify, CSSPropertyTextAlign, "justify");}static bool executeJustifyLeft(Frame* frame, Event*, EditorCommandSource source, const String&){    return executeApplyParagraphStyle(frame, source, EditActionAlignLeft, CSSPropertyTextAlign, "left");}

⌨️ 快捷键说明

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