Title: [128889] trunk/Source/WebKit/qt
- Revision
- 128889
- Author
- [email protected]
- Date
- 2012-09-18 07:05:07 -0700 (Tue, 18 Sep 2012)
Log Message
[Qt] Use UndoStep::editingAction() to set the text of undo/redo actions
https://bugs.webkit.org/show_bug.cgi?id=96921
Reviewed by Ryosuke Niwa.
Set the text of QUndoCommands we create for undo/redo actions based on the
editing action from UndoStep.
This change is visible using QtTestBrowser, and looking at the Edit menu after
doing HTML editing changes. I've used http://simple-rte.rniwa.com for testing.
* WebCoreSupport/UndoStepQt.cpp:
(undoNameForEditAction): This function returns a localized name of the action.
(UndoStepQt::UndoStepQt): Set the text based on UndoStep::editingAction.
* tests/qwebpage/tst_qwebpage.cpp:
(tst_QWebPage):
(tst_QWebPage::undoActionHaveCustomText): Create a new test to verify that the text
describing the undo action after inserting a text and indenting the text is different.
Modified Paths
Diff
Modified: trunk/Source/WebKit/qt/ChangeLog (128888 => 128889)
--- trunk/Source/WebKit/qt/ChangeLog 2012-09-18 14:03:48 UTC (rev 128888)
+++ trunk/Source/WebKit/qt/ChangeLog 2012-09-18 14:05:07 UTC (rev 128889)
@@ -1,3 +1,24 @@
+2012-09-17 Caio Marcelo de Oliveira Filho <[email protected]>
+
+ [Qt] Use UndoStep::editingAction() to set the text of undo/redo actions
+ https://bugs.webkit.org/show_bug.cgi?id=96921
+
+ Reviewed by Ryosuke Niwa.
+
+ Set the text of QUndoCommands we create for undo/redo actions based on the
+ editing action from UndoStep.
+
+ This change is visible using QtTestBrowser, and looking at the Edit menu after
+ doing HTML editing changes. I've used http://simple-rte.rniwa.com for testing.
+
+ * WebCoreSupport/UndoStepQt.cpp:
+ (undoNameForEditAction): This function returns a localized name of the action.
+ (UndoStepQt::UndoStepQt): Set the text based on UndoStep::editingAction.
+ * tests/qwebpage/tst_qwebpage.cpp:
+ (tst_QWebPage):
+ (tst_QWebPage::undoActionHaveCustomText): Create a new test to verify that the text
+ describing the undo action after inserting a text and indenting the text is different.
+
2012-09-17 Leo Franchi <[email protected]>
[Qt] Inspector WebSocket backend protocol update
Modified: trunk/Source/WebKit/qt/WebCoreSupport/UndoStepQt.cpp (128888 => 128889)
--- trunk/Source/WebKit/qt/WebCoreSupport/UndoStepQt.cpp 2012-09-18 14:03:48 UTC (rev 128888)
+++ trunk/Source/WebKit/qt/WebCoreSupport/UndoStepQt.cpp 2012-09-18 14:05:07 UTC (rev 128889)
@@ -23,11 +23,95 @@
using namespace WebCore;
#ifndef QT_NO_UNDOCOMMAND
+static QString undoNameForEditAction(const EditAction editAction)
+{
+ switch (editAction) {
+ case EditActionUnspecified:
+ return QString();
+ case EditActionSetColor:
+ return QObject::tr("Set Color");
+ case EditActionSetBackgroundColor:
+ return QObject::tr("Set Background Color");
+ case EditActionTurnOffKerning:
+ return QObject::tr("Turn Off Kerning");
+ case EditActionTightenKerning:
+ return QObject::tr("Tighten Kerning");
+ case EditActionLoosenKerning:
+ return QObject::tr("Loosen Kerning");
+ case EditActionUseStandardKerning:
+ return QObject::tr("Use Standard Kerning");
+ case EditActionTurnOffLigatures:
+ return QObject::tr("Turn Off Ligatures");
+ case EditActionUseStandardLigatures:
+ return QObject::tr("Use Standard Ligatures");
+ case EditActionUseAllLigatures:
+ return QObject::tr("Use All Ligatures");
+ case EditActionRaiseBaseline:
+ return QObject::tr("Raise Baseline");
+ case EditActionLowerBaseline:
+ return QObject::tr("Lower Baseline");
+ case EditActionSetTraditionalCharacterShape:
+ return QObject::tr("Set Traditional Character Shape");
+ case EditActionSetFont:
+ return QObject::tr("Set Font");
+ case EditActionChangeAttributes:
+ return QObject::tr("Change Attributes");
+ case EditActionAlignLeft:
+ return QObject::tr("Align Left");
+ case EditActionAlignRight:
+ return QObject::tr("Align Right");
+ case EditActionCenter:
+ return QObject::tr("Center");
+ case EditActionJustify:
+ return QObject::tr("Justify");
+ case EditActionSetWritingDirection:
+ return QObject::tr("Set Writing Direction");
+ case EditActionSubscript:
+ return QObject::tr("Subscript");
+ case EditActionSuperscript:
+ return QObject::tr("Superscript");
+ case EditActionUnderline:
+ return QObject::tr("Underline");
+ case EditActionOutline:
+ return QObject::tr("Outline");
+ case EditActionUnscript:
+ return QObject::tr("Unscript");
+ case EditActionDrag:
+ return QObject::tr("Drag");
+ case EditActionCut:
+ return QObject::tr("Cut");
+ case EditActionPaste:
+ return QObject::tr("Paste");
+ case EditActionPasteFont:
+ return QObject::tr("Paste Font");
+ case EditActionPasteRuler:
+ return QObject::tr("Paste Ruler");
+ case EditActionTyping:
+ return QObject::tr("Typing");
+ case EditActionCreateLink:
+ return QObject::tr("Create Link");
+ case EditActionUnlink:
+ return QObject::tr("Unlink");
+ case EditActionInsertList:
+ return QObject::tr("Insert List");
+ case EditActionFormatBlock:
+ return QObject::tr("Formatting");
+ case EditActionIndent:
+ return QObject::tr("Indent");
+ case EditActionOutdent:
+ return QObject::tr("Outdent");
+ }
+
+ ASSERT_NOT_REACHED();
+ return QString();
+}
+
UndoStepQt::UndoStepQt(WTF::RefPtr<UndoStep> step, QUndoCommand *parent)
: QUndoCommand(parent)
, m_step(step)
, m_first(true)
{
+ setText(undoNameForEditAction(step->editingAction()));
}
#else
UndoStepQt::UndoStepQt(WTF::RefPtr<UndoStep> step)
Modified: trunk/Source/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp (128888 => 128889)
--- trunk/Source/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp 2012-09-18 14:03:48 UTC (rev 128888)
+++ trunk/Source/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp 2012-09-18 14:05:07 UTC (rev 128889)
@@ -139,6 +139,7 @@
void errorPageExtensionLoadFinished();
void userAgentApplicationName();
void userAgentNewlineStripping();
+ void undoActionHaveCustomText();
void viewModes();
@@ -3260,5 +3261,19 @@
QTRY_VERIFY(loadSpy.isFinished());
}
+void tst_QWebPage::undoActionHaveCustomText()
+{
+ m_page->mainFrame()->setHtml("<div id=test contenteditable></div>");
+ m_page->mainFrame()->evaluateJavaScript("document.getElementById('test').focus()");
+
+ m_page->mainFrame()->evaluateJavaScript("document.execCommand('insertText', true, 'Test');");
+ QString typingActionText = m_page->action(QWebPage::Undo)->text();
+
+ m_page->mainFrame()->evaluateJavaScript("document.execCommand('indent', true);");
+ QString alignActionText = m_page->action(QWebPage::Undo)->text();
+
+ QVERIFY(typingActionText != alignActionText);
+}
+
QTEST_MAIN(tst_QWebPage)
#include "tst_qwebpage.moc"
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes