Commit 4b3900cc authored by ariya@webkit.org's avatar ariya@webkit.org
Browse files

2009-03-20 Erik L. Bunce <elbunce@xendom.com>

        Reviewed by Tor Arne Vestbø.

        Fix QWebPage::WebActions action states to more closely match when they are
        actually applicable and remove erroneous documentation.

        * Most WebActions implemented using editor commands now use the
          Editor::Command::isEnabled() to control their availability.
        * SelectAll is always enabled (since it's editor command is).
        * SetTextDirection{} family of WebActions are available when canEdit() is true
          and not just canEditRichly().

        Fix and clarify documentation about the availability of various web actions.

        * Api/qwebpage.cpp:
        (QWebPagePrivate::updateAction):
        (QWebPagePrivate::updateEditorActions):
        * tests/qwebpage/tst_qwebpage.cpp:
        (tst_QWebPage::textSelection):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@41861 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent d6e7a1a5
......@@ -463,61 +463,35 @@ void QWebPagePrivate::updateAction(QWebPage::WebAction action)
case QWebPage::Reload:
enabled = !loader->isLoading();
break;
case QWebPage::Cut:
enabled = editor->canCut();
break;
case QWebPage::Copy:
enabled = editor->canCopy();
break;
case QWebPage::Paste:
enabled = editor->canPaste();
break;
#ifndef QT_NO_UNDOSTACK
case QWebPage::Undo:
case QWebPage::Redo:
// those two are handled by QUndoStack
break;
#endif // QT_NO_UNDOSTACK
case QWebPage::MoveToNextChar:
case QWebPage::MoveToPreviousChar:
case QWebPage::MoveToNextWord:
case QWebPage::MoveToPreviousWord:
case QWebPage::MoveToNextLine:
case QWebPage::MoveToPreviousLine:
case QWebPage::MoveToStartOfLine:
case QWebPage::MoveToEndOfLine:
case QWebPage::MoveToStartOfBlock:
case QWebPage::MoveToEndOfBlock:
case QWebPage::MoveToStartOfDocument:
case QWebPage::MoveToEndOfDocument:
case QWebPage::SelectAll:
case QWebPage::SelectNextChar:
case QWebPage::SelectPreviousChar:
case QWebPage::SelectNextWord:
case QWebPage::SelectPreviousWord:
case QWebPage::SelectNextLine:
case QWebPage::SelectPreviousLine:
case QWebPage::SelectStartOfLine:
case QWebPage::SelectEndOfLine:
case QWebPage::SelectStartOfBlock:
case QWebPage::SelectEndOfBlock:
case QWebPage::SelectStartOfDocument:
case QWebPage::SelectEndOfDocument:
case QWebPage::DeleteStartOfWord:
case QWebPage::DeleteEndOfWord:
case QWebPage::SelectAll: // editor command is always enabled
break;
case QWebPage::SetTextDirectionDefault:
case QWebPage::SetTextDirectionLeftToRight:
case QWebPage::SetTextDirectionRightToLeft:
case QWebPage::ToggleBold:
case QWebPage::ToggleItalic:
case QWebPage::ToggleUnderline:
enabled = editor->canEditRichly();
if (enabled)
checked = editor->command(editorCommandForWebActions(action)).state() != FalseTriState;
else
checked = false;
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;
default: break;
}
}
a->setEnabled(enabled);
......@@ -551,7 +525,6 @@ void QWebPagePrivate::updateEditorActions()
updateAction(QWebPage::MoveToEndOfBlock);
updateAction(QWebPage::MoveToStartOfDocument);
updateAction(QWebPage::MoveToEndOfDocument);
updateAction(QWebPage::SelectAll);
updateAction(QWebPage::SelectNextChar);
updateAction(QWebPage::SelectPreviousChar);
updateAction(QWebPage::SelectNextWord);
......@@ -1130,8 +1103,13 @@ QVariant QWebPage::inputMethodQuery(Qt::InputMethodQuery property) const
\enum QWebPage::WebAction
This enum describes the types of action which can be performed on the web page.
Actions which are related to text editing, cursor movement, and text selection
only have an effect if \l contentEditable is true.
Actions only have an effect when they are applicable. The availability of
actions can be be determined by checking \l{QAction::}{enabled()} on the
action returned by \l{QWebPage::}{action()}.
One method of enabling the text editing, cursor movement, and text selection actions
is by setting \l contentEditable to true.
\value NoWebAction No action is triggered.
\value OpenLink Open the current link.
......
2009-03-20 Erik L. Bunce <elbunce@xendom.com>
Reviewed by Tor Arne Vestbø.
Fix QWebPage::WebActions action states to more closely match when they are
actually applicable and remove erroneous documentation.
* Most WebActions implemented using editor commands now use the
Editor::Command::isEnabled() to control their availability.
* SelectAll is always enabled (since it's editor command is).
* SetTextDirection{} family of WebActions are available when canEdit() is true
and not just canEditRichly().
Fix and clarify documentation about the availability of various web actions.
* Api/qwebpage.cpp:
(QWebPagePrivate::updateAction):
(QWebPagePrivate::updateEditorActions):
* tests/qwebpage/tst_qwebpage.cpp:
(tst_QWebPage::textSelection):
2009-03-19 Ariya Hidayat <ariya.hidayat@trolltech.com>
Reviewed by Simon Hausmann.
......
......@@ -894,7 +894,6 @@ void tst_QWebPage::textSelection()
QVERIFY(page->action(QWebPage::SelectEndOfDocument) != 0);
// right now they are disabled because contentEditable is false
QCOMPARE(page->action(QWebPage::SelectAll)->isEnabled(), false);
QCOMPARE(page->action(QWebPage::SelectNextChar)->isEnabled(), false);
QCOMPARE(page->action(QWebPage::SelectPreviousChar)->isEnabled(), false);
QCOMPARE(page->action(QWebPage::SelectNextWord)->isEnabled(), false);
......@@ -908,6 +907,9 @@ void tst_QWebPage::textSelection()
QCOMPARE(page->action(QWebPage::SelectStartOfDocument)->isEnabled(), false);
QCOMPARE(page->action(QWebPage::SelectEndOfDocument)->isEnabled(), false);
// ..but SelectAll is awalys enabled
QCOMPARE(page->action(QWebPage::SelectAll)->isEnabled(), true);
// make it editable before navigating the cursor
page->setContentEditable(true);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment