forked from mirrors/gecko-dev
Bug 1533293 - part 3: Make editor and ContentEventHandler not use Selection::Extend() due to too slow r=m_kato
`Selection::Extend()` is too slow but editor and ContentEventHandler use it in some places. We should make them use `Selection::SetStartAndEndInLimiter()` or `Selection::SetBaseAndExtentInLimiter()`. The former is usable only when caller guarantees the start point is prior to the end point in the DOM tree. Otherwise, we need to use the latter even though it's slower than the former. Differential Revision: https://phabricator.services.mozilla.com/D23462 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
448571fd81
commit
6dd0ecdd8e
22 changed files with 179 additions and 134 deletions
|
|
@ -2981,32 +2981,28 @@ nsresult ContentEventHandler::OnSelectionEvent(WidgetSelectionEvent* aEvent) {
|
||||||
return NS_ERROR_UNEXPECTED;
|
return NS_ERROR_UNEXPECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
mSelection->StartBatchChanges();
|
if (aEvent->mReversed) {
|
||||||
|
nsCOMPtr<nsINode> startNodeStrong(startNode);
|
||||||
// Clear selection first before setting
|
nsCOMPtr<nsINode> endNodeStrong(endNode);
|
||||||
rv = mSelection->RemoveAllRangesTemporarily();
|
ErrorResult error;
|
||||||
// Need to call EndBatchChanges at the end even if call failed
|
MOZ_KnownLive(mSelection)
|
||||||
if (NS_SUCCEEDED(rv)) {
|
->SetBaseAndExtentInLimiter(*endNodeStrong, endNodeOffset,
|
||||||
if (aEvent->mReversed) {
|
*startNodeStrong, startNodeOffset, error);
|
||||||
rv = mSelection->Collapse(endNode, endNodeOffset);
|
if (NS_WARN_IF(error.Failed())) {
|
||||||
} else {
|
return error.StealNSResult();
|
||||||
rv = mSelection->Collapse(startNode, startNodeOffset);
|
|
||||||
}
|
}
|
||||||
if (NS_SUCCEEDED(rv) &&
|
} else {
|
||||||
(startNode != endNode || startNodeOffset != endNodeOffset)) {
|
nsCOMPtr<nsINode> startNodeStrong(startNode);
|
||||||
if (aEvent->mReversed) {
|
nsCOMPtr<nsINode> endNodeStrong(endNode);
|
||||||
rv = mSelection->Extend(startNode, startNodeOffset);
|
ErrorResult error;
|
||||||
} else {
|
MOZ_KnownLive(mSelection)
|
||||||
rv = mSelection->Extend(endNode, endNodeOffset);
|
->SetBaseAndExtentInLimiter(*startNodeStrong, startNodeOffset,
|
||||||
}
|
*endNodeStrong, endNodeOffset, error);
|
||||||
|
if (NS_WARN_IF(error.Failed())) {
|
||||||
|
return error.StealNSResult();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pass the eSetSelection events reason along with the BatchChange-end
|
|
||||||
// selection change notifications.
|
|
||||||
mSelection->EndBatchChanges(aEvent->mReason);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
mSelection->ScrollIntoView(nsISelectionController::SELECTION_FOCUS_REGION,
|
mSelection->ScrollIntoView(nsISelectionController::SELECTION_FOCUS_REGION,
|
||||||
nsIPresShell::ScrollAxis(),
|
nsIPresShell::ScrollAxis(),
|
||||||
nsIPresShell::ScrollAxis(), 0);
|
nsIPresShell::ScrollAxis(), 0);
|
||||||
|
|
|
||||||
|
|
@ -123,6 +123,7 @@ class MOZ_STACK_CLASS ContentEventHandler {
|
||||||
nsresult OnQueryDOMWidgetHittest(WidgetQueryContentEvent* aEvent);
|
nsresult OnQueryDOMWidgetHittest(WidgetQueryContentEvent* aEvent);
|
||||||
|
|
||||||
// NS_SELECTION_* event
|
// NS_SELECTION_* event
|
||||||
|
MOZ_CAN_RUN_SCRIPT
|
||||||
nsresult OnSelectionEvent(WidgetSelectionEvent* aEvent);
|
nsresult OnSelectionEvent(WidgetSelectionEvent* aEvent);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
||||||
|
|
@ -750,10 +750,12 @@ nsresult EventStateManager::PreHandleEvent(nsPresContext* aPresContext,
|
||||||
DeltaAccumulator::GetInstance()->InitLineOrPageDelta(aTargetFrame, this,
|
DeltaAccumulator::GetInstance()->InitLineOrPageDelta(aTargetFrame, this,
|
||||||
wheelEvent);
|
wheelEvent);
|
||||||
} break;
|
} break;
|
||||||
case eSetSelection:
|
case eSetSelection: {
|
||||||
IMEStateManager::HandleSelectionEvent(aPresContext, GetFocusedContent(),
|
nsCOMPtr<nsIContent> focusedContent = GetFocusedContent();
|
||||||
|
IMEStateManager::HandleSelectionEvent(aPresContext, focusedContent,
|
||||||
aEvent->AsSelectionEvent());
|
aEvent->AsSelectionEvent());
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case eContentCommandCut:
|
case eContentCommandCut:
|
||||||
case eContentCommandCopy:
|
case eContentCommandCopy:
|
||||||
case eContentCommandPaste:
|
case eContentCommandPaste:
|
||||||
|
|
|
||||||
|
|
@ -205,6 +205,7 @@ class IMEStateManager {
|
||||||
* because they must be handled by same target as composition events when
|
* because they must be handled by same target as composition events when
|
||||||
* there is a composition.
|
* there is a composition.
|
||||||
*/
|
*/
|
||||||
|
MOZ_CAN_RUN_SCRIPT
|
||||||
static void HandleSelectionEvent(nsPresContext* aPresContext,
|
static void HandleSelectionEvent(nsPresContext* aPresContext,
|
||||||
nsIContent* aEventTargetContent,
|
nsIContent* aEventTargetContent,
|
||||||
WidgetSelectionEvent* aSelectionEvent);
|
WidgetSelectionEvent* aSelectionEvent);
|
||||||
|
|
|
||||||
|
|
@ -456,9 +456,13 @@ class TextComposition final {
|
||||||
* HandleSelectionEvent() sends the selection event to ContentEventHandler
|
* HandleSelectionEvent() sends the selection event to ContentEventHandler
|
||||||
* or dispatches it to the focused child process.
|
* or dispatches it to the focused child process.
|
||||||
*/
|
*/
|
||||||
|
MOZ_CAN_RUN_SCRIPT
|
||||||
void HandleSelectionEvent(WidgetSelectionEvent* aSelectionEvent) {
|
void HandleSelectionEvent(WidgetSelectionEvent* aSelectionEvent) {
|
||||||
HandleSelectionEvent(mPresContext, mTabParent, aSelectionEvent);
|
RefPtr<nsPresContext> presContext(mPresContext);
|
||||||
|
RefPtr<TabParent> tabParent(mTabParent);
|
||||||
|
HandleSelectionEvent(presContext, tabParent, aSelectionEvent);
|
||||||
}
|
}
|
||||||
|
MOZ_CAN_RUN_SCRIPT
|
||||||
static void HandleSelectionEvent(nsPresContext* aPresContext,
|
static void HandleSelectionEvent(nsPresContext* aPresContext,
|
||||||
TabParent* aTabParent,
|
TabParent* aTabParent,
|
||||||
WidgetSelectionEvent* aSelectionEvent);
|
WidgetSelectionEvent* aSelectionEvent);
|
||||||
|
|
|
||||||
|
|
@ -389,6 +389,7 @@ class EditorBase : public nsIEditor,
|
||||||
return mTransactionManager->RemoveTransactionListener(aListener);
|
return mTransactionManager->RemoveTransactionListener(aListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MOZ_CAN_RUN_SCRIPT
|
||||||
virtual nsresult HandleKeyPressEvent(WidgetKeyboardEvent* aKeyboardEvent);
|
virtual nsresult HandleKeyPressEvent(WidgetKeyboardEvent* aKeyboardEvent);
|
||||||
|
|
||||||
virtual dom::EventTarget* GetDOMEventTarget() = 0;
|
virtual dom::EventTarget* GetDOMEventTarget() = 0;
|
||||||
|
|
|
||||||
|
|
@ -1731,7 +1731,8 @@ EditActionResult HTMLEditRules::WillInsertParagraphSeparator() {
|
||||||
// MakeBasicBlock() creates AutoSelectionRestorer.
|
// MakeBasicBlock() creates AutoSelectionRestorer.
|
||||||
// Therefore, even if it returns NS_OK, editor might have been destroyed
|
// Therefore, even if it returns NS_OK, editor might have been destroyed
|
||||||
// at restoring Selection.
|
// at restoring Selection.
|
||||||
nsresult rv = MakeBasicBlock(ParagraphSeparatorElement(separator));
|
OwningNonNull<nsAtom> separatorTag = ParagraphSeparatorElement(separator);
|
||||||
|
nsresult rv = MakeBasicBlock(separatorTag);
|
||||||
if (NS_WARN_IF(rv == NS_ERROR_EDITOR_DESTROYED) ||
|
if (NS_WARN_IF(rv == NS_ERROR_EDITOR_DESTROYED) ||
|
||||||
NS_WARN_IF(!CanHandleEditAction())) {
|
NS_WARN_IF(!CanHandleEditAction())) {
|
||||||
return EditActionIgnored(NS_ERROR_EDITOR_DESTROYED);
|
return EditActionIgnored(NS_ERROR_EDITOR_DESTROYED);
|
||||||
|
|
@ -2221,7 +2222,8 @@ nsresult HTMLEditRules::WillDeleteSelection(
|
||||||
HTMLEditorRef().GetFirstSelectedTableCellElement(error);
|
HTMLEditorRef().GetFirstSelectedTableCellElement(error);
|
||||||
if (cellElement) {
|
if (cellElement) {
|
||||||
error.SuppressException();
|
error.SuppressException();
|
||||||
nsresult rv = HTMLEditorRef().DeleteTableCellContentsWithTransaction();
|
nsresult rv =
|
||||||
|
MOZ_KnownLive(HTMLEditorRef()).DeleteTableCellContentsWithTransaction();
|
||||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||||
return NS_ERROR_EDITOR_DESTROYED;
|
return NS_ERROR_EDITOR_DESTROYED;
|
||||||
}
|
}
|
||||||
|
|
@ -6508,13 +6510,6 @@ nsresult HTMLEditRules::ExpandSelectionForDeletion() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Now set the selection to the new range
|
|
||||||
DebugOnly<nsresult> rv =
|
|
||||||
SelectionRefPtr()->Collapse(selStartNode, selStartOffset);
|
|
||||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
|
||||||
return NS_ERROR_EDITOR_DESTROYED;
|
|
||||||
}
|
|
||||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Failed to collapse selection");
|
|
||||||
|
|
||||||
// Expand selection endpoint only if we didn't pass a <br>, or if we really
|
// Expand selection endpoint only if we didn't pass a <br>, or if we really
|
||||||
// needed to pass that <br> (i.e., its block is now totally selected).
|
// needed to pass that <br> (i.e., its block is now totally selected).
|
||||||
|
|
@ -6542,26 +6537,20 @@ nsresult HTMLEditRules::ExpandSelectionForDeletion() {
|
||||||
doEndExpansion = false;
|
doEndExpansion = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (doEndExpansion) {
|
|
||||||
nsresult rv = SelectionRefPtr()->Extend(selEndNode, selEndOffset);
|
|
||||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
|
||||||
return NS_ERROR_EDITOR_DESTROYED;
|
|
||||||
}
|
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Only expand to just before <br>.
|
|
||||||
nsresult rv = SelectionRefPtr()->Extend(firstBRParent, firstBROffset);
|
|
||||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
|
||||||
return NS_ERROR_EDITOR_DESTROYED;
|
|
||||||
}
|
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return NS_OK;
|
EditorRawDOMPoint newSelectionStart(selStartNode, selStartOffset);
|
||||||
|
EditorRawDOMPoint newSelectionEnd(
|
||||||
|
doEndExpansion ? selEndNode : firstBRParent,
|
||||||
|
doEndExpansion ? selEndOffset : firstBROffset);
|
||||||
|
ErrorResult error;
|
||||||
|
MOZ_KnownLive(SelectionRefPtr())
|
||||||
|
->SetStartAndEndInLimiter(newSelectionStart, newSelectionEnd, error);
|
||||||
|
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||||
|
error.SuppressException();
|
||||||
|
return NS_ERROR_EDITOR_DESTROYED;
|
||||||
|
}
|
||||||
|
NS_WARNING_ASSERTION(!error.Failed(), "Failed to set selection for deletion");
|
||||||
|
return error.StealNSResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult HTMLEditRules::NormalizeSelection() {
|
nsresult HTMLEditRules::NormalizeSelection() {
|
||||||
|
|
@ -6714,20 +6703,18 @@ nsresult HTMLEditRules::NormalizeSelection() {
|
||||||
return NS_OK; // New start after old end.
|
return NS_OK; // New start after old end.
|
||||||
}
|
}
|
||||||
|
|
||||||
// otherwise set selection to new values.
|
// Otherwise set selection to new values. Note that end point may be prior
|
||||||
// XXX Why don't we use SetBaseAndExtent()?
|
// to start point. So, we cannot use Selection::SetStartAndEndInLimit() here.
|
||||||
DebugOnly<nsresult> rv =
|
ErrorResult error;
|
||||||
SelectionRefPtr()->Collapse(newStartNode, newStartOffset);
|
MOZ_KnownLive(SelectionRefPtr())
|
||||||
|
->SetBaseAndExtentInLimiter(*newStartNode, newStartOffset, *newEndNode,
|
||||||
|
newEndOffset, error);
|
||||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||||
|
error.SuppressException();
|
||||||
return NS_ERROR_EDITOR_DESTROYED;
|
return NS_ERROR_EDITOR_DESTROYED;
|
||||||
}
|
}
|
||||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Failed to collapse selection");
|
NS_WARNING_ASSERTION(!error.Failed(), "Failed to set selection");
|
||||||
rv = SelectionRefPtr()->Extend(newEndNode, newEndOffset);
|
return error.StealNSResult();
|
||||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
|
||||||
return NS_ERROR_EDITOR_DESTROYED;
|
|
||||||
}
|
|
||||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Failed to extend selection");
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorDOMPoint HTMLEditRules::GetPromotedPoint(RulesEndpoint aWhere,
|
EditorDOMPoint HTMLEditRules::GetPromotedPoint(RulesEndpoint aWhere,
|
||||||
|
|
|
||||||
|
|
@ -230,6 +230,7 @@ class HTMLEditRules : public TextEditRules {
|
||||||
* @param aCancel Returns true if the operation is canceled.
|
* @param aCancel Returns true if the operation is canceled.
|
||||||
* @param aHandled Returns true if the edit action is handled.
|
* @param aHandled Returns true if the edit action is handled.
|
||||||
*/
|
*/
|
||||||
|
MOZ_CAN_RUN_SCRIPT
|
||||||
MOZ_MUST_USE nsresult WillDeleteSelection(
|
MOZ_MUST_USE nsresult WillDeleteSelection(
|
||||||
nsIEditor::EDirection aAction, nsIEditor::EStripWrappers aStripWrappers,
|
nsIEditor::EDirection aAction, nsIEditor::EStripWrappers aStripWrappers,
|
||||||
bool* aCancel, bool* aHandled);
|
bool* aCancel, bool* aHandled);
|
||||||
|
|
@ -374,6 +375,7 @@ class HTMLEditRules : public TextEditRules {
|
||||||
/**
|
/**
|
||||||
* XXX Should document what this does.
|
* XXX Should document what this does.
|
||||||
*/
|
*/
|
||||||
|
MOZ_CAN_RUN_SCRIPT
|
||||||
MOZ_MUST_USE nsresult WillMakeList(const nsAString* aListType,
|
MOZ_MUST_USE nsresult WillMakeList(const nsAString* aListType,
|
||||||
bool aEntireList,
|
bool aEntireList,
|
||||||
const nsAString* aBulletType,
|
const nsAString* aBulletType,
|
||||||
|
|
@ -388,6 +390,7 @@ class HTMLEditRules : public TextEditRules {
|
||||||
* @param aCancel Returns true if the operation is canceled.
|
* @param aCancel Returns true if the operation is canceled.
|
||||||
* @param aHandled Returns true if the edit action is handled.
|
* @param aHandled Returns true if the edit action is handled.
|
||||||
*/
|
*/
|
||||||
|
MOZ_CAN_RUN_SCRIPT
|
||||||
MOZ_MUST_USE nsresult WillRemoveList(bool* aCancel, bool* aHandled);
|
MOZ_MUST_USE nsresult WillRemoveList(bool* aCancel, bool* aHandled);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -397,6 +400,7 @@ class HTMLEditRules : public TextEditRules {
|
||||||
* @param aCancel Returns true if the operation is canceled.
|
* @param aCancel Returns true if the operation is canceled.
|
||||||
* @param aHandled Returns true if the edit action is handled.
|
* @param aHandled Returns true if the edit action is handled.
|
||||||
*/
|
*/
|
||||||
|
MOZ_CAN_RUN_SCRIPT
|
||||||
MOZ_MUST_USE nsresult WillIndent(bool* aCancel, bool* aHandled);
|
MOZ_MUST_USE nsresult WillIndent(bool* aCancel, bool* aHandled);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -406,6 +410,7 @@ class HTMLEditRules : public TextEditRules {
|
||||||
* @param aCancel Returns true if the operation is canceled.
|
* @param aCancel Returns true if the operation is canceled.
|
||||||
* @param aHandled Returns true if the edit action is handled.
|
* @param aHandled Returns true if the edit action is handled.
|
||||||
*/
|
*/
|
||||||
|
MOZ_CAN_RUN_SCRIPT
|
||||||
MOZ_MUST_USE nsresult WillCSSIndent(bool* aCancel, bool* aHandled);
|
MOZ_MUST_USE nsresult WillCSSIndent(bool* aCancel, bool* aHandled);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -415,6 +420,7 @@ class HTMLEditRules : public TextEditRules {
|
||||||
* @param aCancel Returns true if the operation is canceled.
|
* @param aCancel Returns true if the operation is canceled.
|
||||||
* @param aHandled Returns true if the edit action is handled.
|
* @param aHandled Returns true if the edit action is handled.
|
||||||
*/
|
*/
|
||||||
|
MOZ_CAN_RUN_SCRIPT
|
||||||
MOZ_MUST_USE nsresult WillHTMLIndent(bool* aCancel, bool* aHandled);
|
MOZ_MUST_USE nsresult WillHTMLIndent(bool* aCancel, bool* aHandled);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -424,6 +430,7 @@ class HTMLEditRules : public TextEditRules {
|
||||||
* @param aCancel Returns true if the operation is canceled.
|
* @param aCancel Returns true if the operation is canceled.
|
||||||
* @param aHandled Returns true if the edit action is handled.
|
* @param aHandled Returns true if the edit action is handled.
|
||||||
*/
|
*/
|
||||||
|
MOZ_CAN_RUN_SCRIPT
|
||||||
MOZ_MUST_USE nsresult WillOutdent(bool* aCancel, bool* aHandled);
|
MOZ_MUST_USE nsresult WillOutdent(bool* aCancel, bool* aHandled);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -435,6 +442,7 @@ class HTMLEditRules : public TextEditRules {
|
||||||
* @param aCancel Returns true if the operation is canceled.
|
* @param aCancel Returns true if the operation is canceled.
|
||||||
* @param aHandled Returns true if the edit action is handled.
|
* @param aHandled Returns true if the edit action is handled.
|
||||||
*/
|
*/
|
||||||
|
MOZ_CAN_RUN_SCRIPT
|
||||||
nsresult WillAlign(const nsAString& aAlignType, bool* aCancel,
|
nsresult WillAlign(const nsAString& aAlignType, bool* aCancel,
|
||||||
bool* aHandled);
|
bool* aHandled);
|
||||||
|
|
||||||
|
|
@ -473,6 +481,7 @@ class HTMLEditRules : public TextEditRules {
|
||||||
* @param aCancel Returns true if the operation is canceled.
|
* @param aCancel Returns true if the operation is canceled.
|
||||||
* @param aHandled Returns true if the edit action is handled.
|
* @param aHandled Returns true if the edit action is handled.
|
||||||
*/
|
*/
|
||||||
|
MOZ_CAN_RUN_SCRIPT
|
||||||
MOZ_MUST_USE nsresult WillMakeDefListItem(const nsAString* aBlockType,
|
MOZ_MUST_USE nsresult WillMakeDefListItem(const nsAString* aBlockType,
|
||||||
bool aEntireList, bool* aCancel,
|
bool aEntireList, bool* aCancel,
|
||||||
bool* aHandled);
|
bool* aHandled);
|
||||||
|
|
@ -485,6 +494,7 @@ class HTMLEditRules : public TextEditRules {
|
||||||
* @param aCancel Returns true if the operation is canceled.
|
* @param aCancel Returns true if the operation is canceled.
|
||||||
* @param aHandled Returns true if the edit action is handled.
|
* @param aHandled Returns true if the edit action is handled.
|
||||||
*/
|
*/
|
||||||
|
MOZ_CAN_RUN_SCRIPT
|
||||||
MOZ_MUST_USE nsresult WillMakeBasicBlock(const nsAString& aBlockType,
|
MOZ_MUST_USE nsresult WillMakeBasicBlock(const nsAString& aBlockType,
|
||||||
bool* aCancel, bool* aHandled);
|
bool* aCancel, bool* aHandled);
|
||||||
|
|
||||||
|
|
@ -501,6 +511,7 @@ class HTMLEditRules : public TextEditRules {
|
||||||
* will be called.
|
* will be called.
|
||||||
* Otherwise, ApplyBlockStyle() will be called.
|
* Otherwise, ApplyBlockStyle() will be called.
|
||||||
*/
|
*/
|
||||||
|
MOZ_CAN_RUN_SCRIPT
|
||||||
MOZ_MUST_USE nsresult MakeBasicBlock(nsAtom& aBlockType);
|
MOZ_MUST_USE nsresult MakeBasicBlock(nsAtom& aBlockType);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -519,6 +530,7 @@ class HTMLEditRules : public TextEditRules {
|
||||||
* @param aCancel Returns true if the operation is canceled.
|
* @param aCancel Returns true if the operation is canceled.
|
||||||
* @param aHandled Returns true if the edit action is handled.
|
* @param aHandled Returns true if the edit action is handled.
|
||||||
*/
|
*/
|
||||||
|
MOZ_CAN_RUN_SCRIPT
|
||||||
MOZ_MUST_USE nsresult WillAbsolutePosition(bool* aCancel, bool* aHandled);
|
MOZ_MUST_USE nsresult WillAbsolutePosition(bool* aCancel, bool* aHandled);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -848,6 +860,7 @@ class HTMLEditRules : public TextEditRules {
|
||||||
* invisible <br> element for preventing delete action handler to keep
|
* invisible <br> element for preventing delete action handler to keep
|
||||||
* unexpected nodes.
|
* unexpected nodes.
|
||||||
*/
|
*/
|
||||||
|
MOZ_CAN_RUN_SCRIPT
|
||||||
MOZ_MUST_USE nsresult ExpandSelectionForDeletion();
|
MOZ_MUST_USE nsresult ExpandSelectionForDeletion();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -856,6 +869,7 @@ class HTMLEditRules : public TextEditRules {
|
||||||
* non-editable point, they should be moved to nearest text node or something
|
* non-editable point, they should be moved to nearest text node or something
|
||||||
* where the other methods easier to handle edit action.
|
* where the other methods easier to handle edit action.
|
||||||
*/
|
*/
|
||||||
|
MOZ_CAN_RUN_SCRIPT
|
||||||
MOZ_MUST_USE nsresult NormalizeSelection();
|
MOZ_MUST_USE nsresult NormalizeSelection();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1727,7 +1727,7 @@ HTMLEditor::SelectElement(Element* aElement) {
|
||||||
return NS_ERROR_NOT_INITIALIZED;
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult rv = SelectContentInternal(*aElement);
|
nsresult rv = SelectContentInternal(MOZ_KnownLive(*aElement));
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
@ -1742,28 +1742,18 @@ nsresult HTMLEditor::SelectContentInternal(nsIContent& aContentToSelect) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsINode* parent = aContentToSelect.GetParentNode();
|
EditorRawDOMPoint newSelectionStart(&aContentToSelect);
|
||||||
if (NS_WARN_IF(!parent)) {
|
if (NS_WARN_IF(!newSelectionStart.IsSet())) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
EditorRawDOMPoint newSelectionEnd(&aContentToSelect);
|
||||||
// Don't notify selection change at collapse.
|
MOZ_ASSERT(newSelectionEnd.IsSet());
|
||||||
AutoUpdateViewBatch notifySelectionChangeOnce(*this);
|
DebugOnly<bool> advanced = newSelectionEnd.AdvanceOffset();
|
||||||
|
ErrorResult error;
|
||||||
// XXX Perhaps, Selection should have SelectNode(nsIContent&).
|
MOZ_KnownLive(SelectionRefPtr())
|
||||||
int32_t offsetInParent = parent->ComputeIndexOf(&aContentToSelect);
|
->SetStartAndEndInLimiter(newSelectionStart, newSelectionEnd, error);
|
||||||
|
NS_WARNING_ASSERTION(!error.Failed(), "Failed to select the given content");
|
||||||
// Collapse selection to just before desired element,
|
return error.StealNSResult();
|
||||||
nsresult rv = SelectionRefPtr()->Collapse(parent, offsetInParent);
|
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
// then extend it to just after
|
|
||||||
rv = SelectionRefPtr()->Extend(parent, offsetInParent + 1);
|
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
|
|
||||||
|
|
@ -141,6 +141,7 @@ class HTMLEditor final : public TextEditor,
|
||||||
|
|
||||||
NS_IMETHOD InsertLineBreak() override;
|
NS_IMETHOD InsertLineBreak() override;
|
||||||
|
|
||||||
|
MOZ_CAN_RUN_SCRIPT
|
||||||
virtual nsresult HandleKeyPressEvent(
|
virtual nsresult HandleKeyPressEvent(
|
||||||
WidgetKeyboardEvent* aKeyboardEvent) override;
|
WidgetKeyboardEvent* aKeyboardEvent) override;
|
||||||
virtual nsIContent* GetFocusedContent() override;
|
virtual nsIContent* GetFocusedContent() override;
|
||||||
|
|
@ -423,6 +424,7 @@ class HTMLEditor final : public TextEditor,
|
||||||
* activation of an inline table editing UI element
|
* activation of an inline table editing UI element
|
||||||
* @param aUIAnonymousElement [IN] the inline table editing UI element
|
* @param aUIAnonymousElement [IN] the inline table editing UI element
|
||||||
*/
|
*/
|
||||||
|
MOZ_CAN_RUN_SCRIPT
|
||||||
nsresult DoInlineTableEditingAction(const Element& aUIAnonymousElement);
|
nsresult DoInlineTableEditingAction(const Element& aUIAnonymousElement);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -641,6 +643,7 @@ class HTMLEditor final : public TextEditor,
|
||||||
* a cell which contains first selection range. This does not return
|
* a cell which contains first selection range. This does not return
|
||||||
* error even if selection is not in cell element, just does nothing.
|
* error even if selection is not in cell element, just does nothing.
|
||||||
*/
|
*/
|
||||||
|
MOZ_CAN_RUN_SCRIPT
|
||||||
nsresult DeleteTableCellContentsWithTransaction();
|
nsresult DeleteTableCellContentsWithTransaction();
|
||||||
|
|
||||||
void IsNextCharInNodeWhitespace(nsIContent* aContent, int32_t aOffset,
|
void IsNextCharInNodeWhitespace(nsIContent* aContent, int32_t aOffset,
|
||||||
|
|
@ -964,6 +967,7 @@ class HTMLEditor final : public TextEditor,
|
||||||
*
|
*
|
||||||
* @param aContentToSelect The content which should be selected.
|
* @param aContentToSelect The content which should be selected.
|
||||||
*/
|
*/
|
||||||
|
MOZ_CAN_RUN_SCRIPT
|
||||||
nsresult SelectContentInternal(nsIContent& aContentToSelect);
|
nsresult SelectContentInternal(nsIContent& aContentToSelect);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -1665,6 +1669,7 @@ class HTMLEditor final : public TextEditor,
|
||||||
*/
|
*/
|
||||||
bool SetCaretInTableCell(dom::Element* aElement);
|
bool SetCaretInTableCell(dom::Element* aElement);
|
||||||
|
|
||||||
|
MOZ_CAN_RUN_SCRIPT
|
||||||
nsresult TabInTable(bool inIsShift, bool* outHandled);
|
nsresult TabInTable(bool inIsShift, bool* outHandled);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -1696,6 +1701,7 @@ class HTMLEditor final : public TextEditor,
|
||||||
* @param aInsertPosition Before or after the target cell which
|
* @param aInsertPosition Before or after the target cell which
|
||||||
* contains first selection range.
|
* contains first selection range.
|
||||||
*/
|
*/
|
||||||
|
MOZ_CAN_RUN_SCRIPT
|
||||||
nsresult InsertTableCellsWithTransaction(int32_t aNumberOfCellsToInsert,
|
nsresult InsertTableCellsWithTransaction(int32_t aNumberOfCellsToInsert,
|
||||||
InsertPosition aInsertPosition);
|
InsertPosition aInsertPosition);
|
||||||
|
|
||||||
|
|
@ -1711,6 +1717,7 @@ class HTMLEditor final : public TextEditor,
|
||||||
* @param aInsertPosition Before or after the target cell which
|
* @param aInsertPosition Before or after the target cell which
|
||||||
* contains first selection range.
|
* contains first selection range.
|
||||||
*/
|
*/
|
||||||
|
MOZ_CAN_RUN_SCRIPT
|
||||||
nsresult InsertTableColumnsWithTransaction(int32_t aNumberOfColumnsToInsert,
|
nsresult InsertTableColumnsWithTransaction(int32_t aNumberOfColumnsToInsert,
|
||||||
InsertPosition aInsertPosition);
|
InsertPosition aInsertPosition);
|
||||||
|
|
||||||
|
|
@ -1726,6 +1733,7 @@ class HTMLEditor final : public TextEditor,
|
||||||
* @param aInsertPosition Before or after the target cell which
|
* @param aInsertPosition Before or after the target cell which
|
||||||
* contains first selection range.
|
* contains first selection range.
|
||||||
*/
|
*/
|
||||||
|
MOZ_CAN_RUN_SCRIPT
|
||||||
nsresult InsertTableRowsWithTransaction(int32_t aNumberOfRowsToInsert,
|
nsresult InsertTableRowsWithTransaction(int32_t aNumberOfRowsToInsert,
|
||||||
InsertPosition aInsertPosition);
|
InsertPosition aInsertPosition);
|
||||||
|
|
||||||
|
|
@ -1755,6 +1763,7 @@ class HTMLEditor final : public TextEditor,
|
||||||
* ignored if 2 ore more cells are
|
* ignored if 2 ore more cells are
|
||||||
* selected.
|
* selected.
|
||||||
*/
|
*/
|
||||||
|
MOZ_CAN_RUN_SCRIPT
|
||||||
nsresult DeleteSelectedTableColumnsWithTransaction(
|
nsresult DeleteSelectedTableColumnsWithTransaction(
|
||||||
int32_t aNumberOfColumnsToDelete);
|
int32_t aNumberOfColumnsToDelete);
|
||||||
|
|
||||||
|
|
@ -1770,6 +1779,7 @@ class HTMLEditor final : public TextEditor,
|
||||||
* @param aRowIndex Index of the column which you want to remove.
|
* @param aRowIndex Index of the column which you want to remove.
|
||||||
* 0 is the first column.
|
* 0 is the first column.
|
||||||
*/
|
*/
|
||||||
|
MOZ_CAN_RUN_SCRIPT
|
||||||
nsresult DeleteTableColumnWithTransaction(Element& aTableElement,
|
nsresult DeleteTableColumnWithTransaction(Element& aTableElement,
|
||||||
int32_t aColumnIndex);
|
int32_t aColumnIndex);
|
||||||
|
|
||||||
|
|
@ -1788,6 +1798,7 @@ class HTMLEditor final : public TextEditor,
|
||||||
* @param aNumberOfRowsToDelete Number of rows to remove. This is ignored
|
* @param aNumberOfRowsToDelete Number of rows to remove. This is ignored
|
||||||
* if 2 or more cells are selected.
|
* if 2 or more cells are selected.
|
||||||
*/
|
*/
|
||||||
|
MOZ_CAN_RUN_SCRIPT
|
||||||
nsresult DeleteSelectedTableRowsWithTransaction(
|
nsresult DeleteSelectedTableRowsWithTransaction(
|
||||||
int32_t aNumberOfRowsToDelete);
|
int32_t aNumberOfRowsToDelete);
|
||||||
|
|
||||||
|
|
@ -1802,6 +1813,7 @@ class HTMLEditor final : public TextEditor,
|
||||||
* @param aRowIndex Index of the <tr> element which you want to
|
* @param aRowIndex Index of the <tr> element which you want to
|
||||||
* remove. 0 is the first row.
|
* remove. 0 is the first row.
|
||||||
*/
|
*/
|
||||||
|
MOZ_CAN_RUN_SCRIPT
|
||||||
nsresult DeleteTableRowWithTransaction(Element& aTableElement,
|
nsresult DeleteTableRowWithTransaction(Element& aTableElement,
|
||||||
int32_t aRowIndex);
|
int32_t aRowIndex);
|
||||||
|
|
||||||
|
|
@ -1819,6 +1831,7 @@ class HTMLEditor final : public TextEditor,
|
||||||
* @param aNumberOfCellsToDelete Number of cells to remove. This is ignored
|
* @param aNumberOfCellsToDelete Number of cells to remove. This is ignored
|
||||||
* if 2 or more cells are selected.
|
* if 2 or more cells are selected.
|
||||||
*/
|
*/
|
||||||
|
MOZ_CAN_RUN_SCRIPT
|
||||||
nsresult DeleteTableCellWithTransaction(int32_t aNumberOfCellsToDelete);
|
nsresult DeleteTableCellWithTransaction(int32_t aNumberOfCellsToDelete);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -2122,6 +2135,7 @@ class HTMLEditor final : public TextEditor,
|
||||||
* AutoSelectionSetterAfterTableEdit stack-based object to
|
* AutoSelectionSetterAfterTableEdit stack-based object to
|
||||||
* insure we reset the caret in a table-editing method.
|
* insure we reset the caret in a table-editing method.
|
||||||
*/
|
*/
|
||||||
|
MOZ_CAN_RUN_SCRIPT
|
||||||
void SetSelectionAfterTableEdit(Element* aTable, int32_t aRow, int32_t aCol,
|
void SetSelectionAfterTableEdit(Element* aTable, int32_t aRow, int32_t aCol,
|
||||||
int32_t aDirection, bool aSelected);
|
int32_t aDirection, bool aSelected);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -258,7 +258,7 @@ nsresult HTMLEditorEventListener::MouseDown(MouseEvent* aMouseEvent) {
|
||||||
WidgetMouseEvent* mousedownEvent =
|
WidgetMouseEvent* mousedownEvent =
|
||||||
aMouseEvent->WidgetEventPtr()->AsMouseEvent();
|
aMouseEvent->WidgetEventPtr()->AsMouseEvent();
|
||||||
|
|
||||||
HTMLEditor* htmlEditor = mEditorBase->AsHTMLEditor();
|
RefPtr<HTMLEditor> htmlEditor = mEditorBase->AsHTMLEditor();
|
||||||
MOZ_ASSERT(htmlEditor);
|
MOZ_ASSERT(htmlEditor);
|
||||||
|
|
||||||
// Contenteditable should disregard mousedowns outside it.
|
// Contenteditable should disregard mousedowns outside it.
|
||||||
|
|
|
||||||
|
|
@ -63,10 +63,12 @@ class MOZ_STACK_CLASS AutoSelectionSetterAfterTableEdit final {
|
||||||
mDirection(aDirection),
|
mDirection(aDirection),
|
||||||
mSelected(aSelected) {}
|
mSelected(aSelected) {}
|
||||||
|
|
||||||
|
MOZ_CAN_RUN_SCRIPT
|
||||||
~AutoSelectionSetterAfterTableEdit() {
|
~AutoSelectionSetterAfterTableEdit() {
|
||||||
if (mHTMLEditor) {
|
if (mHTMLEditor) {
|
||||||
mHTMLEditor->SetSelectionAfterTableEdit(mTable, mRow, mCol, mDirection,
|
MOZ_KnownLive(mHTMLEditor)
|
||||||
mSelected);
|
->SetSelectionAfterTableEdit(MOZ_KnownLive(mTable), mRow, mCol,
|
||||||
|
mDirection, mSelected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1705,20 +1705,14 @@ nsresult TextEditRules::HideLastPasswordInputInternal() {
|
||||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||||
return NS_ERROR_EDITOR_DESTROYED;
|
return NS_ERROR_EDITOR_DESTROYED;
|
||||||
}
|
}
|
||||||
// XXXbz Selection::Collapse/Extend take int32_t, but there are tons of
|
IgnoredErrorResult ignoredError;
|
||||||
// callsites... Converting all that is a battle for another day.
|
MOZ_KnownLive(SelectionRefPtr())
|
||||||
DebugOnly<nsresult> rv = SelectionRefPtr()->Collapse(selNode, start);
|
->SetStartAndEndInLimiter(RawRangeBoundary(selNode, start),
|
||||||
|
RawRangeBoundary(selNode, end), ignoredError);
|
||||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
if (NS_WARN_IF(!CanHandleEditAction())) {
|
||||||
return NS_ERROR_EDITOR_DESTROYED;
|
return NS_ERROR_EDITOR_DESTROYED;
|
||||||
}
|
}
|
||||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Failed to collapse selection");
|
NS_WARNING_ASSERTION(!ignoredError.Failed(), "Failed to set selection");
|
||||||
if (start != end) {
|
|
||||||
rv = SelectionRefPtr()->Extend(selNode, end);
|
|
||||||
if (NS_WARN_IF(!CanHandleEditAction())) {
|
|
||||||
return NS_ERROR_EDITOR_DESTROYED;
|
|
||||||
}
|
|
||||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Failed to extend selection");
|
|
||||||
}
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -105,6 +105,7 @@ class TextEditor : public EditorBase, public nsIPlaintextEditor {
|
||||||
return NS_SUCCEEDED(rv) && isEmpty;
|
return NS_SUCCEEDED(rv) && isEmpty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MOZ_CAN_RUN_SCRIPT
|
||||||
virtual nsresult HandleKeyPressEvent(
|
virtual nsresult HandleKeyPressEvent(
|
||||||
WidgetKeyboardEvent* aKeyboardEvent) override;
|
WidgetKeyboardEvent* aKeyboardEvent) override;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ interface nsIEditorSpellCheck : nsISupports
|
||||||
*
|
*
|
||||||
* @see mozSpellChecker::GetNextMisspelledWord
|
* @see mozSpellChecker::GetNextMisspelledWord
|
||||||
*/
|
*/
|
||||||
|
[can_run_script]
|
||||||
AString GetNextMisspelledWord();
|
AString GetNextMisspelledWord();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -64,6 +65,7 @@ interface nsIEditorSpellCheck : nsISupports
|
||||||
*
|
*
|
||||||
* @see mozSpellChecker::CheckCurrentWord
|
* @see mozSpellChecker::CheckCurrentWord
|
||||||
*/
|
*/
|
||||||
|
[can_run_script]
|
||||||
void ReplaceWord(in AString misspelledWord, in AString replaceWord, in boolean allOccurrences);
|
void ReplaceWord(in AString misspelledWord, in AString replaceWord, in boolean allOccurrences);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -183,6 +183,7 @@ interface nsIHTMLEditor : nsISupports
|
||||||
*
|
*
|
||||||
* @param aElement An element in the document
|
* @param aElement An element in the document
|
||||||
*/
|
*/
|
||||||
|
[can_run_script]
|
||||||
void selectElement(in Element aElement);
|
void selectElement(in Element aElement);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ interface nsITableEditor : nsISupports
|
||||||
* before current cell. Otherwise, will
|
* before current cell. Otherwise, will
|
||||||
* be inserted after the cell.
|
* be inserted after the cell.
|
||||||
*/
|
*/
|
||||||
|
[can_run_script]
|
||||||
void insertTableCell(in long aNumberOfColumnsToInsert,
|
void insertTableCell(in long aNumberOfColumnsToInsert,
|
||||||
in boolean aInsertAfterSelectedCell);
|
in boolean aInsertAfterSelectedCell);
|
||||||
|
|
||||||
|
|
@ -52,6 +53,7 @@ interface nsITableEditor : nsISupports
|
||||||
* before current cell. Otherwise, will
|
* before current cell. Otherwise, will
|
||||||
* be inserted after the cell.
|
* be inserted after the cell.
|
||||||
*/
|
*/
|
||||||
|
[can_run_script]
|
||||||
void insertTableColumn(in long aNumberOfColumnsToInsert,
|
void insertTableColumn(in long aNumberOfColumnsToInsert,
|
||||||
in boolean aInsertAfterSelectedCell);
|
in boolean aInsertAfterSelectedCell);
|
||||||
|
|
||||||
|
|
@ -67,6 +69,7 @@ interface nsITableEditor : nsISupports
|
||||||
* before current cell. Otherwise, will
|
* before current cell. Otherwise, will
|
||||||
* be inserted after the cell.
|
* be inserted after the cell.
|
||||||
*/
|
*/
|
||||||
|
[can_run_script]
|
||||||
void insertTableRow(in long aNumberOfRowsToInsert,
|
void insertTableRow(in long aNumberOfRowsToInsert,
|
||||||
in boolean aInsertAfterSelectedCell);
|
in boolean aInsertAfterSelectedCell);
|
||||||
|
|
||||||
|
|
@ -80,6 +83,7 @@ interface nsITableEditor : nsISupports
|
||||||
*
|
*
|
||||||
* @param aNumber Number of items to insert/delete
|
* @param aNumber Number of items to insert/delete
|
||||||
*/
|
*/
|
||||||
|
[can_run_script]
|
||||||
void deleteTable();
|
void deleteTable();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -89,6 +93,7 @@ interface nsITableEditor : nsISupports
|
||||||
* first selection range. This does nothing without exception if selection
|
* first selection range. This does nothing without exception if selection
|
||||||
* is not in cell element.
|
* is not in cell element.
|
||||||
*/
|
*/
|
||||||
|
[can_run_script]
|
||||||
void deleteTableCellContents();
|
void deleteTableCellContents();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -105,6 +110,7 @@ interface nsITableEditor : nsISupports
|
||||||
* @param aNumberOfCellsToDelete Number of cells to remove. This is ignored
|
* @param aNumberOfCellsToDelete Number of cells to remove. This is ignored
|
||||||
* if 2 or more cells are selected.
|
* if 2 or more cells are selected.
|
||||||
*/
|
*/
|
||||||
|
[can_run_script]
|
||||||
void deleteTableCell(in long aNumberOfCellsToDelete);
|
void deleteTableCell(in long aNumberOfCellsToDelete);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -124,6 +130,7 @@ interface nsITableEditor : nsISupports
|
||||||
* ignored if 2 ore more cells are
|
* ignored if 2 ore more cells are
|
||||||
* selected.
|
* selected.
|
||||||
*/
|
*/
|
||||||
|
[can_run_script]
|
||||||
void deleteTableColumn(in long aNumberOfColumnsToDelete);
|
void deleteTableColumn(in long aNumberOfColumnsToDelete);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -141,12 +148,14 @@ interface nsITableEditor : nsISupports
|
||||||
* @param aNumberOfRowsToDelete Number of rows to remove. This is ignored
|
* @param aNumberOfRowsToDelete Number of rows to remove. This is ignored
|
||||||
* if 2 or more cells are selected.
|
* if 2 or more cells are selected.
|
||||||
*/
|
*/
|
||||||
|
[can_run_script]
|
||||||
void deleteTableRow(in long aNumberOfRowsToDelete);
|
void deleteTableRow(in long aNumberOfRowsToDelete);
|
||||||
|
|
||||||
/** Table Selection methods
|
/** Table Selection methods
|
||||||
* Selecting a row or column actually
|
* Selecting a row or column actually
|
||||||
* selects all cells (not TR in the case of rows)
|
* selects all cells (not TR in the case of rows)
|
||||||
*/
|
*/
|
||||||
|
[can_run_script]
|
||||||
void selectTableCell();
|
void selectTableCell();
|
||||||
|
|
||||||
/** Select a rectangular block of cells:
|
/** Select a rectangular block of cells:
|
||||||
|
|
@ -157,12 +166,17 @@ interface nsITableEditor : nsISupports
|
||||||
* @param aStartCell starting cell in block
|
* @param aStartCell starting cell in block
|
||||||
* @param aEndCell ending cell in block
|
* @param aEndCell ending cell in block
|
||||||
*/
|
*/
|
||||||
|
[can_run_script]
|
||||||
void selectBlockOfCells(in Element aStartCell,
|
void selectBlockOfCells(in Element aStartCell,
|
||||||
in Element aEndCell);
|
in Element aEndCell);
|
||||||
|
|
||||||
|
[can_run_script]
|
||||||
void selectTableRow();
|
void selectTableRow();
|
||||||
|
[can_run_script]
|
||||||
void selectTableColumn();
|
void selectTableColumn();
|
||||||
|
[can_run_script]
|
||||||
void selectTable();
|
void selectTable();
|
||||||
|
[can_run_script]
|
||||||
void selectAllTableCells();
|
void selectAllTableCells();
|
||||||
|
|
||||||
/** Create a new TD or TH element, the opposite type of the supplied aSourceCell
|
/** Create a new TD or TH element, the opposite type of the supplied aSourceCell
|
||||||
|
|
@ -173,6 +187,7 @@ interface nsITableEditor : nsISupports
|
||||||
* @param aSourceCell The cell to be replaced
|
* @param aSourceCell The cell to be replaced
|
||||||
* @return The new cell that replaces aSourceCell
|
* @return The new cell that replaces aSourceCell
|
||||||
*/
|
*/
|
||||||
|
[can_run_script]
|
||||||
Element switchTableCellHeaderType(in Element aSourceCell);
|
Element switchTableCellHeaderType(in Element aSourceCell);
|
||||||
|
|
||||||
/** Merges contents of all selected cells
|
/** Merges contents of all selected cells
|
||||||
|
|
@ -195,6 +210,7 @@ interface nsITableEditor : nsISupports
|
||||||
* that cell and the one to the right
|
* that cell and the one to the right
|
||||||
* are merged
|
* are merged
|
||||||
*/
|
*/
|
||||||
|
[can_run_script]
|
||||||
void joinTableCells(in boolean aMergeNonContiguousContents);
|
void joinTableCells(in boolean aMergeNonContiguousContents);
|
||||||
|
|
||||||
/** Split a cell that has rowspan and/or colspan > 0
|
/** Split a cell that has rowspan and/or colspan > 0
|
||||||
|
|
@ -203,6 +219,7 @@ interface nsITableEditor : nsISupports
|
||||||
* All of the contents are not touched --
|
* All of the contents are not touched --
|
||||||
* they will appear to be in the upper-left cell
|
* they will appear to be in the upper-left cell
|
||||||
*/
|
*/
|
||||||
|
[can_run_script]
|
||||||
void splitTableCell();
|
void splitTableCell();
|
||||||
|
|
||||||
/** Scan through all rows and add cells as needed so
|
/** Scan through all rows and add cells as needed so
|
||||||
|
|
@ -215,6 +232,7 @@ interface nsITableEditor : nsISupports
|
||||||
* thus it can be used to fixup all tables
|
* thus it can be used to fixup all tables
|
||||||
* in a page independent of the selection
|
* in a page independent of the selection
|
||||||
*/
|
*/
|
||||||
|
[can_run_script]
|
||||||
void normalizeTable(in Element aTable);
|
void normalizeTable(in Element aTable);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -407,8 +407,9 @@ EditorSpellCheck::GetNextMisspelledWord(nsAString& aNextMisspelledWord) {
|
||||||
DeleteSuggestedWordList();
|
DeleteSuggestedWordList();
|
||||||
// Beware! This may flush notifications via synchronous
|
// Beware! This may flush notifications via synchronous
|
||||||
// ScrollSelectionIntoView.
|
// ScrollSelectionIntoView.
|
||||||
return mSpellChecker->NextMisspelledWord(aNextMisspelledWord,
|
RefPtr<mozSpellChecker> spellChecker(mSpellChecker);
|
||||||
&mSuggestedWordList);
|
return spellChecker->NextMisspelledWord(aNextMisspelledWord,
|
||||||
|
&mSuggestedWordList);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
|
@ -450,7 +451,8 @@ EditorSpellCheck::ReplaceWord(const nsAString& aMisspelledWord,
|
||||||
bool aAllOccurrences) {
|
bool aAllOccurrences) {
|
||||||
NS_ENSURE_TRUE(mSpellChecker, NS_ERROR_NOT_INITIALIZED);
|
NS_ENSURE_TRUE(mSpellChecker, NS_ERROR_NOT_INITIALIZED);
|
||||||
|
|
||||||
return mSpellChecker->Replace(aMisspelledWord, aReplaceWord, aAllOccurrences);
|
RefPtr<mozSpellChecker> spellChecker(mSpellChecker);
|
||||||
|
return spellChecker->Replace(aMisspelledWord, aReplaceWord, aAllOccurrences);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
|
|
||||||
|
|
@ -1666,7 +1666,10 @@ bool TextServicesDocument::IsTextNode(nsIContent* aContent) {
|
||||||
nsresult TextServicesDocument::SetSelectionInternal(int32_t aOffset,
|
nsresult TextServicesDocument::SetSelectionInternal(int32_t aOffset,
|
||||||
int32_t aLength,
|
int32_t aLength,
|
||||||
bool aDoUpdate) {
|
bool aDoUpdate) {
|
||||||
NS_ENSURE_TRUE(mSelCon && aOffset >= 0 && aLength >= 0, NS_ERROR_FAILURE);
|
if (NS_WARN_IF(!mSelCon) || NS_WARN_IF(aOffset < 0) ||
|
||||||
|
NS_WARN_IF(aLength < 0)) {
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsINode> startNode;
|
nsCOMPtr<nsINode> startNode;
|
||||||
int32_t startNodeOffset = 0;
|
int32_t startNodeOffset = 0;
|
||||||
|
|
@ -1728,26 +1731,22 @@ nsresult TextServicesDocument::SetSelectionInternal(int32_t aOffset,
|
||||||
// use it.
|
// use it.
|
||||||
|
|
||||||
RefPtr<Selection> selection;
|
RefPtr<Selection> selection;
|
||||||
|
|
||||||
if (aDoUpdate) {
|
if (aDoUpdate) {
|
||||||
selection = mSelCon->GetSelection(nsISelectionController::SELECTION_NORMAL);
|
selection = mSelCon->GetSelection(nsISelectionController::SELECTION_NORMAL);
|
||||||
NS_ENSURE_STATE(selection);
|
if (NS_WARN_IF(!selection)) {
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
nsresult rv = selection->Collapse(startNode, startNodeOffset);
|
}
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aLength <= 0) {
|
if (!aLength) {
|
||||||
// We have a collapsed selection. (Caret)
|
if (aDoUpdate) {
|
||||||
|
nsresult rv = selection->Collapse(startNode, startNodeOffset);
|
||||||
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
}
|
||||||
mSelEndIndex = mSelStartIndex;
|
mSelEndIndex = mSelStartIndex;
|
||||||
mSelEndOffset = mSelStartOffset;
|
mSelEndOffset = mSelStartOffset;
|
||||||
|
|
||||||
//**** KDEBUG ****
|
|
||||||
// printf("\n* Sel: (%2d, %4d) (%2d, %4d)\n", mSelStartIndex,
|
|
||||||
// mSelStartOffset, mSelEndIndex, mSelEndOffset);
|
|
||||||
//**** KDEBUG ****
|
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1780,18 +1779,22 @@ nsresult TextServicesDocument::SetSelectionInternal(int32_t aOffset,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aDoUpdate && endNode) {
|
if (!aDoUpdate) {
|
||||||
nsresult rv = selection->Extend(endNode, endNodeOffset);
|
return NS_OK;
|
||||||
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//**** KDEBUG ****
|
if (!endNode) {
|
||||||
// printf("\n * Sel: (%2d, %4d) (%2d, %4d)\n", mSelStartIndex,
|
nsresult rv = selection->Collapse(startNode, startNodeOffset);
|
||||||
// mSelStartOffset, mSelEndIndex, mSelEndOffset);
|
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Failed to collapse selection");
|
||||||
//**** KDEBUG ****
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
return NS_OK;
|
ErrorResult error;
|
||||||
|
selection->SetStartAndEndInLimiter(
|
||||||
|
RawRangeBoundary(startNode, startNodeOffset),
|
||||||
|
RawRangeBoundary(endNode, endNodeOffset), error);
|
||||||
|
NS_WARNING_ASSERTION(!error.Failed(), "Failed to set selection");
|
||||||
|
return error.StealNSResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult TextServicesDocument::GetSelection(BlockSelectionStatus* aSelStatus,
|
nsresult TextServicesDocument::GetSelection(BlockSelectionStatus* aSelStatus,
|
||||||
|
|
|
||||||
|
|
@ -150,6 +150,7 @@ class TextServicesDocument final : public nsIEditActionListener {
|
||||||
* @param aLength [OUT] This will contain the number of
|
* @param aLength [OUT] This will contain the number of
|
||||||
* characters that are selected in the string.
|
* characters that are selected in the string.
|
||||||
*/
|
*/
|
||||||
|
MOZ_CAN_RUN_SCRIPT
|
||||||
nsresult LastSelectedBlock(BlockSelectionStatus* aSelStatus,
|
nsresult LastSelectedBlock(BlockSelectionStatus* aSelStatus,
|
||||||
int32_t* aSelOffset, int32_t* aSelLength);
|
int32_t* aSelOffset, int32_t* aSelLength);
|
||||||
|
|
||||||
|
|
@ -189,6 +190,7 @@ class TextServicesDocument final : public nsIEditActionListener {
|
||||||
* GetCurrentTextBlock().
|
* GetCurrentTextBlock().
|
||||||
* @param aLength Number of characters selected.
|
* @param aLength Number of characters selected.
|
||||||
*/
|
*/
|
||||||
|
MOZ_CAN_RUN_SCRIPT
|
||||||
nsresult SetSelection(int32_t aOffset, int32_t aLength);
|
nsresult SetSelection(int32_t aOffset, int32_t aLength);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -201,12 +203,14 @@ class TextServicesDocument final : public nsIEditActionListener {
|
||||||
* with nothing selected, or with a collapsed selection (cursor) does
|
* with nothing selected, or with a collapsed selection (cursor) does
|
||||||
* nothing and returns NS_OK.
|
* nothing and returns NS_OK.
|
||||||
*/
|
*/
|
||||||
|
MOZ_CAN_RUN_SCRIPT
|
||||||
nsresult DeleteSelection();
|
nsresult DeleteSelection();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inserts the given text at the current cursor position. If there is a
|
* Inserts the given text at the current cursor position. If there is a
|
||||||
* selection, it will be deleted before the text is inserted.
|
* selection, it will be deleted before the text is inserted.
|
||||||
*/
|
*/
|
||||||
|
MOZ_CAN_RUN_SCRIPT
|
||||||
nsresult InsertText(const nsString* aText);
|
nsresult InsertText(const nsString* aText);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -267,10 +271,13 @@ class TextServicesDocument final : public nsIEditActionListener {
|
||||||
static bool HasSameBlockNodeParent(nsIContent* aContent1,
|
static bool HasSameBlockNodeParent(nsIContent* aContent1,
|
||||||
nsIContent* aContent2);
|
nsIContent* aContent2);
|
||||||
|
|
||||||
|
MOZ_CAN_RUN_SCRIPT
|
||||||
nsresult SetSelectionInternal(int32_t aOffset, int32_t aLength,
|
nsresult SetSelectionInternal(int32_t aOffset, int32_t aLength,
|
||||||
bool aDoUpdate);
|
bool aDoUpdate);
|
||||||
|
MOZ_CAN_RUN_SCRIPT
|
||||||
nsresult GetSelection(BlockSelectionStatus* aSelStatus, int32_t* aSelOffset,
|
nsresult GetSelection(BlockSelectionStatus* aSelStatus, int32_t* aSelOffset,
|
||||||
int32_t* aSelLength);
|
int32_t* aSelLength);
|
||||||
|
MOZ_CAN_RUN_SCRIPT
|
||||||
nsresult GetCollapsedSelection(BlockSelectionStatus* aSelStatus,
|
nsresult GetCollapsedSelection(BlockSelectionStatus* aSelStatus,
|
||||||
int32_t* aSelOffset, int32_t* aSelLength);
|
int32_t* aSelOffset, int32_t* aSelLength);
|
||||||
nsresult GetUncollapsedSelection(BlockSelectionStatus* aSelStatus,
|
nsresult GetUncollapsedSelection(BlockSelectionStatus* aSelStatus,
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,8 @@ nsresult mozSpellChecker::NextMisspelledWord(nsAString &aWord,
|
||||||
result = CheckWord(currWord, &isMisspelled, aSuggestions);
|
result = CheckWord(currWord, &isMisspelled, aSuggestions);
|
||||||
if (isMisspelled) {
|
if (isMisspelled) {
|
||||||
aWord = currWord;
|
aWord = currWord;
|
||||||
mTextServicesDocument->SetSelection(begin, end - begin);
|
MOZ_KnownLive(mTextServicesDocument)
|
||||||
|
->SetSelection(begin, end - begin);
|
||||||
// After ScrollSelectionIntoView(), the pending notifications might
|
// After ScrollSelectionIntoView(), the pending notifications might
|
||||||
// be flushed and PresShell/PresContext/Frames may be dead.
|
// be flushed and PresShell/PresContext/Frames may be dead.
|
||||||
// See bug 418470.
|
// See bug 418470.
|
||||||
|
|
@ -224,8 +225,9 @@ nsresult mozSpellChecker::Replace(const nsAString &aOldWord,
|
||||||
selOffset = begin;
|
selOffset = begin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mTextServicesDocument->SetSelection(begin, end - begin);
|
MOZ_KnownLive(mTextServicesDocument)
|
||||||
mTextServicesDocument->InsertText(&newWord);
|
->SetSelection(begin, end - begin);
|
||||||
|
MOZ_KnownLive(mTextServicesDocument)->InsertText(&newWord);
|
||||||
mTextServicesDocument->GetCurrentTextBlock(&str);
|
mTextServicesDocument->GetCurrentTextBlock(&str);
|
||||||
end += (aNewWord.Length() -
|
end += (aNewWord.Length() -
|
||||||
aOldWord.Length()); // recursion was cute in GEB, not here.
|
aOldWord.Length()); // recursion was cute in GEB, not here.
|
||||||
|
|
@ -267,13 +269,13 @@ nsresult mozSpellChecker::Replace(const nsAString &aOldWord,
|
||||||
result = mTextServicesDocument->GetCurrentTextBlock(&str);
|
result = mTextServicesDocument->GetCurrentTextBlock(&str);
|
||||||
result = mConverter->FindNextWord(str.get(), str.Length(), selOffset,
|
result = mConverter->FindNextWord(str.get(), str.Length(), selOffset,
|
||||||
&begin, &end);
|
&begin, &end);
|
||||||
mTextServicesDocument->SetSelection(begin, 0);
|
MOZ_KnownLive(mTextServicesDocument)->SetSelection(begin, 0);
|
||||||
} else {
|
} else {
|
||||||
mTextServicesDocument->SetSelection(begin, 0);
|
MOZ_KnownLive(mTextServicesDocument)->SetSelection(begin, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mTextServicesDocument->InsertText(&newWord);
|
MOZ_KnownLive(mTextServicesDocument)->InsertText(&newWord);
|
||||||
}
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
@ -461,8 +463,8 @@ nsresult mozSpellChecker::SetupDoc(int32_t *outBlockOffset) {
|
||||||
*outBlockOffset = 0;
|
*outBlockOffset = 0;
|
||||||
|
|
||||||
if (!mFromStart) {
|
if (!mFromStart) {
|
||||||
rv = mTextServicesDocument->LastSelectedBlock(&blockStatus, &selOffset,
|
rv = MOZ_KnownLive(mTextServicesDocument)
|
||||||
&selLength);
|
->LastSelectedBlock(&blockStatus, &selOffset, &selLength);
|
||||||
if (NS_SUCCEEDED(rv) &&
|
if (NS_SUCCEEDED(rv) &&
|
||||||
blockStatus !=
|
blockStatus !=
|
||||||
TextServicesDocument::BlockSelectionStatus::eBlockNotFound) {
|
TextServicesDocument::BlockSelectionStatus::eBlockNotFound) {
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@ class mozSpellChecker final {
|
||||||
* @param aSuggestions is an array of nsStrings, that represent the
|
* @param aSuggestions is an array of nsStrings, that represent the
|
||||||
* suggested replacements for the misspelled word.
|
* suggested replacements for the misspelled word.
|
||||||
*/
|
*/
|
||||||
|
MOZ_CAN_RUN_SCRIPT
|
||||||
nsresult NextMisspelledWord(nsAString& aWord,
|
nsresult NextMisspelledWord(nsAString& aWord,
|
||||||
nsTArray<nsString>* aSuggestions);
|
nsTArray<nsString>* aSuggestions);
|
||||||
|
|
||||||
|
|
@ -81,6 +82,7 @@ class mozSpellChecker final {
|
||||||
* word, in the document, with new word when it is true. If
|
* word, in the document, with new word when it is true. If
|
||||||
* false, it will replace the 1st occurrence only!
|
* false, it will replace the 1st occurrence only!
|
||||||
*/
|
*/
|
||||||
|
MOZ_CAN_RUN_SCRIPT
|
||||||
nsresult Replace(const nsAString& aOldWord, const nsAString& aNewWord,
|
nsresult Replace(const nsAString& aOldWord, const nsAString& aNewWord,
|
||||||
bool aAllOccurrences);
|
bool aAllOccurrences);
|
||||||
|
|
||||||
|
|
@ -162,6 +164,7 @@ class mozSpellChecker final {
|
||||||
|
|
||||||
nsString mCurrentDictionary;
|
nsString mCurrentDictionary;
|
||||||
|
|
||||||
|
MOZ_CAN_RUN_SCRIPT
|
||||||
nsresult SetupDoc(int32_t* outBlockOffset);
|
nsresult SetupDoc(int32_t* outBlockOffset);
|
||||||
|
|
||||||
nsresult GetCurrentBlockIndex(
|
nsresult GetCurrentBlockIndex(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue