summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorFranklinDM <mrmineshafter17@gmail.com>2023-03-03 23:42:46 +0800
committerFranklinDM <mrmineshafter17@gmail.com>2023-03-04 21:32:12 +0800
commit2fbefbbc584d9380e5b1987a617bc916d29e1a57 (patch)
treecfc9b26679e9c4446bcf14315802d3d4bae9f319 /editor
parent59b4e5ceb2350c355d5e51ebc86949092fd18dc4 (diff)
downloaduxp-2fbefbbc584d9380e5b1987a617bc916d29e1a57.tar.gz
Issue #2135 - Bug 1066965: Make contentEditable and spellchecking to work in Shadow DOM
Diffstat (limited to 'editor')
-rw-r--r--editor/composer/nsEditorSpellCheck.cpp2
-rw-r--r--editor/libeditor/EditorEventListener.cpp6
-rw-r--r--editor/libeditor/HTMLEditRules.cpp4
-rw-r--r--editor/libeditor/HTMLEditor.cpp11
4 files changed, 15 insertions, 8 deletions
diff --git a/editor/composer/nsEditorSpellCheck.cpp b/editor/composer/nsEditorSpellCheck.cpp
index 1413653ac9..a3e41bd160 100644
--- a/editor/composer/nsEditorSpellCheck.cpp
+++ b/editor/composer/nsEditorSpellCheck.cpp
@@ -682,7 +682,7 @@ nsEditorSpellCheck::UpdateCurrentDictionary(nsIEditorSpellCheckCallback* aCallba
RefPtr<DictionaryFetcher> fetcher =
new DictionaryFetcher(this, aCallback, mDictionaryFetcherGroup);
rootContent->GetLang(fetcher->mRootContentLang);
- nsCOMPtr<nsIDocument> doc = rootContent->GetUncomposedDoc();
+ nsCOMPtr<nsIDocument> doc = rootContent->GetComposedDoc();
NS_ENSURE_STATE(doc);
doc->GetContentLanguage(fetcher->mRootDocContentLang);
diff --git a/editor/libeditor/EditorEventListener.cpp b/editor/libeditor/EditorEventListener.cpp
index 32f3585288..d809d8d8cd 100644
--- a/editor/libeditor/EditorEventListener.cpp
+++ b/editor/libeditor/EditorEventListener.cpp
@@ -1114,7 +1114,7 @@ EditorEventListener::Focus(WidgetEvent* aFocusEvent)
return NS_OK;
}
- nsCOMPtr<nsIDOMEventTarget> target = aFocusEvent->GetDOMEventTarget();
+ nsCOMPtr<nsIDOMEventTarget> target = aFocusEvent->GetOriginalDOMEventTarget();
nsCOMPtr<nsINode> node = do_QueryInterface(target);
NS_ENSURE_TRUE(node, NS_ERROR_UNEXPECTED);
@@ -1126,13 +1126,15 @@ EditorEventListener::Focus(WidgetEvent* aFocusEvent)
}
if (node->IsNodeOfType(nsINode::eCONTENT)) {
+ nsIContent* content =
+ node->AsContent()->FindFirstNonChromeOnlyAccessContent();
// XXX If the focus event target is a form control in contenteditable
// element, perhaps, the parent HTML editor should do nothing by this
// handler. However, FindSelectionRoot() returns the root element of the
// contenteditable editor. So, the editableRoot value is invalid for
// the plain text editor, and it will be set to the wrong limiter of
// the selection. However, fortunately, actual bugs are not found yet.
- nsCOMPtr<nsIContent> editableRoot = editorBase->FindSelectionRoot(node);
+ nsCOMPtr<nsIContent> editableRoot = editorBase->FindSelectionRoot(content);
// make sure that the element is really focused in case an earlier
// listener in the chain changed the focus.
diff --git a/editor/libeditor/HTMLEditRules.cpp b/editor/libeditor/HTMLEditRules.cpp
index 850bbe9b5a..a5b284d82f 100644
--- a/editor/libeditor/HTMLEditRules.cpp
+++ b/editor/libeditor/HTMLEditRules.cpp
@@ -8013,7 +8013,7 @@ HTMLEditRules::ConfirmSelectionInBody()
// check that selNode is inside body
while (temp && !temp->IsHTMLElement(nsGkAtoms::body)) {
- temp = temp->GetParentNode();
+ temp = temp->GetParentOrHostNode();
}
// if we aren't in the body, force the issue
@@ -8033,7 +8033,7 @@ HTMLEditRules::ConfirmSelectionInBody()
// check that selNode is inside body
while (temp && !temp->IsHTMLElement(nsGkAtoms::body)) {
- temp = temp->GetParentNode();
+ temp = temp->GetParentOrHostNode();
}
// if we aren't in the body, force the issue
diff --git a/editor/libeditor/HTMLEditor.cpp b/editor/libeditor/HTMLEditor.cpp
index 130b033bd1..2defc3e12c 100644
--- a/editor/libeditor/HTMLEditor.cpp
+++ b/editor/libeditor/HTMLEditor.cpp
@@ -381,13 +381,14 @@ HTMLEditor::FindSelectionRoot(nsINode* aNode)
aNode->IsNodeOfType(nsINode::eCONTENT),
"aNode must be content or document node");
- nsCOMPtr<nsIDocument> doc = aNode->GetUncomposedDoc();
+ nsCOMPtr<nsIDocument> doc = aNode->GetComposedDoc();
if (!doc) {
return nullptr;
}
nsCOMPtr<nsIContent> content;
- if (doc->HasFlag(NODE_IS_EDITABLE) || !aNode->IsContent()) {
+ if (aNode->IsInUncomposedDoc() &&
+ doc->HasFlag(NODE_IS_EDITABLE) || !aNode->IsContent()) {
content = doc->GetRootElement();
return content.forget();
}
@@ -5135,7 +5136,11 @@ HTMLEditor::IsAcceptableInputEvent(WidgetGUIEvent* aGUIEvent)
return true;
}
- nsCOMPtr<nsIDOMEventTarget> target = aGUIEvent->GetDOMEventTarget();
+ nsCOMPtr<nsIDOMEventTarget> target = aGUIEvent->GetOriginalDOMEventTarget();
+ nsCOMPtr<nsIContent> content = do_QueryInterface(target);
+ if (content) {
+ target = content->FindFirstNonChromeOnlyAccessContent();
+ }
NS_ENSURE_TRUE(target, false);
nsCOMPtr<nsIDocument> document = GetDocument();