+2007-12-14 Darin Adler <darin@apple.com>
+
+ Reviewed by Alexey.
+
+ - http://bugs.webkit.org/show_bug.cgi?id=16420
+ change regression tests to use document.execCommand instead of textInputController.doCommand
+
+ To avoid changing results at this time, I didn't correct the many tests that now have
+ misleading "this test cannot be run manually" text or references to "NSResponder" or
+ uneeded instructions for running the test manually. We can do that on a later pass.
+
+ * editing/deleting/5300379.html: Use execCommand instead of doCommand.
+ * editing/deleting/delete-to-end-of-paragraph.html: Ditto.
+ * editing/deleting/smart-delete-003.html: Ditto.
+ * editing/deleting/smart-delete-004.html: Ditto.
+ * editing/execCommand/nsresponder-indent.html: Ditto.
+ * editing/execCommand/nsresponder-outdent.html: Ditto.
+ * editing/selection/4947387.html: Ditto.
+ * editing/selection/5195166-1.html: Ditto.
+ * editing/selection/5195166-2.html: Ditto.
+ * editing/selection/select-line.html: Ditto.
+ * editing/selection/selection-actions.html: Ditto.
+
2007-12-14 Justin Garcia <justin.garcia@apple.com>
Reviewed by Darin Adler.
div = document.getElementById("div");
sel = window.getSelection();
sel.setPosition(div, 0);
-if (window.layoutTestController) {
- // Test to see if deleteWordBackward: hangs.
- textInputController.doCommand("deleteWordBackward:");
- document.execCommand("InsertText", false, "Success FAIL");
- // Delete 'FAIL' with deleteWordBackward: to verify that it's not a no-op.
- textInputController.doCommand("deleteWordBackward:");
- textInputController.doCommand("deleteBackward:");
-} else {
- document.execCommand("InsertText", false, "To run this test manually. Delete all this text and then option-delete. Safari shouldn't hang.");
-}
+// Test to see if DeleteWordBackward hangs.
+document.execCommand("DeleteWordBackward");
+document.execCommand("InsertText", false, "Success FAIL");
+// Delete 'FAIL' with DeleteWordBackward to verify that it's not a no-op.
+document.execCommand("DeleteWordBackward");
+document.execCommand("DeleteBackward");
</script>
<script>
function editingTest() {
- if (window.layoutTestController) {
-
- try {
- // test for 4570218 by using double deleteToEndOfParagraph
- textInputController.doCommand("deleteToEndOfParagraph:");
- textInputController.doCommand("deleteToEndOfParagraph:");
+ try {
+ // test for 4570218 by using double deleteToEndOfParagraph
+ document.execCommand("DeleteToEndOfParagraph");
+ document.execCommand("DeleteToEndOfParagraph");
- } catch (ex) {
- document.write("Exception: " + ex.description);
- }
- } else {
- document.write("(cannot run interactively)");
+ } catch (ex) {
+ document.write("Exception: " + ex.description);
}
}
<div id="div" contenteditable="true">foo bar baz</div>
<script>
-if (window.layoutTestController) {
- var div = document.getElementById("div");
- var sel = window.getSelection();
-
- sel.setPosition(div, 0);
- sel.modify("move", "forward", "word");
- sel.modify("move", "forward", "word");
- sel.modify("extend", "backward", "word");
- textInputController.doCommand("deleteBackward:");
-}
+var div = document.getElementById("div");
+var sel = window.getSelection();
+
+sel.setPosition(div, 0);
+sel.modify("move", "forward", "word");
+sel.modify("move", "forward", "word");
+sel.modify("extend", "backward", "word");
+document.execCommand("DeleteBackward");
</script>
<div id="div" contenteditable="true">foo bar baz</div>
<script>
-if (window.layoutTestController) {
- var div = document.getElementById("div");
- var sel = window.getSelection();
-
- sel.setPosition(div, 0);
- sel.modify("move", "forward", "word");
- sel.modify("move", "forward", "word");
- sel.modify("extend", "backward", "word");
- textInputController.doCommand("deleteForward:");
-}
+var div = document.getElementById("div");
+var sel = window.getSelection();
+
+sel.setPosition(div, 0);
+sel.modify("move", "forward", "word");
+sel.modify("move", "forward", "word");
+sel.modify("extend", "backward", "word");
+document.execCommand("DeleteForward");
</script>
sel.setPosition(div, 0);
-textInputController.doCommand("indent:");
+document.execCommand("Indent");
</script>
sel.setPosition(div, 0);
-textInputController.doCommand("outdent:");
+document.execCommand("Outdent");
</script>
<script>
-if (window.layoutTestController) {
-
+if (window.layoutTestController)
window.layoutTestController.dumpEditingCallbacks();
- var div = document.getElementById("div");
- var text = div.firstChild;
- var sel = window.getSelection();
-
- sel.setPosition(text, text.length);
- textInputController.doCommand("moveToBeginningOfLineAndModifySelection:");
-
- sel.setPosition(text, 0);
- textInputController.doCommand("moveToEndOfLineAndModifySelection:");
+var div = document.getElementById("div");
+var text = div.firstChild;
+var sel = window.getSelection();
+
+sel.setPosition(text, text.length);
+document.execCommand("MoveToBeginningOfLineAndModifySelection");
+
+sel.setPosition(text, 0);
+document.execCommand("MoveToEndOfLineAndModifySelection");
+
+sel.setPosition(text, text.length);
+document.execCommand("MoveToBeginningOfParagraphAndModifySelection");
+
+sel.setPosition(text, 0);
+document.execCommand("MoveToEndOfParagraphAndModifySelection");
- sel.setPosition(text, text.length);
- textInputController.doCommand("moveToBeginningOfParagraphAndModifySelection:");
-
- sel.setPosition(text, 0);
- textInputController.doCommand("moveToEndOfParagraphAndModifySelection:");
-}
</script>
console.appendChild(li);
li.appendChild(text);
}
-if (window.layoutTestController) {
- var text = document.getElementById("div").firstChild;
- var selection = window.getSelection();
-
- // FIXME: m_lastChangeWasHorizontalExtension isn't cleared in several places
- // where it should be, when opening a new document for example.
- selection.setPosition(text, 0);
- selection.modify("move", "forward", "character");
-
- selection.setBaseAndExtent(text, 3 + 5, text, 3);
- // Extending this 5 character selection will select 6 characters.
- textInputController.doCommand("moveForwardAndModifySelection:");
- // Extending it in this way flips the base and the extent.
- if (selection.extentOffset - selection.baseOffset != 6)
- log("Failure: Selection isn't the right size.");
- else
- log ("Success");
-} else
- log ("Failure: This test cannot be run manually.")
+var text = document.getElementById("div").firstChild;
+var selection = window.getSelection();
+
+// FIXME: m_lastChangeWasHorizontalExtension isn't cleared in several places
+// where it should be, when opening a new document for example.
+selection.setPosition(text, 0);
+selection.modify("move", "forward", "character");
+
+selection.setBaseAndExtent(text, 3 + 5, text, 3);
+// Extending this 5 character selection will select 6 characters.
+document.execCommand("MoveForwardAndModifySelection");
+// Extending it in this way flips the base and the extent.
+if (selection.extentOffset - selection.baseOffset != 6)
+ log("Failure: Selection isn't the right size.");
+else
+ log ("Success");
</script>
console.appendChild(li);
li.appendChild(text);
}
-if (window.layoutTestController) {
+if (window.layoutTestController)
window.layoutTestController.dumpEditingCallbacks();
- var text = document.getElementById("div").firstChild;
- var selection = window.getSelection();
- selection.setBaseAndExtent(text, 0, text, 0);
- textInputController.doCommand("moveForwardAndModifySelection:");
- textInputController.doCommand("moveForwardAndModifySelection:");
- textInputController.doCommand("moveForwardAndModifySelection:");
- textInputController.doCommand("moveBackwardAndModifySelection:");
-} else {
- log("Failure: This test cannot be run manually.")
-}
-
+var text = document.getElementById("div").firstChild;
+var selection = window.getSelection();
+selection.setBaseAndExtent(text, 0, text, 0);
+document.execCommand("MoveForwardAndModifySelection");
+document.execCommand("MoveForwardAndModifySelection");
+document.execCommand("MoveForwardAndModifySelection");
+document.execCommand("MoveBackwardAndModifySelection");
</script>
var sel = window.getSelection();
sel.setPosition(div, 0);
-if (window.layoutTestController)
- textInputController.doCommand("selectLine:");
+document.execCommand("SelectLine");
</script>
eventSender.mouseMoveTo(x, y);
eventSender.mouseUp();
- textInputController.doCommand("moveBackward:");
- textInputController.doCommand("moveBackwardAndModifySelection:");
- textInputController.doCommand("moveDown:");
- textInputController.doCommand("moveDownAndModifySelection:");
- textInputController.doCommand("moveForward:");
- textInputController.doCommand("moveForwardAndModifySelection:");
- textInputController.doCommand("moveLeft:");
- textInputController.doCommand("moveLeftAndModifySelection:");
- textInputController.doCommand("moveRight:");
- textInputController.doCommand("moveRightAndModifySelection:");
- textInputController.doCommand("moveToBeginningOfDocument:");
- textInputController.doCommand("moveToBeginningOfLine:");
- textInputController.doCommand("moveToBeginningOfParagraph:");
- textInputController.doCommand("moveToEndOfDocument:");
- textInputController.doCommand("moveToEndOfLine:");
- textInputController.doCommand("moveToEndOfParagraph:");
- textInputController.doCommand("moveUp:");
- textInputController.doCommand("moveUpAndModifySelection:");
- textInputController.doCommand("moveWordBackward:");
- textInputController.doCommand("moveWordBackwardAndModifySelection:");
- textInputController.doCommand("moveWordForward:");
- textInputController.doCommand("moveWordForwardAndModifySelection:");
- textInputController.doCommand("moveWordLeft:");
- textInputController.doCommand("moveWordRight:");
- textInputController.doCommand("moveWordRightAndModifySelection:");
- textInputController.doCommand("moveWordLeftAndModifySelection:");
- textInputController.doCommand("pageDown:");
- textInputController.doCommand("pageUp:");
- textInputController.doCommand("selectLine:");
- textInputController.doCommand("selectParagraph:");
- textInputController.doCommand("selectWord:");
+ document.execCommand("MoveBackward");
+ document.execCommand("MoveBackwardAndModifySelection");
+ document.execCommand("MoveDown");
+ document.execCommand("MoveDownAndModifySelection");
+ document.execCommand("MoveForward");
+ document.execCommand("MoveForwardAndModifySelection");
+ document.execCommand("MoveLeft");
+ document.execCommand("MoveLeftAndModifySelection");
+ document.execCommand("MoveRight");
+ document.execCommand("MoveRightAndModifySelection");
+ document.execCommand("MoveToBeginningOfDocument");
+ document.execCommand("MoveToBeginningOfLine");
+ document.execCommand("MoveToBeginningOfParagraph");
+ document.execCommand("MoveToEndOfDocument");
+ document.execCommand("MoveToEndOfLine");
+ document.execCommand("MoveToEndOfParagraph");
+ document.execCommand("MoveUp");
+ document.execCommand("MoveUpAndModifySelection");
+ document.execCommand("MoveWordBackward");
+ document.execCommand("MoveWordBackwardAndModifySelection");
+ document.execCommand("MoveWordForward");
+ document.execCommand("MoveWordForwardAndModifySelection");
+ document.execCommand("MoveWordLeft");
+ document.execCommand("MoveWordRight");
+ document.execCommand("MoveWordRightAndModifySelection");
+ document.execCommand("MoveWordLeftAndModifySelection");
+ document.execCommand("MovePageDown");
+ document.execCommand("MovePageUp");
+ document.execCommand("SelectLine");
+ document.execCommand("SelectParagraph");
+ document.execCommand("SelectWord");
}
</script>
+2007-12-14 Darin Adler <darin@apple.com>
+
+ Reviewed by Alexey.
+
+ - http://bugs.webkit.org/show_bug.cgi?id=16420
+ change regression tests to use document.execCommand instead of textInputController.doCommand
+
+ Add a few more operations to document.execCommand.
+
+ Finished up the transition to the new Editor::Command, including removing
+ the Editor::execCommand function.
+
+ * WebCore.base.exp: Added Editor::Command::isSupported.
+ * editing/Editor.h: Removed execCommand.
+ * editing/EditorCommand.cpp:
+ (WebCore::expandSelectionToGranularity): Added.
+ (WebCore::verticalScrollDistance): Added; replaces canScroll.
+ (WebCore::executeDeleteBackward): Added. Moved code here from WebHTMLView.
+ (WebCore::executeDeleteBackwardByDecomposingPreviousCharacter): Ditto.
+ (WebCore::executeDeleteForward): Ditto.
+ (WebCore::executeDeleteToBeginningOfLine): Ditto.
+ (WebCore::executeDeleteToBeginningOfParagraph): Ditto.
+ (WebCore::executeDeleteToEndOfLine): Ditto.
+ (WebCore::executeDeleteToEndOfParagraph): Ditto.
+ (WebCore::executeMovePageDown): Renamed this command to be consistent with all the other
+ Move commands. They all modify the caret. Reimplemented to match the Mac OS X version by
+ removing the explicit scrolling, and letting it be done automatically by code that makes
+ the caret visible. In some cases the old code would scroll twice which was harmless but
+ unnecessary.
+ (WebCore::executeMovePageDownAndModifySelection): Added. Moved code here from WebHTMLView.
+ (WebCore::executeMovePageUp): See MovePageDown above.
+ (WebCore::executeMovePageUpAndModifySelection): Added. Moved code here from WebHTMLView.
+ (WebCore::executeSelectLine): Ditto.
+ (WebCore::executeSelectParagraph): Ditto.
+ (WebCore::executeSelectSentence): Ditto.
+ (WebCore::executeSelectWord): Ditto.
+ (WebCore::executeSwapWithMark): Some small tweaks.
+
+ * page/ContextMenuController.cpp:
+ (WebCore::ContextMenuController::contextMenuItemSelected): Changed to use Editor::command()
+ instead of Editor::execCommand(). This code could be changed to use Editor::Command quite a
+ bit more, but I didn't do that this time.
+
+ - Removed some obsolete unused code.
+
+ * page/mac/EventHandlerMac.mm:
+ (WebCore::EventHandler::passMouseDownEventToWidget): Removed the special case code for
+ NSTextView. This was left over from when we used NSTextField and NSTextView for form
+ elements and is no longer used at all.
+
+ * page/mac/WebCoreFrameBridge.h: Removed 20 unused methods that were still on one side
+ of the bridge or another. We really need to find a time to tear down the rest of the
+ bridge, but that's not this patch.
+
+ * page/mac/WebCoreFrameBridge.mm:
+ (-[WebCoreFrameBridge addData:]): Changed to get at the _shouldCreateRenderers field directly
+ instead of using a method.
+ (-[WebCoreFrameBridge rangeByAlteringCurrentSelection:SelectionController::direction:SelectionController::granularity:]):
+ Took out obsolete comment about matching enums (we use a single enum now and have for some
+ time).
+ (-[WebCoreFrameBridge selectionGranularity]): Ditto.
+
2007-12-14 Justin Garcia <justin.garcia@apple.com>
Reviewed by Darin Adler.
__ZNK7WebCore6Editor22selectionStartHasStyleEPNS_19CSSStyleDeclarationE
__ZNK7WebCore6Editor23getCompositionSelectionERjS1_
__ZNK7WebCore6Editor6canCutEv
+__ZNK7WebCore6Editor7Command11isSupportedEv
__ZNK7WebCore6Editor7Command15isTextInsertionEv
__ZNK7WebCore6Editor7Command5stateEPNS_5EventE
__ZNK7WebCore6Editor7Command7executeEPNS_5EventE
Command command(const String& commandName); // Default is CommandFromMenuOrKeyBinding.
Command command(const String& commandName, EditorCommandSource);
- // Deprecated, but used by old key binding code. Keep around until we have eliminated all callers.
- bool execCommand(const AtomicString& commandName, Event* triggeringEvent = 0);
-
bool insertText(const String&, Event* triggeringEvent);
bool insertTextWithoutSendingTextEvent(const String&, bool selectInsertedText, Event* triggeringEvent = 0);
bool insertLineBreak();
#include "CreateLinkCommand.h"
#include "DocumentFragment.h"
#include "Editor.h"
+#include "EditorClient.h"
#include "Event.h"
#include "EventHandler.h"
#include "FormatBlockCommand.h"
return executeInsertFragment(frame, fragment.release());
}
+static bool expandSelectionToGranularity(Frame* frame, TextGranularity granularity)
+{
+ Selection selection = frame->selectionController()->selection();
+ selection.expandUsingGranularity(granularity);
+ RefPtr<Range> newRange = selection.toRange();
+ if (!newRange)
+ return false;
+ ExceptionCode ec = 0;
+ if (newRange->collapsed(ec))
+ return false;
+ RefPtr<Range> oldRange = frame->selectionController()->selection().toRange();
+ EAffinity affinity = frame->selectionController()->affinity();
+ if (!frame->editor()->client()->shouldChangeSelectedRange(oldRange.get(), newRange.get(), affinity, false))
+ return false;
+ frame->selectionController()->setSelectedRange(newRange.get(), affinity, true);
+ return true;
+}
+
static TriState stateStyle(Frame* frame, int propertyID, const char* desiredValue)
{
RefPtr<CSSMutableStyleDeclaration> style = new CSSMutableStyleDeclaration;
return frame->selectionStartStylePropertyValue(propertyID);
}
-static bool canScroll(RenderObject* renderer)
+static int verticalScrollDistance(Frame* frame)
{
+ Node* focusedNode = frame->document()->focusedNode();
+ if (!focusedNode)
+ return 0;
+ RenderObject* renderer = focusedNode->renderer();
if (!renderer)
- return false;
+ return 0;
RenderStyle* style = renderer->style();
if (!style)
- return false;
- return style->overflowY() == OSCROLL || style->overflowY() == OAUTO || renderer->isTextArea();
+ return 0;
+ if (!(style->overflowY() == OSCROLL || style->overflowY() == OAUTO || renderer->isTextArea()))
+ return 0;
+ int height = renderer->clientHeight();
+ return max((height + 1) / 2, height - PAGE_KEEP);
}
static RefPtr<Range> unionDOMRanges(Range* a, Range* b)
return false;
}
+static bool executeDeleteBackward(Frame* frame, Event*, EditorCommandSource, const String&)
+{
+ frame->editor()->deleteWithDirection(SelectionController::BACKWARD, CharacterGranularity, false, true);
+ return true;
+}
+
+static bool executeDeleteBackwardByDecomposingPreviousCharacter(Frame* frame, Event*, EditorCommandSource, const String&)
+{
+ LOG_ERROR("DeleteBackwardByDecomposingPreviousCharacter is not implemented, doing DeleteBackward instead");
+ frame->editor()->deleteWithDirection(SelectionController::BACKWARD, CharacterGranularity, false, true);
+ return true;
+}
+
+static bool executeDeleteForward(Frame* frame, Event*, EditorCommandSource source, const String&)
+{
+ frame->editor()->deleteWithDirection(SelectionController::FORWARD, CharacterGranularity, false, true);
+ return true;
+}
+
+static bool executeDeleteToBeginningOfLine(Frame* frame, Event*, EditorCommandSource, const String&)
+{
+ frame->editor()->deleteWithDirection(SelectionController::BACKWARD, LineBoundary, true, false);
+ return true;
+}
+
+static bool executeDeleteToBeginningOfParagraph(Frame* frame, Event*, EditorCommandSource, const String&)
+{
+ frame->editor()->deleteWithDirection(SelectionController::BACKWARD, ParagraphBoundary, true, false);
+ return true;
+}
+
+static bool executeDeleteToEndOfLine(Frame* frame, Event*, EditorCommandSource, const String&)
+{
+ // Despite its name, this command should delete the newline at the end of
+ // a paragraph if you are at the end of a paragraph (like DeleteToEndOfParagraph).
+ frame->editor()->deleteWithDirection(SelectionController::FORWARD, LineBoundary, true, false);
+ return true;
+}
+
+static bool executeDeleteToEndOfParagraph(Frame* frame, Event*, EditorCommandSource, const String&)
+{
+ // Despite its name, this command should delete the newline at the end of
+ // a paragraph if you are at the end of a paragraph.
+ frame->editor()->deleteWithDirection(SelectionController::FORWARD, ParagraphBoundary, true, false);
+ return true;
+}
+
static bool executeDeleteToMark(Frame* frame, Event*, EditorCommandSource, const String&)
{
RefPtr<Range> mark = frame->mark().toRange();
return true;
}
-static bool executeMoveDownByPageAndModifyCaret(Frame* frame, Event*, EditorCommandSource, const String&)
-{
- Node* focusedNode = frame->document()->focusedNode();
- if (!focusedNode)
- return false;
- RenderObject* renderer = focusedNode->renderer();
- if (!canScroll(renderer))
- return false;
- bool handledScroll = renderer->scroll(ScrollDown, ScrollByPage);
- bool handledCaretMove = frame->selectionController()->modify(SelectionController::MOVE, renderer->clientHeight() - PAGE_KEEP);
- return handledScroll || handledCaretMove;
-}
-
static bool executeMoveForward(Frame* frame, Event*, EditorCommandSource, const String&)
{
frame->selectionController()->modify(SelectionController::MOVE, SelectionController::FORWARD, CharacterGranularity, true);
return true;
}
+static bool executeMovePageDown(Frame* frame, Event*, EditorCommandSource, const String&)
+{
+ int distance = verticalScrollDistance(frame);
+ if (!distance)
+ return false;
+ return frame->selectionController()->modify(SelectionController::MOVE, distance, true);
+}
+
+static bool executeMovePageDownAndModifySelection(Frame* frame, Event*, EditorCommandSource, const String&)
+{
+ int distance = verticalScrollDistance(frame);
+ if (!distance)
+ return false;
+ return frame->selectionController()->modify(SelectionController::EXTEND, distance, true);
+}
+
+static bool executeMovePageUp(Frame* frame, Event*, EditorCommandSource, const String&)
+{
+ int distance = verticalScrollDistance(frame);
+ if (!distance)
+ return false;
+ return frame->selectionController()->modify(SelectionController::MOVE, -distance, true);
+}
+
+static bool executeMovePageUpAndModifySelection(Frame* frame, Event*, EditorCommandSource, const String&)
+{
+ int distance = verticalScrollDistance(frame);
+ if (!distance)
+ return false;
+ return frame->selectionController()->modify(SelectionController::EXTEND, -distance, true);
+}
+
static bool executeMoveRight(Frame* frame, Event*, EditorCommandSource, const String&)
{
frame->selectionController()->modify(SelectionController::MOVE, SelectionController::RIGHT, CharacterGranularity, true);
return true;
}
-static bool executeMoveUpByPageAndModifyCaret(Frame* frame, Event*, EditorCommandSource, const String&)
-{
- Node* focusedNode = frame->document()->focusedNode();
- if (!focusedNode)
- return false;
- RenderObject* renderer = focusedNode->renderer();
- if (!canScroll(renderer))
- return false;
- bool handledScroll = renderer->scroll(ScrollDown, ScrollByPage);
- bool handledCaretMove = frame->selectionController()->modify(SelectionController::MOVE, -(renderer->clientHeight() - PAGE_KEEP));
- return handledScroll || handledCaretMove;
-}
-
static bool executeMoveWordBackward(Frame* frame, Event*, EditorCommandSource, const String&)
{
frame->selectionController()->modify(SelectionController::MOVE, SelectionController::BACKWARD, WordGranularity, true);
return true;
}
+static bool executeSelectLine(Frame* frame, Event*, EditorCommandSource, const String&)
+{
+ return expandSelectionToGranularity(frame, LineGranularity);
+}
+
+static bool executeSelectParagraph(Frame* frame, Event*, EditorCommandSource, const String&)
+{
+ return expandSelectionToGranularity(frame, ParagraphGranularity);
+}
+
+static bool executeSelectSentence(Frame* frame, Event*, EditorCommandSource, const String&)
+{
+ return expandSelectionToGranularity(frame, SentenceGranularity);
+}
+
static bool executeSelectToMark(Frame* frame, Event*, EditorCommandSource, const String&)
{
RefPtr<Range> mark = frame->mark().toRange();
return true;
}
+static bool executeSelectWord(Frame* frame, Event*, EditorCommandSource, const String&)
+{
+ return expandSelectionToGranularity(frame, WordGranularity);
+}
+
static bool executeSetMark(Frame* frame, Event*, EditorCommandSource, const String&)
{
frame->setMark(frame->selectionController()->selection());
static bool executeSwapWithMark(Frame* frame, Event*, EditorCommandSource, const String&)
{
const Selection& mark = frame->mark();
- Selection selection = frame->selectionController()->selection();
+ const Selection& selection = frame->selectionController()->selection();
if (mark.isNone() || selection.isNone()) {
systemBeep();
return false;
}
-
frame->selectionController()->setSelection(mark);
frame->setMark(selection);
return true;
{ "CreateLink", { executeCreateLink, supported, enabledInRichlyEditableText, stateNone, valueNull, notTextInsertion } },
{ "Cut", { executeCut, supported, enabledCut, stateNone, valueNull, notTextInsertion } },
{ "Delete", { executeDelete, supported, enabledInEditableText, stateNone, valueNull, notTextInsertion } },
+ { "DeleteBackward", { executeDeleteBackward, supported, enabledInEditableText, stateNone, valueNull, notTextInsertion } },
+ { "DeleteBackwardByDecomposingPreviousCharacter", { executeDeleteBackwardByDecomposingPreviousCharacter, supported, enabledInEditableText, stateNone, valueNull, notTextInsertion } },
+ { "DeleteForward", { executeDeleteForward, supported, enabledInEditableText, stateNone, valueNull, notTextInsertion } },
+ { "DeleteToBeginningOfLine", { executeDeleteToBeginningOfLine, supported, enabledInEditableText, stateNone, valueNull, notTextInsertion } },
+ { "DeleteToBeginningOfParagraph", { executeDeleteToBeginningOfParagraph, supported, enabledInEditableText, stateNone, valueNull, notTextInsertion } },
+ { "DeleteToEndOfLine", { executeDeleteToEndOfLine, supported, enabledInEditableText, stateNone, valueNull, notTextInsertion } },
+ { "DeleteToEndOfParagraph", { executeDeleteToEndOfParagraph, supported, enabledInEditableText, stateNone, valueNull, notTextInsertion } },
{ "DeleteToMark", { executeDeleteToMark, supported, enabledInEditableText, stateNone, valueNull, notTextInsertion } },
{ "DeleteWordBackward", { executeDeleteWordBackward, supported, enabledInEditableText, stateNone, valueNull, notTextInsertion } },
{ "DeleteWordForward", { executeDeleteWordForward, supported, enabledInEditableText, stateNone, valueNull, notTextInsertion } },
{ "MoveBackwardAndModifySelection", { executeMoveBackwardAndModifySelection, supported, enabledInEditableText, stateNone, valueNull, notTextInsertion } },
{ "MoveDown", { executeMoveDown, supported, enabledInEditableText, stateNone, valueNull, notTextInsertion } },
{ "MoveDownAndModifySelection", { executeMoveDownAndModifySelection, supported, enabledInEditableText, stateNone, valueNull, notTextInsertion } },
- { "MoveDownByPageAndModifyCaret", { executeMoveDownByPageAndModifyCaret, supported, enabledInEditableText, stateNone, valueNull, notTextInsertion } },
{ "MoveForward", { executeMoveForward, supported, enabledInEditableText, stateNone, valueNull, notTextInsertion } },
{ "MoveForwardAndModifySelection", { executeMoveForwardAndModifySelection, supported, enabledInEditableText, stateNone, valueNull, notTextInsertion } },
{ "MoveLeft", { executeMoveLeft, supported, enabledInEditableText, stateNone, valueNull, notTextInsertion } },
{ "MoveLeftAndModifySelection", { executeMoveLeftAndModifySelection, supported, enabledInEditableText, stateNone, valueNull, notTextInsertion } },
+ { "MovePageDown", { executeMovePageDown, supported, enabledInEditableText, stateNone, valueNull, notTextInsertion } },
+ { "MovePageDownAndModifySelection", { executeMovePageDownAndModifySelection, supported, enabledInEditableText, stateNone, valueNull, notTextInsertion } },
+ { "MovePageUp", { executeMovePageUp, supported, enabledInEditableText, stateNone, valueNull, notTextInsertion } },
+ { "MovePageUpAndModifySelection", { executeMovePageUpAndModifySelection, supported, enabledInEditableText, stateNone, valueNull, notTextInsertion } },
{ "MoveParagraphBackwardAndModifySelection", { executeMoveParagraphBackwardAndModifySelection, supported, enabledInEditableText, stateNone, valueNull, notTextInsertion } },
{ "MoveParagraphForwardAndModifySelection", { executeMoveParagraphForwardAndModifySelection, supported, enabledInEditableText, stateNone, valueNull, notTextInsertion } },
{ "MoveRight", { executeMoveRight, supported, enabledInEditableText, stateNone, valueNull, notTextInsertion } },
{ "MoveToEndOfSentenceAndModifySelection", { executeMoveToEndOfSentenceAndModifySelection, supported, enabledInEditableText, stateNone, valueNull, notTextInsertion } },
{ "MoveUp", { executeMoveUp, supported, enabledInEditableText, stateNone, valueNull, notTextInsertion } },
{ "MoveUpAndModifySelection", { executeMoveUpAndModifySelection, supported, enabledInEditableText, stateNone, valueNull, notTextInsertion } },
- { "MoveUpByPageAndModifyCaret", { executeMoveUpByPageAndModifyCaret, supported, enabledInEditableText, stateNone, valueNull, notTextInsertion } },
{ "MoveWordBackward", { executeMoveWordBackward, supported, enabledInEditableText, stateNone, valueNull, notTextInsertion } },
{ "MoveWordBackwardAndModifySelection", { executeMoveWordBackwardAndModifySelection, supported, enabledInEditableText, stateNone, valueNull, notTextInsertion } },
{ "MoveWordForward", { executeMoveWordForward, supported, enabledInEditableText, stateNone, valueNull, notTextInsertion } },
{ "Redo", { executeRedo, supported, enabledRedo, stateNone, valueNull, notTextInsertion } },
{ "RemoveFormat", { executeRemoveFormat, supported, enabledRangeInEditableText, stateNone, valueNull, notTextInsertion } },
{ "SelectAll", { executeSelectAll, supported, enabled, stateNone, valueNull, notTextInsertion } },
+ { "SelectLine", { executeSelectLine, supported, enabledInEditableText, stateNone, valueNull, notTextInsertion } },
+ { "SelectParagraph", { executeSelectParagraph, supported, enabledInEditableText, stateNone, valueNull, notTextInsertion } },
+ { "SelectSentence", { executeSelectSentence, supported, enabledInEditableText, stateNone, valueNull, notTextInsertion } },
{ "SelectToMark", { executeSelectToMark, supported, enabledAnySelectionAndMark, stateNone, valueNull, notTextInsertion } },
+ { "SelectWord", { executeSelectWord, supported, enabledInEditableText, stateNone, valueNull, notTextInsertion } },
{ "SetMark", { executeSetMark, supported, enabledAnySelection, stateNone, valueNull, notTextInsertion } },
{ "Strikethrough", { executeStrikethrough, supported, enabledInRichlyEditableText, stateStrikethrough, valueNull, notTextInsertion } },
{ "Subscript", { executeSubscript, supported, enabledInRichlyEditableText, stateSubscript, valueNull, notTextInsertion } },
return m_command && m_command->isTextInsertion;
}
-bool Editor::execCommand(const AtomicString& commandName, Event* triggeringEvent)
-{
- return command(commandName).execute(triggeringEvent);
-}
-
} // namespace WebCore
openNewWindow(result.absoluteLinkURL(), frame);
break;
case ContextMenuItemTagBold:
- frame->editor()->execCommand("ToggleBold");
+ frame->editor()->command("ToggleBold").execute();
break;
case ContextMenuItemTagItalic:
- frame->editor()->execCommand("ToggleItalic");
+ frame->editor()->command("ToggleItalic").execute();
break;
case ContextMenuItemTagUnderline:
frame->editor()->toggleUnderline();
ASSERT(nodeView);
ASSERT([nodeView superview]);
NSView *view = [nodeView hitTest:[[nodeView superview] convertPoint:[currentEvent().get() locationInWindow] fromView:nil]];
- if (!view)
+ if (!view) {
// We probably hit the border of a RenderWidget
return true;
+ }
- if ([m_frame->bridge() firstResponder] == view) {
- // In the case where we just became first responder, we should send the mouseDown:
- // to the NSTextField, not the NSTextField's editor. This code makes sure that happens.
- // If we don't do this, we see a flash of selected text when clicking in a text field.
- // FIXME: This is the only caller of textViewWasFirstResponderAtMouseDownTime. When we
- // eliminate all use of NSTextField/NSTextView in form fields we can eliminate this code,
- // and textViewWasFirstResponderAtMouseDownTime:, and the instance variable WebHTMLView
- // keeps solely to support textViewWasFirstResponderAtMouseDownTime:.
- if ([view isKindOfClass:[NSTextView class]] && ![m_frame->bridge() textViewWasFirstResponderAtMouseDownTime:(NSTextView *)view]) {
- NSView *superview = view;
- while (superview != nodeView) {
- superview = [superview superview];
- ASSERT(superview);
- if ([superview isKindOfClass:[NSControl class]]) {
- NSControl *control = static_cast<NSControl*>(superview);
- if ([control currentEditor] == view)
- view = superview;
- break;
- }
- }
- }
- } else {
+ if ([m_frame->bridge() firstResponder] != view) {
// Normally [NSWindow sendEvent:] handles setting the first responder.
// But in our case, the event was sent to the view representing the entire web page.
- if ([currentEvent().get() clickCount] <= 1 && [view acceptsFirstResponder] && [view needsPanelToBecomeKey]) {
+ if ([currentEvent().get() clickCount] <= 1 && [view acceptsFirstResponder] && [view needsPanelToBecomeKey])
[m_frame->bridge() makeFirstResponder:view];
- }
}
// We need to "defer loading" while tracking the mouse, because tearing down the
- (id)init;
- (void)close;
-- (void)addData:(NSData *)data;
-
- (void)clearFrame;
- (NSURL *)baseURL;
- (void)forceLayoutWithMinimumPageWidth:(float)minPageWidth maximumPageWidth:(float)maxPageWidth adjustingViewSize:(BOOL)adjustSizeFlag;
- (void)sendScrollEvent;
- (BOOL)needsLayout;
-- (void)setNeedsLayout;
- (void)drawRect:(NSRect)rect;
- (void)adjustPageHeightNew:(float *)newBottom top:(float)oldTop bottom:(float)oldBottom limit:(float)bottomLimit;
- (NSArray*)computePageRectsWithPrintWidthScaleFactor:(float)printWidthScaleFactor printHeight:(float)printHeight;
- (NSRect)firstRectForDOMRange:(DOMRange *)range;
- (void)scrollDOMRangeToVisible:(DOMRange *)range;
-// Emacs-style-editing "mark"
-- (DOMRange *)markDOMRange;
-
- (NSFont *)fontForSelection:(BOOL *)hasMultipleFonts;
- (NSWritingDirection)baseWritingDirectionForSelectionStart;
- (NSString *)stringWithData:(NSData *)data; // using the encoding of the frame's main resource
+ (NSString *)stringWithData:(NSData *)data textEncodingName:(NSString *)textEncodingName; // nil for textEncodingName means Latin-1
-- (void)setShouldCreateRenderers:(BOOL)f;
-- (BOOL)shouldCreateRenderers;
+- (void)setShouldCreateRenderers:(BOOL)shouldCreateRenderers;
- (void)setBaseBackgroundColor:(NSColor *)backgroundColor;
- (void)setDrawsBackground:(BOOL)drawsBackround;
- (id)accessibilityTree;
- (DOMRange *)rangeByAlteringCurrentSelection:(WebCore::SelectionController::EAlteration)alteration direction:(WebCore::SelectionController::EDirection)direction granularity:(WebCore::TextGranularity)granularity;
-- (void)alterCurrentSelection:(WebCore::SelectionController::EAlteration)alteration verticalDistance:(float)distance;
- (WebCore::TextGranularity)selectionGranularity;
-- (DOMRange *)smartDeleteRangeForProposedRange:(DOMRange *)proposedCharRange;
-- (void)smartInsertForString:(NSString *)pasteString replacingRange:(DOMRange *)charRangeToReplace beforeString:(NSString **)beforeString afterString:(NSString **)afterString;
- (void)selectNSRange:(NSRange)range;
- (NSRange)selectedNSRange;
- (NSRange)markedTextNSRange;
- (void)insertParagraphSeparatorInQuotedContent;
-- (void)setSelectionToDragCaret;
-- (void)moveSelectionToDragCaret:(DOMDocumentFragment *)selectionFragment smartMove:(BOOL)smartMove;
-- (DOMRange *)dragCaretDOMRange;
-- (BOOL)isDragCaretRichlyEditable;
- (DOMRange *)characterRangeAtPoint:(NSPoint)point;
- (DOMCSSStyleDeclaration *)typingStyle;
@protocol WebCoreFrameBridge
-- (NSView *)documentView;
-
-- (WebCore::Frame*)createChildFrameNamed:(NSString *)frameName withURL:(NSURL *)URL referrer:(const WebCore::String&)referrer
- ownerElement:(WebCore::HTMLFrameOwnerElement *)ownerElement allowsScrolling:(BOOL)allowsScrolling marginWidth:(int)width marginHeight:(int)height;
-
- (NSWindow *)window;
- (NSResponder *)firstResponder;
- (void)makeFirstResponder:(NSResponder *)responder;
-- (void)willMakeFirstResponderForNodeFocus;
-
-- (BOOL)textViewWasFirstResponderAtMouseDownTime:(NSTextView *)textView;
- (void)runOpenPanelForFileButtonWithResultListener:(id <WebCoreOpenPanelResultListener>)resultListener;
-- (NSView *)viewForPluginWithFrame:(NSRect)frame
- URL:(NSURL *)URL
- attributeNames:(NSArray *)attributeNames
- attributeValues:(NSArray *)attributeValues
- MIMEType:(NSString *)MIMEType
- DOMElement:(DOMElement *)element
- loadManually:(BOOL)loadManually;
-- (NSView *)viewForJavaAppletWithFrame:(NSRect)frame
- attributeNames:(NSArray *)attributeNames
- attributeValues:(NSArray *)attributeValues
- baseURL:(NSURL *)baseURL
- DOMElement:(DOMElement *)element;
-- (void)redirectDataToPlugin:(NSView *)pluginView;
-
-- (WebCore::ObjectContentType)determineObjectFromMIMEType:(NSString*)MIMEType URL:(NSURL*)URL;
-
- (jobject)getAppletInView:(NSView *)view;
// Deprecated, use getAppletInView: instead.
- (jobject)pollForAppletInView:(NSView *)view;
- (void)issuePasteCommand;
-- (void)setIsSelected:(BOOL)isSelected forView:(NSView *)view;
-- (void)windowObjectCleared;
+- (void)setIsSelected:(BOOL)isSelected forView:(NSView *)view;
- (void)dashboardRegionsChanged:(NSMutableDictionary *)regions;
- (void)willPopupMenu:(NSMenu *)menu;
// changing another's location before the frame's document
// has been created.
if (doc) {
- doc->setShouldCreateRenderers([self shouldCreateRenderers]);
+ doc->setShouldCreateRenderers(_shouldCreateRenderers);
m_frame->loader()->addData((const char *)[data bytes], [data length]);
}
}
return m_frame->view() ? m_frame->view()->needsLayout() : false;
}
-- (void)setNeedsLayout
-{
- if (m_frame->view())
- m_frame->view()->setNeedsLayout();
-}
-
- (NSString *)renderTreeAsExternalRepresentation
{
return externalRepresentation(m_frame->renderer()).getNSString();
_shouldCreateRenderers = f;
}
-- (BOOL)shouldCreateRenderers
-{
- return _shouldCreateRenderers;
-}
-
- (NSColor *)selectionColor
{
return m_frame->isActive() ? [NSColor selectedTextBackgroundColor] : [NSColor secondarySelectedControlColor];
if (m_frame->selectionController()->isNone())
return nil;
- // NOTE: The enums *must* match the very similar ones declared in SelectionController.h
SelectionController selectionController;
selectionController.setSelection(m_frame->selectionController()->selection());
selectionController.modify(alteration, direction, granularity);
return [DOMRange _wrapRange:selectionController.toRange().get()];
}
-- (void)alterCurrentSelection:(SelectionController::EAlteration)alteration verticalDistance:(float)verticalDistance
-{
- if (m_frame->selectionController()->isNone())
- return;
- SelectionController* selectionController = m_frame->selectionController();
- selectionController->modify(alteration, static_cast<int>(verticalDistance), true);
-}
-
- (TextGranularity)selectionGranularity
{
- // NOTE: The enums *must* match the very similar ones declared in SelectionController.h
return m_frame->selectionGranularity();
}
m_frame->revealSelection(RenderLayer::gAlignToEdgeIfNeeded);
}
-- (void)setSelectionToDragCaret
-{
- m_frame->selectionController()->setSelection(m_frame->dragCaretController()->selection());
-}
-
-- (void)moveSelectionToDragCaret:(DOMDocumentFragment *)selectionFragment smartMove:(BOOL)smartMove
-{
- applyCommand(new MoveSelectionCommand([selectionFragment _documentFragment], m_frame->dragCaretController()->base(), smartMove));
-}
-
- (VisiblePosition)_visiblePositionForPoint:(NSPoint)point
{
IntPoint outerPoint(point);
return visiblePos;
}
-- (DOMRange *)dragCaretDOMRange
-{
- return [DOMRange _wrapRange:m_frame->dragCaretController()->toRange().get()];
-}
-
-- (BOOL)isDragCaretRichlyEditable
-{
- return m_frame->dragCaretController()->isContentRichlyEditable();
-}
-
- (DOMRange *)characterRangeAtPoint:(NSPoint)point
{
VisiblePosition position = [self _visiblePositionForPoint:point];
+2007-12-14 Darin Adler <darin@apple.com>
+
+ * StringsNotToBeLocalized.txt: Updated.
+
2007-12-12 Brady Eidson <beidson@apple.com>
Reviewed by Sam Weinig
- Fix for <rdar://problem/4886844> and lay groundwork for <rdar://problem/4516170> (Back/Forward Cache on Windows)
+ Fix for <rdar://problem/4886844> and lay groundwork for <rdar://problem/4516170> (Back/Forward Cache on Windows)
* WebKit.xcodeproj/project.pbxproj: Added a new file
" *POST*"
" *target*"
" >>>"
-" Mac OS X; %@) AppleWebKit/%@ (KHTML, like Gecko) %@"
-" Mac OS X; %@) AppleWebKit/%@ (KHTML, like Gecko)"
+" Mac OS X %@; %@) AppleWebKit/%@ (KHTML, like Gecko) %@"
+" Mac OS X %@; %@) AppleWebKit/%@ (KHTML, like Gecko)"
" webViewDrawResizer delegate call"
"#"
"%"
"%@://%@/%@"
"%@://%@:%d"
"%d"
+"%d_%d"
+"%d_%d_%d"
"%dpx"
"%ld"
"&ie=UTF-8&oe=UTF-8"
"419"
"420+"
"422"
+"5242880"
"5CACD637-F82F-491F-947A-5DCA38AA0FEA"
"6EB8D98F-2723-4472-88D3-5936F9D6E631"
"7"
"BEGIN:VCARD"
"BP_CreatePluginMIMETypesPreferences"
"BackwardDelete"
-"CFNetwork"
"CSS"
"Cache-Control"
"Content-Encoding"
"ImmSetOpenStatus"
"IncludeDebugMenu"
"InsertBacktab"
-"InsertLineBreak"
"InsertNewline"
"InsertTab"
"Intel"
"MIME\\Database\\Content Type"
"MoveDown"
"MoveDownAndModifySelection"
-"MoveDownByPageAndModifyCaret"
"MoveLeft"
"MoveLeftAndModifySelection"
+"MovePageDown"
+"MovePageDownAndModifySelection"
+"MovePageUp"
+"MovePageUpAndModifySelection"
"MoveRight"
"MoveRightAndModifySelection"
"MoveToBeginningOfDocument"
"MoveToEndOfLineAndModifySelection"
"MoveUp"
"MoveUpAndModifySelection"
-"MoveUpByPageAndModifyCaret"
"MoveWordLeft"
"MoveWordLeftAndModifySelection"
"MoveWordRight"
"Referer"
"SAMILang"
"SAMIStyle"
-"STInitialize"
"Safari.exe"
"Safari/419.3"
"Times"
WebKit/mac/WebView/WebHTMLView.mm:"body"
WebKit/mac/WebView/WebHTMLView.mm:"bold"
WebKit/mac/WebView/WebHTMLView.mm:"center"
+WebKit/mac/WebView/WebHTMLView.mm:"direction"
WebKit/mac/WebView/WebHTMLView.mm:"font"
WebKit/mac/WebView/WebHTMLView.mm:"head"
WebKit/mac/WebView/WebHTMLView.mm:"italic"
-WebKit/mac/WebView/WebHTMLView.mm:"justify"
-WebKit/mac/WebView/WebHTMLView.mm:"left"
WebKit/mac/WebView/WebHTMLView.mm:"menu"
WebKit/mac/WebView/WebHTMLView.mm:"none"
WebKit/mac/WebView/WebHTMLView.mm:"normal"
WebKit/mac/WebView/WebHTMLView.mm:"object"
-WebKit/mac/WebView/WebHTMLView.mm:"right"
WebKit/mac/WebView/WebHTMLView.mm:"strike"
WebKit/mac/WebView/WebHTMLView.mm:"style"
WebKit/mac/WebView/WebHTMLView.mm:"super"
+2007-12-14 Darin Adler <darin@apple.com>
+
+ Reviewed by Alexey.
+
+ * WebCoreSupport/EditorClientGtk.cpp:
+ (WebKit::EditorClient::handleKeyboardEvent): Changed to use Editor::command
+ instead of Editor::execCommand.
+ * WebView/webkitwebview.cpp: Ditto.
+
2007-12-12 Brady Eidson <beidson@apple.com>
Reviewed by Sam Weinig
true);
break;
case VK_PRIOR: // PageUp
- frame->editor()->execCommand("MoveUpByPageAndModifyCaret");
+ frame->editor()->command("MovePageUp").execute();
break;
case VK_NEXT: // PageDown
- frame->editor()->execCommand("MoveDownByPageAndModifyCaret");
+ frame->editor()->command("MovePageDown").execute();
break;
case VK_HOME:
if (kevent->ctrlKey() && kevent->shiftKey())
- frame->editor()->execCommand("MoveToBeginningOfDocumentAndModifySelection");
+ frame->editor()->command("MoveToBeginningOfDocumentAndModifySelection").execute();
else if (kevent->ctrlKey())
- frame->editor()->execCommand("MoveToBeginningOfDocument");
+ frame->editor()->command("MoveToBeginningOfDocument").execute();
else if (kevent->shiftKey())
- frame->editor()->execCommand("MoveToBeginningOfLineAndModifySelection");
+ frame->editor()->command("MoveToBeginningOfLineAndModifySelection").execute();
else
- frame->editor()->execCommand("MoveToBeginningOfLine");
+ frame->editor()->command("MoveToBeginningOfLine").execute();
break;
case VK_END:
if (kevent->ctrlKey() && kevent->shiftKey())
- frame->editor()->execCommand("MoveToEndOfDocumentAndModifySelection");
+ frame->editor()->command("MoveToEndOfDocumentAndModifySelection").execute();
else if (kevent->ctrlKey())
- frame->editor()->execCommand("MoveToEndOfDocument");
+ frame->editor()->command("MoveToEndOfDocument").execute();
else if (kevent->shiftKey())
- frame->editor()->execCommand("MoveToEndOfLineAndModifySelection");
+ frame->editor()->command("MoveToEndOfLineAndModifySelection").execute();
else
- frame->editor()->execCommand("MoveToEndOfLine");
+ frame->editor()->command("MoveToEndOfLine").execute();
break;
case VK_RETURN:
- frame->editor()->execCommand("InsertLineBreak");
+ frame->editor()->command("InsertLineBreak").execute();
break;
case VK_TAB:
return;
} else if (kevent->ctrlKey()) {
switch (kevent->windowsVirtualKeyCode()) {
case VK_B:
- frame->editor()->execCommand("ToggleBold");
+ frame->editor()->command("ToggleBold").execute();
break;
case VK_I:
- frame->editor()->execCommand("ToggleItalic");
+ frame->editor()->command("ToggleItalic").execute();
break;
case VK_Y:
- frame->editor()->execCommand("Redo");
+ frame->editor()->command("Redo").execute();
break;
case VK_Z:
- frame->editor()->execCommand("Undo");
+ frame->editor()->command("Undo").execute();
break;
default:
return;
} else {
switch (kevent->windowsVirtualKeyCode()) {
case VK_UP:
- frame->editor()->execCommand("MoveUp");
+ frame->editor()->command("MoveUp").execute();
break;
case VK_DOWN:
- frame->editor()->execCommand("MoveDown");
+ frame->editor()->command("MoveDown").execute();
break;
case VK_PRIOR: // PageUp
- frame->editor()->execCommand("MoveUpByPageAndModifyCaret");
+ frame->editor()->command("MovePageUp").execute();
break;
case VK_NEXT: // PageDown
- frame->editor()->execCommand("MoveDownByPageAndModifyCaret");
+ frame->editor()->command("MovePageDown").execute();
break;
case VK_HOME:
if (kevent->ctrlKey())
- frame->editor()->execCommand("MoveToBeginningOfDocument");
+ frame->editor()->command("MoveToBeginningOfDocument").execute();
break;
case VK_END:
if (kevent->ctrlKey())
- frame->editor()->execCommand("MoveToEndOfDocument");
+ frame->editor()->command("MoveToEndOfDocument").execute();
break;
default:
return;
static void webkit_web_view_real_select_all(WebKitWebView* webView)
{
Frame* frame = core(webView)->focusController()->focusedOrMainFrame();
- frame->editor()->execCommand("SelectAll");
+ frame->editor()->command("SelectAll").execute();
}
static void webkit_web_view_real_cut_clipboard(WebKitWebView* webView)
{
Frame* frame = core(webView)->focusController()->focusedOrMainFrame();
- frame->editor()->execCommand("Cut");
+ frame->editor()->command("Cut").execute();
}
static void webkit_web_view_real_copy_clipboard(WebKitWebView* webView)
{
Frame* frame = core(webView)->focusController()->focusedOrMainFrame();
- frame->editor()->execCommand("Copy");
+ frame->editor()->command("Copy").execute();
}
static void webkit_web_view_real_paste_clipboard(WebKitWebView* webView)
{
Frame* frame = core(webView)->focusController()->focusedOrMainFrame();
- frame->editor()->execCommand("Paste");
+ frame->editor()->command("Paste").execute();
}
static void webkit_web_view_finalize(GObject* object)
+2007-12-14 Darin Adler <darin@apple.com>
+
+ Reviewed by Alexey.
+
+ - Changed a few more editing operations to use WebCore instead of WebKit.
+ - Removed some obsolete unused code.
+
+ * WebCoreSupport/WebFrameBridge.h: Moved declarations of methods that are both
+ defined and used on the WebKit side to here. These no longer belong on the bridge
+ and should be moved to the WebFrame class (or elsewhere).
+ * WebCoreSupport/WebFrameBridge.mm: Removed some unused methods.
+
+ * WebView/WebFrameView.mm:
+ (+[WebFrameView _viewTypesAllowImageTypeOmission:]): Fix typo in comment.
+
+ * WebView/WebHTMLView.mm:
+ (-[WebHTMLViewPrivate dealloc]): Removed unused firstResponderTextViewAtMouseDownTime.
+ (-[WebHTMLViewPrivate clear]): Ditto.
+ (-[WebHTMLView _setMouseDownEvent:]): Ditto.
+ (commandNameForSelector): Added special cases for pageDown:, pageDownAndModifySelection:,
+ pageUp:, and pageUpAndModifySelection:, since those names probably aren't specific enough
+ to be used in WebCore (what AppKit calls scrollPageDown: vs. pageDown: needs to be
+ disambiguated with the word "Move"). Added deleteBackward:,
+ deleteBackwardByDecomposingPreviousCharacter:, deleteForward:, deleteToBeginningOfLine:,
+ deleteToBeginningOfParagraph:, deleteToEndOfLine:, deleteToEndOfParagraph:, pageDown:,
+ pageDownAndModifySelection:, pageUp:, pageUpAndModifySelection:, selectLine:,
+ selectParagraph:, selectSentence:, and selectWord: to the list of commands that are
+ forwarded to WebCore.
+ (-[WebHTMLView validateUserInterfaceItemWithoutDelegate:]): Eliminated the long list of
+ operations that we forward to WebCore. Instead, look up any command that WebCore can
+ handle, after any that we handle specially in WebHTMLView. Also fixed a bug where
+ an item that's not a menu item with changeBaseWritingDirection:NSWritingDirectionNatural
+ would end up enabled instead of disabled and streamlined the logic for toggleGrammarChecking:.
+ (-[WebHTMLView mouseDown:]): Removed unused firstResponderTextViewAtMouseDownTime.
+ (-[WebHTMLView becomeFirstResponder]): Removed unused willBecomeFirstResponderForNodeFocus.
+ (-[WebHTMLView resignFirstResponder]): Ditto.
+ (-[WebHTMLView checkSpelling:]): Took unneeded extra initialization of NSSpellChecker.
+
+ * WebView/WebHTMLViewInternal.h: Removed unused willBecomeFirstResponderForNodeFocus,
+ firstResponderTextViewAtMouseDownTime, _textViewWasFirstResponderAtMouseDownTime: and
+ _willMakeFirstResponderForNodeFocus.
+
2007-12-13 Alexey Proskuryakov <ap@webkit.org>
Reviewed by Darin.
- (WebFrame *)webFrame;
+// The following methods can all move off the bridge; they're used on the WebKit side only.
+
+- (NSView *)viewForPluginWithFrame:(NSRect)frame
+ URL:(NSURL *)URL
+ attributeNames:(NSArray *)attributeNames
+ attributeValues:(NSArray *)attributeValues
+ MIMEType:(NSString *)MIMEType
+ DOMElement:(DOMElement *)element
+ loadManually:(BOOL)loadManually;
+- (NSView *)viewForJavaAppletWithFrame:(NSRect)frame
+ attributeNames:(NSArray *)attributeNames
+ attributeValues:(NSArray *)attributeValues
+ baseURL:(NSURL *)baseURL
+ DOMElement:(DOMElement *)element;
+
+- (WebCore::Frame*)createChildFrameNamed:(NSString *)frameName withURL:(NSURL *)URL referrer:(const WebCore::String&)referrer
+ ownerElement:(WebCore::HTMLFrameOwnerElement *)ownerElement allowsScrolling:(BOOL)allowsScrolling marginWidth:(int)width marginHeight:(int)height;
+
+- (void)redirectDataToPlugin:(NSView *)pluginView;
+
+- (WebCore::ObjectContentType)determineObjectFromMIMEType:(NSString*)MIMEType URL:(NSURL*)URL;
+
+- (void)windowObjectCleared;
+
@end
return [[[self webView] mainFrame] _bridge];
}
-- (NSView *)documentView
-{
- ASSERT(_frame != nil);
- return [[_frame frameView] documentView];
-}
-
- (NSResponder *)firstResponder
{
ASSERT(_frame != nil);
[webView _popPerformingProgrammaticFocus];
}
-- (void)willMakeFirstResponderForNodeFocus
-{
- ASSERT([[[_frame frameView] documentView] isKindOfClass:[WebHTMLView class]]);
- [(WebHTMLView *)[[_frame frameView] documentView] _willMakeFirstResponderForNodeFocus];
-}
-
-- (BOOL)textViewWasFirstResponderAtMouseDownTime:(NSTextView *)textView;
-{
- ASSERT(_frame != nil);
- NSView *documentView = [[_frame frameView] documentView];
- if (![documentView isKindOfClass:[WebHTMLView class]])
- return NO;
- WebHTMLView *webHTMLView = (WebHTMLView *)documentView;
- return [webHTMLView _textViewWasFirstResponderAtMouseDownTime:textView];
-}
-
- (NSWindow *)window
{
ASSERT(_frame != nil);
viewTypes = [[NSMutableDictionary alloc] init];
addTypesFromClass(viewTypes, [WebHTMLView class], [WebHTMLView supportedNonImageMIMETypes]);
- // Since this is a "secret default" we don't both registering it.
+ // Since this is a "secret default" we don't bother registering it.
BOOL omitPDFSupport = [[NSUserDefaults standardUserDefaults] boolForKey:@"WebKitOmitPDFSupport"];
if (!omitPDFSupport)
addTypesFromClass(viewTypes, [WebPDFView class], [WebPDFView supportedMIMETypes]);
[pluginController release];
[toolTip release];
[compController release];
- [firstResponderTextViewAtMouseDownTime release];
[dataSource release];
[highlighters release];
if (promisedDragTIFFDataSource)
[pluginController release];
[toolTip release];
[compController release];
- [firstResponderTextViewAtMouseDownTime release];
[dataSource release];
[highlighters release];
if (promisedDragTIFFDataSource)
pluginController = nil;
toolTip = nil;
compController = nil;
- firstResponderTextViewAtMouseDownTime = nil;
dataSource = nil;
highlighters = nil;
promisedDragTIFFDataSource = 0;
[event retain];
[_private->mouseDownEvent release];
_private->mouseDownEvent = event;
-
- [_private->firstResponderTextViewAtMouseDownTime release];
-
- // The only code that checks this ivar only cares about NSTextViews. The code used to be more general,
- // but it caused reference cycles leading to world leaks (see 4557386). We should be able to eliminate
- // firstResponderTextViewAtMouseDownTime entirely when all the form controls are native widgets, because
- // the only caller (in WebCore) will be unnecessary.
- if (event) {
- NSResponder *firstResponder = [[self window] firstResponder];
- if ([firstResponder isKindOfClass:[NSTextView class]])
- _private->firstResponderTextViewAtMouseDownTime = [firstResponder retain];
- else
- _private->firstResponderTextViewAtMouseDownTime = nil;
- } else
- _private->firstResponderTextViewAtMouseDownTime = nil;
}
- (void)_cancelUpdateActiveStateTimer
return self != [self _topHTMLView];
}
-- (void)scrollPoint:(NSPoint)point
-{
- // Since we can't subclass NSTextView to do what we want, we have to second guess it here.
- // If we get called during the handling of a key down event, we assume the call came from
- // NSTextView, and ignore it and use our own code to decide how to page up and page down
- // We are smarter about how far to scroll, and we have "superview scrolling" logic.
- NSEvent *event = [[self window] currentEvent];
- if ([event type] == NSKeyDown) {
- const unichar pageUp = NSPageUpFunctionKey;
- if ([[event characters] rangeOfString:[NSString stringWithCharacters:&pageUp length:1]].length == 1) {
- [self tryToPerform:@selector(scrollPageUp:) with:nil];
- return;
- }
- const unichar pageDown = NSPageDownFunctionKey;
- if ([[event characters] rangeOfString:[NSString stringWithCharacters:&pageDown length:1]].length == 1) {
- [self tryToPerform:@selector(scrollPageDown:) with:nil];
- return;
- }
- }
-
- [super scrollPoint:point];
-}
-
- (NSView *)hitTest:(NSPoint)point
{
// WebHTMLView objects handle all events for objects inside them.
return [[webView _editingDelegateForwarder] webView:webView doCommandBySelector:selector];
}
-static String comandNameForSelector(SEL selector)
+static String commandNameForSelector(SEL selector)
{
// Change a few command names into ones supported by WebCore::Editor.
+ // If this list gets too long we might decide we need to use a hash table.
if (selector == @selector(insertParagraphSeparator:) || selector == @selector(insertNewlineIgnoringFieldEditor:))
return "InsertNewline";
if (selector == @selector(insertTabIgnoringFieldEditor:))
return "InsertTab";
+ if (selector == @selector(pageDown:))
+ return "MovePageDown";
+ if (selector == @selector(pageDownAndModifySelection:))
+ return "MovePageDownAndModifySelection";
+ if (selector == @selector(pageUp:))
+ return "MovePageUp";
+ if (selector == @selector(pageUpAndModifySelection:))
+ return "MovePageUpAndModifySelection";
// Remove the trailing colon.
const char* selectorName = sel_getName(selector);
Frame* coreFrame = core([self _frame]);
if (!coreFrame)
return Editor::Command();
- return coreFrame->editor()->command(comandNameForSelector(selector));
+ return coreFrame->editor()->command(commandNameForSelector(selector));
}
- (Editor::Command)coreCommandByName:(const char*)name
WEBCORE_COMMAND(alignJustified)
WEBCORE_COMMAND(alignLeft)
WEBCORE_COMMAND(alignRight)
-WEBCORE_COMMAND(cut)
WEBCORE_COMMAND(copy)
+WEBCORE_COMMAND(cut)
+WEBCORE_COMMAND(delete)
+WEBCORE_COMMAND(deleteBackward)
+WEBCORE_COMMAND(deleteBackwardByDecomposingPreviousCharacter)
+WEBCORE_COMMAND(deleteForward)
+WEBCORE_COMMAND(deleteToBeginningOfLine)
+WEBCORE_COMMAND(deleteToBeginningOfParagraph)
+WEBCORE_COMMAND(deleteToEndOfLine)
+WEBCORE_COMMAND(deleteToEndOfParagraph)
WEBCORE_COMMAND(deleteToMark)
WEBCORE_COMMAND(deleteWordBackward)
WEBCORE_COMMAND(deleteWordForward)
WEBCORE_COMMAND(moveWordRight)
WEBCORE_COMMAND(moveWordRightAndModifySelection)
WEBCORE_COMMAND(outdent)
+WEBCORE_COMMAND(pageDown)
+WEBCORE_COMMAND(pageDownAndModifySelection)
+WEBCORE_COMMAND(pageUp)
+WEBCORE_COMMAND(pageUpAndModifySelection)
WEBCORE_COMMAND(selectAll)
+WEBCORE_COMMAND(selectLine)
+WEBCORE_COMMAND(selectParagraph)
+WEBCORE_COMMAND(selectSentence)
WEBCORE_COMMAND(selectToMark)
+WEBCORE_COMMAND(selectWord)
WEBCORE_COMMAND(setMark)
WEBCORE_COMMAND(subscript)
WEBCORE_COMMAND(superscript)
}
// jumpToSelection is the old name for what AppKit now calls centerSelectionInVisibleArea. Safari
-// was using the old jumpToSelection selector in its menu. Newer versions of Safari will us the
-// selector centerSelectionInVisibleArea. We'll leave this old selector in place for two reasons:
-// (1) compatibility between older Safari and newer WebKit; (2) other WebKit-based applications
-// might be using the jumpToSelection: selector, and we don't want to break them.
+// was using the old jumpToSelection selector in its menu. Newer versions of Safari will use the
+// selector centerSelectionInVisibleArea. We'll leave the old selector in place for two reasons:
+// (1) Compatibility between older Safari and newer WebKit; (2) other WebKit-based applications
+// might be using the selector, and we don't want to break them.
- (void)jumpToSelection:(id)sender
{
COMMAND_PROLOGUE
if (Document* doc = frame->document()) {
if (doc->isPluginDocument())
return NO;
-
if (doc->isImageDocument()) {
if (action == @selector(copy:))
return frame->loader()->isComplete();
-
return NO;
}
}
- if (action == @selector(alignCenter:)
- || action == @selector(alignJustified:)
- || action == @selector(alignLeft:)
- || action == @selector(alignRight:)
- || action == @selector(cut:)
- || action == @selector(copy:)
- || action == @selector(deleteToMark:)
- || action == @selector(deleteWordBackward:)
- || action == @selector(deleteWordForward:)
- || action == @selector(indent:)
- || action == @selector(insertBacktab:)
- || action == @selector(insertLineBreak:)
- || action == @selector(insertNewline:)
- || action == @selector(insertNewlineIgnoringFieldEditor:)
- || action == @selector(insertParagraphSeparator:)
- || action == @selector(insertTab:)
- || action == @selector(insertTabIgnoringFieldEditor:)
- || action == @selector(moveBackward:)
- || action == @selector(moveBackwardAndModifySelection:)
- || action == @selector(moveDown:)
- || action == @selector(moveDownAndModifySelection:)
- || action == @selector(moveForward:)
- || action == @selector(moveForwardAndModifySelection:)
- || action == @selector(moveLeft:)
- || action == @selector(moveLeftAndModifySelection:)
- || action == @selector(moveParagraphBackwardAndModifySelection:)
- || action == @selector(moveParagraphForwardAndModifySelection:)
- || action == @selector(moveRight:)
- || action == @selector(moveRightAndModifySelection:)
- || action == @selector(moveToBeginningOfDocument:)
- || action == @selector(moveToBeginningOfDocumentAndModifySelection:)
- || action == @selector(moveToBeginningOfLine:)
- || action == @selector(moveToBeginningOfLineAndModifySelection:)
- || action == @selector(moveToBeginningOfParagraph:)
- || action == @selector(moveToBeginningOfParagraphAndModifySelection:)
- || action == @selector(moveToBeginningOfSentence:)
- || action == @selector(moveToBeginningOfSentenceAndModifySelection:)
- || action == @selector(moveToEndOfDocument:)
- || action == @selector(moveToEndOfDocumentAndModifySelection:)
- || action == @selector(moveToEndOfLine:)
- || action == @selector(moveToEndOfLineAndModifySelection:)
- || action == @selector(moveToEndOfParagraph:)
- || action == @selector(moveToEndOfParagraphAndModifySelection:)
- || action == @selector(moveToEndOfSentence:)
- || action == @selector(moveToEndOfSentenceAndModifySelection:)
- || action == @selector(moveUp:)
- || action == @selector(moveUpAndModifySelection:)
- || action == @selector(moveWordBackward:)
- || action == @selector(moveWordBackwardAndModifySelection:)
- || action == @selector(moveWordForward:)
- || action == @selector(moveWordForwardAndModifySelection:)
- || action == @selector(moveWordLeft:)
- || action == @selector(moveWordLeftAndModifySelection:)
- || action == @selector(moveWordRight:)
- || action == @selector(moveWordRightAndModifySelection:)
- || action == @selector(outdent:)
- || action == @selector(selectAll:)
- || action == @selector(selectToMark:)
- || action == @selector(setMark:)
- || action == @selector(subscript:)
- || action == @selector(superscript:)
- || action == @selector(swapWithMark:)
- || action == @selector(transpose:)
- || action == @selector(underline:)
- || action == @selector(unscript:)
- || action == @selector(yank:)
- || action == @selector(yankAndSelect:)) {
- Editor::Command command = [self coreCommandBySelector:action];
- NSMenuItem *menuItem = (NSMenuItem *)item;
- if ([menuItem isKindOfClass:[NSMenuItem class]])
- [menuItem setState:kit(command.state())];
- return command.isEnabled();
- }
-
if (action == @selector(changeSpelling:)
|| action == @selector(_changeSpellingFromMenu:)
|| action == @selector(checkSpelling:)
|| action == @selector(complete:)
- || action == @selector(deleteBackward:)
- || action == @selector(deleteBackwardByDecomposingPreviousCharacter:)
- || action == @selector(deleteForward:)
- || action == @selector(deleteToBeginningOfLine:)
- || action == @selector(deleteToBeginningOfParagraph:)
- || action == @selector(deleteToEndOfLine:)
- || action == @selector(deleteToEndOfParagraph:)
- || action == @selector(pageDown:)
- || action == @selector(pageDownAndModifySelection:)
- || action == @selector(pageUp:)
- || action == @selector(pageUpAndModifySelection:)
|| action == @selector(pasteFont:))
return [self _canEdit];
}
if (action == @selector(changeBaseWritingDirection:)) {
+ NSWritingDirection writingDirection = static_cast<NSWritingDirection>([item tag]);
+ if (writingDirection == NSWritingDirectionNatural)
+ return NO;
NSMenuItem *menuItem = (NSMenuItem *)item;
if ([menuItem isKindOfClass:[NSMenuItem class]]) {
- NSWritingDirection writingDirection = static_cast<NSWritingDirection>([item tag]);
- if (writingDirection == NSWritingDirectionNatural) {
- [menuItem setState:NSOffState];
- return NO;
- }
RefPtr<CSSStyleDeclaration> style = new CSSMutableStyleDeclaration;
ExceptionCode ec;
style->setProperty("direction", writingDirection == NSWritingDirectionLeftToRight ? "LTR" : "RTL", ec);
if (action == @selector(changeDocumentBackgroundColor:))
return [[self _webView] isEditable] && [self _canEditRichly];
- if (action == @selector(delete:))
- return frame && frame->editor()->canDelete();
-
if (action == @selector(_ignoreSpellingFromMenu:)
|| action == @selector(_learnSpellingFromMenu:)
|| action == @selector(takeFindStringFromSelection:))
|| (frame->editor()->canPaste() && frame->selectionController()->isContentRichlyEditable()));
if (action == @selector(performFindPanelAction:))
- // FIXME: Not yet implemented.
return NO;
- if (action == @selector(_lookUpInDictionaryFromMenu:)) {
+ if (action == @selector(_lookUpInDictionaryFromMenu:))
return [self _hasSelection];
- }
#ifndef BUILDING_ON_TIGER
if (action == @selector(toggleGrammarChecking:)) {
// FIXME 4799134: WebView is the bottleneck for this grammar-checking logic, but we must validate
// the selector here because we implement it here, and we must implement it here because the AppKit
// code checks the first responder.
- BOOL checkMark = [self isGrammarCheckingEnabled];
- if ([(NSObject *)item isKindOfClass:[NSMenuItem class]]) {
- NSMenuItem *menuItem = (NSMenuItem *)item;
- [menuItem setState:checkMark ? NSOnState : NSOffState];
- }
+ NSMenuItem *menuItem = (NSMenuItem *)item;
+ if ([menuItem isKindOfClass:[NSMenuItem class]])
+ [menuItem setState:[self isGrammarCheckingEnabled] ? NSOnState : NSOffState];
return YES;
}
#endif
+ Editor::Command command = [self coreCommandBySelector:action];
+ if (command.isSupported()) {
+ NSMenuItem *menuItem = (NSMenuItem *)item;
+ if ([menuItem isKindOfClass:[NSMenuItem class]])
+ [menuItem setState:kit(command.state())];
+ return command.isEnabled();
+ }
+
return YES;
}
}
done:
- [_private->firstResponderTextViewAtMouseDownTime release];
- _private->firstResponderTextViewAtMouseDownTime = nil;
-
_private->handlingMouseDownEvent = NO;
}
- (BOOL)becomeFirstResponder
{
NSSelectionDirection direction = NSDirectSelection;
- if (![[self _webView] _isPerformingProgrammaticFocus] && !_private->willBecomeFirstResponderForNodeFocus)
+ if (![[self _webView] _isPerformingProgrammaticFocus])
direction = [[self window] keyViewSelectionDirection];
- _private->willBecomeFirstResponderForNodeFocus = NO;
[self _updateActiveState];
[self _updateFontPanel];
}
[self _updateActiveState];
_private->resigningFirstResponder = NO;
- _private->willBecomeFirstResponderForNodeFocus = NO;
}
return resign;
}
coreFrame->revealSelection(RenderLayer::gAlignCenterAlways);
}
-- (void)pageUp:(id)sender
-{
- COMMAND_PROLOGUE
-
- WebFrameView *frameView = [self _frameView];
- if (!frameView)
- return;
- if ([self _canAlterCurrentSelection])
- [[self _bridge] alterCurrentSelection:SelectionController::MOVE verticalDistance:-[frameView _verticalPageScrollDistance]];
-}
-
-- (void)pageDown:(id)sender
-{
- COMMAND_PROLOGUE
-
- WebFrameView *frameView = [self _frameView];
- if (!frameView)
- return;
- if ([self _canAlterCurrentSelection])
- [[self _bridge] alterCurrentSelection:SelectionController::MOVE verticalDistance:[frameView _verticalPageScrollDistance]];
-}
-
-- (void)pageUpAndModifySelection:(id)sender
-{
- COMMAND_PROLOGUE
-
- WebFrameView *frameView = [self _frameView];
- if (!frameView)
- return;
- if ([self _canAlterCurrentSelection])
- [[self _bridge] alterCurrentSelection:SelectionController::EXTEND verticalDistance:-[frameView _verticalPageScrollDistance]];
-}
-
-- (void)pageDownAndModifySelection:(id)sender
-{
- COMMAND_PROLOGUE
-
- WebFrameView *frameView = [self _frameView];
- if (frameView == nil)
- return;
- if ([self _canAlterCurrentSelection])
- [[self _bridge] alterCurrentSelection:SelectionController::EXTEND verticalDistance:[frameView _verticalPageScrollDistance]];
-}
-
-- (void)_expandSelectionToGranularity:(TextGranularity)granularity
-{
- if (![self _canAlterCurrentSelection])
- return;
-
- Frame* coreFrame = core([self _frame]);
- if (!coreFrame || !coreFrame->selectionController()->isCaretOrRange())
- return;
-
- // NOTE: The enums *must* match the very similar ones declared in SelectionController.h
- Selection selection(coreFrame->selectionController()->selection());
- selection.expandUsingGranularity(static_cast<TextGranularity>(granularity));
-
- RefPtr<Range> range = selection.toRange();
- if (!range)
- return;
-
- DOMRange *domRange = kit(range.get());
-
- if ([domRange collapsed])
- return;
-
- EAffinity affinity = coreFrame->selectionController()->affinity();
- WebView *webView = [self _webView];
- if ([[webView _editingDelegateForwarder] webView:webView shouldChangeSelectedDOMRange:[self _selectedRange] toDOMRange:domRange affinity:kit(affinity) stillSelecting:NO]) {
- coreFrame->selectionController()->setSelectedRange(range.get(), affinity, true);
- }
-}
-
-- (void)selectParagraph:(id)sender
-{
- COMMAND_PROLOGUE
-
- [self _expandSelectionToGranularity:ParagraphGranularity];
-}
-
-- (void)selectLine:(id)sender
-{
- COMMAND_PROLOGUE
-
- [self _expandSelectionToGranularity:LineGranularity];
-}
-
-- (void)selectSentence:(id)sender
-{
- COMMAND_PROLOGUE
-
- [self _expandSelectionToGranularity:SentenceGranularity];
-}
-
-- (void)selectWord:(id)sender
-{
- COMMAND_PROLOGUE
-
- [self _expandSelectionToGranularity:WordGranularity];
-}
-
-- (void)delete:(id)sender
-{
- COMMAND_PROLOGUE
-
- if (Frame* coreFrame = core([self _frame]))
- coreFrame->editor()->performDelete();
-}
-
- (NSData *)_selectionStartFontAttributesAsRTF
{
Frame* coreFrame = core([self _frame]);
[self _changeWordCaseWithSelector:@selector(capitalizedString)];
}
-- (void)deleteForward:(id)sender
-{
- COMMAND_PROLOGUE
-
- if (![self _isEditable])
- return;
- Frame* coreFrame = core([self _frame]);
- if (coreFrame)
- coreFrame->editor()->deleteWithDirection(SelectionController::FORWARD, CharacterGranularity, false, true);
-}
-
-- (void)deleteBackward:(id)sender
-{
- COMMAND_PROLOGUE
-
- if (![self _isEditable])
- return;
- Frame* coreFrame = core([self _frame]);
- if (coreFrame)
- coreFrame->editor()->deleteWithDirection(SelectionController::BACKWARD, CharacterGranularity, false, true);
-}
-
-- (void)deleteBackwardByDecomposingPreviousCharacter:(id)sender
-{
- COMMAND_PROLOGUE
-
- LOG_ERROR("unimplemented, doing deleteBackward instead");
-
- if (![self _isEditable])
- return;
- Frame* coreFrame = core([self _frame]);
- if (coreFrame)
- coreFrame->editor()->deleteWithDirection(SelectionController::BACKWARD, CharacterGranularity, false, true);
-}
-
-- (void)deleteToBeginningOfLine:(id)sender
-{
- COMMAND_PROLOGUE
-
- Frame* coreFrame = core([self _frame]);
- if (coreFrame)
- coreFrame->editor()->deleteWithDirection(SelectionController::BACKWARD, LineBoundary, true, false);
-}
-
-- (void)deleteToEndOfLine:(id)sender
-{
- COMMAND_PROLOGUE
-
- // To match NSTextView, this command should delete the newline at the end of
- // a paragraph if you are at the end of a paragraph (like deleteToEndOfParagraph does below).
- Frame* coreFrame = core([self _frame]);
- if (coreFrame)
- coreFrame->editor()->deleteWithDirection(SelectionController::FORWARD, LineBoundary, true, false);
-}
-
-- (void)deleteToBeginningOfParagraph:(id)sender
-{
- COMMAND_PROLOGUE
-
- Frame* coreFrame = core([self _frame]);
- if (coreFrame)
- coreFrame->editor()->deleteWithDirection(SelectionController::BACKWARD, ParagraphBoundary, true, false);
-}
-
-- (void)deleteToEndOfParagraph:(id)sender
-{
- COMMAND_PROLOGUE
-
- // Despite the name of the method, this should delete the newline if the caret is at the end of a paragraph.
- Frame* coreFrame = core([self _frame]);
- if (coreFrame)
- coreFrame->editor()->deleteWithDirection(SelectionController::FORWARD, ParagraphBoundary, true, false);
-}
-
- (void)complete:(id)sender
{
COMMAND_PROLOGUE
{
COMMAND_PROLOGUE
- NSSpellChecker *checker = [NSSpellChecker sharedSpellChecker];
- if (!checker) {
- LOG_ERROR("No NSSpellChecker");
- return;
- }
-
if (Frame* coreFrame = core([self _frame]))
coreFrame->editor()->advanceToNextMisspelling();
}
return [[self _webView] smartInsertDeleteEnabled] && [[self _bridge] selectionGranularity] == WordGranularity;
}
-- (DOMRange *)_smartDeleteRangeForProposedRange:(DOMRange *)proposedRange
-{
- if (proposedRange == nil || [self _canSmartCopyOrDelete] == NO)
- return nil;
-
- return [[self _bridge] smartDeleteRangeForProposedRange:proposedRange];
-}
-
-- (void)_smartInsertForString:(NSString *)pasteString replacingRange:(DOMRange *)rangeToReplace beforeString:(NSString **)beforeString afterString:(NSString **)afterString
-{
- if (!pasteString || !rangeToReplace || ![[self _webView] smartInsertDeleteEnabled]) {
- if (beforeString)
- *beforeString = nil;
- if (afterString)
- *afterString = nil;
- return;
- }
-
- [[self _bridge] smartInsertForString:pasteString replacingRange:rangeToReplace beforeString:beforeString afterString:afterString];
-}
-
-- (BOOL)_textViewWasFirstResponderAtMouseDownTime:(NSTextView *)textView
-{
- return textView == _private->firstResponderTextViewAtMouseDownTime;
-}
-
-
- (NSEvent *)_mouseDownEvent
{
return _private->mouseDownEvent;
}
#endif
-- (void)_willMakeFirstResponderForNodeFocus
-{
- _private->willBecomeFirstResponderForNodeFocus = YES;
-}
-
- (id<WebHTMLHighlighter>)_highlighterForType:(NSString*)type
{
return [_private->highlighters objectForKey:type];
BOOL resigningFirstResponder;
BOOL nextResponderDisabledOnce;
- BOOL willBecomeFirstResponderForNodeFocus;
WebTextCompleteController *compController;
WebHTMLViewInterpretKeyEventsParameters *interpretKeyEventsParameters;
BOOL receivedNOOP;
- NSTextView *firstResponderTextViewAtMouseDownTime;
-
WebDataSource *dataSource;
WebCore::CachedImage *promisedDragTIFFDataSource;
- (void)_selectionChanged;
- (void)_updateFontPanel;
- (BOOL)_canSmartCopyOrDelete;
-- (BOOL)_textViewWasFirstResponderAtMouseDownTime:(NSTextView *)textView;
#ifndef __LP64__
- (void)_pauseNullEventsForAllNetscapePlugins;
- (void)_resumeNullEventsForAllNetscapePlugins;
#endif
-- (void)_willMakeFirstResponderForNodeFocus;
- (id<WebHTMLHighlighter>)_highlighterForType:(NSString*)type;
- (WebFrame *)_frame;
- (void)paste:(id)sender;
mainFrame()->d->frame->loader()->reload();
break;
case Cut:
- editor->cut();
+ command = "Cut";
break;
case Copy:
- editor->copy();
+ command = "Copy";
break;
case Paste:
- editor->paste();
+ command = "Paste";
break;
case Undo:
- editor->undo();
+ command = "Undo";
break;
case Redo:
- editor->redo();
+ command = "Redo";
break;
case MoveToNextChar:
editor->setBaseWritingDirection("rtl");
break;
-
case ToggleBold:
command = "ToggleBold";
break;
}
if (command)
- editor->execCommand(command);
+ editor->command(command).execute();
}
QWebPage::NavigationRequestResponse QWebPage::navigationRequested(QWebFrame *frame, const QWebNetworkRequest &request, QWebPage::NavigationType type)
+2007-12-14 Darin Adler <darin@apple.com>
+
+ Reviewed by Alexey.
+
+ * Api/qwebpage.cpp:
+ (QWebPage::triggerAction): Removed some use of Editor member functions we plan
+ to eventually eliminate. Switch from Editor::execCommand to Editor::command.
+ * WebCoreSupport/EditorClientQt.cpp:
+ (WebCore::EditorClientQt::handleKeyboardEvent): Ditto. Also updated name from
+ MoveUpByPageAndModifyCaret to MovePageUp and from MoveDownByPageAndModifyCaret
+ to MovePageDown.
+
2007-12-12 Brady Eidson <beidson@apple.com>
Reviewed by Sam Weinig
if (start->isContentEditable()) {
switch (kevent->windowsVirtualKeyCode()) {
case VK_RETURN:
- frame->editor()->execCommand("InsertLineBreak");
+ frame->editor()->command("InsertLineBreak").execute();
break;
case VK_BACK:
frame->editor()->deleteWithDirection(SelectionController::BACKWARD,
break;
case VK_LEFT:
if (kevent->shiftKey())
- frame->editor()->execCommand("MoveLeftAndModifySelection");
- else frame->editor()->execCommand("MoveLeft");
+ frame->editor()->command("MoveLeftAndModifySelection").execute();
+ else frame->editor()->command("MoveLeft").execute();
break;
case VK_RIGHT:
if (kevent->shiftKey())
- frame->editor()->execCommand("MoveRightAndModifySelection");
- else frame->editor()->execCommand("MoveRight");
+ frame->editor()->command("MoveRightAndModifySelection").execute();
+ else frame->editor()->command("MoveRight").execute();
break;
case VK_UP:
if (kevent->shiftKey())
- frame->editor()->execCommand("MoveUpAndModifySelection");
- else frame->editor()->execCommand("MoveUp");
+ frame->editor()->command("MoveUpAndModifySelection").execute();
+ else frame->editor()->command("MoveUp").execute();
break;
case VK_DOWN:
if (kevent->shiftKey())
- frame->editor()->execCommand("MoveDownAndModifySelection");
- else frame->editor()->execCommand("MoveDown");
+ frame->editor()->command("MoveDownAndModifySelection").execute();
+ else frame->editor()->command("MoveDown").execute();
break;
case VK_PRIOR: // PageUp
- frame->editor()->execCommand("MoveUpByPageAndModifyCaret");
+ frame->editor()->command("MovePageUp").execute();
break;
case VK_NEXT: // PageDown
- frame->editor()->execCommand("MoveDownByPageAndModifyCaret");
+ frame->editor()->command("MovePageDown").execute();
break;
case VK_TAB:
return;
} else if (kevent->ctrlKey()) {
switch (kevent->windowsVirtualKeyCode()) {
case VK_A:
- frame->editor()->execCommand("SelectAll");
+ frame->editor()->command("SelectAll").execute();
break;
case VK_B:
- frame->editor()->execCommand("ToggleBold");
+ frame->editor()->command("ToggleBold").execute();
break;
case VK_C:
- frame->editor()->execCommand("Copy");
+ frame->editor()->command("Copy").execute();
break;
case VK_I:
- frame->editor()->execCommand("ToggleItalic");
+ frame->editor()->command("ToggleItalic").execute();
break;
case VK_V:
- frame->editor()->execCommand("Paste");
+ frame->editor()->command("Paste").execute();
break;
case VK_X:
- frame->editor()->execCommand("Cut");
+ frame->editor()->command("Cut").execute();
break;
case VK_Y:
- frame->editor()->execCommand("Redo");
+ frame->editor()->command("Redo").execute();
break;
case VK_Z:
- frame->editor()->execCommand("Undo");
+ frame->editor()->command("Undo").execute();
break;
default:
return;
} else {
switch (kevent->windowsVirtualKeyCode()) {
case VK_UP:
- frame->editor()->execCommand("MoveUp");
+ frame->editor()->command("MoveUp").execute();
break;
case VK_DOWN:
- frame->editor()->execCommand("MoveDown");
+ frame->editor()->command("MoveDown").execute();
break;
case VK_PRIOR: // PageUp
- frame->editor()->execCommand("MoveUpByPageAndModifyCaret");
+ frame->editor()->command("MovePageUp").execute();
break;
case VK_NEXT: // PageDown
- frame->editor()->execCommand("MoveDownByPageAndModifyCaret");
+ frame->editor()->command("MovePageDown").execute();
break;
case VK_HOME:
if (kevent->ctrlKey())
- frame->editor()->execCommand("MoveToBeginningOfDocument");
+ frame->editor()->command("MoveToBeginningOfDocument").execute();
break;
case VK_END:
if (kevent->ctrlKey())
- frame->editor()->execCommand("MoveToEndOfDocument");
+ frame->editor()->command("MoveToEndOfDocument").execute();
break;
default:
if (kevent->ctrlKey()) {
- switch(kevent->windowsVirtualKeyCode()) {
+ switch (kevent->windowsVirtualKeyCode()) {
case VK_A:
- frame->editor()->execCommand("SelectAll");
+ frame->editor()->command("SelectAll").execute();
break;
case VK_C: case VK_X:
- frame->editor()->execCommand("Copy");
+ frame->editor()->command("Copy").execute();
break;
default:
return;
+2007-12-14 Darin Adler <darin@apple.com>
+
+ Reviewed by Alexey.
+
+ * WebView.cpp:
+ (WebView::execCommand): Switched from Editor::execCommand to Editor:command.
+ Updated name from MoveUpByPageAndModifyCaret to MovePageUp and from
+ MoveDownByPageAndModifyCaret to MovePageDown.
+ (WebView::copy): Switched from Editor::execCommand to Editor:command.
+ (WebView::cut): Ditto.
+ (WebView::paste): Ditto.
+ (WebView::delete_): Ditto.
+
2007-12-13 Steve Falkenburg <sfalken@apple.com>
Move source file generation into its own vcproj to fix build dependencies.
bool WebView::execCommand(WPARAM wParam, LPARAM /*lParam*/)
{
Frame* frame = m_page->focusController()->focusedOrMainFrame();
- bool handled = false;
switch (LOWORD(wParam)) {
- case SelectAll:
- handled = frame->editor()->execCommand("SelectAll");
- break;
- case Undo:
- handled = frame->editor()->execCommand("Undo");
- break;
- case Redo:
- handled = frame->editor()->execCommand("Redo");
- break;
- default:
- break;
+ case SelectAll:
+ return frame->editor()->command("SelectAll").execute();
+ case Undo:
+ return frame->editor()->command("Undo").execute();
+ case Redo:
+ return frame->editor()->command("Redo").execute();
}
- return handled;
+ return false;
}
bool WebView::keyUp(WPARAM virtualKeyCode, LPARAM keyData, bool systemKeyDown)
{ VK_DOWN, 0, "MoveDown" },
{ VK_DOWN, ShiftKey, "MoveDownAndModifySelection" },
{ VK_NEXT, ShiftKey, "MoveDownAndModifySelection" },
- { VK_PRIOR, 0, "MoveUpByPageAndModifyCaret" },
- { VK_NEXT, 0, "MoveDownByPageAndModifyCaret" },
+ { VK_PRIOR, 0, "MovePageUp" },
+ { VK_NEXT, 0, "MovePageDown" },
{ VK_HOME, 0, "MoveToBeginningOfLine" },
{ VK_HOME, ShiftKey, "MoveToBeginningOfLineAndModifySelection" },
{ VK_HOME, CtrlKey, "MoveToBeginningOfDocument" },
HRESULT STDMETHODCALLTYPE WebView::copy(
/* [in] */ IUnknown* /*sender*/)
{
- m_page->focusController()->focusedOrMainFrame()->editor()->execCommand("Copy");
+ m_page->focusController()->focusedOrMainFrame()->editor()->command("Copy").execute();
return S_OK;
}
HRESULT STDMETHODCALLTYPE WebView::cut(
/* [in] */ IUnknown* /*sender*/)
{
- m_page->focusController()->focusedOrMainFrame()->editor()->execCommand("Cut");
+ m_page->focusController()->focusedOrMainFrame()->editor()->command("Cut").execute();
return S_OK;
}
HRESULT STDMETHODCALLTYPE WebView::paste(
/* [in] */ IUnknown* /*sender*/)
{
- m_page->focusController()->focusedOrMainFrame()->editor()->execCommand("Paste");
+ m_page->focusController()->focusedOrMainFrame()->editor()->command("Paste").execute();
return S_OK;
}
HRESULT STDMETHODCALLTYPE WebView::delete_(
/* [in] */ IUnknown* /*sender*/)
{
- m_page->focusController()->focusedOrMainFrame()->editor()->execCommand("Delete");
+ m_page->focusController()->focusedOrMainFrame()->editor()->command("Delete").execute();
return S_OK;
}
+2007-12-14 Darin Adler <darin@apple.com>
+
+ Reviewed by Alexey.
+
+ * WebKitSupport/EditorClientWx.cpp:
+ (WebCore::EditorClientWx::handleKeyboardEvent): Switched from Editor::execCommand
+ to Edtor::command.
+
2007-12-12 Brady Eidson <beidson@apple.com>
Reviewed by Sam Weinig
CharacterGranularity, false, true);
break;
case VK_LEFT:
- frame->editor()->execCommand("MoveLeft");
+ frame->editor()->command("MoveLeft").execute();
break;
case VK_RIGHT:
- frame->editor()->execCommand("MoveRight");
+ frame->editor()->command("MoveRight").execute();
break;
case VK_UP:
- frame->editor()->execCommand("MoveUp");
+ frame->editor()->command("MoveUp").execute();
break;
case VK_DOWN:
- frame->editor()->execCommand("MoveDown");
+ frame->editor()->command("MoveDown").execute();
break;
case VK_RETURN:
- frame->editor()->execCommand("InsertLineBreak");
+ frame->editor()->command("InsertLineBreak").execute();
default:
break;
}