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

📄 jsobjects.cpp

📁 linux下开源浏览器WebKit的源码,市面上的很多商用浏览器都是移植自WebKit
💻 CPP
📖 第 1 页 / 共 2 页
字号:
void LayoutTestController::setJavaScriptProfilingEnabled(bool enable){    m_topLoadingFrame->page()->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);    qt_drt_setJavaScriptProfilingEnabled(m_topLoadingFrame, enable);}void LayoutTestController::setFixedLayoutSize(int width, int height){    m_topLoadingFrame->page()->setFixedLayoutSize(QSize(width, height));}void LayoutTestController::setUseFixedLayout(bool enable){    m_topLoadingFrame->page()->setUseFixedLayout(enable);}bool LayoutTestController::pauseAnimationAtTimeOnElementWithId(const QString &animationName,                                                               double time,                                                               const QString &elementId){    QWebFrame *frame = m_drt->webPage()->mainFrame();    Q_ASSERT(frame);    return qt_drt_pauseAnimation(frame, animationName, time, elementId);}bool LayoutTestController::pauseTransitionAtTimeOnElementWithId(const QString &propertyName,                                                                double time,                                                                const QString &elementId){    QWebFrame *frame = m_drt->webPage()->mainFrame();    Q_ASSERT(frame);    return qt_drt_pauseTransitionOfProperty(frame, propertyName, time, elementId);}unsigned LayoutTestController::numberOfActiveAnimations() const{    QWebFrame *frame = m_drt->webPage()->mainFrame();    Q_ASSERT(frame);    return qt_drt_numberOfActiveAnimations(frame);}EventSender::EventSender(QWebPage *parent)    : QObject(parent){    m_page = parent;}void EventSender::mouseDown(){//     qDebug() << "EventSender::mouseDown" << frame;    QMouseEvent event(QEvent::MouseButtonPress, m_mousePos, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);    QApplication::sendEvent(m_page, &event);}void EventSender::mouseUp(){//     qDebug() << "EventSender::mouseUp" << frame;    QMouseEvent event(QEvent::MouseButtonRelease, m_mousePos, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);    QApplication::sendEvent(m_page, &event);}void EventSender::mouseMoveTo(int x, int y){//     qDebug() << "EventSender::mouseMoveTo" << x << y;    m_mousePos = QPoint(x, y);    QMouseEvent event(QEvent::MouseMove, m_mousePos, Qt::NoButton, Qt::NoButton, Qt::NoModifier);    QApplication::sendEvent(m_page, &event);}void EventSender::leapForward(int ms){    m_timeLeap += ms;    qDebug() << "EventSender::leapForward" << ms;}void EventSender::keyDown(const QString &string, const QStringList &modifiers){    QString s = string;    Qt::KeyboardModifiers modifs = 0;    for (int i = 0; i < modifiers.size(); ++i) {        const QString &m = modifiers.at(i);        if (m == "ctrlKey")            modifs |= Qt::ControlModifier;        else if (m == "shiftKey")            modifs |= Qt::ShiftModifier;        else if (m == "altKey")            modifs |= Qt::AltModifier;        else if (m == "metaKey")            modifs |= Qt::MetaModifier;    }    int code = 0;    if (string.length() == 1) {        code = string.unicode()->unicode();        qDebug() << ">>>>>>>>> keyDown" << code << (char)code;        // map special keycodes used by the tests to something that works for Qt/X11        if (code == '\t') {            code = Qt::Key_Tab;            if (modifs == Qt::ShiftModifier)                code = Qt::Key_Backtab;            s = QString();        } else if (code == 127) {            code = Qt::Key_Backspace;            if (modifs == Qt::AltModifier)                modifs = Qt::ControlModifier;            s = QString();        } else if (code == 'o' && modifs == Qt::ControlModifier) {            s = QLatin1String("\n");            code = '\n';            modifs = 0;        } else if (code == 'y' && modifs == Qt::ControlModifier) {            s = QLatin1String("c");            code = 'c';        } else if (code == 'k' && modifs == Qt::ControlModifier) {            s = QLatin1String("x");            code = 'x';        } else if (code == 'a' && modifs == Qt::ControlModifier) {            s = QString();            code = Qt::Key_Home;            modifs = 0;        } else if (code == 0xf702) {            s = QString();            code = Qt::Key_Left;            if (modifs & Qt::MetaModifier) {                code = Qt::Key_Home;                modifs &= ~Qt::MetaModifier;            }        } else if (code == 0xf703) {            s = QString();            code = Qt::Key_Right;            if (modifs & Qt::MetaModifier) {                code = Qt::Key_End;                modifs &= ~Qt::MetaModifier;            }        } else if (code == 'a' && modifs == Qt::ControlModifier) {            s = QString();            code = Qt::Key_Home;            modifs = 0;        } else {            code = string.unicode()->toUpper().unicode();        }    }    QKeyEvent event(QEvent::KeyPress, code, modifs, s);    QApplication::sendEvent(m_page, &event);}QWebFrame *EventSender::frameUnderMouse() const{    QWebFrame *frame = m_page->mainFrame();redo:    QList<QWebFrame*> children = frame->childFrames();    for (int i = 0; i < children.size(); ++i) {        if (children.at(i)->geometry().contains(m_mousePos)) {            frame = children.at(i);            goto redo;        }    }    if (frame->geometry().contains(m_mousePos))        return frame;    return 0;}TextInputController::TextInputController(QWebPage *parent)    : QObject(parent){}void TextInputController::doCommand(const QString &command){    Qt::KeyboardModifiers modifiers = Qt::NoModifier;    int keycode = 0;    if (command == "moveBackwardAndModifySelection:") {        modifiers |= Qt::ShiftModifier;        keycode = Qt::Key_Left;    } else if(command =="moveDown:") {        keycode = Qt::Key_Down;    } else if(command =="moveDownAndModifySelection:") {        modifiers |= Qt::ShiftModifier;        keycode = Qt::Key_Down;    } else if(command =="moveForward:") {        keycode = Qt::Key_Right;    } else if(command =="moveForwardAndModifySelection:") {        modifiers |= Qt::ShiftModifier;        keycode = Qt::Key_Right;    } else if(command =="moveLeft:") {        keycode = Qt::Key_Left;    } else if(command =="moveLeftAndModifySelection:") {        modifiers |= Qt::ShiftModifier;        keycode = Qt::Key_Left;    } else if(command =="moveRight:") {        keycode = Qt::Key_Right;    } else if(command =="moveRightAndModifySelection:") {        modifiers |= Qt::ShiftModifier;        keycode = Qt::Key_Right;    } else if(command =="moveToBeginningOfDocument:") {        modifiers |= Qt::ControlModifier;        keycode = Qt::Key_Home;    } else if(command =="moveToBeginningOfLine:") {        keycode = Qt::Key_Home;//     } else if(command =="moveToBeginningOfParagraph:") {    } else if(command =="moveToEndOfDocument:") {        modifiers |= Qt::ControlModifier;        keycode = Qt::Key_End;    } else if(command =="moveToEndOfLine:") {        keycode = Qt::Key_End;//     } else if(command =="moveToEndOfParagraph:") {    } else if(command =="moveUp:") {        keycode = Qt::Key_Up;    } else if(command =="moveUpAndModifySelection:") {        modifiers |= Qt::ShiftModifier;        keycode = Qt::Key_Up;    } else if(command =="moveWordBackward:") {        modifiers |= Qt::ControlModifier;        keycode = Qt::Key_Up;    } else if(command =="moveWordBackwardAndModifySelection:") {        modifiers |= Qt::ShiftModifier;        modifiers |= Qt::ControlModifier;        keycode = Qt::Key_Left;    } else if(command =="moveWordForward:") {        modifiers |= Qt::ControlModifier;        keycode = Qt::Key_Right;    } else if(command =="moveWordForwardAndModifySelection:") {        modifiers |= Qt::ControlModifier;        modifiers |= Qt::ShiftModifier;        keycode = Qt::Key_Right;    } else if(command =="moveWordLeft:") {        modifiers |= Qt::ControlModifier;        keycode = Qt::Key_Left;    } else if(command =="moveWordRight:") {        modifiers |= Qt::ControlModifier;        keycode = Qt::Key_Left;    } else if(command =="moveWordRightAndModifySelection:") {        modifiers |= Qt::ShiftModifier;        modifiers |= Qt::ControlModifier;        keycode = Qt::Key_Right;    } else if(command =="moveWordLeftAndModifySelection:") {        modifiers |= Qt::ShiftModifier;        modifiers |= Qt::ControlModifier;        keycode = Qt::Key_Left;    } else if(command =="pageDown:") {        keycode = Qt::Key_PageDown;            } else if(command =="pageUp:") {        keycode = Qt::Key_PageUp;            } else if(command == "deleteWordBackward:") {        modifiers |= Qt::ControlModifier;        keycode = Qt::Key_Backspace;    } else if(command == "deleteBackward:") {        keycode = Qt::Key_Backspace;    } else if(command == "deleteForward:") {        keycode = Qt::Key_Delete;    }    QKeyEvent event(QEvent::KeyPress, keycode, modifiers);    QApplication::sendEvent(parent(), &event);    QKeyEvent event2(QEvent::KeyRelease, keycode, modifiers);    QApplication::sendEvent(parent(), &event2);}

⌨️ 快捷键说明

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