|
Lines 59-65
a/Source/WebCore/editing/Editor.cpp_sec1
|
| 59 |
#include "HTMLTextAreaElement.h" |
59 |
#include "HTMLTextAreaElement.h" |
| 60 |
#include "HitTestResult.h" |
60 |
#include "HitTestResult.h" |
| 61 |
#include "IndentOutdentCommand.h" |
61 |
#include "IndentOutdentCommand.h" |
|
|
62 |
#include "InputEvent.h" |
| 62 |
#include "InsertListCommand.h" |
63 |
#include "InsertListCommand.h" |
|
|
64 |
#include "InsertTextCommand.h" |
| 63 |
#include "KeyboardEvent.h" |
65 |
#include "KeyboardEvent.h" |
| 64 |
#include "KillRing.h" |
66 |
#include "KillRing.h" |
| 65 |
#include "Logging.h" |
67 |
#include "Logging.h" |
|
Lines 109-114
a/Source/WebCore/editing/Editor.cpp_sec2
|
| 109 |
|
111 |
|
| 110 |
namespace WebCore { |
112 |
namespace WebCore { |
| 111 |
|
113 |
|
|
|
114 |
static bool dispatchBeforeInputEvent(Element& element, const AtomicString& inputType) |
| 115 |
{ |
| 116 |
auto* settings = element.document().settings(); |
| 117 |
if (!settings || !settings->inputEventsEnabled()) |
| 118 |
return true; |
| 119 |
|
| 120 |
auto event = InputEvent::create(eventNames().beforeinputEvent, inputType, true, true, element.document().defaultView(), 0); |
| 121 |
element.dispatchScopedEvent(event); |
| 122 |
|
| 123 |
return !event->defaultPrevented(); |
| 124 |
} |
| 125 |
|
| 112 |
class ClearTextCommand : public DeleteSelectionCommand { |
126 |
class ClearTextCommand : public DeleteSelectionCommand { |
| 113 |
public: |
127 |
public: |
| 114 |
ClearTextCommand(Document& document); |
128 |
ClearTextCommand(Document& document); |
|
Lines 1025-1038
static void notifyTextFromControls(Element* startRoot, Element* endRoot)
a/Source/WebCore/editing/Editor.cpp_sec3
|
| 1025 |
endingTextControl->didEditInnerTextValue(); |
1039 |
endingTextControl->didEditInnerTextValue(); |
| 1026 |
} |
1040 |
} |
| 1027 |
|
1041 |
|
| 1028 |
static void dispatchEditableContentChangedEvents(PassRefPtr<Element> prpStartRoot, PassRefPtr<Element> prpEndRoot) |
1042 |
static bool dispatchBeforeInputEvents(RefPtr<Element> startRoot, RefPtr<Element> endRoot, const AtomicString& inputTypeName) |
| 1029 |
{ |
1043 |
{ |
| 1030 |
RefPtr<Element> startRoot = prpStartRoot; |
1044 |
bool continueWithDefaultBehavior = true; |
| 1031 |
RefPtr<Element> endRoot = prpEndRoot; |
|
|
| 1032 |
if (startRoot) |
1045 |
if (startRoot) |
| 1033 |
startRoot->dispatchEvent(Event::create(eventNames().webkitEditableContentChangedEvent, false, false)); |
1046 |
continueWithDefaultBehavior &= dispatchBeforeInputEvent(*startRoot, inputTypeName); |
| 1034 |
if (endRoot && endRoot != startRoot) |
1047 |
if (endRoot && endRoot != startRoot) |
| 1035 |
endRoot->dispatchEvent(Event::create(eventNames().webkitEditableContentChangedEvent, false, false)); |
1048 |
continueWithDefaultBehavior &= dispatchBeforeInputEvent(*endRoot, inputTypeName); |
|
|
1049 |
return continueWithDefaultBehavior; |
| 1050 |
} |
| 1051 |
|
| 1052 |
static void dispatchInputEvents(RefPtr<Element> startRoot, RefPtr<Element> endRoot, const AtomicString& inputTypeName) |
| 1053 |
{ |
| 1054 |
if (startRoot) |
| 1055 |
startRoot->dispatchInputEvent(inputTypeName); |
| 1056 |
if (endRoot && endRoot != startRoot) |
| 1057 |
endRoot->dispatchInputEvent(inputTypeName); |
| 1058 |
} |
| 1059 |
|
| 1060 |
bool Editor::willApplyEditing(CompositeEditCommand& command) const |
| 1061 |
{ |
| 1062 |
auto* composition = command.composition(); |
| 1063 |
if (!composition) |
| 1064 |
return true; |
| 1065 |
|
| 1066 |
return dispatchBeforeInputEvents(composition->startingRootEditableElement(), composition->endingRootEditableElement(), emptyString()); |
| 1036 |
} |
1067 |
} |
| 1037 |
|
1068 |
|
| 1038 |
void Editor::appliedEditing(PassRefPtr<CompositeEditCommand> cmd) |
1069 |
void Editor::appliedEditing(PassRefPtr<CompositeEditCommand> cmd) |
|
Lines 1051-1057
void Editor::appliedEditing(PassRefPtr<CompositeEditCommand> cmd)
a/Source/WebCore/editing/Editor.cpp_sec4
|
| 1051 |
FrameSelection::SetSelectionOptions options = cmd->isDictationCommand() ? FrameSelection::DictationTriggered : 0; |
1082 |
FrameSelection::SetSelectionOptions options = cmd->isDictationCommand() ? FrameSelection::DictationTriggered : 0; |
| 1052 |
|
1083 |
|
| 1053 |
changeSelectionAfterCommand(newSelection, options); |
1084 |
changeSelectionAfterCommand(newSelection, options); |
| 1054 |
dispatchEditableContentChangedEvents(composition->startingRootEditableElement(), composition->endingRootEditableElement()); |
1085 |
dispatchInputEvents(composition->startingRootEditableElement(), composition->endingRootEditableElement(), emptyString()); |
| 1055 |
|
1086 |
|
| 1056 |
updateEditorUINowIfScheduled(); |
1087 |
updateEditorUINowIfScheduled(); |
| 1057 |
|
1088 |
|
|
Lines 1074-1079
void Editor::appliedEditing(PassRefPtr<CompositeEditCommand> cmd)
a/Source/WebCore/editing/Editor.cpp_sec5
|
| 1074 |
respondToChangedContents(newSelection); |
1105 |
respondToChangedContents(newSelection); |
| 1075 |
} |
1106 |
} |
| 1076 |
|
1107 |
|
|
|
1108 |
bool Editor::willUnapplyEditing(const EditCommandComposition& composition) const |
| 1109 |
{ |
| 1110 |
return dispatchBeforeInputEvents(composition.startingRootEditableElement(), composition.endingRootEditableElement(), emptyString()); |
| 1111 |
} |
| 1112 |
|
| 1077 |
void Editor::unappliedEditing(PassRefPtr<EditCommandComposition> cmd) |
1113 |
void Editor::unappliedEditing(PassRefPtr<EditCommandComposition> cmd) |
| 1078 |
{ |
1114 |
{ |
| 1079 |
document().updateLayout(); |
1115 |
document().updateLayout(); |
|
Lines 1082-1088
void Editor::unappliedEditing(PassRefPtr<EditCommandComposition> cmd)
a/Source/WebCore/editing/Editor.cpp_sec6
|
| 1082 |
|
1118 |
|
| 1083 |
VisibleSelection newSelection(cmd->startingSelection()); |
1119 |
VisibleSelection newSelection(cmd->startingSelection()); |
| 1084 |
changeSelectionAfterCommand(newSelection, FrameSelection::defaultSetSelectionOptions()); |
1120 |
changeSelectionAfterCommand(newSelection, FrameSelection::defaultSetSelectionOptions()); |
| 1085 |
dispatchEditableContentChangedEvents(cmd->startingRootEditableElement(), cmd->endingRootEditableElement()); |
1121 |
dispatchInputEvents(cmd->startingRootEditableElement(), cmd->endingRootEditableElement(), emptyString()); |
| 1086 |
|
1122 |
|
| 1087 |
updateEditorUINowIfScheduled(); |
1123 |
updateEditorUINowIfScheduled(); |
| 1088 |
|
1124 |
|
|
Lines 1094-1099
void Editor::unappliedEditing(PassRefPtr<EditCommandComposition> cmd)
a/Source/WebCore/editing/Editor.cpp_sec7
|
| 1094 |
respondToChangedContents(newSelection); |
1130 |
respondToChangedContents(newSelection); |
| 1095 |
} |
1131 |
} |
| 1096 |
|
1132 |
|
|
|
1133 |
bool Editor::willReapplyEditing(const EditCommandComposition& composition) const |
| 1134 |
{ |
| 1135 |
return dispatchBeforeInputEvents(composition.startingRootEditableElement(), composition.endingRootEditableElement(), emptyString()); |
| 1136 |
} |
| 1137 |
|
| 1097 |
void Editor::reappliedEditing(PassRefPtr<EditCommandComposition> cmd) |
1138 |
void Editor::reappliedEditing(PassRefPtr<EditCommandComposition> cmd) |
| 1098 |
{ |
1139 |
{ |
| 1099 |
document().updateLayout(); |
1140 |
document().updateLayout(); |
|
Lines 1102-1108
void Editor::reappliedEditing(PassRefPtr<EditCommandComposition> cmd)
a/Source/WebCore/editing/Editor.cpp_sec8
|
| 1102 |
|
1143 |
|
| 1103 |
VisibleSelection newSelection(cmd->endingSelection()); |
1144 |
VisibleSelection newSelection(cmd->endingSelection()); |
| 1104 |
changeSelectionAfterCommand(newSelection, FrameSelection::defaultSetSelectionOptions()); |
1145 |
changeSelectionAfterCommand(newSelection, FrameSelection::defaultSetSelectionOptions()); |
| 1105 |
dispatchEditableContentChangedEvents(cmd->startingRootEditableElement(), cmd->endingRootEditableElement()); |
1146 |
dispatchInputEvents(cmd->startingRootEditableElement(), cmd->endingRootEditableElement(), emptyString()); |
| 1106 |
|
1147 |
|
| 1107 |
updateEditorUINowIfScheduled(); |
1148 |
updateEditorUINowIfScheduled(); |
| 1108 |
|
1149 |
|
|
Lines 3052-3057
void Editor::computeAndSetTypingStyle(EditingStyle& style, EditAction editingAct
a/Source/WebCore/editing/Editor.cpp_sec9
|
| 3052 |
return; |
3093 |
return; |
| 3053 |
} |
3094 |
} |
| 3054 |
|
3095 |
|
|
|
3096 |
auto* element = m_frame.selection().selection().rootEditableElement(); |
| 3097 |
if (element && !dispatchBeforeInputEvent(*element, emptyString())) |
| 3098 |
return; |
| 3099 |
|
| 3055 |
// Calculate the current typing style. |
3100 |
// Calculate the current typing style. |
| 3056 |
RefPtr<EditingStyle> typingStyle; |
3101 |
RefPtr<EditingStyle> typingStyle; |
| 3057 |
if (auto existingTypingStyle = m_frame.selection().typingStyle()) |
3102 |
if (auto existingTypingStyle = m_frame.selection().typingStyle()) |
|
Lines 3065-3070
void Editor::computeAndSetTypingStyle(EditingStyle& style, EditAction editingAct
a/Source/WebCore/editing/Editor.cpp_sec10
|
| 3065 |
if (!blockStyle->isEmpty()) |
3110 |
if (!blockStyle->isEmpty()) |
| 3066 |
applyCommand(ApplyStyleCommand::create(document(), blockStyle.get(), editingAction)); |
3111 |
applyCommand(ApplyStyleCommand::create(document(), blockStyle.get(), editingAction)); |
| 3067 |
|
3112 |
|
|
|
3113 |
if (element) |
| 3114 |
element->dispatchInputEvent(emptyString()); |
| 3115 |
|
| 3068 |
// Set the remaining style as the typing style. |
3116 |
// Set the remaining style as the typing style. |
| 3069 |
m_frame.selection().setTypingStyle(typingStyle); |
3117 |
m_frame.selection().setTypingStyle(typingStyle); |
| 3070 |
} |
3118 |
} |