Merge inbound to mozilla-central a=merge

This commit is contained in:
Coroiu Cristina 2018-04-09 11:58:23 +03:00
Родитель e7aa38e0ae 1c91714d38
Коммит 24ef518135
30 изменённых файлов: 1763 добавлений и 1745 удалений

Просмотреть файл

@ -83,18 +83,19 @@ var gTests = [
is(webrtcUI.getActiveStreams(true, true, true).length, 2, "2 active streams");
info("removing the second tab");
// FIXME: This should wait for indicator update instead (bug 1444007).
let sessionStorePromise = BrowserTestUtils.waitForSessionStoreUpdate(tab);
BrowserTestUtils.removeTab(tab);
await sessionStorePromise;
// Check that we still show the sharing indicators for the first tab's stream.
await TestUtils.waitForCondition(() => !webrtcUI.showCameraIndicator);
await Promise.all([
TestUtils.waitForCondition(() => !webrtcUI.showCameraIndicator),
TestUtils.waitForCondition(() => webrtcUI.getActiveStreams(true, true, true).length == 1),
]);
ok(webrtcUI.showGlobalIndicator, "webrtcUI wants the global indicator shown");
ok(!webrtcUI.showCameraIndicator, "webrtcUI wants the camera indicator hidden");
ok(webrtcUI.showMicrophoneIndicator, "webrtcUI wants the mic indicator shown");
is(webrtcUI.getActiveStreams(false, true).length, 1, "1 active audio stream");
is(webrtcUI.getActiveStreams(true, true, true).length, 1, "1 active stream");
await checkSharingUI({audio: true});
@ -306,7 +307,10 @@ var gTests = [
// first tab receives observer notifications for things happening in the
// second tab, so let's clear the observer call counts before we cleanup
// in the first tab.
await ignoreObserversCalled();
await Promise.all([
TestUtils.waitForCondition(() => webrtcUI.getActiveStreams(true, true, true).length == 1),
ignoreObserversCalled(),
]);
// Close the first tab's stream and verify that all indicators are removed.
await closeStream();

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -170,6 +170,7 @@ support-files =
skip-if = true # Bug 1437843
[browser_console_consolejsm_output.js]
[browser_console_context_menu_entries.js]
skip-if = (os == "linux" && (debug || ccov)) # Bug 1440059
[browser_console_dead_objects.js]
[browser_console_devtools_loader_exception.js]
[browser_console_error_source_click.js]

Просмотреть файл

@ -12,7 +12,6 @@
#include "nsDebug.h" // for NS_ENSURE_ARG_POINTER, etc
#include "nsError.h" // for NS_ERROR_INVALID_ARG, etc
#include "nsICommandParams.h" // for nsICommandParams
#include "nsIDOMDocument.h" // for nsIDOMDocument
#include "nsIDocShell.h" // for nsIDocShell
#include "nsIDocument.h" // for nsIDocument
#include "nsIEditingSession.h" // for nsIEditingSession, etc

Просмотреть файл

@ -24,7 +24,6 @@
#include "nsIControllerContext.h" // for nsIControllerContext
#include "nsIControllers.h" // for nsIControllers
#include "nsID.h" // for NS_GET_IID, etc
#include "nsIDOMDocument.h" // for nsIDOMDocument
#include "nsHTMLDocument.h" // for nsHTMLDocument
#include "nsIDOMWindow.h" // for nsIDOMWindow
#include "nsIDocShell.h" // for nsIDocShell

Просмотреть файл

@ -1532,7 +1532,7 @@ public:
*/
virtual nsresult InsertFromDataTransfer(dom::DataTransfer* aDataTransfer,
int32_t aIndex,
nsIDOMDocument* aSourceDoc,
nsIDocument* aSourceDoc,
nsINode* aDestinationNode,
int32_t aDestOffset,
bool aDoDeleteSelection) = 0;

Просмотреть файл

@ -17,7 +17,6 @@
#include "nsIClipboard.h"
#include "nsICommandParams.h"
#include "nsID.h"
#include "nsIDOMDocument.h"
#include "nsIDocument.h"
#include "nsIEditor.h"
#include "nsIEditorMailSupport.h"

Просмотреть файл

@ -31,7 +31,6 @@
#include "mozilla/dom/DOMStringList.h"
#include "mozilla/dom/DataTransfer.h"
#include "mozilla/dom/DragEvent.h"
#include "nsIDOMDocument.h" // for nsIDOMDocument
#include "nsIDOMEvent.h" // for nsIDOMEvent
#include "nsIDOMEventTarget.h" // for nsIDOMEventTarget
#include "nsIDocument.h" // for nsIDocument

Просмотреть файл

@ -12,7 +12,6 @@
#include "nsError.h"
#include "nsIContent.h"
#include "nsIContentIterator.h"
#include "nsIDOMDocument.h"
#include "nsIDocShell.h"
#include "nsIDocument.h"
#include "nsIInterfaceRequestorUtils.h"

Просмотреть файл

@ -19,7 +19,6 @@
class nsAtom;
class nsIContentIterator;
class nsIDOMDocument;
class nsIDOMEvent;
class nsISimpleEnumerator;
class nsITransferable;

Просмотреть файл

@ -37,14 +37,13 @@
#include "nsError.h"
#include "nsGkAtoms.h"
#include "nsAtom.h"
#include "nsHTMLDocument.h"
#include "nsIContent.h"
#include "nsIContentIterator.h"
#include "nsID.h"
#include "nsIDOMDocument.h"
#include "nsIDOMElement.h"
#include "nsIFrame.h"
#include "nsIHTMLAbsPosEditor.h"
#include "nsIHTMLDocument.h"
#include "nsINode.h"
#include "nsLiteralString.h"
#include "nsRange.h"
@ -373,10 +372,10 @@ HTMLEditRules::BeforeEdit(EditAction aAction,
}
// Stabilize the document against contenteditable count changes
nsCOMPtr<nsIDOMDocument> doc = htmlEditor->GetDOMDocument();
NS_ENSURE_TRUE(doc, NS_ERROR_NOT_INITIALIZED);
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(doc);
NS_ENSURE_TRUE(htmlDoc, NS_ERROR_FAILURE);
nsHTMLDocument* htmlDoc = htmlEditor->GetHTMLDocument();
if (NS_WARN_IF(!htmlDoc)) {
return NS_ERROR_FAILURE;
}
if (htmlDoc->GetEditingState() == nsIHTMLDocument::eContentEditable) {
htmlDoc->ChangeContentEditableCount(nullptr, +1);
mRestoreContentEditableCount = true;
@ -416,10 +415,10 @@ HTMLEditRules::AfterEdit(EditAction aAction,
// Reset the contenteditable count to its previous value
if (mRestoreContentEditableCount) {
nsCOMPtr<nsIDOMDocument> doc = htmlEditor->GetDOMDocument();
NS_ENSURE_TRUE(doc, NS_ERROR_NOT_INITIALIZED);
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(doc);
NS_ENSURE_TRUE(htmlDoc, NS_ERROR_FAILURE);
nsHTMLDocument* htmlDoc = htmlEditor->GetHTMLDocument();
if (NS_WARN_IF(!htmlDoc)) {
return NS_ERROR_FAILURE;
}
if (htmlDoc->GetEditingState() == nsIHTMLDocument::eContentEditable) {
htmlDoc->ChangeContentEditableCount(nullptr, -1);
}

Просмотреть файл

@ -25,6 +25,7 @@
#include "TextEditUtils.h"
#include "TypeInState.h"
#include "nsHTMLDocument.h"
#include "nsIDOMDocument.h"
#include "nsIDocumentInlines.h"
#include "nsISelectionController.h"
@ -4977,4 +4978,14 @@ HTMLEditor::GetEditorRoot()
return GetActiveEditingHost();
}
nsHTMLDocument*
HTMLEditor::GetHTMLDocument() const
{
nsIDocument* doc = GetDocument();
if (NS_WARN_IF(!doc)) {
return nullptr;
}
return doc->AsHTMLDocument();
}
} // namespace mozilla

Просмотреть файл

@ -35,6 +35,7 @@
#include "nsTArray.h"
class nsDocumentFragment;
class nsHTMLDocument;
class nsITransferable;
class nsIClipboard;
class nsIDOMDocument;
@ -566,12 +567,14 @@ public:
MaybeCollapseSelectionAtFirstEditableNode(
bool aIgnoreIfSelectionInEditingHost);
nsHTMLDocument* GetHTMLDocument() const;
protected:
class BlobReader final : public nsIEditorBlobListener
{
public:
BlobReader(dom::BlobImpl* aBlob, HTMLEditor* aHTMLEditor,
bool aIsSafe, nsIDOMDocument* aSourceDoc,
bool aIsSafe, nsIDocument* aSourceDoc,
nsINode* aDestinationNode, int32_t aDestOffset,
bool aDoDeleteSelection);
@ -586,7 +589,7 @@ protected:
RefPtr<dom::BlobImpl> mBlob;
RefPtr<HTMLEditor> mHTMLEditor;
bool mIsSafe;
nsCOMPtr<nsIDOMDocument> mSourceDoc;
nsCOMPtr<nsIDocument> mSourceDoc;
nsCOMPtr<nsINode> mDestinationNode;
int32_t mDestOffset;
bool mDoDeleteSelection;
@ -769,7 +772,7 @@ protected:
nsresult InsertObject(const nsACString& aType, nsISupports* aObject,
bool aIsSafe,
nsIDOMDocument* aSourceDoc,
nsIDocument* aSourceDoc,
nsINode* aDestinationNode,
int32_t aDestOffset,
bool aDoDeleteSelection);
@ -779,14 +782,14 @@ protected:
NS_IMETHOD PrepareTransferable(nsITransferable** transferable) override;
nsresult PrepareHTMLTransferable(nsITransferable** transferable);
nsresult InsertFromTransferable(nsITransferable* transferable,
nsIDOMDocument* aSourceDoc,
nsIDocument* aSourceDoc,
const nsAString& aContextStr,
const nsAString& aInfoStr,
bool havePrivateHTMLFlavor,
bool aDoDeleteSelection);
virtual nsresult InsertFromDataTransfer(dom::DataTransfer* aDataTransfer,
int32_t aIndex,
nsIDOMDocument* aSourceDoc,
nsIDocument* aSourceDoc,
nsINode* aDestinationNode,
int32_t aDestOffset,
bool aDoDeleteSelection) override;
@ -1111,7 +1114,7 @@ protected:
const nsAString& aContextStr,
const nsAString& aInfoStr,
const nsAString& aFlavor,
nsIDOMDocument* aSourceDoc,
nsIDocument* aSourceDoc,
nsINode* aDestNode,
int32_t aDestOffset,
bool aDeleteSelection,

Просмотреть файл

@ -39,7 +39,6 @@
#include "nsIClipboard.h"
#include "nsIContent.h"
#include "nsIDOMDocument.h"
#include "nsIDOMDocumentFragment.h"
#include "nsIDOMElement.h"
#include "nsIDOMNode.h"
#include "nsIDocument.h"
@ -182,9 +181,10 @@ HTMLEditor::InsertHTMLWithContext(const nsAString& aInputString,
int32_t aDestOffset,
bool aDeleteSelection)
{
nsCOMPtr<nsIDocument> sourceDoc = do_QueryInterface(aSourceDoc);
nsCOMPtr<nsINode> destNode = do_QueryInterface(aDestNode);
return DoInsertHTMLWithContext(aInputString, aContextStr, aInfoStr,
aFlavor, aSourceDoc, destNode, aDestOffset,
aFlavor, sourceDoc, destNode, aDestOffset,
aDeleteSelection,
/* trusted input */ true,
/* clear style */ false);
@ -195,7 +195,7 @@ HTMLEditor::DoInsertHTMLWithContext(const nsAString& aInputString,
const nsAString& aContextStr,
const nsAString& aInfoStr,
const nsAString& aFlavor,
nsIDOMDocument* aSourceDoc,
nsIDocument* aSourceDoc,
nsINode* aDestNode,
int32_t aDestOffset,
bool aDeleteSelection,
@ -960,7 +960,7 @@ NS_IMPL_ISUPPORTS(HTMLEditor::BlobReader, nsIEditorBlobListener)
HTMLEditor::BlobReader::BlobReader(BlobImpl* aBlob,
HTMLEditor* aHTMLEditor,
bool aIsSafe,
nsIDOMDocument* aSourceDoc,
nsIDocument* aSourceDoc,
nsINode* aDestinationNode,
int32_t aDestOffset,
bool aDoDeleteSelection)
@ -1017,7 +1017,7 @@ nsresult
HTMLEditor::InsertObject(const nsACString& aType,
nsISupports* aObject,
bool aIsSafe,
nsIDOMDocument* aSourceDoc,
nsIDocument* aSourceDoc,
nsINode* aDestinationNode,
int32_t aDestOffset,
bool aDoDeleteSelection)
@ -1097,7 +1097,7 @@ HTMLEditor::InsertObject(const nsACString& aType,
nsresult
HTMLEditor::InsertFromTransferable(nsITransferable* transferable,
nsIDOMDocument* aSourceDoc,
nsIDocument* aSourceDoc,
const nsAString& aContextStr,
const nsAString& aInfoStr,
bool havePrivateHTMLFlavor,
@ -1223,7 +1223,7 @@ GetStringFromDataTransfer(DataTransfer* aDataTransfer,
nsresult
HTMLEditor::InsertFromDataTransfer(DataTransfer* aDataTransfer,
int32_t aIndex,
nsIDOMDocument* aSourceDoc,
nsIDocument* aSourceDoc,
nsINode* aDestinationNode,
int32_t aDestOffset,
bool aDoDeleteSelection)

Просмотреть файл

@ -24,7 +24,6 @@
#include "nsAtom.h"
#include "nsIContent.h"
#include "nsID.h"
#include "nsIDOMDocument.h"
#include "nsIDOMElement.h"
#include "nsIDOMEvent.h"
#include "nsIDocument.h"

Просмотреть файл

@ -30,7 +30,6 @@
#include "nsGkAtoms.h"
#include "nsIContent.h"
#include "nsIDocumentEncoder.h"
#include "nsIDOMDocument.h"
#include "nsNameSpaceManager.h"
#include "nsINode.h"
#include "nsIPlaintextEditor.h"

Просмотреть файл

@ -36,7 +36,6 @@
#include "nsIClipboard.h"
#include "nsIContent.h"
#include "nsIContentIterator.h"
#include "nsIDOMDocument.h"
#include "nsIDOMEventTarget.h"
#include "nsIDOMNode.h"
#include "nsIDocumentEncoder.h"

Просмотреть файл

@ -16,7 +16,6 @@
#include "nscore.h"
class nsIContent;
class nsIDOMDocument;
class nsIDOMEvent;
class nsIDocumentEncoder;
class nsIOutputStream;
@ -149,7 +148,7 @@ public:
virtual nsresult InsertFromDataTransfer(dom::DataTransfer* aDataTransfer,
int32_t aIndex,
nsIDOMDocument* aSourceDoc,
nsIDocument* aSourceDoc,
nsINode* aDestinationNode,
int32_t aDestOffset,
bool aDoDeleteSelection) override;
@ -169,7 +168,7 @@ public:
* principals match, or we are in a editor context where this doesn't matter.
* Otherwise, the data must be sanitized first.
*/
bool IsSafeToInsertData(nsIDOMDocument* aSourceDoc);
bool IsSafeToInsertData(nsIDocument* aSourceDoc);
static void GetDefaultEditorPrefs(int32_t& aNewLineHandling,
int32_t& aCaretStyle);

Просмотреть файл

@ -20,7 +20,6 @@
#include "nsError.h"
#include "nsIClipboard.h"
#include "nsIContent.h"
#include "nsIDOMDocument.h"
#include "nsIDOMEvent.h"
#include "nsIDocument.h"
#include "nsIDragService.h"
@ -135,7 +134,7 @@ TextEditor::InsertTextFromTransferable(nsITransferable* aTransferable)
nsresult
TextEditor::InsertFromDataTransfer(DataTransfer* aDataTransfer,
int32_t aIndex,
nsIDOMDocument* aSourceDoc,
nsIDocument* aSourceDoc,
nsINode* aDestinationNode,
int32_t aDestOffset,
bool aDoDeleteSelection)
@ -170,23 +169,25 @@ TextEditor::InsertFromDrop(DragEvent* aDropEvent)
nsCOMPtr<nsINode> sourceNode = dataTransfer->GetMozSourceNode();
nsCOMPtr<nsIDOMDocument> srcdomdoc;
nsCOMPtr<nsIDocument> srcdoc;
if (sourceNode) {
srcdomdoc = do_QueryInterface(sourceNode->OwnerDoc());
srcdoc = sourceNode->OwnerDoc();
}
if (nsContentUtils::CheckForSubFrameDrop(dragSession,
aDropEvent->WidgetEventPtr()->AsDragEvent())) {
// Don't allow drags from subframe documents with different origins than
// the drop destination.
if (srcdomdoc && !IsSafeToInsertData(srcdomdoc)) {
if (srcdoc && !IsSafeToInsertData(srcdoc)) {
return NS_OK;
}
}
// Current doc is destination
nsCOMPtr<nsIDOMDocument> destdomdoc = GetDOMDocument();
NS_ENSURE_TRUE(destdomdoc, NS_ERROR_NOT_INITIALIZED);
nsIDocument* destdoc = GetDocument();
if (NS_WARN_IF(!destdoc)) {
return NS_ERROR_NOT_INITIALIZED;
}
uint32_t numItems = dataTransfer->MozItemCount();
if (numItems < 1) {
@ -240,7 +241,7 @@ TextEditor::InsertFromDrop(DragEvent* aDropEvent)
if (cursorIsInSelection) {
// Dragging within same doc can't drop on itself -- leave!
if (srcdomdoc == destdomdoc) {
if (srcdoc == destdoc) {
return NS_OK;
}
@ -250,7 +251,7 @@ TextEditor::InsertFromDrop(DragEvent* aDropEvent)
//deleteSelection = true;
} else {
// We are NOT over the selection
if (srcdomdoc == destdomdoc) {
if (srcdoc == destdoc) {
// Within the same doc: delete if user doesn't want to copy
uint32_t dropEffect = dataTransfer->DropEffectInt();
deleteSelection = !(dropEffect & nsIDragService::DRAGDROP_ACTION_COPY);
@ -275,7 +276,7 @@ TextEditor::InsertFromDrop(DragEvent* aDropEvent)
}
for (uint32_t i = 0; i < numItems; ++i) {
InsertFromDataTransfer(dataTransfer, i, srcdomdoc,
InsertFromDataTransfer(dataTransfer, i, srcdoc,
newSelectionParent,
newSelectionOffset, deleteSelection);
}
@ -399,7 +400,7 @@ TextEditor::CanPasteTransferable(nsITransferable* aTransferable,
}
bool
TextEditor::IsSafeToInsertData(nsIDOMDocument* aSourceDoc)
TextEditor::IsSafeToInsertData(nsIDocument* aSourceDoc)
{
// Try to determine whether we should use a sanitizing fragment sink
bool isSafe = false;
@ -417,10 +418,7 @@ TextEditor::IsSafeToInsertData(nsIDOMDocument* aSourceDoc)
isSafe = appType == nsIDocShell::APP_TYPE_EDITOR;
}
if (!isSafe && aSourceDoc) {
nsCOMPtr<nsIDocument> srcdoc = do_QueryInterface(aSourceDoc);
NS_ASSERTION(srcdoc, "Where is our source doc?");
nsIPrincipal* srcPrincipal = srcdoc->NodePrincipal();
nsIPrincipal* srcPrincipal = aSourceDoc->NodePrincipal();
nsIPrincipal* destPrincipal = destdoc->NodePrincipal();
NS_ASSERTION(srcPrincipal && destPrincipal, "How come we don't have a principal?");
srcPrincipal->Subsumes(destPrincipal, &isSafe);

Просмотреть файл

@ -13,7 +13,6 @@
#include "nsError.h"
#include "nsGkAtoms.h"
#include "nsIDocument.h"
#include "nsIDOMDocument.h"
#include "nsIEditor.h"
#include "nsIHTMLEditor.h"
#include "nsINodeList.h"
@ -129,11 +128,7 @@ nsresult TextEditorTest::TestInsertBreak()
nsresult TextEditorTest::TestTextProperties()
{
nsCOMPtr<nsIDOMDocument>domDoc;
nsresult rv = mEditor->GetDocument(getter_AddRefs(domDoc));
TEST_RESULT(rv);
TEST_POINTER(domDoc.get());
nsCOMPtr<nsIDocument>doc = do_QueryInterface(domDoc);
nsCOMPtr<nsIDocument> doc = mEditor->AsEditorBase()->GetDocument();
TEST_POINTER(doc.get());
// XXX This is broken, text nodes are not elements.
nsAutoString textTag(NS_LITERAL_STRING("#text"));
@ -147,7 +142,7 @@ nsresult TextEditorTest::TestTextProperties()
// set the whole text node to bold
printf("set the whole first text node to bold\n");
nsCOMPtr<nsISelection>selection;
rv = mEditor->GetSelection(getter_AddRefs(selection));
nsresult rv = mEditor->GetSelection(getter_AddRefs(selection));
TEST_RESULT(rv);
TEST_POINTER(selection.get());
uint32_t length = textNode->Length();

Просмотреть файл

@ -26,7 +26,6 @@
#endif
class nsAtom;
class nsIDOMDocument;
namespace mozilla {

Просмотреть файл

@ -22,7 +22,6 @@
#include "nsDebug.h"
#include "nsError.h"
#include "nsIContent.h"
#include "nsIDOMDocument.h"
#include "nsISupportsImpl.h"
#include "nsRange.h"
#include "nsString.h"

Просмотреть файл

@ -77,6 +77,7 @@ UNIFIED_SOURCES += [
LOCAL_INCLUDES += [
'/dom/base',
'/dom/html',
'/extensions/spellcheck/src',
'/layout/generic',
'/layout/style',

Просмотреть файл

@ -8,6 +8,7 @@
#include "mozilla/Attributes.h" // for final
#include "mozilla/EditorBase.h" // for EditorBase
#include "mozilla/HTMLEditor.h" // for HTMLEditor
#include "mozilla/dom/Element.h" // for Element
#include "mozilla/dom/Selection.h"
#include "mozilla/intl/LocaleService.h" // for retrieving app locale
@ -22,10 +23,8 @@
#include "nsError.h" // for NS_ERROR_NOT_INITIALIZED, etc
#include "nsIContent.h" // for nsIContent
#include "nsIContentPrefService2.h" // for nsIContentPrefService2, etc
#include "nsIDOMDocument.h" // for nsIDOMDocument
#include "nsIDocument.h" // for nsIDocument
#include "nsIEditor.h" // for nsIEditor
#include "nsIHTMLEditor.h" // for nsIHTMLEditor
#include "nsILoadContext.h"
#include "nsISelection.h" // for nsISelection
#include "nsISupportsBase.h" // for nsISupports
@ -76,39 +75,28 @@ public:
/**
* Gets the URI of aEditor's document.
*/
static nsresult
GetDocumentURI(nsIEditor* aEditor, nsIURI * *aURI)
static nsIURI*
GetDocumentURI(EditorBase* aEditor)
{
NS_ENSURE_ARG_POINTER(aEditor);
NS_ENSURE_ARG_POINTER(aURI);
MOZ_ASSERT(aEditor);
nsCOMPtr<nsIDOMDocument> domDoc;
aEditor->GetDocument(getter_AddRefs(domDoc));
NS_ENSURE_TRUE(domDoc, NS_ERROR_FAILURE);
nsIDocument* doc = aEditor->AsEditorBase()->GetDocument();
if (NS_WARN_IF(!doc)) {
return nullptr;
}
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
nsCOMPtr<nsIURI> docUri = doc->GetDocumentURI();
NS_ENSURE_TRUE(docUri, NS_ERROR_FAILURE);
*aURI = docUri;
NS_ADDREF(*aURI);
return NS_OK;
return doc->GetDocumentURI();
}
static already_AddRefed<nsILoadContext>
static nsILoadContext*
GetLoadContext(nsIEditor* aEditor)
{
nsCOMPtr<nsIDOMDocument> domDoc;
aEditor->GetDocument(getter_AddRefs(domDoc));
NS_ENSURE_TRUE(domDoc, nullptr);
nsIDocument* doc = aEditor->AsEditorBase()->GetDocument();
if (NS_WARN_IF(!doc)) {
return nullptr;
}
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
NS_ENSURE_TRUE(doc, nullptr);
nsCOMPtr<nsILoadContext> loadContext = doc->GetLoadContext();
return loadContext.forget();
return doc->GetLoadContext();
}
/**
@ -171,14 +159,14 @@ public:
ContentPrefInitializerRunnable(nsIEditor* aEditor,
nsIContentPrefCallback2* aCallback)
: Runnable("ContentPrefInitializerRunnable")
, mEditor(aEditor)
, mEditorBase(aEditor->AsEditorBase())
, mCallback(aCallback)
{
}
NS_IMETHOD Run() override
{
if (mEditor->AsEditorBase()->Destroyed()) {
if (mEditorBase->Destroyed()) {
mCallback->HandleError(NS_ERROR_NOT_AVAILABLE);
return NS_OK;
}
@ -190,24 +178,23 @@ public:
return NS_OK;
}
nsCOMPtr<nsIURI> docUri;
nsresult rv = GetDocumentURI(mEditor, getter_AddRefs(docUri));
if (NS_WARN_IF(NS_FAILED(rv))) {
mCallback->HandleError(rv);
nsCOMPtr<nsIURI> docUri = GetDocumentURI(mEditorBase);
if (NS_WARN_IF(!docUri)) {
mCallback->HandleError(NS_ERROR_FAILURE);
return NS_OK;
}
nsAutoCString docUriSpec;
rv = docUri->GetSpec(docUriSpec);
nsresult rv = docUri->GetSpec(docUriSpec);
if (NS_WARN_IF(NS_FAILED(rv))) {
mCallback->HandleError(rv);
return NS_OK;
}
nsCOMPtr<nsILoadContext> loadContext = GetLoadContext(mEditor);
rv = contentPrefService->GetByDomainAndName(
NS_ConvertUTF8toUTF16(docUriSpec),
CPS_PREF_NAME, loadContext,
CPS_PREF_NAME,
GetLoadContext(mEditorBase),
mCallback);
if (NS_WARN_IF(NS_FAILED(rv))) {
mCallback->HandleError(rv);
@ -217,7 +204,7 @@ public:
}
private:
nsCOMPtr<nsIEditor> mEditor;
RefPtr<EditorBase> mEditorBase;
nsCOMPtr<nsIContentPrefCallback2> mCallback;
};
@ -237,15 +224,16 @@ DictionaryFetcher::Fetch(nsIEditor* aEditor)
* Stores the current dictionary for aEditor's document URL.
*/
static nsresult
StoreCurrentDictionary(nsIEditor* aEditor, const nsAString& aDictionary)
StoreCurrentDictionary(EditorBase* aEditorBase, const nsAString& aDictionary)
{
NS_ENSURE_ARG_POINTER(aEditor);
NS_ENSURE_ARG_POINTER(aEditorBase);
nsresult rv;
nsCOMPtr<nsIURI> docUri;
rv = GetDocumentURI(aEditor, getter_AddRefs(docUri));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIURI> docUri = GetDocumentURI(aEditorBase);
if (NS_WARN_IF(!docUri)) {
return NS_ERROR_FAILURE;
}
nsAutoCString docUriSpec;
rv = docUri->GetSpec(docUriSpec);
@ -258,9 +246,9 @@ StoreCurrentDictionary(nsIEditor* aEditor, const nsAString& aDictionary)
do_GetService(NS_CONTENT_PREF_SERVICE_CONTRACTID);
NS_ENSURE_TRUE(contentPrefService, NS_ERROR_NOT_INITIALIZED);
nsCOMPtr<nsILoadContext> loadContext = GetLoadContext(aEditor);
return contentPrefService->Set(NS_ConvertUTF8toUTF16(docUriSpec),
CPS_PREF_NAME, prefValue, loadContext,
CPS_PREF_NAME, prefValue,
GetLoadContext(aEditorBase),
nullptr);
}
@ -268,15 +256,16 @@ StoreCurrentDictionary(nsIEditor* aEditor, const nsAString& aDictionary)
* Forgets the current dictionary stored for aEditor's document URL.
*/
static nsresult
ClearCurrentDictionary(nsIEditor* aEditor)
ClearCurrentDictionary(EditorBase* aEditorBase)
{
NS_ENSURE_ARG_POINTER(aEditor);
NS_ENSURE_ARG_POINTER(aEditorBase);
nsresult rv;
nsCOMPtr<nsIURI> docUri;
rv = GetDocumentURI(aEditor, getter_AddRefs(docUri));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIURI> docUri = GetDocumentURI(aEditorBase);
if (NS_WARN_IF(!docUri)) {
return NS_ERROR_FAILURE;
}
nsAutoCString docUriSpec;
rv = docUri->GetSpec(docUriSpec);
@ -286,9 +275,9 @@ ClearCurrentDictionary(nsIEditor* aEditor)
do_GetService(NS_CONTENT_PREF_SERVICE_CONTRACTID);
NS_ENSURE_TRUE(contentPrefService, NS_ERROR_NOT_INITIALIZED);
nsCOMPtr<nsILoadContext> loadContext = GetLoadContext(aEditor);
return contentPrefService->RemoveByDomainAndName(
NS_ConvertUTF8toUTF16(docUriSpec), CPS_PREF_NAME, loadContext, nullptr);
NS_ConvertUTF8toUTF16(docUriSpec), CPS_PREF_NAME,
GetLoadContext(aEditorBase), nullptr);
}
NS_IMPL_CYCLE_COLLECTING_ADDREF(EditorSpellCheck)
@ -384,12 +373,12 @@ EditorSpellCheck::InitSpellChecker(nsIEditor* aEditor,
nsIEditorSpellCheckCallback* aCallback)
{
NS_ENSURE_TRUE(aEditor, NS_ERROR_NULL_POINTER);
mEditor = aEditor;
mEditor = aEditor->AsEditorBase();
nsCOMPtr<nsIDOMDocument> domDoc;
mEditor->GetDocument(getter_AddRefs(domDoc));
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
NS_ENSURE_STATE(doc);
nsCOMPtr<nsIDocument> doc = mEditor->GetDocument();
if (NS_WARN_IF(!doc)) {
return NS_ERROR_FAILURE;
}
nsresult rv;
@ -733,11 +722,11 @@ EditorSpellCheck::UpdateCurrentDictionary(
// Get language with html5 algorithm
nsCOMPtr<nsIContent> rootContent;
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(mEditor);
HTMLEditor* htmlEditor = mEditor->AsHTMLEditor();
if (htmlEditor) {
rootContent = htmlEditor->GetActiveEditingHost();
} else {
rootContent = mEditor->AsEditorBase()->GetRoot();
rootContent = mEditor->GetRoot();
}
// Try to get topmost document's document element for embedded mail editor.

Просмотреть файл

@ -29,6 +29,7 @@ class nsITextServicesFilter;
namespace mozilla {
class DictionaryFetcher;
class EditorBase;
enum dictCompare
{
@ -57,7 +58,7 @@ protected:
RefPtr<mozSpellChecker> mSpellChecker;
nsCOMPtr<nsITextServicesFilter> mTxtSrvFilter;
nsCOMPtr<nsIEditor> mEditor;
RefPtr<EditorBase> mEditor;
nsTArray<nsString> mSuggestedWordList;

Просмотреть файл

@ -6,6 +6,7 @@
#include "TextServicesDocument.h"
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc
#include "mozilla/dom/Element.h"
#include "mozilla/dom/Selection.h"
#include "mozilla/mozalloc.h" // for operator new, etc
#include "mozilla/TextEditor.h" // for TextEditor
@ -19,7 +20,6 @@
#include "nsIContent.h" // for nsIContent, etc
#include "nsIContentIterator.h" // for nsIContentIterator
#include "nsID.h" // for NS_GET_IID
#include "nsIDOMDocument.h" // for nsIDOMDocument
#include "nsIDOMNode.h" // for nsIDOMNode, etc
#include "nsIEditor.h" // for nsIEditor, etc
#include "nsINode.h" // for nsINode
@ -98,7 +98,7 @@ NS_INTERFACE_MAP_BEGIN(TextServicesDocument)
NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTION(TextServicesDocument,
mDOMDocument,
mDocument,
mSelCon,
mTextEditor,
mIterator,
@ -111,7 +111,6 @@ nsresult
TextServicesDocument::InitWithEditor(nsIEditor* aEditor)
{
nsCOMPtr<nsISelectionController> selCon;
nsCOMPtr<nsIDOMDocument> doc;
NS_ENSURE_TRUE(aEditor, NS_ERROR_NULL_POINTER);
@ -136,23 +135,17 @@ TextServicesDocument::InitWithEditor(nsIEditor* aEditor)
mSelCon = selCon;
}
// Check to see if we already have an mDOMDocument. If we do, it
// Check to see if we already have an mDocument. If we do, it
// better be the same one the editor uses!
rv = aEditor->GetDocument(getter_AddRefs(doc));
if (NS_FAILED(rv)) {
UNLOCK_DOC(this);
return rv;
}
if (!doc || (mDOMDocument && doc != mDOMDocument)) {
nsCOMPtr<nsIDocument> doc = aEditor->AsEditorBase()->GetDocument();
if (!doc || (mDocument && doc != mDocument)) {
UNLOCK_DOC(this);
return NS_ERROR_FAILURE;
}
if (!mDOMDocument) {
mDOMDocument = doc;
if (!mDocument) {
mDocument = doc;
rv = CreateDocumentContentIterator(getter_AddRefs(mIterator));
@ -180,25 +173,11 @@ TextServicesDocument::InitWithEditor(nsIEditor* aEditor)
return rv;
}
nsresult
TextServicesDocument::GetDocument(nsIDOMDocument** aDoc)
{
NS_ENSURE_TRUE(aDoc, NS_ERROR_NULL_POINTER);
*aDoc = nullptr; // init out param
NS_ENSURE_TRUE(mDOMDocument, NS_ERROR_NOT_INITIALIZED);
*aDoc = mDOMDocument;
NS_ADDREF(*aDoc);
return NS_OK;
}
nsresult
TextServicesDocument::SetExtent(nsRange* aRange)
{
NS_ENSURE_ARG_POINTER(aRange);
NS_ENSURE_TRUE(mDOMDocument, NS_ERROR_FAILURE);
NS_ENSURE_TRUE(mDocument, NS_ERROR_FAILURE);
LOCK_DOC(this);
@ -1644,24 +1623,20 @@ TextServicesDocument::CreateContentIterator(nsRange* aRange,
return NS_OK;
}
already_AddRefed<nsINode>
TextServicesDocument::GetDocumentContentRootNode()
Element*
TextServicesDocument::GetDocumentContentRootNode() const
{
if (NS_WARN_IF(!mDOMDocument)) {
if (NS_WARN_IF(!mDocument)) {
return nullptr;
}
nsCOMPtr<nsIDocument> doc = do_QueryInterface(mDOMDocument);
if (doc->IsHTMLOrXHTML()) {
if (mDocument->IsHTMLOrXHTML()) {
// For HTML documents, the content root node is the body.
nsCOMPtr<nsINode> node = doc->GetBody();
return node.forget();
return mDocument->GetBody();
}
// For non-HTML documents, the content root node will be the document element.
nsCOMPtr<nsINode> node = doc->GetDocumentElement();
return node.forget();
return mDocument->GetDocumentElement();
}
already_AddRefed<nsRange>
@ -2096,7 +2071,7 @@ TextServicesDocument::GetSelection(BlockSelectionStatus* aSelStatus,
*aSelOffset = -1;
*aSelLength = -1;
NS_ENSURE_TRUE(mDOMDocument && mSelCon, NS_ERROR_FAILURE);
NS_ENSURE_TRUE(mDocument && mSelCon, NS_ERROR_FAILURE);
if (mIteratorStatus == IteratorStatus::eDone) {
return NS_OK;

Просмотреть файл

@ -16,7 +16,6 @@
class nsIContent;
class nsIContentIterator;
class nsIDOMDocument;
class nsIDOMNode;
class nsIEditor;
class nsINode;
@ -30,6 +29,10 @@ namespace mozilla {
class OffsetEntry;
class TextEditor;
namespace dom {
class Elemenent;
};
/**
* The TextServicesDocument presents the document in as a bunch of flattened
* text blocks. Each text block can be retrieved as an nsString.
@ -49,7 +52,7 @@ private:
eNext,
};
nsCOMPtr<nsIDOMDocument> mDOMDocument;
nsCOMPtr<nsIDocument> mDocument;
nsCOMPtr<nsISelectionController> mSelCon;
RefPtr<TextEditor> mTextEditor;
nsCOMPtr<nsIContentIterator> mIterator;
@ -84,13 +87,6 @@ public:
*/
nsresult InitWithEditor(nsIEditor* aEditor);
/**
* Get the DOM document for the document in use.
*
* @return aDOMDocument The dom document.
*/
nsresult GetDocument(nsIDOMDocument** aDOMDocument);
/**
* Sets the range/extent over which the text services document will iterate.
* Note that InitWithEditor() should have been called prior to calling this
@ -243,7 +239,7 @@ private:
nsresult CreateContentIterator(nsRange* aRange,
nsIContentIterator** aIterator);
already_AddRefed<nsINode> GetDocumentContentRootNode();
dom::Element* GetDocumentContentRootNode() const;
already_AddRefed<nsRange> CreateDocumentContentRange();
already_AddRefed<nsRange> CreateDocumentContentRootToNodeOffsetRange(
nsINode* aParent,

Просмотреть файл

@ -54,9 +54,50 @@ struct FontTemplate {
StaticMutex sFontDataTableLock;
std::unordered_map<FontKey, FontTemplate> sFontDataTable;
// Fixed-size ring buffer logging font deletion events to aid debugging.
static struct FontDeleteLog {
static const size_t MAX_ENTRIES = 256;
uint64_t mEntries[MAX_ENTRIES] = { 0 };
size_t mNextEntry = 0;
void AddEntry(uint64_t aEntry) {
mEntries[mNextEntry] = aEntry;
mNextEntry = (mNextEntry + 1) % MAX_ENTRIES;
}
void Add(WrFontKey aKey) {
AddEntry(AsUint64(aKey));
}
// Store namespace clears as font id 0, since this will never be allocated.
void Add(WrIdNamespace aNamespace) {
AddEntry(AsUint64(WrFontKey { aNamespace, 0 }));
}
// Find a matching entry in the log, searching backwards starting at the newest
// entry and finishing with the oldest entry. Returns a brief description of why
// the font was deleted, if known.
const char* Find(WrFontKey aKey) {
uint64_t keyEntry = AsUint64(aKey);
uint64_t namespaceEntry = AsUint64(WrFontKey { aKey.mNamespace, 0 });
size_t offset = mNextEntry;
do {
offset = (offset + MAX_ENTRIES - 1) % MAX_ENTRIES;
if (mEntries[offset] == keyEntry) {
return "deleted font";
} else if (mEntries[offset] == namespaceEntry) {
return "cleared namespace";
}
} while (offset != mNextEntry);
return "unknown font";
}
} sFontDeleteLog;
void
ClearBlobImageResources(WrIdNamespace aNamespace) {
StaticMutexAutoLock lock(sFontDataTableLock);
sFontDeleteLog.Add(aNamespace);
for (auto i = sFontDataTable.begin(); i != sFontDataTable.end();) {
if (i->first.mNamespace == aNamespace) {
if (i->second.mVec) {
@ -110,6 +151,7 @@ AddNativeFontHandle(WrFontKey aKey, void* aHandle, uint32_t aIndex) {
void
DeleteFontData(WrFontKey aKey) {
StaticMutexAutoLock lock(sFontDataTableLock);
sFontDeleteLog.Add(aKey);
auto i = sFontDataTable.find(aKey);
if (i != sFontDataTable.end()) {
if (i->second.mVec) {
@ -125,7 +167,8 @@ GetUnscaledFont(Translator *aTranslator, wr::FontKey key) {
StaticMutexAutoLock lock(sFontDataTableLock);
auto i = sFontDataTable.find(key);
if (i == sFontDataTable.end()) {
gfxDevCrash(LogReason::UnscaledFontNotFound) << "Failed to get UnscaledFont entry for FontKey " << key.mHandle;
gfxDevCrash(LogReason::UnscaledFontNotFound) << "Failed to get UnscaledFont entry for FontKey " << key.mHandle
<< " because " << sFontDeleteLog.Find(key);
return nullptr;
}
auto &data = i->second;

Просмотреть файл

@ -231,7 +231,6 @@ skip-if = os == "mac" && debug
[test_system_repository.js]
[test_system_reset.js]
[test_system_update_blank.js]
fail-if = os == 'win' && ccov
[test_system_update_checkSizeHash.js]
[test_system_update_custom.js]
[test_system_update_empty.js]