mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 05:37:11 +00:00
import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1145395 - Make some cosmetic improvements to nsHTMLEditor::CreateDOMFragmentFromPaste; r=ehsan (b7b165297)
- Bug 1145395 - Return a DocumentFragment from nsHTMLEditor::ParseFragment; r=ehsan (05e314df6)
- Bug 1145395 - Use the local fragment variable rather than *outFragNode; r=ehsan (908366bc0)
- Bug 1145395 - Pass nsIContent& to nsHTMLEditor::StripFormattingNodes; r=ehsan (187bae854)
- Bug 1145395 - Pass nsINode& to RemoveBodyAndHead in nsHTMLDataTransfer; r=ehsan (1a2448d65)
- Bug 1169139 Remove all trailing whitespaces in editor (IGNORE IDL) r=ehsan (210ecf551)
- Bug 1067788 - Part 1: Don't invalidate bidi cursor directionality duing a delete. r=smontagu (c029b4271)
- Bug 1067788 - Part 2: Fixes to caret positioning in bidi text. r=smontagu (8fdb47aa7)
- Bug 1067788 - part 3: Fix timeouts in test_reftests_with_caret.html. r=ehsan (dfe0547d2)
- Bug 1067788 - Part 4: Update test_bug496275.html. Add setCaretBidiLevel method to Selection. r=smontagu r=ehsan (bcb737a2e)
- Bug 1067788 - Part 5: Fix for parts of test_bug496275.html. r=smontagu (885f2dc7e)
- Bug 1067788 - Fix non-unified bustage. r=ehsan (e141e2b81)
- remove thickcaret preference not in FF (d96cb3aee)
- Bug 1159263 - Add support to nsCaret to stop blinking after a set of cycles r=roc r=snorp (d07966610)
- Bug 988143 - Enable Gecko Touch in Fennec, SelectionController mods, r=ehsan (71de5c15e)
- Bug 988143 - Enable Gecko Touch in Fennec, Android specific nsCaret mods, r=ehsan (2a7b7058e)
- Bug 988143 - Enable Gecko Touch in Fennec, TouchCaret mods, r=ehsan (653a7d3be)
- Bug 988143 - Enable Gecko Touch in Fennec, TouchCaret Scroll mods, r=ehsan (8830df1cd)
- Bug 1153076 - Add NS_MOUSE_MOZLONGTAP support in Fennec, r=kats, tylin (bc14a39c5)
- Bug 988143 - Enable Gecko Touch in Fennec, SelectionCarets mods, r=ehsan (af5c15f7b)
- Bug 1164693 - Part 1: Directional caret should point in caret direction in bidi paragraphs. r=smontagu (2604fd0e1)
- Bug 1164693 - Part 2: Frames in a non-bidi paragraph with newline shouldn't be marked as bidi. r=smontagu (e1de49c9b)
- Bug 1143558 part 1 - Fix line break suppression when newline is significant. r=roc (adac6e4c3)
- Bug 1143558 part 2 - Convert suppressed line break to whitespace. r=roc (f36789322)
- Bug 1143558 part 3 - Reftests for line break suppression inside ruby. r=roc (4fadd0e17)
- Bug 1137723 - Don't call ::IsBoxWrapped(this) with the current mParent intact b/c IsBoxWrapped uses GetParent() and it may have been destroyed while this frame is still sitting an overflow list waiting to be lazy re-parented. r=roc (22a8806ba)
- Bug 1136010 - Don't coalesce style contexts added to RestyleManager::mContextsToClear. r=dbaron (81991b943)
- Bug 1146103 - Use NS_WARNING instead of MOZ_ASSERT for bcoord check in ruby text container. r=dbaron (ec1af437e)
- Bug 1146114 - Make assertion checking additional leading in ruby frame non-crash. r=dholbert (a775a1006)
- Bug 1146107 - Replace MOZ_ASSERT with NS_WARN_IF_FALSE on isize check in ruby base container. r=dholbert (705a4c8e5)
- Bug 1146103 followup - Add comment mentions upgrading warning and add crashtest for the assertion. (5820682fc)
- Bug 1172789 (part 1) - Remove PL_DHashTableEnumerate() uses from nsLoadGroup. r=michal. (73c3202f9)
- Bug 1172789 (part 2) - Remove PL_DHashTableEnumerate() uses from nsLoadGroup. r=michal. (6495530a4)
- Bug 1172789 (part 3) - Remove PL_DHashTableEnumerate() uses from nsLoadGroup. r=michal. (d8a17dd64)
- Bug 1173247 (part 1) - Remove PL_DHashTableEnumerate() uses from nsDiskCacheBindery. r=michal. (13b096297)
- Bug 1173247 (part 2) - Remove PL_DHashTableEnumerate() uses from nsDiskCacheBindery. r=michal. (290bb2093)
- Bug 1171830 - Remove PL_DHashTableEnumerator use from nsDocLoader. r=smaug. (3334d7120)
- Bug 1172761 (part 1) - Remove PL_DHashTableEnumerator use from nsAtomTable. r=froydnj. (7b3be498e)
- Bug 1172761 (part 2) - Remove PL_DHashTableEnumerator use from nsPersistentProperties. r=froydnj. (42f05514e)
- Bug 1174625 - Overhaul PLDHashTable's iterator. r=froydnj. (4e1efd69d)
- Bug 11746250 (follow-up) - Fix link errors on Linux and Android. r=me. (4a8ebc7df)
- Bug 1173600 (part 3) - Add PLDHashTable::RemovingIterator. r=froydnj. (7c01103c9)
- Bug 1174594 (part 1) - Remove uses of PL_DHashTableEnumerate from XPConnect. r=mrbkap. (4b2349650)
- Bug 1174594 (part 2) - Use a more sensible type for UNMARK_{ONLY,AND_SWEEP}. r=mrbkap. (4dc043f58)
- Bug 1174594 (part 3) - Remove ShutdownData. r=mrbkap. (0503b28cf)
This commit is contained in:
@@ -4017,9 +4017,8 @@ nsContentUtils::UnmarkGrayJSListenersInCCGenerationDocuments()
|
||||
return;
|
||||
}
|
||||
|
||||
PLDHashTable::Iterator iter(sEventListenerManagersHash);
|
||||
while (iter.HasMoreEntries()) {
|
||||
auto entry = static_cast<EventListenerManagerMapEntry*>(iter.NextEntry());
|
||||
for (auto i = sEventListenerManagersHash->Iter(); !i.Done(); i.Next()) {
|
||||
auto entry = static_cast<EventListenerManagerMapEntry*>(i.Get());
|
||||
nsINode* n = static_cast<nsINode*>(entry->mListenerManager->GetTarget());
|
||||
if (n && n->IsInDoc() &&
|
||||
nsCCUncollectableMarker::InGeneration(n->OwnerDoc()->GetMarkedCCGeneration())) {
|
||||
|
||||
+8
-12
@@ -1986,9 +1986,8 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsDocument)
|
||||
}
|
||||
|
||||
if (tmp->mSubDocuments) {
|
||||
PLDHashTable::Iterator iter(tmp->mSubDocuments);
|
||||
while (iter.HasMoreEntries()) {
|
||||
auto entry = static_cast<SubDocMapEntry*>(iter.NextEntry());
|
||||
for (auto iter = tmp->mSubDocuments->Iter(); !iter.Done(); iter.Next()) {
|
||||
auto entry = static_cast<SubDocMapEntry*>(iter.Get());
|
||||
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb,
|
||||
"mSubDocuments entry->mKey");
|
||||
@@ -4063,9 +4062,8 @@ nsDocument::FindContentForSubDocument(nsIDocument *aDocument) const
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PLDHashTable::Iterator iter(mSubDocuments);
|
||||
while (iter.HasMoreEntries()) {
|
||||
auto entry = static_cast<SubDocMapEntry*>(iter.NextEntry());
|
||||
for (auto iter = mSubDocuments->Iter(); !iter.Done(); iter.Next()) {
|
||||
auto entry = static_cast<SubDocMapEntry*>(iter.Get());
|
||||
if (entry->mSubDocument == aDocument) {
|
||||
return entry->mKey;
|
||||
}
|
||||
@@ -8712,9 +8710,8 @@ nsDocument::EnumerateSubDocuments(nsSubDocEnumFunc aCallback, void *aData)
|
||||
return;
|
||||
}
|
||||
|
||||
PLDHashTable::Iterator iter(mSubDocuments);
|
||||
while (iter.HasMoreEntries()) {
|
||||
auto entry = static_cast<SubDocMapEntry*>(iter.NextEntry());
|
||||
for (auto iter = mSubDocuments->Iter(); !iter.Done(); iter.Next()) {
|
||||
auto entry = static_cast<SubDocMapEntry*>(iter.Get());
|
||||
nsIDocument* subdoc = entry->mSubDocument;
|
||||
bool next = subdoc ? aCallback(subdoc, aData) : true;
|
||||
if (!next) {
|
||||
@@ -8814,9 +8811,8 @@ nsDocument::CanSavePresentation(nsIRequest *aNewRequest)
|
||||
}
|
||||
|
||||
if (mSubDocuments) {
|
||||
PLDHashTable::Iterator iter(mSubDocuments);
|
||||
while (iter.HasMoreEntries()) {
|
||||
auto entry = static_cast<SubDocMapEntry*>(iter.NextEntry());
|
||||
for (auto iter = mSubDocuments->Iter(); !iter.Done(); iter.Next()) {
|
||||
auto entry = static_cast<SubDocMapEntry*>(iter.Get());
|
||||
nsIDocument* subdoc = entry->mSubDocument;
|
||||
|
||||
// The aIgnoreRequest we were passed is only for us, so don't pass it on.
|
||||
|
||||
@@ -16,7 +16,7 @@ interface nsIDOMNode;
|
||||
interface nsISelection;
|
||||
interface nsISelectionDisplay;
|
||||
|
||||
[scriptable, uuid(7835DE46-DB36-4BB7-8684-1049A0C13049)]
|
||||
[scriptable, uuid(82c3a9df-9bd6-4da2-b561-d85a9eec5caa)]
|
||||
interface nsISelectionController : nsISelectionDisplay
|
||||
{
|
||||
const short SELECTION_NONE=0;
|
||||
@@ -266,6 +266,11 @@ interface nsISelectionController : nsISelectionDisplay
|
||||
boolean checkVisibility(in nsIDOMNode node, in short startOffset, in short endOffset);
|
||||
[noscript,nostdcall] boolean checkVisibilityContent(in nsIContent node, in short startOffset, in short endOffset);
|
||||
|
||||
/**
|
||||
* Returns the current visibility status of the selection carets, and allows
|
||||
* the visibility to be turned off, or on (if a selection exists).
|
||||
*/
|
||||
attribute boolean selectionCaretsVisibility;
|
||||
};
|
||||
%{ C++
|
||||
#define NS_ISELECTIONCONTROLLER_CID \
|
||||
|
||||
@@ -137,9 +137,8 @@ void
|
||||
nsPropertyTable::EnumerateAll(NSPropertyFunc aCallBack, void* aData)
|
||||
{
|
||||
for (PropertyList* prop = mPropertyList; prop; prop = prop->mNext) {
|
||||
PLDHashTable::Iterator iter(&prop->mObjectValueMap);
|
||||
while (iter.HasMoreEntries()) {
|
||||
auto entry = static_cast<PropertyListMapEntry*>(iter.NextEntry());
|
||||
for (auto iter = prop->mObjectValueMap.Iter(); !iter.Done(); iter.Next()) {
|
||||
auto entry = static_cast<PropertyListMapEntry*>(iter.Get());
|
||||
aCallBack(const_cast<void*>(entry->key), prop->mName, entry->value,
|
||||
aData);
|
||||
}
|
||||
@@ -285,9 +284,8 @@ nsPropertyTable::PropertyList::Destroy()
|
||||
{
|
||||
// Enumerate any remaining object/value pairs and destroy the value object.
|
||||
if (mDtorFunc) {
|
||||
PLDHashTable::Iterator iter(&mObjectValueMap);
|
||||
while (iter.HasMoreEntries()) {
|
||||
auto entry = static_cast<PropertyListMapEntry*>(iter.NextEntry());
|
||||
for (auto iter = mObjectValueMap.Iter(); !iter.Done(); iter.Next()) {
|
||||
auto entry = static_cast<PropertyListMapEntry*>(iter.Get());
|
||||
mDtorFunc(const_cast<void*>(entry->key), mName, entry->value, mDtorData);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -248,6 +248,9 @@ public:
|
||||
NS_IMETHOD CheckVisibility(nsIDOMNode *node, int16_t startOffset, int16_t EndOffset, bool* _retval) override;
|
||||
virtual nsresult CheckVisibilityContent(nsIContent* aNode, int16_t aStartOffset, int16_t aEndOffset, bool* aRetval) override;
|
||||
|
||||
NS_IMETHOD GetSelectionCaretsVisibility(bool* aOutVisibility) override;
|
||||
NS_IMETHOD SetSelectionCaretsVisibility(bool aVisibility) override;
|
||||
|
||||
private:
|
||||
nsRefPtr<nsFrameSelection> mFrameSelection;
|
||||
nsCOMPtr<nsIContent> mLimiter;
|
||||
@@ -644,6 +647,36 @@ nsTextInputSelectionImpl::CheckVisibility(nsIDOMNode *node, int16_t startOffset,
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTextInputSelectionImpl::GetSelectionCaretsVisibility(bool* aOutVisibility)
|
||||
{
|
||||
if (!mPresShellWeak) {
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
nsresult result;
|
||||
nsCOMPtr<nsISelectionController> shell = do_QueryReferent(mPresShellWeak, &result);
|
||||
if (shell) {
|
||||
return shell->GetSelectionCaretsVisibility(aOutVisibility);
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTextInputSelectionImpl::SetSelectionCaretsVisibility(bool aVisibility)
|
||||
{
|
||||
if (!mPresShellWeak) {
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
nsresult result;
|
||||
nsCOMPtr<nsISelectionController> shell = do_QueryReferent(mPresShellWeak, &result);
|
||||
if (shell) {
|
||||
return shell->SetSelectionCaretsVisibility(aVisibility);
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsTextInputSelectionImpl::CheckVisibilityContent(nsIContent* aNode,
|
||||
int16_t aStartOffset,
|
||||
|
||||
@@ -66,6 +66,9 @@ partial interface Selection {
|
||||
[ChromeOnly,Throws]
|
||||
attribute boolean interlinePosition;
|
||||
|
||||
[Throws]
|
||||
attribute short? caretBidiLevel;
|
||||
|
||||
[ChromeOnly,Throws]
|
||||
DOMString toStringWithFormat(DOMString formatType, unsigned long flags, long wrapColumn);
|
||||
[ChromeOnly,Throws]
|
||||
|
||||
@@ -24,7 +24,7 @@ public:
|
||||
// nsISupports interface...
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsITextServicesFilter
|
||||
// nsITextServicesFilter
|
||||
NS_DECL_NSITEXTSERVICESFILTER
|
||||
|
||||
// Helper - Intializer
|
||||
@@ -39,12 +39,12 @@ private:
|
||||
#define NS_COMPOSERTXTSRVFILTER_CID \
|
||||
{/* {171E72DB-0F8A-412a-8461-E4C927A3A2AC}*/ \
|
||||
0x171e72db, 0xf8a, 0x412a, \
|
||||
{ 0x84, 0x61, 0xe4, 0xc9, 0x27, 0xa3, 0xa2, 0xac} }
|
||||
{ 0x84, 0x61, 0xe4, 0xc9, 0x27, 0xa3, 0xa2, 0xac} }
|
||||
|
||||
#define NS_COMPOSERTXTSRVFILTERMAIL_CID \
|
||||
{/* {7FBD2146-5FF4-4674-B069-A7BBCE66E773}*/ \
|
||||
0x7fbd2146, 0x5ff4, 0x4674, \
|
||||
{ 0xb0, 0x69, 0xa7, 0xbb, 0xce, 0x66, 0xe7, 0x73} }
|
||||
{ 0xb0, 0x69, 0xa7, 0xbb, 0xce, 0x66, 0xe7, 0x73} }
|
||||
|
||||
// Generic for the editor
|
||||
#define COMPOSER_TXTSRVFILTER_CONTRACTID "@mozilla.org/editor/txtsrvfilter;1"
|
||||
|
||||
@@ -101,7 +101,7 @@ nsBaseStateUpdatingCommand::DoCommandParams(const char *aCommandName,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBaseStateUpdatingCommand::GetCommandStateParams(const char *aCommandName,
|
||||
nsBaseStateUpdatingCommand::GetCommandStateParams(const char *aCommandName,
|
||||
nsICommandParams *aParams,
|
||||
nsISupports *refCon)
|
||||
{
|
||||
@@ -113,15 +113,15 @@ nsBaseStateUpdatingCommand::GetCommandStateParams(const char *aCommandName,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPasteNoFormattingCommand::IsCommandEnabled(const char * aCommandName,
|
||||
nsISupports *refCon,
|
||||
nsPasteNoFormattingCommand::IsCommandEnabled(const char * aCommandName,
|
||||
nsISupports *refCon,
|
||||
bool *outCmdEnabled)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(outCmdEnabled);
|
||||
*outCmdEnabled = false;
|
||||
|
||||
// This command is only implemented by nsIHTMLEditor, since
|
||||
// pasting in a plaintext editor automatically only supplies
|
||||
// pasting in a plaintext editor automatically only supplies
|
||||
// "unformatted" text
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(refCon);
|
||||
NS_ENSURE_TRUE(htmlEditor, NS_ERROR_NOT_IMPLEMENTED);
|
||||
@@ -145,7 +145,7 @@ nsPasteNoFormattingCommand::DoCommand(const char *aCommandName,
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPasteNoFormattingCommand::DoCommandParams(const char *aCommandName,
|
||||
nsICommandParams *aParams,
|
||||
nsICommandParams *aParams,
|
||||
nsISupports *refCon)
|
||||
{
|
||||
return DoCommand(aCommandName, refCon);
|
||||
@@ -171,13 +171,13 @@ nsStyleUpdatingCommand::nsStyleUpdatingCommand(nsIAtom* aTagName)
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsStyleUpdatingCommand::GetCurrentState(nsIEditor *aEditor,
|
||||
nsStyleUpdatingCommand::GetCurrentState(nsIEditor *aEditor,
|
||||
nsICommandParams *aParams)
|
||||
{
|
||||
NS_ASSERTION(aEditor, "Need editor here");
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(aEditor);
|
||||
NS_ENSURE_TRUE(htmlEditor, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
|
||||
bool firstOfSelectionHasProp = false;
|
||||
bool anyOfSelectionHasProp = false;
|
||||
bool allOfSelectionHasProp = false;
|
||||
@@ -211,7 +211,7 @@ nsStyleUpdatingCommand::ToggleState(nsIEditor *aEditor)
|
||||
if (NS_FAILED(rv) || !params)
|
||||
return rv;
|
||||
|
||||
// tags "href" and "name" are special cases in the core editor
|
||||
// tags "href" and "name" are special cases in the core editor
|
||||
// they are used to remove named anchor/link and shouldn't be used for insertion
|
||||
bool doTagRemoval;
|
||||
if (mTagName == nsGkAtoms::href || mTagName == nsGkAtoms::name) {
|
||||
@@ -300,11 +300,11 @@ nsListCommand::ToggleState(nsIEditor *aEditor)
|
||||
|
||||
nsDependentAtomString listType(mTagName);
|
||||
if (inList) {
|
||||
rv = editor->RemoveList(listType);
|
||||
rv = editor->RemoveList(listType);
|
||||
} else {
|
||||
rv = editor->MakeOrChangeList(listType, false, EmptyString());
|
||||
}
|
||||
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
@@ -362,13 +362,13 @@ nsListItemCommand::ToggleState(nsIEditor *aEditor)
|
||||
rv = params->GetBooleanValue(STATE_ALL,&inList);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
||||
if (inList) {
|
||||
// To remove a list, first get what kind of list we're in
|
||||
bool bMixed;
|
||||
nsAutoString localName;
|
||||
rv = GetListState(htmlEditor, &bMixed, localName);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (localName.IsEmpty() || bMixed) {
|
||||
return rv;
|
||||
}
|
||||
@@ -424,11 +424,11 @@ nsRemoveListCommand::DoCommand(const char *aCommandName, nsISupports *refCon)
|
||||
rv = editor->RemoveList(EmptyString());
|
||||
}
|
||||
|
||||
return rv;
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRemoveListCommand::DoCommandParams(const char *aCommandName,
|
||||
nsRemoveListCommand::DoCommandParams(const char *aCommandName,
|
||||
nsICommandParams *aParams,
|
||||
nsISupports *refCon)
|
||||
{
|
||||
@@ -437,7 +437,7 @@ nsRemoveListCommand::DoCommandParams(const char *aCommandName,
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRemoveListCommand::GetCommandStateParams(const char *aCommandName,
|
||||
nsICommandParams *aParams,
|
||||
nsICommandParams *aParams,
|
||||
nsISupports *refCon)
|
||||
{
|
||||
bool outCmdEnabled = false;
|
||||
@@ -468,8 +468,8 @@ nsIndentCommand::DoCommand(const char *aCommandName, nsISupports *refCon)
|
||||
{
|
||||
rv = editor->Indent(NS_LITERAL_STRING("indent"));
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@@ -477,7 +477,7 @@ nsIndentCommand::DoCommandParams(const char *aCommandName,
|
||||
nsICommandParams *aParams,
|
||||
nsISupports *refCon)
|
||||
{
|
||||
return DoCommand(aCommandName, refCon);
|
||||
return DoCommand(aCommandName, refCon);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@@ -516,16 +516,16 @@ nsOutdentCommand::DoCommand(const char *aCommandName, nsISupports *refCon)
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(refCon);
|
||||
if (htmlEditor)
|
||||
return htmlEditor->Indent(NS_LITERAL_STRING("outdent"));
|
||||
|
||||
return NS_OK;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsOutdentCommand::DoCommandParams(const char *aCommandName,
|
||||
nsICommandParams *aParams,
|
||||
nsICommandParams *aParams,
|
||||
nsISupports *refCon)
|
||||
{
|
||||
return DoCommand(aCommandName, refCon);
|
||||
return DoCommand(aCommandName, refCon);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@@ -560,7 +560,7 @@ nsMultiStateCommand::IsCommandEnabled(const char * aCommandName,
|
||||
return editor->GetIsSelectionEditable(outCmdEnabled);
|
||||
|
||||
*outCmdEnabled = false;
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -571,8 +571,8 @@ nsMultiStateCommand::DoCommand(const char *aCommandName, nsISupports *refCon)
|
||||
printf("who is calling nsMultiStateCommand::DoCommand \
|
||||
(no implementation)? %s\n", aCommandName);
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@@ -598,8 +598,8 @@ nsMultiStateCommand::DoCommandParams(const char *aCommandName,
|
||||
|
||||
rv = SetState(editor, tString);
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@@ -626,7 +626,7 @@ nsParagraphStateCommand::GetCurrentState(nsIEditor *aEditor,
|
||||
nsICommandParams *aParams)
|
||||
{
|
||||
NS_ASSERTION(aEditor, "Need an editor here");
|
||||
|
||||
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(aEditor);
|
||||
NS_ENSURE_TRUE(htmlEditor, NS_ERROR_FAILURE);
|
||||
|
||||
@@ -685,7 +685,7 @@ nsFontFaceStateCommand::SetState(nsIEditor *aEditor, nsString& newState)
|
||||
NS_ASSERTION(aEditor, "Need an editor here");
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(aEditor);
|
||||
NS_ENSURE_TRUE(htmlEditor, NS_ERROR_FAILURE);
|
||||
|
||||
|
||||
if (newState.EqualsLiteral("tt")) {
|
||||
// The old "teletype" attribute
|
||||
nsresult rv = htmlEditor->SetInlineProperty(nsGkAtoms::tt, EmptyString(),
|
||||
@@ -788,7 +788,7 @@ nsFontColorStateCommand::GetCurrentState(nsIEditor *aEditor,
|
||||
nsICommandParams *aParams)
|
||||
{
|
||||
NS_ASSERTION(aEditor, "Need an editor here");
|
||||
|
||||
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(aEditor);
|
||||
NS_ENSURE_TRUE(htmlEditor, NS_ERROR_FAILURE);
|
||||
|
||||
@@ -810,12 +810,12 @@ nsFontColorStateCommand::SetState(nsIEditor *aEditor, nsString& newState)
|
||||
NS_ASSERTION(aEditor, "Need an editor here");
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(aEditor);
|
||||
NS_ENSURE_TRUE(htmlEditor, NS_ERROR_FAILURE);
|
||||
|
||||
|
||||
if (newState.IsEmpty() || newState.EqualsLiteral("normal")) {
|
||||
return htmlEditor->RemoveInlineProperty(nsGkAtoms::font,
|
||||
NS_LITERAL_STRING("color"));
|
||||
}
|
||||
|
||||
|
||||
return htmlEditor->SetInlineProperty(nsGkAtoms::font,
|
||||
NS_LITERAL_STRING("color"), newState);
|
||||
}
|
||||
@@ -886,7 +886,7 @@ nsBackgroundColorStateCommand::GetCurrentState(nsIEditor *aEditor,
|
||||
nsICommandParams *aParams)
|
||||
{
|
||||
NS_ASSERTION(aEditor, "Need an editor here");
|
||||
|
||||
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(aEditor);
|
||||
NS_ENSURE_TRUE(htmlEditor, NS_ERROR_FAILURE);
|
||||
|
||||
@@ -906,7 +906,7 @@ nsresult
|
||||
nsBackgroundColorStateCommand::SetState(nsIEditor *aEditor, nsString& newState)
|
||||
{
|
||||
NS_ASSERTION(aEditor, "Need an editor here");
|
||||
|
||||
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(aEditor);
|
||||
NS_ENSURE_TRUE(htmlEditor, NS_ERROR_FAILURE);
|
||||
|
||||
@@ -922,16 +922,16 @@ nsresult
|
||||
nsAlignCommand::GetCurrentState(nsIEditor *aEditor, nsICommandParams *aParams)
|
||||
{
|
||||
NS_ASSERTION(aEditor, "Need an editor here");
|
||||
|
||||
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(aEditor);
|
||||
NS_ENSURE_TRUE(htmlEditor, NS_ERROR_FAILURE);
|
||||
|
||||
|
||||
nsIHTMLEditor::EAlignment firstAlign;
|
||||
bool outMixed;
|
||||
nsresult rv = htmlEditor->GetAlignment(&outMixed, &firstAlign);
|
||||
|
||||
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
||||
nsAutoString outStateString;
|
||||
switch (firstAlign)
|
||||
{
|
||||
@@ -939,11 +939,11 @@ nsAlignCommand::GetCurrentState(nsIEditor *aEditor, nsICommandParams *aParams)
|
||||
case nsIHTMLEditor::eLeft:
|
||||
outStateString.AssignLiteral("left");
|
||||
break;
|
||||
|
||||
|
||||
case nsIHTMLEditor::eCenter:
|
||||
outStateString.AssignLiteral("center");
|
||||
break;
|
||||
|
||||
|
||||
case nsIHTMLEditor::eRight:
|
||||
outStateString.AssignLiteral("right");
|
||||
break;
|
||||
@@ -963,7 +963,7 @@ nsresult
|
||||
nsAlignCommand::SetState(nsIEditor *aEditor, nsString& newState)
|
||||
{
|
||||
NS_ASSERTION(aEditor, "Need an editor here");
|
||||
|
||||
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(aEditor);
|
||||
NS_ENSURE_TRUE(htmlEditor, NS_ERROR_FAILURE);
|
||||
|
||||
@@ -999,7 +999,7 @@ nsresult
|
||||
nsAbsolutePositioningCommand::GetCurrentState(nsIEditor *aEditor, nsICommandParams *aParams)
|
||||
{
|
||||
NS_ASSERTION(aEditor, "Need an editor here");
|
||||
|
||||
|
||||
nsCOMPtr<nsIHTMLAbsPosEditor> htmlEditor = do_QueryInterface(aEditor);
|
||||
NS_ENSURE_TRUE(htmlEditor, NS_ERROR_FAILURE);
|
||||
|
||||
@@ -1028,7 +1028,7 @@ nsresult
|
||||
nsAbsolutePositioningCommand::ToggleState(nsIEditor *aEditor)
|
||||
{
|
||||
NS_ASSERTION(aEditor, "Need an editor here");
|
||||
|
||||
|
||||
nsCOMPtr<nsIHTMLAbsPosEditor> htmlEditor = do_QueryInterface(aEditor);
|
||||
NS_ENSURE_TRUE(htmlEditor, NS_ERROR_FAILURE);
|
||||
|
||||
@@ -1077,7 +1077,7 @@ nsDecreaseZIndexCommand::DoCommand(const char *aCommandName,
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDecreaseZIndexCommand::DoCommandParams(const char *aCommandName,
|
||||
nsICommandParams *aParams,
|
||||
nsICommandParams *aParams,
|
||||
nsISupports *refCon)
|
||||
{
|
||||
return DoCommand(aCommandName, refCon);
|
||||
@@ -1127,7 +1127,7 @@ nsIncreaseZIndexCommand::DoCommand(const char *aCommandName,
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsIncreaseZIndexCommand::DoCommandParams(const char *aCommandName,
|
||||
nsICommandParams *aParams,
|
||||
nsICommandParams *aParams,
|
||||
nsISupports *refCon)
|
||||
{
|
||||
return DoCommand(aCommandName, refCon);
|
||||
@@ -1175,8 +1175,8 @@ nsRemoveStylesCommand::DoCommand(const char *aCommandName,
|
||||
{
|
||||
rv = editor->RemoveAllInlineProperties();
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@@ -1223,8 +1223,8 @@ nsIncreaseFontSizeCommand::DoCommand(const char *aCommandName,
|
||||
{
|
||||
rv = editor->IncreaseFontSize();
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@@ -1271,8 +1271,8 @@ nsDecreaseFontSizeCommand::DoCommand(const char *aCommandName,
|
||||
{
|
||||
rv = editor->DecreaseFontSize();
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@@ -1377,7 +1377,7 @@ nsInsertTagCommand::IsCommandEnabled(const char * aCommandName,
|
||||
}
|
||||
|
||||
|
||||
// corresponding STATE_ATTRIBUTE is: src (img) and href (a)
|
||||
// corresponding STATE_ATTRIBUTE is: src (img) and href (a)
|
||||
NS_IMETHODIMP
|
||||
nsInsertTagCommand::DoCommand(const char *aCmdName, nsISupports *refCon)
|
||||
{
|
||||
@@ -1513,7 +1513,7 @@ RemoveTextProperty(nsIHTMLEditor* aEditor, const nsAString& aProp)
|
||||
if (aProp.LowerCaseEqualsLiteral("all")) {
|
||||
return aEditor->RemoveAllInlineProperties();
|
||||
}
|
||||
|
||||
|
||||
return RemoveOneProperty(aEditor, aProp);
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ protected:
|
||||
|
||||
// get the current state (on or off) for this style or block format
|
||||
virtual nsresult GetCurrentState(nsIEditor* aEditor, nsICommandParams* aParams) = 0;
|
||||
|
||||
|
||||
// add/remove the style
|
||||
virtual nsresult ToggleState(nsIEditor* aEditor) = 0;
|
||||
|
||||
@@ -81,12 +81,12 @@ class nsStyleUpdatingCommand : public nsBaseStateUpdatingCommand
|
||||
{
|
||||
public:
|
||||
explicit nsStyleUpdatingCommand(nsIAtom* aTagName);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// get the current state (on or off) for this style or block format
|
||||
virtual nsresult GetCurrentState(nsIEditor* aEditor, nsICommandParams* aParams);
|
||||
|
||||
|
||||
// add/remove the style
|
||||
virtual nsresult ToggleState(nsIEditor* aEditor);
|
||||
};
|
||||
@@ -96,7 +96,7 @@ class nsInsertTagCommand : public nsBaseComposerCommand
|
||||
{
|
||||
public:
|
||||
explicit nsInsertTagCommand(nsIAtom* aTagName);
|
||||
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
NS_DECL_NSICONTROLLERCOMMAND
|
||||
@@ -117,7 +117,7 @@ protected:
|
||||
|
||||
// get the current state (on or off) for this style or block format
|
||||
virtual nsresult GetCurrentState(nsIEditor* aEditor, nsICommandParams* aParams);
|
||||
|
||||
|
||||
// add/remove the style
|
||||
virtual nsresult ToggleState(nsIEditor* aEditor);
|
||||
};
|
||||
@@ -131,7 +131,7 @@ protected:
|
||||
|
||||
// get the current state (on or off) for this style or block format
|
||||
virtual nsresult GetCurrentState(nsIEditor* aEditor, nsICommandParams* aParams);
|
||||
|
||||
|
||||
// add/remove the style
|
||||
virtual nsresult ToggleState(nsIEditor* aEditor);
|
||||
};
|
||||
@@ -140,9 +140,9 @@ protected:
|
||||
class nsMultiStateCommand : public nsBaseComposerCommand
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
nsMultiStateCommand();
|
||||
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSICONTROLLERCOMMAND
|
||||
|
||||
@@ -151,7 +151,7 @@ protected:
|
||||
|
||||
virtual nsresult GetCurrentState(nsIEditor *aEditor, nsICommandParams* aParams) =0;
|
||||
virtual nsresult SetState(nsIEditor *aEditor, nsString& newState) = 0;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ nsComposerCommandsUpdater::NotifyDocumentWillBeDestroyed()
|
||||
mUpdateTimer->Cancel();
|
||||
mUpdateTimer = nullptr;
|
||||
}
|
||||
|
||||
|
||||
// We can't call this right now; it is too late in some cases and the window
|
||||
// is already partially destructed (e.g. JS objects may be gone).
|
||||
#if 0
|
||||
@@ -114,11 +114,11 @@ nsComposerCommandsUpdater::DidDo(nsITransactionManager *aManager,
|
||||
UpdateCommandGroup(NS_LITERAL_STRING("undo"));
|
||||
mFirstDoOfFirstUndo = false;
|
||||
}
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsComposerCommandsUpdater::WillUndo(nsITransactionManager *aManager,
|
||||
nsITransaction *aTransaction,
|
||||
bool *aInterrupt)
|
||||
@@ -151,7 +151,7 @@ nsComposerCommandsUpdater::WillRedo(nsITransactionManager *aManager,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsComposerCommandsUpdater::DidRedo(nsITransactionManager *aManager,
|
||||
nsComposerCommandsUpdater::DidRedo(nsITransactionManager *aManager,
|
||||
nsITransaction *aTransaction,
|
||||
nsresult aRedoResult)
|
||||
{
|
||||
@@ -183,7 +183,7 @@ nsComposerCommandsUpdater::WillEndBatch(nsITransactionManager *aManager,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsComposerCommandsUpdater::DidEndBatch(nsITransactionManager *aManager,
|
||||
nsComposerCommandsUpdater::DidEndBatch(nsITransactionManager *aManager,
|
||||
nsresult aResult)
|
||||
{
|
||||
return NS_OK;
|
||||
@@ -277,7 +277,7 @@ nsComposerCommandsUpdater::UpdateCommandGroup(const nsAString& aCommandGroup)
|
||||
nsCOMPtr<nsPICommandUpdater> commandUpdater = GetCommandUpdater();
|
||||
NS_ENSURE_TRUE(commandUpdater, NS_ERROR_FAILURE);
|
||||
|
||||
|
||||
|
||||
// This hardcoded list of commands is temporary.
|
||||
// This code should use nsIControllerCommandGroup.
|
||||
if (aCommandGroup.EqualsLiteral("undo"))
|
||||
@@ -306,7 +306,7 @@ nsComposerCommandsUpdater::UpdateCommandGroup(const nsAString& aCommandGroup)
|
||||
commandUpdater->CommandStatusChanged("cmd_code");
|
||||
commandUpdater->CommandStatusChanged("cmd_samp");
|
||||
commandUpdater->CommandStatusChanged("cmd_var");
|
||||
|
||||
|
||||
commandUpdater->CommandStatusChanged("cmd_increaseFont");
|
||||
commandUpdater->CommandStatusChanged("cmd_decreaseFont");
|
||||
|
||||
@@ -315,14 +315,14 @@ nsComposerCommandsUpdater::UpdateCommandGroup(const nsAString& aCommandGroup)
|
||||
commandUpdater->CommandStatusChanged("cmd_fontColor");
|
||||
commandUpdater->CommandStatusChanged("cmd_backgroundColor");
|
||||
commandUpdater->CommandStatusChanged("cmd_highlight");
|
||||
}
|
||||
}
|
||||
else if (aCommandGroup.EqualsLiteral("save"))
|
||||
{
|
||||
// save commands (most are not in C++)
|
||||
commandUpdater->CommandStatusChanged("cmd_setDocumentModified");
|
||||
commandUpdater->CommandStatusChanged("cmd_save");
|
||||
}
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
@@ -333,7 +333,7 @@ nsComposerCommandsUpdater::UpdateOneCommand(const char *aCommand)
|
||||
|
||||
commandUpdater->CommandStatusChanged(aCommand);
|
||||
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool
|
||||
|
||||
@@ -35,10 +35,10 @@ public:
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
|
||||
// nsISelectionListener
|
||||
NS_DECL_NSISELECTIONLISTENER
|
||||
|
||||
|
||||
// nsIDocumentStateListener
|
||||
NS_DECL_NSIDOCUMENTSTATELISTENER
|
||||
|
||||
@@ -46,7 +46,7 @@ public:
|
||||
NS_DECL_NSITIMERCALLBACK
|
||||
|
||||
/** nsITransactionListener interfaces
|
||||
*/
|
||||
*/
|
||||
NS_IMETHOD WillDo(nsITransactionManager *aManager, nsITransaction *aTransaction, bool *aInterrupt) override;
|
||||
NS_IMETHOD DidDo(nsITransactionManager *aManager, nsITransaction *aTransaction, nsresult aDoResult) override;
|
||||
NS_IMETHOD WillUndo(nsITransactionManager *aManager, nsITransaction *aTransaction, bool *aInterrupt) override;
|
||||
@@ -75,24 +75,24 @@ protected:
|
||||
eStateOff = false,
|
||||
eStateOn = true
|
||||
};
|
||||
|
||||
|
||||
bool SelectionIsCollapsed();
|
||||
nsresult UpdateDirtyState(bool aNowDirty);
|
||||
nsresult UpdateDirtyState(bool aNowDirty);
|
||||
nsresult UpdateOneCommand(const char* aCommand);
|
||||
nsresult UpdateCommandGroup(const nsAString& aCommandGroup);
|
||||
|
||||
already_AddRefed<nsPICommandUpdater> GetCommandUpdater();
|
||||
|
||||
|
||||
nsresult PrimeUpdateTimer();
|
||||
void TimerCallback();
|
||||
nsCOMPtr<nsITimer> mUpdateTimer;
|
||||
|
||||
nsWeakPtr mDOMWindow;
|
||||
nsWeakPtr mDocShell;
|
||||
int8_t mDirtyState;
|
||||
int8_t mSelectionCollapsed;
|
||||
int8_t mDirtyState;
|
||||
int8_t mSelectionCollapsed;
|
||||
bool mFirstDoOfFirstUndo;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -40,14 +40,14 @@ class nsIControllerCommand;
|
||||
inCommandTable->RegisterCommand(_cmdName, \
|
||||
static_cast<nsIControllerCommand *>(theCmd)); \
|
||||
}
|
||||
|
||||
|
||||
#define NS_REGISTER_TAG_COMMAND(_cmdClass, _cmdName, _tagName) \
|
||||
{ \
|
||||
_cmdClass* theCmd = new _cmdClass(_tagName); \
|
||||
inCommandTable->RegisterCommand(_cmdName, \
|
||||
static_cast<nsIControllerCommand *>(theCmd)); \
|
||||
}
|
||||
|
||||
|
||||
|
||||
// static
|
||||
nsresult
|
||||
|
||||
@@ -14,7 +14,7 @@ class nsIControllerCommandTable;
|
||||
|
||||
// The plaintext editor controller is used for basic text editing and html editing
|
||||
// commands in composer
|
||||
// The refCon that gets passed to its commands is initially nsIEditingSession,
|
||||
// The refCon that gets passed to its commands is initially nsIEditingSession,
|
||||
// and after successfule editor creation it is changed to nsIEditor.
|
||||
#define NS_EDITORDOCSTATECONTROLLER_CID \
|
||||
{ 0x50e95301, 0x17a8, 0x11d4, { 0x9f, 0x7e, 0xdd, 0x53, 0x0d, 0x5f, 0x05, 0x7c } }
|
||||
|
||||
@@ -92,7 +92,7 @@ nsSetDocumentOptionsCommand::DoCommandParams(const char *aCommandName,
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_TRUE(presContext, NS_ERROR_FAILURE);
|
||||
|
||||
int32_t animationMode;
|
||||
int32_t animationMode;
|
||||
rv = aParams->GetLongValue("imageAnimation", &animationMode);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
@@ -101,7 +101,7 @@ nsSetDocumentOptionsCommand::DoCommandParams(const char *aCommandName,
|
||||
presContext->SetImageAnimationMode(animationMode);
|
||||
}
|
||||
|
||||
bool allowPlugins;
|
||||
bool allowPlugins;
|
||||
rv = aParams->GetBooleanValue("plugins", &allowPlugins);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
@@ -150,7 +150,7 @@ nsSetDocumentOptionsCommand::GetCommandStateParams(const char *aCommandName,
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
bool allowPlugins = false;
|
||||
bool allowPlugins = false;
|
||||
rv = aParams->GetBooleanValue("plugins", &allowPlugins);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
@@ -205,7 +205,7 @@ nsSetDocumentStateCommand::DoCommandParams(const char *aCommandName,
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aParams);
|
||||
|
||||
bool modified;
|
||||
bool modified;
|
||||
nsresult rv = aParams->GetBooleanValue(STATE_ATTRIBUTE, &modified);
|
||||
|
||||
// Should we fail if this param wasn't set?
|
||||
@@ -221,7 +221,7 @@ nsSetDocumentStateCommand::DoCommandParams(const char *aCommandName,
|
||||
if (!nsCRT::strcmp(aCommandName, "cmd_setDocumentReadOnly"))
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aParams);
|
||||
bool isReadOnly;
|
||||
bool isReadOnly;
|
||||
nsresult rvRO = aParams->GetBooleanValue(STATE_ATTRIBUTE, &isReadOnly);
|
||||
NS_ENSURE_SUCCESS(rvRO, rvRO);
|
||||
|
||||
@@ -376,7 +376,7 @@ nsSetDocumentStateCommand::GetCommandStateParams(const char *aCommandName,
|
||||
}
|
||||
|
||||
/**
|
||||
* Commands just for state notification
|
||||
* Commands just for state notification
|
||||
* As of 11/21/02, possible commands are:
|
||||
* "obs_documentCreated"
|
||||
* "obs_documentWillBeDestroyed"
|
||||
@@ -389,7 +389,7 @@ nsSetDocumentStateCommand::GetCommandStateParams(const char *aCommandName,
|
||||
* 1. Get the nsICommandManager for the current editor
|
||||
* 2. Implement an nsIObserve object, e.g:
|
||||
*
|
||||
* void Observe(
|
||||
* void Observe(
|
||||
* in nsISupports aSubject, // The nsICommandManager calling this Observer
|
||||
* in string aTopic, // command name, e.g.:"obs_documentCreated"
|
||||
* // or "obs_documentWillBeDestroyed"
|
||||
@@ -397,7 +397,7 @@ nsSetDocumentStateCommand::GetCommandStateParams(const char *aCommandName,
|
||||
*
|
||||
* 3. Add the observer by:
|
||||
* commandManager.addObserver(observeobject, obs_documentCreated);
|
||||
* 4. In the appropriate location in editorSession, editor, or commands code,
|
||||
* 4. In the appropriate location in editorSession, editor, or commands code,
|
||||
* trigger the notification of this observer by something like:
|
||||
*
|
||||
* nsCOMPtr<nsICommandManager> commandManager = do_GetInterface(mDocShell);
|
||||
@@ -406,8 +406,8 @@ nsSetDocumentStateCommand::GetCommandStateParams(const char *aCommandName,
|
||||
* commandUpdater->CommandStatusChanged(obs_documentCreated);
|
||||
*
|
||||
* 5. Use GetCommandStateParams() to obtain state information
|
||||
* e.g., any creation state codes when creating an editor are
|
||||
* supplied for "obs_documentCreated" command in the
|
||||
* e.g., any creation state codes when creating an editor are
|
||||
* supplied for "obs_documentCreated" command in the
|
||||
* "state_data" param's value
|
||||
*
|
||||
*/
|
||||
@@ -457,7 +457,7 @@ nsDocumentStateCommand::GetCommandStateParams(const char *aCommandName,
|
||||
// refCon is initially set to nsIEditingSession until editor
|
||||
// is successfully created and source doc is loaded
|
||||
// Embedder gets error status if this fails
|
||||
// If called before startup is finished,
|
||||
// If called before startup is finished,
|
||||
// status = eEditorCreationInProgress
|
||||
rv = editingSession->GetEditorStatus(&editorStatus);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
@@ -474,7 +474,7 @@ nsDocumentStateCommand::GetCommandStateParams(const char *aCommandName,
|
||||
// an nsIEditingSession or nsIEditor, we return "eEditorErrorUnknown"
|
||||
aParams->SetLongValue(STATE_DATA, editorStatus);
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
else if (!nsCRT::strcmp(aCommandName, "obs_documentLocationChanged"))
|
||||
{
|
||||
nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
|
||||
@@ -491,7 +491,7 @@ nsDocumentStateCommand::GetCommandStateParams(const char *aCommandName,
|
||||
return aParams->SetISupportsValue(STATE_DATA, (nsISupports*)uri);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ static NS_DEFINE_CID(kHTMLEditorDocStateCommandTableCID, NS_HTMLEDITOR_DOCSTATE_
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsEditingSession)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsEditorSpellCheck)
|
||||
|
||||
// There are no macros that enable us to have 2 constructors
|
||||
// There are no macros that enable us to have 2 constructors
|
||||
// for the same object
|
||||
//
|
||||
// Here we are creating the same object with two different contract IDs
|
||||
@@ -58,12 +58,12 @@ nsComposeTxtSrvFilterConstructor(nsISupports *aOuter, REFNSIID aIID,
|
||||
void **aResult, bool aIsForMail)
|
||||
{
|
||||
*aResult = nullptr;
|
||||
if (nullptr != aOuter)
|
||||
if (nullptr != aOuter)
|
||||
{
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
}
|
||||
nsComposeTxtSrvFilter * inst = new nsComposeTxtSrvFilter();
|
||||
if (nullptr == inst)
|
||||
if (nullptr == inst)
|
||||
{
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
@@ -75,7 +75,7 @@ nsComposeTxtSrvFilterConstructor(nsISupports *aOuter, REFNSIID aIID,
|
||||
}
|
||||
|
||||
static nsresult
|
||||
nsComposeTxtSrvFilterConstructorForComposer(nsISupports *aOuter,
|
||||
nsComposeTxtSrvFilterConstructorForComposer(nsISupports *aOuter,
|
||||
REFNSIID aIID,
|
||||
void **aResult)
|
||||
{
|
||||
@@ -83,7 +83,7 @@ nsComposeTxtSrvFilterConstructorForComposer(nsISupports *aOuter,
|
||||
}
|
||||
|
||||
static nsresult
|
||||
nsComposeTxtSrvFilterConstructorForMail(nsISupports *aOuter,
|
||||
nsComposeTxtSrvFilterConstructorForMail(nsISupports *aOuter,
|
||||
REFNSIID aIID,
|
||||
void **aResult)
|
||||
{
|
||||
@@ -95,7 +95,7 @@ nsComposeTxtSrvFilterConstructorForMail(nsISupports *aOuter,
|
||||
// by the CID passed in. This function uses do_GetService to get the
|
||||
// command table, so that every controller shares a single command
|
||||
// table, for space-efficiency.
|
||||
//
|
||||
//
|
||||
// The only reason to go via the service manager for the command table
|
||||
// is that it holds onto the singleton for us, avoiding static variables here.
|
||||
static nsresult
|
||||
@@ -107,16 +107,16 @@ CreateControllerWithSingletonCommandTable(const nsCID& inCommandTableCID, nsICon
|
||||
|
||||
nsCOMPtr<nsIControllerCommandTable> composerCommandTable = do_GetService(inCommandTableCID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
||||
// this guy is a singleton, so make it immutable
|
||||
composerCommandTable->MakeImmutable();
|
||||
|
||||
|
||||
nsCOMPtr<nsIControllerContext> controllerContext = do_QueryInterface(controller, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
||||
rv = controllerContext->Init(composerCommandTable);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
||||
*aResult = controller;
|
||||
NS_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
@@ -126,7 +126,7 @@ CreateControllerWithSingletonCommandTable(const nsCID& inCommandTableCID, nsICon
|
||||
// Here we make an instance of the controller that holds doc state commands.
|
||||
// We set it up with a singleton command table.
|
||||
static nsresult
|
||||
nsHTMLEditorDocStateControllerConstructor(nsISupports *aOuter, REFNSIID aIID,
|
||||
nsHTMLEditorDocStateControllerConstructor(nsISupports *aOuter, REFNSIID aIID,
|
||||
void **aResult)
|
||||
{
|
||||
nsCOMPtr<nsIController> controller;
|
||||
@@ -150,40 +150,40 @@ nsHTMLEditorControllerConstructor(nsISupports *aOuter, REFNSIID aIID, void **aRe
|
||||
|
||||
// Constructor for a command table that is pref-filled with HTML editor commands
|
||||
static nsresult
|
||||
nsHTMLEditorCommandTableConstructor(nsISupports *aOuter, REFNSIID aIID,
|
||||
nsHTMLEditorCommandTableConstructor(nsISupports *aOuter, REFNSIID aIID,
|
||||
void **aResult)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIControllerCommandTable> commandTable =
|
||||
do_CreateInstance(NS_CONTROLLERCOMMANDTABLE_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
||||
rv = nsComposerController::RegisterHTMLEditorCommands(commandTable);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
||||
// we don't know here whether we're being created as an instance,
|
||||
// or a service, so we can't become immutable
|
||||
|
||||
|
||||
return commandTable->QueryInterface(aIID, aResult);
|
||||
}
|
||||
|
||||
|
||||
// Constructor for a command table that is pref-filled with HTML editor doc state commands
|
||||
static nsresult
|
||||
nsHTMLEditorDocStateCommandTableConstructor(nsISupports *aOuter, REFNSIID aIID,
|
||||
nsHTMLEditorDocStateCommandTableConstructor(nsISupports *aOuter, REFNSIID aIID,
|
||||
void **aResult)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIControllerCommandTable> commandTable =
|
||||
do_CreateInstance(NS_CONTROLLERCOMMANDTABLE_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
||||
rv = nsComposerController::RegisterEditorDocStateCommands(commandTable);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
||||
// we don't know here whether we're being created as an instance,
|
||||
// or a service, so we can't become immutable
|
||||
|
||||
|
||||
return commandTable->QueryInterface(aIID, aResult);
|
||||
}
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ nsEditingSession::~nsEditingSession()
|
||||
mLoadBlankDocTimer->Cancel();
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsEditingSession, nsIEditingSession, nsIWebProgressListener,
|
||||
NS_IMPL_ISUPPORTS(nsEditingSession, nsIEditingSession, nsIWebProgressListener,
|
||||
nsISupportsWeakReference)
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
@@ -97,7 +97,7 @@ NS_IMPL_ISUPPORTS(nsEditingSession, nsIEditingSession, nsIWebProgressListener,
|
||||
MakeWindowEditable
|
||||
|
||||
aEditorType string, "html" "htmlsimple" "text" "textsimple"
|
||||
void makeWindowEditable(in nsIDOMWindow aWindow, in string aEditorType,
|
||||
void makeWindowEditable(in nsIDOMWindow aWindow, in string aEditorType,
|
||||
in boolean aDoAfterUriLoad,
|
||||
in boolean aMakeWholeDocumentEditable,
|
||||
in boolean aInteractive);
|
||||
@@ -106,7 +106,7 @@ NS_IMPL_ISUPPORTS(nsEditingSession, nsIEditingSession, nsIWebProgressListener,
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditingSession::MakeWindowEditable(nsIDOMWindow *aWindow,
|
||||
const char *aEditorType,
|
||||
const char *aEditorType,
|
||||
bool aDoAfterUriLoad,
|
||||
bool aMakeWholeDocumentEditable,
|
||||
bool aInteractive)
|
||||
@@ -130,7 +130,7 @@ nsEditingSession::MakeWindowEditable(nsIDOMWindow *aWindow,
|
||||
|
||||
// Always remove existing editor
|
||||
TearDownEditorOnWindow(aWindow);
|
||||
|
||||
|
||||
// Tells embedder that startup is in progress
|
||||
mEditorStatus = eEditorCreationInProgress;
|
||||
|
||||
@@ -139,14 +139,14 @@ nsEditingSession::MakeWindowEditable(nsIDOMWindow *aWindow,
|
||||
aEditorType = DEFAULT_EDITOR_TYPE;
|
||||
mEditorType = aEditorType;
|
||||
|
||||
// if all this does is setup listeners and I don't need listeners,
|
||||
// if all this does is setup listeners and I don't need listeners,
|
||||
// can't this step be ignored?? (based on aDoAfterURILoad)
|
||||
rv = PrepareForEditing(aWindow);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// set the flag on the docShell to say that it's editable
|
||||
rv = docShell->MakeEditable(aDoAfterUriLoad);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Setup commands common to plaintext and html editors,
|
||||
// including the document creation observers
|
||||
@@ -249,7 +249,7 @@ nsEditingSession::WindowIsEditable(nsIDOMWindow *aWindow, bool *outIsEditable)
|
||||
// These are MIME types that are automatically parsed as "text/plain"
|
||||
// and thus we can edit them as plaintext
|
||||
// Note: in older versions, we attempted to convert the mimetype of
|
||||
// the network channel for these and "text/xml" to "text/plain",
|
||||
// the network channel for these and "text/xml" to "text/plain",
|
||||
// but further investigation reveals that strategy doesn't work
|
||||
const char* const gSupportedTextTypes[] = {
|
||||
"text/plain",
|
||||
@@ -281,7 +281,7 @@ IsSupportedTextType(const char* aMIMEType)
|
||||
|
||||
i ++;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -348,13 +348,13 @@ nsEditingSession::SetupEditorOnWindow(nsIDOMWindow *aWindow)
|
||||
const char *classString = "@mozilla.org/editor/htmleditor;1";
|
||||
if (mEditorType.EqualsLiteral("textmail"))
|
||||
{
|
||||
mEditorFlags = nsIPlaintextEditor::eEditorPlaintextMask |
|
||||
nsIPlaintextEditor::eEditorEnableWrapHackMask |
|
||||
mEditorFlags = nsIPlaintextEditor::eEditorPlaintextMask |
|
||||
nsIPlaintextEditor::eEditorEnableWrapHackMask |
|
||||
nsIPlaintextEditor::eEditorMailMask;
|
||||
}
|
||||
else if (mEditorType.EqualsLiteral("text"))
|
||||
{
|
||||
mEditorFlags = nsIPlaintextEditor::eEditorPlaintextMask |
|
||||
mEditorFlags = nsIPlaintextEditor::eEditorPlaintextMask |
|
||||
nsIPlaintextEditor::eEditorEnableWrapHackMask;
|
||||
}
|
||||
else if (mEditorType.EqualsLiteral("htmlmail"))
|
||||
@@ -365,7 +365,7 @@ nsEditingSession::SetupEditorOnWindow(nsIDOMWindow *aWindow)
|
||||
mEditorFlags = nsIPlaintextEditor::eEditorMailMask;
|
||||
}
|
||||
else //set the flags back to textplain.
|
||||
mEditorFlags = nsIPlaintextEditor::eEditorPlaintextMask |
|
||||
mEditorFlags = nsIPlaintextEditor::eEditorPlaintextMask |
|
||||
nsIPlaintextEditor::eEditorEnableWrapHackMask;
|
||||
}
|
||||
else // Defaulted to html
|
||||
@@ -392,10 +392,10 @@ nsEditingSession::SetupEditorOnWindow(nsIDOMWindow *aWindow)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Create editor and do other things
|
||||
// Create editor and do other things
|
||||
// only if we haven't found some error above,
|
||||
nsCOMPtr<nsIDocShell> docShell = GetDocShellFromWindow(aWindow);
|
||||
NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
|
||||
NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
|
||||
nsCOMPtr<nsIPresShell> presShell = docShell->GetPresShell();
|
||||
NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);
|
||||
|
||||
@@ -447,7 +447,7 @@ nsEditingSession::SetupEditorOnWindow(nsIDOMWindow *aWindow)
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_TRUE(contentViewer, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
rv = contentViewer->GetDOMDocument(getter_AddRefs(domDoc));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_TRUE(domDoc, NS_ERROR_FAILURE);
|
||||
@@ -529,7 +529,7 @@ nsEditingSession::TearDownEditorOnWindow(nsIDOMWindow *aWindow)
|
||||
NS_ENSURE_TRUE(aWindow, NS_ERROR_NULL_POINTER);
|
||||
|
||||
nsresult rv;
|
||||
|
||||
|
||||
// Kill any existing reload timer
|
||||
if (mLoadBlankDocTimer)
|
||||
{
|
||||
@@ -549,7 +549,7 @@ nsEditingSession::TearDownEditorOnWindow(nsIDOMWindow *aWindow)
|
||||
|
||||
nsCOMPtr<nsIDocShell> docShell = GetDocShellFromWindow(aWindow);
|
||||
NS_ENSURE_STATE(docShell);
|
||||
|
||||
|
||||
nsCOMPtr<nsIEditor> editor;
|
||||
rv = docShell->GetEditor(getter_AddRefs(editor));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
@@ -559,7 +559,7 @@ nsEditingSession::TearDownEditorOnWindow(nsIDOMWindow *aWindow)
|
||||
|
||||
if (mStateMaintainer && editor)
|
||||
{
|
||||
// Null out the editor on the controllers first to prevent their weak
|
||||
// Null out the editor on the controllers first to prevent their weak
|
||||
// references from pointing to a destroyed editor.
|
||||
SetEditorOnControllers(aWindow, nullptr);
|
||||
}
|
||||
@@ -598,13 +598,13 @@ nsEditingSession::TearDownEditorOnWindow(nsIDOMWindow *aWindow)
|
||||
|
||||
nsIEditor getEditorForFrame (in nsIDOMWindow aWindow);
|
||||
----------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsEditingSession::GetEditorForWindow(nsIDOMWindow *aWindow,
|
||||
nsIEditor **outEditor)
|
||||
{
|
||||
nsCOMPtr<nsIDocShell> docShell = GetDocShellFromWindow(aWindow);
|
||||
NS_ENSURE_STATE(aWindow);
|
||||
|
||||
|
||||
return docShell->GetEditor(outEditor);
|
||||
}
|
||||
|
||||
@@ -798,7 +798,7 @@ nsEditingSession::OnProgressChange(nsIWebProgress *aWebProgress,
|
||||
|
||||
----------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP
|
||||
nsEditingSession::OnLocationChange(nsIWebProgress *aWebProgress,
|
||||
nsEditingSession::OnLocationChange(nsIWebProgress *aWebProgress,
|
||||
nsIRequest *aRequest, nsIURI *aURI,
|
||||
uint32_t aFlags)
|
||||
{
|
||||
@@ -876,8 +876,8 @@ nsEditingSession::IsProgressForTargetDocument(nsIWebProgress *aWebProgress)
|
||||
|
||||
GetEditorStatus
|
||||
|
||||
Called during GetCommandStateParams("obs_documentCreated"...)
|
||||
to determine if editor was created and document
|
||||
Called during GetCommandStateParams("obs_documentCreated"...)
|
||||
to determine if editor was created and document
|
||||
was loaded successfully
|
||||
----------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP
|
||||
@@ -895,7 +895,7 @@ nsEditingSession::GetEditorStatus(uint32_t *aStatus)
|
||||
Called on start of load in a single frame
|
||||
----------------------------------------------------------------------------*/
|
||||
nsresult
|
||||
nsEditingSession::StartDocumentLoad(nsIWebProgress *aWebProgress,
|
||||
nsEditingSession::StartDocumentLoad(nsIWebProgress *aWebProgress,
|
||||
bool aIsToBeMadeEditable)
|
||||
{
|
||||
#ifdef NOISY_DOC_LOADING
|
||||
@@ -903,7 +903,7 @@ nsEditingSession::StartDocumentLoad(nsIWebProgress *aWebProgress,
|
||||
#endif
|
||||
|
||||
NS_ENSURE_ARG_POINTER(aWebProgress);
|
||||
|
||||
|
||||
// If we have an editor here, then we got a reload after making the editor.
|
||||
// We need to blow it away and make a new one at the end of the load.
|
||||
nsCOMPtr<nsIDOMWindow> domWindow;
|
||||
@@ -914,7 +914,7 @@ nsEditingSession::StartDocumentLoad(nsIWebProgress *aWebProgress,
|
||||
NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
|
||||
docShell->DetachEditorFromWindow();
|
||||
}
|
||||
|
||||
|
||||
if (aIsToBeMadeEditable)
|
||||
mEditorStatus = eEditorCreationInProgress;
|
||||
|
||||
@@ -933,7 +933,7 @@ nsEditingSession::EndDocumentLoad(nsIWebProgress *aWebProgress,
|
||||
bool aIsToBeMadeEditable)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aWebProgress);
|
||||
|
||||
|
||||
#ifdef NOISY_DOC_LOADING
|
||||
printf("======= EndDocumentLoad ========\n");
|
||||
printf("with status %d, ", aStatus);
|
||||
@@ -948,12 +948,12 @@ nsEditingSession::EndDocumentLoad(nsIWebProgress *aWebProgress,
|
||||
// We want to call the base class EndDocumentLoad,
|
||||
// but avoid some of the stuff
|
||||
// that nsDocShell does (need to refactor).
|
||||
|
||||
|
||||
// OK, time to make an editor on this document
|
||||
nsCOMPtr<nsIDOMWindow> domWindow;
|
||||
aWebProgress->GetDOMWindow(getter_AddRefs(domWindow));
|
||||
|
||||
// Set the error state -- we will create an editor
|
||||
|
||||
// Set the error state -- we will create an editor
|
||||
// anyway and load empty doc later
|
||||
if (aIsToBeMadeEditable) {
|
||||
if (aStatus == NS_ERROR_FILE_NOT_FOUND)
|
||||
@@ -977,7 +977,7 @@ nsEditingSession::EndDocumentLoad(nsIWebProgress *aWebProgress,
|
||||
{
|
||||
bool makeEditable;
|
||||
docShell->GetEditable(&makeEditable);
|
||||
|
||||
|
||||
if (makeEditable)
|
||||
{
|
||||
// To keep pre Gecko 1.9 behavior, setup editor always when
|
||||
@@ -1007,7 +1007,7 @@ nsEditingSession::EndDocumentLoad(nsIWebProgress *aWebProgress,
|
||||
mLoadBlankDocTimer->Cancel();
|
||||
mLoadBlankDocTimer = nullptr;
|
||||
}
|
||||
|
||||
|
||||
mLoadBlankDocTimer = do_CreateInstance("@mozilla.org/timer;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
@@ -1071,15 +1071,15 @@ nsEditingSession::EndPageLoad(nsIWebProgress *aWebProgress,
|
||||
uri->GetSpec(spec);
|
||||
printf("uri %s\n", spec.get());
|
||||
}
|
||||
|
||||
|
||||
nsAutoCString contentType;
|
||||
aChannel->GetContentType(contentType);
|
||||
if (!contentType.IsEmpty())
|
||||
printf(" flags = %d, status = %d, MIMETYPE = %s\n",
|
||||
printf(" flags = %d, status = %d, MIMETYPE = %s\n",
|
||||
mEditorFlags, mEditorStatus, contentType.get());
|
||||
#endif
|
||||
|
||||
// Set the error state -- we will create an editor anyway
|
||||
// Set the error state -- we will create an editor anyway
|
||||
// and load empty doc later
|
||||
if (aStatus == NS_ERROR_FILE_NOT_FOUND)
|
||||
mEditorStatus = eEditorErrorFileNotFound;
|
||||
@@ -1131,16 +1131,16 @@ nsEditingSession::PrepareForEditing(nsIDOMWindow *aWindow)
|
||||
{
|
||||
if (mProgressListenerRegistered)
|
||||
return NS_OK;
|
||||
|
||||
|
||||
nsIDocShell *docShell = GetDocShellFromWindow(aWindow);
|
||||
|
||||
|
||||
// register callback
|
||||
nsCOMPtr<nsIWebProgress> webProgress = do_GetInterface(docShell);
|
||||
NS_ENSURE_TRUE(webProgress, NS_ERROR_FAILURE);
|
||||
|
||||
nsresult rv =
|
||||
webProgress->AddProgressListener(this,
|
||||
(nsIWebProgress::NOTIFY_STATE_NETWORK |
|
||||
(nsIWebProgress::NOTIFY_STATE_NETWORK |
|
||||
nsIWebProgress::NOTIFY_STATE_DOCUMENT |
|
||||
nsIWebProgress::NOTIFY_LOCATION));
|
||||
|
||||
@@ -1167,8 +1167,8 @@ nsEditingSession::SetupEditorCommandController(
|
||||
NS_ENSURE_ARG_POINTER(aWindow);
|
||||
NS_ENSURE_ARG_POINTER(aContext);
|
||||
NS_ENSURE_ARG_POINTER(aControllerId);
|
||||
|
||||
nsCOMPtr<nsIControllers> controllers;
|
||||
|
||||
nsCOMPtr<nsIControllers> controllers;
|
||||
nsresult rv = aWindow->GetControllers(getter_AddRefs(controllers));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
@@ -1178,18 +1178,18 @@ nsEditingSession::SetupEditorCommandController(
|
||||
{
|
||||
nsCOMPtr<nsIController> controller;
|
||||
controller = do_CreateInstance(aControllerClassName, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// We must insert at head of the list to be sure our
|
||||
// controller is found before other implementations
|
||||
// (e.g., not-implemented versions by browser)
|
||||
rv = controllers->InsertControllerAt(0, controller);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Remember the ID for the controller
|
||||
rv = controllers->GetControllerId(controller, aControllerId);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
// Set the context
|
||||
return SetContextOnControllerById(controllers, aContext, *aControllerId);
|
||||
@@ -1206,8 +1206,8 @@ nsEditingSession::SetEditorOnControllers(nsIDOMWindow *aWindow,
|
||||
nsIEditor* aEditor)
|
||||
{
|
||||
NS_ENSURE_TRUE(aWindow, NS_ERROR_NULL_POINTER);
|
||||
|
||||
nsCOMPtr<nsIControllers> controllers;
|
||||
|
||||
nsCOMPtr<nsIControllers> controllers;
|
||||
nsresult rv = aWindow->GetControllers(getter_AddRefs(controllers));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
@@ -1241,9 +1241,9 @@ nsEditingSession::SetContextOnControllerById(nsIControllers* aControllers,
|
||||
NS_ENSURE_ARG_POINTER(aControllers);
|
||||
|
||||
// aContext can be null (when destroying editor)
|
||||
nsCOMPtr<nsIController> controller;
|
||||
nsCOMPtr<nsIController> controller;
|
||||
aControllers->GetControllerById(aID, getter_AddRefs(controller));
|
||||
|
||||
|
||||
// ok with nil controller
|
||||
nsCOMPtr<nsIControllerContext> editorController =
|
||||
do_QueryInterface(controller);
|
||||
@@ -1255,7 +1255,7 @@ nsEditingSession::SetContextOnControllerById(nsIControllers* aControllers,
|
||||
void
|
||||
nsEditingSession::RemoveEditorControllers(nsIDOMWindow *aWindow)
|
||||
{
|
||||
// Remove editor controllers from the aWindow, call when we're
|
||||
// Remove editor controllers from the aWindow, call when we're
|
||||
// tearing down/detaching editor.
|
||||
|
||||
nsCOMPtr<nsIControllers> controllers;
|
||||
|
||||
@@ -56,7 +56,7 @@ public:
|
||||
|
||||
// nsIWebProgressListener
|
||||
NS_DECL_NSIWEBPROGRESSLISTENER
|
||||
|
||||
|
||||
// nsIEditingSession
|
||||
NS_DECL_NSIEDITINGSESSION
|
||||
|
||||
@@ -64,13 +64,13 @@ protected:
|
||||
virtual ~nsEditingSession();
|
||||
|
||||
nsIDocShell * GetDocShellFromWindow(nsIDOMWindow *aWindow);
|
||||
|
||||
|
||||
nsresult SetupEditorCommandController(const char *aControllerClassName,
|
||||
nsIDOMWindow *aWindow,
|
||||
nsISupports *aContext,
|
||||
uint32_t *aControllerId);
|
||||
|
||||
nsresult SetContextOnControllerById(nsIControllers* aControllers,
|
||||
nsresult SetContextOnControllerById(nsIControllers* aControllers,
|
||||
nsISupports* aContext,
|
||||
uint32_t aID);
|
||||
|
||||
@@ -78,17 +78,17 @@ protected:
|
||||
|
||||
static void TimerCallback(nsITimer *aTimer, void *aClosure);
|
||||
nsCOMPtr<nsITimer> mLoadBlankDocTimer;
|
||||
|
||||
|
||||
// progress load stuff
|
||||
nsresult StartDocumentLoad(nsIWebProgress *aWebProgress,
|
||||
bool isToBeMadeEditable);
|
||||
nsresult EndDocumentLoad(nsIWebProgress *aWebProgress,
|
||||
nsresult EndDocumentLoad(nsIWebProgress *aWebProgress,
|
||||
nsIChannel* aChannel, nsresult aStatus,
|
||||
bool isToBeMadeEditable);
|
||||
nsresult StartPageLoad(nsIChannel *aChannel);
|
||||
nsresult EndPageLoad(nsIWebProgress *aWebProgress,
|
||||
nsresult EndPageLoad(nsIWebProgress *aWebProgress,
|
||||
nsIChannel* aChannel, nsresult aStatus);
|
||||
|
||||
|
||||
bool IsProgressForTargetDocument(nsIWebProgress *aWebProgress);
|
||||
|
||||
void RemoveEditorControllers(nsIDOMWindow *aWindow);
|
||||
@@ -102,10 +102,10 @@ protected:
|
||||
bool mDoneSetup; // have we prepared for editing yet?
|
||||
|
||||
// Used to prevent double creation of editor because nsIWebProgressListener
|
||||
// receives a STATE_STOP notification before the STATE_START
|
||||
// for our document, so we wait for the STATE_START, then STATE_STOP
|
||||
// receives a STATE_STOP notification before the STATE_START
|
||||
// for our document, so we wait for the STATE_START, then STATE_STOP
|
||||
// before creating an editor
|
||||
bool mCanCreateEditor;
|
||||
bool mCanCreateEditor;
|
||||
|
||||
bool mInteractive;
|
||||
bool mMakeWholeDocumentEditable;
|
||||
@@ -128,9 +128,9 @@ protected:
|
||||
// THE REMAINING MEMBER VARIABLES WILL BECOME A SET WHEN WE EDIT
|
||||
// MORE THAN ONE EDITOR PER EDITING SESSION
|
||||
nsRefPtr<nsComposerCommandsUpdater> mStateMaintainer;
|
||||
|
||||
|
||||
// Save the editor type so we can create the editor after loading uri
|
||||
nsCString mEditorType;
|
||||
nsCString mEditorType;
|
||||
uint32_t mEditorFlags;
|
||||
uint32_t mEditorStatus;
|
||||
uint32_t mBaseCommandControllerId;
|
||||
|
||||
@@ -320,7 +320,7 @@ private:
|
||||
nsCOMPtr<nsIEditorSpellCheckCallback> mCallback;
|
||||
};
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsEditorSpellCheck::InitSpellChecker(nsIEditor* aEditor, bool aEnableSelectionChecking, nsIEditorSpellCheckCallback* aCallback)
|
||||
{
|
||||
NS_ENSURE_TRUE(aEditor, NS_ERROR_NULL_POINTER);
|
||||
@@ -407,13 +407,13 @@ nsEditorSpellCheck::InitSpellChecker(nsIEditor* aEditor, bool aEnableSelectionCh
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsEditorSpellCheck::GetNextMisspelledWord(char16_t **aNextMisspelledWord)
|
||||
{
|
||||
NS_ENSURE_TRUE(mSpellChecker, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
nsAutoString nextMisspelledWord;
|
||||
|
||||
|
||||
DeleteSuggestedWordList();
|
||||
// Beware! This may flush notifications via synchronous
|
||||
// ScrollSelectionIntoView.
|
||||
@@ -424,7 +424,7 @@ nsEditorSpellCheck::GetNextMisspelledWord(char16_t **aNextMisspelledWord)
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsEditorSpellCheck::GetSuggestedWord(char16_t **aSuggestedWord)
|
||||
{
|
||||
nsAutoString word;
|
||||
@@ -439,7 +439,7 @@ nsEditorSpellCheck::GetSuggestedWord(char16_t **aSuggestedWord)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsEditorSpellCheck::CheckCurrentWord(const char16_t *aSuggestedWord,
|
||||
bool *aIsMisspelled)
|
||||
{
|
||||
@@ -450,7 +450,7 @@ nsEditorSpellCheck::CheckCurrentWord(const char16_t *aSuggestedWord,
|
||||
aIsMisspelled, &mSuggestedWordList);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsEditorSpellCheck::CheckCurrentWordNoSuggest(const char16_t *aSuggestedWord,
|
||||
bool *aIsMisspelled)
|
||||
{
|
||||
@@ -460,7 +460,7 @@ nsEditorSpellCheck::CheckCurrentWordNoSuggest(const char16_t *aSuggestedWord,
|
||||
aIsMisspelled, nullptr);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsEditorSpellCheck::ReplaceWord(const char16_t *aMisspelledWord,
|
||||
const char16_t *aReplaceWord,
|
||||
bool allOccurrences)
|
||||
@@ -471,7 +471,7 @@ nsEditorSpellCheck::ReplaceWord(const char16_t *aMisspelledWord,
|
||||
nsDependentString(aReplaceWord), allOccurrences);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsEditorSpellCheck::IgnoreWordAllOccurrences(const char16_t *aWord)
|
||||
{
|
||||
NS_ENSURE_TRUE(mSpellChecker, NS_ERROR_NOT_INITIALIZED);
|
||||
@@ -479,7 +479,7 @@ nsEditorSpellCheck::IgnoreWordAllOccurrences(const char16_t *aWord)
|
||||
return mSpellChecker->IgnoreAll(nsDependentString(aWord));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsEditorSpellCheck::GetPersonalDictionary()
|
||||
{
|
||||
NS_ENSURE_TRUE(mSpellChecker, NS_ERROR_NOT_INITIALIZED);
|
||||
@@ -490,7 +490,7 @@ nsEditorSpellCheck::GetPersonalDictionary()
|
||||
return mSpellChecker->GetPersonalDictionary(&mDictionaryList);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsEditorSpellCheck::GetPersonalDictionaryWord(char16_t **aDictionaryWord)
|
||||
{
|
||||
if ( mDictionaryIndex < int32_t( mDictionaryList.Length()))
|
||||
@@ -505,7 +505,7 @@ nsEditorSpellCheck::GetPersonalDictionaryWord(char16_t **aDictionaryWord)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsEditorSpellCheck::AddWordToDictionary(const char16_t *aWord)
|
||||
{
|
||||
NS_ENSURE_TRUE(mSpellChecker, NS_ERROR_NOT_INITIALIZED);
|
||||
@@ -513,7 +513,7 @@ nsEditorSpellCheck::AddWordToDictionary(const char16_t *aWord)
|
||||
return mSpellChecker->AddWordToPersonalDictionary(nsDependentString(aWord));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsEditorSpellCheck::RemoveWordFromDictionary(const char16_t *aWord)
|
||||
{
|
||||
NS_ENSURE_TRUE(mSpellChecker, NS_ERROR_NOT_INITIALIZED);
|
||||
@@ -521,7 +521,7 @@ nsEditorSpellCheck::RemoveWordFromDictionary(const char16_t *aWord)
|
||||
return mSpellChecker->RemoveWordFromPersonalDictionary(nsDependentString(aWord));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsEditorSpellCheck::GetDictionaryList(char16_t ***aDictionaryList, uint32_t *aCount)
|
||||
{
|
||||
NS_ENSURE_TRUE(mSpellChecker, NS_ERROR_NOT_INITIALIZED);
|
||||
@@ -572,7 +572,7 @@ nsEditorSpellCheck::GetDictionaryList(char16_t ***aDictionaryList, uint32_t *aCo
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsEditorSpellCheck::GetCurrentDictionary(nsAString& aDictionary)
|
||||
{
|
||||
NS_ENSURE_TRUE(mSpellChecker, NS_ERROR_NOT_INITIALIZED);
|
||||
@@ -580,7 +580,7 @@ nsEditorSpellCheck::GetCurrentDictionary(nsAString& aDictionary)
|
||||
return mSpellChecker->GetCurrentDictionary(aDictionary);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsEditorSpellCheck::SetCurrentDictionary(const nsAString& aDictionary)
|
||||
{
|
||||
NS_ENSURE_TRUE(mSpellChecker, NS_ERROR_NOT_INITIALIZED);
|
||||
@@ -638,7 +638,7 @@ nsEditorSpellCheck::CheckCurrentDictionary()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsEditorSpellCheck::UninitSpellChecker()
|
||||
{
|
||||
NS_ENSURE_TRUE(mSpellChecker, NS_ERROR_NOT_INITIALIZED);
|
||||
@@ -653,14 +653,14 @@ nsEditorSpellCheck::UninitSpellChecker()
|
||||
|
||||
|
||||
/* void setFilter (in nsITextServicesFilter filter); */
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsEditorSpellCheck::SetFilter(nsITextServicesFilter *filter)
|
||||
{
|
||||
mTxtSrvFilter = filter;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsresult
|
||||
nsEditorSpellCheck::DeleteSuggestedWordList()
|
||||
{
|
||||
mSuggestedWordList.Clear();
|
||||
|
||||
@@ -43,27 +43,27 @@ interface nsIEditingSession : nsISupports
|
||||
in boolean doAfterUriLoad,
|
||||
in boolean aMakeWholeDocumentEditable,
|
||||
in boolean aInteractive);
|
||||
|
||||
|
||||
/**
|
||||
* Test whether a specific window has had its editable flag set; it may have an editor
|
||||
* now, or will get one after the uri load.
|
||||
*
|
||||
*
|
||||
* Use this, passing the content root window, to test if we've set up editing
|
||||
* for this content.
|
||||
*/
|
||||
boolean windowIsEditable(in nsIDOMWindow window);
|
||||
|
||||
|
||||
/**
|
||||
* Get the editor for this window. May return null
|
||||
*/
|
||||
nsIEditor getEditorForWindow(in nsIDOMWindow window);
|
||||
nsIEditor getEditorForWindow(in nsIDOMWindow window);
|
||||
|
||||
/**
|
||||
/**
|
||||
* Setup editor and related support objects
|
||||
*/
|
||||
void setupEditorOnWindow(in nsIDOMWindow window);
|
||||
|
||||
/**
|
||||
/**
|
||||
* Destroy editor and related support objects
|
||||
*/
|
||||
void tearDownEditorOnWindow(in nsIDOMWindow window);
|
||||
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(InsertTextTxn, EditTxn)
|
||||
|
||||
|
||||
NS_DECL_EDITTXN
|
||||
|
||||
NS_IMETHOD Merge(nsITransaction* aTransaction, bool* aDidMerge) override;
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
PlaceholderTxn::PlaceholderTxn() : EditAggregateTxn(),
|
||||
mAbsorb(true),
|
||||
PlaceholderTxn::PlaceholderTxn() : EditAggregateTxn(),
|
||||
mAbsorb(true),
|
||||
mForwarding(nullptr),
|
||||
mIMETextTxn(nullptr),
|
||||
mCommitted(false),
|
||||
@@ -72,7 +72,7 @@ NS_IMETHODIMP PlaceholderTxn::UndoTransaction(void)
|
||||
// undo txns
|
||||
nsresult res = EditAggregateTxn::UndoTransaction();
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
|
||||
NS_ENSURE_TRUE(mStartSel, NS_ERROR_NULL_POINTER);
|
||||
|
||||
// now restore selection
|
||||
@@ -87,7 +87,7 @@ NS_IMETHODIMP PlaceholderTxn::RedoTransaction(void)
|
||||
// redo txns
|
||||
nsresult res = EditAggregateTxn::RedoTransaction();
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
|
||||
// now restore selection
|
||||
nsRefPtr<Selection> selection = mEditor->GetSelection();
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
|
||||
@@ -101,8 +101,8 @@ NS_IMETHODIMP PlaceholderTxn::Merge(nsITransaction *aTransaction, bool *aDidMerg
|
||||
|
||||
// set out param default value
|
||||
*aDidMerge=false;
|
||||
|
||||
if (mForwarding)
|
||||
|
||||
if (mForwarding)
|
||||
{
|
||||
NS_NOTREACHED("tried to merge into a placeholder that was in forwarding mode!");
|
||||
return NS_ERROR_FAILURE;
|
||||
@@ -122,18 +122,18 @@ NS_IMETHODIMP PlaceholderTxn::Merge(nsITransaction *aTransaction, bool *aDidMerg
|
||||
|
||||
// we are absorbing all txn's if mAbsorb is lit.
|
||||
if (mAbsorb)
|
||||
{
|
||||
{
|
||||
nsRefPtr<IMETextTxn> otherTxn = do_QueryObject(aTransaction);
|
||||
if (otherTxn) {
|
||||
// special handling for IMETextTxn's: they need to merge with any previous
|
||||
// IMETextTxn in this placeholder, if possible.
|
||||
if (!mIMETextTxn)
|
||||
if (!mIMETextTxn)
|
||||
{
|
||||
// this is the first IME txn in the placeholder
|
||||
mIMETextTxn =otherTxn;
|
||||
AppendChild(editTxn);
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
bool didMerge;
|
||||
mIMETextTxn->Merge(otherTxn, &didMerge);
|
||||
@@ -153,7 +153,7 @@ NS_IMETHODIMP PlaceholderTxn::Merge(nsITransaction *aTransaction, bool *aDidMerg
|
||||
}
|
||||
*aDidMerge = true;
|
||||
// RememberEndingSelection();
|
||||
// efficiency hack: no need to remember selection here, as we haven't yet
|
||||
// efficiency hack: no need to remember selection here, as we haven't yet
|
||||
// finished the initial batch and we know we will be told when the batch ends.
|
||||
// we can remeber the selection then.
|
||||
}
|
||||
@@ -161,8 +161,8 @@ NS_IMETHODIMP PlaceholderTxn::Merge(nsITransaction *aTransaction, bool *aDidMerg
|
||||
{ // merge typing or IME or deletion transactions if the selection matches
|
||||
if (((mName.get() == nsGkAtoms::TypingTxnName) ||
|
||||
(mName.get() == nsGkAtoms::IMETxnName) ||
|
||||
(mName.get() == nsGkAtoms::DeleteTxnName))
|
||||
&& !mCommitted )
|
||||
(mName.get() == nsGkAtoms::DeleteTxnName))
|
||||
&& !mCommitted )
|
||||
{
|
||||
nsCOMPtr<nsIAbsorbingTransaction> plcTxn = do_QueryObject(editTxn);
|
||||
if (plcTxn) {
|
||||
@@ -229,19 +229,19 @@ NS_IMETHODIMP PlaceholderTxn::StartSelectionEquals(nsSelectionState *aSelState,
|
||||
NS_IMETHODIMP PlaceholderTxn::EndPlaceHolderBatch()
|
||||
{
|
||||
mAbsorb = false;
|
||||
|
||||
if (mForwarding)
|
||||
|
||||
if (mForwarding)
|
||||
{
|
||||
nsCOMPtr<nsIAbsorbingTransaction> plcTxn = do_QueryReferent(mForwarding);
|
||||
if (plcTxn) plcTxn->EndPlaceHolderBatch();
|
||||
}
|
||||
|
||||
|
||||
// remember our selection state.
|
||||
return RememberEndingSelection();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP PlaceholderTxn::ForwardEndBatchTo(nsIAbsorbingTransaction *aForwardingAddress)
|
||||
{
|
||||
{
|
||||
mForwarding = do_GetWeakReference(aForwardingAddress);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -27,14 +27,14 @@ class IMETextTxn;
|
||||
* But it absorbs other transactions via merge, and can undo/redo the
|
||||
* transactions it has absorbed.
|
||||
*/
|
||||
|
||||
class PlaceholderTxn : public EditAggregateTxn,
|
||||
public nsIAbsorbingTransaction,
|
||||
|
||||
class PlaceholderTxn : public EditAggregateTxn,
|
||||
public nsIAbsorbingTransaction,
|
||||
public nsSupportsWeakReference
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
PlaceholderTxn();
|
||||
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(PlaceholderTxn, EditAggregateTxn)
|
||||
@@ -49,9 +49,9 @@ public:
|
||||
|
||||
NS_IMETHOD Init(nsIAtom* aName, nsSelectionState* aSelState,
|
||||
nsEditor* aEditor) override;
|
||||
|
||||
|
||||
NS_IMETHOD GetTxnName(nsIAtom **aName) override;
|
||||
|
||||
|
||||
NS_IMETHOD StartSelectionEquals(nsSelectionState *aSelState, bool *aResult) override;
|
||||
|
||||
NS_IMETHOD EndPlaceHolderBatch() override;
|
||||
@@ -71,7 +71,7 @@ protected:
|
||||
mozilla::dom::IMETextTxn *mIMETextTxn; // first IME txn in this placeholder - used for IME merging
|
||||
// non-owning for now - can't nsCOMPtr it due to broken transaction interfaces
|
||||
bool mCommitted; // do we stop auto absorbing any matching placeholder txns?
|
||||
// these next two members store the state of the selection in a safe way.
|
||||
// these next two members store the state of the selection in a safe way.
|
||||
// selection at the start of the txn is stored, as is the selection at the end.
|
||||
// This is so that UndoTransaction() and RedoTransaction() can restore the
|
||||
// selection properly.
|
||||
|
||||
@@ -149,8 +149,8 @@ nsresult SetDocTitleTxn::SetDomTitle(const nsAString& aTitle)
|
||||
// Not undoable: We will insert newTitleNode below
|
||||
nsCOMPtr<nsIDOMNode> resultNode;
|
||||
res = titleNode->AppendChild(newNode, getter_AddRefs(resultNode));
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
// This is an undoable transaction
|
||||
res = editor->InsertNode(newNode, titleNode, 0);
|
||||
@@ -175,7 +175,7 @@ NS_IMETHODIMP SetDocTitleTxn::GetTxnDescription(nsAString& aString)
|
||||
|
||||
NS_IMETHODIMP SetDocTitleTxn::GetIsTransient(bool *aIsTransient)
|
||||
{
|
||||
NS_ENSURE_TRUE(aIsTransient, NS_ERROR_NULL_POINTER);
|
||||
NS_ENSURE_TRUE(aIsTransient, NS_ERROR_NULL_POINTER);
|
||||
*aIsTransient = mIsTransient;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ protected:
|
||||
|
||||
/** the editor that created this transaction */
|
||||
nsIHTMLEditor* mEditor;
|
||||
|
||||
|
||||
/** The new title string */
|
||||
nsString mValue;
|
||||
|
||||
|
||||
@@ -49,23 +49,23 @@ void TextEditorTest::Run(nsIEditor *aEditor, int32_t *outNumTests, int32_t *outN
|
||||
nsresult TextEditorTest::RunUnitTest(int32_t *outNumTests, int32_t *outNumTestsFailed)
|
||||
{
|
||||
nsresult result;
|
||||
|
||||
|
||||
NS_ENSURE_TRUE(outNumTests && outNumTestsFailed, NS_ERROR_NULL_POINTER);
|
||||
|
||||
|
||||
*outNumTests = 0;
|
||||
*outNumTestsFailed = 0;
|
||||
|
||||
|
||||
result = InitDoc();
|
||||
TEST_RESULT(result);
|
||||
// shouldn't we just bail on error here?
|
||||
|
||||
|
||||
// insert some simple text
|
||||
result = mTextEditor->InsertText(NS_LITERAL_STRING("1234567890abcdefghij1234567890"));
|
||||
TEST_RESULT(result);
|
||||
(*outNumTests)++;
|
||||
if (NS_FAILED(result))
|
||||
++(*outNumTestsFailed);
|
||||
|
||||
|
||||
// insert some more text
|
||||
result = mTextEditor->InsertText(NS_LITERAL_STRING("Moreover, I am cognizant of the interrelatedness of all communities and states. I cannot sit idly by in Atlanta and not be concerned about what happens in Birmingham. Injustice anywhere is a threat to justice everywhere"));
|
||||
TEST_RESULT(result);
|
||||
@@ -123,7 +123,7 @@ nsresult TextEditorTest::TestInsertBreak()
|
||||
result = mTextEditor->InsertLineBreak();
|
||||
TEST_RESULT(result);
|
||||
mEditor->DebugDumpContent();
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
/********************************************************************
|
||||
* XPCOM cruft
|
||||
* XPCOM cruft
|
||||
*******************************************************************/
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION(TypeInState, mLastSelectionContainer)
|
||||
@@ -41,7 +41,7 @@ NS_INTERFACE_MAP_END
|
||||
/********************************************************************
|
||||
* public methods
|
||||
*******************************************************************/
|
||||
|
||||
|
||||
TypeInState::TypeInState() :
|
||||
mSetArray()
|
||||
,mClearedArray()
|
||||
@@ -63,7 +63,7 @@ nsresult
|
||||
TypeInState::UpdateSelState(Selection* aSelection)
|
||||
{
|
||||
NS_ENSURE_TRUE(aSelection, NS_ERROR_NULL_POINTER);
|
||||
|
||||
|
||||
if (!aSelection->Collapsed()) {
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -114,7 +114,7 @@ NS_IMETHODIMP TypeInState::NotifySelectionChanged(nsIDOMDocument *, nsISelection
|
||||
}
|
||||
}
|
||||
|
||||
Reset();
|
||||
Reset();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ TypeInState::ClearProp(nsIAtom* aProp, const nsAString& aAttr)
|
||||
/***************************************************************************
|
||||
* TakeClearProperty: hands back next property item on the clear list.
|
||||
* caller assumes ownership of PropItem and must delete it.
|
||||
*/
|
||||
*/
|
||||
PropItem*
|
||||
TypeInState::TakeClearProperty()
|
||||
{
|
||||
@@ -207,7 +207,7 @@ TypeInState::TakeClearProperty()
|
||||
/***************************************************************************
|
||||
* TakeSetProperty: hands back next poroperty item on the set list.
|
||||
* caller assumes ownership of PropItem and must delete it.
|
||||
*/
|
||||
*/
|
||||
PropItem*
|
||||
TypeInState::TakeSetProperty()
|
||||
{
|
||||
@@ -266,7 +266,7 @@ TypeInState::GetTypingState(bool &isSet,
|
||||
/********************************************************************
|
||||
* protected methods
|
||||
*******************************************************************/
|
||||
|
||||
|
||||
void
|
||||
TypeInState::RemovePropFromSetList(nsIAtom* aProp, const nsAString& aAttr)
|
||||
{
|
||||
@@ -354,7 +354,7 @@ bool TypeInState::IsPropCleared(nsIAtom* aProp,
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TypeInState::FindPropInList(nsIAtom *aProp,
|
||||
bool TypeInState::FindPropInList(nsIAtom *aProp,
|
||||
const nsAString &aAttr,
|
||||
nsAString *outValue,
|
||||
nsTArray<PropItem*> &aList,
|
||||
@@ -366,7 +366,7 @@ bool TypeInState::FindPropInList(nsIAtom *aProp,
|
||||
{
|
||||
PropItem *item = aList[i];
|
||||
if ( (item->tag == aProp) &&
|
||||
(item->attr == aAttr) )
|
||||
(item->attr == aAttr) )
|
||||
{
|
||||
if (outValue) *outValue = item->value;
|
||||
outIndex = i;
|
||||
@@ -382,7 +382,7 @@ bool TypeInState::FindPropInList(nsIAtom *aProp,
|
||||
* PropItem: helper struct for TypeInState
|
||||
*******************************************************************/
|
||||
|
||||
PropItem::PropItem() :
|
||||
PropItem::PropItem() :
|
||||
tag(nullptr)
|
||||
,attr()
|
||||
,value()
|
||||
|
||||
@@ -27,7 +27,7 @@ struct PropItem
|
||||
nsIAtom *tag;
|
||||
nsString attr;
|
||||
nsString value;
|
||||
|
||||
|
||||
PropItem();
|
||||
PropItem(nsIAtom *aTag, const nsAString &aAttr, const nsAString &aValue);
|
||||
~PropItem();
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
|
||||
void ClearAllProps();
|
||||
void ClearProp(nsIAtom* aProp, const nsAString& aAttr);
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// TakeClearProperty: hands back next property item on the clear list.
|
||||
// caller assumes ownership of PropItem and must delete it.
|
||||
@@ -89,7 +89,7 @@ protected:
|
||||
int32_t mRelativeFontSize;
|
||||
nsCOMPtr<nsIDOMNode> mLastSelectionContainer;
|
||||
int32_t mLastSelectionOffset;
|
||||
|
||||
|
||||
friend class nsHTMLEditRules;
|
||||
};
|
||||
|
||||
|
||||
@@ -26,22 +26,22 @@ class Selection;
|
||||
class nsRulesInfo
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
explicit nsRulesInfo(EditAction aAction) : action(aAction) {}
|
||||
virtual ~nsRulesInfo() {}
|
||||
|
||||
|
||||
EditAction action;
|
||||
};
|
||||
|
||||
/***************************************************************************
|
||||
* Interface of editing rules.
|
||||
*
|
||||
*
|
||||
*/
|
||||
class nsIEditRules : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IEDITRULES_IID)
|
||||
|
||||
|
||||
//Interfaces for addref and release and queryinterface
|
||||
//NOTE: Use NS_DECL_ISUPPORTS_INHERITED in any class inherited from nsIEditRules
|
||||
|
||||
|
||||
+108
-108
@@ -242,7 +242,7 @@ nsEditor::Init(nsIDOMDocument *aDoc, nsIContent *aRoot,
|
||||
}
|
||||
NS_ASSERTION(selCon, "Selection controller should be available at this point");
|
||||
|
||||
//set up root element if we are passed one.
|
||||
//set up root element if we are passed one.
|
||||
if (aRoot)
|
||||
mRootElement = do_QueryInterface(aRoot);
|
||||
|
||||
@@ -554,7 +554,7 @@ nsEditor::GetDOMDocument()
|
||||
return doc.forget();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsEditor::GetDocument(nsIDOMDocument **aDoc)
|
||||
{
|
||||
*aDoc = GetDOMDocument().take();
|
||||
@@ -766,7 +766,7 @@ NS_IMETHODIMP
|
||||
nsEditor::GetTransactionManager(nsITransactionManager* *aTxnManager)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aTxnManager);
|
||||
|
||||
|
||||
*aTxnManager = nullptr;
|
||||
NS_ENSURE_TRUE(mTxnMgr, NS_ERROR_FAILURE);
|
||||
|
||||
@@ -784,7 +784,7 @@ nsEditor::SetTransactionManager(nsITransactionManager *aTxnManager)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsEditor::Undo(uint32_t aCount)
|
||||
{
|
||||
ForceCompositionEnd();
|
||||
@@ -826,7 +826,7 @@ NS_IMETHODIMP nsEditor::CanUndo(bool *aIsEnabled, bool *aCanUndo)
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsEditor::Redo(uint32_t aCount)
|
||||
{
|
||||
bool hasTxnMgr, hasTransaction = false;
|
||||
@@ -867,7 +867,7 @@ NS_IMETHODIMP nsEditor::CanRedo(bool *aIsEnabled, bool *aCanRedo)
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsEditor::BeginTransaction()
|
||||
{
|
||||
BeginUpdateViewBatch();
|
||||
@@ -880,7 +880,7 @@ nsEditor::BeginTransaction()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsEditor::EndTransaction()
|
||||
{
|
||||
if (mTxnMgr) {
|
||||
@@ -901,7 +901,7 @@ nsEditor::EndTransaction()
|
||||
// placeholder transactions can later merge, if needed. Merging
|
||||
// is unavailable between transaction manager batches.
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsEditor::BeginPlaceHolderTransaction(nsIAtom *aName)
|
||||
{
|
||||
NS_PRECONDITION(mPlaceHolderBatch >= 0, "negative placeholder batch count!");
|
||||
@@ -923,7 +923,7 @@ nsEditor::BeginPlaceHolderTransaction(nsIAtom *aName)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsEditor::EndPlaceHolderTransaction()
|
||||
{
|
||||
NS_PRECONDITION(mPlaceHolderBatch > 0, "zero or negative placeholder batch count when ending batch!");
|
||||
@@ -966,7 +966,7 @@ nsEditor::EndPlaceHolderTransaction()
|
||||
|
||||
if (mSelState)
|
||||
{
|
||||
// we saved the selection state, but never got to hand it to placeholder
|
||||
// we saved the selection state, but never got to hand it to placeholder
|
||||
// (else we ould have nulled out this pointer), so destroy it to prevent leaks.
|
||||
delete mSelState;
|
||||
mSelState = nullptr;
|
||||
@@ -974,11 +974,11 @@ nsEditor::EndPlaceHolderTransaction()
|
||||
if (mPlaceHolderTxn) // we might have never made a placeholder if no action took place
|
||||
{
|
||||
nsCOMPtr<nsIAbsorbingTransaction> plcTxn = do_QueryReferent(mPlaceHolderTxn);
|
||||
if (plcTxn)
|
||||
if (plcTxn)
|
||||
{
|
||||
plcTxn->EndPlaceHolderBatch();
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
// in the future we will check to make sure undo is off here,
|
||||
// since that is the only known case where the placeholdertxn would disappear on us.
|
||||
@@ -994,7 +994,7 @@ nsEditor::EndPlaceHolderTransaction()
|
||||
}
|
||||
}
|
||||
mPlaceHolderBatch--;
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -1006,7 +1006,7 @@ nsEditor::ShouldTxnSetSelection(bool *aResult)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsEditor::SetShouldTxnSetSelection(bool aShould)
|
||||
{
|
||||
mShouldTxnSetSelection = aShould;
|
||||
@@ -1019,7 +1019,7 @@ nsEditor::GetDocumentIsEmpty(bool *aDocumentIsEmpty)
|
||||
*aDocumentIsEmpty = true;
|
||||
|
||||
dom::Element* root = GetRoot();
|
||||
NS_ENSURE_TRUE(root, NS_ERROR_NULL_POINTER);
|
||||
NS_ENSURE_TRUE(root, NS_ERROR_NULL_POINTER);
|
||||
|
||||
*aDocumentIsEmpty = !root->HasChildren();
|
||||
return NS_OK;
|
||||
@@ -1044,11 +1044,11 @@ NS_IMETHODIMP nsEditor::BeginningOfDocument()
|
||||
// get the selection
|
||||
nsRefPtr<Selection> selection = GetSelection();
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
// get the root element
|
||||
|
||||
// get the root element
|
||||
dom::Element* rootElement = GetRoot();
|
||||
NS_ENSURE_TRUE(rootElement, NS_ERROR_NULL_POINTER);
|
||||
|
||||
NS_ENSURE_TRUE(rootElement, NS_ERROR_NULL_POINTER);
|
||||
|
||||
// find first editable thingy
|
||||
nsCOMPtr<nsINode> firstNode = GetFirstEditableNode(rootElement);
|
||||
if (!firstNode) {
|
||||
@@ -1073,16 +1073,16 @@ NS_IMETHODIMP nsEditor::BeginningOfDocument()
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditor::EndOfDocument()
|
||||
{
|
||||
{
|
||||
NS_ENSURE_TRUE(mDocWeak, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
// get selection
|
||||
nsRefPtr<Selection> selection = GetSelection();
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
|
||||
|
||||
// get the root element
|
||||
// get selection
|
||||
nsRefPtr<Selection> selection = GetSelection();
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
|
||||
|
||||
// get the root element
|
||||
nsINode* node = GetRoot();
|
||||
NS_ENSURE_TRUE(node, NS_ERROR_NULL_POINTER);
|
||||
NS_ENSURE_TRUE(node, NS_ERROR_NULL_POINTER);
|
||||
nsINode* child = node->GetLastChild();
|
||||
|
||||
while (child && IsContainer(child->AsDOMNode())) {
|
||||
@@ -1092,8 +1092,8 @@ nsEditor::EndOfDocument()
|
||||
|
||||
uint32_t length = node->Length();
|
||||
return selection->CollapseNative(node, int32_t(length));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditor::GetDocumentModified(bool *outDocModified)
|
||||
{
|
||||
@@ -1129,25 +1129,25 @@ nsEditor::SetDocumentCharacterSet(const nsACString& characterSet)
|
||||
NS_IMETHODIMP
|
||||
nsEditor::Cut()
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditor::CanCut(bool *aCanCut)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditor::Copy()
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditor::CanCopy(bool *aCanCut)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@@ -1159,25 +1159,25 @@ nsEditor::CanDelete(bool *aCanDelete)
|
||||
NS_IMETHODIMP
|
||||
nsEditor::Paste(int32_t aSelectionType)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditor::PasteTransferable(nsITransferable *aTransferable)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditor::CanPaste(int32_t aSelectionType, bool *aCanPaste)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditor::CanPasteTransferable(nsITransferable *aTransferable, bool *aCanPaste)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@@ -1193,10 +1193,10 @@ nsEditor::SetAttribute(nsIDOMElement* aElement, const nsAString& aAttribute,
|
||||
return DoTransaction(txn);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditor::GetAttributeValue(nsIDOMElement *aElement,
|
||||
const nsAString & aAttribute,
|
||||
nsAString & aResultValue,
|
||||
NS_IMETHODIMP
|
||||
nsEditor::GetAttributeValue(nsIDOMElement *aElement,
|
||||
const nsAString & aAttribute,
|
||||
nsAString & aResultValue,
|
||||
bool *aResultIsSet)
|
||||
{
|
||||
NS_ENSURE_TRUE(aResultIsSet, NS_ERROR_NULL_POINTER);
|
||||
@@ -1239,7 +1239,7 @@ nsEditor::OutputsMozDirty()
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditor::MarkNodeDirty(nsIDOMNode* aNode)
|
||||
{
|
||||
{
|
||||
// Mark the node dirty, but not for webpages (bug 599983)
|
||||
if (!OutputsMozDirty()) {
|
||||
return NS_OK;
|
||||
@@ -1552,9 +1552,9 @@ nsEditor::DeleteNode(nsINode* aNode)
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// ReplaceContainer: replace inNode with a new node (outNode) which is contructed
|
||||
// ReplaceContainer: replace inNode with a new node (outNode) which is contructed
|
||||
// to be of type aNodeType. Put inNodes children into outNode.
|
||||
// Callers responsibility to make sure inNode's children can
|
||||
// Callers responsibility to make sure inNode's children can
|
||||
// go in outNode.
|
||||
already_AddRefed<Element>
|
||||
nsEditor::ReplaceContainer(Element* aOldContainer,
|
||||
@@ -1583,7 +1583,7 @@ nsEditor::ReplaceContainer(Element* aOldContainer,
|
||||
if (aCloneAttributes == eCloneAttributes) {
|
||||
CloneAttributes(ret, aOldContainer);
|
||||
}
|
||||
|
||||
|
||||
// notify our internal selection state listener
|
||||
// (Note: A nsAutoSelectionReset object must be created
|
||||
// before calling this to initialize mRangeUpdater)
|
||||
@@ -1605,7 +1605,7 @@ nsEditor::ReplaceContainer(Element* aOldContainer,
|
||||
// insert new container into tree
|
||||
res = InsertNode(*ret, *parent, offset);
|
||||
NS_ENSURE_SUCCESS(res, nullptr);
|
||||
|
||||
|
||||
// delete old container
|
||||
res = DeleteNode(aOldContainer);
|
||||
NS_ENSURE_SUCCESS(res, nullptr);
|
||||
@@ -1745,7 +1745,7 @@ nsEditor::AddEditorObserver(nsIEditorObserver *aObserver)
|
||||
{
|
||||
// we don't keep ownership of the observers. They must
|
||||
// remove themselves as observers before they are destroyed.
|
||||
|
||||
|
||||
NS_ENSURE_TRUE(aObserver, NS_ERROR_NULL_POINTER);
|
||||
|
||||
// Make sure the listener isn't already on the list
|
||||
@@ -1974,7 +1974,7 @@ nsEditor::DebugUnitTests(int32_t *outNumTests, int32_t *outNumTestsFailed)
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
bool
|
||||
nsEditor::ArePreservingSelection()
|
||||
{
|
||||
return !(mSavedSel.IsEmpty());
|
||||
@@ -1987,7 +1987,7 @@ nsEditor::PreserveSelectionAcrossActions(Selection* aSel)
|
||||
mRangeUpdater.RegisterSelectionState(mSavedSel);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsresult
|
||||
nsEditor::RestorePreservedSelection(Selection* aSel)
|
||||
{
|
||||
if (mSavedSel.IsEmpty()) return NS_ERROR_FAILURE;
|
||||
@@ -1996,7 +1996,7 @@ nsEditor::RestorePreservedSelection(Selection* aSel)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
nsEditor::StopPreservingSelection()
|
||||
{
|
||||
mRangeUpdater.DropSelectionState(mSavedSel);
|
||||
@@ -2471,7 +2471,7 @@ nsEditor::NotifyDocumentListeners(TDocumentListenerNotification aNotificationTyp
|
||||
// Maybe there just aren't any.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsTArray<OwningNonNull<nsIDocumentStateListener>>
|
||||
listeners(mDocStateListeners);
|
||||
nsresult rv = NS_OK;
|
||||
@@ -2485,7 +2485,7 @@ nsEditor::NotifyDocumentListeners(TDocumentListenerNotification aNotificationTyp
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case eDocumentToBeDestroyed:
|
||||
for (auto& listener : listeners) {
|
||||
rv = listener->NotifyDocumentWillBeDestroyed();
|
||||
@@ -2512,7 +2512,7 @@ nsEditor::NotifyDocumentListeners(TDocumentListenerNotification aNotificationTyp
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
NS_NOTREACHED("Unknown notification");
|
||||
}
|
||||
@@ -2903,10 +2903,10 @@ nsEditor::GetNodeLocation(nsINode* aChild, int32_t* aOffset)
|
||||
return parent;
|
||||
}
|
||||
|
||||
// returns the number of things inside aNode.
|
||||
// returns the number of things inside aNode.
|
||||
// If aNode is text, returns number of characters. If not, returns number of children nodes.
|
||||
nsresult
|
||||
nsEditor::GetLengthOfDOMNode(nsIDOMNode *aNode, uint32_t &aCount)
|
||||
nsEditor::GetLengthOfDOMNode(nsIDOMNode *aNode, uint32_t &aCount)
|
||||
{
|
||||
aCount = 0;
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
|
||||
@@ -2990,7 +2990,7 @@ nsEditor::GetNextNode(nsINode* aParentNode,
|
||||
// restart the search from the non-editable node we just found
|
||||
return GetNextNode(resultNode, aEditableNode, aNoBlockCrossing);
|
||||
}
|
||||
|
||||
|
||||
// unless there isn't one, in which case we are at the end of the node
|
||||
// and want the next one.
|
||||
if (aNoBlockCrossing && IsBlockNode(aParentNode)) {
|
||||
@@ -3016,7 +3016,7 @@ nsEditor::GetPriorNode(nsINode* aCurrentNode, bool aEditableNode,
|
||||
}
|
||||
|
||||
nsIContent*
|
||||
nsEditor::FindNextLeafNode(nsINode *aCurrentNode,
|
||||
nsEditor::FindNextLeafNode(nsINode *aCurrentNode,
|
||||
bool aGoForward,
|
||||
bool bNoBlockCrossing)
|
||||
{
|
||||
@@ -3039,7 +3039,7 @@ nsEditor::FindNextLeafNode(nsINode *aCurrentNode,
|
||||
nsIContent *leaf =
|
||||
aGoForward ? GetLeftmostChild(sibling, bNoBlockCrossing) :
|
||||
GetRightmostChild(sibling, bNoBlockCrossing);
|
||||
if (!leaf) {
|
||||
if (!leaf) {
|
||||
return sibling;
|
||||
}
|
||||
|
||||
@@ -3097,7 +3097,7 @@ nsEditor::FindNode(nsINode *aCurrentNode,
|
||||
|
||||
nsCOMPtr<nsIContent> candidate =
|
||||
FindNextLeafNode(aCurrentNode, aGoForward, bNoBlockCrossing);
|
||||
|
||||
|
||||
if (!candidate) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -3196,7 +3196,7 @@ nsEditor::CanContainTag(nsINode& aParent, nsIAtom& aChildTag)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
bool
|
||||
nsEditor::TagCanContain(nsIAtom& aParentTag, nsIContent& aChild)
|
||||
{
|
||||
switch (aChild.NodeType()) {
|
||||
@@ -3208,7 +3208,7 @@ nsEditor::TagCanContain(nsIAtom& aParentTag, nsIContent& aChild)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
bool
|
||||
nsEditor::TagCanContainTag(nsIAtom& aParentTag, nsIAtom& aChildTag)
|
||||
{
|
||||
return true;
|
||||
@@ -3224,7 +3224,7 @@ nsEditor::IsRoot(nsIDOMNode* inNode)
|
||||
return inNode == rootNode;
|
||||
}
|
||||
|
||||
bool
|
||||
bool
|
||||
nsEditor::IsRoot(nsINode* inNode)
|
||||
{
|
||||
NS_ENSURE_TRUE(inNode, false);
|
||||
@@ -3242,7 +3242,7 @@ nsEditor::IsEditorRoot(nsINode* aNode)
|
||||
return aNode == rootNode;
|
||||
}
|
||||
|
||||
bool
|
||||
bool
|
||||
nsEditor::IsDescendantOfRoot(nsIDOMNode* inNode)
|
||||
{
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(inNode);
|
||||
@@ -3346,7 +3346,7 @@ IsElementVisible(dom::Element* aElement)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
bool
|
||||
nsEditor::IsEditable(nsIDOMNode *aNode)
|
||||
{
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
|
||||
@@ -3451,29 +3451,29 @@ nsEditor::GetTag(nsIDOMNode *aNode)
|
||||
{
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
|
||||
|
||||
if (!content)
|
||||
if (!content)
|
||||
{
|
||||
NS_ASSERTION(aNode, "null node passed to nsEditor::GetTag()");
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
return content->NodeInfo()->NameAtom();
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// GetTagString: digs out string for the tag of this node
|
||||
//
|
||||
nsresult
|
||||
//
|
||||
nsresult
|
||||
nsEditor::GetTagString(nsIDOMNode *aNode, nsAString& outString)
|
||||
{
|
||||
if (!aNode)
|
||||
if (!aNode)
|
||||
{
|
||||
NS_NOTREACHED("null node passed to nsEditor::GetTagString()");
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
|
||||
nsIAtom *atom = GetTag(aNode);
|
||||
if (!atom)
|
||||
{
|
||||
@@ -3487,8 +3487,8 @@ nsEditor::GetTagString(nsIDOMNode *aNode, nsAString& outString)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// NodesSameType: do these nodes have the same tag?
|
||||
//
|
||||
bool
|
||||
//
|
||||
bool
|
||||
nsEditor::NodesSameType(nsIDOMNode *aNode1, nsIDOMNode *aNode2)
|
||||
{
|
||||
if (!aNode1 || !aNode2) {
|
||||
@@ -3517,7 +3517,7 @@ nsEditor::AreNodesSameType(nsIContent* aNode1, nsIContent* aNode2)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// IsTextNode: true if node of dom type text
|
||||
//
|
||||
//
|
||||
bool
|
||||
nsEditor::IsTextNode(nsIDOMNode *aNode)
|
||||
{
|
||||
@@ -3526,7 +3526,7 @@ nsEditor::IsTextNode(nsIDOMNode *aNode)
|
||||
NS_NOTREACHED("null node passed to IsTextNode()");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
uint16_t nodeType;
|
||||
aNode->GetNodeType(&nodeType);
|
||||
return (nodeType == nsIDOMNode::TEXT_NODE);
|
||||
@@ -3541,11 +3541,11 @@ nsEditor::IsTextNode(nsINode *aNode)
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// GetChildAt: returns the node at this position index in the parent
|
||||
//
|
||||
nsCOMPtr<nsIDOMNode>
|
||||
nsCOMPtr<nsIDOMNode>
|
||||
nsEditor::GetChildAt(nsIDOMNode *aParent, int32_t aOffset)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> resultNode;
|
||||
|
||||
|
||||
nsCOMPtr<nsIContent> parent = do_QueryInterface(aParent);
|
||||
|
||||
NS_ENSURE_TRUE(parent, resultNode);
|
||||
@@ -3571,9 +3571,9 @@ nsEditor::GetNodeAtRangeOffsetPoint(nsIDOMNode* aParentOrNode, int32_t aOffset)
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// GetStartNodeAndOffset: returns whatever the start parent & offset is of
|
||||
// GetStartNodeAndOffset: returns whatever the start parent & offset is of
|
||||
// the first range in the selection.
|
||||
nsresult
|
||||
nsresult
|
||||
nsEditor::GetStartNodeAndOffset(Selection* aSelection,
|
||||
nsIDOMNode **outStartNode,
|
||||
int32_t *outStartOffset)
|
||||
@@ -3618,9 +3618,9 @@ nsEditor::GetStartNodeAndOffset(Selection* aSelection, nsINode** aStartNode,
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// GetEndNodeAndOffset: returns whatever the end parent & offset is of
|
||||
// GetEndNodeAndOffset: returns whatever the end parent & offset is of
|
||||
// the first range in the selection.
|
||||
nsresult
|
||||
nsresult
|
||||
nsEditor::GetEndNodeAndOffset(Selection* aSelection,
|
||||
nsIDOMNode **outEndNode,
|
||||
int32_t *outEndOffset)
|
||||
@@ -3667,13 +3667,13 @@ nsEditor::GetEndNodeAndOffset(Selection* aSelection, nsINode** aEndNode,
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// IsPreformatted: checks the style info for the node for the preformatted
|
||||
// text style.
|
||||
nsresult
|
||||
nsresult
|
||||
nsEditor::IsPreformatted(nsIDOMNode *aNode, bool *aResult)
|
||||
{
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
|
||||
|
||||
|
||||
NS_ENSURE_TRUE(aResult && content, NS_ERROR_NULL_POINTER);
|
||||
|
||||
|
||||
nsCOMPtr<nsIPresShell> ps = GetPresShell();
|
||||
NS_ENSURE_TRUE(ps, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
@@ -3705,18 +3705,18 @@ nsEditor::IsPreformatted(nsIDOMNode *aNode, bool *aResult)
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// SplitNodeDeep: this splits a node "deeply", splitting children as
|
||||
// SplitNodeDeep: this splits a node "deeply", splitting children as
|
||||
// appropriate. The place to split is represented by
|
||||
// a dom point at {splitPointParent, splitPointOffset}.
|
||||
// That dom point must be inside aNode, which is the node to
|
||||
// That dom point must be inside aNode, which is the node to
|
||||
// split. outOffset is set to the offset in the parent of aNode where
|
||||
// the split terminates - where you would want to insert
|
||||
// a new element, for instance, if that's why you were splitting
|
||||
// the split terminates - where you would want to insert
|
||||
// a new element, for instance, if that's why you were splitting
|
||||
// the node.
|
||||
//
|
||||
nsresult
|
||||
nsEditor::SplitNodeDeep(nsIDOMNode *aNode,
|
||||
nsIDOMNode *aSplitPointParent,
|
||||
nsEditor::SplitNodeDeep(nsIDOMNode *aNode,
|
||||
nsIDOMNode *aSplitPointParent,
|
||||
int32_t aSplitPointOffset,
|
||||
int32_t *outOffset,
|
||||
bool aNoEmptyContainers,
|
||||
@@ -3737,11 +3737,11 @@ nsEditor::SplitNodeDeep(nsIDOMNode *aNode,
|
||||
// for now we just have some smarts about unneccessarily splitting
|
||||
// textnodes, which should be universal enough to put straight in
|
||||
// this nsEditor routine.
|
||||
|
||||
|
||||
nsCOMPtr<nsIDOMCharacterData> nodeAsText = do_QueryInterface(nodeToSplit);
|
||||
uint32_t len = nodeToSplit->Length();
|
||||
bool bDoSplit = false;
|
||||
|
||||
|
||||
if (!(aNoEmptyContainers || nodeAsText) || (offset && (offset != (int32_t)len)))
|
||||
{
|
||||
bDoSplit = true;
|
||||
@@ -3872,7 +3872,7 @@ nsEditor::BeginUpdateViewBatch()
|
||||
nsresult nsEditor::EndUpdateViewBatch()
|
||||
{
|
||||
NS_PRECONDITION(mUpdateCount > 0, "bad state");
|
||||
|
||||
|
||||
if (mUpdateCount <= 0)
|
||||
{
|
||||
mUpdateCount = 0;
|
||||
@@ -3894,14 +3894,14 @@ nsresult nsEditor::EndUpdateViewBatch()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool
|
||||
bool
|
||||
nsEditor::GetShouldTxnSetSelection()
|
||||
{
|
||||
return mShouldTxnSetSelection;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsEditor::DeleteSelectionImpl(EDirection aAction,
|
||||
EStripWrappers aStripWrappers)
|
||||
{
|
||||
@@ -3918,7 +3918,7 @@ nsEditor::DeleteSelectionImpl(EDirection aAction,
|
||||
&deleteCharLength);
|
||||
nsCOMPtr<nsIDOMCharacterData> deleteCharData(do_QueryInterface(deleteNode));
|
||||
|
||||
if (NS_SUCCEEDED(res))
|
||||
if (NS_SUCCEEDED(res))
|
||||
{
|
||||
nsAutoRules beginRulesSniffing(this, EditAction::deleteSelection, aAction);
|
||||
// Notify nsIEditActionListener::WillDelete[Selection|Text|Node]
|
||||
@@ -3937,7 +3937,7 @@ nsEditor::DeleteSelectionImpl(EDirection aAction,
|
||||
}
|
||||
|
||||
// Delete the specified amount
|
||||
res = DoTransaction(txn);
|
||||
res = DoTransaction(txn);
|
||||
|
||||
// Notify nsIEditActionListener::DidDelete[Selection|Text|Node]
|
||||
if (!deleteNode) {
|
||||
@@ -4055,7 +4055,7 @@ nsEditor::DoAfterDoTransaction(nsITransaction *aTxn)
|
||||
bool isTransientTransaction;
|
||||
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(
|
||||
aTxn->GetIsTransient(&isTransientTransaction)));
|
||||
|
||||
|
||||
if (!isTransientTransaction)
|
||||
{
|
||||
// we need to deal here with the case where the user saved after some
|
||||
@@ -4066,7 +4066,7 @@ nsEditor::DoAfterDoTransaction(nsITransaction *aTxn)
|
||||
GetModificationCount(&modCount);
|
||||
if (modCount < 0)
|
||||
modCount = -modCount;
|
||||
|
||||
|
||||
// don't count transient transactions
|
||||
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(
|
||||
IncrementModificationCount(1)));
|
||||
@@ -4160,7 +4160,7 @@ nsEditor::CreateTxnForIMEText(const nsAString& aStringToInsert)
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsEditor::CreateTxnForAddStyleSheet(CSSStyleSheet* aSheet, AddStyleSheetTxn* *aTxn)
|
||||
{
|
||||
nsRefPtr<AddStyleSheetTxn> txn = new AddStyleSheetTxn();
|
||||
@@ -4176,7 +4176,7 @@ nsEditor::CreateTxnForAddStyleSheet(CSSStyleSheet* aSheet, AddStyleSheetTxn* *aT
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsEditor::CreateTxnForRemoveStyleSheet(CSSStyleSheet* aSheet, RemoveStyleSheetTxn* *aTxn)
|
||||
{
|
||||
nsRefPtr<RemoveStyleSheetTxn> txn = new RemoveStyleSheetTxn();
|
||||
@@ -4436,7 +4436,7 @@ nsEditor::CreateTxnForDeleteInsertionPoint(nsRange* aRange,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsresult
|
||||
nsEditor::CreateRange(nsIDOMNode *aStartParent, int32_t aStartOffset,
|
||||
nsIDOMNode *aEndParent, int32_t aEndOffset,
|
||||
nsRange** aRange)
|
||||
@@ -4445,7 +4445,7 @@ nsEditor::CreateRange(nsIDOMNode *aStartParent, int32_t aStartOffset,
|
||||
aEndOffset, aRange);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsresult
|
||||
nsEditor::AppendNodeToSelectionAsRange(nsIDOMNode *aNode)
|
||||
{
|
||||
NS_ENSURE_TRUE(aNode, NS_ERROR_NULL_POINTER);
|
||||
@@ -4456,9 +4456,9 @@ nsEditor::AppendNodeToSelectionAsRange(nsIDOMNode *aNode)
|
||||
nsresult res = aNode->GetParentNode(getter_AddRefs(parentNode));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
NS_ENSURE_TRUE(parentNode, NS_ERROR_NULL_POINTER);
|
||||
|
||||
|
||||
int32_t offset = GetChildOffset(aNode, parentNode);
|
||||
|
||||
|
||||
nsRefPtr<nsRange> range;
|
||||
res = CreateRange(parentNode, offset, parentNode, offset+1, getter_AddRefs(range));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
@@ -4471,7 +4471,7 @@ nsresult nsEditor::ClearSelection()
|
||||
{
|
||||
nsRefPtr<Selection> selection = GetSelection();
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_FAILURE);
|
||||
return selection->RemoveAllRanges();
|
||||
return selection->RemoveAllRanges();
|
||||
}
|
||||
|
||||
already_AddRefed<Element>
|
||||
@@ -4569,7 +4569,7 @@ nsEditor::HandleKeyPressEvent(nsIDOMKeyEvent* aKeyEvent)
|
||||
}
|
||||
DeleteSelection(nsIEditor::eNext, nsIEditor::eStrip);
|
||||
aKeyEvent->PreventDefault(); // consumed
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -4840,12 +4840,12 @@ nsEditor::DumpNode(nsIDOMNode *aNode, int32_t indent)
|
||||
int32_t i;
|
||||
for (i=0; i<indent; i++)
|
||||
printf(" ");
|
||||
|
||||
|
||||
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(aNode);
|
||||
nsCOMPtr<nsIDOMDocumentFragment> docfrag = do_QueryInterface(aNode);
|
||||
|
||||
|
||||
if (element || docfrag)
|
||||
{
|
||||
{
|
||||
if (element)
|
||||
{
|
||||
nsAutoString tag;
|
||||
|
||||
+26
-26
@@ -132,9 +132,9 @@ inline bool operator!(const EditAction& aOp)
|
||||
return aOp == EditAction::none;
|
||||
}
|
||||
|
||||
/** implementation of an editor object. it will be the controller/focal point
|
||||
* for the main editor services. i.e. the GUIManager, publishing, transaction
|
||||
* manager, event interfaces. the idea for the event interfaces is to have them
|
||||
/** implementation of an editor object. it will be the controller/focal point
|
||||
* for the main editor services. i.e. the GUIManager, publishing, transaction
|
||||
* manager, event interfaces. the idea for the event interfaces is to have them
|
||||
* delegate the actual commands to the editor independent of the XPFE implementation.
|
||||
*/
|
||||
class nsEditor : public nsIEditor,
|
||||
@@ -157,7 +157,7 @@ public:
|
||||
nsEditor();
|
||||
|
||||
protected:
|
||||
/** The default destructor. This should suffice. Should this be pure virtual
|
||||
/** The default destructor. This should suffice. Should this be pure virtual
|
||||
* for someone to derive from the nsEditor later? I don't believe so.
|
||||
*/
|
||||
virtual ~nsEditor();
|
||||
@@ -236,7 +236,7 @@ public:
|
||||
nsresult JoinNodes(nsINode& aLeftNode, nsINode& aRightNode);
|
||||
nsresult MoveNode(nsIContent* aNode, nsINode* aParent, int32_t aOffset);
|
||||
|
||||
/* Method to replace certain CreateElementNS() calls.
|
||||
/* Method to replace certain CreateElementNS() calls.
|
||||
Arguments:
|
||||
nsIAtom* aTag - tag you want
|
||||
*/
|
||||
@@ -294,8 +294,8 @@ protected:
|
||||
int32_t* aOffset,
|
||||
int32_t* aLength);
|
||||
|
||||
nsresult CreateTxnForDeleteInsertionPoint(nsRange* aRange,
|
||||
EDirection aAction,
|
||||
nsresult CreateTxnForDeleteInsertionPoint(nsRange* aRange,
|
||||
EDirection aAction,
|
||||
EditAggregateTxn* aTxn,
|
||||
nsINode** aNode,
|
||||
int32_t* aOffset,
|
||||
@@ -322,7 +322,7 @@ protected:
|
||||
*/
|
||||
NS_IMETHOD CreateTxnForRemoveStyleSheet(mozilla::CSSStyleSheet* aSheet,
|
||||
RemoveStyleSheetTxn* *aTxn);
|
||||
|
||||
|
||||
nsresult DeleteText(nsGenericDOMDataNode& aElement,
|
||||
uint32_t aOffset, uint32_t aLength);
|
||||
|
||||
@@ -335,7 +335,7 @@ protected:
|
||||
already_AddRefed<mozilla::dom::DeleteTextTxn>
|
||||
CreateTxnForDeleteCharacter(nsGenericDOMDataNode& aData, uint32_t aOffset,
|
||||
EDirection aDirection);
|
||||
|
||||
|
||||
already_AddRefed<mozilla::dom::SplitNodeTxn>
|
||||
CreateTxnForSplitNode(nsIContent& aNode, uint32_t aOffset);
|
||||
|
||||
@@ -364,10 +364,10 @@ protected:
|
||||
eDocumentToBeDestroyed,
|
||||
eDocumentStateChanged
|
||||
} TDocumentListenerNotification;
|
||||
|
||||
|
||||
// tell the doc state listeners that the doc state has changed
|
||||
NS_IMETHOD NotifyDocumentListeners(TDocumentListenerNotification aNotificationType);
|
||||
|
||||
|
||||
/** make the given selection span the entire document */
|
||||
virtual nsresult SelectEntireDocument(mozilla::dom::Selection* aSelection);
|
||||
|
||||
@@ -385,15 +385,15 @@ protected:
|
||||
|
||||
// Convenience method; forwards to IsBlockNode(nsINode*).
|
||||
bool IsBlockNode(nsIDOMNode* aNode);
|
||||
// stub. see comment in source.
|
||||
// stub. see comment in source.
|
||||
virtual bool IsBlockNode(nsINode* aNode);
|
||||
|
||||
|
||||
// helper for GetPriorNode and GetNextNode
|
||||
nsIContent* FindNextLeafNode(nsINode *aCurrentNode,
|
||||
bool aGoForward,
|
||||
bool bNoBlockCrossing);
|
||||
|
||||
// install the event listeners for the editor
|
||||
// install the event listeners for the editor
|
||||
virtual nsresult InstallEventListeners();
|
||||
|
||||
virtual void CreateEventListeners();
|
||||
@@ -432,14 +432,14 @@ public:
|
||||
* with a call to EndOperation */
|
||||
NS_IMETHOD EndOperation();
|
||||
|
||||
/** routines for managing the preservation of selection across
|
||||
/** routines for managing the preservation of selection across
|
||||
* various editor actions */
|
||||
bool ArePreservingSelection();
|
||||
void PreserveSelectionAcrossActions(mozilla::dom::Selection* aSel);
|
||||
nsresult RestorePreservedSelection(mozilla::dom::Selection* aSel);
|
||||
void StopPreservingSelection();
|
||||
|
||||
/**
|
||||
/**
|
||||
* SplitNode() creates a new node identical to an existing node, and split
|
||||
* the contents between the two nodes
|
||||
* @param aExistingRightNode The node to split. It will become the new
|
||||
@@ -453,7 +453,7 @@ public:
|
||||
int32_t aOffset,
|
||||
nsIContent& aNewLeftNode);
|
||||
|
||||
/**
|
||||
/**
|
||||
* JoinNodes() takes 2 nodes and merge their content|children.
|
||||
* @param aNodeToKeep The node that will remain after the join.
|
||||
* @param aNodeToJoin The node that will be joined with aNodeToKeep.
|
||||
@@ -479,9 +479,9 @@ public:
|
||||
int32_t* outOffset);
|
||||
static nsINode* GetNodeLocation(nsINode* aChild, int32_t* aOffset);
|
||||
|
||||
/** returns the number of things inside aNode in the out-param aCount.
|
||||
* @param aNode is the node to get the length of.
|
||||
* If aNode is text, returns number of characters.
|
||||
/** returns the number of things inside aNode in the out-param aCount.
|
||||
* @param aNode is the node to get the length of.
|
||||
* If aNode is text, returns number of characters.
|
||||
* If not, returns number of children nodes.
|
||||
* @param aCount [OUT] the result of the above calculation.
|
||||
*/
|
||||
@@ -577,7 +577,7 @@ public:
|
||||
|
||||
/** counts number of editable child nodes */
|
||||
uint32_t CountEditableChildren(nsINode* aNode);
|
||||
|
||||
|
||||
/** Find the deep first and last children. */
|
||||
nsINode* GetFirstEditableNode(nsINode* aRoot);
|
||||
|
||||
@@ -599,7 +599,7 @@ public:
|
||||
|
||||
static bool IsTextNode(nsIDOMNode *aNode);
|
||||
static bool IsTextNode(nsINode *aNode);
|
||||
|
||||
|
||||
static nsCOMPtr<nsIDOMNode> GetChildAt(nsIDOMNode *aParent, int32_t aOffset);
|
||||
static nsCOMPtr<nsIDOMNode> GetNodeAtRangeOffsetPoint(nsIDOMNode* aParentOrNode, int32_t aOffset);
|
||||
|
||||
@@ -621,7 +621,7 @@ public:
|
||||
mozilla::dom::Selection* GetSelection(int16_t aSelectionType =
|
||||
nsISelectionController::SELECTION_NORMAL);
|
||||
|
||||
// Helpers to add a node to the selection.
|
||||
// Helpers to add a node to the selection.
|
||||
// Used by table cell selection methods
|
||||
nsresult CreateRange(nsIDOMNode *aStartParent, int32_t aStartOffset,
|
||||
nsIDOMNode *aEndParent, int32_t aEndOffset,
|
||||
@@ -634,8 +634,8 @@ public:
|
||||
|
||||
nsresult IsPreformatted(nsIDOMNode *aNode, bool *aResult);
|
||||
|
||||
nsresult SplitNodeDeep(nsIDOMNode *aNode,
|
||||
nsIDOMNode *aSplitPointParent,
|
||||
nsresult SplitNodeDeep(nsIDOMNode *aNode,
|
||||
nsIDOMNode *aSplitPointParent,
|
||||
int32_t aSplitPointOffset,
|
||||
int32_t *outOffset,
|
||||
bool aNoEmptyContainers = false,
|
||||
@@ -734,7 +734,7 @@ public:
|
||||
{
|
||||
return (mFlags & nsIPlaintextEditor::eEditorDontEchoPassword) != 0;
|
||||
}
|
||||
|
||||
|
||||
bool ShouldSkipSpellCheck() const
|
||||
{
|
||||
return (mFlags & nsIPlaintextEditor::eEditorSkipSpellCheck) != 0;
|
||||
|
||||
@@ -20,9 +20,9 @@ class nsBaseEditorCommand : public nsIControllerCommand
|
||||
{
|
||||
public:
|
||||
nsBaseEditorCommand();
|
||||
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
|
||||
NS_IMETHOD IsCommandEnabled(const char * aCommandName, nsISupports *aCommandRefCon, bool *_retval) override = 0;
|
||||
NS_IMETHOD DoCommand(const char *aCommandName, nsISupports *aCommandRefCon) override = 0;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ class nsIControllerCommandTable;
|
||||
// the editor controller is used for both text widgets, and basic text editing
|
||||
// commands in composer. The refCon that gets passed to its commands is an nsIEditor.
|
||||
|
||||
class nsEditorController
|
||||
class nsEditorController
|
||||
{
|
||||
public:
|
||||
static nsresult RegisterEditorCommands(nsIControllerCommandTable* inCommandTable);
|
||||
|
||||
@@ -106,7 +106,7 @@ nsEditorEventListener::nsEditorEventListener()
|
||||
{
|
||||
}
|
||||
|
||||
nsEditorEventListener::~nsEditorEventListener()
|
||||
nsEditorEventListener::~nsEditorEventListener()
|
||||
{
|
||||
if (mEditor) {
|
||||
NS_WARNING("We're not uninstalled");
|
||||
@@ -685,7 +685,7 @@ nsEditorEventListener::MouseClick(nsIDOMMouseEvent* aMouseEvent)
|
||||
return rv;
|
||||
}
|
||||
|
||||
// If we got a mouse down inside the editing area, we should force the
|
||||
// If we got a mouse down inside the editing area, we should force the
|
||||
// IME to commit before we change the cursor position
|
||||
mEditor->ForceCompositionEnd();
|
||||
|
||||
@@ -721,7 +721,7 @@ nsEditorEventListener::HandleMiddleClickPaste(nsIDOMMouseEvent* aMouseEvent)
|
||||
}
|
||||
|
||||
// If the ctrl key is pressed, we'll do paste as quotation.
|
||||
// Would've used the alt key, but the kde wmgr treats alt-middle specially.
|
||||
// Would've used the alt key, but the kde wmgr treats alt-middle specially.
|
||||
bool ctrlKey = false;
|
||||
aMouseEvent->GetCtrlKey(&ctrlKey);
|
||||
|
||||
@@ -923,8 +923,8 @@ nsEditorEventListener::Drop(nsIDOMDragEvent* aDragEvent)
|
||||
if ((mEditor->IsReadonly() || mEditor->IsDisabled()) &&
|
||||
!IsFileControlTextBox()) {
|
||||
// it was decided to "eat" the event as this is the "least surprise"
|
||||
// since someone else handling it might be unintentional and the
|
||||
// user could probably re-drag to be not over the disabled/readonly
|
||||
// since someone else handling it might be unintentional and the
|
||||
// user could probably re-drag to be not over the disabled/readonly
|
||||
// editfields if that is what is desired.
|
||||
return aDragEvent->StopPropagation();
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ using namespace mozilla::dom;
|
||||
|
||||
nsAutoSelectionReset::nsAutoSelectionReset(Selection* aSel, nsEditor* aEd)
|
||||
: mSel(nullptr), mEd(nullptr)
|
||||
{
|
||||
{
|
||||
if (!aSel || !aEd) return; // not much we can do, bail.
|
||||
if (aEd->ArePreservingSelection()) return; // we already have initted mSavedSel, so this must be nested call.
|
||||
mSel = aSel;
|
||||
@@ -175,7 +175,7 @@ nsEditorHookUtils::GetHookEnumeratorFromDocument(nsIDOMDocument *aDoc,
|
||||
}
|
||||
|
||||
bool
|
||||
nsEditorHookUtils::DoInsertionHook(nsIDOMDocument *aDoc, nsIDOMEvent *aDropEvent,
|
||||
nsEditorHookUtils::DoInsertionHook(nsIDOMDocument *aDoc, nsIDOMEvent *aDropEvent,
|
||||
nsITransferable *aTrans)
|
||||
{
|
||||
nsCOMPtr<nsISimpleEnumerator> enumerator;
|
||||
|
||||
@@ -27,7 +27,7 @@ class Selection;
|
||||
} // namespace mozilla
|
||||
|
||||
/***************************************************************************
|
||||
* stack based helper class for batching a collection of txns inside a
|
||||
* stack based helper class for batching a collection of txns inside a
|
||||
* placeholder txn.
|
||||
*/
|
||||
class MOZ_STACK_CLASS nsAutoPlaceHolderBatch
|
||||
@@ -35,13 +35,13 @@ class MOZ_STACK_CLASS nsAutoPlaceHolderBatch
|
||||
private:
|
||||
nsCOMPtr<nsIEditor> mEd;
|
||||
public:
|
||||
nsAutoPlaceHolderBatch( nsIEditor *aEd, nsIAtom *atom) : mEd(do_QueryInterface(aEd))
|
||||
nsAutoPlaceHolderBatch( nsIEditor *aEd, nsIAtom *atom) : mEd(do_QueryInterface(aEd))
|
||||
{ if (mEd) mEd->BeginPlaceHolderTransaction(atom); }
|
||||
~nsAutoPlaceHolderBatch() { if (mEd) mEd->EndPlaceHolderTransaction(); }
|
||||
};
|
||||
|
||||
/***************************************************************************
|
||||
* stack based helper class for batching a collection of txns.
|
||||
* stack based helper class for batching a collection of txns.
|
||||
* Note: I changed this to use placeholder batching so that we get
|
||||
* proper selection save/restore across undo/redo.
|
||||
*/
|
||||
@@ -66,7 +66,7 @@ class MOZ_STACK_CLASS nsAutoSelectionReset
|
||||
public:
|
||||
/** constructor responsible for remembering all state needed to restore aSel */
|
||||
nsAutoSelectionReset(mozilla::dom::Selection* aSel, nsEditor* aEd);
|
||||
|
||||
|
||||
/** destructor restores mSel to its former state */
|
||||
~nsAutoSelectionReset();
|
||||
|
||||
@@ -80,25 +80,25 @@ class MOZ_STACK_CLASS nsAutoSelectionReset
|
||||
class MOZ_STACK_CLASS nsAutoRules
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
nsAutoRules(nsEditor *ed, EditAction action,
|
||||
nsIEditor::EDirection aDirection) :
|
||||
mEd(ed), mDoNothing(false)
|
||||
{
|
||||
{
|
||||
if (mEd && !mEd->mAction) // mAction will already be set if this is nested call
|
||||
{
|
||||
mEd->StartOperation(action, aDirection);
|
||||
}
|
||||
else mDoNothing = true; // nested calls will end up here
|
||||
}
|
||||
~nsAutoRules()
|
||||
~nsAutoRules()
|
||||
{
|
||||
if (mEd && !mDoNothing)
|
||||
if (mEd && !mDoNothing)
|
||||
{
|
||||
mEd->EndOperation();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
nsEditor *mEd;
|
||||
bool mDoNothing;
|
||||
@@ -112,24 +112,24 @@ class MOZ_STACK_CLASS nsAutoRules
|
||||
class MOZ_STACK_CLASS nsAutoTxnsConserveSelection
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
explicit nsAutoTxnsConserveSelection(nsEditor *ed) : mEd(ed), mOldState(true)
|
||||
{
|
||||
if (mEd)
|
||||
if (mEd)
|
||||
{
|
||||
mOldState = mEd->GetShouldTxnSetSelection();
|
||||
mEd->SetShouldTxnSetSelection(false);
|
||||
}
|
||||
}
|
||||
|
||||
~nsAutoTxnsConserveSelection()
|
||||
|
||||
~nsAutoTxnsConserveSelection()
|
||||
{
|
||||
if (mEd)
|
||||
if (mEd)
|
||||
{
|
||||
mEd->SetShouldTxnSetSelection(mOldState);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
nsEditor *mEd;
|
||||
bool mOldState;
|
||||
@@ -141,21 +141,21 @@ class MOZ_STACK_CLASS nsAutoTxnsConserveSelection
|
||||
class MOZ_STACK_CLASS nsAutoUpdateViewBatch
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
explicit nsAutoUpdateViewBatch(nsEditor *ed) : mEd(ed)
|
||||
{
|
||||
NS_ASSERTION(mEd, "null mEd pointer!");
|
||||
|
||||
if (mEd)
|
||||
if (mEd)
|
||||
mEd->BeginUpdateViewBatch();
|
||||
}
|
||||
|
||||
~nsAutoUpdateViewBatch()
|
||||
|
||||
~nsAutoUpdateViewBatch()
|
||||
{
|
||||
if (mEd)
|
||||
if (mEd)
|
||||
mEd->EndUpdateViewBatch();
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
nsEditor *mEd;
|
||||
};
|
||||
@@ -164,7 +164,7 @@ class MOZ_STACK_CLASS nsAutoUpdateViewBatch
|
||||
* some helper classes for iterating the dom tree
|
||||
*****************************************************************************/
|
||||
|
||||
class nsBoolDomIterFunctor
|
||||
class nsBoolDomIterFunctor
|
||||
{
|
||||
public:
|
||||
virtual bool operator()(nsINode* aNode) const = 0;
|
||||
|
||||
@@ -62,7 +62,7 @@ nsHTMLEditor::AbsolutePositionSelection(bool aEnabled)
|
||||
aEnabled ? EditAction::setAbsolutePosition :
|
||||
EditAction::removeAbsolutePosition,
|
||||
nsIEditor::eNext);
|
||||
|
||||
|
||||
// the line below does not match the code; should it be removed?
|
||||
// Find out if the selection is collapsed:
|
||||
nsRefPtr<Selection> selection = GetSelection();
|
||||
@@ -76,7 +76,7 @@ nsHTMLEditor::AbsolutePositionSelection(bool aEnabled)
|
||||
nsresult res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
||||
if (NS_FAILED(res) || cancel)
|
||||
return res;
|
||||
|
||||
|
||||
return mRules->DidDoAction(selection, &ruleInfo, res);
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ nsHTMLEditor::GetAbsolutelyPositionedSelectionContainer(nsIDOMElement **_retval)
|
||||
}
|
||||
}
|
||||
|
||||
element = do_QueryInterface(resultNode );
|
||||
element = do_QueryInterface(resultNode );
|
||||
*_retval = element;
|
||||
NS_IF_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
@@ -171,7 +171,7 @@ nsHTMLEditor::RelativeChangeZIndex(int32_t aChange)
|
||||
(aChange < 0) ? EditAction::decreaseZIndex :
|
||||
EditAction::increaseZIndex,
|
||||
nsIEditor::eNext);
|
||||
|
||||
|
||||
// brade: can we get rid of this comment?
|
||||
// Find out if the selection is collapsed:
|
||||
nsRefPtr<Selection> selection = GetSelection();
|
||||
@@ -184,7 +184,7 @@ nsHTMLEditor::RelativeChangeZIndex(int32_t aChange)
|
||||
nsresult res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
||||
if (cancel || NS_FAILED(res))
|
||||
return res;
|
||||
|
||||
|
||||
return mRules->DidDoAction(selection, &ruleInfo, res);
|
||||
}
|
||||
|
||||
@@ -618,7 +618,7 @@ nsHTMLEditor::CheckPositionedElementBGandFG(nsIDOMElement * aElement,
|
||||
NS_ENSURE_STATE(element || !aElement);
|
||||
|
||||
aReturn.Truncate();
|
||||
|
||||
|
||||
nsAutoString bgImageStr;
|
||||
nsresult res =
|
||||
mHTMLCSSUtils->GetComputedProperty(*element, *nsGkAtoms::background_image,
|
||||
|
||||
@@ -150,14 +150,14 @@ void ProcessMarginLeftValue(const nsAString * aInputString, nsAString & aOutputS
|
||||
if (aInputString) {
|
||||
if (aInputString->EqualsLiteral("center") ||
|
||||
aInputString->EqualsLiteral("-moz-center")) {
|
||||
aOutputString.AppendLiteral("auto");
|
||||
aOutputString.AppendLiteral("auto");
|
||||
}
|
||||
else if (aInputString->EqualsLiteral("right") ||
|
||||
aInputString->EqualsLiteral("-moz-right")) {
|
||||
aOutputString.AppendLiteral("auto");
|
||||
aOutputString.AppendLiteral("auto");
|
||||
}
|
||||
else {
|
||||
aOutputString.AppendLiteral("0px");
|
||||
aOutputString.AppendLiteral("0px");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -171,14 +171,14 @@ void ProcessMarginRightValue(const nsAString * aInputString, nsAString & aOutput
|
||||
if (aInputString) {
|
||||
if (aInputString->EqualsLiteral("center") ||
|
||||
aInputString->EqualsLiteral("-moz-center")) {
|
||||
aOutputString.AppendLiteral("auto");
|
||||
aOutputString.AppendLiteral("auto");
|
||||
}
|
||||
else if (aInputString->EqualsLiteral("left") ||
|
||||
aInputString->EqualsLiteral("-moz-left")) {
|
||||
aOutputString.AppendLiteral("auto");
|
||||
aOutputString.AppendLiteral("auto");
|
||||
}
|
||||
else {
|
||||
aOutputString.AppendLiteral("0px");
|
||||
aOutputString.AppendLiteral("0px");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1190,7 +1190,7 @@ nsHTMLCSSUtils::IsCSSPrefChecked()
|
||||
}
|
||||
|
||||
// ElementsSameStyle compares two elements and checks if they have the same
|
||||
// specified CSS declarations in the STYLE attribute
|
||||
// specified CSS declarations in the STYLE attribute
|
||||
// The answer is always negative if at least one of them carries an ID or a class
|
||||
bool
|
||||
nsHTMLCSSUtils::ElementsSameStyle(nsIDOMNode *aFirstNode, nsIDOMNode *aSecondNode)
|
||||
|
||||
@@ -285,7 +285,7 @@ public:
|
||||
bool IsCSSPrefChecked();
|
||||
|
||||
/** ElementsSameStyle compares two elements and checks if they have the same
|
||||
* specified CSS declarations in the STYLE attribute
|
||||
* specified CSS declarations in the STYLE attribute
|
||||
* The answer is always false if at least one of them carries an ID or a class
|
||||
*
|
||||
* @return true if the two elements are considered to have same styles
|
||||
@@ -404,7 +404,7 @@ private:
|
||||
|
||||
private:
|
||||
nsHTMLEditor *mHTMLEditor;
|
||||
bool mIsCSSPrefChecked;
|
||||
bool mIsCSSPrefChecked;
|
||||
};
|
||||
|
||||
#define NS_EDITOR_INDENT_INCREMENT_IN 0.4134f
|
||||
@@ -415,6 +415,6 @@ private:
|
||||
#define NS_EDITOR_INDENT_INCREMENT_EM 3
|
||||
#define NS_EDITOR_INDENT_INCREMENT_EX 6
|
||||
#define NS_EDITOR_INDENT_INCREMENT_PX 40
|
||||
#define NS_EDITOR_INDENT_INCREMENT_PERCENT 4
|
||||
#define NS_EDITOR_INDENT_INCREMENT_PERCENT 4
|
||||
|
||||
#endif /* nsHTMLCSSUtils_h__ */
|
||||
|
||||
@@ -96,10 +96,10 @@ using namespace mozilla::dom;
|
||||
#define kInsertCookie "_moz_Insert Here_moz_"
|
||||
|
||||
// some little helpers
|
||||
static bool FindIntegerAfterString(const char *aLeadingString,
|
||||
static bool FindIntegerAfterString(const char *aLeadingString,
|
||||
nsCString &aCStr, int32_t &foundNumber);
|
||||
static nsresult RemoveFragComments(nsCString &theStr);
|
||||
static void RemoveBodyAndHead(nsIDOMNode *aNode);
|
||||
static void RemoveBodyAndHead(nsINode& aNode);
|
||||
static nsresult FindTargetNode(nsIDOMNode *aStart, nsCOMPtr<nsIDOMNode> &aResult);
|
||||
|
||||
nsresult
|
||||
@@ -325,7 +325,7 @@ nsHTMLEditor::DoInsertHTMLWithContext(const nsAString & aInputString,
|
||||
// do we have table content to paste? If so, we want to delete
|
||||
// the selected table cells and replace with new table elements;
|
||||
// but if not we want to delete _contents_ of cells and replace
|
||||
// with non-table elements. Use cellSelectionMode bool to
|
||||
// with non-table elements. Use cellSelectionMode bool to
|
||||
// indicate results.
|
||||
if (!nsHTMLEditUtils::IsTableElement(nodeList[0])) {
|
||||
cellSelectionMode = false;
|
||||
@@ -418,8 +418,8 @@ nsHTMLEditor::DoInsertHTMLWithContext(const nsAString & aInputString,
|
||||
startListAndTableArray);
|
||||
}
|
||||
|
||||
// if we have pieces of tables or lists to be inserted, let's force the paste
|
||||
// to deal with table elements right away, so that it doesn't orphan some
|
||||
// if we have pieces of tables or lists to be inserted, let's force the paste
|
||||
// to deal with table elements right away, so that it doesn't orphan some
|
||||
// table or list contents outside the table or list.
|
||||
if (highWaterMark >= 0)
|
||||
{
|
||||
@@ -465,7 +465,7 @@ nsHTMLEditor::DoInsertHTMLWithContext(const nsAString & aInputString,
|
||||
|
||||
if (insertedContextParent)
|
||||
{
|
||||
// if we had to insert something higher up in the paste hierarchy, we want to
|
||||
// if we had to insert something higher up in the paste hierarchy, we want to
|
||||
// skip any further paste nodes that descend from that. Else we will paste twice.
|
||||
if (nsEditorUtils::IsDescendantOf(curNode, insertedContextParent))
|
||||
continue;
|
||||
@@ -496,7 +496,7 @@ nsHTMLEditor::DoInsertHTMLWithContext(const nsAString & aInputString,
|
||||
// a list on the clipboard, and are trying to insert
|
||||
// into a list or list item, insert the appropriate children instead,
|
||||
// ie, merge the lists instead of pasting in a sublist.
|
||||
else if (nsHTMLEditUtils::IsList(curNode) &&
|
||||
else if (nsHTMLEditUtils::IsList(curNode) &&
|
||||
(nsHTMLEditUtils::IsList(parentNode) || nsHTMLEditUtils::IsListItem(parentNode)) )
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> child, tmp;
|
||||
@@ -594,7 +594,7 @@ nsHTMLEditor::DoInsertHTMLWithContext(const nsAString & aInputString,
|
||||
}
|
||||
|
||||
// Now collapse the selection to the end of what we just inserted:
|
||||
if (lastInsertNode)
|
||||
if (lastInsertNode)
|
||||
{
|
||||
// set selection to the end of what we just pasted.
|
||||
nsCOMPtr<nsIDOMNode> selNode, tmp, highTable;
|
||||
@@ -644,7 +644,7 @@ nsHTMLEditor::DoInsertHTMLWithContext(const nsAString & aInputString,
|
||||
wsRunObj.PriorVisibleNode(selNode_, selOffset, address_of(visNode),
|
||||
&outVisOffset, &visType);
|
||||
if (visType == WSType::br) {
|
||||
// we are after a break. Is it visible? Despite the name,
|
||||
// we are after a break. Is it visible? Despite the name,
|
||||
// PriorVisibleNode does not make that determination for breaks.
|
||||
// It also may not return the break in visNode. We have to pull it
|
||||
// out of the nsWSRunObject's state.
|
||||
@@ -662,7 +662,7 @@ nsHTMLEditor::DoInsertHTMLWithContext(const nsAString & aInputString,
|
||||
selNode = GetAsDOMNode(visNode);
|
||||
selOffset = outVisOffset; // PriorVisibleNode already set offset to _after_ the text or ws
|
||||
} else if (visType == WSType::special) {
|
||||
// prior visible thing is an image or some other non-text thingy.
|
||||
// prior visible thing is an image or some other non-text thingy.
|
||||
// We want to be right after it.
|
||||
selNode = GetNodeLocation(GetAsDOMNode(wsRunObj.mStartReasonNode), &selOffset);
|
||||
++selOffset;
|
||||
@@ -716,15 +716,15 @@ nsHTMLEditor::RemoveInsertionListener(nsIContentFilter *aListener)
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsHTMLEditor::DoContentFilterCallback(const nsAString &aFlavor,
|
||||
nsHTMLEditor::DoContentFilterCallback(const nsAString &aFlavor,
|
||||
nsIDOMDocument *sourceDoc,
|
||||
bool aWillDeleteSelection,
|
||||
nsIDOMNode **aFragmentAsNode,
|
||||
nsIDOMNode **aFragStartNode,
|
||||
nsIDOMNode **aFragmentAsNode,
|
||||
nsIDOMNode **aFragStartNode,
|
||||
int32_t *aFragStartOffset,
|
||||
nsIDOMNode **aFragEndNode,
|
||||
nsIDOMNode **aFragEndNode,
|
||||
int32_t *aFragEndOffset,
|
||||
nsIDOMNode **aTargetNode,
|
||||
int32_t *aTargetOffset,
|
||||
@@ -755,7 +755,7 @@ nsHTMLEditor::IsInLink(nsIDOMNode *aNode, nsCOMPtr<nsIDOMNode> *outLink)
|
||||
nsCOMPtr<nsIDOMNode> tmp, node = aNode;
|
||||
while (node)
|
||||
{
|
||||
if (nsHTMLEditUtils::IsLink(node))
|
||||
if (nsHTMLEditUtils::IsLink(node))
|
||||
{
|
||||
if (outLink)
|
||||
*outLink = node;
|
||||
@@ -769,36 +769,27 @@ nsHTMLEditor::IsInLink(nsIDOMNode *aNode, nsCOMPtr<nsIDOMNode> *outLink)
|
||||
|
||||
|
||||
nsresult
|
||||
nsHTMLEditor::StripFormattingNodes(nsIDOMNode *aNode, bool aListOnly)
|
||||
nsHTMLEditor::StripFormattingNodes(nsIContent& aNode, bool aListOnly)
|
||||
{
|
||||
NS_ENSURE_TRUE(aNode, NS_ERROR_NULL_POINTER);
|
||||
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
|
||||
if (content->TextIsOnlyWhitespace())
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> parent, ignored;
|
||||
aNode->GetParentNode(getter_AddRefs(parent));
|
||||
if (parent)
|
||||
{
|
||||
if (aNode.TextIsOnlyWhitespace()) {
|
||||
nsCOMPtr<nsINode> parent = aNode.GetParentNode();
|
||||
if (parent) {
|
||||
if (!aListOnly || nsHTMLEditUtils::IsList(parent)) {
|
||||
return parent->RemoveChild(aNode, getter_AddRefs(ignored));
|
||||
ErrorResult rv;
|
||||
parent->RemoveChild(aNode, rv);
|
||||
return rv.StealNSResult();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
if (!nsHTMLEditUtils::IsPre(aNode))
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> child;
|
||||
aNode->GetLastChild(getter_AddRefs(child));
|
||||
|
||||
while (child)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> tmp;
|
||||
child->GetPreviousSibling(getter_AddRefs(tmp));
|
||||
nsresult rv = StripFormattingNodes(child, aListOnly);
|
||||
if (!aNode.IsHTMLElement(nsGkAtoms::pre)) {
|
||||
nsCOMPtr<nsIContent> child = aNode.GetLastChild();
|
||||
while (child) {
|
||||
nsCOMPtr<nsIContent> previous = child->GetPreviousSibling();
|
||||
nsresult rv = StripFormattingNodes(*child, aListOnly);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
child = tmp;
|
||||
child = previous.forget();
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
@@ -829,7 +820,7 @@ nsHTMLEditor::PrepareHTMLTransferable(nsITransferable **aTransferable,
|
||||
// This should only happen in html editors, not plaintext
|
||||
if (!IsPlaintextEditor())
|
||||
{
|
||||
if (!aHavePrivFlavor)
|
||||
if (!aHavePrivFlavor)
|
||||
{
|
||||
(*aTransferable)->AddDataFlavor(kNativeHTMLMime);
|
||||
}
|
||||
@@ -862,12 +853,12 @@ nsHTMLEditor::PrepareHTMLTransferable(nsITransferable **aTransferable,
|
||||
(*aTransferable)->AddDataFlavor(kUnicodeMime);
|
||||
(*aTransferable)->AddDataFlavor(kMozTextInternal);
|
||||
}
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool
|
||||
FindIntegerAfterString(const char *aLeadingString,
|
||||
FindIntegerAfterString(const char *aLeadingString,
|
||||
nsCString &aCStr, int32_t &foundNumber)
|
||||
{
|
||||
// first obtain offsets from cfhtml str
|
||||
@@ -912,16 +903,16 @@ nsHTMLEditor::ParseCFHTML(nsCString & aCfhtml, char16_t **aStuffToPaste, char16_
|
||||
{
|
||||
// First obtain offsets from cfhtml str.
|
||||
int32_t startHTML, endHTML, startFragment, endFragment;
|
||||
if (!FindIntegerAfterString("StartHTML:", aCfhtml, startHTML) ||
|
||||
if (!FindIntegerAfterString("StartHTML:", aCfhtml, startHTML) ||
|
||||
startHTML < -1)
|
||||
return NS_ERROR_FAILURE;
|
||||
if (!FindIntegerAfterString("EndHTML:", aCfhtml, endHTML) ||
|
||||
if (!FindIntegerAfterString("EndHTML:", aCfhtml, endHTML) ||
|
||||
endHTML < -1)
|
||||
return NS_ERROR_FAILURE;
|
||||
if (!FindIntegerAfterString("StartFragment:", aCfhtml, startFragment) ||
|
||||
if (!FindIntegerAfterString("StartFragment:", aCfhtml, startFragment) ||
|
||||
startFragment < 0)
|
||||
return NS_ERROR_FAILURE;
|
||||
if (!FindIntegerAfterString("EndFragment:", aCfhtml, endFragment) ||
|
||||
if (!FindIntegerAfterString("EndFragment:", aCfhtml, endFragment) ||
|
||||
startFragment < 0)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
@@ -958,10 +949,10 @@ nsHTMLEditor::ParseCFHTML(nsCString & aCfhtml, char16_t **aStuffToPaste, char16_
|
||||
// so StartFragment is good, so do nothing.
|
||||
break;
|
||||
}
|
||||
else if (aCfhtml[curPos] == '<')
|
||||
else if (aCfhtml[curPos] == '<')
|
||||
{
|
||||
// if we are at the start, then we want to see the '<'
|
||||
if (curPos != startFragment)
|
||||
if (curPos != startFragment)
|
||||
{
|
||||
// working backwards, the first thing we see is the start of a tag
|
||||
// so StartFragment is bad, so we need to update it.
|
||||
@@ -970,7 +961,7 @@ nsHTMLEditor::ParseCFHTML(nsCString & aCfhtml, char16_t **aStuffToPaste, char16_
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
curPos--;
|
||||
}
|
||||
@@ -993,8 +984,8 @@ nsHTMLEditor::ParseCFHTML(nsCString & aCfhtml, char16_t **aStuffToPaste, char16_
|
||||
int32_t oldLengthInChars = fragUcs2Str.Length() + 1; // +1 to include null terminator
|
||||
int32_t newLengthInChars = 0;
|
||||
*aStuffToPaste = nsLinebreakConverter::ConvertUnicharLineBreaks(fragUcs2Str.get(),
|
||||
nsLinebreakConverter::eLinebreakAny,
|
||||
nsLinebreakConverter::eLinebreakContent,
|
||||
nsLinebreakConverter::eLinebreakAny,
|
||||
nsLinebreakConverter::eLinebreakContent,
|
||||
oldLengthInChars, &newLengthInChars);
|
||||
NS_ENSURE_TRUE(*aStuffToPaste, NS_ERROR_FAILURE);
|
||||
|
||||
@@ -1002,8 +993,8 @@ nsHTMLEditor::ParseCFHTML(nsCString & aCfhtml, char16_t **aStuffToPaste, char16_
|
||||
oldLengthInChars = cntxtUcs2Str.Length() + 1; // +1 to include null terminator
|
||||
newLengthInChars = 0;
|
||||
*aCfcontext = nsLinebreakConverter::ConvertUnicharLineBreaks(cntxtUcs2Str.get(),
|
||||
nsLinebreakConverter::eLinebreakAny,
|
||||
nsLinebreakConverter::eLinebreakContent,
|
||||
nsLinebreakConverter::eLinebreakAny,
|
||||
nsLinebreakConverter::eLinebreakContent,
|
||||
oldLengthInChars, &newLengthInChars);
|
||||
// it's ok for context to be empty. frag might be whole doc and contain all its context.
|
||||
|
||||
@@ -1088,7 +1079,7 @@ nsresult nsHTMLEditor::InsertObject(const char* aType, nsISupports* aObject, boo
|
||||
AppendUTF8toUTF16(data64, stuffToPaste);
|
||||
stuffToPaste.AppendLiteral("\" alt=\"\" >");
|
||||
nsAutoEditBatch beginBatching(this);
|
||||
rv = DoInsertHTMLWithContext(stuffToPaste, EmptyString(), EmptyString(),
|
||||
rv = DoInsertHTMLWithContext(stuffToPaste, EmptyString(), EmptyString(),
|
||||
NS_LITERAL_STRING(kFileMime),
|
||||
aSourceDoc,
|
||||
aDestinationNode, aDestOffset,
|
||||
@@ -1417,7 +1408,7 @@ NS_IMETHODIMP nsHTMLEditor::PasteTransferable(nsITransferable *aTransferable)
|
||||
nullptr, 0, true);
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
// HTML PasteNoFormatting. Ignore any HTML styles and formating in paste source
|
||||
//
|
||||
NS_IMETHODIMP nsHTMLEditor::PasteNoFormatting(int32_t aSelectionType)
|
||||
@@ -1438,7 +1429,7 @@ NS_IMETHODIMP nsHTMLEditor::PasteNoFormatting(int32_t aSelectionType)
|
||||
rv = nsPlaintextEditor::PrepareTransferable(getter_AddRefs(trans));
|
||||
if (NS_SUCCEEDED(rv) && trans)
|
||||
{
|
||||
// Get the Data from the clipboard
|
||||
// Get the Data from the clipboard
|
||||
if (NS_SUCCEEDED(clipboard->GetData(trans, aSelectionType)) && IsModifiable())
|
||||
{
|
||||
const nsAFlatString& empty = EmptyString();
|
||||
@@ -1893,39 +1884,34 @@ nsHTMLEditor::InsertAsCitedQuotation(const nsAString & aQuotedText,
|
||||
}
|
||||
|
||||
|
||||
void RemoveBodyAndHead(nsIDOMNode *aNode)
|
||||
void RemoveBodyAndHead(nsINode& aNode)
|
||||
{
|
||||
if (!aNode)
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> tmp, child, body, head;
|
||||
nsCOMPtr<nsIContent> body, head;
|
||||
// find the body and head nodes if any.
|
||||
// look only at immediate children of aNode.
|
||||
aNode->GetFirstChild(getter_AddRefs(child));
|
||||
while (child)
|
||||
{
|
||||
if (nsTextEditUtils::IsBody(child))
|
||||
{
|
||||
for (nsCOMPtr<nsIContent> child = aNode.GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
if (child->IsHTMLElement(nsGkAtoms::body)) {
|
||||
body = child;
|
||||
} else if (nsEditor::NodeIsType(child, nsGkAtoms::head)) {
|
||||
} else if (child->IsHTMLElement(nsGkAtoms::head)) {
|
||||
head = child;
|
||||
}
|
||||
child->GetNextSibling(getter_AddRefs(tmp));
|
||||
child = tmp;
|
||||
}
|
||||
if (head)
|
||||
{
|
||||
aNode->RemoveChild(head, getter_AddRefs(tmp));
|
||||
if (head) {
|
||||
ErrorResult ignored;
|
||||
aNode.RemoveChild(*head, ignored);
|
||||
}
|
||||
if (body)
|
||||
{
|
||||
body->GetFirstChild(getter_AddRefs(child));
|
||||
while (child)
|
||||
{
|
||||
aNode->InsertBefore(child, body, getter_AddRefs(tmp));
|
||||
body->GetFirstChild(getter_AddRefs(child));
|
||||
if (body) {
|
||||
nsCOMPtr<nsIContent> child = body->GetFirstChild();
|
||||
while (child) {
|
||||
ErrorResult ignored;
|
||||
aNode.InsertBefore(*child, body, ignored);
|
||||
child = body->GetFirstChild();
|
||||
}
|
||||
aNode->RemoveChild(body, getter_AddRefs(tmp));
|
||||
|
||||
ErrorResult ignored;
|
||||
aNode.RemoveChild(*body, ignored);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2006,27 +1992,24 @@ nsresult nsHTMLEditor::CreateDOMFragmentFromPaste(const nsAString &aInputString,
|
||||
bool aTrustedInput)
|
||||
{
|
||||
NS_ENSURE_TRUE(outFragNode && outStartNode && outEndNode, NS_ERROR_NULL_POINTER);
|
||||
nsCOMPtr<nsIDOMDocumentFragment> docfrag;
|
||||
nsCOMPtr<nsIDOMNode> contextAsNode, tmp;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsCOMPtr<nsIDocument> doc = GetDocument();
|
||||
NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
|
||||
|
||||
// if we have context info, create a fragment for that
|
||||
nsCOMPtr<nsIDOMDocumentFragment> contextfrag;
|
||||
nsCOMPtr<nsIDOMNode> contextLeaf, junk;
|
||||
if (!aContextStr.IsEmpty())
|
||||
{
|
||||
rv = ParseFragment(aContextStr, nullptr, doc, address_of(contextAsNode),
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIDOMNode> contextLeaf;
|
||||
nsRefPtr<DocumentFragment> contextAsNode;
|
||||
if (!aContextStr.IsEmpty()) {
|
||||
rv = ParseFragment(aContextStr, nullptr, doc, getter_AddRefs(contextAsNode),
|
||||
aTrustedInput);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_TRUE(contextAsNode, NS_ERROR_FAILURE);
|
||||
|
||||
rv = StripFormattingNodes(contextAsNode);
|
||||
rv = StripFormattingNodes(*contextAsNode);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
RemoveBodyAndHead(contextAsNode);
|
||||
RemoveBodyAndHead(*contextAsNode);
|
||||
|
||||
rv = FindTargetNode(contextAsNode, contextLeaf);
|
||||
if (rv == NS_FOUND_TARGET) {
|
||||
@@ -2047,57 +2030,57 @@ nsresult nsHTMLEditor::CreateDOMFragmentFromPaste(const nsAString &aInputString,
|
||||
} else {
|
||||
contextAtom = nsGkAtoms::body;
|
||||
}
|
||||
nsRefPtr<DocumentFragment> fragment;
|
||||
rv = ParseFragment(aInputString,
|
||||
contextAtom,
|
||||
doc,
|
||||
outFragNode,
|
||||
getter_AddRefs(fragment),
|
||||
aTrustedInput);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_TRUE(*outFragNode, NS_ERROR_FAILURE);
|
||||
NS_ENSURE_TRUE(fragment, NS_ERROR_FAILURE);
|
||||
|
||||
RemoveBodyAndHead(*outFragNode);
|
||||
RemoveBodyAndHead(*fragment);
|
||||
|
||||
if (contextAsNode)
|
||||
{
|
||||
if (contextAsNode) {
|
||||
// unite the two trees
|
||||
contextLeaf->AppendChild(*outFragNode, getter_AddRefs(junk));
|
||||
*outFragNode = contextAsNode;
|
||||
nsCOMPtr<nsIDOMNode> junk;
|
||||
contextLeaf->AppendChild(fragment, getter_AddRefs(junk));
|
||||
fragment = contextAsNode;
|
||||
}
|
||||
|
||||
rv = StripFormattingNodes(*outFragNode, true);
|
||||
rv = StripFormattingNodes(*fragment, true);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// If there was no context, then treat all of the data we did get as the
|
||||
// pasted data.
|
||||
if (contextLeaf)
|
||||
if (contextLeaf) {
|
||||
*outEndNode = *outStartNode = contextLeaf;
|
||||
else
|
||||
*outEndNode = *outStartNode = *outFragNode;
|
||||
} else {
|
||||
*outEndNode = *outStartNode = fragment;
|
||||
}
|
||||
|
||||
*outFragNode = fragment.forget();
|
||||
*outStartOffset = 0;
|
||||
|
||||
// get the infoString contents
|
||||
nsAutoString numstr1, numstr2;
|
||||
if (!aInfoStr.IsEmpty())
|
||||
{
|
||||
int32_t sep, num;
|
||||
sep = aInfoStr.FindChar((char16_t)',');
|
||||
numstr1 = Substring(aInfoStr, 0, sep);
|
||||
numstr2 = Substring(aInfoStr, sep+1, aInfoStr.Length() - (sep+1));
|
||||
if (!aInfoStr.IsEmpty()) {
|
||||
int32_t sep = aInfoStr.FindChar((char16_t)',');
|
||||
nsAutoString numstr1(Substring(aInfoStr, 0, sep));
|
||||
nsAutoString numstr2(Substring(aInfoStr, sep+1, aInfoStr.Length() - (sep+1)));
|
||||
|
||||
// Move the start and end children.
|
||||
nsresult err;
|
||||
num = numstr1.ToInteger(&err);
|
||||
while (num--)
|
||||
{
|
||||
int32_t num = numstr1.ToInteger(&err);
|
||||
|
||||
nsCOMPtr<nsIDOMNode> tmp;
|
||||
while (num--) {
|
||||
(*outStartNode)->GetFirstChild(getter_AddRefs(tmp));
|
||||
NS_ENSURE_TRUE(tmp, NS_ERROR_FAILURE);
|
||||
tmp.swap(*outStartNode);
|
||||
}
|
||||
|
||||
num = numstr2.ToInteger(&err);
|
||||
while (num--)
|
||||
{
|
||||
while (num--) {
|
||||
(*outEndNode)->GetLastChild(getter_AddRefs(tmp));
|
||||
NS_ENSURE_TRUE(tmp, NS_ERROR_FAILURE);
|
||||
tmp.swap(*outEndNode);
|
||||
@@ -2112,7 +2095,7 @@ nsresult nsHTMLEditor::CreateDOMFragmentFromPaste(const nsAString &aInputString,
|
||||
nsresult nsHTMLEditor::ParseFragment(const nsAString & aFragStr,
|
||||
nsIAtom* aContextLocalName,
|
||||
nsIDocument* aTargetDocument,
|
||||
nsCOMPtr<nsIDOMNode> *outNode,
|
||||
DocumentFragment** aFragment,
|
||||
bool aTrustedInput)
|
||||
{
|
||||
nsAutoScriptBlockerSuppressNodeRemoved autoBlocker;
|
||||
@@ -2132,7 +2115,7 @@ nsresult nsHTMLEditor::ParseFragment(const nsAString & aFragStr,
|
||||
nsIParserUtils::SanitizerAllowComments);
|
||||
sanitizer.Sanitize(fragment);
|
||||
}
|
||||
*outNode = fragment.forget();
|
||||
fragment.forget(aFragment);
|
||||
return rv;
|
||||
}
|
||||
|
||||
@@ -2191,7 +2174,7 @@ nsHTMLEditor::DiscoverPartialListsAndTables(nsTArray<OwningNonNull<nsINode>>& aP
|
||||
{
|
||||
int32_t ret = -1;
|
||||
int32_t listAndTableParents = aListsAndTables.Length();
|
||||
|
||||
|
||||
// Scan insertion list for table elements (other than table).
|
||||
for (auto& curNode : aPasteNodes) {
|
||||
if (nsHTMLEditUtils::IsTableElement(curNode) &&
|
||||
@@ -2239,7 +2222,7 @@ nsHTMLEditor::ScanForListAndTableStructure(StartOrEnd aStartOrEnd,
|
||||
// Look upward from first/last paste node for a piece of this list/table
|
||||
int32_t idx = aStartOrEnd == StartOrEnd::end ? aNodes.Length() - 1 : 0;
|
||||
bool isList = nsHTMLEditUtils::IsList(&aListOrTable);
|
||||
|
||||
|
||||
for (nsCOMPtr<nsINode> node = aNodes[idx]; node;
|
||||
node = node->GetParentNode()) {
|
||||
if ((isList && nsHTMLEditUtils::IsListItem(node)) ||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -41,12 +41,12 @@ struct DOMPoint;
|
||||
struct StyleCache : public PropItem
|
||||
{
|
||||
bool mPresent;
|
||||
|
||||
|
||||
StyleCache() : PropItem(), mPresent(false) {
|
||||
MOZ_COUNT_CTOR(StyleCache);
|
||||
}
|
||||
|
||||
StyleCache(nsIAtom *aTag, const nsAString &aAttr, const nsAString &aValue) :
|
||||
StyleCache(nsIAtom *aTag, const nsAString &aAttr, const nsAString &aValue) :
|
||||
PropItem(aTag, aAttr, aValue), mPresent(false) {
|
||||
MOZ_COUNT_CTOR(StyleCache);
|
||||
}
|
||||
@@ -88,7 +88,7 @@ public:
|
||||
nsresult MakeSureElemStartsOrEndsOnCR(nsIDOMNode *aNode);
|
||||
|
||||
// nsIEditActionListener methods
|
||||
|
||||
|
||||
NS_IMETHOD WillCreateNode(const nsAString& aTag, nsIDOMNode *aParent, int32_t aPosition) override;
|
||||
NS_IMETHOD DidCreateNode(const nsAString& aTag, nsIDOMNode *aNode, nsIDOMNode *aParent, int32_t aPosition, nsresult aResult) override;
|
||||
NS_IMETHOD WillInsertNode(nsIDOMNode *aNode, nsIDOMNode *aParent, int32_t aPosition) override;
|
||||
@@ -144,8 +144,8 @@ protected:
|
||||
nsIEditor::EDirection aAction,
|
||||
nsIEditor::EStripWrappers aStripWrappers,
|
||||
bool* aCancel, bool* aHandled);
|
||||
nsresult DidDeleteSelection(mozilla::dom::Selection* aSelection,
|
||||
nsIEditor::EDirection aDir,
|
||||
nsresult DidDeleteSelection(mozilla::dom::Selection* aSelection,
|
||||
nsIEditor::EDirection aDir,
|
||||
nsresult aResult);
|
||||
nsresult InsertBRIfNeeded(mozilla::dom::Selection* aSelection);
|
||||
::DOMPoint GetGoodSelPointForNode(nsINode& aNode,
|
||||
@@ -210,9 +210,9 @@ protected:
|
||||
nsIDOMNode* aHeader, nsIDOMNode* aTextNode,
|
||||
int32_t aOffset, bool* aCancel, bool* aHandled);
|
||||
nsresult SplitParagraph(nsIDOMNode *aPara,
|
||||
nsIDOMNode *aBRNode,
|
||||
nsIDOMNode *aBRNode,
|
||||
mozilla::dom::Selection* aSelection,
|
||||
nsCOMPtr<nsIDOMNode> *aSelNode,
|
||||
nsCOMPtr<nsIDOMNode> *aSelNode,
|
||||
int32_t *aOffset);
|
||||
nsresult ReturnInListItem(mozilla::dom::Selection* aSelection,
|
||||
nsIDOMNode* aHeader, nsIDOMNode* aTextNode,
|
||||
@@ -222,14 +222,14 @@ protected:
|
||||
nsresult RemovePartOfBlock(mozilla::dom::Element& aBlock,
|
||||
nsIContent& aStartChild,
|
||||
nsIContent& aEndChild);
|
||||
nsresult SplitBlock(nsIDOMNode *aBlock,
|
||||
nsIDOMNode *aStartChild,
|
||||
nsresult SplitBlock(nsIDOMNode *aBlock,
|
||||
nsIDOMNode *aStartChild,
|
||||
nsIDOMNode *aEndChild,
|
||||
nsCOMPtr<nsIDOMNode> *aLeftNode = 0,
|
||||
nsCOMPtr<nsIDOMNode> *aRightNode = 0,
|
||||
nsCOMPtr<nsIDOMNode> *aMiddleNode = 0);
|
||||
nsresult OutdentPartOfBlock(nsIDOMNode *aBlock,
|
||||
nsIDOMNode *aStartChild,
|
||||
nsresult OutdentPartOfBlock(nsIDOMNode *aBlock,
|
||||
nsIDOMNode *aStartChild,
|
||||
nsIDOMNode *aEndChild,
|
||||
bool aIsBlockIndentedWithCSS,
|
||||
nsCOMPtr<nsIDOMNode> *aLeftNode = 0,
|
||||
@@ -246,8 +246,8 @@ protected:
|
||||
|
||||
nsresult CreateStyleForInsertText(mozilla::dom::Selection* aSelection,
|
||||
nsIDOMDocument* aDoc);
|
||||
nsresult IsEmptyBlock(nsIDOMNode *aNode,
|
||||
bool *outIsEmptyBlock,
|
||||
nsresult IsEmptyBlock(nsIDOMNode *aNode,
|
||||
bool *outIsEmptyBlock,
|
||||
bool aMozBRDoesntCount = false,
|
||||
bool aListItemsNotEmpty = false);
|
||||
nsresult CheckForEmptyBlock(nsINode* aStartNode,
|
||||
@@ -255,7 +255,7 @@ protected:
|
||||
mozilla::dom::Selection* aSelection,
|
||||
nsIEditor::EDirection aAction,
|
||||
bool* aHandled);
|
||||
nsresult CheckForInvisibleBR(nsIDOMNode *aBlock, nsHTMLEditRules::BRLocation aWhere,
|
||||
nsresult CheckForInvisibleBR(nsIDOMNode *aBlock, nsHTMLEditRules::BRLocation aWhere,
|
||||
nsCOMPtr<nsIDOMNode> *outBRNode, int32_t aOffset=0);
|
||||
nsresult ExpandSelectionForDeletion(mozilla::dom::Selection* aSelection);
|
||||
bool IsFirstNode(nsIDOMNode *aNode);
|
||||
@@ -264,7 +264,7 @@ protected:
|
||||
void GetPromotedPoint(RulesEndpoint aWhere, nsIDOMNode* aNode,
|
||||
int32_t aOffset, EditAction actionID,
|
||||
nsCOMPtr<nsIDOMNode>* outNode, int32_t* outOffset);
|
||||
void GetPromotedRanges(mozilla::dom::Selection& aSelection,
|
||||
void GetPromotedRanges(mozilla::dom::Selection& aSelection,
|
||||
nsTArray<nsRefPtr<nsRange>>& outArrayOfRanges,
|
||||
EditAction inOperationType);
|
||||
void PromoteRange(nsRange& aRange, EditAction inOperationType);
|
||||
@@ -318,8 +318,8 @@ protected:
|
||||
nsresult CheckInterlinePosition(mozilla::dom::Selection* aSelection);
|
||||
nsresult AdjustSelection(mozilla::dom::Selection* aSelection,
|
||||
nsIEditor::EDirection aAction);
|
||||
nsresult FindNearSelectableNode(nsIDOMNode *aSelNode,
|
||||
int32_t aSelOffset,
|
||||
nsresult FindNearSelectableNode(nsIDOMNode *aSelNode,
|
||||
int32_t aSelOffset,
|
||||
nsIEditor::EDirection &aDirection,
|
||||
nsCOMPtr<nsIDOMNode> *outSelectableNode);
|
||||
/**
|
||||
|
||||
@@ -37,8 +37,8 @@ nsHTMLEditUtils::IsBig(nsIDOMNode* aNode)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// IsInlineStyle true if node is an inline style
|
||||
//
|
||||
bool
|
||||
//
|
||||
bool
|
||||
nsHTMLEditUtils::IsInlineStyle(nsIDOMNode* aNode)
|
||||
{
|
||||
NS_PRECONDITION(aNode, "null parent passed to nsHTMLEditUtils::IsInlineStyle");
|
||||
@@ -65,7 +65,7 @@ nsHTMLEditUtils::IsInlineStyle(nsINode* aNode)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// IsFormatNode true if node is a format node
|
||||
//
|
||||
//
|
||||
bool
|
||||
nsHTMLEditUtils::IsFormatNode(nsIDOMNode* aNode)
|
||||
{
|
||||
@@ -90,7 +90,7 @@ nsHTMLEditUtils::IsFormatNode(nsINode* aNode)
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// IsNodeThatCanOutdent true if node is a list, list item, or blockquote
|
||||
// IsNodeThatCanOutdent true if node is a list, list item, or blockquote
|
||||
//
|
||||
bool
|
||||
nsHTMLEditUtils::IsNodeThatCanOutdent(nsIDOMNode* aNode)
|
||||
@@ -118,11 +118,11 @@ nsHTMLEditUtils::IsSmall(nsIDOMNode* aNode)
|
||||
/********************************************************
|
||||
* helper methods from nsHTMLEditRules
|
||||
********************************************************/
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// IsHeader: true if node an html header
|
||||
//
|
||||
bool
|
||||
//
|
||||
bool
|
||||
nsHTMLEditUtils::IsHeader(nsINode& aNode)
|
||||
{
|
||||
return aNode.IsAnyOfHTMLElements(nsGkAtoms::h1,
|
||||
@@ -144,8 +144,8 @@ nsHTMLEditUtils::IsHeader(nsIDOMNode* aNode)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// IsParagraph: true if node an html paragraph
|
||||
//
|
||||
bool
|
||||
//
|
||||
bool
|
||||
nsHTMLEditUtils::IsParagraph(nsIDOMNode* aNode)
|
||||
{
|
||||
return nsEditor::NodeIsType(aNode, nsGkAtoms::p);
|
||||
@@ -154,8 +154,8 @@ nsHTMLEditUtils::IsParagraph(nsIDOMNode* aNode)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// IsHR: true if node an horizontal rule
|
||||
//
|
||||
bool
|
||||
//
|
||||
bool
|
||||
nsHTMLEditUtils::IsHR(nsIDOMNode* aNode)
|
||||
{
|
||||
return nsEditor::NodeIsType(aNode, nsGkAtoms::hr);
|
||||
@@ -164,8 +164,8 @@ nsHTMLEditUtils::IsHR(nsIDOMNode* aNode)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// IsListItem: true if node an html list item
|
||||
//
|
||||
bool
|
||||
//
|
||||
bool
|
||||
nsHTMLEditUtils::IsListItem(nsIDOMNode* aNode)
|
||||
{
|
||||
NS_PRECONDITION(aNode, "null parent passed to nsHTMLEditUtils::IsListItem");
|
||||
@@ -185,7 +185,7 @@ nsHTMLEditUtils::IsListItem(nsINode* aNode)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// IsTableElement: true if node an html table, td, tr, ...
|
||||
//
|
||||
//
|
||||
bool
|
||||
nsHTMLEditUtils::IsTableElement(nsIDOMNode* aNode)
|
||||
{
|
||||
@@ -210,8 +210,8 @@ nsHTMLEditUtils::IsTableElement(nsINode* aNode)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// IsTableElementButNotTable: true if node an html td, tr, ... (doesn't include table)
|
||||
//
|
||||
bool
|
||||
//
|
||||
bool
|
||||
nsHTMLEditUtils::IsTableElementButNotTable(nsIDOMNode* aNode)
|
||||
{
|
||||
NS_PRECONDITION(aNode, "null node passed to nsHTMLEditor::IsTableElementButNotTable");
|
||||
@@ -234,7 +234,7 @@ nsHTMLEditUtils::IsTableElementButNotTable(nsINode* aNode)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// IsTable: true if node an html table
|
||||
//
|
||||
//
|
||||
bool
|
||||
nsHTMLEditUtils::IsTable(nsIDOMNode* aNode)
|
||||
{
|
||||
@@ -249,8 +249,8 @@ nsHTMLEditUtils::IsTable(nsINode* aNode)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// IsTableRow: true if node an html tr
|
||||
//
|
||||
bool
|
||||
//
|
||||
bool
|
||||
nsHTMLEditUtils::IsTableRow(nsIDOMNode* aNode)
|
||||
{
|
||||
return nsEditor::NodeIsType(aNode, nsGkAtoms::tr);
|
||||
@@ -259,8 +259,8 @@ nsHTMLEditUtils::IsTableRow(nsIDOMNode* aNode)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// IsTableCell: true if node an html td or th
|
||||
//
|
||||
bool
|
||||
//
|
||||
bool
|
||||
nsHTMLEditUtils::IsTableCell(nsIDOMNode* aNode)
|
||||
{
|
||||
NS_PRECONDITION(aNode, "null parent passed to nsHTMLEditUtils::IsTableCell");
|
||||
@@ -278,8 +278,8 @@ nsHTMLEditUtils::IsTableCell(nsINode* aNode)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// IsTableCell: true if node an html td or th
|
||||
//
|
||||
bool
|
||||
//
|
||||
bool
|
||||
nsHTMLEditUtils::IsTableCellOrCaption(nsIDOMNode* aNode)
|
||||
{
|
||||
NS_PRECONDITION(aNode, "null parent passed to nsHTMLEditUtils::IsTableCell");
|
||||
@@ -292,7 +292,7 @@ nsHTMLEditUtils::IsTableCellOrCaption(nsIDOMNode* aNode)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// IsList: true if node an html list
|
||||
//
|
||||
//
|
||||
bool
|
||||
nsHTMLEditUtils::IsList(nsIDOMNode* aNode)
|
||||
{
|
||||
@@ -313,8 +313,8 @@ nsHTMLEditUtils::IsList(nsINode* aNode)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// IsOrderedList: true if node an html ordered list
|
||||
//
|
||||
bool
|
||||
//
|
||||
bool
|
||||
nsHTMLEditUtils::IsOrderedList(nsIDOMNode* aNode)
|
||||
{
|
||||
return nsEditor::NodeIsType(aNode, nsGkAtoms::ol);
|
||||
@@ -323,8 +323,8 @@ nsHTMLEditUtils::IsOrderedList(nsIDOMNode* aNode)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// IsUnorderedList: true if node an html unordered list
|
||||
//
|
||||
bool
|
||||
//
|
||||
bool
|
||||
nsHTMLEditUtils::IsUnorderedList(nsIDOMNode* aNode)
|
||||
{
|
||||
return nsEditor::NodeIsType(aNode, nsGkAtoms::ul);
|
||||
@@ -333,8 +333,8 @@ nsHTMLEditUtils::IsUnorderedList(nsIDOMNode* aNode)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// IsBlockquote: true if node an html blockquote node
|
||||
//
|
||||
bool
|
||||
//
|
||||
bool
|
||||
nsHTMLEditUtils::IsBlockquote(nsIDOMNode* aNode)
|
||||
{
|
||||
return nsEditor::NodeIsType(aNode, nsGkAtoms::blockquote);
|
||||
@@ -343,8 +343,8 @@ nsHTMLEditUtils::IsBlockquote(nsIDOMNode* aNode)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// IsPre: true if node an html pre node
|
||||
//
|
||||
bool
|
||||
//
|
||||
bool
|
||||
nsHTMLEditUtils::IsPre(nsIDOMNode* aNode)
|
||||
{
|
||||
return nsEditor::NodeIsType(aNode, nsGkAtoms::pre);
|
||||
@@ -353,20 +353,20 @@ nsHTMLEditUtils::IsPre(nsIDOMNode* aNode)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// IsImage: true if node an html image node
|
||||
//
|
||||
//
|
||||
bool
|
||||
nsHTMLEditUtils::IsImage(nsINode* aNode)
|
||||
{
|
||||
return aNode && aNode->IsHTMLElement(nsGkAtoms::img);
|
||||
}
|
||||
|
||||
bool
|
||||
bool
|
||||
nsHTMLEditUtils::IsImage(nsIDOMNode* aNode)
|
||||
{
|
||||
return nsEditor::NodeIsType(aNode, nsGkAtoms::img);
|
||||
}
|
||||
|
||||
bool
|
||||
bool
|
||||
nsHTMLEditUtils::IsLink(nsIDOMNode *aNode)
|
||||
{
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
|
||||
@@ -389,7 +389,7 @@ nsHTMLEditUtils::IsLink(nsINode* aNode)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
bool
|
||||
nsHTMLEditUtils::IsNamedAnchor(nsIDOMNode *aNode)
|
||||
{
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
|
||||
@@ -412,8 +412,8 @@ nsHTMLEditUtils::IsNamedAnchor(nsINode* aNode)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// IsDiv: true if node an html div node
|
||||
//
|
||||
bool
|
||||
//
|
||||
bool
|
||||
nsHTMLEditUtils::IsDiv(nsIDOMNode* aNode)
|
||||
{
|
||||
return nsEditor::NodeIsType(aNode, nsGkAtoms::div);
|
||||
@@ -422,8 +422,8 @@ nsHTMLEditUtils::IsDiv(nsIDOMNode* aNode)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// IsMozDiv: true if node an html div node with type = _moz
|
||||
//
|
||||
bool
|
||||
//
|
||||
bool
|
||||
nsHTMLEditUtils::IsMozDiv(nsIDOMNode* aNode)
|
||||
{
|
||||
if (IsDiv(aNode) && nsTextEditUtils::HasMozAttr(aNode)) return true;
|
||||
@@ -441,7 +441,7 @@ nsHTMLEditUtils::IsMozDiv(nsINode* aNode)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// IsMailCite: true if node an html blockquote with type=cite
|
||||
//
|
||||
//
|
||||
bool
|
||||
nsHTMLEditUtils::IsMailCite(nsIDOMNode* aNode)
|
||||
{
|
||||
@@ -477,7 +477,7 @@ nsHTMLEditUtils::IsMailCite(nsINode* aNode)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// IsFormWidget: true if node is a form widget of some kind
|
||||
//
|
||||
//
|
||||
bool
|
||||
nsHTMLEditUtils::IsFormWidget(nsIDOMNode* aNode)
|
||||
{
|
||||
@@ -868,7 +868,7 @@ nsHTMLEditUtils::CanContain(int32_t aParent, int32_t aChild)
|
||||
|
||||
const nsElementInfo& child = kElements[aChild - 1];
|
||||
return (parent.mCanContainGroups & child.mGroup) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
nsHTMLEditUtils::IsContainer(int32_t aTag)
|
||||
|
||||
+142
-142
@@ -28,7 +28,7 @@
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMAttr.h"
|
||||
#include "nsIDocumentInlines.h"
|
||||
#include "nsIDOMEventTarget.h"
|
||||
#include "nsIDOMEventTarget.h"
|
||||
#include "nsIDOMKeyEvent.h"
|
||||
#include "nsIDOMMouseEvent.h"
|
||||
#include "nsIDOMHTMLAnchorElement.h"
|
||||
@@ -109,7 +109,7 @@ nsHTMLEditor::nsHTMLEditor()
|
||||
, mInfoYIncrement(20)
|
||||
, mGridSize(0)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
nsHTMLEditor::~nsHTMLEditor()
|
||||
{
|
||||
@@ -119,7 +119,7 @@ nsHTMLEditor::~nsHTMLEditor()
|
||||
nsCOMPtr<nsIEditActionListener> mListener = do_QueryInterface(mRules);
|
||||
RemoveEditActionListener(mListener);
|
||||
|
||||
//the autopointers will clear themselves up.
|
||||
//the autopointers will clear themselves up.
|
||||
//but we need to also remove the listeners or we have a leak
|
||||
nsRefPtr<Selection> selection = GetSelection();
|
||||
// if we don't get the selection, just skip this
|
||||
@@ -128,12 +128,12 @@ nsHTMLEditor::~nsHTMLEditor()
|
||||
listener = do_QueryInterface(mTypeInState);
|
||||
if (listener)
|
||||
{
|
||||
selection->RemoveSelectionListener(listener);
|
||||
selection->RemoveSelectionListener(listener);
|
||||
}
|
||||
listener = do_QueryInterface(mSelectionListenerP);
|
||||
if (listener)
|
||||
{
|
||||
selection->RemoveSelectionListener(listener);
|
||||
selection->RemoveSelectionListener(listener);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,7 +239,7 @@ nsHTMLEditor::Init(nsIDOMDocument *aDoc,
|
||||
MOZ_ASSERT(aInitialValue.IsEmpty(), "Non-empty initial values not supported");
|
||||
|
||||
nsresult result = NS_OK, rulesRes = NS_OK;
|
||||
|
||||
|
||||
if (1)
|
||||
{
|
||||
// block to scope nsAutoEditInitRulesTrigger
|
||||
@@ -286,16 +286,16 @@ nsHTMLEditor::Init(nsIDOMDocument *aDoc,
|
||||
}
|
||||
|
||||
nsRefPtr<Selection> selection = GetSelection();
|
||||
if (selection)
|
||||
if (selection)
|
||||
{
|
||||
nsCOMPtr<nsISelectionListener>listener;
|
||||
listener = do_QueryInterface(mTypeInState);
|
||||
if (listener) {
|
||||
selection->AddSelectionListener(listener);
|
||||
selection->AddSelectionListener(listener);
|
||||
}
|
||||
listener = do_QueryInterface(mSelectionListenerP);
|
||||
if (listener) {
|
||||
selection->AddSelectionListener(listener);
|
||||
selection->AddSelectionListener(listener);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -342,8 +342,8 @@ nsHTMLEditor::GetRootElement(nsIDOMElement **aRootElement)
|
||||
// Use the HTML documents body element as the editor root if we didn't
|
||||
// get a root element during initialization.
|
||||
|
||||
nsCOMPtr<nsIDOMElement> rootElement;
|
||||
nsCOMPtr<nsIDOMHTMLElement> bodyElement;
|
||||
nsCOMPtr<nsIDOMElement> rootElement;
|
||||
nsCOMPtr<nsIDOMHTMLElement> bodyElement;
|
||||
nsresult rv = GetBodyElement(getter_AddRefs(bodyElement));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
@@ -479,7 +479,7 @@ nsHTMLEditor::RemoveEventListeners()
|
||||
nsPlaintextEditor::RemoveEventListeners();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsHTMLEditor::SetFlags(uint32_t aFlags)
|
||||
{
|
||||
nsresult rv = nsPlaintextEditor::SetFlags(aFlags);
|
||||
@@ -801,7 +801,7 @@ nsHTMLEditor::IsBlockNode(nsINode *aNode)
|
||||
}
|
||||
|
||||
// Non-static version for the nsIEditor interface and JavaScript
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsHTMLEditor::SetDocumentTitle(const nsAString &aTitle)
|
||||
{
|
||||
nsRefPtr<SetDocTitleTxn> txn = new SetDocTitleTxn();
|
||||
@@ -812,7 +812,7 @@ nsHTMLEditor::SetDocumentTitle(const nsAString &aTitle)
|
||||
|
||||
//Don't let Rules System change the selection
|
||||
nsAutoTxnsConserveSelection dontChangeSelection(this);
|
||||
return nsEditor::DoTransaction(txn);
|
||||
return nsEditor::DoTransaction(txn);
|
||||
}
|
||||
|
||||
/* ------------ Block methods moved from nsEditor -------------- */
|
||||
@@ -939,7 +939,7 @@ nsHTMLEditor::IsVisBreak(nsINode* aNode)
|
||||
if (nextNode && nsTextEditUtils::IsBreak(nextNode)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// If we are right before block boundary, then br not visible
|
||||
if (!nextNode) {
|
||||
// This break is trailer in block, it's not visible
|
||||
@@ -949,8 +949,8 @@ nsHTMLEditor::IsVisBreak(nsINode* aNode)
|
||||
// Break is right before a block, it's not visible
|
||||
return false;
|
||||
}
|
||||
|
||||
// Sigh. We have to use expensive whitespace calculation code to
|
||||
|
||||
// Sigh. We have to use expensive whitespace calculation code to
|
||||
// determine what is going on
|
||||
int32_t selOffset;
|
||||
nsCOMPtr<nsINode> selNode = GetNodeLocation(aNode, &selOffset);
|
||||
@@ -965,7 +965,7 @@ nsHTMLEditor::IsVisBreak(nsINode* aNode)
|
||||
if (visType & WSType::block) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1073,7 +1073,7 @@ nsHTMLEditor::TabInTable(bool inIsShift, bool* outHandled)
|
||||
return NS_OK;
|
||||
}
|
||||
} while (!iter->IsDone());
|
||||
|
||||
|
||||
if (!(*outHandled) && !inIsShift) {
|
||||
// If we haven't handled it yet, then we must have run off the end of the
|
||||
// table. Insert a new row.
|
||||
@@ -1085,9 +1085,9 @@ nsHTMLEditor::TabInTable(bool inIsShift, bool* outHandled)
|
||||
nsRefPtr<Selection> selection;
|
||||
nsCOMPtr<nsIDOMElement> tblElement, cell;
|
||||
int32_t row;
|
||||
res = GetCellContext(getter_AddRefs(selection),
|
||||
res = GetCellContext(getter_AddRefs(selection),
|
||||
getter_AddRefs(tblElement),
|
||||
getter_AddRefs(cell),
|
||||
getter_AddRefs(cell),
|
||||
nullptr, nullptr,
|
||||
&row, nullptr);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
@@ -1101,7 +1101,7 @@ nsHTMLEditor::TabInTable(bool inIsShift, bool* outHandled)
|
||||
selection->Collapse(cell, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -1186,11 +1186,11 @@ nsHTMLEditor::ReplaceHeadContentsWithHTML(const nsAString& aSourceToInsert)
|
||||
// happen if you insert returns (instead of dom newlines, \n) into an editor
|
||||
// document.
|
||||
nsAutoString inputString (aSourceToInsert); // hope this does copy-on-write
|
||||
|
||||
|
||||
// Windows linebreaks: Map CRLF to LF:
|
||||
inputString.ReplaceSubstring(MOZ_UTF16("\r\n"),
|
||||
MOZ_UTF16("\n"));
|
||||
|
||||
|
||||
// Mac linebreaks: Map any remaining CR to LF:
|
||||
inputString.ReplaceSubstring(MOZ_UTF16("\r"),
|
||||
MOZ_UTF16("\n"));
|
||||
@@ -1281,7 +1281,7 @@ nsHTMLEditor::RebuildDocumentFromSource(const nsAString& aSourceString)
|
||||
if (foundbody && beginclosehead.get() > beginbody.get()) {
|
||||
foundclosehead = false;
|
||||
}
|
||||
|
||||
|
||||
// Time to change the document
|
||||
nsAutoEditBatch beginBatching(this);
|
||||
|
||||
@@ -1353,7 +1353,7 @@ nsHTMLEditor::RebuildDocumentFromSource(const nsAString& aSourceString)
|
||||
// Now we must copy attributes user might have edited on the <body> tag
|
||||
// because InsertHTML (actually, CreateContextualFragment()) will never
|
||||
// return a body node in the DOM fragment
|
||||
|
||||
|
||||
// We already know where "<body" begins
|
||||
nsReadingIterator<char16_t> beginclosebody = beginbody;
|
||||
nsReadingIterator<char16_t> endclosebody;
|
||||
@@ -1379,10 +1379,10 @@ nsHTMLEditor::RebuildDocumentFromSource(const nsAString& aSourceString)
|
||||
|
||||
nsCOMPtr<nsIContent> child = docfrag->GetFirstChild();
|
||||
NS_ENSURE_TRUE(child && child->IsElement(), NS_ERROR_NULL_POINTER);
|
||||
|
||||
|
||||
// Copy all attributes from the div child to current body element
|
||||
CloneAttributes(bodyElement, child->AsElement());
|
||||
|
||||
|
||||
// place selection at first editable content
|
||||
return BeginningOfDocument();
|
||||
}
|
||||
@@ -1396,9 +1396,9 @@ nsHTMLEditor::NormalizeEOLInsertPosition(nsIDOMNode *firstNodeToInsert,
|
||||
This function will either correct the position passed in,
|
||||
or leave the position unchanged.
|
||||
|
||||
When the (first) item to insert is a block level element,
|
||||
and our insertion position is after the last visible item in a line,
|
||||
i.e. the insertion position is just before a visible line break <br>,
|
||||
When the (first) item to insert is a block level element,
|
||||
and our insertion position is after the last visible item in a line,
|
||||
i.e. the insertion position is just before a visible line break <br>,
|
||||
we want to skip to the position just after the line break (see bug 68767)
|
||||
|
||||
However, our logic to detect whether we should skip or not
|
||||
@@ -1406,18 +1406,18 @@ nsHTMLEditor::NormalizeEOLInsertPosition(nsIDOMNode *firstNodeToInsert,
|
||||
We must not skip when the caret appears to be positioned at the beginning
|
||||
of a block, in that case skipping the <br> would not insert the <br>
|
||||
at the caret position, but after the current empty line.
|
||||
|
||||
|
||||
So we have several cases to test:
|
||||
|
||||
|
||||
1) We only ever want to skip, if the next visible thing after the current position is a break
|
||||
|
||||
|
||||
2) We do not want to skip if there is no previous visible thing at all
|
||||
That is detected if the call to PriorVisibleNode gives us an offset of zero.
|
||||
Because PriorVisibleNode always positions after the prior node, we would
|
||||
see an offset > 0, if there were a prior node.
|
||||
|
||||
|
||||
3) We do not want to skip, if both the next and the previous visible things are breaks.
|
||||
|
||||
|
||||
4) We do not want to skip if the previous visible thing is in a different block
|
||||
than the insertion position.
|
||||
*/
|
||||
@@ -1467,11 +1467,11 @@ nsHTMLEditor::InsertElementAtSelection(nsIDOMElement* aElement, bool aDeleteSele
|
||||
nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
|
||||
|
||||
nsresult res = NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
|
||||
NS_ENSURE_TRUE(aElement, NS_ERROR_NULL_POINTER);
|
||||
|
||||
|
||||
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(aElement);
|
||||
|
||||
|
||||
ForceCompositionEnd();
|
||||
nsAutoEditBatch beginBatching(this);
|
||||
nsAutoRules beginRulesSniffing(this, EditAction::insertElement, nsIEditor::eNext);
|
||||
@@ -1531,7 +1531,7 @@ nsHTMLEditor::InsertElementAtSelection(nsIDOMElement* aElement, bool aDeleteSele
|
||||
|
||||
res = InsertNodeAtPoint(node, address_of(parentSelectedNode), &offsetForInsert, false);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
// Set caret after element, but check for special case
|
||||
// Set caret after element, but check for special case
|
||||
// of inserting table-related elements: set in first cell instead
|
||||
if (!SetCaretInTableCell(aElement))
|
||||
{
|
||||
@@ -1559,8 +1559,8 @@ nsHTMLEditor::InsertElementAtSelection(nsIDOMElement* aElement, bool aDeleteSele
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
InsertNodeAtPoint: attempts to insert aNode into the document, at a point specified by
|
||||
/*
|
||||
InsertNodeAtPoint: attempts to insert aNode into the document, at a point specified by
|
||||
{*ioParent,*ioOffset}. Checks with strict dtd to see if containment is allowed. If not
|
||||
allowed, will attempt to find a parent in the parent hierarchy of *ioParent that will
|
||||
accept aNode as a child. If such a parent is found, will split the document tree from
|
||||
@@ -1573,9 +1573,9 @@ nsHTMLEditor::InsertElementAtSelection(nsIDOMElement* aElement, bool aDeleteSele
|
||||
bool aNoEmptyNodes splitting can result in empty nodes?
|
||||
*/
|
||||
nsresult
|
||||
nsHTMLEditor::InsertNodeAtPoint(nsIDOMNode *aNode,
|
||||
nsCOMPtr<nsIDOMNode> *ioParent,
|
||||
int32_t *ioOffset,
|
||||
nsHTMLEditor::InsertNodeAtPoint(nsIDOMNode *aNode,
|
||||
nsCOMPtr<nsIDOMNode> *ioParent,
|
||||
int32_t *ioOffset,
|
||||
bool aNoEmptyNodes)
|
||||
{
|
||||
nsCOMPtr<nsIContent> node = do_QueryInterface(aNode);
|
||||
@@ -1583,14 +1583,14 @@ nsHTMLEditor::InsertNodeAtPoint(nsIDOMNode *aNode,
|
||||
NS_ENSURE_TRUE(ioParent, NS_ERROR_NULL_POINTER);
|
||||
NS_ENSURE_TRUE(*ioParent, NS_ERROR_NULL_POINTER);
|
||||
NS_ENSURE_TRUE(ioOffset, NS_ERROR_NULL_POINTER);
|
||||
|
||||
|
||||
nsresult res = NS_OK;
|
||||
nsCOMPtr<nsINode> parent = do_QueryInterface(*ioParent);
|
||||
NS_ENSURE_TRUE(parent, NS_ERROR_NULL_POINTER);
|
||||
nsCOMPtr<nsINode> topChild = parent;
|
||||
int32_t offsetOfInsert = *ioOffset;
|
||||
|
||||
// Search up the parent chain to find a suitable container
|
||||
|
||||
// Search up the parent chain to find a suitable container
|
||||
while (!CanContain(*parent, *node)) {
|
||||
// If the current parent is a root (body or table element)
|
||||
// then go no further - we can't insert
|
||||
@@ -1671,7 +1671,7 @@ nsHTMLEditor::SetCaretAfterElement(nsIDOMElement* aElement)
|
||||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsHTMLEditor::SetParagraphFormat(const nsAString& aParagraphFormat)
|
||||
{
|
||||
nsAutoString tag; tag.Assign(aParagraphFormat);
|
||||
@@ -1682,13 +1682,13 @@ nsHTMLEditor::SetParagraphFormat(const nsAString& aParagraphFormat)
|
||||
return InsertBasicBlock(tag);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsHTMLEditor::GetParagraphState(bool *aMixed, nsAString &outFormat)
|
||||
{
|
||||
if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
|
||||
NS_ENSURE_TRUE(aMixed, NS_ERROR_NULL_POINTER);
|
||||
nsRefPtr<nsHTMLEditRules> htmlRules = static_cast<nsHTMLEditRules*>(mRules.get());
|
||||
|
||||
|
||||
return htmlRules->GetParagraphState(aMixed, outFormat);
|
||||
}
|
||||
|
||||
@@ -1730,7 +1730,7 @@ nsHTMLEditor::GetCSSBackgroundColorState(bool *aMixed, nsAString &aOutColor, boo
|
||||
*aMixed = false;
|
||||
// the default background color is transparent
|
||||
aOutColor.AssignLiteral("transparent");
|
||||
|
||||
|
||||
// get selection
|
||||
nsRefPtr<Selection> selection = GetSelection();
|
||||
NS_ENSURE_STATE(selection && selection->GetRangeAt(0));
|
||||
@@ -1751,7 +1751,7 @@ nsHTMLEditor::GetCSSBackgroundColorState(bool *aMixed, nsAString &aOutColor, boo
|
||||
nodeToExamine = parent->GetChildAt(offset);
|
||||
//GetNextNode(parent, offset, true, address_of(nodeToExamine));
|
||||
}
|
||||
|
||||
|
||||
NS_ENSURE_TRUE(nodeToExamine, NS_ERROR_NULL_POINTER);
|
||||
|
||||
if (aBlockLevel) {
|
||||
@@ -1811,14 +1811,14 @@ nsHTMLEditor::GetCSSBackgroundColorState(bool *aMixed, nsAString &aOutColor, boo
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsHTMLEditor::GetHTMLBackgroundColorState(bool *aMixed, nsAString &aOutColor)
|
||||
{
|
||||
//TODO: We don't handle "mixed" correctly!
|
||||
NS_ENSURE_TRUE(aMixed, NS_ERROR_NULL_POINTER);
|
||||
*aMixed = false;
|
||||
aOutColor.Truncate();
|
||||
|
||||
|
||||
nsCOMPtr<nsIDOMElement> domElement;
|
||||
int32_t selectedCount;
|
||||
nsAutoString tagName;
|
||||
@@ -1843,7 +1843,7 @@ nsHTMLEditor::GetHTMLBackgroundColorState(bool *aMixed, nsAString &aOutColor)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// No color is set, but we need to report visible color inherited
|
||||
// No color is set, but we need to report visible color inherited
|
||||
// from nested cells/tables, so search up parent chain
|
||||
element = element->GetParentElement();
|
||||
}
|
||||
@@ -1856,24 +1856,24 @@ nsHTMLEditor::GetHTMLBackgroundColorState(bool *aMixed, nsAString &aOutColor)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsHTMLEditor::GetListState(bool *aMixed, bool *aOL, bool *aUL, bool *aDL)
|
||||
{
|
||||
if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
|
||||
NS_ENSURE_TRUE(aMixed && aOL && aUL && aDL, NS_ERROR_NULL_POINTER);
|
||||
nsRefPtr<nsHTMLEditRules> htmlRules = static_cast<nsHTMLEditRules*>(mRules.get());
|
||||
|
||||
|
||||
return htmlRules->GetListState(aMixed, aOL, aUL, aDL);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsHTMLEditor::GetListItemState(bool *aMixed, bool *aLI, bool *aDT, bool *aDD)
|
||||
{
|
||||
if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
|
||||
NS_ENSURE_TRUE(aMixed && aLI && aDT && aDD, NS_ERROR_NULL_POINTER);
|
||||
|
||||
nsRefPtr<nsHTMLEditRules> htmlRules = static_cast<nsHTMLEditRules*>(mRules.get());
|
||||
|
||||
|
||||
return htmlRules->GetListItemState(aMixed, aLI, aDT, aDD);
|
||||
}
|
||||
|
||||
@@ -1883,19 +1883,19 @@ nsHTMLEditor::GetAlignment(bool *aMixed, nsIHTMLEditor::EAlignment *aAlign)
|
||||
if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
|
||||
NS_ENSURE_TRUE(aMixed && aAlign, NS_ERROR_NULL_POINTER);
|
||||
nsRefPtr<nsHTMLEditRules> htmlRules = static_cast<nsHTMLEditRules*>(mRules.get());
|
||||
|
||||
|
||||
return htmlRules->GetAlignment(aMixed, aAlign);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsHTMLEditor::GetIndentState(bool *aCanIndent, bool *aCanOutdent)
|
||||
{
|
||||
if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
|
||||
NS_ENSURE_TRUE(aCanIndent && aCanOutdent, NS_ERROR_NULL_POINTER);
|
||||
|
||||
nsRefPtr<nsHTMLEditRules> htmlRules = static_cast<nsHTMLEditRules*>(mRules.get());
|
||||
|
||||
|
||||
return htmlRules->GetIndentState(aCanIndent, aCanOutdent);
|
||||
}
|
||||
|
||||
@@ -1912,7 +1912,7 @@ nsHTMLEditor::MakeOrChangeList(const nsAString& aListType, bool entireList, cons
|
||||
|
||||
nsAutoEditBatch beginBatching(this);
|
||||
nsAutoRules beginRulesSniffing(this, EditAction::makeList, nsIEditor::eNext);
|
||||
|
||||
|
||||
// pre-process
|
||||
nsRefPtr<Selection> selection = GetSelection();
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
|
||||
@@ -1934,19 +1934,19 @@ nsHTMLEditor::MakeOrChangeList(const nsAString& aListType, bool entireList, cons
|
||||
res = GetStartNodeAndOffset(selection, getter_AddRefs(node), &offset);
|
||||
if (!node) res = NS_ERROR_FAILURE;
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
|
||||
if (isCollapsed)
|
||||
{
|
||||
// have to find a place to put the list
|
||||
nsCOMPtr<nsINode> parent = node;
|
||||
nsCOMPtr<nsINode> topChild = node;
|
||||
|
||||
|
||||
nsCOMPtr<nsIAtom> listAtom = do_GetAtom(aListType);
|
||||
while (!CanContainTag(*parent, *listAtom)) {
|
||||
topChild = parent;
|
||||
parent = parent->GetParentNode();
|
||||
}
|
||||
|
||||
|
||||
if (parent != node)
|
||||
{
|
||||
// we need to split up to the child of parent
|
||||
@@ -1965,7 +1965,7 @@ nsHTMLEditor::MakeOrChangeList(const nsAString& aListType, bool entireList, cons
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
res = mRules->DidDoAction(selection, &ruleInfo, res);
|
||||
return res;
|
||||
}
|
||||
@@ -1984,7 +1984,7 @@ nsHTMLEditor::RemoveList(const nsAString& aListType)
|
||||
|
||||
nsAutoEditBatch beginBatching(this);
|
||||
nsAutoRules beginRulesSniffing(this, EditAction::removeList, nsIEditor::eNext);
|
||||
|
||||
|
||||
// pre-process
|
||||
nsRefPtr<Selection> selection = GetSelection();
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
|
||||
@@ -2015,7 +2015,7 @@ nsHTMLEditor::MakeDefinitionItem(const nsAString& aItemType)
|
||||
|
||||
nsAutoEditBatch beginBatching(this);
|
||||
nsAutoRules beginRulesSniffing(this, EditAction::makeDefListItem, nsIEditor::eNext);
|
||||
|
||||
|
||||
// pre-process
|
||||
nsRefPtr<Selection> selection = GetSelection();
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
|
||||
@@ -2046,7 +2046,7 @@ nsHTMLEditor::InsertBasicBlock(const nsAString& aBlockType)
|
||||
|
||||
nsAutoEditBatch beginBatching(this);
|
||||
nsAutoRules beginRulesSniffing(this, EditAction::makeBasicBlock, nsIEditor::eNext);
|
||||
|
||||
|
||||
// pre-process
|
||||
nsRefPtr<Selection> selection = GetSelection();
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
|
||||
@@ -2065,20 +2065,20 @@ nsHTMLEditor::InsertBasicBlock(const nsAString& aBlockType)
|
||||
res = GetStartNodeAndOffset(selection, getter_AddRefs(node), &offset);
|
||||
if (!node) res = NS_ERROR_FAILURE;
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
|
||||
if (isCollapsed)
|
||||
{
|
||||
// have to find a place to put the block
|
||||
nsCOMPtr<nsINode> parent = node;
|
||||
nsCOMPtr<nsINode> topChild = node;
|
||||
|
||||
|
||||
nsCOMPtr<nsIAtom> blockAtom = do_GetAtom(aBlockType);
|
||||
while (!CanContainTag(*parent, *blockAtom)) {
|
||||
NS_ENSURE_TRUE(parent->GetParentNode(), NS_ERROR_FAILURE);
|
||||
topChild = parent;
|
||||
parent = parent->GetParentNode();
|
||||
}
|
||||
|
||||
|
||||
if (parent != node)
|
||||
{
|
||||
// we need to split up to the child of parent
|
||||
@@ -2090,10 +2090,10 @@ nsHTMLEditor::InsertBasicBlock(const nsAString& aBlockType)
|
||||
// make a block
|
||||
nsCOMPtr<Element> newBlock = CreateNode(blockAtom, parent, offset);
|
||||
NS_ENSURE_STATE(newBlock);
|
||||
|
||||
|
||||
// reposition selection to inside the block
|
||||
res = selection->Collapse(newBlock,0);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2118,7 +2118,7 @@ nsHTMLEditor::Indent(const nsAString& aIndent)
|
||||
}
|
||||
nsAutoEditBatch beginBatching(this);
|
||||
nsAutoRules beginRulesSniffing(this, opID, nsIEditor::eNext);
|
||||
|
||||
|
||||
// pre-process
|
||||
nsRefPtr<Selection> selection = GetSelection();
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
|
||||
@@ -2126,7 +2126,7 @@ nsHTMLEditor::Indent(const nsAString& aIndent)
|
||||
nsTextRulesInfo ruleInfo(opID);
|
||||
res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
||||
if (cancel || (NS_FAILED(res))) return res;
|
||||
|
||||
|
||||
if (!handled)
|
||||
{
|
||||
// Do default - insert a blockquote node if selection collapsed
|
||||
@@ -2137,7 +2137,7 @@ nsHTMLEditor::Indent(const nsAString& aIndent)
|
||||
res = GetStartNodeAndOffset(selection, getter_AddRefs(node), &offset);
|
||||
if (!node) res = NS_ERROR_FAILURE;
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
|
||||
if (aIndent.EqualsLiteral("indent"))
|
||||
{
|
||||
if (isCollapsed)
|
||||
@@ -2150,7 +2150,7 @@ nsHTMLEditor::Indent(const nsAString& aIndent)
|
||||
topChild = parent;
|
||||
parent = parent->GetParentNode();
|
||||
}
|
||||
|
||||
|
||||
if (parent != node)
|
||||
{
|
||||
// we need to split up to the child of parent
|
||||
@@ -2192,7 +2192,7 @@ nsHTMLEditor::Align(const nsAString& aAlignType)
|
||||
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
bool cancel, handled;
|
||||
|
||||
|
||||
// Find out if the selection is collapsed:
|
||||
nsRefPtr<Selection> selection = GetSelection();
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
|
||||
@@ -2201,7 +2201,7 @@ nsHTMLEditor::Align(const nsAString& aAlignType)
|
||||
nsresult res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
||||
if (cancel || NS_FAILED(res))
|
||||
return res;
|
||||
|
||||
|
||||
res = mRules->DidDoAction(selection, &ruleInfo, res);
|
||||
return res;
|
||||
}
|
||||
@@ -2311,10 +2311,10 @@ NS_IMETHODIMP
|
||||
nsHTMLEditor::GetSelectedElement(const nsAString& aTagName, nsIDOMElement** aReturn)
|
||||
{
|
||||
NS_ENSURE_TRUE(aReturn , NS_ERROR_NULL_POINTER);
|
||||
|
||||
|
||||
// default is null - no element found
|
||||
*aReturn = nullptr;
|
||||
|
||||
|
||||
// First look for a single element in selection
|
||||
nsRefPtr<Selection> selection = GetSelection();
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
|
||||
@@ -2329,7 +2329,7 @@ nsHTMLEditor::GetSelectedElement(const nsAString& aTagName, nsIDOMElement** aRet
|
||||
bool anyTag = (TagName.IsEmpty());
|
||||
bool isLinkTag = IsLinkTag(TagName);
|
||||
bool isNamedAnchorTag = IsNamedAnchorTag(TagName);
|
||||
|
||||
|
||||
nsCOMPtr<nsIDOMElement> selectedElement;
|
||||
nsRefPtr<nsRange> range = selection->GetRangeAt(0);
|
||||
NS_ENSURE_STATE(range);
|
||||
@@ -2401,7 +2401,7 @@ nsHTMLEditor::GetSelectedElement(const nsAString& aTagName, nsIDOMElement** aRet
|
||||
{
|
||||
// We have just a caret in the link
|
||||
bNodeFound = true;
|
||||
} else if(focusNode)
|
||||
} else if(focusNode)
|
||||
{ // Link node must be the same for both ends of selection
|
||||
nsCOMPtr<nsIDOMElement> parentLinkOfFocus;
|
||||
res = GetElementOrParentByTagName(NS_LITERAL_STRING("href"), focusNode, getter_AddRefs(parentLinkOfFocus));
|
||||
@@ -2421,7 +2421,7 @@ nsHTMLEditor::GetSelectedElement(const nsAString& aTagName, nsIDOMElement** aRet
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> anchorChild;
|
||||
anchorChild = GetChildAt(anchorNode,anchorOffset);
|
||||
if (anchorChild && nsHTMLEditUtils::IsLink(anchorChild) &&
|
||||
if (anchorChild && nsHTMLEditUtils::IsLink(anchorChild) &&
|
||||
(anchorNode == focusNode) && focusOffset == (anchorOffset+1))
|
||||
{
|
||||
selectedElement = do_QueryInterface(anchorChild);
|
||||
@@ -2429,7 +2429,7 @@ nsHTMLEditor::GetSelectedElement(const nsAString& aTagName, nsIDOMElement** aRet
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!isCollapsed) // Don't bother to examine selection if it is collapsed
|
||||
{
|
||||
@@ -2495,14 +2495,14 @@ nsHTMLEditor::GetSelectedElement(const nsAString& aTagName, nsIDOMElement** aRet
|
||||
}
|
||||
if (bNodeFound)
|
||||
{
|
||||
|
||||
|
||||
*aReturn = selectedElement;
|
||||
if (selectedElement)
|
||||
{
|
||||
{
|
||||
// Getters must addref
|
||||
NS_ADDREF(*aReturn);
|
||||
}
|
||||
}
|
||||
}
|
||||
else res = NS_EDITOR_ELEMENT_NOT_FOUND;
|
||||
|
||||
return res;
|
||||
@@ -2647,7 +2647,7 @@ nsresult
|
||||
nsHTMLEditor::SetHTMLBackgroundColor(const nsAString& aColor)
|
||||
{
|
||||
NS_PRECONDITION(mDocWeak, "Missing Editor DOM Document");
|
||||
|
||||
|
||||
// Find a selected or enclosing table element to set background on
|
||||
nsCOMPtr<nsIDOMElement> element;
|
||||
int32_t selectedCount;
|
||||
@@ -2701,7 +2701,7 @@ NS_IMETHODIMP nsHTMLEditor::SetBodyAttribute(const nsAString& aAttribute, const
|
||||
// TODO: Check selection for Cell, Row, Column or table and do color on appropriate level
|
||||
|
||||
NS_ASSERTION(mDocWeak, "Missing Editor DOM Document");
|
||||
|
||||
|
||||
// Set the background color attribute on the body tag
|
||||
nsCOMPtr<nsIDOMElement> bodyElement = do_QueryInterface(GetRoot());
|
||||
NS_ENSURE_TRUE(bodyElement, NS_ERROR_NULL_POINTER);
|
||||
@@ -2816,7 +2816,7 @@ nsHTMLEditor::RemoveStyleSheet(const nsAString &aURL)
|
||||
// Remove it from our internal list
|
||||
rv = RemoveStyleSheetFromList(aURL);
|
||||
}
|
||||
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
@@ -3382,7 +3382,7 @@ nsHTMLEditor::DebugUnitTests(int32_t *outNumTests, int32_t *outNumTestsFailed)
|
||||
|
||||
TextEditorTest *tester = new TextEditorTest();
|
||||
NS_ENSURE_TRUE(tester, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
|
||||
tester->Run(this, outNumTests, outNumTestsFailed);
|
||||
delete tester;
|
||||
return NS_OK;
|
||||
@@ -3392,7 +3392,7 @@ nsHTMLEditor::DebugUnitTests(int32_t *outNumTests, int32_t *outNumTestsFailed)
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsHTMLEditor::StyleSheetLoaded(CSSStyleSheet* aSheet, bool aWasAlternate,
|
||||
nsresult aStatus)
|
||||
{
|
||||
@@ -3457,9 +3457,9 @@ nsHTMLEditor::EndOperation()
|
||||
if (mRules) res = mRules->AfterEdit(mAction, mDirection);
|
||||
nsEditor::EndOperation(); // will clear mAction, mDirection
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
bool
|
||||
nsHTMLEditor::TagCanContainTag(nsIAtom& aParentTag, nsIAtom& aChildTag)
|
||||
{
|
||||
nsIParserService* parserService = nsContentUtils::GetParserService();
|
||||
@@ -3507,18 +3507,18 @@ nsresult
|
||||
nsHTMLEditor::SelectEntireDocument(Selection* aSelection)
|
||||
{
|
||||
if (!aSelection || !mRules) { return NS_ERROR_NULL_POINTER; }
|
||||
|
||||
|
||||
// Protect the edit rules object from dying
|
||||
nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
|
||||
|
||||
// get editor root node
|
||||
nsCOMPtr<nsIDOMElement> rootElement = do_QueryInterface(GetRoot());
|
||||
|
||||
|
||||
// is doc empty?
|
||||
bool bDocIsEmpty;
|
||||
nsresult res = mRules->DocumentIsEmpty(&bDocIsEmpty);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
|
||||
if (bDocIsEmpty)
|
||||
{
|
||||
// if its empty dont select entire doc - that would select the bogus node
|
||||
@@ -3582,9 +3582,9 @@ bool nsHTMLEditor::IsTextPropertySetByContent(nsINode* aNode,
|
||||
}
|
||||
|
||||
void nsHTMLEditor::IsTextPropertySetByContent(nsIDOMNode *aNode,
|
||||
nsIAtom *aProperty,
|
||||
const nsAString *aAttribute,
|
||||
const nsAString *aValue,
|
||||
nsIAtom *aProperty,
|
||||
const nsAString *aAttribute,
|
||||
const nsAString *aValue,
|
||||
bool &aIsSet,
|
||||
nsAString *outValue)
|
||||
{
|
||||
@@ -3626,7 +3626,7 @@ void nsHTMLEditor::IsTextPropertySetByContent(nsIDOMNode *aNode,
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
else {
|
||||
found = true;
|
||||
}
|
||||
if (found)
|
||||
@@ -3675,7 +3675,7 @@ nsHTMLEditor::SetCaretInTableCell(nsIDOMElement* aElement)
|
||||
NS_ENSURE_TRUE(selection, false);
|
||||
|
||||
return NS_SUCCEEDED(selection->CollapseNative(node, 0));
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// GetEnclosingTable: find ancestor who is a table, if any
|
||||
@@ -3710,7 +3710,7 @@ nsHTMLEditor::GetEnclosingTable(nsIDOMNode *aNode)
|
||||
/* this method scans the selection for adjacent text nodes
|
||||
* and collapses them into a single text node.
|
||||
* "adjacent" means literally adjacent siblings of the same parent.
|
||||
* Uses nsEditor::JoinNodes so action is undoable.
|
||||
* Uses nsEditor::JoinNodes so action is undoable.
|
||||
* Should be called within the context of a batch transaction.
|
||||
*/
|
||||
nsresult
|
||||
@@ -3720,7 +3720,7 @@ nsHTMLEditor::CollapseAdjacentTextNodes(nsRange* aInRange)
|
||||
nsAutoTxnsConserveSelection dontSpazMySelection(this);
|
||||
nsTArray<nsCOMPtr<nsIDOMNode> > textNodes;
|
||||
// we can't actually do anything during iteration, so store the text nodes in an array
|
||||
// don't bother ref counting them because we know we can hold them for the
|
||||
// don't bother ref counting them because we know we can hold them for the
|
||||
// lifetime of this method
|
||||
|
||||
|
||||
@@ -3796,7 +3796,7 @@ nsHTMLEditor::RemoveBlockContainer(nsIDOMNode *inNode)
|
||||
NS_ENSURE_TRUE(node, NS_ERROR_NULL_POINTER);
|
||||
nsresult res;
|
||||
nsCOMPtr<nsIDOMNode> sibling, child, unused;
|
||||
|
||||
|
||||
// Two possibilities: the container cold be empty of editable content.
|
||||
// If that is the case, we need to compare what is before and after inNode
|
||||
// to determine if we need a br.
|
||||
@@ -3804,9 +3804,9 @@ nsHTMLEditor::RemoveBlockContainer(nsIDOMNode *inNode)
|
||||
// sibling and first child to determine if we need a leading br,
|
||||
// and compare following sibling and last child to determine if we need a
|
||||
// trailing br.
|
||||
|
||||
|
||||
child = GetAsDOMNode(GetFirstEditableChild(*node));
|
||||
|
||||
|
||||
if (child) // the case of inNode not being empty
|
||||
{
|
||||
// we need a br at start unless:
|
||||
@@ -3814,7 +3814,7 @@ nsHTMLEditor::RemoveBlockContainer(nsIDOMNode *inNode)
|
||||
// 2) previous sibling of inNode is a br, OR
|
||||
// 3) first child of inNode is a block OR
|
||||
// 4) either is null
|
||||
|
||||
|
||||
res = GetPriorHTMLSibling(inNode, address_of(sibling));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
if (sibling && !IsBlockNode(sibling) && !nsTextEditUtils::IsBreak(sibling))
|
||||
@@ -3825,7 +3825,7 @@ nsHTMLEditor::RemoveBlockContainer(nsIDOMNode *inNode)
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// we need a br at end unless:
|
||||
// 1) following sibling of inNode is a block, OR
|
||||
// 2) last child of inNode is a block, OR
|
||||
@@ -3870,7 +3870,7 @@ nsHTMLEditor::RemoveBlockContainer(nsIDOMNode *inNode)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// now remove container
|
||||
return RemoveContainer(node);
|
||||
}
|
||||
@@ -3879,7 +3879,7 @@ nsHTMLEditor::RemoveBlockContainer(nsIDOMNode *inNode)
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// GetPriorHTMLSibling: returns the previous editable sibling, if there is
|
||||
// one within the parent
|
||||
//
|
||||
//
|
||||
nsIContent*
|
||||
nsHTMLEditor::GetPriorHTMLSibling(nsINode* aNode)
|
||||
{
|
||||
@@ -3912,7 +3912,7 @@ nsHTMLEditor::GetPriorHTMLSibling(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outN
|
||||
// GetPriorHTMLSibling: returns the previous editable sibling, if there is
|
||||
// one within the parent. just like above routine but
|
||||
// takes a parent/offset instead of a node.
|
||||
//
|
||||
//
|
||||
nsIContent*
|
||||
nsHTMLEditor::GetPriorHTMLSibling(nsINode* aParent, int32_t aOffset)
|
||||
{
|
||||
@@ -3944,7 +3944,7 @@ nsHTMLEditor::GetPriorHTMLSibling(nsIDOMNode *inParent, int32_t inOffset, nsCOMP
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// GetNextHTMLSibling: returns the next editable sibling, if there is
|
||||
// one within the parent
|
||||
//
|
||||
//
|
||||
nsIContent*
|
||||
nsHTMLEditor::GetNextHTMLSibling(nsINode* aNode)
|
||||
{
|
||||
@@ -3966,7 +3966,7 @@ nsHTMLEditor::GetNextHTMLSibling(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNo
|
||||
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(inNode);
|
||||
NS_ENSURE_TRUE(node, NS_ERROR_NULL_POINTER);
|
||||
|
||||
|
||||
*outNode = do_QueryInterface(GetNextHTMLSibling(node));
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -4071,7 +4071,7 @@ nsHTMLEditor::GetPriorHTMLNode(nsIDOMNode* aNode, int32_t aOffset,
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// GetNextHTMLNode: returns the next editable leaf node, if there is
|
||||
// one within the <body>
|
||||
//
|
||||
//
|
||||
nsIContent*
|
||||
nsHTMLEditor::GetNextHTMLNode(nsINode* aNode, bool aNoBlockCrossing)
|
||||
{
|
||||
@@ -4103,7 +4103,7 @@ nsHTMLEditor::GetNextHTMLNode(nsIDOMNode* aNode,
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// GetNextHTMLNode: same as above but takes {parent,offset} instead of node
|
||||
//
|
||||
//
|
||||
nsIContent*
|
||||
nsHTMLEditor::GetNextHTMLNode(nsINode* aParent, int32_t aOffset,
|
||||
bool aNoBlockCrossing)
|
||||
@@ -4131,37 +4131,37 @@ nsHTMLEditor::GetNextHTMLNode(nsIDOMNode* aNode, int32_t aOffset,
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsresult
|
||||
nsHTMLEditor::IsFirstEditableChild( nsIDOMNode *aNode, bool *aOutIsFirst)
|
||||
{
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
|
||||
NS_ENSURE_TRUE(aOutIsFirst && node, NS_ERROR_NULL_POINTER);
|
||||
|
||||
|
||||
// init out parms
|
||||
*aOutIsFirst = false;
|
||||
|
||||
|
||||
// find first editable child and compare it to aNode
|
||||
nsCOMPtr<nsINode> parent = node->GetParentNode();
|
||||
NS_ENSURE_TRUE(parent, NS_ERROR_FAILURE);
|
||||
|
||||
|
||||
*aOutIsFirst = (GetFirstEditableChild(*parent) == node);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsresult
|
||||
nsHTMLEditor::IsLastEditableChild( nsIDOMNode *aNode, bool *aOutIsLast)
|
||||
{
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
|
||||
NS_ENSURE_TRUE(aOutIsLast && node, NS_ERROR_NULL_POINTER);
|
||||
|
||||
|
||||
// init out parms
|
||||
*aOutIsLast = false;
|
||||
|
||||
|
||||
// find last editable child and compare it to aNode
|
||||
nsCOMPtr<nsINode> parent = node->GetParentNode();
|
||||
NS_ENSURE_TRUE(parent, NS_ERROR_FAILURE);
|
||||
|
||||
|
||||
*aOutIsLast = (GetLastEditableChild(*parent) == node);
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -4228,7 +4228,7 @@ nsHTMLEditor::GetLastEditableLeaf(nsINode& aNode)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// IsVisTextNode: figure out if textnode aTextNode has any visible content.
|
||||
//
|
||||
//
|
||||
nsresult
|
||||
nsHTMLEditor::IsVisTextNode(nsIContent* aNode,
|
||||
bool* outIsEmptyNode,
|
||||
@@ -4256,7 +4256,7 @@ nsHTMLEditor::IsVisTextNode(nsIContent* aNode,
|
||||
// partial fix for bug 46209)
|
||||
res = selCon->CheckVisibilityContent(aNode, 0, length, &isVisible);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
if (isVisible)
|
||||
if (isVisible)
|
||||
{
|
||||
*outIsEmptyNode = false;
|
||||
}
|
||||
@@ -4280,18 +4280,18 @@ nsHTMLEditor::IsVisTextNode(nsIContent* aNode,
|
||||
*outIsEmptyNode = false;
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// IsEmptyNode: figure out if aNode is an empty node.
|
||||
// A block can have children and still be considered empty,
|
||||
// if the children are empty or non-editable.
|
||||
//
|
||||
//
|
||||
nsresult
|
||||
nsHTMLEditor::IsEmptyNode( nsIDOMNode *aNode,
|
||||
bool *outIsEmptyNode,
|
||||
nsHTMLEditor::IsEmptyNode( nsIDOMNode *aNode,
|
||||
bool *outIsEmptyNode,
|
||||
bool aSingleBRDoesntCount,
|
||||
bool aListOrCellNotEmpty,
|
||||
bool aSafeToAskFrames)
|
||||
@@ -4317,7 +4317,7 @@ nsHTMLEditor::IsEmptyNode(nsINode* aNode,
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// IsEmptyNodeImpl: workhorse for IsEmptyNode.
|
||||
//
|
||||
//
|
||||
nsresult
|
||||
nsHTMLEditor::IsEmptyNodeImpl(nsINode* aNode,
|
||||
bool *outIsEmptyNode,
|
||||
@@ -4347,12 +4347,12 @@ nsHTMLEditor::IsEmptyNodeImpl(nsINode* aNode,
|
||||
*outIsEmptyNode = false;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
// need this for later
|
||||
bool isListItemOrCell = nsHTMLEditUtils::IsListItem(aNode) ||
|
||||
nsHTMLEditUtils::IsTableCell(aNode);
|
||||
|
||||
// loop over children of node. if no children, or all children are either
|
||||
|
||||
// loop over children of node. if no children, or all children are either
|
||||
// empty text nodes or non-editable, then node qualifies as empty
|
||||
for (nsCOMPtr<nsIContent> child = aNode->GetFirstChild();
|
||||
child;
|
||||
@@ -4411,7 +4411,7 @@ nsHTMLEditor::IsEmptyNodeImpl(nsINode* aNode,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -4478,7 +4478,7 @@ nsHTMLEditor::SetAttributeOrEquivalent(nsIDOMElement * aElement,
|
||||
res = aElement->SetAttribute(aAttribute, aValue);
|
||||
else
|
||||
res = SetAttribute(aElement, aAttribute, aValue);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -4708,7 +4708,7 @@ nsHTMLEditor::SetBackgroundColor(const nsAString& aColor)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// NodesSameType: do these nodes have the same tag?
|
||||
//
|
||||
//
|
||||
/* virtual */
|
||||
bool
|
||||
nsHTMLEditor::AreNodesSameType(nsIContent* aNode1, nsIContent* aNode2)
|
||||
|
||||
@@ -54,8 +54,9 @@ struct PropItem;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
class DocumentFragment;
|
||||
template<class T> class OwningNonNull;
|
||||
}
|
||||
} // namespace dom
|
||||
namespace widget {
|
||||
struct IMEState;
|
||||
} // namespace widget
|
||||
@@ -63,7 +64,7 @@ struct IMEState;
|
||||
|
||||
/**
|
||||
* The HTML editor implementation.<br>
|
||||
* Use to edit HTML document represented as a DOM tree.
|
||||
* Use to edit HTML document represented as a DOM tree.
|
||||
*/
|
||||
class nsHTMLEditor final : public nsPlaintextEditor,
|
||||
public nsIHTMLEditor,
|
||||
@@ -90,7 +91,7 @@ public:
|
||||
// see nsIHTMLEditor for documentation
|
||||
|
||||
//Interfaces for addref and release and queryinterface
|
||||
//NOTE macro used is for classes that inherit from
|
||||
//NOTE macro used is for classes that inherit from
|
||||
// another class. Only the base class should use NS_DECL_ISUPPORTS
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsHTMLEditor, nsPlaintextEditor)
|
||||
@@ -194,14 +195,14 @@ public:
|
||||
int32_t aRowIndex, int32_t aColIndex,
|
||||
nsIDOMElement **aCell,
|
||||
int32_t* aStartRowIndex, int32_t* aStartColIndex,
|
||||
int32_t* aRowSpan, int32_t* aColSpan,
|
||||
int32_t* aActualRowSpan, int32_t* aActualColSpan,
|
||||
int32_t* aRowSpan, int32_t* aColSpan,
|
||||
int32_t* aActualRowSpan, int32_t* aActualColSpan,
|
||||
bool* aIsSelected) override;
|
||||
NS_IMETHOD GetFirstRow(nsIDOMElement* aTableElement, nsIDOMNode** aRowNode) override;
|
||||
NS_IMETHOD GetNextRow(nsIDOMNode* aCurrentRowNode, nsIDOMNode** aRowNode) override;
|
||||
nsresult GetLastCellInRow(nsIDOMNode* aRowNode, nsIDOMNode** aCellNode);
|
||||
|
||||
NS_IMETHOD SetSelectionAfterTableEdit(nsIDOMElement* aTable, int32_t aRow, int32_t aCol,
|
||||
NS_IMETHOD SetSelectionAfterTableEdit(nsIDOMElement* aTable, int32_t aRow, int32_t aCol,
|
||||
int32_t aDirection, bool aSelected) override;
|
||||
NS_IMETHOD GetSelectedOrParentTableElement(nsAString& aTagName,
|
||||
int32_t *aSelectedCount,
|
||||
@@ -212,7 +213,7 @@ public:
|
||||
|
||||
// Finds the first selected cell in first range of selection
|
||||
// This is in the *order of selection*, not order in the table
|
||||
// (i.e., each cell added to selection is added in another range
|
||||
// (i.e., each cell added to selection is added in another range
|
||||
// in the selection's rangelist, independent of location in table)
|
||||
// aRange is optional: returns the range around the cell
|
||||
NS_IMETHOD GetFirstSelectedCell(nsIDOMRange **aRange, nsIDOMElement **aCell) override;
|
||||
@@ -222,7 +223,7 @@ public:
|
||||
|
||||
// Upper-left-most selected cell in table
|
||||
NS_IMETHOD GetFirstSelectedCellInTable(int32_t *aRowIndex, int32_t *aColIndex, nsIDOMElement **aCell) override;
|
||||
|
||||
|
||||
/* miscellaneous */
|
||||
// This sets background on the appropriate container element (table, cell,)
|
||||
// or calls into nsTextEditor to set the page background
|
||||
@@ -289,7 +290,7 @@ public:
|
||||
/** returns true if aParentTag can contain a child of type aChildTag */
|
||||
virtual bool TagCanContainTag(nsIAtom& aParentTag, nsIAtom& aChildTag)
|
||||
override;
|
||||
|
||||
|
||||
/** returns true if aNode is a container */
|
||||
virtual bool IsContainer(nsINode* aNode) override;
|
||||
virtual bool IsContainer(nsIDOMNode* aNode) override;
|
||||
@@ -336,12 +337,12 @@ public:
|
||||
|
||||
/* ------------ Utility Routines, not part of public API -------------- */
|
||||
NS_IMETHOD TypedText(const nsAString& aString, ETypingAction aAction) override;
|
||||
nsresult InsertNodeAtPoint( nsIDOMNode *aNode,
|
||||
nsCOMPtr<nsIDOMNode> *ioParent,
|
||||
int32_t *ioOffset,
|
||||
nsresult InsertNodeAtPoint( nsIDOMNode *aNode,
|
||||
nsCOMPtr<nsIDOMNode> *ioParent,
|
||||
int32_t *ioOffset,
|
||||
bool aNoEmptyNodes);
|
||||
|
||||
// Use this to assure that selection is set after attribute nodes when
|
||||
// Use this to assure that selection is set after attribute nodes when
|
||||
// trying to collapse selection at begining of a block node
|
||||
// e.g., when setting at beginning of a table cell
|
||||
// This will stop at a table, however, since we don't want to
|
||||
@@ -357,7 +358,7 @@ public:
|
||||
nsresult IsVisTextNode(nsIContent* aNode,
|
||||
bool* outIsEmptyNode,
|
||||
bool aSafeToAskFrames);
|
||||
nsresult IsEmptyNode(nsIDOMNode *aNode, bool *outIsEmptyBlock,
|
||||
nsresult IsEmptyNode(nsIDOMNode *aNode, bool *outIsEmptyBlock,
|
||||
bool aMozBRDoesntCount = false,
|
||||
bool aListOrCellNotEmpty = false,
|
||||
bool aSafeToAskFrames = false);
|
||||
@@ -366,7 +367,7 @@ public:
|
||||
bool aListOrCellNotEmpty = false,
|
||||
bool aSafeToAskFrames = false);
|
||||
nsresult IsEmptyNodeImpl(nsINode* aNode,
|
||||
bool *outIsEmptyBlock,
|
||||
bool *outIsEmptyBlock,
|
||||
bool aMozBRDoesntCount,
|
||||
bool aListOrCellNotEmpty,
|
||||
bool aSafeToAskFrames,
|
||||
@@ -426,14 +427,14 @@ protected:
|
||||
NS_IMETHOD TabInTable(bool inIsShift, bool *outHandled);
|
||||
already_AddRefed<mozilla::dom::Element> CreateBR(nsINode* aNode,
|
||||
int32_t aOffset, EDirection aSelect = eNone);
|
||||
NS_IMETHOD CreateBR(nsIDOMNode *aNode, int32_t aOffset,
|
||||
NS_IMETHOD CreateBR(nsIDOMNode *aNode, int32_t aOffset,
|
||||
nsCOMPtr<nsIDOMNode> *outBRNode, nsIEditor::EDirection aSelect = nsIEditor::eNone) override;
|
||||
|
||||
// Table Editing (implemented in nsTableEditor.cpp)
|
||||
|
||||
// Table utilities
|
||||
|
||||
// Insert a new cell after or before supplied aCell.
|
||||
// Insert a new cell after or before supplied aCell.
|
||||
// Optional: If aNewCell supplied, returns the newly-created cell (addref'd, of course)
|
||||
// This doesn't change or use the current selection
|
||||
NS_IMETHOD InsertCell(nsIDOMElement *aCell, int32_t aRowSpan, int32_t aColSpan,
|
||||
@@ -473,7 +474,7 @@ protected:
|
||||
nsIDOMNode** aCellParent, int32_t* aCellOffset,
|
||||
int32_t* aRowIndex, int32_t* aColIndex);
|
||||
|
||||
NS_IMETHOD GetCellSpansAt(nsIDOMElement* aTable, int32_t aRowIndex, int32_t aColIndex,
|
||||
NS_IMETHOD GetCellSpansAt(nsIDOMElement* aTable, int32_t aRowIndex, int32_t aColIndex,
|
||||
int32_t& aActualRowSpan, int32_t& aActualColSpan);
|
||||
|
||||
NS_IMETHOD SplitCellIntoColumns(nsIDOMElement *aTable, int32_t aRowIndex, int32_t aColIndex,
|
||||
@@ -493,13 +494,13 @@ protected:
|
||||
nsresult SetSelectionAtDocumentStart(mozilla::dom::Selection* aSelection);
|
||||
|
||||
// End of Table Editing utilities
|
||||
|
||||
|
||||
static already_AddRefed<mozilla::dom::Element>
|
||||
GetEnclosingTable(nsINode* aNode);
|
||||
static nsCOMPtr<nsIDOMNode> GetEnclosingTable(nsIDOMNode *aNode);
|
||||
|
||||
/** content-based query returns true if <aProperty aAttribute=aValue> effects aNode
|
||||
* If <aProperty aAttribute=aValue> contains aNode,
|
||||
* If <aProperty aAttribute=aValue> contains aNode,
|
||||
* but <aProperty aAttribute=SomeOtherValue> also contains aNode and the second is
|
||||
* more deeply nested than the first, then the first does not effect aNode.
|
||||
*
|
||||
@@ -552,7 +553,7 @@ protected:
|
||||
// factored methods for handling insertion of data from transferables (drag&drop or clipboard)
|
||||
NS_IMETHOD PrepareTransferable(nsITransferable **transferable) override;
|
||||
nsresult PrepareHTMLTransferable(nsITransferable **transferable, bool havePrivFlavor);
|
||||
nsresult InsertFromTransferable(nsITransferable *transferable,
|
||||
nsresult InsertFromTransferable(nsITransferable *transferable,
|
||||
nsIDOMDocument *aSourceDoc,
|
||||
const nsAString & aContextStr,
|
||||
const nsAString & aInfoStr,
|
||||
@@ -570,17 +571,17 @@ protected:
|
||||
nsresult DoContentFilterCallback(const nsAString &aFlavor,
|
||||
nsIDOMDocument *aSourceDoc,
|
||||
bool aWillDeleteSelection,
|
||||
nsIDOMNode **aFragmentAsNode,
|
||||
nsIDOMNode **aFragmentAsNode,
|
||||
nsIDOMNode **aFragStartNode,
|
||||
int32_t *aFragStartOffset,
|
||||
nsIDOMNode **aFragEndNode,
|
||||
int32_t *aFragEndOffset,
|
||||
nsIDOMNode **aTargetNode,
|
||||
int32_t *aTargetOffset,
|
||||
nsIDOMNode **aTargetNode,
|
||||
int32_t *aTargetOffset,
|
||||
bool *aDoContinue);
|
||||
|
||||
bool IsInLink(nsIDOMNode *aNode, nsCOMPtr<nsIDOMNode> *outLink = nullptr);
|
||||
nsresult StripFormattingNodes(nsIDOMNode *aNode, bool aOnlyList = false);
|
||||
nsresult StripFormattingNodes(nsIContent& aNode, bool aOnlyList = false);
|
||||
nsresult CreateDOMFragmentFromPaste(const nsAString & aInputString,
|
||||
const nsAString & aContextStr,
|
||||
const nsAString & aInfoStr,
|
||||
@@ -592,7 +593,7 @@ protected:
|
||||
bool aTrustedInput);
|
||||
nsresult ParseFragment(const nsAString & aStr, nsIAtom* aContextLocalName,
|
||||
nsIDocument* aTargetDoc,
|
||||
nsCOMPtr<nsIDOMNode> *outNode,
|
||||
mozilla::dom::DocumentFragment** aFragment,
|
||||
bool aTrustedInput);
|
||||
void CreateListOfNodesToPaste(mozilla::dom::DocumentFragment& aFragment,
|
||||
nsTArray<mozilla::dom::OwningNonNull<nsINode>>& outNodeList,
|
||||
@@ -620,7 +621,7 @@ protected:
|
||||
bool IsVisBreak(nsINode* aNode);
|
||||
bool IsVisBreak(nsIDOMNode *aNode);
|
||||
|
||||
/* utility routine to possibly adjust the insertion position when
|
||||
/* utility routine to possibly adjust the insertion position when
|
||||
inserting a block level element */
|
||||
void NormalizeEOLInsertPosition(nsIDOMNode *firstNodeToInsert,
|
||||
nsCOMPtr<nsIDOMNode> *insertParentNode,
|
||||
@@ -632,14 +633,14 @@ protected:
|
||||
/* helpers for block transformations */
|
||||
nsresult MakeDefinitionItem(const nsAString & aItemType);
|
||||
nsresult InsertBasicBlock(const nsAString & aBlockType);
|
||||
|
||||
|
||||
/* increase/decrease the font size of selection */
|
||||
enum class FontSize { incr, decr };
|
||||
nsresult RelativeFontChange(FontSize aDir);
|
||||
|
||||
|
||||
/* helper routines for font size changing */
|
||||
nsresult RelativeFontChangeOnTextNode( int32_t aSizeChange,
|
||||
nsIDOMCharacterData *aTextNode,
|
||||
nsresult RelativeFontChangeOnTextNode( int32_t aSizeChange,
|
||||
nsIDOMCharacterData *aTextNode,
|
||||
int32_t aStartOffset,
|
||||
int32_t aEndOffset);
|
||||
nsresult RelativeFontChangeOnNode(int32_t aSizeChange, nsIContent* aNode);
|
||||
@@ -660,18 +661,18 @@ protected:
|
||||
nsresult PromoteInlineRange(nsRange* aRange);
|
||||
nsresult PromoteRangeIfStartsOrEndsInNamedAnchor(nsRange* aRange);
|
||||
nsresult SplitStyleAboveRange(nsRange* aRange,
|
||||
nsIAtom *aProperty,
|
||||
nsIAtom *aProperty,
|
||||
const nsAString *aAttribute);
|
||||
nsresult SplitStyleAbovePoint(nsCOMPtr<nsIDOMNode> *aNode,
|
||||
int32_t *aOffset,
|
||||
nsIAtom *aProperty,
|
||||
nsIAtom *aProperty,
|
||||
const nsAString *aAttribute,
|
||||
nsCOMPtr<nsIDOMNode> *outLeftNode = nullptr,
|
||||
nsCOMPtr<nsIDOMNode> *outRightNode = nullptr);
|
||||
nsresult ApplyDefaultProperties();
|
||||
nsresult RemoveStyleInside(nsIDOMNode *aNode,
|
||||
nsIAtom *aProperty,
|
||||
const nsAString *aAttribute,
|
||||
nsresult RemoveStyleInside(nsIDOMNode *aNode,
|
||||
nsIAtom *aProperty,
|
||||
const nsAString *aAttribute,
|
||||
const bool aChildrenOnly = false);
|
||||
nsresult RemoveInlinePropertyImpl(nsIAtom* aProperty,
|
||||
const nsAString* aAttribute);
|
||||
@@ -774,7 +775,7 @@ protected:
|
||||
// Maintain a list of associated style sheets and their urls.
|
||||
nsTArray<nsString> mStyleSheetURLs;
|
||||
nsTArray<nsRefPtr<mozilla::CSSStyleSheet>> mStyleSheets;
|
||||
|
||||
|
||||
// an array for holding default style settings
|
||||
nsTArray<PropItem*> mDefaultStyles;
|
||||
|
||||
|
||||
@@ -183,7 +183,7 @@ nsHTMLEditorEventListener::MouseDown(nsIDOMMouseEvent* aMouseEvent)
|
||||
// the event; so we need to check resizing state ourselves
|
||||
htmlEditor->CheckSelectionStateForAnonymousButtons(selection);
|
||||
|
||||
// Prevent bubbling if we changed selection or
|
||||
// Prevent bubbling if we changed selection or
|
||||
// for all context clicks
|
||||
if (element || isContextClick) {
|
||||
aMouseEvent->PreventDefault();
|
||||
|
||||
@@ -59,8 +59,8 @@ IsEmptyTextNode(nsHTMLEditor* aThis, nsINode* aNode)
|
||||
isEmptyTextNode;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLEditor::AddDefaultProperty(nsIAtom *aProperty,
|
||||
const nsAString & aAttribute,
|
||||
NS_IMETHODIMP nsHTMLEditor::AddDefaultProperty(nsIAtom *aProperty,
|
||||
const nsAString & aAttribute,
|
||||
const nsAString & aValue)
|
||||
{
|
||||
nsString outValue;
|
||||
@@ -80,8 +80,8 @@ NS_IMETHODIMP nsHTMLEditor::AddDefaultProperty(nsIAtom *aProperty,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLEditor::RemoveDefaultProperty(nsIAtom *aProperty,
|
||||
const nsAString & aAttribute,
|
||||
NS_IMETHODIMP nsHTMLEditor::RemoveDefaultProperty(nsIAtom *aProperty,
|
||||
const nsAString & aAttribute,
|
||||
const nsAString & aValue)
|
||||
{
|
||||
nsString outValue;
|
||||
@@ -715,7 +715,7 @@ nsresult nsHTMLEditor::ApplyDefaultProperties()
|
||||
return res;
|
||||
}
|
||||
|
||||
nsresult nsHTMLEditor::RemoveStyleInside(nsIDOMNode *aNode,
|
||||
nsresult nsHTMLEditor::RemoveStyleInside(nsIDOMNode *aNode,
|
||||
// null here means remove all properties
|
||||
nsIAtom *aProperty,
|
||||
const nsAString *aAttribute,
|
||||
@@ -753,7 +753,7 @@ nsresult nsHTMLEditor::RemoveStyleInside(nsIDOMNode *aNode,
|
||||
(!aProperty && NodeIsProperty(aNode))
|
||||
)
|
||||
) {
|
||||
// if we weren't passed an attribute, then we want to
|
||||
// if we weren't passed an attribute, then we want to
|
||||
// remove any matching inlinestyles entirely
|
||||
if (!aAttribute || aAttribute->IsEmpty()) {
|
||||
NS_NAMED_LITERAL_STRING(styleAttr, "style");
|
||||
@@ -829,7 +829,7 @@ nsresult nsHTMLEditor::RemoveStyleInside(nsIDOMNode *aNode,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool nsHTMLEditor::IsOnlyAttribute(nsIDOMNode *aNode,
|
||||
bool nsHTMLEditor::IsOnlyAttribute(nsIDOMNode *aNode,
|
||||
const nsAString *aAttribute)
|
||||
{
|
||||
NS_ENSURE_TRUE(aNode && aAttribute, false); // ooops
|
||||
@@ -894,7 +894,7 @@ nsHTMLEditor::PromoteRangeIfStartsOrEndsInNamedAnchor(nsRange* inRange)
|
||||
nsresult res;
|
||||
nsCOMPtr<nsIDOMNode> startNode, endNode, parent, tmp;
|
||||
int32_t startOffset, endOffset, tmpOffset;
|
||||
|
||||
|
||||
res = inRange->GetStartContainer(getter_AddRefs(startNode));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
res = inRange->GetStartOffset(&startOffset);
|
||||
@@ -905,7 +905,7 @@ nsHTMLEditor::PromoteRangeIfStartsOrEndsInNamedAnchor(nsRange* inRange)
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
tmp = startNode;
|
||||
while ( tmp &&
|
||||
while ( tmp &&
|
||||
!nsTextEditUtils::IsBody(tmp) &&
|
||||
!nsHTMLEditUtils::IsNamedAnchor(tmp))
|
||||
{
|
||||
@@ -921,7 +921,7 @@ nsHTMLEditor::PromoteRangeIfStartsOrEndsInNamedAnchor(nsRange* inRange)
|
||||
}
|
||||
|
||||
tmp = endNode;
|
||||
while ( tmp &&
|
||||
while ( tmp &&
|
||||
!nsTextEditUtils::IsBody(tmp) &&
|
||||
!nsHTMLEditUtils::IsNamedAnchor(tmp))
|
||||
{
|
||||
@@ -949,7 +949,7 @@ nsHTMLEditor::PromoteInlineRange(nsRange* inRange)
|
||||
nsresult res;
|
||||
nsCOMPtr<nsIDOMNode> startNode, endNode, parent;
|
||||
int32_t startOffset, endOffset;
|
||||
|
||||
|
||||
res = inRange->GetStartContainer(getter_AddRefs(startNode));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
res = inRange->GetStartOffset(&startOffset);
|
||||
@@ -958,9 +958,9 @@ nsHTMLEditor::PromoteInlineRange(nsRange* inRange)
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
res = inRange->GetEndOffset(&endOffset);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
while ( startNode &&
|
||||
!nsTextEditUtils::IsBody(startNode) &&
|
||||
|
||||
while ( startNode &&
|
||||
!nsTextEditUtils::IsBody(startNode) &&
|
||||
IsEditable(startNode) &&
|
||||
IsAtFrontOfNode(startNode, startOffset) )
|
||||
{
|
||||
@@ -968,9 +968,9 @@ nsHTMLEditor::PromoteInlineRange(nsRange* inRange)
|
||||
startNode = parent;
|
||||
}
|
||||
NS_ENSURE_TRUE(startNode, NS_ERROR_NULL_POINTER);
|
||||
|
||||
while ( endNode &&
|
||||
!nsTextEditUtils::IsBody(endNode) &&
|
||||
|
||||
while ( endNode &&
|
||||
!nsTextEditUtils::IsBody(endNode) &&
|
||||
IsEditable(endNode) &&
|
||||
IsAtEndOfNode(endNode, endOffset) )
|
||||
{
|
||||
@@ -979,7 +979,7 @@ nsHTMLEditor::PromoteInlineRange(nsRange* inRange)
|
||||
endOffset++; // we are AFTER this node
|
||||
}
|
||||
NS_ENSURE_TRUE(endNode, NS_ERROR_NULL_POINTER);
|
||||
|
||||
|
||||
res = inRange->SetStart(startNode, startOffset);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
res = inRange->SetEnd(endNode, endOffset);
|
||||
@@ -1001,7 +1001,7 @@ bool nsHTMLEditor::IsAtFrontOfNode(nsIDOMNode *aNode, int32_t aOffset)
|
||||
else
|
||||
{
|
||||
nsCOMPtr<nsIContent> firstNode = GetFirstEditableChild(*node);
|
||||
NS_ENSURE_TRUE(firstNode, true);
|
||||
NS_ENSURE_TRUE(firstNode, true);
|
||||
int32_t offset = node->IndexOf(firstNode);
|
||||
if (offset < aOffset) return false;
|
||||
return true;
|
||||
@@ -1014,7 +1014,7 @@ bool nsHTMLEditor::IsAtEndOfNode(nsIDOMNode *aNode, int32_t aOffset)
|
||||
NS_ENSURE_TRUE(node, false);
|
||||
uint32_t len = node->Length();
|
||||
if (aOffset == (int32_t)len) return true;
|
||||
|
||||
|
||||
if (IsTextNode(aNode))
|
||||
{
|
||||
return false;
|
||||
@@ -1022,7 +1022,7 @@ bool nsHTMLEditor::IsAtEndOfNode(nsIDOMNode *aNode, int32_t aOffset)
|
||||
else
|
||||
{
|
||||
nsCOMPtr<nsIContent> lastNode = GetLastEditableChild(*node);
|
||||
NS_ENSURE_TRUE(lastNode, true);
|
||||
NS_ENSURE_TRUE(lastNode, true);
|
||||
int32_t offset = node->IndexOf(lastNode);
|
||||
if (offset < aOffset) return true;
|
||||
return false;
|
||||
@@ -1202,11 +1202,11 @@ nsHTMLEditor::GetInlinePropertyBase(nsIAtom& aProperty,
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsHTMLEditor::GetInlineProperty(nsIAtom *aProperty,
|
||||
const nsAString &aAttribute,
|
||||
NS_IMETHODIMP nsHTMLEditor::GetInlineProperty(nsIAtom *aProperty,
|
||||
const nsAString &aAttribute,
|
||||
const nsAString &aValue,
|
||||
bool *aFirst,
|
||||
bool *aAny,
|
||||
bool *aFirst,
|
||||
bool *aAny,
|
||||
bool *aAll)
|
||||
{
|
||||
NS_ENSURE_TRUE(aProperty && aFirst && aAny && aAll, NS_ERROR_NULL_POINTER);
|
||||
@@ -1220,11 +1220,11 @@ NS_IMETHODIMP nsHTMLEditor::GetInlineProperty(nsIAtom *aProperty,
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsHTMLEditor::GetInlinePropertyWithAttrValue(nsIAtom *aProperty,
|
||||
const nsAString &aAttribute,
|
||||
NS_IMETHODIMP nsHTMLEditor::GetInlinePropertyWithAttrValue(nsIAtom *aProperty,
|
||||
const nsAString &aAttribute,
|
||||
const nsAString &aValue,
|
||||
bool *aFirst,
|
||||
bool *aAny,
|
||||
bool *aFirst,
|
||||
bool *aAny,
|
||||
bool *aAll,
|
||||
nsAString &outValue)
|
||||
{
|
||||
@@ -1514,8 +1514,8 @@ nsHTMLEditor::RelativeFontChange(FontSize aDir)
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLEditor::RelativeFontChangeOnTextNode( int32_t aSizeChange,
|
||||
nsIDOMCharacterData *aTextNode,
|
||||
nsHTMLEditor::RelativeFontChangeOnTextNode( int32_t aSizeChange,
|
||||
nsIDOMCharacterData *aTextNode,
|
||||
int32_t aStartOffset,
|
||||
int32_t aEndOffset)
|
||||
{
|
||||
@@ -1524,10 +1524,10 @@ nsHTMLEditor::RelativeFontChangeOnTextNode( int32_t aSizeChange,
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
nsCOMPtr<nsIContent> textNode = do_QueryInterface(aTextNode);
|
||||
NS_ENSURE_TRUE(textNode, NS_ERROR_NULL_POINTER);
|
||||
|
||||
|
||||
// don't need to do anything if no characters actually selected
|
||||
if (aStartOffset == aEndOffset) return NS_OK;
|
||||
|
||||
|
||||
if (!textNode->GetParentNode() ||
|
||||
!CanContainTag(*textNode->GetParentNode(), *nsGkAtoms::big)) {
|
||||
return NS_OK;
|
||||
@@ -1540,10 +1540,10 @@ nsHTMLEditor::RelativeFontChangeOnTextNode( int32_t aSizeChange,
|
||||
// do we need to split the text node?
|
||||
uint32_t textLen;
|
||||
aTextNode->GetLength(&textLen);
|
||||
|
||||
|
||||
// -1 is a magic value meaning to the end of node
|
||||
if (aEndOffset == -1) aEndOffset = textLen;
|
||||
|
||||
|
||||
nsresult res = NS_OK;
|
||||
if ( (uint32_t)aEndOffset != textLen )
|
||||
{
|
||||
@@ -1574,7 +1574,7 @@ nsHTMLEditor::RelativeFontChangeOnTextNode( int32_t aSizeChange,
|
||||
res = MoveNode(node, sibling, 0);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
// else reparent the node inside font node with appropriate relative size
|
||||
nsCOMPtr<Element> newElement = InsertContainerAbove(node, nodeType);
|
||||
NS_ENSURE_STATE(newElement);
|
||||
@@ -1593,7 +1593,7 @@ nsHTMLEditor::RelativeFontChangeHelper(int32_t aSizeChange, nsINode* aNode)
|
||||
set. Any such nodes need to have big or small put inside them, since
|
||||
they override any big/small that are above them.
|
||||
*/
|
||||
|
||||
|
||||
// Can only change font size by + or - 1
|
||||
if (aSizeChange != 1 && aSizeChange != -1) {
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
@@ -1638,7 +1638,7 @@ nsHTMLEditor::RelativeFontChangeOnNode(int32_t aSizeChange, nsIContent* aNode)
|
||||
} else {
|
||||
atom = nsGkAtoms::small;
|
||||
}
|
||||
|
||||
|
||||
// Is it the opposite of what we want?
|
||||
if ((aSizeChange == 1 && aNode->IsHTMLElement(nsGkAtoms::small)) ||
|
||||
(aSizeChange == -1 && aNode->IsHTMLElement(nsGkAtoms::big))) {
|
||||
@@ -1680,7 +1680,7 @@ nsHTMLEditor::RelativeFontChangeOnNode(int32_t aSizeChange, nsIContent* aNode)
|
||||
// none of the above? then cycle through the children.
|
||||
// MOOSE: we should group the children together if possible
|
||||
// into a single "big" or "small". For the moment they are
|
||||
// each getting their own.
|
||||
// each getting their own.
|
||||
for (uint32_t i = aNode->GetChildCount(); i--; ) {
|
||||
nsresult rv = RelativeFontChangeOnNode(aSizeChange, aNode->GetChildAt(i));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
@@ -1689,7 +1689,7 @@ nsHTMLEditor::RelativeFontChangeOnNode(int32_t aSizeChange, nsIContent* aNode)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsHTMLEditor::GetFontFaceState(bool *aMixed, nsAString &outFace)
|
||||
{
|
||||
NS_ENSURE_TRUE(aMixed, NS_ERROR_FAILURE);
|
||||
@@ -1698,7 +1698,7 @@ nsHTMLEditor::GetFontFaceState(bool *aMixed, nsAString &outFace)
|
||||
|
||||
nsresult res;
|
||||
bool first, any, all;
|
||||
|
||||
|
||||
NS_NAMED_LITERAL_STRING(attr, "face");
|
||||
res = GetInlinePropertyBase(*nsGkAtoms::font, &attr, nullptr, &first, &any,
|
||||
&all, &outFace);
|
||||
@@ -1709,7 +1709,7 @@ nsHTMLEditor::GetFontFaceState(bool *aMixed, nsAString &outFace)
|
||||
*aMixed = false;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
// if there is no font face, check for tt
|
||||
res = GetInlinePropertyBase(*nsGkAtoms::tt, nullptr, nullptr, &first, &any,
|
||||
&all,nullptr);
|
||||
@@ -1720,7 +1720,7 @@ nsHTMLEditor::GetFontFaceState(bool *aMixed, nsAString &outFace)
|
||||
*aMixed = false;
|
||||
outFace.AssignLiteral("tt");
|
||||
}
|
||||
|
||||
|
||||
if (!any)
|
||||
{
|
||||
// there was no font face attrs of any kind. We are in normal font.
|
||||
@@ -1730,17 +1730,17 @@ nsHTMLEditor::GetFontFaceState(bool *aMixed, nsAString &outFace)
|
||||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsHTMLEditor::GetFontColorState(bool *aMixed, nsAString &aOutColor)
|
||||
{
|
||||
NS_ENSURE_TRUE(aMixed, NS_ERROR_NULL_POINTER);
|
||||
*aMixed = true;
|
||||
aOutColor.Truncate();
|
||||
|
||||
|
||||
nsresult res;
|
||||
NS_NAMED_LITERAL_STRING(colorStr, "color");
|
||||
bool first, any, all;
|
||||
|
||||
|
||||
res = GetInlinePropertyBase(*nsGkAtoms::font, &colorStr, nullptr, &first,
|
||||
&any, &all, &aOutColor);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
@@ -1750,7 +1750,7 @@ nsHTMLEditor::GetFontColorState(bool *aMixed, nsAString &aOutColor)
|
||||
*aMixed = false;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
if (!any)
|
||||
{
|
||||
// there was no font color attrs of any kind..
|
||||
|
||||
@@ -58,7 +58,7 @@ class nsHTMLEditUtils;
|
||||
// ==================================================================
|
||||
NS_IMPL_ISUPPORTS(DocumentResizeEventListener, nsIDOMEventListener)
|
||||
|
||||
DocumentResizeEventListener::DocumentResizeEventListener(nsIHTMLEditor * aEditor)
|
||||
DocumentResizeEventListener::DocumentResizeEventListener(nsIHTMLEditor * aEditor)
|
||||
{
|
||||
mEditor = do_GetWeakReference(aEditor);
|
||||
}
|
||||
@@ -96,7 +96,7 @@ ResizerSelectionListener::NotifySelectionChanged(nsIDOMDocument *, nsISelection
|
||||
{
|
||||
if ((aReason & (nsISelectionListener::MOUSEDOWN_REASON |
|
||||
nsISelectionListener::KEYPRESS_REASON |
|
||||
nsISelectionListener::SELECTALL_REASON)) && aSelection)
|
||||
nsISelectionListener::SELECTALL_REASON)) && aSelection)
|
||||
{
|
||||
// the selection changed and we need to check if we have to
|
||||
// hide and/or redisplay resizing handles
|
||||
@@ -119,7 +119,7 @@ ResizerMouseMotionListener::ResizerMouseMotionListener(nsIHTMLEditor * aEditor)
|
||||
mEditor = do_GetWeakReference(aEditor);
|
||||
}
|
||||
|
||||
ResizerMouseMotionListener::~ResizerMouseMotionListener()
|
||||
ResizerMouseMotionListener::~ResizerMouseMotionListener()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -299,7 +299,7 @@ nsHTMLEditor::RefreshResizers()
|
||||
mResizedObjectX, mResizedObjectY);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsHTMLEditor::ShowResizers(nsIDOMElement *aResizedElement)
|
||||
{
|
||||
nsresult res = ShowResizersInner(aResizedElement);
|
||||
@@ -308,7 +308,7 @@ nsHTMLEditor::ShowResizers(nsIDOMElement *aResizedElement)
|
||||
return res;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsresult
|
||||
nsHTMLEditor::ShowResizersInner(nsIDOMElement *aResizedElement)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aResizedElement);
|
||||
@@ -394,7 +394,7 @@ nsHTMLEditor::ShowResizersInner(nsIDOMElement *aResizedElement)
|
||||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsHTMLEditor::HideResizers(void)
|
||||
{
|
||||
NS_ENSURE_TRUE(mResizedObject, NS_OK);
|
||||
@@ -576,7 +576,7 @@ nsHTMLEditor::StartResizing(nsIDOMElement *aHandle)
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsHTMLEditor::MouseDown(int32_t aClientX, int32_t aClientY,
|
||||
nsIDOMElement *aTarget, nsIDOMEvent* aEvent)
|
||||
{
|
||||
@@ -605,7 +605,7 @@ nsHTMLEditor::MouseDown(int32_t aClientX, int32_t aClientY,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsHTMLEditor::MouseUp(int32_t aClientX, int32_t aClientY,
|
||||
nsIDOMElement *aTarget)
|
||||
{
|
||||
@@ -761,7 +761,7 @@ nsHTMLEditor::GetNewResizingIncrement(int32_t aX, int32_t aY, int32_t aID)
|
||||
|
||||
int32_t xi = (aX - mOriginalX) * mWidthIncrementFactor;
|
||||
int32_t yi = (aY - mOriginalY) * mHeightIncrementFactor;
|
||||
float objectSizeRatio =
|
||||
float objectSizeRatio =
|
||||
((float)mResizedObjectWidth) / ((float)mResizedObjectHeight);
|
||||
result = (xi > yi) ? xi : yi;
|
||||
switch (aID) {
|
||||
@@ -907,7 +907,7 @@ nsHTMLEditor::SetFinalSize(int32_t aX, int32_t aY)
|
||||
int32_t height = GetNewResizingHeight(aX, aY);
|
||||
bool setWidth = !mResizedObjectIsAbsolutelyPositioned || (width != mResizedObjectWidth);
|
||||
bool setHeight = !mResizedObjectIsAbsolutelyPositioned || (height != mResizedObjectHeight);
|
||||
|
||||
|
||||
int32_t x, y;
|
||||
x = left - ((mResizedObjectIsAbsolutelyPositioned) ? mResizedObjectBorderLeft+mResizedObjectMarginLeft : 0);
|
||||
y = top - ((mResizedObjectIsAbsolutelyPositioned) ? mResizedObjectBorderTop+mResizedObjectMarginTop : 0);
|
||||
@@ -917,7 +917,7 @@ nsHTMLEditor::SetFinalSize(int32_t aX, int32_t aY)
|
||||
|
||||
NS_NAMED_LITERAL_STRING(widthStr, "width");
|
||||
NS_NAMED_LITERAL_STRING(heightStr, "height");
|
||||
|
||||
|
||||
nsCOMPtr<Element> resizedObject = do_QueryInterface(mResizedObject);
|
||||
NS_ENSURE_TRUE(resizedObject, );
|
||||
if (mResizedObjectIsAbsolutelyPositioned) {
|
||||
|
||||
@@ -23,8 +23,8 @@ class nsSelectionState;
|
||||
class nsIAtom;
|
||||
|
||||
/**
|
||||
* A transaction interface mixin - for transactions that can support.
|
||||
* the placeholder absorbtion idiom.
|
||||
* A transaction interface mixin - for transactions that can support.
|
||||
* the placeholder absorbtion idiom.
|
||||
*/
|
||||
class nsIAbsorbingTransaction : public nsISupports{
|
||||
public:
|
||||
@@ -33,15 +33,15 @@ public:
|
||||
|
||||
NS_IMETHOD Init(nsIAtom* aName, nsSelectionState* aSelState,
|
||||
nsEditor* aEditor) = 0;
|
||||
|
||||
|
||||
NS_IMETHOD EndPlaceHolderBatch()=0;
|
||||
|
||||
|
||||
NS_IMETHOD GetTxnName(nsIAtom **aName)=0;
|
||||
|
||||
NS_IMETHOD StartSelectionEquals(nsSelectionState *aSelState, bool *aResult)=0;
|
||||
|
||||
NS_IMETHOD ForwardEndBatchTo(nsIAbsorbingTransaction *aForwardingAddress)=0;
|
||||
|
||||
|
||||
NS_IMETHOD Commit()=0;
|
||||
};
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ NS_IMETHODIMP nsPlaintextEditor::InsertTextFromTransferable(nsITransferable *aTr
|
||||
}
|
||||
}
|
||||
NS_Free(bestFlavor);
|
||||
|
||||
|
||||
// Try to scroll the selection into view if the paste/drop succeeded
|
||||
|
||||
if (NS_SUCCEEDED(rv))
|
||||
@@ -278,7 +278,7 @@ nsresult nsPlaintextEditor::InsertFromDrop(nsIDOMEvent* aDropEvent)
|
||||
// note that 4.x does replace if dropped on
|
||||
//deleteSelection = true;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
// We are NOT over the selection
|
||||
if (srcdomdoc == destdomdoc)
|
||||
@@ -336,7 +336,7 @@ NS_IMETHODIMP nsPlaintextEditor::Paste(int32_t aSelectionType)
|
||||
rv = PrepareTransferable(getter_AddRefs(trans));
|
||||
if (NS_SUCCEEDED(rv) && trans)
|
||||
{
|
||||
// Get the Data from the clipboard
|
||||
// Get the Data from the clipboard
|
||||
if (NS_SUCCEEDED(clipboard->GetData(trans, aSelectionType)) && IsModifiable())
|
||||
{
|
||||
// handle transferable hooks
|
||||
@@ -381,7 +381,7 @@ NS_IMETHODIMP nsPlaintextEditor::CanPaste(int32_t aSelectionType, bool *aCanPast
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIClipboard> clipboard(do_GetService("@mozilla.org/widget/clipboard;1", &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
||||
// the flavors that we can deal with
|
||||
const char* textEditorFlavors[] = { kUnicodeMime };
|
||||
|
||||
@@ -390,7 +390,7 @@ NS_IMETHODIMP nsPlaintextEditor::CanPaste(int32_t aSelectionType, bool *aCanPast
|
||||
ArrayLength(textEditorFlavors),
|
||||
aSelectionType, &haveFlavors);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
||||
*aCanPaste = haveFlavors;
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -421,7 +421,7 @@ NS_IMETHODIMP nsPlaintextEditor::CanPasteTransferable(nsITransferable *aTransfer
|
||||
*aCanPaste = true;
|
||||
else
|
||||
*aCanPaste = false;
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#include "nsIDOMCharacterData.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMEventTarget.h"
|
||||
#include "nsIDOMEventTarget.h"
|
||||
#include "nsIDOMKeyEvent.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
@@ -114,7 +114,7 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsPlaintextEditor)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsEditor)
|
||||
|
||||
|
||||
NS_IMETHODIMP nsPlaintextEditor::Init(nsIDOMDocument *aDoc,
|
||||
NS_IMETHODIMP nsPlaintextEditor::Init(nsIDOMDocument *aDoc,
|
||||
nsIContent *aRoot,
|
||||
nsISelectionController *aSelCon,
|
||||
uint32_t aFlags,
|
||||
@@ -122,16 +122,16 @@ NS_IMETHODIMP nsPlaintextEditor::Init(nsIDOMDocument *aDoc,
|
||||
{
|
||||
NS_PRECONDITION(aDoc, "bad arg");
|
||||
NS_ENSURE_TRUE(aDoc, NS_ERROR_NULL_POINTER);
|
||||
|
||||
|
||||
nsresult res = NS_OK, rulesRes = NS_OK;
|
||||
if (mRules) {
|
||||
mRules->DetachEditor();
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
// block to scope nsAutoEditInitRulesTrigger
|
||||
nsAutoEditInitRulesTrigger rulesTrigger(this, rulesRes);
|
||||
|
||||
|
||||
// Init the base editor
|
||||
res = nsEditor::Init(aDoc, aRoot, aSelCon, aFlags, aInitialValue);
|
||||
}
|
||||
@@ -187,13 +187,13 @@ nsPlaintextEditor::GetDefaultEditorPrefs(int32_t &aNewlineHandling,
|
||||
aCaretStyle = sCaretStylePref;
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
nsPlaintextEditor::BeginEditorInit()
|
||||
{
|
||||
mInitTriggerCounter++;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsresult
|
||||
nsPlaintextEditor::EndEditorInit()
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
@@ -458,14 +458,14 @@ nsPlaintextEditor::CreateBRImpl(nsCOMPtr<nsIDOMNode>* aInOutParent,
|
||||
NS_ENSURE_TRUE(aInOutParent && *aInOutParent && aInOutOffset && outBRNode, NS_ERROR_NULL_POINTER);
|
||||
*outBRNode = nullptr;
|
||||
nsresult res;
|
||||
|
||||
|
||||
// we need to insert a br. unfortunately, we may have to split a text node to do it.
|
||||
nsCOMPtr<nsIDOMNode> node = *aInOutParent;
|
||||
int32_t theOffset = *aInOutOffset;
|
||||
nsCOMPtr<nsIDOMCharacterData> nodeAsText = do_QueryInterface(node);
|
||||
NS_NAMED_LITERAL_STRING(brType, "br");
|
||||
nsCOMPtr<nsIDOMNode> brNode;
|
||||
if (nodeAsText)
|
||||
if (nodeAsText)
|
||||
{
|
||||
int32_t offset;
|
||||
uint32_t len;
|
||||
@@ -555,10 +555,10 @@ nsPlaintextEditor::InsertBR(nsCOMPtr<nsIDOMNode>* outBRNode)
|
||||
int32_t selOffset;
|
||||
res = GetStartNodeAndOffset(selection, getter_AddRefs(selNode), &selOffset);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
|
||||
res = CreateBR(selNode, selOffset, outBRNode);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
|
||||
// position selection after br
|
||||
selNode = GetNodeLocation(*outBRNode, &selOffset);
|
||||
selection->SetInterlinePosition(true);
|
||||
@@ -678,7 +678,7 @@ nsPlaintextEditor::DeleteSelection(EDirection aAction,
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
aAction = eNone;
|
||||
}
|
||||
}
|
||||
@@ -695,7 +695,7 @@ nsPlaintextEditor::DeleteSelection(EDirection aAction,
|
||||
}
|
||||
if (!cancel)
|
||||
{
|
||||
// post-process
|
||||
// post-process
|
||||
result = mRules->DidDoAction(selection, &ruleInfo, result);
|
||||
}
|
||||
|
||||
@@ -713,7 +713,7 @@ NS_IMETHODIMP nsPlaintextEditor::InsertText(const nsAString &aStringToInsert)
|
||||
if (mComposition) {
|
||||
opID = EditAction::insertIMEText;
|
||||
}
|
||||
nsAutoPlaceHolderBatch batch(this, nullptr);
|
||||
nsAutoPlaceHolderBatch batch(this, nullptr);
|
||||
nsAutoRules beginRulesSniffing(this, opID, nsIEditor::eNext);
|
||||
|
||||
// pre-process
|
||||
@@ -737,7 +737,7 @@ NS_IMETHODIMP nsPlaintextEditor::InsertText(const nsAString &aStringToInsert)
|
||||
}
|
||||
if (!cancel)
|
||||
{
|
||||
// post-process
|
||||
// post-process
|
||||
res = mRules->DidDoAction(selection, &ruleInfo, res);
|
||||
}
|
||||
return res;
|
||||
@@ -906,12 +906,12 @@ NS_IMETHODIMP
|
||||
nsPlaintextEditor::GetDocumentIsEmpty(bool *aDocumentIsEmpty)
|
||||
{
|
||||
NS_ENSURE_TRUE(aDocumentIsEmpty, NS_ERROR_NULL_POINTER);
|
||||
|
||||
|
||||
NS_ENSURE_TRUE(mRules, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
// Protect the edit rules object from dying
|
||||
nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
|
||||
|
||||
|
||||
return mRules->DocumentIsEmpty(aDocumentIsEmpty);
|
||||
}
|
||||
|
||||
@@ -922,7 +922,7 @@ nsPlaintextEditor::GetTextLength(int32_t *aCount)
|
||||
|
||||
// initialize out params
|
||||
*aCount = 0;
|
||||
|
||||
|
||||
// special-case for empty document, to account for the bogus node
|
||||
bool docEmpty;
|
||||
nsresult rv = GetDocumentIsEmpty(&docEmpty);
|
||||
@@ -971,7 +971,7 @@ nsPlaintextEditor::GetMaxTextLength(int32_t* aMaxTextLength)
|
||||
//
|
||||
// Get the wrap width
|
||||
//
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsPlaintextEditor::GetWrapWidth(int32_t *aWrapColumn)
|
||||
{
|
||||
NS_ENSURE_TRUE( aWrapColumn, NS_ERROR_NULL_POINTER);
|
||||
@@ -1000,8 +1000,8 @@ static void CutStyle(const char* stylename, nsString& styleValue)
|
||||
|
||||
//
|
||||
// Change the wrap width on the root of this document.
|
||||
//
|
||||
NS_IMETHODIMP
|
||||
//
|
||||
NS_IMETHODIMP
|
||||
nsPlaintextEditor::SetWrapWidth(int32_t aWrapColumn)
|
||||
{
|
||||
SetWrapColumn(aWrapColumn);
|
||||
@@ -1064,7 +1064,7 @@ nsPlaintextEditor::SetWrapWidth(int32_t aWrapColumn)
|
||||
return rootElement->SetAttr(kNameSpaceID_None, nsGkAtoms::style, styleValue, true);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsPlaintextEditor::SetWrapColumn(int32_t aWrapColumn)
|
||||
{
|
||||
mWrapColumn = aWrapColumn;
|
||||
@@ -1074,7 +1074,7 @@ nsPlaintextEditor::SetWrapColumn(int32_t aWrapColumn)
|
||||
//
|
||||
// Get the newline handling for this editor
|
||||
//
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsPlaintextEditor::GetNewlineHandling(int32_t *aNewlineHandling)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aNewlineHandling);
|
||||
@@ -1085,16 +1085,16 @@ nsPlaintextEditor::GetNewlineHandling(int32_t *aNewlineHandling)
|
||||
|
||||
//
|
||||
// Change the newline handling for this editor
|
||||
//
|
||||
NS_IMETHODIMP
|
||||
//
|
||||
NS_IMETHODIMP
|
||||
nsPlaintextEditor::SetNewlineHandling(int32_t aNewlineHandling)
|
||||
{
|
||||
mNewlineHandling = aNewlineHandling;
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsPlaintextEditor::Undo(uint32_t aCount)
|
||||
{
|
||||
// Protect the edit rules object from dying
|
||||
@@ -1112,18 +1112,18 @@ nsPlaintextEditor::Undo(uint32_t aCount)
|
||||
nsRefPtr<Selection> selection = GetSelection();
|
||||
bool cancel, handled;
|
||||
nsresult result = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
||||
|
||||
|
||||
if (!cancel && NS_SUCCEEDED(result))
|
||||
{
|
||||
result = nsEditor::Undo(aCount);
|
||||
result = mRules->DidDoAction(selection, &ruleInfo, result);
|
||||
}
|
||||
}
|
||||
|
||||
NotifyEditorObservers(eNotifyEditorObserversOfEnd);
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsPlaintextEditor::Redo(uint32_t aCount)
|
||||
{
|
||||
// Protect the edit rules object from dying
|
||||
@@ -1141,12 +1141,12 @@ nsPlaintextEditor::Redo(uint32_t aCount)
|
||||
nsRefPtr<Selection> selection = GetSelection();
|
||||
bool cancel, handled;
|
||||
nsresult result = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
||||
|
||||
|
||||
if (!cancel && NS_SUCCEEDED(result))
|
||||
{
|
||||
result = nsEditor::Redo(aCount);
|
||||
result = mRules->DidDoAction(selection, &ruleInfo, result);
|
||||
}
|
||||
}
|
||||
|
||||
NotifyEditorObservers(eNotifyEditorObserversOfEnd);
|
||||
return result;
|
||||
@@ -1289,7 +1289,7 @@ nsPlaintextEditor::GetAndInitDocEncoder(const nsAString& aFormatType,
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsPlaintextEditor::OutputToString(const nsAString& aFormatType,
|
||||
uint32_t aFlags,
|
||||
nsAString& aOutputString)
|
||||
@@ -1339,7 +1339,7 @@ nsPlaintextEditor::OutputToStream(nsIOutputStream* aOutputStream,
|
||||
bool docEmpty;
|
||||
rv = GetDocumentIsEmpty(&docEmpty);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
||||
if (docEmpty)
|
||||
return NS_OK; // output nothing
|
||||
}
|
||||
@@ -1513,7 +1513,7 @@ nsPlaintextEditor::Rewrap(bool aRespectNewlines)
|
||||
return InsertTextWithQuotations(wrapped);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsPlaintextEditor::StripCites()
|
||||
{
|
||||
nsAutoString current;
|
||||
@@ -1571,7 +1571,7 @@ nsPlaintextEditor::EndOperation()
|
||||
if (mRules) res = mRules->AfterEdit(mAction, mDirection);
|
||||
nsEditor::EndOperation(); // will clear mAction, mDirection
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
|
||||
@@ -35,7 +35,7 @@ class Selection;
|
||||
|
||||
/**
|
||||
* The text editor implementation.
|
||||
* Use to edit text document represented as a DOM tree.
|
||||
* Use to edit text document represented as a DOM tree.
|
||||
*/
|
||||
class nsPlaintextEditor : public nsEditor,
|
||||
public nsIPlaintextEditor,
|
||||
@@ -45,7 +45,7 @@ class nsPlaintextEditor : public nsEditor,
|
||||
public:
|
||||
|
||||
// Interfaces for addref and release and queryinterface
|
||||
// NOTE macro used is for classes that inherit from
|
||||
// NOTE macro used is for classes that inherit from
|
||||
// another class. Only the base class should use NS_DECL_ISUPPORTS
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsPlaintextEditor, nsEditor)
|
||||
@@ -78,7 +78,7 @@ public:
|
||||
NS_IMETHOD Init(nsIDOMDocument *aDoc, nsIContent *aRoot,
|
||||
nsISelectionController *aSelCon, uint32_t aFlags,
|
||||
const nsAString& aValue) override;
|
||||
|
||||
|
||||
NS_IMETHOD GetDocumentIsEmpty(bool *aDocumentIsEmpty) override;
|
||||
NS_IMETHOD GetIsDocumentEditable(bool *aIsDocumentEditable) override;
|
||||
|
||||
@@ -103,7 +103,7 @@ public:
|
||||
NS_IMETHOD OutputToString(const nsAString& aFormatType,
|
||||
uint32_t aFlags,
|
||||
nsAString& aOutputString) override;
|
||||
|
||||
|
||||
NS_IMETHOD OutputToStream(nsIOutputStream* aOutputStream,
|
||||
const nsAString& aFormatType,
|
||||
const nsACString& aCharsetOverride,
|
||||
@@ -178,7 +178,7 @@ protected:
|
||||
nsIDocumentEncoder** encoder);
|
||||
|
||||
// key event helpers
|
||||
NS_IMETHOD CreateBR(nsIDOMNode *aNode, int32_t aOffset,
|
||||
NS_IMETHOD CreateBR(nsIDOMNode *aNode, int32_t aOffset,
|
||||
nsCOMPtr<nsIDOMNode> *outBRNode, EDirection aSelect = eNone);
|
||||
already_AddRefed<mozilla::dom::Element>
|
||||
CreateBRImpl(nsCOMPtr<nsINode>* aInOutParent, int32_t* aInOutOffset,
|
||||
|
||||
@@ -30,7 +30,7 @@ using namespace mozilla::dom;
|
||||
*/
|
||||
nsSelectionState::nsSelectionState() : mArray(){}
|
||||
|
||||
nsSelectionState::~nsSelectionState()
|
||||
nsSelectionState::~nsSelectionState()
|
||||
{
|
||||
MakeEmpty();
|
||||
}
|
||||
@@ -76,7 +76,7 @@ nsSelectionState::SaveSelection(Selection* aSel)
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsresult
|
||||
nsSelectionState::RestoreSelection(Selection* aSel)
|
||||
{
|
||||
NS_ENSURE_TRUE(aSel, NS_ERROR_NULL_POINTER);
|
||||
@@ -85,13 +85,13 @@ nsSelectionState::RestoreSelection(Selection* aSel)
|
||||
|
||||
// clear out selection
|
||||
aSel->RemoveAllRanges();
|
||||
|
||||
|
||||
// set the selection ranges anew
|
||||
for (i=0; i<arrayCount; i++)
|
||||
{
|
||||
nsRefPtr<nsRange> range = mArray[i]->GetRange();
|
||||
NS_ENSURE_TRUE(range, NS_ERROR_UNEXPECTED);
|
||||
|
||||
|
||||
res = aSel->AddRange(range);
|
||||
if(NS_FAILED(res)) return res;
|
||||
|
||||
@@ -123,7 +123,7 @@ nsSelectionState::IsEqual(nsSelectionState *aSelState)
|
||||
nsRefPtr<nsRange> myRange = mArray[i]->GetRange();
|
||||
nsRefPtr<nsRange> itsRange = aSelState->mArray[i]->GetRange();
|
||||
NS_ENSURE_TRUE(myRange && itsRange, false);
|
||||
|
||||
|
||||
int16_t compResult;
|
||||
nsresult rv;
|
||||
rv = myRange->CompareBoundaryPoints(nsIDOMRange::START_TO_START, itsRange, &compResult);
|
||||
@@ -135,14 +135,14 @@ nsSelectionState::IsEqual(nsSelectionState *aSelState)
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
nsSelectionState::MakeEmpty()
|
||||
{
|
||||
// free any items in the array
|
||||
mArray.Clear();
|
||||
}
|
||||
|
||||
bool
|
||||
bool
|
||||
nsSelectionState::IsEmpty()
|
||||
{
|
||||
return mArray.IsEmpty();
|
||||
@@ -158,8 +158,8 @@ nsRangeUpdater::~nsRangeUpdater()
|
||||
{
|
||||
// nothing to do, we don't own the items in our array.
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
void
|
||||
nsRangeUpdater::RegisterRangeItem(nsRangeStore *aRangeItem)
|
||||
{
|
||||
if (!aRangeItem) return;
|
||||
@@ -171,14 +171,14 @@ nsRangeUpdater::RegisterRangeItem(nsRangeStore *aRangeItem)
|
||||
mArray.AppendElement(aRangeItem);
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
nsRangeUpdater::DropRangeItem(nsRangeStore *aRangeItem)
|
||||
{
|
||||
if (!aRangeItem) return;
|
||||
mArray.RemoveElement(aRangeItem);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsresult
|
||||
nsRangeUpdater::RegisterSelectionState(nsSelectionState &aSelState)
|
||||
{
|
||||
uint32_t i, theCount = aSelState.mArray.Length();
|
||||
@@ -192,7 +192,7 @@ nsRangeUpdater::RegisterSelectionState(nsSelectionState &aSelState)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsresult
|
||||
nsRangeUpdater::DropSelectionState(nsSelectionState &aSelState)
|
||||
{
|
||||
uint32_t i, theCount = aSelState.mArray.Length();
|
||||
@@ -497,7 +497,7 @@ nsRangeUpdater::SelAdjDeleteText(nsIDOMCharacterData* aTextNode,
|
||||
nsresult
|
||||
nsRangeUpdater::WillReplaceContainer()
|
||||
{
|
||||
if (mLock) return NS_ERROR_UNEXPECTED;
|
||||
if (mLock) return NS_ERROR_UNEXPECTED;
|
||||
mLock = true;
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -518,7 +518,7 @@ nsRangeUpdater::DidReplaceContainer(Element* aOriginalNode, Element* aNewNode)
|
||||
for (uint32_t i = 0; i < count; i++) {
|
||||
nsRangeStore* item = mArray[i];
|
||||
NS_ENSURE_TRUE(item, NS_ERROR_NULL_POINTER);
|
||||
|
||||
|
||||
if (item->startNode == aOriginalNode) {
|
||||
item->startNode = aNewNode;
|
||||
}
|
||||
@@ -533,7 +533,7 @@ nsRangeUpdater::DidReplaceContainer(Element* aOriginalNode, Element* aNewNode)
|
||||
nsresult
|
||||
nsRangeUpdater::WillRemoveContainer()
|
||||
{
|
||||
if (mLock) return NS_ERROR_UNEXPECTED;
|
||||
if (mLock) return NS_ERROR_UNEXPECTED;
|
||||
mLock = true;
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -555,14 +555,14 @@ nsRangeUpdater::DidRemoveContainer(nsINode* aNode, nsINode* aParent,
|
||||
for (uint32_t i = 0; i < count; i++) {
|
||||
nsRangeStore* item = mArray[i];
|
||||
NS_ENSURE_TRUE(item, NS_ERROR_NULL_POINTER);
|
||||
|
||||
|
||||
if (item->startNode == aNode) {
|
||||
item->startNode = aParent;
|
||||
item->startOffset += aOffset;
|
||||
} else if (item->startNode == aParent && item->startOffset > aOffset) {
|
||||
item->startOffset += (int32_t)aNodeOrigLen - 1;
|
||||
}
|
||||
|
||||
|
||||
if (item->endNode == aNode) {
|
||||
item->endNode = aParent;
|
||||
item->endOffset += aOffset;
|
||||
@@ -586,7 +586,7 @@ nsRangeUpdater::DidRemoveContainer(nsIDOMNode* aNode, nsIDOMNode* aParent,
|
||||
nsresult
|
||||
nsRangeUpdater::WillInsertContainer()
|
||||
{
|
||||
if (mLock) return NS_ERROR_UNEXPECTED;
|
||||
if (mLock) return NS_ERROR_UNEXPECTED;
|
||||
mLock = true;
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -595,7 +595,7 @@ nsRangeUpdater::WillInsertContainer()
|
||||
nsresult
|
||||
nsRangeUpdater::DidInsertContainer()
|
||||
{
|
||||
NS_ENSURE_TRUE(mLock, NS_ERROR_UNEXPECTED);
|
||||
NS_ENSURE_TRUE(mLock, NS_ERROR_UNEXPECTED);
|
||||
mLock = false;
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -620,7 +620,7 @@ nsRangeUpdater::DidMoveNode(nsINode* aOldParent, int32_t aOldOffset,
|
||||
for (uint32_t i = 0, count = mArray.Length(); i < count; ++i) {
|
||||
nsRangeStore* item = mArray[i];
|
||||
NS_ENSURE_TRUE_VOID(item);
|
||||
|
||||
|
||||
// like a delete in aOldParent
|
||||
if (item->startNode == aOldParent && item->startOffset > aOldOffset) {
|
||||
item->startOffset--;
|
||||
@@ -628,7 +628,7 @@ nsRangeUpdater::DidMoveNode(nsINode* aOldParent, int32_t aOldOffset,
|
||||
if (item->endNode == aOldParent && item->endOffset > aOldOffset) {
|
||||
item->endOffset--;
|
||||
}
|
||||
|
||||
|
||||
// and like an insert in aNewParent
|
||||
if (item->startNode == aNewParent && item->startOffset > aNewOffset) {
|
||||
item->startOffset++;
|
||||
@@ -645,8 +645,8 @@ nsRangeUpdater::DidMoveNode(nsINode* aOldParent, int32_t aOldOffset,
|
||||
* helper class for nsSelectionState. nsRangeStore stores range endpoints.
|
||||
*/
|
||||
|
||||
nsRangeStore::nsRangeStore()
|
||||
{
|
||||
nsRangeStore::nsRangeStore()
|
||||
{
|
||||
}
|
||||
nsRangeStore::~nsRangeStore()
|
||||
{
|
||||
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
already_AddRefed<nsRange> GetRange();
|
||||
|
||||
NS_INLINE_DECL_REFCOUNTING(nsRangeStore)
|
||||
|
||||
|
||||
nsCOMPtr<nsINode> startNode;
|
||||
int32_t startOffset;
|
||||
nsCOMPtr<nsINode> endNode;
|
||||
@@ -52,37 +52,37 @@ public:
|
||||
class nsSelectionState
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
nsSelectionState();
|
||||
~nsSelectionState();
|
||||
|
||||
void DoTraverse(nsCycleCollectionTraversalCallback &cb);
|
||||
void DoUnlink() { MakeEmpty(); }
|
||||
|
||||
|
||||
void SaveSelection(mozilla::dom::Selection *aSel);
|
||||
nsresult RestoreSelection(mozilla::dom::Selection* aSel);
|
||||
bool IsCollapsed();
|
||||
bool IsEqual(nsSelectionState *aSelState);
|
||||
void MakeEmpty();
|
||||
bool IsEmpty();
|
||||
protected:
|
||||
protected:
|
||||
nsTArray<nsRefPtr<nsRangeStore> > mArray;
|
||||
|
||||
|
||||
friend class nsRangeUpdater;
|
||||
};
|
||||
|
||||
class nsRangeUpdater
|
||||
{
|
||||
public:
|
||||
|
||||
public:
|
||||
|
||||
nsRangeUpdater();
|
||||
~nsRangeUpdater();
|
||||
|
||||
|
||||
void RegisterRangeItem(nsRangeStore *aRangeItem);
|
||||
void DropRangeItem(nsRangeStore *aRangeItem);
|
||||
nsresult RegisterSelectionState(nsSelectionState &aSelState);
|
||||
nsresult DropSelectionState(nsSelectionState &aSelState);
|
||||
|
||||
|
||||
// editor selection gravity routines. Note that we can't always depend on
|
||||
// DOM Range gravity to do what we want to the "real" selection. For instance,
|
||||
// if you move a node, that corresponds to deleting it and reinserting it.
|
||||
@@ -120,7 +120,7 @@ class nsRangeUpdater
|
||||
void WillMoveNode();
|
||||
void DidMoveNode(nsINode* aOldParent, int32_t aOldOffset,
|
||||
nsINode* aNewParent, int32_t aNewOffset);
|
||||
protected:
|
||||
protected:
|
||||
nsTArray<nsRefPtr<nsRangeStore> > mArray;
|
||||
bool mLock;
|
||||
};
|
||||
@@ -248,7 +248,7 @@ class MOZ_STACK_CLASS nsAutoRemoveContainerSelNotify
|
||||
{
|
||||
mRU.WillRemoveContainer();
|
||||
}
|
||||
|
||||
|
||||
~nsAutoRemoveContainerSelNotify()
|
||||
{
|
||||
mRU.DidRemoveContainer(mNode, mParent, mOffset, mNodeOrigLen);
|
||||
@@ -271,7 +271,7 @@ class MOZ_STACK_CLASS nsAutoInsertContainerSelNotify
|
||||
{
|
||||
mRU.WillInsertContainer();
|
||||
}
|
||||
|
||||
|
||||
~nsAutoInsertContainerSelNotify()
|
||||
{
|
||||
mRU.DidInsertContainer();
|
||||
@@ -294,9 +294,9 @@ class MOZ_STACK_CLASS nsAutoMoveNodeSelNotify
|
||||
int32_t mNewOffset;
|
||||
|
||||
public:
|
||||
nsAutoMoveNodeSelNotify(nsRangeUpdater &aRangeUpdater,
|
||||
nsAutoMoveNodeSelNotify(nsRangeUpdater &aRangeUpdater,
|
||||
nsINode* aOldParent,
|
||||
int32_t aOldOffset,
|
||||
int32_t aOldOffset,
|
||||
nsINode* aNewParent,
|
||||
int32_t aNewOffset)
|
||||
: mRU(aRangeUpdater)
|
||||
@@ -309,7 +309,7 @@ class MOZ_STACK_CLASS nsAutoMoveNodeSelNotify
|
||||
MOZ_ASSERT(aNewParent);
|
||||
mRU.WillMoveNode();
|
||||
}
|
||||
|
||||
|
||||
~nsAutoMoveNodeSelNotify()
|
||||
{
|
||||
mRU.DidMoveNode(mOldParent, mOldOffset, mNewParent, mNewOffset);
|
||||
|
||||
+210
-210
File diff suppressed because it is too large
Load Diff
@@ -53,7 +53,7 @@ using namespace mozilla::dom;
|
||||
|
||||
|
||||
/********************************************************
|
||||
* Constructor/Destructor
|
||||
* Constructor/Destructor
|
||||
********************************************************/
|
||||
|
||||
nsTextEditRules::nsTextEditRules()
|
||||
@@ -105,7 +105,7 @@ NS_IMPL_CYCLE_COLLECTING_ADDREF(nsTextEditRules)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsTextEditRules)
|
||||
|
||||
/********************************************************
|
||||
* Public methods
|
||||
* Public methods
|
||||
********************************************************/
|
||||
|
||||
NS_IMETHODIMP
|
||||
@@ -171,7 +171,7 @@ nsTextEditRules::BeforeEdit(EditAction action,
|
||||
nsIEditor::EDirection aDirection)
|
||||
{
|
||||
if (mLockRulesSniffing) return NS_OK;
|
||||
|
||||
|
||||
nsAutoLockRulesSniffing lockIt(this);
|
||||
mDidExplicitlySetInterline = false;
|
||||
if (!mActionNesting)
|
||||
@@ -180,7 +180,7 @@ nsTextEditRules::BeforeEdit(EditAction action,
|
||||
mTheAction = action;
|
||||
}
|
||||
mActionNesting++;
|
||||
|
||||
|
||||
// get the selection and cache the position before editing
|
||||
NS_ENSURE_STATE(mEditor);
|
||||
nsRefPtr<Selection> selection = mEditor->GetSelection();
|
||||
@@ -198,9 +198,9 @@ nsTextEditRules::AfterEdit(EditAction action,
|
||||
nsIEditor::EDirection aDirection)
|
||||
{
|
||||
if (mLockRulesSniffing) return NS_OK;
|
||||
|
||||
|
||||
nsAutoLockRulesSniffing lockIt(this);
|
||||
|
||||
|
||||
NS_PRECONDITION(mActionNesting>0, "bad action nesting!");
|
||||
nsresult res = NS_OK;
|
||||
if (!--mActionNesting)
|
||||
@@ -208,7 +208,7 @@ nsTextEditRules::AfterEdit(EditAction action,
|
||||
NS_ENSURE_STATE(mEditor);
|
||||
nsRefPtr<Selection> selection = mEditor->GetSelection();
|
||||
NS_ENSURE_STATE(selection);
|
||||
|
||||
|
||||
NS_ENSURE_STATE(mEditor);
|
||||
res = mEditor->HandleInlineSpellCheck(action, selection,
|
||||
mCachedSelectionNode, mCachedSelectionOffset,
|
||||
@@ -223,7 +223,7 @@ nsTextEditRules::AfterEdit(EditAction action,
|
||||
// detect empty doc
|
||||
res = CreateBogusNodeIfNeeded(selection);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
|
||||
// ensure trailing br node
|
||||
res = CreateTrailingBRIfNeeded();
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
@@ -252,9 +252,11 @@ nsTextEditRules::WillDoAction(Selection* aSelection,
|
||||
|
||||
switch (info->action) {
|
||||
case EditAction::insertBreak:
|
||||
UndefineCaretBidiLevel(aSelection);
|
||||
return WillInsertBreak(aSelection, aCancel, aHandled, info->maxLength);
|
||||
case EditAction::insertText:
|
||||
case EditAction::insertIMEText:
|
||||
UndefineCaretBidiLevel(aSelection);
|
||||
return WillInsertText(info->action, aSelection, aCancel, aHandled,
|
||||
info->inString, info->outString, info->maxLength);
|
||||
case EditAction::deleteSelection:
|
||||
@@ -280,7 +282,7 @@ nsTextEditRules::WillDoAction(Selection* aSelection,
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsTextEditRules::DidDoAction(Selection* aSelection,
|
||||
nsRulesInfo *aInfo, nsresult aResult)
|
||||
{
|
||||
@@ -290,7 +292,7 @@ nsTextEditRules::DidDoAction(Selection* aSelection,
|
||||
nsAutoTxnsConserveSelection dontSpazMySelection(mEditor);
|
||||
|
||||
NS_ENSURE_TRUE(aSelection && aInfo, NS_ERROR_NULL_POINTER);
|
||||
|
||||
|
||||
// my kingdom for dynamic cast
|
||||
nsTextRulesInfo *info = static_cast<nsTextRulesInfo*>(aInfo);
|
||||
|
||||
@@ -324,13 +326,13 @@ NS_IMETHODIMP
|
||||
nsTextEditRules::DocumentIsEmpty(bool *aDocumentIsEmpty)
|
||||
{
|
||||
NS_ENSURE_TRUE(aDocumentIsEmpty, NS_ERROR_NULL_POINTER);
|
||||
|
||||
|
||||
*aDocumentIsEmpty = (mBogusNode != nullptr);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/********************************************************
|
||||
* Protected methods
|
||||
* Protected methods
|
||||
********************************************************/
|
||||
|
||||
|
||||
@@ -338,12 +340,12 @@ nsresult
|
||||
nsTextEditRules::WillInsert(Selection* aSelection, bool* aCancel)
|
||||
{
|
||||
NS_ENSURE_TRUE(aSelection && aCancel, NS_ERROR_NULL_POINTER);
|
||||
|
||||
|
||||
CANCEL_OPERATION_IF_READONLY_OR_DISABLED
|
||||
|
||||
// initialize out param
|
||||
*aCancel = false;
|
||||
|
||||
|
||||
// check for the magic content node and delete it if it exists
|
||||
if (mBogusNode)
|
||||
{
|
||||
@@ -373,7 +375,7 @@ nsTextEditRules::WillInsertBreak(Selection* aSelection,
|
||||
if (IsSingleLineEditor()) {
|
||||
*aCancel = true;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
// handle docs with a max length
|
||||
// NOTE, this function copies inString into outString for us.
|
||||
@@ -406,7 +408,7 @@ nsTextEditRules::WillInsertBreak(Selection* aSelection,
|
||||
// initialize out param
|
||||
// we want to ignore result of WillInsert()
|
||||
*aCancel = false;
|
||||
|
||||
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -422,7 +424,7 @@ nsTextEditRules::CollapseSelectionToTrailingBRIfNeeded(Selection* aSelection)
|
||||
{
|
||||
// we only need to execute the stuff below if we are a plaintext editor.
|
||||
// html editors have a different mechanism for putting in mozBR's
|
||||
// (because there are a bunch more places you have to worry about it in html)
|
||||
// (because there are a bunch more places you have to worry about it in html)
|
||||
if (!IsPlaintextEditor()) {
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -579,20 +581,20 @@ nsTextEditRules::WillInsertText(EditAction aAction,
|
||||
const nsAString *inString,
|
||||
nsAString *outString,
|
||||
int32_t aMaxLength)
|
||||
{
|
||||
{
|
||||
if (!aSelection || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; }
|
||||
|
||||
if (inString->IsEmpty() && aAction != EditAction::insertIMEText) {
|
||||
// HACK: this is a fix for bug 19395
|
||||
// I can't outlaw all empty insertions
|
||||
// because IME transaction depend on them
|
||||
// There is more work to do to make the
|
||||
// There is more work to do to make the
|
||||
// world safe for IME.
|
||||
*aCancel = true;
|
||||
*aHandled = false;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
// initialize out param
|
||||
*aCancel = false;
|
||||
*aHandled = true;
|
||||
@@ -610,7 +612,7 @@ nsTextEditRules::WillInsertText(EditAction aAction,
|
||||
*aCancel = true;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
int32_t start = 0;
|
||||
int32_t end = 0;
|
||||
|
||||
@@ -637,7 +639,7 @@ nsTextEditRules::WillInsertText(EditAction aAction,
|
||||
// initialize out param
|
||||
// we want to ignore result of WillInsert()
|
||||
*aCancel = false;
|
||||
|
||||
|
||||
// handle password field data
|
||||
// this has the side effect of changing all the characters in aOutString
|
||||
// to the replacement character
|
||||
@@ -688,8 +690,8 @@ nsTextEditRules::WillInsertText(EditAction aAction,
|
||||
}
|
||||
mTimer->InitWithCallback(this, LookAndFeel::GetPasswordMaskDelay(),
|
||||
nsITimer::TYPE_ONE_SHOT);
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
FillBufWithPWChars(outString, outString->Length());
|
||||
}
|
||||
@@ -712,7 +714,7 @@ nsTextEditRules::WillInsertText(EditAction aAction,
|
||||
NS_ENSURE_STATE(mEditor);
|
||||
nsCOMPtr<nsIDocument> doc = mEditor->GetDocument();
|
||||
NS_ENSURE_TRUE(doc, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
|
||||
if (aAction == EditAction::insertIMEText) {
|
||||
NS_ENSURE_STATE(mEditor);
|
||||
res = mEditor->InsertTextImpl(*outString, address_of(selNode), &selOffset, doc);
|
||||
@@ -730,9 +732,9 @@ nsTextEditRules::WillInsertText(EditAction aAction,
|
||||
&curOffset, doc);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
if (curNode)
|
||||
if (curNode)
|
||||
{
|
||||
// Make the caret attach to the inserted text, unless this text ends with a LF,
|
||||
// Make the caret attach to the inserted text, unless this text ends with a LF,
|
||||
// in which case make the caret attach to the next line.
|
||||
bool endsWithLF =
|
||||
!outString->IsEmpty() && outString->Last() == nsCRT::LF;
|
||||
@@ -757,7 +759,7 @@ nsresult
|
||||
nsTextEditRules::WillSetTextProperty(Selection* aSelection, bool* aCancel,
|
||||
bool* aHandled)
|
||||
{
|
||||
if (!aSelection || !aCancel || !aHandled)
|
||||
if (!aSelection || !aCancel || !aHandled)
|
||||
{ return NS_ERROR_NULL_POINTER; }
|
||||
|
||||
// XXX: should probably return a success value other than NS_OK that means "not allowed"
|
||||
@@ -777,7 +779,7 @@ nsresult
|
||||
nsTextEditRules::WillRemoveTextProperty(Selection* aSelection, bool* aCancel,
|
||||
bool* aHandled)
|
||||
{
|
||||
if (!aSelection || !aCancel || !aHandled)
|
||||
if (!aSelection || !aCancel || !aHandled)
|
||||
{ return NS_ERROR_NULL_POINTER; }
|
||||
|
||||
// XXX: should probably return a success value other than NS_OK that means "not allowed"
|
||||
@@ -795,7 +797,7 @@ nsTextEditRules::DidRemoveTextProperty(Selection* aSelection, nsresult aResult)
|
||||
|
||||
nsresult
|
||||
nsTextEditRules::WillDeleteSelection(Selection* aSelection,
|
||||
nsIEditor::EDirection aCollapsedAction,
|
||||
nsIEditor::EDirection aCollapsedAction,
|
||||
bool *aCancel,
|
||||
bool *aHandled)
|
||||
{
|
||||
@@ -805,7 +807,7 @@ nsTextEditRules::WillDeleteSelection(Selection* aSelection,
|
||||
// initialize out param
|
||||
*aCancel = false;
|
||||
*aHandled = false;
|
||||
|
||||
|
||||
// if there is only bogus content, cancel the operation
|
||||
if (mBogusNode) {
|
||||
*aCancel = true;
|
||||
@@ -866,11 +868,11 @@ nsTextEditRules::WillDeleteSelection(Selection* aSelection,
|
||||
res = mEditor->GetStartNodeAndOffset(aSelection, getter_AddRefs(startNode), &startOffset);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
NS_ENSURE_TRUE(startNode, NS_ERROR_FAILURE);
|
||||
|
||||
|
||||
bool bCollapsed;
|
||||
res = aSelection->GetIsCollapsed(&bCollapsed);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
|
||||
if (!bCollapsed)
|
||||
return NS_OK;
|
||||
|
||||
@@ -894,8 +896,8 @@ nsTextEditRules::WillDeleteSelection(Selection* aSelection,
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsTextEditRules::DidDeleteSelection(Selection* aSelection,
|
||||
nsIEditor::EDirection aCollapsedAction,
|
||||
nsTextEditRules::DidDeleteSelection(Selection* aSelection,
|
||||
nsIEditor::EDirection aCollapsedAction,
|
||||
nsresult aResult)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> startNode;
|
||||
@@ -904,7 +906,7 @@ nsTextEditRules::DidDeleteSelection(Selection* aSelection,
|
||||
nsresult res = mEditor->GetStartNodeAndOffset(aSelection, getter_AddRefs(startNode), &startOffset);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
NS_ENSURE_TRUE(startNode, NS_ERROR_FAILURE);
|
||||
|
||||
|
||||
// delete empty text nodes at selection
|
||||
if (mEditor->IsTextNode(startNode))
|
||||
{
|
||||
@@ -912,7 +914,7 @@ nsTextEditRules::DidDeleteSelection(Selection* aSelection,
|
||||
uint32_t strLength;
|
||||
res = textNode->GetLength(&strLength);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
|
||||
// are we in an empty text node?
|
||||
if (!strLength)
|
||||
{
|
||||
@@ -980,12 +982,12 @@ nsTextEditRules::DidRedo(Selection* aSelection, nsresult aResult)
|
||||
{
|
||||
nsresult res = aResult; // if aResult is an error, we return it.
|
||||
if (!aSelection) { return NS_ERROR_NULL_POINTER; }
|
||||
if (NS_SUCCEEDED(res))
|
||||
if (NS_SUCCEEDED(res))
|
||||
{
|
||||
NS_ENSURE_STATE(mEditor);
|
||||
nsCOMPtr<nsIDOMElement> theRoot = do_QueryInterface(mEditor->GetRoot());
|
||||
NS_ENSURE_TRUE(theRoot, NS_ERROR_FAILURE);
|
||||
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLCollection> nodeList;
|
||||
res = theRoot->GetElementsByTagName(NS_LITERAL_STRING("br"),
|
||||
getter_AddRefs(nodeList));
|
||||
@@ -994,11 +996,11 @@ nsTextEditRules::DidRedo(Selection* aSelection, nsresult aResult)
|
||||
{
|
||||
uint32_t len;
|
||||
nodeList->GetLength(&len);
|
||||
|
||||
|
||||
if (len != 1) {
|
||||
// only in the case of one br could there be the bogus node
|
||||
mBogusNode = nullptr;
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
@@ -1018,12 +1020,12 @@ nsTextEditRules::DidRedo(Selection* aSelection, nsresult aResult)
|
||||
nsresult
|
||||
nsTextEditRules::WillOutputText(Selection* aSelection,
|
||||
const nsAString *aOutputFormat,
|
||||
nsAString *aOutString,
|
||||
nsAString *aOutString,
|
||||
bool *aCancel,
|
||||
bool *aHandled)
|
||||
{
|
||||
// null selection ok
|
||||
if (!aOutString || !aOutputFormat || !aCancel || !aHandled)
|
||||
if (!aOutString || !aOutputFormat || !aCancel || !aHandled)
|
||||
{ return NS_ERROR_NULL_POINTER; }
|
||||
|
||||
// initialize out param
|
||||
@@ -1204,7 +1206,7 @@ nsTextEditRules::TruncateInsertionIfNeeded(Selection* aSelection,
|
||||
bool *aTruncated)
|
||||
{
|
||||
if (!aSelection || !aInString || !aOutString) {return NS_ERROR_NULL_POINTER;}
|
||||
|
||||
|
||||
nsresult res = NS_OK;
|
||||
if (!aOutString->Assign(*aInString, mozilla::fallible)) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
@@ -1212,7 +1214,7 @@ nsTextEditRules::TruncateInsertionIfNeeded(Selection* aSelection,
|
||||
if (aTruncated) {
|
||||
*aTruncated = false;
|
||||
}
|
||||
|
||||
|
||||
NS_ENSURE_STATE(mEditor);
|
||||
if ((-1 != aMaxLength) && IsPlaintextEditor() && !mEditor->IsIMEComposing() )
|
||||
{
|
||||
@@ -1220,13 +1222,13 @@ nsTextEditRules::TruncateInsertionIfNeeded(Selection* aSelection,
|
||||
// Get the length of inString.
|
||||
// Get the length of the selection.
|
||||
// If selection is collapsed, it is length 0.
|
||||
// Subtract the length of the selection from the len(doc)
|
||||
// Subtract the length of the selection from the len(doc)
|
||||
// since we'll delete the selection on insert.
|
||||
// This is resultingDocLength.
|
||||
// Get old length of IME composing string
|
||||
// which will be replaced by new one.
|
||||
// If (resultingDocLength) is at or over max, cancel the insert
|
||||
// If (resultingDocLength) + (length of input) > max,
|
||||
// If (resultingDocLength) + (length of input) > max,
|
||||
// set aOutString to subset of inString so length = max
|
||||
int32_t docLength;
|
||||
res = mEditor->GetTextLength(&docLength);
|
||||
@@ -1331,10 +1333,10 @@ nsresult nsTextEditRules::HideLastPWInput() {
|
||||
|
||||
nsCOMPtr<nsIDOMNode> selNode = GetTextNode(selection, mEditor);
|
||||
NS_ENSURE_TRUE(selNode, NS_OK);
|
||||
|
||||
|
||||
nsCOMPtr<nsIDOMCharacterData> nodeAsText(do_QueryInterface(selNode));
|
||||
NS_ENSURE_TRUE(nodeAsText, NS_OK);
|
||||
|
||||
|
||||
nodeAsText->ReplaceData(mLastStart, mLastLength, hiddenText);
|
||||
selection->Collapse(selNode, start);
|
||||
if (start != end)
|
||||
@@ -1360,8 +1362,8 @@ nsTextEditRules::FillBufWithPWChars(nsAString *aOutString, int32_t aLength)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// CreateMozBR: put a BR node with moz attribute at {aNode, aOffset}
|
||||
//
|
||||
nsresult
|
||||
//
|
||||
nsresult
|
||||
nsTextEditRules::CreateMozBR(nsIDOMNode* inParent, int32_t inOffset,
|
||||
nsIDOMNode** outBRNode)
|
||||
{
|
||||
|
||||
@@ -26,14 +26,14 @@ class Selection;
|
||||
} // namespace mozilla
|
||||
|
||||
/** Object that encapsulates HTML text-specific editing rules.
|
||||
*
|
||||
*
|
||||
* To be a good citizen, edit rules must live by these restrictions:
|
||||
* 1. All data manipulation is through the editor.
|
||||
* 1. All data manipulation is through the editor.
|
||||
* Content nodes in the document tree must <B>not</B> be manipulated directly.
|
||||
* Content nodes in document fragments that are not part of the document itself
|
||||
* may be manipulated at will. Operations on document fragments must <B>not</B>
|
||||
* go through the editor.
|
||||
* 2. Selection must not be explicitly set by the rule method.
|
||||
* 2. Selection must not be explicitly set by the rule method.
|
||||
* Any manipulation of Selection must be done by the editor.
|
||||
*/
|
||||
class nsTextEditRules : public nsIEditRules, public nsITimerCallback
|
||||
@@ -127,11 +127,11 @@ protected:
|
||||
nsresult DidInsert(mozilla::dom::Selection* aSelection, nsresult aResult);
|
||||
|
||||
nsresult WillDeleteSelection(mozilla::dom::Selection* aSelection,
|
||||
nsIEditor::EDirection aCollapsedAction,
|
||||
nsIEditor::EDirection aCollapsedAction,
|
||||
bool *aCancel,
|
||||
bool *aHandled);
|
||||
nsresult DidDeleteSelection(mozilla::dom::Selection* aSelection,
|
||||
nsIEditor::EDirection aCollapsedAction,
|
||||
nsIEditor::EDirection aCollapsedAction,
|
||||
nsresult aResult);
|
||||
|
||||
nsresult WillSetTextProperty(mozilla::dom::Selection* aSelection,
|
||||
@@ -161,8 +161,8 @@ protected:
|
||||
*/
|
||||
nsresult WillOutputText(mozilla::dom::Selection* aSelection,
|
||||
const nsAString *aInFormat,
|
||||
nsAString *aOutText,
|
||||
bool *aOutCancel,
|
||||
nsAString *aOutText,
|
||||
bool *aOutCancel,
|
||||
bool *aHandled);
|
||||
|
||||
nsresult DidOutputText(mozilla::dom::Selection* aSelection, nsresult aResult);
|
||||
@@ -172,10 +172,10 @@ protected:
|
||||
|
||||
/** check for and replace a redundant trailing break */
|
||||
nsresult RemoveRedundantTrailingBR();
|
||||
|
||||
|
||||
/** creates a trailing break in the text doc if there is not one already */
|
||||
nsresult CreateTrailingBRIfNeeded();
|
||||
|
||||
|
||||
/** creates a bogus text node if the document has no editable content */
|
||||
nsresult CreateBogusNodeIfNeeded(mozilla::dom::Selection* aSelection);
|
||||
|
||||
@@ -193,9 +193,11 @@ protected:
|
||||
nsresult CreateMozBR(nsIDOMNode* inParent, int32_t inOffset,
|
||||
nsIDOMNode** outBRNode = nullptr);
|
||||
|
||||
void UndefineCaretBidiLevel(mozilla::dom::Selection* aSelection);
|
||||
|
||||
nsresult CheckBidiLevelForDeletion(mozilla::dom::Selection* aSelection,
|
||||
nsIDOMNode *aSelNode,
|
||||
int32_t aSelOffset,
|
||||
nsIDOMNode *aSelNode,
|
||||
int32_t aSelOffset,
|
||||
nsIEditor::EDirection aAction,
|
||||
bool *aCancel);
|
||||
|
||||
@@ -244,7 +246,7 @@ protected:
|
||||
bool mLockRulesSniffing;
|
||||
bool mDidExplicitlySetInterline;
|
||||
bool mDeleteBidiImmediately; // in bidirectional text, delete
|
||||
// characters not visually
|
||||
// characters not visually
|
||||
// adjacent to the caret without
|
||||
// moving the caret first.
|
||||
EditAction mTheAction; // the top level editor action
|
||||
@@ -261,7 +263,7 @@ protected:
|
||||
class nsTextRulesInfo : public nsRulesInfo
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
explicit nsTextRulesInfo(EditAction aAction) :
|
||||
nsRulesInfo(aAction),
|
||||
inString(0),
|
||||
@@ -279,17 +281,17 @@ class nsTextRulesInfo : public nsRulesInfo
|
||||
{}
|
||||
|
||||
virtual ~nsTextRulesInfo() {}
|
||||
|
||||
|
||||
// kInsertText
|
||||
const nsAString *inString;
|
||||
nsAString *outString;
|
||||
const nsAString *outputFormat;
|
||||
int32_t maxLength;
|
||||
|
||||
|
||||
// kDeleteSelection
|
||||
nsIEditor::EDirection collapsedAction;
|
||||
nsIEditor::EStripWrappers stripWrappers;
|
||||
|
||||
|
||||
// kMakeList
|
||||
bool bOrdered;
|
||||
bool entireList;
|
||||
@@ -297,10 +299,10 @@ class nsTextRulesInfo : public nsRulesInfo
|
||||
|
||||
// kAlign
|
||||
const nsAString *alignType;
|
||||
|
||||
|
||||
// kMakeBasicBlock
|
||||
const nsAString *blockType;
|
||||
|
||||
|
||||
// kInsertElement
|
||||
const nsIDOMElement* insertElement;
|
||||
};
|
||||
@@ -309,17 +311,17 @@ class nsTextRulesInfo : public nsRulesInfo
|
||||
/***************************************************************************
|
||||
* stack based helper class for StartOperation()/EndOperation() sandwich.
|
||||
* this class sets a bool letting us know to ignore any rules sniffing
|
||||
* that tries to occur reentrantly.
|
||||
* that tries to occur reentrantly.
|
||||
*/
|
||||
class nsAutoLockRulesSniffing
|
||||
{
|
||||
public:
|
||||
|
||||
explicit nsAutoLockRulesSniffing(nsTextEditRules *rules) : mRules(rules)
|
||||
|
||||
explicit nsAutoLockRulesSniffing(nsTextEditRules *rules) : mRules(rules)
|
||||
{if (mRules) mRules->mLockRulesSniffing = true;}
|
||||
~nsAutoLockRulesSniffing()
|
||||
~nsAutoLockRulesSniffing()
|
||||
{if (mRules) mRules->mLockRulesSniffing = false;}
|
||||
|
||||
|
||||
protected:
|
||||
nsTextEditRules *mRules;
|
||||
};
|
||||
@@ -332,12 +334,12 @@ class nsAutoLockRulesSniffing
|
||||
class nsAutoLockListener
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
explicit nsAutoLockListener(bool *enabled) : mEnabled(enabled)
|
||||
{if (mEnabled) { mOldState=*mEnabled; *mEnabled = false;}}
|
||||
~nsAutoLockListener()
|
||||
~nsAutoLockListener()
|
||||
{if (mEnabled) *mEnabled = mOldState;}
|
||||
|
||||
|
||||
protected:
|
||||
bool *mEnabled;
|
||||
bool mOldState;
|
||||
|
||||
@@ -25,8 +25,8 @@ using namespace mozilla::dom;
|
||||
// Test for distance between caret and text that will be deleted
|
||||
nsresult
|
||||
nsTextEditRules::CheckBidiLevelForDeletion(Selection* aSelection,
|
||||
nsIDOMNode *aSelNode,
|
||||
int32_t aSelOffset,
|
||||
nsIDOMNode *aSelNode,
|
||||
int32_t aSelOffset,
|
||||
nsIEditor::EDirection aAction,
|
||||
bool *aCancel)
|
||||
{
|
||||
@@ -35,13 +35,13 @@ nsTextEditRules::CheckBidiLevelForDeletion(Selection* aSelection,
|
||||
|
||||
nsCOMPtr<nsIPresShell> shell = mEditor->GetPresShell();
|
||||
NS_ENSURE_TRUE(shell, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
|
||||
nsPresContext *context = shell->GetPresContext();
|
||||
NS_ENSURE_TRUE(context, NS_ERROR_NULL_POINTER);
|
||||
|
||||
|
||||
if (!context->BidiEnabled())
|
||||
return NS_OK;
|
||||
|
||||
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(aSelNode);
|
||||
NS_ENSURE_TRUE(content, NS_ERROR_NULL_POINTER);
|
||||
|
||||
@@ -50,10 +50,10 @@ nsTextEditRules::CheckBidiLevelForDeletion(Selection* aSelection,
|
||||
nsRefPtr<nsFrameSelection> frameSelection =
|
||||
static_cast<Selection*>(aSelection)->GetFrameSelection();
|
||||
NS_ENSURE_TRUE(frameSelection, NS_ERROR_NULL_POINTER);
|
||||
|
||||
|
||||
nsPrevNextBidiLevels levels = frameSelection->
|
||||
GetPrevNextBidiLevels(content, aSelOffset, true);
|
||||
|
||||
|
||||
levelBefore = levels.mLevelBefore;
|
||||
levelAfter = levels.mLevelAfter;
|
||||
|
||||
@@ -80,3 +80,19 @@ nsTextEditRules::CheckBidiLevelForDeletion(Selection* aSelection,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsTextEditRules::UndefineCaretBidiLevel(Selection* aSelection)
|
||||
{
|
||||
/**
|
||||
* After inserting text the caret Bidi level must be set to the level of the
|
||||
* inserted text.This is difficult, because we cannot know what the level is
|
||||
* until after the Bidi algorithm is applied to the whole paragraph.
|
||||
*
|
||||
* So we set the caret Bidi level to UNDEFINED here, and the caret code will
|
||||
* set it correctly later
|
||||
*/
|
||||
nsRefPtr<nsFrameSelection> frameSelection = aSelection->GetFrameSelection();
|
||||
if (frameSelection) {
|
||||
frameSelection->UndefineCaretBidiLevel();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ using namespace mozilla;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// IsBody: true if node an html body node
|
||||
bool
|
||||
bool
|
||||
nsTextEditUtils::IsBody(nsIDOMNode *node)
|
||||
{
|
||||
return nsEditor::NodeIsType(node, nsGkAtoms::body);
|
||||
@@ -34,13 +34,13 @@ nsTextEditUtils::IsBody(nsIDOMNode *node)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// IsBreak: true if node an html break node
|
||||
bool
|
||||
bool
|
||||
nsTextEditUtils::IsBreak(nsIDOMNode *node)
|
||||
{
|
||||
return nsEditor::NodeIsType(node, nsGkAtoms::br);
|
||||
}
|
||||
|
||||
bool
|
||||
|
||||
bool
|
||||
nsTextEditUtils::IsBreak(nsINode* aNode)
|
||||
{
|
||||
MOZ_ASSERT(aNode);
|
||||
@@ -50,8 +50,8 @@ nsTextEditUtils::IsBreak(nsINode* aNode)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// IsMozBR: true if node an html br node with type = _moz
|
||||
//
|
||||
bool
|
||||
//
|
||||
bool
|
||||
nsTextEditUtils::IsMozBR(nsIDOMNode *node)
|
||||
{
|
||||
NS_PRECONDITION(node, "null node passed to nsHTMLEditUtils::IsMozBR");
|
||||
@@ -73,8 +73,8 @@ nsTextEditUtils::IsMozBR(nsINode* aNode)
|
||||
// HasMozAttr: true if node has type attribute = _moz
|
||||
// (used to indicate the div's and br's we use in
|
||||
// mail compose rules)
|
||||
//
|
||||
bool
|
||||
//
|
||||
bool
|
||||
nsTextEditUtils::HasMozAttr(nsIDOMNode *node)
|
||||
{
|
||||
NS_PRECONDITION(node, "null parent passed to nsHTMLEditUtils::HasMozAttr");
|
||||
|
||||
@@ -120,7 +120,7 @@ nsWSRunObject::ScrubBlockBoundary(nsHTMLEditor* aHTMLEd,
|
||||
NS_ENSURE_STATE(aOffset >= 0);
|
||||
offset = aOffset;
|
||||
}
|
||||
|
||||
|
||||
nsWSRunObject theWSObj(aHTMLEd, aBlock, offset);
|
||||
return theWSObj.Scrub();
|
||||
}
|
||||
@@ -573,7 +573,7 @@ nsWSRunObject::NextVisibleNode(nsINode* aNode,
|
||||
*outType = mEndReason;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsresult
|
||||
nsWSRunObject::AdjustWhitespace()
|
||||
{
|
||||
// this routine examines a run of ws and tries to get rid of some unneeded nbsp's,
|
||||
@@ -621,7 +621,7 @@ nsresult
|
||||
nsWSRunObject::GetWSNodes()
|
||||
{
|
||||
// collect up an array of nodes that are contiguous with the insertion point
|
||||
// and which contain only whitespace. Stop if you reach non-ws text or a new
|
||||
// and which contain only whitespace. Stop if you reach non-ws text or a new
|
||||
// block boundary.
|
||||
::DOMPoint start(mNode, mOffset), end(mNode, mOffset);
|
||||
nsCOMPtr<nsINode> wsBoundingParent = GetWSBoundingParent();
|
||||
@@ -629,7 +629,7 @@ nsWSRunObject::GetWSNodes()
|
||||
// first look backwards to find preceding ws nodes
|
||||
if (nsRefPtr<Text> textNode = mNode->GetAsText()) {
|
||||
const nsTextFragment* textFrag = textNode->GetText();
|
||||
|
||||
|
||||
mNodeArray.InsertElementAt(0, textNode);
|
||||
if (mOffset) {
|
||||
for (int32_t pos = mOffset - 1; pos >= 0; pos--) {
|
||||
@@ -729,9 +729,9 @@ nsWSRunObject::GetWSNodes()
|
||||
mStartOffset = start.offset;
|
||||
mStartReason = WSType::thisBlock;
|
||||
mStartReasonNode = wsBoundingParent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// then look ahead to find following ws nodes
|
||||
if (nsRefPtr<Text> textNode = mNode->GetAsText()) {
|
||||
// don't need to put it on list. it already is from code above
|
||||
@@ -819,8 +819,8 @@ nsWSRunObject::GetWSNodes()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// we encountered a break or a special node, like <img>,
|
||||
// that is not a block and not a break but still
|
||||
// we encountered a break or a special node, like <img>,
|
||||
// that is not a block and not a break but still
|
||||
// serves as a terminator to ws runs.
|
||||
mEndNode = end.node;
|
||||
mEndOffset = end.offset;
|
||||
@@ -837,7 +837,7 @@ nsWSRunObject::GetWSNodes()
|
||||
mEndOffset = end.offset;
|
||||
mEndReason = WSType::thisBlock;
|
||||
mEndReasonNode = wsBoundingParent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
@@ -847,7 +847,7 @@ void
|
||||
nsWSRunObject::GetRuns()
|
||||
{
|
||||
ClearRuns();
|
||||
|
||||
|
||||
// handle some easy cases first
|
||||
mHTMLEditor->IsPreformatted(GetAsDOMNode(mNode), &mPRE);
|
||||
// if it's preformatedd, or if we are surrounded by text or special, it's all one
|
||||
@@ -875,12 +875,12 @@ nsWSRunObject::GetRuns()
|
||||
MakeSingleWSRun(wstype);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// otherwise a little trickier. shucks.
|
||||
mStartRun = new WSFragment();
|
||||
mStartRun->mStartNode = mStartNode;
|
||||
mStartRun->mStartOffset = mStartOffset;
|
||||
|
||||
|
||||
if (mStartReason & WSType::block || mStartReason == WSType::br) {
|
||||
// set up mStartRun
|
||||
mStartRun->mType = WSType::leadingWS;
|
||||
@@ -888,7 +888,7 @@ nsWSRunObject::GetRuns()
|
||||
mStartRun->mEndOffset = mFirstNBSPOffset;
|
||||
mStartRun->mLeftType = mStartReason;
|
||||
mStartRun->mRightType = WSType::normalWS;
|
||||
|
||||
|
||||
// set up next run
|
||||
WSFragment *normalRun = new WSFragment();
|
||||
mStartRun->mRight = normalRun;
|
||||
@@ -923,7 +923,7 @@ nsWSRunObject::GetRuns()
|
||||
normalRun->mEndNode = mLastNBSPNode;
|
||||
normalRun->mEndOffset = mLastNBSPOffset+1;
|
||||
normalRun->mRightType = WSType::trailingWS;
|
||||
|
||||
|
||||
// set up next run
|
||||
WSFragment *lastRun = new WSFragment();
|
||||
lastRun->mType = WSType::trailingWS;
|
||||
@@ -1000,7 +1000,7 @@ nsWSRunObject::MakeSingleWSRun(WSType aType)
|
||||
mStartRun->mEndOffset = mEndOffset;
|
||||
mStartRun->mLeftType = mStartReason;
|
||||
mStartRun->mRightType = mEndReason;
|
||||
|
||||
|
||||
mEndRun = mStartRun;
|
||||
}
|
||||
|
||||
@@ -1171,24 +1171,24 @@ nsWSRunObject::GetNextWSNode(::DOMPoint aPoint, nsINode* aBlockParent)
|
||||
return nextNode;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsresult
|
||||
nsWSRunObject::PrepareToDeleteRangePriv(nsWSRunObject* aEndObject)
|
||||
{
|
||||
// this routine adjust whitespace before *this* and after aEndObject
|
||||
// in preperation for the two areas to become adjacent after the
|
||||
// in preperation for the two areas to become adjacent after the
|
||||
// intervening content is deleted. It's overly agressive right
|
||||
// now. There might be a block boundary remaining between them after
|
||||
// the deletion, in which case these adjstments are unneeded (though
|
||||
// I don't think they can ever be harmful?)
|
||||
|
||||
|
||||
NS_ENSURE_TRUE(aEndObject, NS_ERROR_NULL_POINTER);
|
||||
nsresult res = NS_OK;
|
||||
|
||||
|
||||
// get the runs before and after selection
|
||||
WSFragment *beforeRun, *afterRun;
|
||||
FindRun(mNode, mOffset, &beforeRun, false);
|
||||
aEndObject->FindRun(aEndObject->mNode, aEndObject->mOffset, &afterRun, true);
|
||||
|
||||
|
||||
// trim after run of any leading ws
|
||||
if (afterRun && (afterRun->mType & WSType::leadingWS)) {
|
||||
res = aEndObject->DeleteChars(aEndObject->mNode, aEndObject->mOffset,
|
||||
@@ -1239,19 +1239,19 @@ nsWSRunObject::PrepareToDeleteRangePriv(nsWSRunObject* aEndObject)
|
||||
return res;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsresult
|
||||
nsWSRunObject::PrepareToSplitAcrossBlocksPriv()
|
||||
{
|
||||
// used to prepare ws to be split across two blocks. The main issue
|
||||
// used to prepare ws to be split across two blocks. The main issue
|
||||
// here is make sure normalWS doesn't end up becoming non-significant
|
||||
// leading or trailing ws after the split.
|
||||
nsresult res = NS_OK;
|
||||
|
||||
|
||||
// get the runs before and after selection
|
||||
WSFragment *beforeRun, *afterRun;
|
||||
FindRun(mNode, mOffset, &beforeRun, false);
|
||||
FindRun(mNode, mOffset, &afterRun, true);
|
||||
|
||||
|
||||
// adjust normal ws in afterRun if needed
|
||||
if (afterRun && afterRun->mType == WSType::normalWS) {
|
||||
// make sure leading char of following ws is an nbsp, so that it will show up
|
||||
@@ -1609,7 +1609,7 @@ nsWSRunObject::FindRun(nsINode* aNode, int32_t aOffset, WSFragment** outRun,
|
||||
}
|
||||
}
|
||||
|
||||
char16_t
|
||||
char16_t
|
||||
nsWSRunObject::GetCharAt(Text* aTextNode, int32_t aOffset)
|
||||
{
|
||||
// return 0 if we can't get a char, for whatever reason
|
||||
@@ -1618,7 +1618,7 @@ nsWSRunObject::GetCharAt(Text* aTextNode, int32_t aOffset)
|
||||
int32_t len = int32_t(aTextNode->TextLength());
|
||||
if (aOffset < 0 || aOffset >= len)
|
||||
return 0;
|
||||
|
||||
|
||||
return aTextNode->GetText()->CharAt(aOffset);
|
||||
}
|
||||
|
||||
|
||||
@@ -154,16 +154,16 @@ class MOZ_STACK_CLASS nsWSRunObject
|
||||
nsWSRunObject(nsHTMLEditor* aEd, nsINode* aNode, int32_t aOffset);
|
||||
nsWSRunObject(nsHTMLEditor *aEd, nsIDOMNode *aNode, int32_t aOffset);
|
||||
~nsWSRunObject();
|
||||
|
||||
|
||||
// public methods ---------------------------------------------------------
|
||||
|
||||
// ScrubBlockBoundary removes any non-visible whitespace at the specified
|
||||
// location relative to a block node.
|
||||
// location relative to a block node.
|
||||
static nsresult ScrubBlockBoundary(nsHTMLEditor* aHTMLEd,
|
||||
BlockBoundary aBoundary,
|
||||
nsINode* aBlock,
|
||||
int32_t aOffset = -1);
|
||||
|
||||
|
||||
// PrepareToJoinBlocks fixes up ws at the end of aLeftBlock and the
|
||||
// beginning of aRightBlock in preperation for them to be joined. Example
|
||||
// of fixup: trailingws in aLeftBlock needs to be removed.
|
||||
@@ -174,7 +174,7 @@ class MOZ_STACK_CLASS nsWSRunObject
|
||||
// PrepareToDeleteRange fixes up ws before {aStartNode,aStartOffset}
|
||||
// and after {aEndNode,aEndOffset} in preperation for content
|
||||
// in that range to be deleted. Note that the nodes and offsets
|
||||
// are adjusted in response to any dom changes we make while
|
||||
// are adjusted in response to any dom changes we make while
|
||||
// adjusting ws.
|
||||
// example of fixup: trailingws before {aStartNode,aStartOffset}
|
||||
// needs to be removed.
|
||||
@@ -251,7 +251,7 @@ class MOZ_STACK_CLASS nsWSRunObject
|
||||
nsresult AdjustWhitespace();
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
// WSFragment struct ---------------------------------------------------------
|
||||
// WSFragment represents a single run of ws (all leadingws, or all normalws,
|
||||
// or all trailingws, or all leading+trailingws). Note that this single run may
|
||||
@@ -274,11 +274,11 @@ class MOZ_STACK_CLASS nsWSRunObject
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// WSPoint struct ------------------------------------------------------------
|
||||
// A WSPoint struct represents a unique location within the ws run. It is
|
||||
// A WSPoint struct represents a unique location within the ws run. It is
|
||||
// always within a textnode that is one of the nodes stored in the list
|
||||
// in the wsRunObject. For convenience, the character at that point is also
|
||||
// in the wsRunObject. For convenience, the character at that point is also
|
||||
// stored in the struct.
|
||||
struct MOZ_STACK_CLASS WSPoint
|
||||
{
|
||||
@@ -289,15 +289,15 @@ class MOZ_STACK_CLASS nsWSRunObject
|
||||
WSPoint() : mTextNode(0),mOffset(0),mChar(0) {}
|
||||
WSPoint(mozilla::dom::Text* aTextNode, int32_t aOffset, char16_t aChar) :
|
||||
mTextNode(aTextNode),mOffset(aOffset),mChar(aChar) {}
|
||||
};
|
||||
};
|
||||
|
||||
enum AreaRestriction
|
||||
{
|
||||
eAnywhere, eOutsideUserSelectAll
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
// protected methods ---------------------------------------------------------
|
||||
// tons of utility methods.
|
||||
// tons of utility methods.
|
||||
|
||||
/**
|
||||
* Return the node which we will handle white-space under. This is the
|
||||
@@ -341,40 +341,40 @@ class MOZ_STACK_CLASS nsWSRunObject
|
||||
int32_t aOffset);
|
||||
nsresult CheckLeadingNBSP(WSFragment* aRun, nsINode* aNode,
|
||||
int32_t aOffset);
|
||||
|
||||
|
||||
nsresult Scrub();
|
||||
|
||||
|
||||
// member variables ---------------------------------------------------------
|
||||
|
||||
|
||||
nsCOMPtr<nsINode> mNode; // the node passed to our constructor
|
||||
int32_t mOffset; // the offset passed to our contructor
|
||||
// together, the above represent the point at which we are building up ws info.
|
||||
|
||||
|
||||
bool mPRE; // true if we are in preformatted whitespace context
|
||||
nsCOMPtr<nsINode> mStartNode; // node/offset where ws starts
|
||||
int32_t mStartOffset; // ...
|
||||
WSType mStartReason; // reason why ws starts (eText, eOtherBlock, etc)
|
||||
nsCOMPtr<nsINode> mStartReasonNode;// the node that implicated by start reason
|
||||
|
||||
|
||||
nsCOMPtr<nsINode> mEndNode; // node/offset where ws ends
|
||||
int32_t mEndOffset; // ...
|
||||
WSType mEndReason; // reason why ws ends (eText, eOtherBlock, etc)
|
||||
nsCOMPtr<nsINode> mEndReasonNode; // the node that implicated by end reason
|
||||
|
||||
|
||||
nsRefPtr<mozilla::dom::Text> mFirstNBSPNode; // location of first nbsp in ws run, if any
|
||||
int32_t mFirstNBSPOffset; // ...
|
||||
|
||||
|
||||
nsRefPtr<mozilla::dom::Text> mLastNBSPNode; // location of last nbsp in ws run, if any
|
||||
int32_t mLastNBSPOffset; // ...
|
||||
|
||||
|
||||
// the list of nodes containing ws in this run
|
||||
nsTArray<nsRefPtr<mozilla::dom::Text>> mNodeArray;
|
||||
|
||||
|
||||
WSFragment *mStartRun; // the first WSFragment in the run
|
||||
WSFragment *mEndRun; // the last WSFragment in the run, may be same as first
|
||||
|
||||
|
||||
nsHTMLEditor *mHTMLEditor; // non-owning.
|
||||
|
||||
|
||||
friend class nsHTMLEditRules; // opening this class up for pillaging
|
||||
friend class nsHTMLEditor; // opening this class up for more pillaging
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "domstubs.idl"
|
||||
|
||||
@@ -34,10 +34,10 @@ interface nsIContentFilter : nsISupports
|
||||
* Callers who want to allow insertion of the data with no changes
|
||||
* can simply set continueWithInsertion to PR_TRUE and return.
|
||||
*
|
||||
* Callers who want to modify the content (docFragment) being inserted are
|
||||
* responsible for updating contentStartNode, contentStartOffset,
|
||||
* contentEndNode, and contentEndOffset (if necessary).
|
||||
* Callers are responsible for freeing and addref'ing if they want to
|
||||
* Callers who want to modify the content (docFragment) being inserted are
|
||||
* responsible for updating contentStartNode, contentStartOffset,
|
||||
* contentEndNode, and contentEndOffset (if necessary).
|
||||
* Callers are responsible for freeing and addref'ing if they want to
|
||||
* completely replace any of the DOM nodes passed in.
|
||||
*
|
||||
* The location where insertion will occur should be considered an
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[scriptable, uuid(050cdc00-3b8e-11d3-9ce4-a458f454fcbc)]
|
||||
|
||||
@@ -15,7 +15,7 @@ Editor Action Listener interface to outside world
|
||||
|
||||
|
||||
/**
|
||||
* A generic editor action listener interface.
|
||||
* A generic editor action listener interface.
|
||||
* <P>
|
||||
* nsIEditActionListener is the interface used by applications wishing to be notified
|
||||
* when the editor modifies the DOM tree.
|
||||
@@ -28,7 +28,7 @@ Editor Action Listener interface to outside world
|
||||
|
||||
interface nsIEditActionListener : nsISupports{
|
||||
|
||||
/**
|
||||
/**
|
||||
* Called before the editor creates a node.
|
||||
* @param aTag The tag name of the DOM Node to create.
|
||||
* @param aParent The node to insert the new object into
|
||||
@@ -40,7 +40,7 @@ interface nsIEditActionListener : nsISupports{
|
||||
in nsIDOMNode aParent,
|
||||
in long aPosition);
|
||||
|
||||
/**
|
||||
/**
|
||||
* Called after the editor creates a node.
|
||||
* @param aTag The tag name of the DOM Node to create.
|
||||
* @param aNode The DOM Node that was created.
|
||||
@@ -56,7 +56,7 @@ interface nsIEditActionListener : nsISupports{
|
||||
in long aPosition,
|
||||
in nsresult aResult);
|
||||
|
||||
/**
|
||||
/**
|
||||
* Called before the editor inserts a node.
|
||||
* @param aNode The DOM Node to insert.
|
||||
* @param aParent The node to insert the new object into
|
||||
@@ -68,7 +68,7 @@ interface nsIEditActionListener : nsISupports{
|
||||
in nsIDOMNode aParent,
|
||||
in long aPosition);
|
||||
|
||||
/**
|
||||
/**
|
||||
* Called after the editor inserts a node.
|
||||
* @param aNode The DOM Node to insert.
|
||||
* @param aParent The node to insert the new object into
|
||||
@@ -82,20 +82,20 @@ interface nsIEditActionListener : nsISupports{
|
||||
in long aPosition,
|
||||
in nsresult aResult);
|
||||
|
||||
/**
|
||||
/**
|
||||
* Called before the editor deletes a node.
|
||||
* @param aChild The node to delete
|
||||
*/
|
||||
void WillDeleteNode(in nsIDOMNode aChild);
|
||||
|
||||
/**
|
||||
/**
|
||||
* Called after the editor deletes a node.
|
||||
* @param aChild The node to delete
|
||||
* @param aResult The result of the delete node operation.
|
||||
*/
|
||||
void DidDeleteNode(in nsIDOMNode aChild, in nsresult aResult);
|
||||
|
||||
/**
|
||||
/**
|
||||
* Called before the editor splits a node.
|
||||
* @param aExistingRightNode the node to split. It will become the new node's next sibling.
|
||||
* @param aOffset the offset of aExistingRightNode's content|children to do the split at
|
||||
@@ -104,7 +104,7 @@ interface nsIEditActionListener : nsISupports{
|
||||
void WillSplitNode(in nsIDOMNode aExistingRightNode,
|
||||
in long aOffset);
|
||||
|
||||
/**
|
||||
/**
|
||||
* Called after the editor splits a node.
|
||||
* @param aExistingRightNode the node to split. It will become the new node's next sibling.
|
||||
* @param aOffset the offset of aExistingRightNode's content|children to do the split at
|
||||
@@ -115,7 +115,7 @@ interface nsIEditActionListener : nsISupports{
|
||||
in nsIDOMNode aNewLeftNode,
|
||||
in nsresult aResult);
|
||||
|
||||
/**
|
||||
/**
|
||||
* Called before the editor joins 2 nodes.
|
||||
* @param aLeftNode This node will be merged into the right node
|
||||
* @param aRightNode The node that will be merged into.
|
||||
@@ -127,7 +127,7 @@ interface nsIEditActionListener : nsISupports{
|
||||
in nsIDOMNode aRightNode,
|
||||
in nsIDOMNode aParent);
|
||||
|
||||
/**
|
||||
/**
|
||||
* Called after the editor joins 2 nodes.
|
||||
* @param aLeftNode This node will be merged into the right node
|
||||
* @param aRightNode The node that will be merged into.
|
||||
@@ -141,7 +141,7 @@ interface nsIEditActionListener : nsISupports{
|
||||
in nsIDOMNode aParent,
|
||||
in nsresult aResult);
|
||||
|
||||
/**
|
||||
/**
|
||||
* Called before the editor inserts text.
|
||||
* @param aTextNode This node getting inserted text
|
||||
* @param aOffset The offset in aTextNode to insert at.
|
||||
@@ -151,7 +151,7 @@ interface nsIEditActionListener : nsISupports{
|
||||
in long aOffset,
|
||||
in DOMString aString);
|
||||
|
||||
/**
|
||||
/**
|
||||
* Called after the editor inserts text.
|
||||
* @param aTextNode This node getting inserted text
|
||||
* @param aOffset The offset in aTextNode to insert at.
|
||||
@@ -163,7 +163,7 @@ interface nsIEditActionListener : nsISupports{
|
||||
in DOMString aString,
|
||||
in nsresult aResult);
|
||||
|
||||
/**
|
||||
/**
|
||||
* Called before the editor deletes text.
|
||||
* @param aTextNode This node getting text deleted
|
||||
* @param aOffset The offset in aTextNode to delete at.
|
||||
@@ -173,7 +173,7 @@ interface nsIEditActionListener : nsISupports{
|
||||
in long aOffset,
|
||||
in long aLength);
|
||||
|
||||
/**
|
||||
/**
|
||||
* Called before the editor deletes text.
|
||||
* @param aTextNode This node getting text deleted
|
||||
* @param aOffset The offset in aTextNode to delete at.
|
||||
@@ -185,13 +185,13 @@ interface nsIEditActionListener : nsISupports{
|
||||
in long aLength,
|
||||
in nsresult aResult);
|
||||
|
||||
/**
|
||||
/**
|
||||
* Called before the editor deletes the selection.
|
||||
* @param aSelection The selection to be deleted
|
||||
*/
|
||||
void WillDeleteSelection(in nsISelection aSelection);
|
||||
|
||||
/**
|
||||
/**
|
||||
* Called after the editor deletes the selection.
|
||||
* @param aSelection The selection, after deletion
|
||||
*/
|
||||
|
||||
+16
-16
@@ -117,7 +117,7 @@ interface nsIEditor : nsISupports
|
||||
|
||||
/* ------------ Selected content removal -------------- */
|
||||
|
||||
/**
|
||||
/**
|
||||
* DeleteSelection removes all nodes in the current selection.
|
||||
* @param aDir if eNext, delete to the right (for example, the DEL key)
|
||||
* if ePrevious, delete to the left (for example, the BACKSPACE key)
|
||||
@@ -130,10 +130,10 @@ interface nsIEditor : nsISupports
|
||||
|
||||
|
||||
/* ------------ Document info and file methods -------------- */
|
||||
|
||||
|
||||
/** Returns true if the document has no *meaningful* content */
|
||||
readonly attribute boolean documentIsEmpty;
|
||||
|
||||
|
||||
/** Returns true if the document is modifed and needs saving */
|
||||
readonly attribute boolean documentModified;
|
||||
|
||||
@@ -157,7 +157,7 @@ interface nsIEditor : nsISupports
|
||||
* to increase or decrease the count
|
||||
*/
|
||||
void incrementModificationCount(in long aModCount);
|
||||
|
||||
|
||||
/* ------------ Transaction methods -------------- */
|
||||
|
||||
/** transactionManager Get the transaction manager the editor is using.
|
||||
@@ -166,7 +166,7 @@ interface nsIEditor : nsISupports
|
||||
|
||||
/** doTransaction() fires a transaction.
|
||||
* It is provided here so clients can create their own transactions.
|
||||
* If a transaction manager is present, it is used.
|
||||
* If a transaction manager is present, it is used.
|
||||
* Otherwise, the transaction is just executed directly.
|
||||
*
|
||||
* @param aTxn the transaction to execute
|
||||
@@ -199,7 +199,7 @@ interface nsIEditor : nsISupports
|
||||
* It is provided here so clients need no knowledge of whether
|
||||
* the editor has a transaction manager or not.
|
||||
* If a transaction manager is present, it is told to undo,
|
||||
* and the result of that undo is returned.
|
||||
* and the result of that undo is returned.
|
||||
* Otherwise, the Undo request is ignored and an
|
||||
* error NS_ERROR_NOT_AVAILABLE is returned.
|
||||
*
|
||||
@@ -377,8 +377,8 @@ interface nsIEditor : nsISupports
|
||||
* @return PR_TRUE if aAttribute is set on the current node,
|
||||
* PR_FALSE if it is not.
|
||||
*/
|
||||
boolean getAttributeValue(in nsIDOMElement aElement,
|
||||
in AString attributestr,
|
||||
boolean getAttributeValue(in nsIDOMElement aElement,
|
||||
in AString attributestr,
|
||||
out AString resultValue);
|
||||
|
||||
/**
|
||||
@@ -388,7 +388,7 @@ interface nsIEditor : nsISupports
|
||||
* @param aElement the content element to operate on
|
||||
* @param aAttribute the string representation of the attribute to get
|
||||
*/
|
||||
void removeAttribute(in nsIDOMElement aElement,
|
||||
void removeAttribute(in nsIDOMElement aElement,
|
||||
in AString aAttribute);
|
||||
|
||||
/**
|
||||
@@ -419,7 +419,7 @@ interface nsIEditor : nsISupports
|
||||
*/
|
||||
void cloneAttributes(in nsIDOMNode destNode, in nsIDOMNode sourceNode);
|
||||
|
||||
/**
|
||||
/**
|
||||
* createNode instantiates a new element of type aTag and inserts it
|
||||
* into aParent at aPosition.
|
||||
* @param aTag The type of object to create
|
||||
@@ -431,7 +431,7 @@ interface nsIEditor : nsISupports
|
||||
in nsIDOMNode parent,
|
||||
in long position);
|
||||
|
||||
/**
|
||||
/**
|
||||
* insertNode inserts aNode into aParent at aPosition.
|
||||
* No checking is done to verify the legality of the insertion.
|
||||
* That is the responsibility of the caller.
|
||||
@@ -446,7 +446,7 @@ interface nsIEditor : nsISupports
|
||||
in long aPosition);
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* splitNode() creates a new node identical to an existing node,
|
||||
* and split the contents between the two nodes
|
||||
* @param aExistingRightNode the node to split.
|
||||
@@ -460,7 +460,7 @@ interface nsIEditor : nsISupports
|
||||
in long offset,
|
||||
out nsIDOMNode newLeftNode);
|
||||
|
||||
/**
|
||||
/**
|
||||
* joinNodes() takes 2 nodes and merge their content|children.
|
||||
* @param aLeftNode The left node. It will be deleted.
|
||||
* @param aRightNode The right node. It will remain after the join.
|
||||
@@ -474,7 +474,7 @@ interface nsIEditor : nsISupports
|
||||
in nsIDOMNode rightNode,
|
||||
in nsIDOMNode parent);
|
||||
|
||||
/**
|
||||
/**
|
||||
* deleteNode removes aChild from aParent.
|
||||
* @param aChild The node to delete
|
||||
*/
|
||||
@@ -486,7 +486,7 @@ interface nsIEditor : nsISupports
|
||||
*/
|
||||
[notxpcom] boolean outputsMozDirty();
|
||||
|
||||
/**
|
||||
/**
|
||||
* markNodeDirty() sets a special dirty attribute on the node.
|
||||
* Usually this will be called immediately after creating a new node.
|
||||
* @param aNode The node for which to insert formatting.
|
||||
@@ -495,7 +495,7 @@ interface nsIEditor : nsISupports
|
||||
|
||||
/* ---------- direction controller ---------- */
|
||||
|
||||
/**
|
||||
/**
|
||||
* Switches the editor element direction; from "Left-to-Right" to
|
||||
* "Right-to-Left", and vice versa.
|
||||
*/
|
||||
|
||||
@@ -12,14 +12,14 @@ Editor Observer interface to outside world
|
||||
[scriptable, uuid(f3ee57a6-890c-4ce0-a584-8a84bba0292e)]
|
||||
|
||||
/**
|
||||
* A generic editor observer interface.
|
||||
* A generic editor observer interface.
|
||||
* <P>
|
||||
* nsIEditorObserver is the interface used by applications wishing to be notified
|
||||
* when the editor has completed a user action.
|
||||
* when the editor has completed a user action.
|
||||
*
|
||||
*/
|
||||
interface nsIEditorObserver : nsISupports {
|
||||
/**
|
||||
/**
|
||||
* Called after the editor completes a user action.
|
||||
*/
|
||||
void EditAction();
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIEditor;
|
||||
|
||||
@@ -20,7 +20,7 @@ interface nsIEditorStyleSheets : nsISupports
|
||||
/** Load and apply the style sheet, specified by aURL, to the
|
||||
* editor's document, replacing the last style sheet added (if any).
|
||||
* This is always asynchronous, and may cause network I/O.
|
||||
*
|
||||
*
|
||||
* @param aURL The style sheet to be loaded and applied.
|
||||
*/
|
||||
void replaceStyleSheet(in AString aURL);
|
||||
@@ -41,7 +41,7 @@ interface nsIEditorStyleSheets : nsISupports
|
||||
* display behavior for editing (like showing special cursors) that will
|
||||
* not be affected by loading "document" style sheets with addStyleSheet or
|
||||
* especially replaceStyleSheet.
|
||||
*
|
||||
*
|
||||
* @param aURL The style sheet to be loaded and applied.
|
||||
*/
|
||||
void replaceOverrideStyleSheet(in AString aURL);
|
||||
|
||||
+59
-59
@@ -34,8 +34,8 @@ interface nsIHTMLEditor : nsISupports
|
||||
const short eCenter = 1;
|
||||
const short eRight = 2;
|
||||
const short eJustify = 3;
|
||||
|
||||
|
||||
|
||||
|
||||
/* ------------ Inline property methods -------------- */
|
||||
|
||||
|
||||
@@ -50,8 +50,8 @@ interface nsIHTMLEditor : nsISupports
|
||||
* Example: aProperty="font", aAttribute="color",
|
||||
* aValue="0x00FFFF"
|
||||
*/
|
||||
void addDefaultProperty(in nsIAtom aProperty,
|
||||
in AString aAttribute,
|
||||
void addDefaultProperty(in nsIAtom aProperty,
|
||||
in AString aAttribute,
|
||||
in AString aValue);
|
||||
|
||||
/**
|
||||
@@ -65,8 +65,8 @@ interface nsIHTMLEditor : nsISupports
|
||||
* Example: aProperty="font", aAttribute="color",
|
||||
* aValue="0x00FFFF"
|
||||
*/
|
||||
void removeDefaultProperty(in nsIAtom aProperty,
|
||||
in AString aAttribute,
|
||||
void removeDefaultProperty(in nsIAtom aProperty,
|
||||
in AString aAttribute,
|
||||
in AString aValue);
|
||||
|
||||
/**
|
||||
@@ -78,7 +78,7 @@ interface nsIHTMLEditor : nsISupports
|
||||
/**
|
||||
* SetInlineProperty() sets the aggregate properties on the current selection
|
||||
*
|
||||
* @param aProperty the property to set on the selection
|
||||
* @param aProperty the property to set on the selection
|
||||
* @param aAttribute the attribute of the property, if applicable.
|
||||
* May be null.
|
||||
* Example: aProperty="font", aAttribute="color"
|
||||
@@ -87,7 +87,7 @@ interface nsIHTMLEditor : nsISupports
|
||||
* Example: aProperty="font", aAttribute="color",
|
||||
* aValue="0x00FFFF"
|
||||
*/
|
||||
void setInlineProperty(in nsIAtom aProperty,
|
||||
void setInlineProperty(in nsIAtom aProperty,
|
||||
in AString aAttribute,
|
||||
in AString aValue);
|
||||
|
||||
@@ -96,7 +96,7 @@ interface nsIHTMLEditor : nsISupports
|
||||
* All object in the current selection are scanned and their attributes are
|
||||
* represented in a list of Property object.
|
||||
*
|
||||
* @param aProperty the property to get on the selection
|
||||
* @param aProperty the property to get on the selection
|
||||
* @param aAttribute the attribute of the property, if applicable.
|
||||
* May be null.
|
||||
* Example: aProperty="font", aAttribute="color"
|
||||
@@ -111,22 +111,22 @@ interface nsIHTMLEditor : nsISupports
|
||||
* @param aAll [OUT] PR_TRUE if all of the text nodes in the
|
||||
* selection have the property
|
||||
*/
|
||||
void getInlineProperty(in nsIAtom aProperty,
|
||||
void getInlineProperty(in nsIAtom aProperty,
|
||||
in AString aAttribute,
|
||||
in AString aValue,
|
||||
out boolean aFirst,
|
||||
out boolean aAny,
|
||||
out boolean aAll);
|
||||
|
||||
AString getInlinePropertyWithAttrValue(in nsIAtom aProperty,
|
||||
AString getInlinePropertyWithAttrValue(in nsIAtom aProperty,
|
||||
in AString aAttribute,
|
||||
in AString aValue,
|
||||
out boolean aFirst,
|
||||
out boolean aAny,
|
||||
out boolean aAll);
|
||||
|
||||
|
||||
/**
|
||||
* removeAllInlineProperties() deletes all the inline properties from all
|
||||
* removeAllInlineProperties() deletes all the inline properties from all
|
||||
* text in the current selection.
|
||||
*/
|
||||
void removeAllInlineProperties();
|
||||
@@ -136,7 +136,7 @@ interface nsIHTMLEditor : nsISupports
|
||||
* removeInlineProperty() deletes the properties from all text in the current
|
||||
* selection. If aProperty is not set on the selection, nothing is done.
|
||||
*
|
||||
* @param aProperty the property to remove from the selection
|
||||
* @param aProperty the property to remove from the selection
|
||||
* All atoms are for normal HTML tags (e.g.:
|
||||
* nsIEditorProperty::font) except when you want to
|
||||
* remove just links and not named anchors.
|
||||
@@ -183,13 +183,13 @@ interface nsIHTMLEditor : nsISupports
|
||||
void insertHTML(in AString aInputString);
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* Paste the text in the OS clipboard at the cursor position, replacing
|
||||
* the selected text (if any), but strip out any HTML styles and formatting
|
||||
*/
|
||||
void pasteNoFormatting(in long aSelectionType);
|
||||
|
||||
/**
|
||||
/**
|
||||
* Rebuild the entire document from source HTML
|
||||
* Needed to be able to edit HEAD and other outside-of-BODY content
|
||||
*
|
||||
@@ -203,12 +203,12 @@ interface nsIHTMLEditor : nsISupports
|
||||
*
|
||||
* @param aInputString the string to be inserted
|
||||
* @param aContextStr Context of insertion
|
||||
* @param aInfoStr Related info to aInputString
|
||||
* @param aInfoStr Related info to aInputString
|
||||
* @param aFlavor Transferable flavor, can be ""
|
||||
* @param aSourceDoc document where input was dragged from (may be null)
|
||||
* @param aDestinationNode location for insertion (such as when dropped)
|
||||
* @param aDestinationOffset used with aDestNode to determine insert location
|
||||
* @param aDeleteSelection used with aDestNode during drag&drop
|
||||
* @param aDeleteSelection used with aDestNode during drag&drop
|
||||
* @param aCollapseSelection used with aDestNode during drag&drop
|
||||
*/
|
||||
void insertHTMLWithContext(in AString aInputString,
|
||||
@@ -221,7 +221,7 @@ interface nsIHTMLEditor : nsISupports
|
||||
in boolean aDeleteSelection);
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* Insert an element, which may have child nodes, at the selection
|
||||
* Used primarily to insert a new element for various insert element dialogs,
|
||||
* but it enforces the HTML 4.0 DTD "CanContain" rules, so it should
|
||||
@@ -229,19 +229,19 @@ interface nsIHTMLEditor : nsISupports
|
||||
*
|
||||
* @param aElement The element to insert
|
||||
* @param aDeleteSelection Delete the selection before inserting
|
||||
* If aDeleteSelection is PR_FALSE, then the element is inserted
|
||||
* If aDeleteSelection is PR_FALSE, then the element is inserted
|
||||
* after the end of the selection for all element except
|
||||
* Named Anchors, which insert before the selection
|
||||
*/
|
||||
*/
|
||||
void insertElementAtSelection(in nsIDOMElement aElement,
|
||||
in boolean aDeleteSelection);
|
||||
|
||||
/**
|
||||
/**
|
||||
* Set the documents title.
|
||||
*/
|
||||
void setDocumentTitle(in AString aTitle);
|
||||
|
||||
/**
|
||||
/**
|
||||
* Set the BaseURL for the document to the current URL
|
||||
* but only if the page doesn't have a <base> tag
|
||||
* This should be done after the document URL has changed,
|
||||
@@ -253,17 +253,17 @@ interface nsIHTMLEditor : nsISupports
|
||||
|
||||
/* ------------ Selection manipulation -------------- */
|
||||
/* Should these be moved to nsISelection? */
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* Set the selection at the suppled element
|
||||
*
|
||||
* @param aElement An element in the document
|
||||
*/
|
||||
void selectElement(in nsIDOMElement aElement);
|
||||
|
||||
/**
|
||||
/**
|
||||
* Create a collapsed selection just after aElement
|
||||
*
|
||||
*
|
||||
* XXX could we parameterize SelectElement(before/select/after>?
|
||||
*
|
||||
* The selection is set to parent-of-aElement with an
|
||||
@@ -289,48 +289,48 @@ interface nsIHTMLEditor : nsISupports
|
||||
*/
|
||||
AString getParagraphState(out boolean aMixed);
|
||||
|
||||
/**
|
||||
/**
|
||||
* getFontFaceState returns what font face is in the selection.
|
||||
* @param aMixed True if there is more than one font face
|
||||
* @return Name of face. Note: "tt" is returned for
|
||||
* tt tag. "" is returned for none.
|
||||
*/
|
||||
AString getFontFaceState(out boolean aMixed);
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* getFontColorState returns what font face is in the selection.
|
||||
* @param aMixed True if there is more than one font color
|
||||
* @return Color string. "" is returned for none.
|
||||
*/
|
||||
AString getFontColorState(out boolean aMixed);
|
||||
|
||||
/**
|
||||
/**
|
||||
* getFontColorState returns what font face is in the selection.
|
||||
* @param aMixed True if there is more than one font color
|
||||
* @return Color string. "" is returned for none.
|
||||
*/
|
||||
AString getBackgroundColorState(out boolean aMixed);
|
||||
|
||||
/**
|
||||
/**
|
||||
* getHighlightColorState returns what the highlight color of the selection.
|
||||
* @param aMixed True if there is more than one font color
|
||||
* @return Color string. "" is returned for none.
|
||||
*/
|
||||
AString getHighlightColorState(out boolean aMixed);
|
||||
|
||||
/**
|
||||
/**
|
||||
* getListState returns what list type is in the selection.
|
||||
* @param aMixed True if there is more than one type of list, or
|
||||
* if there is some list and non-list
|
||||
* @param aOL The company that employs me. No, really, it's
|
||||
* @param aOL The company that employs me. No, really, it's
|
||||
* true if an "ol" list is selected.
|
||||
* @param aUL true if an "ul" list is selected.
|
||||
* @param aDL true if a "dl" list is selected.
|
||||
*/
|
||||
void getListState(out boolean aMixed, out boolean aOL, out boolean aUL,
|
||||
out boolean aDL);
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* getListItemState returns what list item type is in the selection.
|
||||
* @param aMixed True if there is more than one type of list item, or
|
||||
* if there is some list and non-list
|
||||
@@ -340,8 +340,8 @@ interface nsIHTMLEditor : nsISupports
|
||||
*/
|
||||
void getListItemState(out boolean aMixed, out boolean aLI,
|
||||
out boolean aDT, out boolean aDD);
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* getAlignment returns what alignment is in the selection.
|
||||
* @param aMixed True if there is more than one type of list item, or
|
||||
* if there is some list and non-list
|
||||
@@ -349,39 +349,39 @@ interface nsIHTMLEditor : nsISupports
|
||||
* (left/center/right)
|
||||
*/
|
||||
void getAlignment(out boolean aMixed, out short aAlign);
|
||||
|
||||
|
||||
/**
|
||||
* Document me!
|
||||
*
|
||||
*
|
||||
*/
|
||||
void getIndentState(out boolean aCanIndent, out boolean aCanOutdent);
|
||||
|
||||
/**
|
||||
* Document me!
|
||||
*
|
||||
*
|
||||
*/
|
||||
void makeOrChangeList(in AString aListType, in boolean entireList,
|
||||
in AString aBulletType);
|
||||
|
||||
/**
|
||||
* Document me!
|
||||
*
|
||||
*
|
||||
*/
|
||||
void removeList(in AString aListType);
|
||||
|
||||
/**
|
||||
* Document me!
|
||||
*
|
||||
*
|
||||
*/
|
||||
void indent(in AString aIndent);
|
||||
|
||||
/**
|
||||
* Document me!
|
||||
*
|
||||
*
|
||||
*/
|
||||
void align(in AString aAlign);
|
||||
|
||||
/**
|
||||
/**
|
||||
* Return the input node or a parent matching the given aTagName,
|
||||
* starting the search at the supplied node.
|
||||
* An example of use is for testing if a node is in a table cell
|
||||
@@ -389,7 +389,7 @@ interface nsIHTMLEditor : nsISupports
|
||||
*
|
||||
* @param aTagName The HTML tagname
|
||||
* Special input values:
|
||||
* Use "href" to get a link node
|
||||
* Use "href" to get a link node
|
||||
* (an "A" tag with the "href" attribute set)
|
||||
* Use "anchor" or "namedanchor" to get a named anchor node
|
||||
* (an "A" tag with the "name" attribute set)
|
||||
@@ -404,7 +404,7 @@ interface nsIHTMLEditor : nsISupports
|
||||
nsIDOMElement getElementOrParentByTagName(in AString aTagName,
|
||||
in nsIDOMNode aNode);
|
||||
|
||||
/**
|
||||
/**
|
||||
* Return an element only if it is the only node selected,
|
||||
* such as an image, horizontal rule, etc.
|
||||
* The exception is a link, which is more like a text attribute:
|
||||
@@ -413,7 +413,7 @@ interface nsIHTMLEditor : nsISupports
|
||||
* This could be a collapsed selection, i.e., a caret
|
||||
* within the link text.
|
||||
*
|
||||
* @param aTagName The HTML tagname or and empty string
|
||||
* @param aTagName The HTML tagname or and empty string
|
||||
* to get any element (but only if it is the only element selected)
|
||||
* Special input values for Links and Named anchors:
|
||||
* Use "href" to get a link node
|
||||
@@ -425,23 +425,23 @@ interface nsIHTMLEditor : nsISupports
|
||||
*/
|
||||
nsIDOMElement getSelectedElement(in AString aTagName);
|
||||
|
||||
/**
|
||||
/**
|
||||
* Output the contents of the <HEAD> section as text/HTML format
|
||||
*/
|
||||
AString getHeadContentsAsHTML();
|
||||
|
||||
/**
|
||||
/**
|
||||
* Replace all children of <HEAD> with string of HTML source
|
||||
*/
|
||||
void replaceHeadContentsWithHTML(in AString aSourceToInsert);
|
||||
|
||||
/**
|
||||
/**
|
||||
* Return a new element with default attribute values
|
||||
*
|
||||
*
|
||||
* This does not rely on the selection, and is not sensitive to context.
|
||||
*
|
||||
*
|
||||
* Used primarily to supply new element for various insert element dialogs
|
||||
* (Image, Link, NamedAnchor, Table, and HorizontalRule
|
||||
* (Image, Link, NamedAnchor, Table, and HorizontalRule
|
||||
* are the only returned elements as of 7/25/99)
|
||||
*
|
||||
* @param aTagName The HTML tagname
|
||||
@@ -454,14 +454,14 @@ interface nsIHTMLEditor : nsISupports
|
||||
*/
|
||||
nsIDOMElement createElementWithDefaults(in AString aTagName);
|
||||
|
||||
/**
|
||||
/**
|
||||
* Insert an link element as the parent of the current selection
|
||||
*
|
||||
* @param aElement An "A" element with a non-empty "href" attribute
|
||||
*/
|
||||
void insertLinkAroundSelection(in nsIDOMElement aAnchorElement);
|
||||
|
||||
/**
|
||||
/**
|
||||
* Set the value of the "bgcolor" attribute on the document's <body> element
|
||||
*
|
||||
* @param aColor The HTML color string, such as "#ffccff" or "yellow"
|
||||
@@ -469,7 +469,7 @@ interface nsIHTMLEditor : nsISupports
|
||||
void setBackgroundColor(in AString aColor);
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* Set an attribute on the document's <body> element
|
||||
* such as text, link, background colors
|
||||
*
|
||||
@@ -479,7 +479,7 @@ interface nsIHTMLEditor : nsISupports
|
||||
* @param aValue The value of the attribute
|
||||
*/
|
||||
void setBodyAttribute(in AString aAttr, in AString aValue);
|
||||
|
||||
|
||||
/**
|
||||
* Find all the nodes in the document which contain references
|
||||
* to outside URIs (e.g. a href, img src, script src, etc.)
|
||||
@@ -489,7 +489,7 @@ interface nsIHTMLEditor : nsISupports
|
||||
*/
|
||||
nsISupportsArray getLinkedObjects();
|
||||
|
||||
/**
|
||||
/**
|
||||
* A boolean which is true is the HTMLEditor has been instantiated
|
||||
* with CSS knowledge and if the CSS pref is currently checked
|
||||
*
|
||||
|
||||
@@ -29,5 +29,5 @@ interface nsIHTMLObjectResizeListener : nsISupports
|
||||
void onEndResizing(in nsIDOMElement aElement,
|
||||
in long aOldWidth, in long aOldHeight,
|
||||
in long aNewWidth, in long aNewHeight);
|
||||
|
||||
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[scriptable, uuid(b74fb158-1265-4102-91eb-edd0136b49f8)]
|
||||
@@ -71,7 +71,7 @@ interface nsIPlaintextEditor : nsISupports
|
||||
attribute long maxTextLength;
|
||||
|
||||
/** Get and set the body wrap width.
|
||||
*
|
||||
*
|
||||
* Special values:
|
||||
* 0 = wrap to window width
|
||||
* -1 = no wrap at all
|
||||
@@ -101,7 +101,7 @@ interface nsIPlaintextEditor : nsISupports
|
||||
* @param aString the string to be inserted
|
||||
*/
|
||||
void insertText(in DOMString aStringToInsert);
|
||||
|
||||
|
||||
/**
|
||||
* Insert a line break into the content model.
|
||||
* The interpretation of a break is up to the implementation:
|
||||
|
||||
+30
-30
@@ -21,7 +21,7 @@ interface nsITableEditor : nsISupports
|
||||
/* ------------ Table editing Methods -------------- */
|
||||
|
||||
/** Insert table methods
|
||||
* Insert relative to the selected cell or the
|
||||
* Insert relative to the selected cell or the
|
||||
* cell enclosing the selection anchor
|
||||
* The selection is collapsed and is left in the new cell
|
||||
* at the same row,col location as the original anchor cell
|
||||
@@ -35,9 +35,9 @@ interface nsITableEditor : nsISupports
|
||||
void insertTableRow(in long aNumber, in boolean aAfter);
|
||||
|
||||
/** Delete table methods
|
||||
* Delete starting at the selected cell or the
|
||||
* Delete starting at the selected cell or the
|
||||
* cell (or table) enclosing the selection anchor
|
||||
* The selection is collapsed and is left in the
|
||||
* The selection is collapsed and is left in the
|
||||
* cell at the same row,col location as
|
||||
* the previous selection anchor, if possible,
|
||||
* else in the closest neigboring cell
|
||||
@@ -56,7 +56,7 @@ interface nsITableEditor : nsISupports
|
||||
* @param aNumber Number of contiguous cells, rows, or columns
|
||||
*
|
||||
* When there are more than 1 selected cells, aNumber is ignored.
|
||||
* For Delete Rows or Columns, the complete columns or rows are
|
||||
* For Delete Rows or Columns, the complete columns or rows are
|
||||
* determined by the selected cells. E.g., to delete 2 complete rows,
|
||||
* user simply selects a cell in each, and they don't
|
||||
* have to be contiguous.
|
||||
@@ -99,35 +99,35 @@ interface nsITableEditor : nsISupports
|
||||
|
||||
/** Merges contents of all selected cells
|
||||
* for selected cells that are adjacent,
|
||||
* this will result in a larger cell with appropriate
|
||||
* this will result in a larger cell with appropriate
|
||||
* rowspan and colspan, and original cells are deleted
|
||||
* The resulting cell is in the location of the
|
||||
* The resulting cell is in the location of the
|
||||
* cell at the upper-left corner of the adjacent
|
||||
* block of selected cells
|
||||
*
|
||||
* @param aMergeNonContiguousContents:
|
||||
* If true:
|
||||
* @param aMergeNonContiguousContents:
|
||||
* If true:
|
||||
* Non-contiguous cells are not deleted,
|
||||
* but their contents are still moved
|
||||
* but their contents are still moved
|
||||
* to the upper-left cell
|
||||
* If false: contiguous cells are ignored
|
||||
*
|
||||
* If there are no selected cells,
|
||||
* and selection or caret is in a cell,
|
||||
* that cell and the one to the right
|
||||
* that cell and the one to the right
|
||||
* are merged
|
||||
*/
|
||||
void joinTableCells(in boolean aMergeNonContiguousContents);
|
||||
|
||||
/** Split a cell that has rowspan and/or colspan > 0
|
||||
* into cells such that all new cells have
|
||||
* into cells such that all new cells have
|
||||
* rowspan = 1 and colspan = 1
|
||||
* 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
|
||||
*/
|
||||
void splitTableCell();
|
||||
|
||||
/** Scan through all rows and add cells as needed so
|
||||
/** Scan through all rows and add cells as needed so
|
||||
* all locations in the cellmap are occupied.
|
||||
* Used after inserting single cells or pasting
|
||||
* a collection of cells that extend past the
|
||||
@@ -141,14 +141,14 @@ interface nsITableEditor : nsISupports
|
||||
|
||||
/** Get the row an column index from the layout's cellmap
|
||||
* If aCell is null, it will try to find enclosing table of selection anchor
|
||||
*
|
||||
*
|
||||
*/
|
||||
void getCellIndexes(in nsIDOMElement aCell,
|
||||
out long aRowIndex, out long aColIndex);
|
||||
|
||||
/** Get the number of rows and columns in a table from the layout's cellmap
|
||||
* If aTable is null, it will try to find enclosing table of selection ancho
|
||||
* Note that all rows in table will not have this many because of
|
||||
* Note that all rows in table will not have this many because of
|
||||
* ROWSPAN effects or if table is not "rectangular" (has short rows)
|
||||
*/
|
||||
void getTableSize(in nsIDOMElement aTable,
|
||||
@@ -174,12 +174,12 @@ interface nsITableEditor : nsISupports
|
||||
/** Get a cell at cellmap grid coordinates and associated data
|
||||
* A cell that spans across multiple cellmap locations will
|
||||
* be returned multiple times, once for each location it occupies
|
||||
* Examine the returned aStartRowIndex and aStartColIndex to see
|
||||
* Examine the returned aStartRowIndex and aStartColIndex to see
|
||||
* if it is in the same layout column or layout row:
|
||||
* A "layout row" is all cells sharing the same top edge
|
||||
* A "layout column" is all cells sharing the same left edge
|
||||
* This is important to determine what to do when inserting or deleting a column or row
|
||||
*
|
||||
*
|
||||
* @param aTable A table in the document
|
||||
* @param aRowIndex, aColIndex The 0-based cellmap indexes
|
||||
* returns values:
|
||||
@@ -191,7 +191,7 @@ interface nsITableEditor : nsISupports
|
||||
* @param aActualRowSpan The actual number of cellmap locations (rows) spanned by the cell
|
||||
* @param aActualColSpan The actual number of cellmap locations (columns) spanned by the cell
|
||||
* @param aIsSelected
|
||||
* @param
|
||||
* @param
|
||||
*
|
||||
* (in C++ returns: NS_EDITOR_ELEMENT_NOT_FOUND if an element is not found
|
||||
* passes NS_SUCCEEDED macro)
|
||||
@@ -200,8 +200,8 @@ interface nsITableEditor : nsISupports
|
||||
in long aRowIndex, in long aColIndex,
|
||||
out nsIDOMElement aCell,
|
||||
out long aStartRowIndex, out long aStartColIndex,
|
||||
out long aRowSpan, out long aColSpan,
|
||||
out long aActualRowSpan, out long aActualColSpan,
|
||||
out long aRowSpan, out long aColSpan,
|
||||
out long aActualRowSpan, out long aActualColSpan,
|
||||
out boolean aIsSelected);
|
||||
|
||||
/** Get the first row element in a table
|
||||
@@ -224,10 +224,10 @@ interface nsITableEditor : nsISupports
|
||||
* passes NS_SUCCEEDED macro)
|
||||
*/
|
||||
nsIDOMNode getNextRow(in nsIDOMNode aTableElement);
|
||||
|
||||
|
||||
/** Preferred direction to search for neighboring cell
|
||||
* when trying to locate a cell to place caret in after
|
||||
* a table editing action.
|
||||
* a table editing action.
|
||||
* Used for aDirection param in SetSelectionAfterTableEdit
|
||||
*/
|
||||
|
||||
@@ -245,11 +245,11 @@ interface nsITableEditor : nsISupports
|
||||
* If no cell is found, caret is place just before table;
|
||||
* and if that fails, at beginning of document.
|
||||
* Thus we generally don't worry about the return value
|
||||
* and can use the nsSetSelectionAfterTableEdit stack-based
|
||||
* and can use the nsSetSelectionAfterTableEdit stack-based
|
||||
* object to insure we reset the caret in a table-editing method.
|
||||
*/
|
||||
void setSelectionAfterTableEdit(in nsIDOMElement aTable,
|
||||
in long aRow, in long aCol,
|
||||
in long aRow, in long aCol,
|
||||
in long aDirection, in boolean aSelected);
|
||||
|
||||
/** Examine the current selection and find
|
||||
@@ -270,12 +270,12 @@ interface nsITableEditor : nsISupports
|
||||
|
||||
/** Generally used after GetSelectedOrParentTableElement
|
||||
* to test if selected cells are complete rows or columns
|
||||
*
|
||||
*
|
||||
* @param aElement Any table or cell element or any element
|
||||
* inside a table
|
||||
* Used to get enclosing table.
|
||||
* Used to get enclosing table.
|
||||
* If null, selection's anchorNode is used
|
||||
*
|
||||
*
|
||||
* @return
|
||||
* 0 aCellElement was not a cell
|
||||
* (returned result = NS_ERROR_FAILURE)
|
||||
@@ -296,14 +296,14 @@ interface nsITableEditor : nsISupports
|
||||
* is in a separate range (selection parent node is table row)
|
||||
* @param aCell [OUT] Selected cell or null if ranges don't contain
|
||||
* cell selections
|
||||
* @param aRange [OUT] Optional: if not null, return the selection range
|
||||
* @param aRange [OUT] Optional: if not null, return the selection range
|
||||
* associated with the cell
|
||||
* Returns the DOM cell element
|
||||
* (in C++: returns NS_EDITOR_ELEMENT_NOT_FOUND if an element is not found
|
||||
* passes NS_SUCCEEDED macro)
|
||||
*/
|
||||
nsIDOMElement getFirstSelectedCell(out nsIDOMRange aRange);
|
||||
|
||||
|
||||
/** Get first selected element in the table
|
||||
* This is the upper-left-most selected cell in table,
|
||||
* ignoring the order that the user selected them (order in the selection ranges)
|
||||
@@ -326,7 +326,7 @@ interface nsITableEditor : nsISupports
|
||||
* Always call GetFirstSelectedCell() to initialize stored index of "next" cell
|
||||
* @param aCell Selected cell or null if no more selected cells
|
||||
* or ranges don't contain cell selections
|
||||
* @param aRange Optional: if not null, return the selection range
|
||||
* @param aRange Optional: if not null, return the selection range
|
||||
* associated with the cell
|
||||
*
|
||||
* Returns the DOM cell element
|
||||
|
||||
@@ -238,7 +238,7 @@ nsTransactionManager::BeginBatch(nsISupports* aData)
|
||||
}
|
||||
|
||||
result = BeginTransaction(0, aData);
|
||||
|
||||
|
||||
nsresult result2 = DidBeginBatchNotify(result);
|
||||
|
||||
if (NS_SUCCEEDED(result))
|
||||
@@ -540,7 +540,7 @@ nsTransactionManager::WillDoNotify(nsITransaction *aTransaction, bool *aInterrup
|
||||
NS_ENSURE_TRUE(listener, NS_ERROR_FAILURE);
|
||||
|
||||
result = listener->WillDo(this, aTransaction, aInterrupt);
|
||||
|
||||
|
||||
if (NS_FAILED(result) || *aInterrupt)
|
||||
break;
|
||||
}
|
||||
@@ -559,7 +559,7 @@ nsTransactionManager::DidDoNotify(nsITransaction *aTransaction, nsresult aDoResu
|
||||
NS_ENSURE_TRUE(listener, NS_ERROR_FAILURE);
|
||||
|
||||
result = listener->DidDo(this, aTransaction, aDoResult);
|
||||
|
||||
|
||||
if (NS_FAILED(result))
|
||||
break;
|
||||
}
|
||||
@@ -578,7 +578,7 @@ nsTransactionManager::WillUndoNotify(nsITransaction *aTransaction, bool *aInterr
|
||||
NS_ENSURE_TRUE(listener, NS_ERROR_FAILURE);
|
||||
|
||||
result = listener->WillUndo(this, aTransaction, aInterrupt);
|
||||
|
||||
|
||||
if (NS_FAILED(result) || *aInterrupt)
|
||||
break;
|
||||
}
|
||||
@@ -597,7 +597,7 @@ nsTransactionManager::DidUndoNotify(nsITransaction *aTransaction, nsresult aUndo
|
||||
NS_ENSURE_TRUE(listener, NS_ERROR_FAILURE);
|
||||
|
||||
result = listener->DidUndo(this, aTransaction, aUndoResult);
|
||||
|
||||
|
||||
if (NS_FAILED(result))
|
||||
break;
|
||||
}
|
||||
@@ -616,7 +616,7 @@ nsTransactionManager::WillRedoNotify(nsITransaction *aTransaction, bool *aInterr
|
||||
NS_ENSURE_TRUE(listener, NS_ERROR_FAILURE);
|
||||
|
||||
result = listener->WillRedo(this, aTransaction, aInterrupt);
|
||||
|
||||
|
||||
if (NS_FAILED(result) || *aInterrupt)
|
||||
break;
|
||||
}
|
||||
@@ -635,7 +635,7 @@ nsTransactionManager::DidRedoNotify(nsITransaction *aTransaction, nsresult aRedo
|
||||
NS_ENSURE_TRUE(listener, NS_ERROR_FAILURE);
|
||||
|
||||
result = listener->DidRedo(this, aTransaction, aRedoResult);
|
||||
|
||||
|
||||
if (NS_FAILED(result))
|
||||
break;
|
||||
}
|
||||
@@ -654,7 +654,7 @@ nsTransactionManager::WillBeginBatchNotify(bool *aInterrupt)
|
||||
NS_ENSURE_TRUE(listener, NS_ERROR_FAILURE);
|
||||
|
||||
result = listener->WillBeginBatch(this, aInterrupt);
|
||||
|
||||
|
||||
if (NS_FAILED(result) || *aInterrupt)
|
||||
break;
|
||||
}
|
||||
@@ -673,7 +673,7 @@ nsTransactionManager::DidBeginBatchNotify(nsresult aResult)
|
||||
NS_ENSURE_TRUE(listener, NS_ERROR_FAILURE);
|
||||
|
||||
result = listener->DidBeginBatch(this, aResult);
|
||||
|
||||
|
||||
if (NS_FAILED(result))
|
||||
break;
|
||||
}
|
||||
@@ -692,7 +692,7 @@ nsTransactionManager::WillEndBatchNotify(bool *aInterrupt)
|
||||
NS_ENSURE_TRUE(listener, NS_ERROR_FAILURE);
|
||||
|
||||
result = listener->WillEndBatch(this, aInterrupt);
|
||||
|
||||
|
||||
if (NS_FAILED(result) || *aInterrupt)
|
||||
break;
|
||||
}
|
||||
@@ -711,7 +711,7 @@ nsTransactionManager::DidEndBatchNotify(nsresult aResult)
|
||||
NS_ENSURE_TRUE(listener, NS_ERROR_FAILURE);
|
||||
|
||||
result = listener->DidEndBatch(this, aResult);
|
||||
|
||||
|
||||
if (NS_FAILED(result))
|
||||
break;
|
||||
}
|
||||
@@ -730,7 +730,7 @@ nsTransactionManager::WillMergeNotify(nsITransaction *aTop, nsITransaction *aTra
|
||||
NS_ENSURE_TRUE(listener, NS_ERROR_FAILURE);
|
||||
|
||||
result = listener->WillMerge(this, aTop, aTransaction, aInterrupt);
|
||||
|
||||
|
||||
if (NS_FAILED(result) || *aInterrupt)
|
||||
break;
|
||||
}
|
||||
@@ -752,7 +752,7 @@ nsTransactionManager::DidMergeNotify(nsITransaction *aTop,
|
||||
NS_ENSURE_TRUE(listener, NS_ERROR_FAILURE);
|
||||
|
||||
result = listener->DidMerge(this, aTop, aTransaction, aDidMerge, aMergeResult);
|
||||
|
||||
|
||||
if (NS_FAILED(result))
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ nsFilteredContentIterator::Init(nsIDOMRange* aRange)
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
nsresult
|
||||
nsresult
|
||||
nsFilteredContentIterator::SwitchDirections(bool aChangeToForward)
|
||||
{
|
||||
nsINode *node = mCurrentIterator->GetCurrentNode();
|
||||
@@ -251,7 +251,7 @@ ContentIsInTraversalRange(nsRange* aRange, nsIDOMNode* aNextNode, bool aIsPreMod
|
||||
|
||||
//------------------------------------------------------------
|
||||
// Helper function to advance to the next or previous node
|
||||
nsresult
|
||||
nsresult
|
||||
nsFilteredContentIterator::AdvanceNode(nsIDOMNode* aNode, nsIDOMNode*& aNewNode, eDirectionType aDir)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> nextNode;
|
||||
@@ -287,7 +287,7 @@ nsFilteredContentIterator::AdvanceNode(nsIDOMNode* aNode, nsIDOMNode*& aNewNode,
|
||||
}
|
||||
}
|
||||
|
||||
// if we get here it pretty much means
|
||||
// if we get here it pretty much means
|
||||
// we went out of the DOM Range
|
||||
mIsOutOfRange = true;
|
||||
|
||||
@@ -309,7 +309,7 @@ nsFilteredContentIterator::CheckAdvNode(nsIDOMNode* aNode, bool& aDidSkip, eDire
|
||||
nsresult rv = mFilter->Skip(aNode, &skipIt);
|
||||
if (NS_SUCCEEDED(rv) && skipIt) {
|
||||
aDidSkip = true;
|
||||
// Get the next/prev node and then
|
||||
// Get the next/prev node and then
|
||||
// see if we should skip that
|
||||
nsCOMPtr<nsIDOMNode> advNode;
|
||||
rv = AdvanceNode(aNode, *getter_AddRefs(advNode), aDir);
|
||||
@@ -353,7 +353,7 @@ nsFilteredContentIterator::Next()
|
||||
return;
|
||||
}
|
||||
|
||||
// If we can't get the current node then
|
||||
// If we can't get the current node then
|
||||
// don't check to see if we can skip it
|
||||
nsINode *currentNode = mCurrentIterator->GetCurrentNode();
|
||||
|
||||
@@ -385,7 +385,7 @@ nsFilteredContentIterator::Prev()
|
||||
return;
|
||||
}
|
||||
|
||||
// If we can't get the current node then
|
||||
// If we can't get the current node then
|
||||
// don't check to see if we can skip it
|
||||
nsINode *currentNode = mCurrentIterator->GetCurrentNode();
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ interface nsIInlineSpellChecker : nsISupports
|
||||
void replaceWord(in nsIDOMNode aNode, in long aOffset, in AString aNewword);
|
||||
void addWordToDictionary(in AString aWord);
|
||||
void removeWordFromDictionary(in AString aWord);
|
||||
|
||||
|
||||
void ignoreWord(in AString aWord);
|
||||
void ignoreWords([array, size_is(aCount)] in wstring aWordsToIgnore, in unsigned long aCount);
|
||||
void updateCurrentDictionary();
|
||||
|
||||
@@ -110,7 +110,7 @@ public:
|
||||
/**
|
||||
* Tells the spellchecker to use a specific dictionary.
|
||||
* @param aDictionary a string that is in the list returned
|
||||
* by GetDictionaryList() or an empty string. If aDictionary is
|
||||
* by GetDictionaryList() or an empty string. If aDictionary is
|
||||
* empty string, spellchecker will be disabled.
|
||||
*/
|
||||
NS_IMETHOD SetCurrentDictionary(const nsAString &aDictionary) = 0;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
/******
|
||||
|
||||
This file contains the list of all text services nsIAtoms and their values
|
||||
|
||||
|
||||
It is designed to be used as inline input to nsTextServicesDocument.cpp *only*
|
||||
through the magic of C preprocessing.
|
||||
|
||||
|
||||
@@ -211,7 +211,7 @@ nsTextServicesDocument::InitWithEditor(nsIEditor *aEditor)
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
nsTextServicesDocument::GetDocument(nsIDOMDocument **aDoc)
|
||||
{
|
||||
NS_ENSURE_TRUE(aDoc, NS_ERROR_NULL_POINTER);
|
||||
@@ -1158,8 +1158,8 @@ nsTextServicesDocument::DeleteSelection()
|
||||
|
||||
// We don't allow deletion during a collapsed selection!
|
||||
nsCOMPtr<nsIEditor> editor (do_QueryReferent(mEditor));
|
||||
NS_ASSERTION(editor, "DeleteSelection called without an editor present!");
|
||||
NS_ASSERTION(SelectionIsValid(), "DeleteSelection called without a valid selection!");
|
||||
NS_ASSERTION(editor, "DeleteSelection called without an editor present!");
|
||||
NS_ASSERTION(SelectionIsValid(), "DeleteSelection called without a valid selection!");
|
||||
|
||||
if (!editor || !SelectionIsValid())
|
||||
return NS_ERROR_FAILURE;
|
||||
@@ -1459,7 +1459,7 @@ nsTextServicesDocument::InsertText(const nsString *aText)
|
||||
nsresult result = NS_OK;
|
||||
|
||||
nsCOMPtr<nsIEditor> editor (do_QueryReferent(mEditor));
|
||||
NS_ASSERTION(editor, "InsertText called without an editor present!");
|
||||
NS_ASSERTION(editor, "InsertText called without an editor present!");
|
||||
|
||||
if (!editor || !SelectionIsValid())
|
||||
return NS_ERROR_FAILURE;
|
||||
@@ -1618,7 +1618,7 @@ nsTextServicesDocument::InsertText(const nsString *aText)
|
||||
itEntry->mLength += strLength;
|
||||
|
||||
mSelStartIndex = mSelEndIndex = i;
|
||||
|
||||
|
||||
result = mSelCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection));
|
||||
|
||||
if (NS_FAILED(result))
|
||||
@@ -1629,7 +1629,7 @@ nsTextServicesDocument::InsertText(const nsString *aText)
|
||||
}
|
||||
|
||||
result = selection->Collapse(itEntry->mNode, itEntry->mNodeOffset + itEntry->mLength);
|
||||
|
||||
|
||||
if (NS_FAILED(result))
|
||||
{
|
||||
editor->EndTransaction();
|
||||
@@ -1711,7 +1711,7 @@ nsTextServicesDocument::InsertText(const nsString *aText)
|
||||
}
|
||||
|
||||
result = DeleteSelection();
|
||||
|
||||
|
||||
if (NS_FAILED(result))
|
||||
{
|
||||
editor->EndTransaction();
|
||||
@@ -1782,7 +1782,7 @@ nsTextServicesDocument::DidDeleteNode(nsIDOMNode *aChild, nsresult aResult)
|
||||
// next valid text node in the offset table, and if there
|
||||
// wasn't a next, it would've set mIteratorStatus to eIsDone.
|
||||
|
||||
NS_ERROR("DeleteNode called for current iterator node.");
|
||||
NS_ERROR("DeleteNode called for current iterator node.");
|
||||
}
|
||||
|
||||
int32_t tcount = mOffsetTable.Length();
|
||||
@@ -2055,7 +2055,7 @@ nsTextServicesDocument::CreateDocumentContentRootToNodeOffsetRange(
|
||||
if (aOffset < 0)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> bodyNode;
|
||||
nsCOMPtr<nsIDOMNode> bodyNode;
|
||||
nsresult rv = GetDocumentContentRootNode(getter_AddRefs(bodyNode));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_TRUE(bodyNode, NS_ERROR_NULL_POINTER);
|
||||
@@ -2217,9 +2217,9 @@ bool
|
||||
nsTextServicesDocument::DidSkip(nsIContentIterator* aFilteredIter)
|
||||
{
|
||||
// We can assume here that the Iterator is a nsFilteredContentIterator because
|
||||
// all the iterator are created in CreateContentIterator which create a
|
||||
// all the iterator are created in CreateContentIterator which create a
|
||||
// nsFilteredContentIterator
|
||||
// So if the iterator bailed on one of the "filtered" content nodes then we
|
||||
// So if the iterator bailed on one of the "filtered" content nodes then we
|
||||
// consider that to be a block and bail with true
|
||||
if (aFilteredIter) {
|
||||
nsFilteredContentIterator* filter = static_cast<nsFilteredContentIterator *>(aFilteredIter);
|
||||
@@ -2431,7 +2431,7 @@ nsTextServicesDocument::SetSelectionInternal(int32_t aOffset, int32_t aLength, b
|
||||
for (i = mOffsetTable.Length() - 1; !eNode && i >= 0; i--)
|
||||
{
|
||||
entry = mOffsetTable[i];
|
||||
|
||||
|
||||
if (entry->mIsValid)
|
||||
{
|
||||
if (entry->mIsInsertedText)
|
||||
@@ -2896,7 +2896,7 @@ nsTextServicesDocument::GetUncollapsedSelection(nsITextServicesDocument::TSDBloc
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
// Find the first text node in the range.
|
||||
|
||||
|
||||
bool found;
|
||||
nsCOMPtr<nsIContent> content;
|
||||
|
||||
@@ -3156,7 +3156,7 @@ nsTextServicesDocument::FirstTextNodeInCurrentBlock(nsIContentIterator *iter)
|
||||
if (DidSkip(iter))
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (last)
|
||||
iter->PositionAt(last);
|
||||
|
||||
@@ -3324,7 +3324,7 @@ nsTextServicesDocument::CreateOffsetTable(nsTArray<OffsetEntry*> *aOffsetTable,
|
||||
// If we have an aIterRange, retrieve the endpoints so
|
||||
// they can be used in the while loop below to trim entries
|
||||
// for text nodes that are partially selected by aIterRange.
|
||||
|
||||
|
||||
nsCOMPtr<nsIDOMNode> rngStartNode, rngEndNode;
|
||||
int32_t rngStartOffset = 0, rngEndOffset = 0;
|
||||
|
||||
@@ -3612,14 +3612,14 @@ nsTextServicesDocument::FindWordBounds(nsTArray<OffsetEntry*> *aOffsetTable,
|
||||
}
|
||||
|
||||
// Strip out the NBSPs at the ends
|
||||
while ((res.mBegin <= res.mEnd) && (IS_NBSP_CHAR(str[res.mBegin])))
|
||||
while ((res.mBegin <= res.mEnd) && (IS_NBSP_CHAR(str[res.mBegin])))
|
||||
res.mBegin++;
|
||||
if (str[res.mEnd] == (unsigned char)0x20)
|
||||
{
|
||||
uint32_t realEndWord = res.mEnd - 1;
|
||||
while ((realEndWord > res.mBegin) && (IS_NBSP_CHAR(str[realEndWord])))
|
||||
while ((realEndWord > res.mBegin) && (IS_NBSP_CHAR(str[realEndWord])))
|
||||
realEndWord--;
|
||||
if (realEndWord < res.mEnd - 1)
|
||||
if (realEndWord < res.mEnd - 1)
|
||||
res.mEnd = realEndWord + 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ private:
|
||||
static nsIAtom *sSampAtom;
|
||||
static nsIAtom *sSmallAtom;
|
||||
static nsIAtom *sSpacerAtom;
|
||||
static nsIAtom *sSpanAtom;
|
||||
static nsIAtom *sSpanAtom;
|
||||
static nsIAtom *sStrikeAtom;
|
||||
static nsIAtom *sStrongAtom;
|
||||
static nsIAtom *sSubAtom;
|
||||
|
||||
@@ -106,97 +106,11 @@ bool xpc::ExtraWarningsForSystemJS() { return sExtraWarningsForSystemJS; }
|
||||
bool xpc::ExtraWarningsForSystemJS() { return false; }
|
||||
#endif
|
||||
|
||||
static void * const UNMARK_ONLY = nullptr;
|
||||
static void * const UNMARK_AND_SWEEP = (void*)1;
|
||||
|
||||
static PLDHashOperator
|
||||
NativeInterfaceSweeper(PLDHashTable* table, PLDHashEntryHdr* hdr,
|
||||
uint32_t number, void* arg)
|
||||
{
|
||||
XPCNativeInterface* iface = ((IID2NativeInterfaceMap::Entry*)hdr)->value;
|
||||
if (iface->IsMarked()) {
|
||||
iface->Unmark();
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
if (arg == UNMARK_ONLY)
|
||||
return PL_DHASH_NEXT;
|
||||
|
||||
XPCNativeInterface::DestroyInstance(iface);
|
||||
return PL_DHASH_REMOVE;
|
||||
}
|
||||
|
||||
// *Some* NativeSets are referenced from mClassInfo2NativeSetMap.
|
||||
// *All* NativeSets are referenced from mNativeSetMap.
|
||||
// So, in mClassInfo2NativeSetMap we just clear references to the unmarked.
|
||||
// In mNativeSetMap we clear the references to the unmarked *and* delete them.
|
||||
|
||||
static PLDHashOperator
|
||||
NativeUnMarkedSetRemover(PLDHashTable* table, PLDHashEntryHdr* hdr,
|
||||
uint32_t number, void* arg)
|
||||
{
|
||||
XPCNativeSet* set = ((ClassInfo2NativeSetMap::Entry*)hdr)->value;
|
||||
if (set->IsMarked())
|
||||
return PL_DHASH_NEXT;
|
||||
return PL_DHASH_REMOVE;
|
||||
}
|
||||
|
||||
static PLDHashOperator
|
||||
NativeSetSweeper(PLDHashTable* table, PLDHashEntryHdr* hdr,
|
||||
uint32_t number, void* arg)
|
||||
{
|
||||
XPCNativeSet* set = ((NativeSetMap::Entry*)hdr)->key_value;
|
||||
if (set->IsMarked()) {
|
||||
set->Unmark();
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
if (arg == UNMARK_ONLY)
|
||||
return PL_DHASH_NEXT;
|
||||
|
||||
XPCNativeSet::DestroyInstance(set);
|
||||
return PL_DHASH_REMOVE;
|
||||
}
|
||||
|
||||
static PLDHashOperator
|
||||
JSClassSweeper(PLDHashTable* table, PLDHashEntryHdr* hdr,
|
||||
uint32_t number, void* arg)
|
||||
{
|
||||
XPCNativeScriptableShared* shared =
|
||||
((XPCNativeScriptableSharedMap::Entry*) hdr)->key;
|
||||
if (shared->IsMarked()) {
|
||||
shared->Unmark();
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
if (arg == UNMARK_ONLY)
|
||||
return PL_DHASH_NEXT;
|
||||
|
||||
delete shared;
|
||||
return PL_DHASH_REMOVE;
|
||||
}
|
||||
|
||||
static PLDHashOperator
|
||||
DyingProtoKiller(PLDHashTable* table, PLDHashEntryHdr* hdr,
|
||||
uint32_t number, void* arg)
|
||||
{
|
||||
XPCWrappedNativeProto* proto =
|
||||
(XPCWrappedNativeProto*)((PLDHashEntryStub*)hdr)->key;
|
||||
delete proto;
|
||||
return PL_DHASH_REMOVE;
|
||||
}
|
||||
|
||||
static PLDHashOperator
|
||||
DetachedWrappedNativeProtoMarker(PLDHashTable* table, PLDHashEntryHdr* hdr,
|
||||
uint32_t number, void* arg)
|
||||
{
|
||||
XPCWrappedNativeProto* proto =
|
||||
(XPCWrappedNativeProto*)((PLDHashEntryStub*)hdr)->key;
|
||||
|
||||
proto->Mark();
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
bool
|
||||
XPCJSRuntime::CustomContextCallback(JSContext* cx, unsigned operation)
|
||||
{
|
||||
@@ -804,8 +718,10 @@ XPCJSRuntime::FinalizeCallback(JSFreeOp* fop,
|
||||
// Do the marking...
|
||||
XPCWrappedNativeScope::MarkAllWrappedNativesAndProtos();
|
||||
|
||||
self->mDetachedWrappedNativeProtoMap->
|
||||
Enumerate(DetachedWrappedNativeProtoMarker, nullptr);
|
||||
for (auto i = self->mDetachedWrappedNativeProtoMap->Iter(); !i.Done(); i.Next()) {
|
||||
auto entry = static_cast<XPCWrappedNativeProtoMap::Entry*>(i.Get());
|
||||
static_cast<const XPCWrappedNativeProto*>(entry->key)->Mark();
|
||||
}
|
||||
|
||||
// Mark the sets used in the call contexts. There is a small
|
||||
// chance that a wrapper's set will change *while* a call is
|
||||
@@ -853,26 +769,53 @@ XPCJSRuntime::FinalizeCallback(JSFreeOp* fop,
|
||||
// kept separate, we could sweep only the ones belonging to
|
||||
// compartments being collected. Currently, though, NativeInterfaces
|
||||
// are shared between compartments. This ought to be fixed.
|
||||
void* sweepArg = isCompartmentGC ? UNMARK_ONLY : UNMARK_AND_SWEEP;
|
||||
bool doSweep = !isCompartmentGC;
|
||||
|
||||
// We don't want to sweep the JSClasses at shutdown time.
|
||||
// At this point there may be JSObjects using them that have
|
||||
// been removed from the other maps.
|
||||
if (!nsXPConnect::XPConnect()->IsShuttingDown()) {
|
||||
self->mNativeScriptableSharedMap->
|
||||
Enumerate(JSClassSweeper, sweepArg);
|
||||
for (auto i = self->mNativeScriptableSharedMap->RemovingIter(); !i.Done(); i.Next()) {
|
||||
auto entry = static_cast<XPCNativeScriptableSharedMap::Entry*>(i.Get());
|
||||
XPCNativeScriptableShared* shared = entry->key;
|
||||
if (shared->IsMarked()) {
|
||||
shared->Unmark();
|
||||
} else if (doSweep) {
|
||||
delete shared;
|
||||
i.Remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!isCompartmentGC) {
|
||||
self->mClassInfo2NativeSetMap->
|
||||
Enumerate(NativeUnMarkedSetRemover, nullptr);
|
||||
for (auto i = self->mClassInfo2NativeSetMap->RemovingIter(); !i.Done(); i.Next()) {
|
||||
auto entry = static_cast<ClassInfo2NativeSetMap::Entry*>(i.Get());
|
||||
if (!entry->value->IsMarked())
|
||||
i.Remove();
|
||||
}
|
||||
}
|
||||
|
||||
self->mNativeSetMap->
|
||||
Enumerate(NativeSetSweeper, sweepArg);
|
||||
for (auto i = self->mNativeSetMap->RemovingIter(); !i.Done(); i.Next()) {
|
||||
auto entry = static_cast<NativeSetMap::Entry*>(i.Get());
|
||||
XPCNativeSet* set = entry->key_value;
|
||||
if (set->IsMarked()) {
|
||||
set->Unmark();
|
||||
} else if (doSweep) {
|
||||
XPCNativeSet::DestroyInstance(set);
|
||||
i.Remove();
|
||||
}
|
||||
}
|
||||
|
||||
self->mIID2NativeInterfaceMap->
|
||||
Enumerate(NativeInterfaceSweeper, sweepArg);
|
||||
for (auto i = self->mIID2NativeInterfaceMap->RemovingIter(); !i.Done(); i.Next()) {
|
||||
auto entry = static_cast<IID2NativeInterfaceMap::Entry*>(i.Get());
|
||||
XPCNativeInterface* iface = entry->value;
|
||||
if (iface->IsMarked()) {
|
||||
iface->Unmark();
|
||||
} else if (doSweep) {
|
||||
XPCNativeInterface::DestroyInstance(iface);
|
||||
i.Remove();
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
XPCWrappedNativeScope::ASSERT_NoInterfaceSetsAreMarked();
|
||||
@@ -928,8 +871,11 @@ XPCJSRuntime::FinalizeCallback(JSFreeOp* fop,
|
||||
// referencing the protos in the dying list are themselves dead.
|
||||
// So, we can safely delete all the protos in the list.
|
||||
|
||||
self->mDyingWrappedNativeProtoMap->
|
||||
Enumerate(DyingProtoKiller, nullptr);
|
||||
for (auto i = self->mDyingWrappedNativeProtoMap->RemovingIter(); !i.Done(); i.Next()) {
|
||||
auto entry = static_cast<XPCWrappedNativeProtoMap::Entry*>(i.Get());
|
||||
delete static_cast<const XPCWrappedNativeProto*>(entry->key);
|
||||
i.Remove();
|
||||
}
|
||||
|
||||
MOZ_ASSERT(self->mGCIsRunning, "bad state");
|
||||
self->mGCIsRunning = false;
|
||||
@@ -1505,17 +1451,6 @@ XPCJSRuntime::SizeOfIncludingThis(MallocSizeOf mallocSizeOf)
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
static PLDHashOperator
|
||||
DetachedWrappedNativeProtoShutdownMarker(PLDHashTable* table, PLDHashEntryHdr* hdr,
|
||||
uint32_t number, void* arg)
|
||||
{
|
||||
XPCWrappedNativeProto* proto =
|
||||
(XPCWrappedNativeProto*)((PLDHashEntryStub*)hdr)->key;
|
||||
|
||||
proto->SystemIsBeingShutDown();
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
void XPCJSRuntime::DestroyJSContextStack()
|
||||
{
|
||||
delete mJSContextStack;
|
||||
@@ -1524,8 +1459,11 @@ void XPCJSRuntime::DestroyJSContextStack()
|
||||
|
||||
void XPCJSRuntime::SystemIsBeingShutDown()
|
||||
{
|
||||
mDetachedWrappedNativeProtoMap->
|
||||
Enumerate(DetachedWrappedNativeProtoShutdownMarker, nullptr);
|
||||
for (auto i = mDetachedWrappedNativeProtoMap->Iter(); !i.Done(); i.Next()) {
|
||||
auto entry = static_cast<XPCWrappedNativeProtoMap::Entry*>(i.Get());
|
||||
auto proto = const_cast<XPCWrappedNativeProto*>(static_cast<const XPCWrappedNativeProto*>(entry->key));
|
||||
proto->SystemIsBeingShutDown();
|
||||
}
|
||||
}
|
||||
|
||||
#define JS_OPTIONS_DOT_STR "javascript.options."
|
||||
@@ -3534,23 +3472,6 @@ XPCJSRuntime::NoteCustomGCThingXPCOMChildren(const js::Class* clasp, JSObject* o
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
#ifdef DEBUG
|
||||
static PLDHashOperator
|
||||
WrappedJSClassMapDumpEnumerator(PLDHashTable* table, PLDHashEntryHdr* hdr,
|
||||
uint32_t number, void* arg)
|
||||
{
|
||||
((IID2WrappedJSClassMap::Entry*)hdr)->value->DebugDump(*(int16_t*)arg);
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
static PLDHashOperator
|
||||
NativeSetDumpEnumerator(PLDHashTable* table, PLDHashEntryHdr* hdr,
|
||||
uint32_t number, void* arg)
|
||||
{
|
||||
((NativeSetMap::Entry*)hdr)->key_value->DebugDump(*(int16_t*)arg);
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
XPCJSRuntime::DebugDump(int16_t depth)
|
||||
{
|
||||
@@ -3583,7 +3504,10 @@ XPCJSRuntime::DebugDump(int16_t depth)
|
||||
// iterate wrappersclasses...
|
||||
if (depth && mWrappedJSClassMap->Count()) {
|
||||
XPC_LOG_INDENT();
|
||||
mWrappedJSClassMap->Enumerate(WrappedJSClassMapDumpEnumerator, &depth);
|
||||
for (auto i = mWrappedJSClassMap->Iter(); !i.Done(); i.Next()) {
|
||||
auto entry = static_cast<IID2WrappedJSClassMap::Entry*>(i.Get());
|
||||
entry->value->DebugDump(depth);
|
||||
}
|
||||
XPC_LOG_OUTDENT();
|
||||
}
|
||||
XPC_LOG_ALWAYS(("mWrappedJSMap @ %x with %d wrappers(s)",
|
||||
@@ -3612,7 +3536,10 @@ XPCJSRuntime::DebugDump(int16_t depth)
|
||||
// iterate sets...
|
||||
if (depth && mNativeSetMap->Count()) {
|
||||
XPC_LOG_INDENT();
|
||||
mNativeSetMap->Enumerate(NativeSetDumpEnumerator, &depth);
|
||||
for (auto i = mNativeSetMap->RemovingIter(); !i.Done(); i.Next()) {
|
||||
auto entry = static_cast<NativeSetMap::Entry*>(i.Get());
|
||||
entry->key_value->DebugDump(depth);
|
||||
}
|
||||
XPC_LOG_OUTDENT();
|
||||
}
|
||||
|
||||
|
||||
+22
-18
@@ -148,8 +148,9 @@ public:
|
||||
}
|
||||
|
||||
inline uint32_t Count() { return mTable->EntryCount(); }
|
||||
inline uint32_t Enumerate(PLDHashEnumerator f, void* arg)
|
||||
{return PL_DHashTableEnumerate(mTable, f, arg);}
|
||||
|
||||
PLDHashTable::Iterator Iter() const { return PLDHashTable::Iterator(mTable); }
|
||||
PLDHashTable::RemovingIterator RemovingIter() { return PLDHashTable::RemovingIterator(mTable); }
|
||||
|
||||
size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf);
|
||||
|
||||
@@ -207,8 +208,8 @@ public:
|
||||
}
|
||||
|
||||
inline uint32_t Count() { return mTable->EntryCount(); }
|
||||
inline uint32_t Enumerate(PLDHashEnumerator f, void* arg)
|
||||
{return PL_DHashTableEnumerate(mTable, f, arg);}
|
||||
|
||||
PLDHashTable::Iterator Iter() const { return PLDHashTable::Iterator(mTable); }
|
||||
|
||||
~IID2WrappedJSClassMap();
|
||||
private:
|
||||
@@ -261,8 +262,8 @@ public:
|
||||
}
|
||||
|
||||
inline uint32_t Count() { return mTable->EntryCount(); }
|
||||
inline uint32_t Enumerate(PLDHashEnumerator f, void* arg)
|
||||
{return PL_DHashTableEnumerate(mTable, f, arg);}
|
||||
|
||||
PLDHashTable::RemovingIterator RemovingIter() { return PLDHashTable::RemovingIterator(mTable); }
|
||||
|
||||
size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf);
|
||||
|
||||
@@ -317,8 +318,8 @@ public:
|
||||
}
|
||||
|
||||
inline uint32_t Count() { return mTable->EntryCount(); }
|
||||
inline uint32_t Enumerate(PLDHashEnumerator f, void* arg)
|
||||
{return PL_DHashTableEnumerate(mTable, f, arg);}
|
||||
|
||||
PLDHashTable::RemovingIterator RemovingIter() { return PLDHashTable::RemovingIterator(mTable); }
|
||||
|
||||
// ClassInfo2NativeSetMap holds pointers to *some* XPCNativeSets.
|
||||
// So we don't want to count those XPCNativeSets, because they are better
|
||||
@@ -374,8 +375,9 @@ public:
|
||||
}
|
||||
|
||||
inline uint32_t Count() { return mTable->EntryCount(); }
|
||||
inline uint32_t Enumerate(PLDHashEnumerator f, void* arg)
|
||||
{return PL_DHashTableEnumerate(mTable, f, arg);}
|
||||
|
||||
PLDHashTable::Iterator Iter() const { return PLDHashTable::Iterator(mTable); }
|
||||
PLDHashTable::RemovingIterator RemovingIter() { return PLDHashTable::RemovingIterator(mTable); }
|
||||
|
||||
size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf);
|
||||
|
||||
@@ -444,8 +446,9 @@ public:
|
||||
}
|
||||
|
||||
inline uint32_t Count() { return mTable->EntryCount(); }
|
||||
inline uint32_t Enumerate(PLDHashEnumerator f, void* arg)
|
||||
{return PL_DHashTableEnumerate(mTable, f, arg);}
|
||||
|
||||
PLDHashTable::Iterator Iter() const { return PLDHashTable::Iterator(mTable); }
|
||||
PLDHashTable::RemovingIterator RemovingIter() { return PLDHashTable::RemovingIterator(mTable); }
|
||||
|
||||
size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf);
|
||||
|
||||
@@ -507,8 +510,6 @@ public:
|
||||
}
|
||||
|
||||
inline uint32_t Count() { return mTable->EntryCount(); }
|
||||
inline uint32_t Enumerate(PLDHashEnumerator f, void* arg)
|
||||
{return PL_DHashTableEnumerate(mTable, f, arg);}
|
||||
|
||||
~IID2ThisTranslatorMap();
|
||||
private:
|
||||
@@ -543,8 +544,8 @@ public:
|
||||
bool GetNewOrUsed(uint32_t flags, char* name, XPCNativeScriptableInfo* si);
|
||||
|
||||
inline uint32_t Count() { return mTable->EntryCount(); }
|
||||
inline uint32_t Enumerate(PLDHashEnumerator f, void* arg)
|
||||
{return PL_DHashTableEnumerate(mTable, f, arg);}
|
||||
|
||||
PLDHashTable::RemovingIterator RemovingIter() { return PLDHashTable::RemovingIterator(mTable); }
|
||||
|
||||
~XPCNativeScriptableSharedMap();
|
||||
private:
|
||||
@@ -559,6 +560,8 @@ private:
|
||||
class XPCWrappedNativeProtoMap
|
||||
{
|
||||
public:
|
||||
typedef PLDHashEntryStub Entry;
|
||||
|
||||
static XPCWrappedNativeProtoMap* newMap(int length);
|
||||
|
||||
inline XPCWrappedNativeProto* Add(XPCWrappedNativeProto* proto)
|
||||
@@ -581,8 +584,9 @@ public:
|
||||
}
|
||||
|
||||
inline uint32_t Count() { return mTable->EntryCount(); }
|
||||
inline uint32_t Enumerate(PLDHashEnumerator f, void* arg)
|
||||
{return PL_DHashTableEnumerate(mTable, f, arg);}
|
||||
|
||||
PLDHashTable::Iterator Iter() const { return PLDHashTable::Iterator(mTable); }
|
||||
PLDHashTable::RemovingIterator RemovingIter() { return PLDHashTable::RemovingIterator(mTable); }
|
||||
|
||||
~XPCWrappedNativeProtoMap();
|
||||
private:
|
||||
|
||||
@@ -459,17 +459,6 @@ XPCWrappedNativeScope::~XPCWrappedNativeScope()
|
||||
mGlobalJSObject.finalize(rt);
|
||||
}
|
||||
|
||||
static PLDHashOperator
|
||||
WrappedNativeJSGCThingTracer(PLDHashTable* table, PLDHashEntryHdr* hdr,
|
||||
uint32_t number, void* arg)
|
||||
{
|
||||
XPCWrappedNative* wrapper = ((Native2WrappedNativeMap::Entry*)hdr)->value;
|
||||
if (wrapper->HasExternalReference() && !wrapper->IsWrapperExpired())
|
||||
wrapper->TraceSelf((JSTracer*)arg);
|
||||
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
// static
|
||||
void
|
||||
XPCWrappedNativeScope::TraceWrappedNativesInAllScopes(JSTracer* trc, XPCJSRuntime* rt)
|
||||
@@ -477,7 +466,13 @@ XPCWrappedNativeScope::TraceWrappedNativesInAllScopes(JSTracer* trc, XPCJSRuntim
|
||||
// Do JS_CallTracer for all wrapped natives with external references, as
|
||||
// well as any DOM expando objects.
|
||||
for (XPCWrappedNativeScope* cur = gScopes; cur; cur = cur->mNext) {
|
||||
cur->mWrappedNativeMap->Enumerate(WrappedNativeJSGCThingTracer, trc);
|
||||
for (auto i = cur->mWrappedNativeMap->Iter(); !i.Done(); i.Next()) {
|
||||
auto entry = static_cast<Native2WrappedNativeMap::Entry*>(i.Get());
|
||||
XPCWrappedNative* wrapper = entry->value;
|
||||
if (wrapper->HasExternalReference() && !wrapper->IsWrapperExpired())
|
||||
wrapper->TraceSelf(trc);
|
||||
}
|
||||
|
||||
if (cur->mDOMExpandoSet) {
|
||||
for (DOMExpandoSet::Enum e(*cur->mDOMExpandoSet); !e.empty(); e.popFront())
|
||||
JS_CallHashSetObjectTracer(trc, e, e.front(), "DOM expando object");
|
||||
@@ -485,21 +480,6 @@ XPCWrappedNativeScope::TraceWrappedNativesInAllScopes(JSTracer* trc, XPCJSRuntim
|
||||
}
|
||||
}
|
||||
|
||||
static PLDHashOperator
|
||||
WrappedNativeSuspecter(PLDHashTable* table, PLDHashEntryHdr* hdr,
|
||||
uint32_t number, void* arg)
|
||||
{
|
||||
XPCWrappedNative* wrapper = ((Native2WrappedNativeMap::Entry*)hdr)->value;
|
||||
|
||||
if (wrapper->HasExternalReference()) {
|
||||
nsCycleCollectionNoteRootCallback* cb =
|
||||
static_cast<nsCycleCollectionNoteRootCallback*>(arg);
|
||||
XPCJSRuntime::SuspectWrappedNative(wrapper, *cb);
|
||||
}
|
||||
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
static void
|
||||
SuspectDOMExpandos(JSObject* obj, nsCycleCollectionNoteRootCallback& cb)
|
||||
{
|
||||
@@ -514,7 +494,13 @@ XPCWrappedNativeScope::SuspectAllWrappers(XPCJSRuntime* rt,
|
||||
nsCycleCollectionNoteRootCallback& cb)
|
||||
{
|
||||
for (XPCWrappedNativeScope* cur = gScopes; cur; cur = cur->mNext) {
|
||||
cur->mWrappedNativeMap->Enumerate(WrappedNativeSuspecter, &cb);
|
||||
for (auto i = cur->mWrappedNativeMap->Iter(); !i.Done(); i.Next()) {
|
||||
auto entry = static_cast<Native2WrappedNativeMap::Entry*>(i.Get());
|
||||
XPCWrappedNative* wrapper = entry->value;
|
||||
if (wrapper->HasExternalReference())
|
||||
XPCJSRuntime::SuspectWrappedNative(wrapper, cb);
|
||||
}
|
||||
|
||||
if (cur->mDOMExpandoSet) {
|
||||
for (DOMExpandoSet::Range r = cur->mDOMExpandoSet->all(); !r.empty(); r.popFront())
|
||||
SuspectDOMExpandos(r.front(), cb);
|
||||
@@ -569,76 +555,52 @@ XPCWrappedNativeScope::UpdateWeakPointersAfterGC(XPCJSRuntime* rt)
|
||||
}
|
||||
}
|
||||
|
||||
static PLDHashOperator
|
||||
WrappedNativeMarker(PLDHashTable* table, PLDHashEntryHdr* hdr,
|
||||
uint32_t number_t, void* arg)
|
||||
{
|
||||
((Native2WrappedNativeMap::Entry*)hdr)->value->Mark();
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
// We need to explicitly mark all the protos too because some protos may be
|
||||
// alive in the hashtable but not currently in use by any wrapper
|
||||
static PLDHashOperator
|
||||
WrappedNativeProtoMarker(PLDHashTable* table, PLDHashEntryHdr* hdr,
|
||||
uint32_t number, void* arg)
|
||||
{
|
||||
((ClassInfo2WrappedNativeProtoMap::Entry*)hdr)->value->Mark();
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
// static
|
||||
void
|
||||
XPCWrappedNativeScope::MarkAllWrappedNativesAndProtos()
|
||||
{
|
||||
for (XPCWrappedNativeScope* cur = gScopes; cur; cur = cur->mNext) {
|
||||
cur->mWrappedNativeMap->Enumerate(WrappedNativeMarker, nullptr);
|
||||
cur->mWrappedNativeProtoMap->Enumerate(WrappedNativeProtoMarker, nullptr);
|
||||
for (auto i = cur->mWrappedNativeMap->Iter(); !i.Done(); i.Next()) {
|
||||
auto entry = static_cast<Native2WrappedNativeMap::Entry*>(i.Get());
|
||||
entry->value->Mark();
|
||||
}
|
||||
// We need to explicitly mark all the protos too because some protos may be
|
||||
// alive in the hashtable but not currently in use by any wrapper
|
||||
for (auto i = cur->mWrappedNativeProtoMap->Iter(); !i.Done(); i.Next()) {
|
||||
auto entry = static_cast<ClassInfo2WrappedNativeProtoMap::Entry*>(i.Get());
|
||||
entry->value->Mark();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
static PLDHashOperator
|
||||
ASSERT_WrappedNativeSetNotMarked(PLDHashTable* table, PLDHashEntryHdr* hdr,
|
||||
uint32_t number, void* arg)
|
||||
{
|
||||
((Native2WrappedNativeMap::Entry*)hdr)->value->ASSERT_SetsNotMarked();
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
static PLDHashOperator
|
||||
ASSERT_WrappedNativeProtoSetNotMarked(PLDHashTable* table, PLDHashEntryHdr* hdr,
|
||||
uint32_t number, void* arg)
|
||||
{
|
||||
((ClassInfo2WrappedNativeProtoMap::Entry*)hdr)->value->ASSERT_SetNotMarked();
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
// static
|
||||
void
|
||||
XPCWrappedNativeScope::ASSERT_NoInterfaceSetsAreMarked()
|
||||
{
|
||||
for (XPCWrappedNativeScope* cur = gScopes; cur; cur = cur->mNext) {
|
||||
cur->mWrappedNativeMap->Enumerate(ASSERT_WrappedNativeSetNotMarked, nullptr);
|
||||
cur->mWrappedNativeProtoMap->Enumerate(ASSERT_WrappedNativeProtoSetNotMarked, nullptr);
|
||||
for (auto i = cur->mWrappedNativeMap->Iter(); !i.Done(); i.Next()) {
|
||||
auto entry = static_cast<Native2WrappedNativeMap::Entry*>(i.Get());
|
||||
entry->value->ASSERT_SetsNotMarked();
|
||||
}
|
||||
for (auto i = cur->mWrappedNativeProtoMap->Iter(); !i.Done(); i.Next()) {
|
||||
auto entry = static_cast<ClassInfo2WrappedNativeProtoMap::Entry*>(i.Get());
|
||||
entry->value->ASSERT_SetNotMarked();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static PLDHashOperator
|
||||
WrappedNativeTearoffSweeper(PLDHashTable* table, PLDHashEntryHdr* hdr,
|
||||
uint32_t number, void* arg)
|
||||
{
|
||||
((Native2WrappedNativeMap::Entry*)hdr)->value->SweepTearOffs();
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
// static
|
||||
void
|
||||
XPCWrappedNativeScope::SweepAllWrappedNativeTearOffs()
|
||||
{
|
||||
for (XPCWrappedNativeScope* cur = gScopes; cur; cur = cur->mNext)
|
||||
cur->mWrappedNativeMap->Enumerate(WrappedNativeTearoffSweeper, nullptr);
|
||||
for (XPCWrappedNativeScope* cur = gScopes; cur; cur = cur->mNext) {
|
||||
for (auto i = cur->mWrappedNativeMap->Iter(); !i.Done(); i.Next()) {
|
||||
auto entry = static_cast<Native2WrappedNativeMap::Entry*>(i.Get());
|
||||
entry->value->SweepTearOffs();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
@@ -656,48 +618,12 @@ XPCWrappedNativeScope::KillDyingScopes()
|
||||
gDyingScopes = nullptr;
|
||||
}
|
||||
|
||||
struct ShutdownData
|
||||
{
|
||||
ShutdownData()
|
||||
: wrapperCount(0),
|
||||
protoCount(0) {}
|
||||
int wrapperCount;
|
||||
int protoCount;
|
||||
};
|
||||
|
||||
static PLDHashOperator
|
||||
WrappedNativeShutdownEnumerator(PLDHashTable* table, PLDHashEntryHdr* hdr,
|
||||
uint32_t number, void* arg)
|
||||
{
|
||||
ShutdownData* data = (ShutdownData*) arg;
|
||||
XPCWrappedNative* wrapper = ((Native2WrappedNativeMap::Entry*)hdr)->value;
|
||||
|
||||
if (wrapper->IsValid()) {
|
||||
wrapper->SystemIsBeingShutDown();
|
||||
data->wrapperCount++;
|
||||
}
|
||||
return PL_DHASH_REMOVE;
|
||||
}
|
||||
|
||||
static PLDHashOperator
|
||||
WrappedNativeProtoShutdownEnumerator(PLDHashTable* table, PLDHashEntryHdr* hdr,
|
||||
uint32_t number, void* arg)
|
||||
{
|
||||
ShutdownData* data = (ShutdownData*) arg;
|
||||
((ClassInfo2WrappedNativeProtoMap::Entry*)hdr)->value->
|
||||
SystemIsBeingShutDown();
|
||||
data->protoCount++;
|
||||
return PL_DHASH_REMOVE;
|
||||
}
|
||||
|
||||
//static
|
||||
void
|
||||
XPCWrappedNativeScope::SystemIsBeingShutDown()
|
||||
{
|
||||
int liveScopeCount = 0;
|
||||
|
||||
ShutdownData data;
|
||||
|
||||
XPCWrappedNativeScope* cur;
|
||||
|
||||
// First move all the scopes to the dying list.
|
||||
@@ -723,10 +649,19 @@ XPCWrappedNativeScope::SystemIsBeingShutDown()
|
||||
|
||||
// Walk the protos first. Wrapper shutdown can leave dangling
|
||||
// proto pointers in the proto map.
|
||||
cur->mWrappedNativeProtoMap->
|
||||
Enumerate(WrappedNativeProtoShutdownEnumerator, &data);
|
||||
cur->mWrappedNativeMap->
|
||||
Enumerate(WrappedNativeShutdownEnumerator, &data);
|
||||
for (auto i = cur->mWrappedNativeProtoMap->RemovingIter(); !i.Done(); i.Next()) {
|
||||
auto entry = static_cast<ClassInfo2WrappedNativeProtoMap::Entry*>(i.Get());
|
||||
entry->value->SystemIsBeingShutDown();
|
||||
i.Remove();
|
||||
}
|
||||
for (auto i = cur->mWrappedNativeMap->RemovingIter(); !i.Done(); i.Next()) {
|
||||
auto entry = static_cast<Native2WrappedNativeMap::Entry*>(i.Get());
|
||||
XPCWrappedNative* wrapper = entry->value;
|
||||
if (wrapper->IsValid()) {
|
||||
wrapper->SystemIsBeingShutDown();
|
||||
}
|
||||
i.Remove();
|
||||
}
|
||||
}
|
||||
|
||||
// Now it is safe to kill all the scopes.
|
||||
@@ -807,23 +742,6 @@ XPCWrappedNativeScope::DebugDumpAllScopes(int16_t depth)
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
static PLDHashOperator
|
||||
WrappedNativeMapDumpEnumerator(PLDHashTable* table, PLDHashEntryHdr* hdr,
|
||||
uint32_t number, void* arg)
|
||||
{
|
||||
((Native2WrappedNativeMap::Entry*)hdr)->value->DebugDump(*(int16_t*)arg);
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
static PLDHashOperator
|
||||
WrappedNativeProtoMapDumpEnumerator(PLDHashTable* table, PLDHashEntryHdr* hdr,
|
||||
uint32_t number, void* arg)
|
||||
{
|
||||
((ClassInfo2WrappedNativeProtoMap::Entry*)hdr)->value->DebugDump(*(int16_t*)arg);
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
XPCWrappedNativeScope::DebugDump(int16_t depth)
|
||||
{
|
||||
@@ -840,7 +758,10 @@ XPCWrappedNativeScope::DebugDump(int16_t depth)
|
||||
// iterate contexts...
|
||||
if (depth && mWrappedNativeMap->Count()) {
|
||||
XPC_LOG_INDENT();
|
||||
mWrappedNativeMap->Enumerate(WrappedNativeMapDumpEnumerator, &depth);
|
||||
for (auto i = mWrappedNativeMap->Iter(); !i.Done(); i.Next()) {
|
||||
auto entry = static_cast<Native2WrappedNativeMap::Entry*>(i.Get());
|
||||
entry->value->DebugDump(depth);
|
||||
}
|
||||
XPC_LOG_OUTDENT();
|
||||
}
|
||||
|
||||
@@ -850,7 +771,10 @@ XPCWrappedNativeScope::DebugDump(int16_t depth)
|
||||
// iterate contexts...
|
||||
if (depth && mWrappedNativeProtoMap->Count()) {
|
||||
XPC_LOG_INDENT();
|
||||
mWrappedNativeProtoMap->Enumerate(WrappedNativeProtoMapDumpEnumerator, &depth);
|
||||
for (auto i = mWrappedNativeProtoMap->Iter(); !i.Done(); i.Next()) {
|
||||
auto entry = static_cast<ClassInfo2WrappedNativeProtoMap::Entry*>(i.Get());
|
||||
entry->value->DebugDump(depth);
|
||||
}
|
||||
XPC_LOG_OUTDENT();
|
||||
}
|
||||
XPC_LOG_OUTDENT();
|
||||
|
||||
@@ -57,8 +57,6 @@ static const char* kSelectionCaretsLogModuleName = "SelectionCarets";
|
||||
// We treat mouse/touch move as "REAL" move event once its move distance
|
||||
// exceed this value, in CSS pixel.
|
||||
static const int32_t kMoveStartTolerancePx = 5;
|
||||
// Time for trigger scroll end event, in miliseconds.
|
||||
static const int32_t kScrollEndTimerDelay = 300;
|
||||
|
||||
NS_IMPL_ISUPPORTS(SelectionCarets,
|
||||
nsIReflowObserver,
|
||||
@@ -67,6 +65,9 @@ NS_IMPL_ISUPPORTS(SelectionCarets,
|
||||
nsISupportsWeakReference)
|
||||
|
||||
/*static*/ int32_t SelectionCarets::sSelectionCaretsInflateSize = 0;
|
||||
/*static*/ bool SelectionCarets::sSelectionCaretDetectsLongTap = true;
|
||||
/*static*/ bool SelectionCarets::sCaretManagesAndroidActionbar = false;
|
||||
/*static*/ bool SelectionCarets::sSelectionCaretObservesCompositions = false;
|
||||
|
||||
SelectionCarets::SelectionCarets(nsIPresShell* aPresShell)
|
||||
: mPresShell(aPresShell)
|
||||
@@ -79,6 +80,7 @@ SelectionCarets::SelectionCarets(nsIPresShell* aPresShell)
|
||||
, mStartCaretVisible(false)
|
||||
, mSelectionVisibleInScrollFrames(true)
|
||||
, mVisible(false)
|
||||
, mActionBarViewID(0)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
@@ -92,6 +94,12 @@ SelectionCarets::SelectionCarets(nsIPresShell* aPresShell)
|
||||
if (!addedPref) {
|
||||
Preferences::AddIntVarCache(&sSelectionCaretsInflateSize,
|
||||
"selectioncaret.inflatesize.threshold");
|
||||
Preferences::AddBoolVarCache(&sSelectionCaretDetectsLongTap,
|
||||
"selectioncaret.detects.longtap", true);
|
||||
Preferences::AddBoolVarCache(&sCaretManagesAndroidActionbar,
|
||||
"caret.manages-android-actionbar");
|
||||
Preferences::AddBoolVarCache(&sSelectionCaretObservesCompositions,
|
||||
"selectioncaret.observes.compositions");
|
||||
addedPref = true;
|
||||
}
|
||||
}
|
||||
@@ -255,13 +263,16 @@ SelectionCarets::HandleEvent(WidgetEvent* aEvent)
|
||||
nsPresContext::AppUnitsPerCSSPixel() * kMoveStartTolerancePx) {
|
||||
CancelLongTapDetector();
|
||||
}
|
||||
|
||||
} else if (aEvent->message == NS_MOUSE_MOZLONGTAP) {
|
||||
if (!mVisible) {
|
||||
SELECTIONCARETS_LOG("SelectWord from APZ");
|
||||
if (!mVisible || !sSelectionCaretDetectsLongTap) {
|
||||
SELECTIONCARETS_LOG("SelectWord from NS_MOUSE_MOZLONGTAP");
|
||||
|
||||
mDownPoint = ptInRoot;
|
||||
nsresult wordSelected = SelectWord();
|
||||
|
||||
if (NS_FAILED(wordSelected)) {
|
||||
SELECTIONCARETS_LOG("SelectWord from APZ failed!")
|
||||
SELECTIONCARETS_LOG("SelectWord from NS_MOUSE_MOZLONGTAP failed!");
|
||||
return nsEventStatus_eIgnore;
|
||||
}
|
||||
|
||||
@@ -308,6 +319,11 @@ SelectionCarets::SetVisibility(bool aVisible)
|
||||
|
||||
dom::Element* endElement = mPresShell->GetSelectionCaretsEndElement();
|
||||
SetElementVisibility(endElement, mVisible && mEndCaretVisible);
|
||||
|
||||
// Update the Android Actionbar visibility if in use.
|
||||
if (sCaretManagesAndroidActionbar) {
|
||||
TouchCaret::UpdateAndroidActionBarVisibility(mVisible, mActionBarViewID);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1105,12 +1121,46 @@ SelectionCarets::NotifySelectionChanged(nsIDOMDocument* aDoc,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (!aReason || (aReason & (nsISelectionListener::DRAG_REASON |
|
||||
nsISelectionListener::KEYPRESS_REASON |
|
||||
nsISelectionListener::MOUSEDOWN_REASON))) {
|
||||
SetVisibility(false);
|
||||
// Update SelectionCaret visibility.
|
||||
if (sSelectionCaretObservesCompositions) {
|
||||
// When observing selection change notifications generated for example
|
||||
// by Android soft-keyboard compositions, we can only obtain visibility
|
||||
// after mouse-up by long-tap, or final caret-drag.
|
||||
if (!mVisible) {
|
||||
if (aReason & nsISelectionListener::MOUSEUP_REASON) {
|
||||
UpdateSelectionCarets();
|
||||
}
|
||||
} else {
|
||||
// If already visible, we hide immediately for some known
|
||||
// event-reasons: drag, keypress, or mouse down.
|
||||
if (aReason & (nsISelectionListener::DRAG_REASON |
|
||||
nsISelectionListener::KEYPRESS_REASON |
|
||||
nsISelectionListener::MOUSEDOWN_REASON)) {
|
||||
SetVisibility(false);
|
||||
} else {
|
||||
// Else we look further at the selection status, as currently
|
||||
// style-composition changes don't provide reason codes.
|
||||
UpdateSelectionCarets();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
UpdateSelectionCarets();
|
||||
// Default logic, mainly employed by b2g, isn't aware of soft-keyboard
|
||||
// selection change compositions.
|
||||
if (!aReason || (aReason & (nsISelectionListener::DRAG_REASON |
|
||||
nsISelectionListener::KEYPRESS_REASON |
|
||||
nsISelectionListener::MOUSEDOWN_REASON))) {
|
||||
SetVisibility(false);
|
||||
} else {
|
||||
UpdateSelectionCarets();
|
||||
}
|
||||
}
|
||||
|
||||
// Maybe trigger Android ActionBar updates.
|
||||
if (mVisible && sCaretManagesAndroidActionbar) {
|
||||
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
||||
if (os) {
|
||||
os->NotifyObservers(nullptr, "ActionBar:UpdateState", nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
DispatchSelectionStateChangedEvent(static_cast<Selection*>(aSel),
|
||||
@@ -1142,7 +1192,10 @@ SelectionCarets::AsyncPanZoomStarted()
|
||||
{
|
||||
if (mVisible) {
|
||||
mInAsyncPanZoomGesture = true;
|
||||
SetVisibility(false);
|
||||
// Hide selection carets if not using ActionBar.
|
||||
if (!sCaretManagesAndroidActionbar) {
|
||||
SetVisibility(false);
|
||||
}
|
||||
|
||||
SELECTIONCARETS_LOG("Dispatch scroll started");
|
||||
DispatchScrollViewChangeEvent(mPresShell, dom::ScrollState::Started);
|
||||
@@ -1178,7 +1231,11 @@ SelectionCarets::ScrollPositionChanged()
|
||||
{
|
||||
if (mVisible) {
|
||||
if (!mUseAsyncPanZoom) {
|
||||
SetVisibility(false);
|
||||
// Hide selection carets if not using ActionBar.
|
||||
if (!sCaretManagesAndroidActionbar) {
|
||||
SetVisibility(false);
|
||||
}
|
||||
|
||||
//TODO: handling scrolling for selection bubble when APZ is off
|
||||
// Dispatch event to notify gaia to hide selection bubble.
|
||||
// Positions will be updated when scroll is end, so no need to calculate
|
||||
@@ -1206,7 +1263,7 @@ SelectionCarets::ScrollPositionChanged()
|
||||
void
|
||||
SelectionCarets::LaunchLongTapDetector()
|
||||
{
|
||||
if (mUseAsyncPanZoom) {
|
||||
if (!sSelectionCaretDetectsLongTap || mUseAsyncPanZoom) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1264,10 +1321,11 @@ SelectionCarets::LaunchScrollEndDetector()
|
||||
|
||||
MOZ_ASSERT(mScrollEndDetectorTimer);
|
||||
|
||||
SELECTIONCARETS_LOG("Will fire scroll end after %d ms", kScrollEndTimerDelay);
|
||||
SELECTIONCARETS_LOG("Will fire scroll end after %d ms",
|
||||
TouchCaret::sScrollEndTimerDelay);
|
||||
mScrollEndDetectorTimer->InitWithFuncCallback(FireScrollEnd,
|
||||
this,
|
||||
kScrollEndTimerDelay,
|
||||
TouchCaret::sScrollEndTimerDelay,
|
||||
nsITimer::TYPE_ONE_SHOT);
|
||||
}
|
||||
|
||||
|
||||
@@ -101,11 +101,6 @@ public:
|
||||
return sSelectionCaretsInflateSize;
|
||||
}
|
||||
|
||||
private:
|
||||
virtual ~SelectionCarets();
|
||||
|
||||
SelectionCarets() = delete;
|
||||
|
||||
/**
|
||||
* Set visibility for selection caret.
|
||||
*/
|
||||
@@ -116,6 +111,11 @@ private:
|
||||
*/
|
||||
void UpdateSelectionCarets();
|
||||
|
||||
private:
|
||||
virtual ~SelectionCarets();
|
||||
|
||||
SelectionCarets() = delete;
|
||||
|
||||
/**
|
||||
* Select a word base on current position, which activates only if element is
|
||||
* selectable. Triggered by long tap event.
|
||||
@@ -266,6 +266,12 @@ private:
|
||||
|
||||
// Preference
|
||||
static int32_t sSelectionCaretsInflateSize;
|
||||
static bool sSelectionCaretDetectsLongTap;
|
||||
static bool sCaretManagesAndroidActionbar;
|
||||
static bool sSelectionCaretObservesCompositions;
|
||||
|
||||
// Unique ID of current Mobile ActionBar view.
|
||||
uint32_t mActionBarViewID;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
+197
-8
@@ -56,17 +56,26 @@ static const char* kTouchCaretLogModuleName = "TouchCaret";
|
||||
// boundary by 61 app units (1 pixel + 1 app unit).
|
||||
static const int32_t kBoundaryAppUnits = 61;
|
||||
|
||||
NS_IMPL_ISUPPORTS(TouchCaret, nsISelectionListener)
|
||||
NS_IMPL_ISUPPORTS(TouchCaret,
|
||||
nsISelectionListener,
|
||||
nsIScrollObserver,
|
||||
nsISupportsWeakReference)
|
||||
|
||||
/*static*/ int32_t TouchCaret::sTouchCaretInflateSize = 0;
|
||||
/*static*/ int32_t TouchCaret::sTouchCaretExpirationTime = 0;
|
||||
/*static*/ bool TouchCaret::sCaretManagesAndroidActionbar = false;
|
||||
/*static*/ bool TouchCaret::sTouchcaretExtendedvisibility = false;
|
||||
|
||||
/*static*/ uint32_t TouchCaret::sActionBarViewCount = 0;
|
||||
|
||||
TouchCaret::TouchCaret(nsIPresShell* aPresShell)
|
||||
: mState(TOUCHCARET_NONE),
|
||||
mActiveTouchId(-1),
|
||||
mCaretCenterToDownPointOffsetY(0),
|
||||
mInAsyncPanZoomGesture(false),
|
||||
mVisible(false),
|
||||
mIsValidTap(false)
|
||||
mIsValidTap(false),
|
||||
mActionBarViewID(0)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
@@ -82,6 +91,10 @@ TouchCaret::TouchCaret(nsIPresShell* aPresShell)
|
||||
"touchcaret.inflatesize.threshold");
|
||||
Preferences::AddIntVarCache(&sTouchCaretExpirationTime,
|
||||
"touchcaret.expiration.time");
|
||||
Preferences::AddBoolVarCache(&sCaretManagesAndroidActionbar,
|
||||
"caret.manages-android-actionbar");
|
||||
Preferences::AddBoolVarCache(&sTouchcaretExtendedvisibility,
|
||||
"touchcaret.extendedvisibility");
|
||||
addedTouchCaretPref = true;
|
||||
}
|
||||
|
||||
@@ -90,6 +103,43 @@ TouchCaret::TouchCaret(nsIPresShell* aPresShell)
|
||||
MOZ_ASSERT(mPresShell, "Hey, pres shell should support weak refs");
|
||||
}
|
||||
|
||||
void
|
||||
TouchCaret::Init()
|
||||
{
|
||||
nsCOMPtr<nsIPresShell> presShell = do_QueryReferent(mPresShell);
|
||||
if (!presShell) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsPresContext* presContext = presShell->GetPresContext();
|
||||
MOZ_ASSERT(presContext, "PresContext should be given in PresShell::Init()");
|
||||
|
||||
nsIDocShell* docShell = presContext->GetDocShell();
|
||||
if (!docShell) {
|
||||
return;
|
||||
}
|
||||
|
||||
docShell->AddWeakScrollObserver(this);
|
||||
mDocShell = static_cast<nsDocShell*>(docShell);
|
||||
}
|
||||
|
||||
void
|
||||
TouchCaret::Terminate()
|
||||
{
|
||||
nsRefPtr<nsDocShell> docShell(mDocShell.get());
|
||||
if (docShell) {
|
||||
docShell->RemoveWeakScrollObserver(this);
|
||||
}
|
||||
|
||||
if (mScrollEndDetectorTimer) {
|
||||
mScrollEndDetectorTimer->Cancel();
|
||||
mScrollEndDetectorTimer = nullptr;
|
||||
}
|
||||
|
||||
mDocShell = WeakPtr<nsDocShell>();
|
||||
mPresShell = nullptr;
|
||||
}
|
||||
|
||||
TouchCaret::~TouchCaret()
|
||||
{
|
||||
TOUCHCARET_LOG("Destructor");
|
||||
@@ -174,6 +224,38 @@ TouchCaret::SetVisibility(bool aVisible)
|
||||
|
||||
// Set touch caret expiration time.
|
||||
mVisible ? LaunchExpirationTimer() : CancelExpirationTimer();
|
||||
|
||||
// If after a TouchCaret visibility change we become hidden, ensure
|
||||
// the Android ActionBar handler is notified to close the current view.
|
||||
if (!mVisible && sCaretManagesAndroidActionbar) {
|
||||
UpdateAndroidActionBarVisibility(false, mActionBarViewID);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Open or close the Android TextSelection ActionBar, based on visibility.
|
||||
* Each time we're called to open the actionbar, we increment / assign a
|
||||
* unique view ID and return it to the caller. The ID is returned on calls
|
||||
* to close the actionbar to ensure we don't close the shared view if it
|
||||
* was already force closed by a subsequent callers open request.
|
||||
*/
|
||||
/* static */void
|
||||
TouchCaret::UpdateAndroidActionBarVisibility(bool aVisibility, uint32_t& aViewID)
|
||||
{
|
||||
// Are we openning a new view?
|
||||
if (aVisibility) {
|
||||
// Assign a new view ID.
|
||||
aViewID = ++sActionBarViewCount;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
||||
if (os) {
|
||||
nsString topic = (aVisibility) ?
|
||||
NS_LITERAL_STRING("ActionBar:OpenNew") : NS_LITERAL_STRING("ActionBar:Close");
|
||||
nsAutoString viewCount;
|
||||
viewCount.AppendInt(aViewID);
|
||||
os->NotifyObservers(nullptr, NS_ConvertUTF16toUTF8(topic).get(), viewCount.get());
|
||||
}
|
||||
}
|
||||
|
||||
nsRect
|
||||
@@ -359,11 +441,100 @@ TouchCaret::NotifySelectionChanged(nsIDOMDocument* aDoc, nsISelection* aSel,
|
||||
SetVisibility(false);
|
||||
} else {
|
||||
SyncVisibilityWithCaret();
|
||||
|
||||
// Is the TouchCaret visible and we're showing/hiding the actionbar?
|
||||
if (mVisible && sCaretManagesAndroidActionbar) {
|
||||
// A selection change due to touch tap opens the actionbar.
|
||||
if (aReason & nsISelectionListener::MOUSEUP_REASON) {
|
||||
UpdateAndroidActionBarVisibility(true, mActionBarViewID);
|
||||
} else {
|
||||
// Update the ActionBar state for caret-specific selection changes.
|
||||
// Ignore transient selection composition changes that occur while
|
||||
// the TouchCaret is also visible.
|
||||
bool isCollapsed;
|
||||
if (NS_SUCCEEDED(aSel->GetIsCollapsed(&isCollapsed)) && isCollapsed) {
|
||||
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
||||
if (os) {
|
||||
os->NotifyObservers(nullptr, "ActionBar:UpdateState", nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to update caret position after PanZoom stops for
|
||||
* extended caret visibility. Never needed by MOZ_WIDGET_GONK.
|
||||
*/
|
||||
void
|
||||
TouchCaret::AsyncPanZoomStarted()
|
||||
{
|
||||
if (mVisible) {
|
||||
if (sTouchcaretExtendedvisibility) {
|
||||
mInAsyncPanZoomGesture = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
TouchCaret::AsyncPanZoomStopped()
|
||||
{
|
||||
if (mInAsyncPanZoomGesture) {
|
||||
mInAsyncPanZoomGesture = false;
|
||||
UpdatePosition();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to update caret position after Scroll stops for
|
||||
* extended caret visibility. Never needed by MOZ_WIDGET_GONK.
|
||||
*/
|
||||
void
|
||||
TouchCaret::ScrollPositionChanged()
|
||||
{
|
||||
if (mVisible) {
|
||||
if (sTouchcaretExtendedvisibility) {
|
||||
// Launch scroll end detector.
|
||||
LaunchScrollEndDetector();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
TouchCaret::LaunchScrollEndDetector()
|
||||
{
|
||||
if (!mScrollEndDetectorTimer) {
|
||||
mScrollEndDetectorTimer = do_CreateInstance("@mozilla.org/timer;1");
|
||||
}
|
||||
MOZ_ASSERT(mScrollEndDetectorTimer);
|
||||
|
||||
mScrollEndDetectorTimer->InitWithFuncCallback(FireScrollEnd,
|
||||
this,
|
||||
sScrollEndTimerDelay,
|
||||
nsITimer::TYPE_ONE_SHOT);
|
||||
}
|
||||
|
||||
void
|
||||
TouchCaret::CancelScrollEndDetector()
|
||||
{
|
||||
if (mScrollEndDetectorTimer) {
|
||||
mScrollEndDetectorTimer->Cancel();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* static */void
|
||||
TouchCaret::FireScrollEnd(nsITimer* aTimer, void* aTouchCaret)
|
||||
{
|
||||
nsRefPtr<TouchCaret> self = static_cast<TouchCaret*>(aTouchCaret);
|
||||
NS_PRECONDITION(aTimer == self->mScrollEndDetectorTimer,
|
||||
"Unexpected timer");
|
||||
self->UpdatePosition();
|
||||
}
|
||||
|
||||
void
|
||||
TouchCaret::SyncVisibilityWithCaret()
|
||||
{
|
||||
@@ -444,10 +615,6 @@ TouchCaret::IsDisplayable()
|
||||
TOUCHCARET_LOG("Focus frame is not valid!");
|
||||
return false;
|
||||
}
|
||||
if (focusRect.IsEmpty()) {
|
||||
TOUCHCARET_LOG("Focus rect is empty!");
|
||||
return false;
|
||||
}
|
||||
|
||||
dom::Element* editingHost = focusFrame->GetContent()->GetEditingHost();
|
||||
if (!editingHost) {
|
||||
@@ -455,6 +622,16 @@ TouchCaret::IsDisplayable()
|
||||
return false;
|
||||
}
|
||||
|
||||
// No further checks required if extended TouchCaret visibility.
|
||||
if (sTouchcaretExtendedvisibility) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (focusRect.IsEmpty()) {
|
||||
TOUCHCARET_LOG("Focus rect is empty!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!nsContentUtils::HasNonEmptyTextContent(
|
||||
editingHost, nsContentUtils::eRecurseIntoChildren)) {
|
||||
TOUCHCARET_LOG("The content is empty!");
|
||||
@@ -839,6 +1016,12 @@ TouchCaret::HandleMouseDownEvent(WidgetMouseEvent* aEvent)
|
||||
CancelExpirationTimer();
|
||||
status = nsEventStatus_eConsumeNoDefault;
|
||||
} else {
|
||||
// Mousedown events that miss HitTest can be caused by soft-keyboard
|
||||
// auto-suggestions. If extended visibility, update the caret position.
|
||||
if (sTouchcaretExtendedvisibility) {
|
||||
UpdatePositionIfNeeded();
|
||||
break;
|
||||
}
|
||||
// Set touch caret invisible if HisTest fails. Bypass event.
|
||||
SetVisibility(false);
|
||||
status = nsEventStatus_eIgnore;
|
||||
@@ -899,8 +1082,14 @@ TouchCaret::HandleTouchDownEvent(WidgetTouchEvent* aEvent)
|
||||
// No touch is on the touch caret. Set touch caret invisible, and bypass
|
||||
// the event.
|
||||
if (mActiveTouchId == -1) {
|
||||
SetVisibility(false);
|
||||
status = nsEventStatus_eIgnore;
|
||||
// Check touch caret visibility style.
|
||||
if (sTouchcaretExtendedvisibility) {
|
||||
// Update position on events associated with scroll and pan-zoom.
|
||||
UpdatePositionIfNeeded();
|
||||
} else {
|
||||
SetVisibility(false);
|
||||
status = nsEventStatus_eIgnore;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -27,7 +27,9 @@ namespace mozilla {
|
||||
* TouchCaret is also responsible for touch caret visibility. Touch caret
|
||||
* won't be shown when timer expires or while key event causes selection change.
|
||||
*/
|
||||
class TouchCaret final : public nsISelectionListener
|
||||
class TouchCaret final : public nsISelectionListener,
|
||||
public nsIScrollObserver,
|
||||
public nsSupportsWeakReference
|
||||
{
|
||||
public:
|
||||
explicit TouchCaret(nsIPresShell* aPresShell);
|
||||
@@ -35,10 +37,15 @@ public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSISELECTIONLISTENER
|
||||
|
||||
void Terminate()
|
||||
{
|
||||
mPresShell = nullptr;
|
||||
}
|
||||
void Init();
|
||||
void Terminate();
|
||||
|
||||
// nsIScrollObserver
|
||||
virtual void ScrollPositionChanged() override;
|
||||
|
||||
// AsyncPanZoom started/stopped callbacks from nsIScrollObserver
|
||||
virtual void AsyncPanZoomStarted() override;
|
||||
virtual void AsyncPanZoomStopped() override;
|
||||
|
||||
/**
|
||||
* Handle mouse and touch event only.
|
||||
@@ -60,6 +67,11 @@ public:
|
||||
return mVisible;
|
||||
}
|
||||
|
||||
/**
|
||||
* Open or close the Android TextSelection ActionBar based on visibility.
|
||||
*/
|
||||
static void UpdateAndroidActionBarVisibility(bool aVisibility, uint32_t& aViewID);
|
||||
|
||||
private:
|
||||
// Hide default constructor.
|
||||
TouchCaret() = delete;
|
||||
@@ -268,7 +280,21 @@ private:
|
||||
return sTouchCaretExpirationTime;
|
||||
}
|
||||
|
||||
void LaunchScrollEndDetector();
|
||||
void CancelScrollEndDetector();
|
||||
static void FireScrollEnd(nsITimer* aTimer, void* aSelectionCarets);
|
||||
|
||||
// This timer is used for detecting scroll end. We don't have
|
||||
// scroll end event now, so we will fire this event with a
|
||||
// const time when we scroll. So when timer triggers, we treat it
|
||||
// as scroll end event.
|
||||
nsCOMPtr<nsITimer> mScrollEndDetectorTimer;
|
||||
|
||||
nsWeakPtr mPresShell;
|
||||
WeakPtr<nsDocShell> mDocShell;
|
||||
|
||||
// True if AsyncPanZoom is started
|
||||
bool mInAsyncPanZoomGesture;
|
||||
|
||||
// Touch caret visibility
|
||||
bool mVisible;
|
||||
@@ -280,10 +306,18 @@ private:
|
||||
// Preference
|
||||
static int32_t sTouchCaretInflateSize;
|
||||
static int32_t sTouchCaretExpirationTime;
|
||||
static bool sCaretManagesAndroidActionbar;
|
||||
static bool sTouchcaretExtendedvisibility;
|
||||
|
||||
// The auto scroll timer's interval in miliseconds.
|
||||
friend class SelectionCarets;
|
||||
static const int32_t sAutoScrollTimerDelay = 30;
|
||||
// Time for trigger scroll end event, in miliseconds.
|
||||
static const int32_t sScrollEndTimerDelay = 300;
|
||||
|
||||
// Unique ID of current Mobile ActionBar view.
|
||||
static uint32_t sActionBarViewCount;
|
||||
uint32_t mActionBarViewID;
|
||||
};
|
||||
} //namespace mozilla
|
||||
#endif //mozilla_TouchCaret_h__
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "nsTextFrame.h"
|
||||
#include "nsBlockFrame.h"
|
||||
#include "nsIFrameInlines.h"
|
||||
#include "nsStyleStructInlines.h"
|
||||
#include "RubyUtils.h"
|
||||
#include "nsRubyFrame.h"
|
||||
#include "nsRubyBaseFrame.h"
|
||||
@@ -700,31 +701,44 @@ nsBidiPresUtils::ResolveParagraph(nsBlockFrame* aBlockFrame,
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (runCount == 1 && frameCount == 1 &&
|
||||
bool isNonBidi = false;
|
||||
|
||||
nsIFrame* frame0 = frameCount > 0 ? aBpd->FrameAt(0) : nullptr;
|
||||
nsIFrame* frame1 = frameCount > 1 ? aBpd->FrameAt(1) : nullptr;
|
||||
|
||||
// Non-bidi frames
|
||||
if (runCount == 1 && (frameCount == 1 || frameCount == 2) &&
|
||||
aBpd->mParagraphDepth == 0 && aBpd->GetDirection() == NSBIDI_LTR &&
|
||||
aBpd->GetParaLevel() == 0) {
|
||||
// We have a single left-to-right frame in a left-to-right paragraph,
|
||||
aBpd->GetParaLevel() == 0 &&
|
||||
frame0 != NS_BIDI_CONTROL_FRAME &&
|
||||
!frame0->Properties().Get(nsIFrame::EmbeddingLevelProperty()) &&
|
||||
!frame0->Properties().Get(nsIFrame::BaseLevelProperty())) {
|
||||
// We have a left-to-right frame in a left-to-right paragraph,
|
||||
// without bidi isolation from the surrounding text.
|
||||
// Make sure that the embedding level and base level frame properties aren't
|
||||
// The embedding level and base level frame properties aren't
|
||||
// set (because if they are this frame used to have some other direction,
|
||||
// so we can't do this optimization), and we're done.
|
||||
nsIFrame* frame = aBpd->FrameAt(0);
|
||||
if (frame != NS_BIDI_CONTROL_FRAME &&
|
||||
!frame->Properties().Get(nsIFrame::EmbeddingLevelProperty()) &&
|
||||
!frame->Properties().Get(nsIFrame::BaseLevelProperty())) {
|
||||
// so we can't do this optimization)
|
||||
// As long as this is the only frame, or it's followed by a linebreak,
|
||||
// this is a non-bidi paragraph.
|
||||
if (!frame1 || (frame1 != NS_BIDI_CONTROL_FRAME &&
|
||||
frame1->GetType() == nsGkAtoms::brFrame)) {
|
||||
isNonBidi = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (isNonBidi) {
|
||||
#ifdef DEBUG
|
||||
#ifdef NOISY_BIDI
|
||||
printf("early return for single direction frame %p\n", (void*)frame);
|
||||
printf("early return for single direction frame %p\n", (void*)frame);
|
||||
#endif
|
||||
#endif
|
||||
frame->AddStateBits(NS_FRAME_IS_BIDI);
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIFrame* firstFrame = nullptr;
|
||||
nsIFrame* lastFrame = nullptr;
|
||||
|
||||
// Bidi frames
|
||||
for (; ;) {
|
||||
if (fragmentLength <= 0) {
|
||||
// Get the next frame from mLogicalFrames
|
||||
@@ -1037,7 +1051,7 @@ nsBidiPresUtils::TraverseFrames(nsBlockFrame* aBlockFrame,
|
||||
if (nsGkAtoms::textFrame == frameType) {
|
||||
if (content != aBpd->mPrevContent) {
|
||||
aBpd->mPrevContent = content;
|
||||
if (!frame->StyleText()->NewlineIsSignificant()) {
|
||||
if (!frame->StyleText()->NewlineIsSignificant(frame)) {
|
||||
content->AppendTextTo(aBpd->mBuffer);
|
||||
} else {
|
||||
/*
|
||||
|
||||
+81
-26
@@ -46,6 +46,9 @@ using namespace mozilla::gfx;
|
||||
// an insignificant dot
|
||||
static const int32_t kMinBidiIndicatorPixels = 2;
|
||||
|
||||
/*static*/ bool nsCaret::sSelectionCaretEnabled = false;
|
||||
/*static*/ bool nsCaret::sSelectionCaretsAffectCaret = false;
|
||||
|
||||
/**
|
||||
* Find the first frame in an in-order traversal of the frame subtree rooted
|
||||
* at aFrame which is either a text frame logically at the end of a line,
|
||||
@@ -112,20 +115,20 @@ AdjustCaretFrameForLineEnd(nsIFrame** aFrame, int32_t* aOffset)
|
||||
}
|
||||
|
||||
static bool
|
||||
IsBidiUI()
|
||||
IsKeyboardRTL()
|
||||
{
|
||||
return Preferences::GetBool("bidi.browser.ui");
|
||||
}
|
||||
|
||||
static bool
|
||||
CjkThickCaret()
|
||||
{
|
||||
return Preferences::GetBool("layout.cjkthickcaret");
|
||||
bool isKeyboardRTL = false;
|
||||
nsIBidiKeyboard* bidiKeyboard = nsContentUtils::GetBidiKeyboard();
|
||||
if (bidiKeyboard) {
|
||||
bidiKeyboard->IsLangRTL(&isKeyboardRTL);
|
||||
}
|
||||
return isKeyboardRTL;
|
||||
}
|
||||
|
||||
nsCaret::nsCaret()
|
||||
: mOverrideOffset(0)
|
||||
, mIsBlinkOn(false)
|
||||
, mBlinkCount(-1)
|
||||
, mVisible(false)
|
||||
, mReadOnly(false)
|
||||
, mShowDuringSelection(false)
|
||||
@@ -149,6 +152,15 @@ nsresult nsCaret::Init(nsIPresShell *inPresShell)
|
||||
LookAndFeel::GetInt(LookAndFeel::eIntID_ShowCaretDuringSelection,
|
||||
mShowDuringSelection ? 1 : 0) != 0;
|
||||
|
||||
static bool addedCaretPref = false;
|
||||
if (!addedCaretPref) {
|
||||
Preferences::AddBoolVarCache(&sSelectionCaretEnabled,
|
||||
"selectioncaret.enabled");
|
||||
Preferences::AddBoolVarCache(&sSelectionCaretsAffectCaret,
|
||||
"selectioncaret.visibility.affectscaret");
|
||||
addedCaretPref = true;
|
||||
}
|
||||
|
||||
// get the selection from the pres shell, and set ourselves up as a selection
|
||||
// listener
|
||||
|
||||
@@ -194,7 +206,7 @@ nsCaret::ComputeMetrics(nsIFrame* aFrame, int32_t aOffset, nscoord aCaretHeight)
|
||||
nsPresContext::CSSPixelsToAppUnits(
|
||||
LookAndFeel::GetInt(LookAndFeel::eIntID_CaretWidth, 1));
|
||||
|
||||
if (DrawCJKCaret(aFrame, aOffset) && CjkThickCaret()) {
|
||||
if (DrawCJKCaret(aFrame, aOffset)) {
|
||||
caretWidth += nsPresContext::CSSPixelsToAppUnits(1);
|
||||
}
|
||||
nscoord bidiIndicatorSize = nsPresContext::CSSPixelsToAppUnits(kMinBidiIndicatorPixels);
|
||||
@@ -258,7 +270,8 @@ bool nsCaret::IsVisible()
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!mShowDuringSelection) {
|
||||
if (!mShowDuringSelection &&
|
||||
!(sSelectionCaretEnabled && sSelectionCaretsAffectCaret)) {
|
||||
Selection* selection = GetSelectionInternal();
|
||||
if (!selection) {
|
||||
return false;
|
||||
@@ -269,6 +282,20 @@ bool nsCaret::IsVisible()
|
||||
}
|
||||
}
|
||||
|
||||
// The Android IME can have a visible caret when there is a composition
|
||||
// selection, due to auto-suggest/auto-correct styling (underlining),
|
||||
// but never when the SelectionCarets are visible.
|
||||
if (sSelectionCaretEnabled && sSelectionCaretsAffectCaret) {
|
||||
nsCOMPtr<nsISelectionController> selCon = do_QueryReferent(mPresShell);
|
||||
if (selCon) {
|
||||
bool visible = false;
|
||||
selCon->GetSelectionCaretsVisibility(&visible);
|
||||
if (visible) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (IsMenuPopupHidingCaret()) {
|
||||
return false;
|
||||
}
|
||||
@@ -456,6 +483,21 @@ nsCaret::SetCaretPosition(nsIDOMNode* aNode, int32_t aOffset)
|
||||
SchedulePaint();
|
||||
}
|
||||
|
||||
bool
|
||||
nsCaret::IsBidiUI()
|
||||
{
|
||||
nsIFrame* frame = nullptr;
|
||||
|
||||
if(Selection* selection = GetSelectionInternal()) {
|
||||
int32_t contentOffset;
|
||||
frame = GetFrameAndOffset(selection, mOverrideContent, mOverrideOffset,
|
||||
&contentOffset);
|
||||
}
|
||||
|
||||
return (frame && frame->GetStateBits() & NS_FRAME_IS_BIDI) ||
|
||||
Preferences::GetBool("bidi.browser.ui");
|
||||
}
|
||||
|
||||
void
|
||||
nsCaret::CheckSelectionLanguageChange()
|
||||
{
|
||||
@@ -463,11 +505,8 @@ nsCaret::CheckSelectionLanguageChange()
|
||||
return;
|
||||
}
|
||||
|
||||
bool isKeyboardRTL = false;
|
||||
nsIBidiKeyboard* bidiKeyboard = nsContentUtils::GetBidiKeyboard();
|
||||
if (bidiKeyboard) {
|
||||
bidiKeyboard->IsLangRTL(&isKeyboardRTL);
|
||||
}
|
||||
bool isKeyboardRTL = IsKeyboardRTL();
|
||||
|
||||
// Call SelectionLanguageChange on every paint. Mostly it will be a noop
|
||||
// but it should be fast anyway. This guarantees we never paint the caret
|
||||
// at the wrong place.
|
||||
@@ -600,6 +639,7 @@ void nsCaret::ResetBlinking()
|
||||
uint32_t blinkRate = static_cast<uint32_t>(
|
||||
LookAndFeel::GetInt(LookAndFeel::eIntID_CaretBlinkTime, 500));
|
||||
if (blinkRate > 0) {
|
||||
mBlinkCount = Preferences::GetInt("ui.caretBlinkCount", -1);
|
||||
mBlinkTimer->InitWithFuncCallback(CaretBlinkCallback, this, blinkRate,
|
||||
nsITimer::TYPE_REPEATING_SLACK);
|
||||
}
|
||||
@@ -652,11 +692,12 @@ nsCaret::GetCaretFrameForNodeOffset(nsFrameSelection* aFrameSelection,
|
||||
// ------------------
|
||||
// NS_STYLE_DIRECTION_LTR : LTR or Default
|
||||
// NS_STYLE_DIRECTION_RTL
|
||||
if (IsBidiUI())
|
||||
if (theFrame->PresContext()->BidiEnabled())
|
||||
{
|
||||
// If there has been a reflow, take the caret Bidi level to be the level of the current frame
|
||||
if (aBidiLevel & BIDI_LEVEL_UNDEFINED)
|
||||
if (aBidiLevel & BIDI_LEVEL_UNDEFINED) {
|
||||
aBidiLevel = NS_GET_EMBEDDING_LEVEL(theFrame);
|
||||
}
|
||||
|
||||
int32_t start;
|
||||
int32_t end;
|
||||
@@ -879,21 +920,22 @@ nsCaret::ComputeCaretRects(nsIFrame* aFrame, int32_t aFrameOffset,
|
||||
}
|
||||
}
|
||||
|
||||
// Simon -- make a hook to draw to the left or right of the caret to show keyboard language direction
|
||||
aHookRect->SetEmpty();
|
||||
if (!IsBidiUI()) {
|
||||
|
||||
Selection* selection = GetSelectionInternal();
|
||||
if (!selection || !selection->GetFrameSelection()) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool isCaretRTL;
|
||||
nsIBidiKeyboard* bidiKeyboard = nsContentUtils::GetBidiKeyboard();
|
||||
// if bidiKeyboard->IsLangRTL() fails, there is no way to tell the
|
||||
// keyboard direction, or the user has no right-to-left keyboard
|
||||
// installed, so we never draw the hook.
|
||||
if (bidiKeyboard && NS_SUCCEEDED(bidiKeyboard->IsLangRTL(&isCaretRTL))) {
|
||||
// If keyboard language is RTL, draw the hook on the left; if LTR, to the right
|
||||
if (IsBidiUI() || IsKeyboardRTL()) {
|
||||
// If caret level is RTL, draw the hook on the left; if LTR, to the right
|
||||
// The height of the hook rectangle is the same as the width of the caret
|
||||
// rectangle.
|
||||
int caretBidiLevel = selection->GetFrameSelection()->GetCaretBidiLevel();
|
||||
if (caretBidiLevel & BIDI_LEVEL_UNDEFINED) {
|
||||
caretBidiLevel = NS_GET_EMBEDDING_LEVEL(aFrame);
|
||||
}
|
||||
bool isCaretRTL = caretBidiLevel % 2;
|
||||
if (isVertical) {
|
||||
aHookRect->SetRect(aCaretRect->XMost() - bidiIndicatorSize,
|
||||
aCaretRect->y + (isCaretRTL ? bidiIndicatorSize * -1 :
|
||||
@@ -919,6 +961,19 @@ void nsCaret::CaretBlinkCallback(nsITimer* aTimer, void* aClosure)
|
||||
}
|
||||
theCaret->mIsBlinkOn = !theCaret->mIsBlinkOn;
|
||||
theCaret->SchedulePaint();
|
||||
|
||||
// mBlinkCount of -1 means blink count is not enabled.
|
||||
if (theCaret->mBlinkCount == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Track the blink count, but only at end of a blink cycle.
|
||||
if (!theCaret->mIsBlinkOn) {
|
||||
// If we exceeded the blink count, stop the timer.
|
||||
if (--theCaret->mBlinkCount <= 0) {
|
||||
theCaret->StopBlinking();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -158,6 +158,7 @@ class nsCaret final : public nsISelectionListener
|
||||
protected:
|
||||
static void CaretBlinkCallback(nsITimer *aTimer, void *aClosure);
|
||||
|
||||
bool IsBidiUI();
|
||||
void CheckSelectionLanguageChange();
|
||||
|
||||
void ResetBlinking();
|
||||
@@ -205,6 +206,12 @@ protected:
|
||||
* mIsBlinkOn is true when we're in a blink cycle where the caret is on.
|
||||
*/
|
||||
bool mIsBlinkOn;
|
||||
/**
|
||||
* mBlinkCount is used to control the number of times to blink the caret
|
||||
* before stopping the blink. This is reset each time we reset the
|
||||
* blinking.
|
||||
*/
|
||||
int32_t mBlinkCount;
|
||||
/**
|
||||
* mIsVisible is true when SetVisible was last called with 'true'.
|
||||
*/
|
||||
@@ -224,6 +231,10 @@ protected:
|
||||
* it's in non-user-modifiable content.
|
||||
*/
|
||||
bool mIgnoreUserModify;
|
||||
|
||||
// Preference
|
||||
static bool sSelectionCaretEnabled;
|
||||
static bool sSelectionCaretsAffectCaret;
|
||||
};
|
||||
|
||||
#endif //nsCaret_h__
|
||||
|
||||
@@ -908,6 +908,7 @@ PresShell::Init(nsIDocument* aDocument,
|
||||
if (TouchCaretPrefEnabled() && !AccessibleCaretEnabled()) {
|
||||
// Create touch caret handle
|
||||
mTouchCaret = new TouchCaret(this);
|
||||
mTouchCaret->Init();
|
||||
}
|
||||
|
||||
if (SelectionCaretPrefEnabled() && !AccessibleCaretEnabled()) {
|
||||
@@ -2571,6 +2572,26 @@ PresShell::CheckVisibilityContent(nsIContent* aNode, int16_t aStartOffset,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
PresShell::GetSelectionCaretsVisibility(bool* aOutVisibility)
|
||||
{
|
||||
*aOutVisibility = (SelectionCaretPrefEnabled() && mSelectionCarets->GetVisibility());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
PresShell::SetSelectionCaretsVisibility(bool aVisibility)
|
||||
{
|
||||
if (SelectionCaretPrefEnabled() && mSelectionCarets) {
|
||||
if (aVisibility) {
|
||||
mSelectionCarets->UpdateSelectionCarets();
|
||||
} else {
|
||||
mSelectionCarets->SetVisibility(false);
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//end implementations nsISelectionController
|
||||
|
||||
nsIFrame*
|
||||
|
||||
@@ -281,6 +281,9 @@ public:
|
||||
virtual nsresult CheckVisibilityContent(nsIContent* aNode, int16_t aStartOffset,
|
||||
int16_t aEndOffset, bool* aRetval) override;
|
||||
|
||||
NS_IMETHOD GetSelectionCaretsVisibility(bool* aOutVisibility) override;
|
||||
NS_IMETHOD SetSelectionCaretsVisibility(bool aVisibility) override;
|
||||
|
||||
// nsIDocumentObserver
|
||||
NS_DECL_NSIDOCUMENTOBSERVER_BEGINUPDATE
|
||||
NS_DECL_NSIDOCUMENTOBSERVER_ENDUPDATE
|
||||
|
||||
@@ -3,13 +3,14 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
</head>
|
||||
<body onload="start()">
|
||||
<textarea onfocus="done()" style="-moz-appearance: none">س</textarea>
|
||||
<textarea onfocus="done()" style="-moz-appearance: none">س‎</textarea>
|
||||
<script>
|
||||
var textarea = document.querySelector("textarea");
|
||||
function start() {
|
||||
textarea.focus();
|
||||
}
|
||||
function done() {
|
||||
textarea.selectionStart = textarea.selectionEnd = 2;
|
||||
document.documentElement.removeAttribute("class");
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
<html class="reftest-wait">
|
||||
<body onload="start()">
|
||||
<textarea dir="rtl" onfocus="done()" style="-moz-appearance: none">s</textarea>
|
||||
<textarea dir="rtl" onfocus="done()" style="-moz-appearance: none">s‏</textarea>
|
||||
<script>
|
||||
var textarea = document.querySelector("textarea");
|
||||
function start() {
|
||||
textarea.focus();
|
||||
}
|
||||
function done() {
|
||||
textarea.selectionStart = textarea.selectionEnd = 2;
|
||||
document.documentElement.removeAttribute("class");
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -110,13 +110,11 @@ function runTest() {
|
||||
enableSelection('span3');
|
||||
action(e, 440, 65);
|
||||
checkRangeCount(1, e);
|
||||
var r = sel.getRangeAt(0);
|
||||
checkRangePoints(r, [e.childNodes[4].firstChild,10,e.childNodes[6],0], e);
|
||||
checkRangePoints(0, [e.childNodes[4].firstChild,10,e.childNodes[6],0], e);
|
||||
} else if (test == "#prev6") {
|
||||
action(e, 140, 125);
|
||||
checkRangeCount(1, e);
|
||||
var r = sel.getRangeAt(0);
|
||||
checkRangePoints(r, [e.childNodes[5].firstChild,2,e.childNodes[6],0], e);
|
||||
checkRangePoints(0, [e.childNodes[5].firstChild,2,e.childNodes[6],0], e);
|
||||
} else if (test == "#prev7") {
|
||||
if (action == accelDragSelect) {
|
||||
accelDragSelect(e, 460, 500, 125);
|
||||
@@ -159,14 +157,12 @@ function runTest() {
|
||||
} else if (test == "#next2") {
|
||||
action(e, 260);
|
||||
checkRangeCount(1, e);
|
||||
var r = sel.getRangeAt(0);
|
||||
checkRangePoints(r, [e.childNodes[0],10,e.childNodes[1].firstChild,3], e);
|
||||
checkRangePoints(0, [e.childNodes[0],10,e.childNodes[1].firstChild,3], e);
|
||||
} else if (test == "#next3") {
|
||||
enableSelection('span2');
|
||||
action(e, 400);
|
||||
checkRangeCount(1, e);
|
||||
var r = sel.getRangeAt(0);
|
||||
checkRangePoints(r, [e.childNodes[0],10,e.childNodes[2].firstChild,5], e);
|
||||
checkRangePoints(0, [e.childNodes[0],10,e.childNodes[2].firstChild,5], e);
|
||||
} else if (test == "#next4") {
|
||||
action(e, 180, 65);
|
||||
checkRangeCount(2, e);
|
||||
@@ -177,8 +173,7 @@ function runTest() {
|
||||
action(e, 440, 65);
|
||||
checkRangeCount(2, e);
|
||||
checkRange(0, [0,10,-1,2], e);
|
||||
var r = sel.getRangeAt(1);
|
||||
checkRangePoints(r, [e.childNodes[3],0,e.childNodes[4].firstChild,10], e);
|
||||
checkRangePoints(1, [e.childNodes[3],0,e.childNodes[4].firstChild,10], e);
|
||||
} else if (test == "#next6") {
|
||||
action(e, 140, 125);
|
||||
checkRangeCount(3, e);
|
||||
@@ -197,8 +192,7 @@ function runTest() {
|
||||
checkRangeCount(3, e);
|
||||
checkRange(0, [0,10,-1,2], e);
|
||||
checkRange(1, [3,0,-1,4], e);
|
||||
var r = sel.getRangeAt(2);
|
||||
checkRangePoints(r, [e.childNodes[5],0,e.childNodes[6],10], e);
|
||||
checkRangePoints(2, [e.childNodes[5],0,e.childNodes[6],10], e);
|
||||
}
|
||||
} else if (test == "#next8") {
|
||||
if (action == accelDragSelect) {
|
||||
|
||||
@@ -124,7 +124,10 @@ function checkRangeCount(n, e)
|
||||
is(sel.rangeCount, n, e.id + ": Selection range count");
|
||||
}
|
||||
|
||||
function checkRangePoints(r, expected, e) {
|
||||
function checkRangePoints(i, expected, e) {
|
||||
var sel = window.getSelection();
|
||||
if (i >= sel.rangeCount) return;
|
||||
var r = sel.getRangeAt(i);
|
||||
is(r.startContainer, expected[0], e.id + ": range.startContainer");
|
||||
is(r.startOffset, expected[1], e.id + ": range.startOffset");
|
||||
is(r.endContainer, expected[2], e.id + ": range.endContainer");
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
<script type="text/javascript">
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
SimpleTest.requestFlakyTimeout("untriaged");
|
||||
SimpleTest.requestLongerTimeout(2);
|
||||
|
||||
var iframes = [];
|
||||
@@ -73,7 +72,7 @@ function createIframe(url,next) {
|
||||
ok(false, "iframe load for " + url + " timed out");
|
||||
endTest();
|
||||
} else {
|
||||
setTimeout(iframeLoadCompleted, 10);
|
||||
setTimeout(iframeLoadCompleted, 0);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -186,6 +186,9 @@ public:
|
||||
bool GetInterlinePosition(mozilla::ErrorResult& aRv);
|
||||
void SetInterlinePosition(bool aValue, mozilla::ErrorResult& aRv);
|
||||
|
||||
Nullable<int16_t> GetCaretBidiLevel(mozilla::ErrorResult& aRv) const;
|
||||
void SetCaretBidiLevel(const Nullable<int16_t>& aCaretBidiLevel, mozilla::ErrorResult& aRv);
|
||||
|
||||
void ToStringWithFormat(const nsAString& aFormatType,
|
||||
uint32_t aFlags,
|
||||
int32_t aWrapColumn,
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<!DOCTYPE html>
|
||||
<html class="reftest-print">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Testcase bug 1137723</title>
|
||||
|
||||
<style>
|
||||
.grid-comment{position:fixed;top:100%;}
|
||||
a[href]:after{content:" (" attr(href) ")";}
|
||||
</style>
|
||||
|
||||
<style>
|
||||
@font-face { font-family: "slick"; src: url("non-existent-file.eot"); }
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div style="height:7in"></div>
|
||||
|
||||
<div class="grid-comment">Artikel teilen
|
||||
|
||||
<div>
|
||||
<a href="https://www.facebook.com/sharer/sharer.php?u=http://www.stuttgarter-zeitung.de/inhalt.griechenland-hilfe-bundestag-stimmt-verlaengerung-zu.daa3baae-e17d-47e8-ad28-62eece0b4cfa.html">shares</a>
|
||||
<a href="https://twitter.com/share?text=Griechenland-Hilfe:Bundestag stimmt Verlängerung zu&url=http://www.stuttgarter-zeitung.de/inhalt.griechenland-hilfe-bundestag-stimmt-verlaengerung-zu.daa3baae-e17d-47e8-ad28-62eece0b4cfa.html">tweets</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,29 @@
|
||||
<!DOCTYPE html>
|
||||
<html class="reftest-print">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Testcase bug 1137723</title>
|
||||
|
||||
<style>
|
||||
.grid-comment{position:fixed;top:100%;}
|
||||
a[href]:after{content:" (" attr(href) ")";}
|
||||
</style>
|
||||
|
||||
<style>
|
||||
@font-face { font-family: "slick"; src: url("non-existent-file.eot"); }
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div style="height:3in"></div>
|
||||
|
||||
<div class="grid-comment">Artikel teilen
|
||||
|
||||
<div>
|
||||
<a href="https://www.facebook.com/sharer/sharer.php?u=http://www.stuttgarter-zeitung.de/inhalt.griechenland-hilfe-bundestag-stimmt-verlaengerung-zu.daa3baae-e17d-47e8-ad28-62eece0b4cfa.html">shares</a>
|
||||
<a href="https://twitter.com/share?text=Griechenland-Hilfe:Bundestag stimmt Verlängerung zu&url=http://www.stuttgarter-zeitung.de/inhalt.griechenland-hilfe-bundestag-stimmt-verlaengerung-zu.daa3baae-e17d-47e8-ad28-62eece0b4cfa.html">tweets</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,6 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
<div style="display: ruby-text; margin: -47891343%"></div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,6 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
<div style="display: ruby-base; margin: -47891343%"></div>
|
||||
</body>
|
||||
</html>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user