Introducing DictationCommand.
authorjpu@apple.com <jpu@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 Apr 2012 03:05:06 +0000 (03:05 +0000)
committerjpu@apple.com <jpu@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 Apr 2012 03:05:06 +0000 (03:05 +0000)
commitdfd2ce6085578855d395fda0aa2706929d2d2031
tree18027c3ab4709690510f71bc5f8288406dc6f4df
parent97d5d8773d315da06e6cbde8312d6ca1051d621f
Introducing DictationCommand.
https://bugs.webkit.org/show_bug.cgi?id=83549

Reviewed by Hajime Morita.

No new tests. This patch doesn't introduce any change of new functionality. It prepares for
additional changes which will inlude tests.

On OS X, alternative dictation results need to be stored as document markers. This patch introduces
following changes to achieve this:
1. Added DictationMarkDetails to store non-string type maker detail.
2. Introduce DictationCommand, which is similor to TypingCommand, but allows inserting text with
  attached markers.
3. Added Editor::insertDictatedText as interaface to WebKit and WebKit2.
4. Added struct DictationAlternative to pass dictation related info from WebKit to WebCore.

Several fragments of code in TypingCommand can be also used by DictationCommand. So this patch
introduced a new class, TextInsertionBaseCommand. It's a subclass of CompositeEditCommmand, and
base class of both TypingCommand and DictationCommand.

This patch also extends InsertTextCommand class. Its constructor will take an TextInsertionMarkerSupplier
object. After text is inserted to a node, InsertTextCommand would give marker supplier a chance to
add document markers to the inserted text.

* CMakeLists.txt:
* GNUmakefile.list.am:
* Target.pri:
* WebCore.exp.in:
* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* dom/Document.cpp:
(WebCore::eventTargetNodeForDocument): Moved this function from EventHandler so that it can be used
  by AlternativeTextController.
