/src/3rdparty/webkit/Source/WebKit/qt/Api/qwebpage.cpp
https://bitbucket.org/ultra_iter/qt-vtl · C++ · 4219 lines · 2641 code · 403 blank · 1175 comment · 401 complexity · a3c2af90db056dba79fb76b251779af7 MD5 · raw file
Large files are truncated click here to view the full file
- /*
- Copyright (C) 2008, 2009 Nokia Corporation and/or its subsidiary(-ies)
- Copyright (C) 2007 Staikos Computing Services Inc.
- Copyright (C) 2007 Apple Inc.
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
- */
- #include "config.h"
- #include "qwebpage.h"
- #include "qwebview.h"
- #include "qwebframe.h"
- #include "qwebpage_p.h"
- #include "qwebframe_p.h"
- #include "qwebhistory.h"
- #include "qwebhistory_p.h"
- #include "qwebinspector.h"
- #include "qwebinspector_p.h"
- #include "qwebsettings.h"
- #include "qwebkitplatformplugin.h"
- #include "qwebkitversion.h"
- #include "CSSComputedStyleDeclaration.h"
- #include "CSSParser.h"
- #include "ApplicationCacheStorage.h"
- #include "BackForwardListImpl.h"
- #include "MemoryCache.h"
- #include "Chrome.h"
- #include "ChromeClientQt.h"
- #include "ClientRect.h"
- #include "ContextMenu.h"
- #include "ContextMenuClientQt.h"
- #include "ContextMenuController.h"
- #include "DeviceMotionClientQt.h"
- #include "DeviceOrientationClientQt.h"
- #include "DocumentLoader.h"
- #include "DragClientQt.h"
- #include "DragController.h"
- #include "DragData.h"
- #include "Editor.h"
- #include "EditorClientQt.h"
- #include "FocusController.h"
- #include "FormState.h"
- #include "Frame.h"
- #include "FrameLoadRequest.h"
- #include "FrameLoader.h"
- #include "FrameLoader.h"
- #include "FrameLoaderClientQt.h"
- #include "FrameTree.h"
- #include "FrameView.h"
- #if ENABLE(CLIENT_BASED_GEOLOCATION)
- #include "GeolocationClientMock.h"
- #include "GeolocationClientQt.h"
- #endif // CLIENT_BASED_GEOLOCATION
- #include "GeolocationPermissionClientQt.h"
- #include "HTMLFormElement.h"
- #include "HTMLFrameOwnerElement.h"
- #include "HTMLInputElement.h"
- #include "HTMLNames.h"
- #include "HashMap.h"
- #include "HitTestResult.h"
- #include "Image.h"
- #include "InspectorClientQt.h"
- #include "InspectorController.h"
- #include "InspectorServerQt.h"
- #include "KURL.h"
- #include "LocalizedStrings.h"
- #include "Logging.h"
- #include "MIMETypeRegistry.h"
- #include "NavigationAction.h"
- #include "NetworkingContext.h"
- #include "NodeList.h"
- #include "NotificationPresenterClientQt.h"
- #include "NotImplemented.h"
- #include "Page.h"
- #include "PageClientQt.h"
- #include "PageGroup.h"
- #include "Pasteboard.h"
- #include "PlatformKeyboardEvent.h"
- #include "PlatformTouchEvent.h"
- #include "PlatformWheelEvent.h"
- #include "PluginDatabase.h"
- #include "PluginDatabase.h"
- #include "PluginPackage.h"
- #include "ProgressTracker.h"
- #include "QtPlatformPlugin.h"
- #include "RefPtr.h"
- #include "RenderTextControl.h"
- #include "SchemeRegistry.h"
- #include "Scrollbar.h"
- #include "SecurityOrigin.h"
- #include "Settings.h"
- #if defined Q_OS_WIN32
- #include "SystemInfo.h"
- #endif // Q_OS_WIN32
- #include "TextIterator.h"
- #include "WebPlatformStrategies.h"
- #if USE(QTKIT)
- #include "WebSystemInterface.h"
- #endif
- #include "WindowFeatures.h"
- #include "WorkerThread.h"
- #include "runtime/InitializeThreading.h"
- #include "wtf/Threading.h"
- #include <QApplication>
- #include <QBasicTimer>
- #include <QBitArray>
- #include <QDebug>
- #include <QDesktopWidget>
- #include <QDragEnterEvent>
- #include <QDragLeaveEvent>
- #include <QDragMoveEvent>
- #include <QDropEvent>
- #include <QFileDialog>
- #include <QHttpRequestHeader>
- #include <QInputDialog>
- #include <QMessageBox>
- #include <QNetworkProxy>
- #include <QUndoStack>
- #include <QUrl>
- #include <QPainter>
- #include <QClipboard>
- #include <QSslSocket>
- #include <QStyle>
- #include <QSysInfo>
- #include <QTextCharFormat>
- #include <QTextDocument>
- #include <QTouchEvent>
- #include <QNetworkAccessManager>
- #include <QNetworkRequest>
- #if defined(Q_WS_X11)
- #include <QX11Info>
- #endif
- #if USE(QT_MOBILITY_SYSTEMINFO)
- #include <qsysteminfo.h>
- #endif
- using namespace WebCore;
- // from text/qfont.cpp
- QT_BEGIN_NAMESPACE
- extern Q_GUI_EXPORT int qt_defaultDpi();
- QT_END_NAMESPACE
- bool QWebPagePrivate::drtRun = false;
- // Lookup table mapping QWebPage::WebActions to the associated Editor commands
- static const char* editorCommandWebActions[] =
- {
- 0, // OpenLink,
- 0, // OpenLinkInNewWindow,
- 0, // OpenFrameInNewWindow,
- 0, // DownloadLinkToDisk,
- 0, // CopyLinkToClipboard,
- 0, // OpenImageInNewWindow,
- 0, // DownloadImageToDisk,
- 0, // CopyImageToClipboard,
- 0, // Back,
- 0, // Forward,
- 0, // Stop,
- 0, // Reload,
- "Cut", // Cut,
- "Copy", // Copy,
- "Paste", // Paste,
- "Undo", // Undo,
- "Redo", // Redo,
- "MoveForward", // MoveToNextChar,
- "MoveBackward", // MoveToPreviousChar,
- "MoveWordForward", // MoveToNextWord,
- "MoveWordBackward", // MoveToPreviousWord,
- "MoveDown", // MoveToNextLine,
- "MoveUp", // MoveToPreviousLine,
- "MoveToBeginningOfLine", // MoveToStartOfLine,
- "MoveToEndOfLine", // MoveToEndOfLine,
- "MoveToBeginningOfParagraph", // MoveToStartOfBlock,
- "MoveToEndOfParagraph", // MoveToEndOfBlock,
- "MoveToBeginningOfDocument", // MoveToStartOfDocument,
- "MoveToEndOfDocument", // MoveToEndOfDocument,
- "MoveForwardAndModifySelection", // SelectNextChar,
- "MoveBackwardAndModifySelection", // SelectPreviousChar,
- "MoveWordForwardAndModifySelection", // SelectNextWord,
- "MoveWordBackwardAndModifySelection", // SelectPreviousWord,
- "MoveDownAndModifySelection", // SelectNextLine,
- "MoveUpAndModifySelection", // SelectPreviousLine,
- "MoveToBeginningOfLineAndModifySelection", // SelectStartOfLine,
- "MoveToEndOfLineAndModifySelection", // SelectEndOfLine,
- "MoveToBeginningOfParagraphAndModifySelection", // SelectStartOfBlock,
- "MoveToEndOfParagraphAndModifySelection", // SelectEndOfBlock,
- "MoveToBeginningOfDocumentAndModifySelection", //SelectStartOfDocument,
- "MoveToEndOfDocumentAndModifySelection", // SelectEndOfDocument,
- "DeleteWordBackward", // DeleteStartOfWord,
- "DeleteWordForward", // DeleteEndOfWord,
- 0, // SetTextDirectionDefault,
- 0, // SetTextDirectionLeftToRight,
- 0, // SetTextDirectionRightToLeft,
- "ToggleBold", // ToggleBold,
- "ToggleItalic", // ToggleItalic,
- "ToggleUnderline", // ToggleUnderline,
- 0, // InspectElement,
- "InsertNewline", // InsertParagraphSeparator
- "InsertLineBreak", // InsertLineSeparator
- "SelectAll", // SelectAll
- 0, // ReloadAndBypassCache,
- "PasteAndMatchStyle", // PasteAndMatchStyle
- "RemoveFormat", // RemoveFormat
- "Strikethrough", // ToggleStrikethrough,
- "Subscript", // ToggleSubscript
- "Superscript", // ToggleSuperscript
- "InsertUnorderedList", // InsertUnorderedList
- "InsertOrderedList", // InsertOrderedList
- "Indent", // Indent
- "Outdent", // Outdent,
- "AlignCenter", // AlignCenter,
- "AlignJustified", // AlignJustified,
- "AlignLeft", // AlignLeft,
- "AlignRight", // AlignRight,
- 0, // StopScheduledPageRefresh,
- 0, // CopyImageUrlToClipboard,
- 0 // WebActionCount
- };
- // Lookup the appropriate editor command to use for WebAction \a action
- const char* QWebPagePrivate::editorCommandForWebActions(QWebPage::WebAction action)
- {
- if ((action > QWebPage::NoWebAction) && (action < int(sizeof(editorCommandWebActions) / sizeof(const char*))))
- return editorCommandWebActions[action];
- return 0;
- }
- static inline DragOperation dropActionToDragOp(Qt::DropActions actions)
- {
- unsigned result = 0;
- if (actions & Qt::CopyAction)
- result |= DragOperationCopy;
- // DragOperationgeneric represents InternetExplorer's equivalent of Move operation,
- // hence it should be considered as "move"
- if (actions & Qt::MoveAction)
- result |= (DragOperationMove | DragOperationGeneric);
- if (actions & Qt::LinkAction)
- result |= DragOperationLink;
- if (result == (DragOperationCopy | DragOperationMove | DragOperationGeneric | DragOperationLink))
- result = DragOperationEvery;
- return (DragOperation)result;
- }
- static inline Qt::DropAction dragOpToDropAction(unsigned actions)
- {
- Qt::DropAction result = Qt::IgnoreAction;
- if (actions & DragOperationCopy)
- result = Qt::CopyAction;
- else if (actions & DragOperationMove)
- result = Qt::MoveAction;
- // DragOperationgeneric represents InternetExplorer's equivalent of Move operation,
- // hence it should be considered as "move"
- else if (actions & DragOperationGeneric)
- result = Qt::MoveAction;
- else if (actions & DragOperationLink)
- result = Qt::LinkAction;
- return result;
- }
- QWebPagePrivate::QWebPagePrivate(QWebPage *qq)
- : q(qq)
- , page(0)
- , mainFrame(0)
- #ifndef QT_NO_UNDOSTACK
- , undoStack(0)
- #endif
- , insideOpenCall(false)
- , m_totalBytes(0)
- , m_bytesReceived()
- , clickCausedFocus(false)
- , networkManager(0)
- , forwardUnsupportedContent(false)
- , smartInsertDeleteEnabled(true)
- , selectTrailingWhitespaceEnabled(false)
- , linkPolicy(QWebPage::DontDelegateLinks)
- , viewportSize(QSize(0, 0))
- , pixelRatio(1)
- #ifndef QT_NO_CONTEXTMENU
- , currentContextMenu(0)
- #endif
- , settings(0)
- , useFixedLayout(false)
- , pluginFactory(0)
- , inspectorFrontend(0)
- , inspector(0)
- , inspectorIsInternalOnly(false)
- , m_lastDropAction(Qt::IgnoreAction)
- {
- WebCore::InitializeLoggingChannelsIfNecessary();
- ScriptController::initializeThreading();
- WTF::initializeMainThread();
- WebCore::SecurityOrigin::setLocalLoadPolicy(WebCore::SecurityOrigin::AllowLocalLoadsForLocalAndSubstituteData);
- WebPlatformStrategies::initialize();
- #if USE(QTKIT)
- InitWebCoreSystemInterface();
- #endif
- Page::PageClients pageClients;
- pageClients.chromeClient = new ChromeClientQt(q);
- pageClients.contextMenuClient = new ContextMenuClientQt();
- pageClients.editorClient = new EditorClientQt(q);
- pageClients.dragClient = new DragClientQt(q);
- pageClients.inspectorClient = new InspectorClientQt(q);
- #if ENABLE(DEVICE_ORIENTATION)
- pageClients.deviceOrientationClient = new DeviceOrientationClientQt(q);
- pageClients.deviceMotionClient = new DeviceMotionClientQt(q);
- #endif
- #if ENABLE(CLIENT_BASED_GEOLOCATION)
- if (QWebPagePrivate::drtRun)
- pageClients.geolocationClient = new GeolocationClientMock();
- else
- pageClients.geolocationClient = new GeolocationClientQt(q);
- #endif
- page = new Page(pageClients);
- // By default each page is put into their own unique page group, which affects popup windows
- // and visited links. Page groups (per process only) is a feature making it possible to use
- // separate settings for each group, so that for instance an integrated browser/email reader
- // can use different settings for displaying HTML pages and HTML email. To make QtWebKit work
- // as expected out of the box, we use a default group similar to what other ports are doing.
- page->setGroupName("Default Group");
- #if ENABLE(CLIENT_BASED_GEOLOCATION)
- // In case running in DumpRenderTree mode set the controller to mock provider.
- if (QWebPagePrivate::drtRun)
- static_cast<GeolocationClientMock*>(pageClients.geolocationClient)->setController(page->geolocationController());
- #endif
- settings = new QWebSettings(page->settings());
- history.d = new QWebHistoryPrivate(static_cast<WebCore::BackForwardListImpl*>(page->backForwardList()));
- memset(actions, 0, sizeof(actions));
- PageGroup::setShouldTrackVisitedLinks(true);
-
- #if ENABLE(NOTIFICATIONS)
- NotificationPresenterClientQt::notificationPresenter()->addClient();
- #endif
- }
- QWebPagePrivate::~QWebPagePrivate()
- {
- if (inspector && inspectorIsInternalOnly) {
- // Since we have to delete an internal inspector,
- // call setInspector(0) directly to prevent potential crashes
- setInspector(0);
- }
- #ifndef QT_NO_CONTEXTMENU
- delete currentContextMenu;
- #endif
- #ifndef QT_NO_UNDOSTACK
- delete undoStack;
- #endif
- delete settings;
- delete page;
-
- if (inspector)
- inspector->setPage(0);
- #if ENABLE(NOTIFICATIONS)
- NotificationPresenterClientQt::notificationPresenter()->removeClient();
- #endif
- }
- WebCore::ViewportArguments QWebPagePrivate::viewportArguments()
- {
- return page ? page->viewportArguments() : WebCore::ViewportArguments();
- }
- WebCore::Page* QWebPagePrivate::core(const QWebPage* page)
- {
- return page->d->page;
- }
- QWebPagePrivate* QWebPagePrivate::priv(QWebPage* page)
- {
- return page->d;
- }
- bool QWebPagePrivate::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, QWebPage::NavigationType type)
- {
- if (insideOpenCall
- && frame == mainFrame)
- return true;
- return q->acceptNavigationRequest(frame, request, type);
- }
- void QWebPagePrivate::createMainFrame()
- {
- if (!mainFrame) {
- QWebFrameData frameData(page);
- mainFrame = new QWebFrame(q, &frameData);
- emit q->frameCreated(mainFrame);
- }
- }
- static QWebPage::WebAction webActionForContextMenuAction(WebCore::ContextMenuAction action)
- {
- switch (action) {
- case WebCore::ContextMenuItemTagOpenLink: return QWebPage::OpenLink;
- case WebCore::ContextMenuItemTagOpenLinkInNewWindow: return QWebPage::OpenLinkInNewWindow;
- case WebCore::ContextMenuItemTagDownloadLinkToDisk: return QWebPage::DownloadLinkToDisk;
- case WebCore::ContextMenuItemTagCopyLinkToClipboard: return QWebPage::CopyLinkToClipboard;
- case WebCore::ContextMenuItemTagOpenImageInNewWindow: return QWebPage::OpenImageInNewWindow;
- case WebCore::ContextMenuItemTagDownloadImageToDisk: return QWebPage::DownloadImageToDisk;
- case WebCore::ContextMenuItemTagCopyImageToClipboard: return QWebPage::CopyImageToClipboard;
- case WebCore::ContextMenuItemTagCopyImageUrlToClipboard: return QWebPage::CopyImageUrlToClipboard;
- case WebCore::ContextMenuItemTagOpenFrameInNewWindow: return QWebPage::OpenFrameInNewWindow;
- case WebCore::ContextMenuItemTagCopy: return QWebPage::Copy;
- case WebCore::ContextMenuItemTagGoBack: return QWebPage::Back;
- case WebCore::ContextMenuItemTagGoForward: return QWebPage::Forward;
- case WebCore::ContextMenuItemTagStop: return QWebPage::Stop;
- case WebCore::ContextMenuItemTagReload: return QWebPage::Reload;
- case WebCore::ContextMenuItemTagCut: return QWebPage::Cut;
- case WebCore::ContextMenuItemTagPaste: return QWebPage::Paste;
- case WebCore::ContextMenuItemTagDefaultDirection: return QWebPage::SetTextDirectionDefault;
- case WebCore::ContextMenuItemTagLeftToRight: return QWebPage::SetTextDirectionLeftToRight;
- case WebCore::ContextMenuItemTagRightToLeft: return QWebPage::SetTextDirectionRightToLeft;
- case WebCore::ContextMenuItemTagBold: return QWebPage::ToggleBold;
- case WebCore::ContextMenuItemTagItalic: return QWebPage::ToggleItalic;
- case WebCore::ContextMenuItemTagUnderline: return QWebPage::ToggleUnderline;
- case WebCore::ContextMenuItemTagSelectAll: return QWebPage::SelectAll;
- #if ENABLE(INSPECTOR)
- case WebCore::ContextMenuItemTagInspectElement: return QWebPage::InspectElement;
- #endif
- default: break;
- }
- return QWebPage::NoWebAction;
- }
- #ifndef QT_NO_CONTEXTMENU
- QMenu *QWebPagePrivate::createContextMenu(const WebCore::ContextMenu *webcoreMenu,
- const QList<WebCore::ContextMenuItem> *items, QBitArray *visitedWebActions)
- {
- if (!client || !webcoreMenu)
- return 0;
- QMenu* menu = new QMenu(client->ownerWidget());
- for (int i = 0; i < items->count(); ++i) {
- const ContextMenuItem &item = items->at(i);
- switch (item.type()) {
- case WebCore::CheckableActionType: /* fall through */
- case WebCore::ActionType: {
- QWebPage::WebAction action = webActionForContextMenuAction(item.action());
- QAction *a = q->action(action);
- if (a) {
- ContextMenuItem it(item);
- page->contextMenuController()->checkOrEnableIfNeeded(it);
- PlatformMenuItemDescription desc = it.releasePlatformDescription();
- a->setEnabled(desc.enabled);
- a->setChecked(desc.checked);
- a->setCheckable(item.type() == WebCore::CheckableActionType);
- menu->addAction(a);
- visitedWebActions->setBit(action);
- }
- break;
- }
- case WebCore::SeparatorType:
- menu->addSeparator();
- break;
- case WebCore::SubmenuType: {
- QMenu *subMenu = createContextMenu(webcoreMenu, item.platformSubMenu(), visitedWebActions);
- bool anyEnabledAction = false;
- QList<QAction *> actions = subMenu->actions();
- for (int i = 0; i < actions.count(); ++i) {
- if (actions.at(i)->isVisible())
- anyEnabledAction |= actions.at(i)->isEnabled();
- }
- // don't show sub-menus with just disabled actions
- if (anyEnabledAction) {
- subMenu->setTitle(item.title());
- menu->addAction(subMenu->menuAction());
- } else
- delete subMenu;
- break;
- }
- }
- }
- return menu;
- }
- #endif // QT_NO_CONTEXTMENU
- #ifndef QT_NO_ACTION
- void QWebPagePrivate::_q_webActionTriggered(bool checked)
- {
- QAction *a = qobject_cast<QAction *>(q->sender());
- if (!a)
- return;
- QWebPage::WebAction action = static_cast<QWebPage::WebAction>(a->data().toInt());
- q->triggerAction(action, checked);
- }
- #endif // QT_NO_ACTION
- void QWebPagePrivate::_q_cleanupLeakMessages()
- {
- #ifndef NDEBUG
- // Need this to make leak messages accurate.
- memoryCache()->setCapacities(0, 0, 0);
- #endif
- }
- void QWebPagePrivate::updateAction(QWebPage::WebAction action)
- {
- #ifdef QT_NO_ACTION
- Q_UNUSED(action)
- #else
- QAction *a = actions[action];
- if (!a || !mainFrame)
- return;
- WebCore::FrameLoader *loader = mainFrame->d->frame->loader();
- WebCore::Editor *editor = page->focusController()->focusedOrMainFrame()->editor();
- bool enabled = a->isEnabled();
- bool checked = a->isChecked();
- switch (action) {
- case QWebPage::Back:
- enabled = page->canGoBackOrForward(-1);
- break;
- case QWebPage::Forward:
- enabled = page->canGoBackOrForward(1);
- break;
- case QWebPage::Stop:
- enabled = loader->isLoading();
- break;
- case QWebPage::Reload:
- case QWebPage::ReloadAndBypassCache:
- enabled = !loader->isLoading();
- break;
- #ifndef QT_NO_UNDOSTACK
- case QWebPage::Undo:
- case QWebPage::Redo:
- // those two are handled by QUndoStack
- break;
- #endif // QT_NO_UNDOSTACK
- case QWebPage::SelectAll: // editor command is always enabled
- break;
- case QWebPage::SetTextDirectionDefault:
- case QWebPage::SetTextDirectionLeftToRight:
- case QWebPage::SetTextDirectionRightToLeft:
- enabled = editor->canEdit();
- checked = false;
- break;
- default: {
- // see if it's an editor command
- const char* commandName = editorCommandForWebActions(action);
- // if it's an editor command, let it's logic determine state
- if (commandName) {
- Editor::Command command = editor->command(commandName);
- enabled = command.isEnabled();
- if (enabled)
- checked = command.state() != FalseTriState;
- else
- checked = false;
- }
- break;
- }
- }
- a->setEnabled(enabled);
- if (a->isCheckable())
- a->setChecked(checked);
- #endif // QT_NO_ACTION
- }
- void QWebPagePrivate::updateNavigationActions()
- {
- updateAction(QWebPage::Back);
- updateAction(QWebPage::Forward);
- updateAction(QWebPage::Stop);
- updateAction(QWebPage::Reload);
- updateAction(QWebPage::ReloadAndBypassCache);
- }
- void QWebPagePrivate::updateEditorActions()
- {
- updateAction(QWebPage::Cut);
- updateAction(QWebPage::Copy);
- updateAction(QWebPage::Paste);
- updateAction(QWebPage::MoveToNextChar);
- updateAction(QWebPage::MoveToPreviousChar);
- updateAction(QWebPage::MoveToNextWord);
- updateAction(QWebPage::MoveToPreviousWord);
- updateAction(QWebPage::MoveToNextLine);
- updateAction(QWebPage::MoveToPreviousLine);
- updateAction(QWebPage::MoveToStartOfLine);
- updateAction(QWebPage::MoveToEndOfLine);
- updateAction(QWebPage::MoveToStartOfBlock);
- updateAction(QWebPage::MoveToEndOfBlock);
- updateAction(QWebPage::MoveToStartOfDocument);
- updateAction(QWebPage::MoveToEndOfDocument);
- updateAction(QWebPage::SelectNextChar);
- updateAction(QWebPage::SelectPreviousChar);
- updateAction(QWebPage::SelectNextWord);
- updateAction(QWebPage::SelectPreviousWord);
- updateAction(QWebPage::SelectNextLine);
- updateAction(QWebPage::SelectPreviousLine);
- updateAction(QWebPage::SelectStartOfLine);
- updateAction(QWebPage::SelectEndOfLine);
- updateAction(QWebPage::SelectStartOfBlock);
- updateAction(QWebPage::SelectEndOfBlock);
- updateAction(QWebPage::SelectStartOfDocument);
- updateAction(QWebPage::SelectEndOfDocument);
- updateAction(QWebPage::DeleteStartOfWord);
- updateAction(QWebPage::DeleteEndOfWord);
- updateAction(QWebPage::SetTextDirectionDefault);
- updateAction(QWebPage::SetTextDirectionLeftToRight);
- updateAction(QWebPage::SetTextDirectionRightToLeft);
- updateAction(QWebPage::ToggleBold);
- updateAction(QWebPage::ToggleItalic);
- updateAction(QWebPage::ToggleUnderline);
- updateAction(QWebPage::InsertParagraphSeparator);
- updateAction(QWebPage::InsertLineSeparator);
- updateAction(QWebPage::PasteAndMatchStyle);
- updateAction(QWebPage::RemoveFormat);
- updateAction(QWebPage::ToggleStrikethrough);
- updateAction(QWebPage::ToggleSubscript);
- updateAction(QWebPage::ToggleSuperscript);
- updateAction(QWebPage::InsertUnorderedList);
- updateAction(QWebPage::InsertOrderedList);
- updateAction(QWebPage::Indent);
- updateAction(QWebPage::Outdent);
- updateAction(QWebPage::AlignCenter);
- updateAction(QWebPage::AlignJustified);
- updateAction(QWebPage::AlignLeft);
- updateAction(QWebPage::AlignRight);
- }
- void QWebPagePrivate::timerEvent(QTimerEvent *ev)
- {
- int timerId = ev->timerId();
- if (timerId == tripleClickTimer.timerId())
- tripleClickTimer.stop();
- else
- q->timerEvent(ev);
- }
- template<class T>
- void QWebPagePrivate::mouseMoveEvent(T* ev)
- {
- WebCore::Frame* frame = QWebFramePrivate::core(mainFrame);
- if (!frame->view())
- return;
- bool accepted = frame->eventHandler()->mouseMoved(PlatformMouseEvent(ev, 0));
- ev->setAccepted(accepted);
- }
- template<class T>
- void QWebPagePrivate::mousePressEvent(T* ev)
- {
- WebCore::Frame* frame = QWebFramePrivate::core(mainFrame);
- if (!frame->view())
- return;
- RefPtr<WebCore::Node> oldNode;
- Frame* focusedFrame = page->focusController()->focusedFrame();
- if (Document* focusedDocument = focusedFrame ? focusedFrame->document() : 0)
- oldNode = focusedDocument->focusedNode();
- if (tripleClickTimer.isActive()
- && (ev->pos() - tripleClick).manhattanLength()
- < QApplication::startDragDistance()) {
- mouseTripleClickEvent(ev);
- return;
- }
- bool accepted = false;
- adjustPointForClicking(ev);
- PlatformMouseEvent mev(ev, 1);
- // ignore the event if we can't map Qt's mouse buttons to WebCore::MouseButton
- if (mev.button() != NoButton)
- accepted = frame->eventHandler()->handleMousePressEvent(mev);
- ev->setAccepted(accepted);
- RefPtr<WebCore::Node> newNode;
- focusedFrame = page->focusController()->focusedFrame();
- if (Document* focusedDocument = focusedFrame ? focusedFrame->document() : 0)
- newNode = focusedDocument->focusedNode();
- if (newNode && oldNode != newNode)
- clickCausedFocus = true;
- }
- template<class T>
- void QWebPagePrivate::mouseDoubleClickEvent(T *ev)
- {
- WebCore::Frame* frame = QWebFramePrivate::core(mainFrame);
- if (!frame->view())
- return;
- bool accepted = false;
- PlatformMouseEvent mev(ev, 2);
- // ignore the event if we can't map Qt's mouse buttons to WebCore::MouseButton
- if (mev.button() != NoButton)
- accepted = frame->eventHandler()->handleMousePressEvent(mev);
- ev->setAccepted(accepted);
- tripleClickTimer.start(QApplication::doubleClickInterval(), q);
- tripleClick = QPointF(ev->pos()).toPoint();
- }
- template<class T>
- void QWebPagePrivate::mouseTripleClickEvent(T *ev)
- {
- WebCore::Frame* frame = QWebFramePrivate::core(mainFrame);
- if (!frame->view())
- return;
- bool accepted = false;
- PlatformMouseEvent mev(ev, 3);
- // ignore the event if we can't map Qt's mouse buttons to WebCore::MouseButton
- if (mev.button() != NoButton)
- accepted = frame->eventHandler()->handleMousePressEvent(mev);
- ev->setAccepted(accepted);
- }
- void QWebPagePrivate::handleClipboard(QEvent* ev, Qt::MouseButton button)
- {
- #ifndef QT_NO_CLIPBOARD
- if (QApplication::clipboard()->supportsSelection()) {
- bool oldSelectionMode = Pasteboard::generalPasteboard()->isSelectionMode();
- Pasteboard::generalPasteboard()->setSelectionMode(true);
- WebCore::Frame* focusFrame = page->focusController()->focusedOrMainFrame();
- if (button == Qt::LeftButton) {
- if (focusFrame && (focusFrame->editor()->canCopy() || focusFrame->editor()->canDHTMLCopy())) {
- Pasteboard::generalPasteboard()->writeSelection(focusFrame->editor()->selectedRange().get(), focusFrame->editor()->canSmartCopyOrDelete(), focusFrame);
- ev->setAccepted(true);
- }
- } else if (button == Qt::MidButton) {
- if (focusFrame && (focusFrame->editor()->canPaste() || focusFrame->editor()->canDHTMLPaste())) {
- focusFrame->editor()->paste();
- ev->setAccepted(true);
- }
- }
- Pasteboard::generalPasteboard()->setSelectionMode(oldSelectionMode);
- }
- #endif
- }
- template<class T>
- void QWebPagePrivate::mouseReleaseEvent(T *ev)
- {
- WebCore::Frame* frame = QWebFramePrivate::core(mainFrame);
- if (!frame->view())
- return;
- bool accepted = false;
- adjustPointForClicking(ev);
- PlatformMouseEvent mev(ev, 0);
- // ignore the event if we can't map Qt's mouse buttons to WebCore::MouseButton
- if (mev.button() != NoButton)
- accepted = frame->eventHandler()->handleMouseReleaseEvent(mev);
- ev->setAccepted(accepted);
- handleClipboard(ev, ev->button());
- handleSoftwareInputPanel(ev->button(), QPointF(ev->pos()).toPoint());
- }
- void QWebPagePrivate::handleSoftwareInputPanel(Qt::MouseButton button, const QPoint& pos)
- {
- Frame* frame = page->focusController()->focusedFrame();
- if (!frame)
- return;
- if (client && client->inputMethodEnabled()
- && frame->document()->focusedNode()
- && button == Qt::LeftButton && qApp->autoSipEnabled()) {
- QStyle::RequestSoftwareInputPanel behavior = QStyle::RequestSoftwareInputPanel(
- client->ownerWidget()->style()->styleHint(QStyle::SH_RequestSoftwareInputPanel));
- if (!clickCausedFocus || behavior == QStyle::RSIP_OnMouseClick) {
- HitTestResult result = frame->eventHandler()->hitTestResultAtPoint(frame->view()->windowToContents(pos), false);
- if (result.isContentEditable()) {
- QEvent event(QEvent::RequestSoftwareInputPanel);
- QApplication::sendEvent(client->ownerWidget(), &event);
- }
- }
- }
- clickCausedFocus = false;
- }
- #ifndef QT_NO_CONTEXTMENU
- void QWebPagePrivate::contextMenuEvent(const QPoint& globalPos)
- {
- QMenu *menu = q->createStandardContextMenu();
- if (menu) {
- menu->exec(globalPos);
- delete menu;
- }
- }
- #endif // QT_NO_CONTEXTMENU
- /*!
- \since 4.5
- This function creates the standard context menu which is shown when
- the user clicks on the web page with the right mouse button. It is
- called from the default contextMenuEvent() handler. The popup menu's
- ownership is transferred to the caller.
- */
- QMenu *QWebPage::createStandardContextMenu()
- {
- #ifndef QT_NO_CONTEXTMENU
- QMenu *menu = d->currentContextMenu;
- d->currentContextMenu = 0;
- return menu;
- #else
- return 0;
- #endif
- }
- #ifndef QT_NO_WHEELEVENT
- template<class T>
- void QWebPagePrivate::wheelEvent(T *ev)
- {
- WebCore::Frame* frame = QWebFramePrivate::core(mainFrame);
- if (!frame->view())
- return;
- WebCore::PlatformWheelEvent pev(ev);
- bool accepted = frame->eventHandler()->handleWheelEvent(pev);
- ev->setAccepted(accepted);
- }
- #endif // QT_NO_WHEELEVENT
- #ifndef QT_NO_SHORTCUT
- QWebPage::WebAction QWebPagePrivate::editorActionForKeyEvent(QKeyEvent* event)
- {
- static struct {
- QKeySequence::StandardKey standardKey;
- QWebPage::WebAction action;
- } editorActions[] = {
- { QKeySequence::Cut, QWebPage::Cut },
- { QKeySequence::Copy, QWebPage::Copy },
- { QKeySequence::Paste, QWebPage::Paste },
- { QKeySequence::Undo, QWebPage::Undo },
- { QKeySequence::Redo, QWebPage::Redo },
- { QKeySequence::MoveToNextChar, QWebPage::MoveToNextChar },
- { QKeySequence::MoveToPreviousChar, QWebPage::MoveToPreviousChar },
- { QKeySequence::MoveToNextWord, QWebPage::MoveToNextWord },
- { QKeySequence::MoveToPreviousWord, QWebPage::MoveToPreviousWord },
- { QKeySequence::MoveToNextLine, QWebPage::MoveToNextLine },
- { QKeySequence::MoveToPreviousLine, QWebPage::MoveToPreviousLine },
- { QKeySequence::MoveToStartOfLine, QWebPage::MoveToStartOfLine },
- { QKeySequence::MoveToEndOfLine, QWebPage::MoveToEndOfLine },
- { QKeySequence::MoveToStartOfBlock, QWebPage::MoveToStartOfBlock },
- { QKeySequence::MoveToEndOfBlock, QWebPage::MoveToEndOfBlock },
- { QKeySequence::MoveToStartOfDocument, QWebPage::MoveToStartOfDocument },
- { QKeySequence::MoveToEndOfDocument, QWebPage::MoveToEndOfDocument },
- { QKeySequence::SelectNextChar, QWebPage::SelectNextChar },
- { QKeySequence::SelectPreviousChar, QWebPage::SelectPreviousChar },
- { QKeySequence::SelectNextWord, QWebPage::SelectNextWord },
- { QKeySequence::SelectPreviousWord, QWebPage::SelectPreviousWord },
- { QKeySequence::SelectNextLine, QWebPage::SelectNextLine },
- { QKeySequence::SelectPreviousLine, QWebPage::SelectPreviousLine },
- { QKeySequence::SelectStartOfLine, QWebPage::SelectStartOfLine },
- { QKeySequence::SelectEndOfLine, QWebPage::SelectEndOfLine },
- { QKeySequence::SelectStartOfBlock, QWebPage::SelectStartOfBlock },
- { QKeySequence::SelectEndOfBlock, QWebPage::SelectEndOfBlock },
- { QKeySequence::SelectStartOfDocument, QWebPage::SelectStartOfDocument },
- { QKeySequence::SelectEndOfDocument, QWebPage::SelectEndOfDocument },
- { QKeySequence::DeleteStartOfWord, QWebPage::DeleteStartOfWord },
- { QKeySequence::DeleteEndOfWord, QWebPage::DeleteEndOfWord },
- { QKeySequence::InsertParagraphSeparator, QWebPage::InsertParagraphSeparator },
- { QKeySequence::InsertLineSeparator, QWebPage::InsertLineSeparator },
- { QKeySequence::SelectAll, QWebPage::SelectAll },
- { QKeySequence::UnknownKey, QWebPage::NoWebAction }
- };
- for (int i = 0; editorActions[i].standardKey != QKeySequence::UnknownKey; ++i)
- if (event == editorActions[i].standardKey)
- return editorActions[i].action;
- return QWebPage::NoWebAction;
- }
- #endif // QT_NO_SHORTCUT
- void QWebPagePrivate::keyPressEvent(QKeyEvent *ev)
- {
- bool handled = false;
- WebCore::Frame* frame = page->focusController()->focusedOrMainFrame();
- // we forward the key event to WebCore first to handle potential DOM
- // defined event handlers and later on end up in EditorClientQt::handleKeyboardEvent
- // to trigger editor commands via triggerAction().
- if (!handled)
- handled = frame->eventHandler()->keyEvent(ev);
- if (!handled) {
- handled = true;
- if (!handleScrolling(ev, frame)) {
- switch (ev->key()) {
- case Qt::Key_Back:
- q->triggerAction(QWebPage::Back);
- break;
- case Qt::Key_Forward:
- q->triggerAction(QWebPage::Forward);
- break;
- case Qt::Key_Stop:
- q->triggerAction(QWebPage::Stop);
- break;
- case Qt::Key_Refresh:
- q->triggerAction(QWebPage::Reload);
- break;
- case Qt::Key_Backspace:
- if (ev->modifiers() == Qt::ShiftModifier)
- q->triggerAction(QWebPage::Forward);
- else
- q->triggerAction(QWebPage::Back);
- break;
- default:
- handled = false;
- break;
- }
- }
- }
- ev->setAccepted(handled);
- }
- void QWebPagePrivate::keyReleaseEvent(QKeyEvent *ev)
- {
- if (ev->isAutoRepeat()) {
- ev->setAccepted(true);
- return;
- }
- WebCore::Frame* frame = page->focusController()->focusedOrMainFrame();
- bool handled = frame->eventHandler()->keyEvent(ev);
- ev->setAccepted(handled);
- }
- void QWebPagePrivate::focusInEvent(QFocusEvent*)
- {
- FocusController *focusController = page->focusController();
- focusController->setActive(true);
- focusController->setFocused(true);
- if (!focusController->focusedFrame())
- focusController->setFocusedFrame(QWebFramePrivate::core(mainFrame));
- }
- void QWebPagePrivate::focusOutEvent(QFocusEvent*)
- {
- // only set the focused frame inactive so that we stop painting the caret
- // and the focus frame. But don't tell the focus controller so that upon
- // focusInEvent() we can re-activate the frame.
- FocusController *focusController = page->focusController();
- // Call setFocused first so that window.onblur doesn't get called twice
- focusController->setFocused(false);
- focusController->setActive(false);
- }
- template<class T>
- void QWebPagePrivate::dragEnterEvent(T* ev)
- {
- #ifndef QT_NO_DRAGANDDROP
- DragData dragData(ev->mimeData(), QPointF(ev->pos()).toPoint(),
- QCursor::pos(), dropActionToDragOp(ev->possibleActions()));
- Qt::DropAction action = dragOpToDropAction(page->dragController()->dragEntered(&dragData));
- ev->setDropAction(action);
- ev->acceptProposedAction();
- #endif
- }
- template<class T>
- void QWebPagePrivate::dragLeaveEvent(T *ev)
- {
- #ifndef QT_NO_DRAGANDDROP
- DragData dragData(0, IntPoint(), QCursor::pos(), DragOperationNone);
- page->dragController()->dragExited(&dragData);
- ev->accept();
- #endif
- }
- template<class T>
- void QWebPagePrivate::dragMoveEvent(T *ev)
- {
- #ifndef QT_NO_DRAGANDDROP
- DragData dragData(ev->mimeData(), QPointF(ev->pos()).toPoint(),
- QCursor::pos(), dropActionToDragOp(ev->possibleActions()));
- m_lastDropAction = dragOpToDropAction(page->dragController()->dragUpdated(&dragData));
- ev->setDropAction(m_lastDropAction);
- if (m_lastDropAction != Qt::IgnoreAction)
- ev->accept();
- #endif
- }
- template<class T>
- void QWebPagePrivate::dropEvent(T *ev)
- {
- #ifndef QT_NO_DRAGANDDROP
- DragData dragData(ev->mimeData(), QPointF(ev->pos()).toPoint(),
- QCursor::pos(), dropActionToDragOp(ev->possibleActions()));
- if (page->dragController()->performDrag(&dragData)) {
- ev->setDropAction(m_lastDropAction);
- ev->accept();
- }
- #endif
- }
- void QWebPagePrivate::leaveEvent(QEvent*)
- {
- // Fake a mouse move event just outside of the widget, since all
- // the interesting mouse-out behavior like invalidating scrollbars
- // is handled by the WebKit event handler's mouseMoved function.
- QMouseEvent fakeEvent(QEvent::MouseMove, QCursor::pos(), Qt::NoButton, Qt::NoButton, Qt::NoModifier);
- mouseMoveEvent(&fakeEvent);
- }
- /*!
- \property QWebPage::palette
- \brief the page's palette
- The base brush of the palette is used to draw the background of the main frame.
- By default, this property contains the application's default palette.
- */
- void QWebPage::setPalette(const QPalette &pal)
- {
- d->palette = pal;
- if (!d->mainFrame || !d->mainFrame->d->frame->view())
- return;
- QBrush brush = pal.brush(QPalette::Base);
- QColor backgroundColor = brush.style() == Qt::SolidPattern ? brush.color() : QColor();
- QWebFramePrivate::core(d->mainFrame)->view()->updateBackgroundRecursively(backgroundColor, !backgroundColor.alpha());
- }
- QPalette QWebPage::palette() const
- {
- return d->palette;
- }
- void QWebPagePrivate::inputMethodEvent(QInputMethodEvent *ev)
- {
- WebCore::Frame *frame = page->focusController()->focusedOrMainFrame();
- WebCore::Editor *editor = frame->editor();
- if (!editor->canEdit()) {
- ev->ignore();
- return;
- }
- Node* node = 0;
- if (frame->selection()->rootEditableElement())
- node = frame->selection()->rootEditableElement()->shadowAncestorNode();
- Vector<CompositionUnderline> underlines;
- bool hasSelection = false;
- for (int i = 0; i < ev->attributes().size(); ++i) {
- const QInputMethodEvent::Attribute& a = ev->attributes().at(i);
- switch (a.type) {
- case QInputMethodEvent::TextFormat: {
- QTextCharFormat textCharFormat = a.value.value<QTextFormat>().toCharFormat();
- QColor qcolor = textCharFormat.underlineColor();
- underlines.append(CompositionUnderline(qMin(a.start, (a.start + a.length)), qMax(a.start, (a.start + a.length)), Color(makeRGBA(qcolor.red(), qcolor.green(), qcolor.blue(), qcolor.alpha())), false));
- break;
- }
- case QInputMethodEvent::Cursor: {
- frame->selection()->setCaretVisible(a.length); //if length is 0 cursor is invisible
- if (a.length > 0) {
- RenderObject* caretRenderer = frame->selection()->caretRenderer();
- if (caretRenderer) {
- QColor qcolor = a.value.value<QColor>();
- caretRenderer->style()->setColor(Color(makeRGBA(qcolor.red(), qcolor.green(), qcolor.blue(), qcolor.alpha())));
- }
- }
- break;
- }
- case QInputMethodEvent::Selection: {
- hasSelection = true;
- // A selection in the inputMethodEvent is always reflected in the visible text
- if (node)
- setSelectionRange(node, qMin(a.start, (a.start + a.length)), qMax(a.start, (a.start + a.length)));
- if (!ev->preeditString().isEmpty())
- editor->setComposition(ev->preeditString(), underlines, qMin(a.start, (a.start + a.length)), qMax(a.start, (a.start + a.length)));
- else {
- // If we are in the middle of a composition, an empty pre-edit string and a selection of zero
- // cancels the current composition
- if (editor->hasComposition() && (a.start + a.length == 0))
- editor->setComposition(QString(), underlines, 0, 0);
- }
- break;
- }
- default:
- break;
- }
- }
- if (node && ev->replacementLength() > 0) {
- int cursorPos = frame->selection()->extent().offsetInContainerNode();
- int start = cursorPos + ev->replacementStart();
- setSelectionRange(node, start, start + ev->replacementLength());
- // Commit regardless of whether commitString is empty, to get rid of selection.
- editor->confirmComposition(ev->commitString());
- } else if (!ev->commitString().isEmpty()) {
- if (editor->hasComposition())
- editor->confirmComposition(ev->commitString());
- else
- editor->insertText(ev->commitString(), 0);
- } else if (!hasSelection && !ev->preeditString().isEmpty())
- editor->setComposition(ev->preeditString(), underlines, 0, 0);
- else if (ev->preeditString().isEmpty() && editor->hasComposition())
- editor->confirmComposition(String());
- ev->accept();
- }
- #ifndef QT_NO_PROPERTIES
- typedef struct {
- const char* name;
- double deferredRepaintDelay;
- double initialDeferredRepaintDelayDuringLoading;
- double maxDeferredRepaintDelayDuringLoading;
- double deferredRepaintDelayIncrementDuringLoading;
- } QRepaintThrottlingPreset;
- void QWebPagePrivate::dynamicPropertyChangeEvent(QDynamicPropertyChangeEvent* event)
- {
- if (event->propertyName() == "_q_viewMode") {
- page->setViewMode(Page::stringToViewMode(q->property("_q_viewMode").toString()));
- } else if (event->propertyName() == "_q_HTMLTokenizerChunkSize") {
- int chunkSize = q->property("_q_HTMLTokenizerChunkSize").toInt();
- q->handle()->page->setCustomHTMLTokenizerChunkSize(chunkSize);
- } else if (event->propertyName() == "_q_HTMLTokenizerTimeDelay") {
- double timeDelay = q->property("_q_HTMLTokenizerTimeDelay").toDouble();
- q->handle()->page->setCustomHTMLTokenizerTimeDelay(timeDelay);
- } else if (event->propertyName() == "_q_RepaintThrottlingDeferredRepaintDelay") {
- double p = q->property("_q_RepaintThrottlingDeferredRepaintDelay").toDouble();
- FrameView::setRepaintThrottlingDeferredRepaintDelay(p);
- } else if (event->propertyName() == "_q_RepaintThrottlingnInitialDeferredRepaintDelayDuringLoading") {
- double p = q->property("_q_RepaintThrottlingnInitialDeferredRepaintDelayDuringLoading").toDouble();
- FrameView::setRepaintThrottlingnInitialDeferredRepaintDelayDuringLoading(p);
- } else if (event->propertyName() == "_q_RepaintThrottlingMaxDeferredRepaintDelayDuringLoading") {
- double p = q->property("_q_RepaintThrottlingMaxDeferredRepaintDelayDuringLoading").toDouble();
- FrameView::setRepaintThrottlingMaxDeferredRepaintDelayDuringLoading(p);
- } else if (event->propertyName() == "_q_RepaintThrottlingDeferredRepaintDelayIncrementDuringLoading") {
- double p = q->property("_q_RepaintThrottlingDeferredRepaintDelayIncrementDuringLoading").toDouble();
- FrameView::setRepaintThrottlingDeferredRepaintDelayIncrementDuringLoading(p);
- } else if (event->propertyName() == "_q_RepaintThrottlingPreset") {
- static const QRepaintThrottlingPreset presets[] = {
- { "NoThrottling", 0, 0, 0, 0 },
- { "Legacy", 0.025, 0, 2.5, 0.5 },
- { "Minimal", 0.01, 0, 1, 0.2 },
- { "Medium", 0.025, 1, 5, 0.5 },
- { "Heavy", 0.1, 2, 10, 1 }
- };
- QString p = q->property("_q_RepaintThrottlingPreset").toString();
- for (size_t i = 0; i < sizeof(presets) / sizeof(presets[0]); i++) {
- if (p == QLatin1String(presets[i].name)) {
- FrameView::setRepaintThrottlingDeferredRepaintDelay(
- presets[i].deferredRepaintDelay);
- FrameView::setRepaintThrottlingnInitialDeferredRepaintDelayDuringLoading(
- presets[i].initialDeferredRepaintDelayDuringLoading);
- FrameView::setRepaintThrottlingMaxDeferredRepaintDelayDuringLoading(
- presets[i].maxDeferredRepaintDelayDuringLoading);
- FrameView::setRepaintThrottlingDeferredRepaintDelayIncrementDuringLoading(
- presets[i].deferredRepaintDelayIncrementDuringLoading);
- break;
- }
- }
- }
- #if ENABLE(TILED_BACKING_STORE)
- else if (event->propertyName() == "_q_TiledBackingStoreTileSize") {
- WebCore::Frame* frame = QWebFramePrivate::core(q->mainFrame());
- if (!frame->tiledBackingStore())
- return;
- QSize tileSize = q->property("_q_TiledBackingStoreTileSize").toSize();
- frame->tiledBackingStore()->setTileSize(tileSize);
- } else if (event->propertyName() == "_q_TiledBackingStoreTileCreationDelay") {
- WebCore::Frame* frame = QWebFramePrivate::core(q->mainFrame());
- if (!frame->tiledBackingStore())
- return;
- int tileCreationDelay = q->property("_q_TiledBackingStoreTileCreationDelay").toInt();
- frame->tiledBackingStore()->setTileCreationDelay(static_cast<double>(tileCreationDelay) / 1000.);
- } else if (event->propertyName() == "_q_TiledBackingStoreKeepAreaMultiplier") {
- WebCore::Frame* frame = QWebFramePrivate::core(q->mainFrame());
- if (!frame->tiledBackingStore())
- return;
- FloatSize keepMultiplier;
- FloatSize coverMultiplier;
- frame->tiledBackingStore()->getKeepAndCoverAreaMultipliers(keepMultiplier, coverMultiplier);
- QSizeF qSize = q->property("_q_TiledBackingStoreKeepAreaMultiplier").toSizeF();
- keepMultiplier = FloatSize(qSize.width(), qSize.height());
- frame->tiledBackingStore()->setKeepAndCoverAreaMultipliers(keepMultiplier, coverMultiplier);
- } else if (event->propertyName() == "_q_TiledBackingStoreCoverAreaMultiplier") {
- WebCore::Frame* frame = QWebFramePrivate::core(q->mainFrame());
- if (!frame->tiledBackingStore())
- return;
- FloatSize keepMultiplier;
- FloatSize coverMultiplier;
- frame->tiledBackingStore()->getKeepAndCoverAreaMultipliers(keepMultiplier, coverMultiplier);
- QSizeF qSize = q->property("_q_TiledBackingStoreCoverAreaMultiplier").toSizeF();
- coverMultiplier = FloatSize(qSize.width(), qSize.height());
- frame->tiledBackingStore()->setKeepAndCoverAreaMultipliers(keepMultiplier, coverMultiplier);
- }
- #endif
- else if (event->propertyName() == "_q_webInspectorServerPort") {
- InspectorServerQt* inspectorServer = InspectorServerQt::server();
- inspectorServer->listen(inspectorServerPort());
- } else if (event->propertyName() == "_q_deadDecodedDataDeletionInterval") {
- double interval = q->property("_q_deadDecodedDataDeletionInterval").toDouble();
- memoryCache()->setDeadDecodedDataDeletionInterval(interval);
- }
- }
- #endif
- void QWebPagePrivate::shortcutOverrideEvent(QKeyEvent* event)
- {
- WebCore::Frame* frame = page->focusController()->focusedOrMainFrame();
- WebCore::Editor* editor = frame->editor();
- if (editor->canEdit()) {
- if (event->modifiers() == Qt::NoModifier
- || event->modifiers() == Qt::ShiftModifier
- || event->modifiers() == Qt::KeypadModifier) {
- if (event->key() < Qt::Key_Escape) {
- event->accept();
- } else {
- switch (event->key()) {
- case Qt::Key_Return:
- case Qt::Key_Enter:
- case Qt::Key_Delete:
- case Qt::Key_Home:
- case Qt::Key_End:
- case Qt::Key_Backspace:
- case Qt::Key_Left:
- case Qt::Key_Right:
- case Qt::Key_Up:
- case Qt::Key_Down:
- case Qt::Key_Tab:
- event->accept();
- default:
- break;
- }
- }
- }
- #ifndef QT_NO_SHORTCUT
- else if (editorActionForKeyEvent(event) != QWebPage::NoWebAction)
- event->accept();
- #endif
- }
- }
- bool QWebPagePrivate::handleScrolling(QKeyEvent *ev, Frame *frame)
- {
- ScrollDirection direction;
- ScrollGranularity granularity;
- #ifndef QT_NO_SHORTCUT
- if (ev == QKeySequence::MoveToNextPage
- || (ev->key() == Qt::Key_Space && !(ev->modifiers() & Qt::ShiftModifier))) {
- granularity = ScrollByPage;
- direction = ScrollDown;
- } else if (ev == QKeySequence::MoveToPreviousPage
- || ((ev->key() == Qt::Key_Space) && (ev->modifiers() & Qt::ShiftModifier))) {
- granularity = ScrollByPage;
- direction = ScrollUp;
- } else
- #endif // QT_NO_SHORTCUT
- if ((ev->key() == Qt::Key_Up && ev->modifiers() & Qt::ControlModifier)
- || ev->key() == Qt::Key_Home) {
- granularity = ScrollByDocument;
- direction = ScrollUp;
- } else if ((ev->key() == Qt::Key_Down && ev->modifiers() & Qt::ControlModifier)
- || ev->key() == Qt::Key_End) {
- granularity = ScrollByDocument;
- direction = ScrollDown;
- } else {
- switch (ev->key()) {
- case Qt::Key_Up:
- granularity = ScrollByLine;
- direction = ScrollUp;
- break;
- case Qt::Key_Down:
- granularity = ScrollByLine;
- direction = ScrollDown;
- break;
- case Qt::Key_Left:
- granularity = ScrollByLine;
- direction = ScrollLeft;
- break;
- case Qt::Key_Right:
- granularity = ScrollByLine;
- direction = ScrollRight;
- break;
- default:
- return false;
- }
- }
- return frame->eventHandler()->scrollRecursively(direction, granularity);
- }
- void QWebPagePrivate::adjustPointForClicking(QMouseEvent*)
- {
- notImplemented();
- }
- #if !defined(QT_NO_GRAPHICSVIEW)
- void QWebPagePrivate::adjustPointForClicking(QGraphicsScene…