(WebCore):
* dom/Document.h:
(WebCore):
* dom/DocumentMarker.cpp:
(WebCore::DocumentMarker::DocumentMarker): New constructor that takes a pointer to DocumentMarkerDetails object.
(WebCore):
* dom/DocumentMarker.h:
(WebCore::DocumentMarker::AllMarkers::AllMarkers):
(DocumentMarker):
* dom/DocumentMarkerController.cpp:
(WebCore::DocumentMarkerController::addMarker):
(WebCore):
* dom/DocumentMarkerController.h:
(DocumentMarkerController):
* dom/TextEvent.cpp:
(WebCore::TextEvent::createForDictation):
(WebCore):
(WebCore::TextEvent::TextEvent):
* dom/TextEvent.h: Added member variable for dictation alternatives.
(TextEvent):
(WebCore::TextEvent::isDictation):
(WebCore::TextEvent::dictationAlternatives):
* dom/TextEventInputType.h:
* editing/AlternativeTextController.cpp:
(WebCore::AlternativeTextController::AlternativeTextController):
(WebCore::AlternativeTextController::insertDictatedText): Used by Editor::insertDictatedText().
(WebCore):
* editing/AlternativeTextController.h:
(WebCore):
(DictationMarkerDetails):
(WebCore::DictationMarkerDetails::create):
(WebCore::DictationMarkerDetails::originalText):
(WebCore::DictationMarkerDetails::dictationContext):
(WebCore::DictationMarkerDetails::DictationMarkerDetails):
(AlternativeTextController):
* editing/CompositeEditCommand.h:
(WebCore::CompositeEditCommand::isDictationCommand):
* editing/DictationAlternative.cpp: Added.
(WebCore):
(WebCore::DictationAlternative::DictationAlternative):
* editing/DictationAlternative.h: Added. Data structure for passing dictation related data from WebKit to WebCore.
(DictationAlternative):
(WebCore):
* editing/DictationCommand.cpp: Added.
(WebCore):
(DictationCommandLineOperation):
(WebCore::DictationCommandLineOperation::DictationCommandLineOperation):
(WebCore::DictationCommandLineOperation::operator()):
(DictationMarkerSupplier):
(WebCore::DictationMarkerSupplier::create):
(WebCore::DictationMarkerSupplier::addMarkersToTextNode):
(WebCore::DictationMarkerSupplier::DictationMarkerSupplier):
(WebCore::DictationCommand::DictationCommand):
(WebCore::DictationCommand::insertText):
(WebCore::DictationCommand::doApply):
(WebCore::DictationCommand::insertTextRunWithoutNewlines):
(WebCore::DictationCommand::insertParagraphSeparator):
(WebCore::DictationCommand::collectDictationAlternativesInRange):
* editing/DictationCommand.h: Added.
(WebCore):
(DictationCommand):
(WebCore::DictationCommand::isDictationCommand):
(WebCore::DictationCommand::create):
* editing/EditingAllInOne.cpp:
* editing/Editor.cpp:
(WebCore::Editor::insertDictatedText): Main interface that allows WebKit passes in text with attached dictation information.
(WebCore):
(WebCore::Editor::insertTextWithoutSendingTextEvent):
(WebCore::Editor::updateMarkersForWordsAffectedByEditing):
* editing/Editor.h:
(Editor):
* editing/InsertTextCommand.cpp:
(WebCore::InsertTextCommand::InsertTextCommand):
(WebCore):
(WebCore::InsertTextCommand::doApply):
* editing/InsertTextCommand.h:
(WebCore):
(TextInsertionMarkerSupplier): Interface to allow caller of InsertTextCommand to add document markers to inserted text.
(WebCore::TextInsertionMarkerSupplier::~TextInsertionMarkerSupplier):
(WebCore::TextInsertionMarkerSupplier::TextInsertionMarkerSupplier):
(WebCore::InsertTextCommand::createWithMarkerSupplier):
(InsertTextCommand):
* editing/TextInsertionBaseCommand.cpp: Added. This class contains functions shared by TypingCommand and DictationCommand.
(WebCore):
(WebCore::TextInsertionBaseCommand::TextInsertionBaseCommand):
(WebCore::TextInsertionBaseCommand::applyTextInsertionCommand):
(WebCore::dispatchBeforeTextInsertedEvent):
(WebCore::canAppendNewLineFeedToSelection):
* editing/TextInsertionBaseCommand.h: Added.
(WebCore):
(TextInsertionBaseCommand):
(WebCore::TextInsertionBaseCommand::~TextInsertionBaseCommand):
(WebCore::forEachLineInString):
* editing/TypingCommand.cpp:
(TypingCommandLineOperation):
(WebCore::TypingCommandLineOperation::TypingCommandLineOperation):
(WebCore::TypingCommandLineOperation::operator()):
(WebCore::TypingCommand::TypingCommand):
(WebCore::TypingCommand::insertText):
(WebCore::TypingCommand::insertLineBreak):
(WebCore::TypingCommand::insertParagraphSeparator):
* editing/TypingCommand.h:
* page/EventHandler.cpp:
* rendering/InlineTextBox.cpp:
(WebCore::lineStyleForMarkerType):
(WebCore::InlineTextBox::paintDocumentMarker): Renamed existing function to reflect new funcationality.
(WebCore::InlineTextBox::paintDocumentMarkers):
* rendering/InlineTextBox.h:
(InlineTextBox):
* testing/Internals.cpp:
(WebCore::markerTypesFrom):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@114220 268f45cc-cd09-0410-ab3c-d52691b4dbfc
37 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.list.am
Source/WebCore/Target.pri
Source/WebCore/WebCore.exp.in
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.vcproj/WebCore.vcproj
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/dom/DocumentMarker.cpp
Source/WebCore/dom/DocumentMarker.h
Source/WebCore/dom/DocumentMarkerController.cpp
Source/WebCore/dom/DocumentMarkerController.h
Source/WebCore/dom/TextEvent.cpp
Source/WebCore/dom/TextEvent.h
Source/WebCore/dom/TextEventInputType.h
Source/WebCore/editing/AlternativeTextController.cpp
Source/WebCore/editing/AlternativeTextController.h
Source/WebCore/editing/CompositeEditCommand.h
Source/WebCore/editing/DictationAlternative.cpp [new file with mode: 0644]
Source/WebCore/editing/DictationAlternative.h [new file with mode: 0644]
Source/WebCore/editing/DictationCommand.cpp [new file with mode: 0644]
Source/WebCore/editing/DictationCommand.h [new file with mode: 0644]
Source/WebCore/editing/EditingAllInOne.cpp
Source/WebCore/editing/Editor.cpp
Source/WebCore/editing/Editor.h
Source/WebCore/editing/InsertTextCommand.cpp
Source/WebCore/editing/InsertTextCommand.h
Source/WebCore/editing/TextInsertionBaseCommand.cpp [new file with mode: 0644]
Source/WebCore/editing/TextInsertionBaseCommand.h [new file with mode: 0644]
Source/WebCore/editing/TypingCommand.cpp
Source/WebCore/editing/TypingCommand.h
Source/WebCore/page/EventHandler.cpp
Source/WebCore/rendering/InlineTextBox.cpp
Source/WebCore/rendering/InlineTextBox.h
Source/WebCore/testing/Internals.cpp