зеркало из https://github.com/mozilla/gecko-dev.git
Merge autoland to mozilla-central. a=merge
This commit is contained in:
Коммит
23a7208a68
|
@ -39,7 +39,7 @@ add_task(async function test_search() {
|
|||
browser.test.sendMessage("searchLoaded", result.url);
|
||||
|
||||
// Search with tabId
|
||||
let tab = await browser.tabs.create({});
|
||||
let tab = await browser.tabs.create({url: "about:blank"});
|
||||
browser.search.search({query: SEARCH_TERM + "2", engine: "Search Test",
|
||||
tabId: tab.id});
|
||||
result = await awaitSearchResult();
|
||||
|
|
|
@ -148,7 +148,7 @@ function PreviewController(win, tab) {
|
|||
this.tab.addEventListener("TabAttrModified", this);
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "canvasPreview", function() {
|
||||
let canvas = PageThumbs.createCanvas();
|
||||
let canvas = PageThumbs.createCanvas(this.win);
|
||||
canvas.mozOpaque = true;
|
||||
return canvas;
|
||||
});
|
||||
|
@ -270,7 +270,7 @@ PreviewController.prototype = {
|
|||
let winWidth = this.win.width;
|
||||
let winHeight = this.win.height;
|
||||
|
||||
let composite = PageThumbs.createCanvas();
|
||||
let composite = PageThumbs.createCanvas(this.win);
|
||||
|
||||
// Use transparency, Aero glass is drawn black without it.
|
||||
composite.mozOpaque = false;
|
||||
|
|
|
@ -62,6 +62,7 @@
|
|||
#include "mozilla/dom/BindingUtils.h"
|
||||
#include "mozilla/NullPrincipal.h"
|
||||
#include <stdint.h>
|
||||
#include "mozilla/dom/nsCSPContext.h"
|
||||
#include "mozilla/dom/ScriptSettings.h"
|
||||
#include "mozilla/ClearOnShutdown.h"
|
||||
#include "mozilla/StaticPtr.h"
|
||||
|
@ -289,26 +290,7 @@ static void InheritAndSetCSPOnPrincipalIfNeeded(nsIChannel* aChannel,
|
|||
nsCOMPtr<nsIContentSecurityPolicy> nullPrincipalCSP;
|
||||
aPrincipal->GetCsp(getter_AddRefs(nullPrincipalCSP));
|
||||
if (nullPrincipalCSP) {
|
||||
#ifdef DEBUG
|
||||
{
|
||||
uint32_t nullPrincipalCSPCount = 0;
|
||||
nullPrincipalCSP->GetPolicyCount(&nullPrincipalCSPCount);
|
||||
|
||||
uint32_t originalCSPCount = 0;
|
||||
originalCSP->GetPolicyCount(&originalCSPCount);
|
||||
|
||||
MOZ_ASSERT(nullPrincipalCSPCount == originalCSPCount,
|
||||
"There should be no other CSP here.");
|
||||
|
||||
nsAutoString nullPrincipalCSPStr, originalCSPStr;
|
||||
for (uint32_t i = 0; i < originalCSPCount; ++i) {
|
||||
originalCSP->GetPolicyString(i, originalCSPStr);
|
||||
nullPrincipalCSP->GetPolicyString(i, nullPrincipalCSPStr);
|
||||
MOZ_ASSERT(originalCSPStr.Equals(nullPrincipalCSPStr),
|
||||
"There should be no other CSP string here.");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
MOZ_ASSERT(nsCSPContext::Equals(originalCSP, nullPrincipalCSP));
|
||||
// CSPs are equal, no need to set it again.
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -288,8 +288,8 @@ class WebConsoleUI {
|
|||
shortcuts.on("CmdOrCtrl+Alt+R", quickRestart);
|
||||
} else if (Services.prefs.getBoolPref(PREF_SIDEBAR_ENABLED)) {
|
||||
shortcuts.on("Esc", event => {
|
||||
if (!this.jsterm.autocompletePopup || !this.jsterm.autocompletePopup.isOpen) {
|
||||
this.wrapper.dispatchSidebarClose();
|
||||
this.wrapper.dispatchSidebarClose();
|
||||
if (this.jsterm) {
|
||||
this.jsterm.focus();
|
||||
}
|
||||
});
|
||||
|
@ -338,7 +338,11 @@ class WebConsoleUI {
|
|||
* @private
|
||||
*/
|
||||
_onPanelSelected() {
|
||||
this.jsterm.focus();
|
||||
// We can only focus when we have the jsterm reference. This is fine because if the
|
||||
// jsterm is not mounted yet, it will be focused in JSTerm's componentDidMount.
|
||||
if (this.jsterm) {
|
||||
this.jsterm.focus();
|
||||
}
|
||||
}
|
||||
|
||||
_onChangeSplitConsoleState() {
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
#include "mozilla/dom/TabGroup.h"
|
||||
#include "mozilla/dom/ToJSValue.h"
|
||||
#include "mozilla/dom/ChildSHistory.h"
|
||||
#include "mozilla/dom/nsCSPContext.h"
|
||||
#include "mozilla/dom/LoadURIOptionsBinding.h"
|
||||
|
||||
#include "mozilla/net/ReferrerPolicy.h"
|
||||
|
@ -9912,34 +9913,9 @@ nsresult nsDocShell::DoURILoad(nsDocShellLoadState* aLoadState,
|
|||
// holds upgrade-insecure-requests.
|
||||
nsCOMPtr<nsIContentSecurityPolicy> csp;
|
||||
aLoadState->TriggeringPrincipal()->GetCsp(getter_AddRefs(csp));
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
// After Bug 965637 we move the CSP from the Principal into the Client,
|
||||
// hence we need an explicit CSP argument passed to docshell. Let's make
|
||||
// sure the explicit CSP is the same as the CSP on the Principal.
|
||||
uint32_t principalCSPCount = 0;
|
||||
if (csp) {
|
||||
csp->GetPolicyCount(&principalCSPCount);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIContentSecurityPolicy> argsCSP = aLoadState->Csp();
|
||||
uint32_t argCSPCount = 0;
|
||||
if (argsCSP) {
|
||||
argsCSP->GetPolicyCount(&argCSPCount);
|
||||
}
|
||||
|
||||
MOZ_ASSERT(principalCSPCount == argCSPCount,
|
||||
"Different PolicyCount for CSP as arg and Principal");
|
||||
|
||||
nsAutoString principalPolicyStr, argPolicyStr;
|
||||
for (uint32_t i = 0; i < principalCSPCount; ++i) {
|
||||
csp->GetPolicyString(i, principalPolicyStr);
|
||||
argsCSP->GetPolicyString(i, argPolicyStr);
|
||||
MOZ_ASSERT(principalPolicyStr.Equals(argPolicyStr),
|
||||
"Different PolicyStr for CSP as arg and Principal");
|
||||
}
|
||||
}
|
||||
nsCOMPtr<nsIContentSecurityPolicy> argsCSP = aLoadState->Csp();
|
||||
MOZ_ASSERT(nsCSPContext::Equals(csp, argsCSP));
|
||||
#endif
|
||||
|
||||
if (csp) {
|
||||
|
|
|
@ -373,6 +373,10 @@ nsresult WebMDemuxer::ReadMetadata() {
|
|||
if (r == -1) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (params.rate > AudioInfo::MAX_RATE ||
|
||||
params.channels > AudioConfig::ChannelLayout::MAX_CHANNELS) {
|
||||
return NS_ERROR_DOM_MEDIA_METADATA_ERR;
|
||||
}
|
||||
|
||||
mAudioTrack = track;
|
||||
mHasAudio = true;
|
||||
|
|
|
@ -253,6 +253,40 @@ nsCSPContext::~nsCSPContext() {
|
|||
}
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool nsCSPContext::Equals(nsIContentSecurityPolicy* aCSP,
|
||||
nsIContentSecurityPolicy* aOtherCSP) {
|
||||
if (aCSP == aOtherCSP) {
|
||||
// fast path for pointer equality
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t policyCount = 0;
|
||||
if (aCSP) {
|
||||
aCSP->GetPolicyCount(&policyCount);
|
||||
}
|
||||
|
||||
uint32_t otherPolicyCount = 0;
|
||||
if (aOtherCSP) {
|
||||
aOtherCSP->GetPolicyCount(&otherPolicyCount);
|
||||
}
|
||||
|
||||
if (policyCount != otherPolicyCount) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsAutoString policyStr, otherPolicyStr;
|
||||
for (uint32_t i = 0; i < policyCount; ++i) {
|
||||
aCSP->GetPolicyString(i, policyStr);
|
||||
aOtherCSP->GetPolicyString(i, otherPolicyStr);
|
||||
if (!policyStr.Equals(otherPolicyStr)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
nsresult nsCSPContext::InitFromOther(nsCSPContext* aOtherContext,
|
||||
Document* aDoc, nsIPrincipal* aPrincipal) {
|
||||
NS_ENSURE_ARG(aOtherContext);
|
||||
|
|
|
@ -54,6 +54,9 @@ class nsCSPContext : public nsIContentSecurityPolicy {
|
|||
public:
|
||||
nsCSPContext();
|
||||
|
||||
static bool Equals(nsIContentSecurityPolicy* aCSP,
|
||||
nsIContentSecurityPolicy* aOtherCSP);
|
||||
|
||||
nsresult InitFromOther(nsCSPContext* otherContext,
|
||||
mozilla::dom::Document* aDoc,
|
||||
nsIPrincipal* aPrincipal);
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "mozilla/FlushType.h" // for FlushType::Frames
|
||||
#include "mozilla/HTMLEditor.h" // for HTMLEditor
|
||||
#include "mozilla/mozalloc.h" // for operator new
|
||||
#include "mozilla/PresShell.h" // for PresShell
|
||||
#include "nsAString.h"
|
||||
#include "nsComponentManagerUtils.h" // for do_CreateInstance
|
||||
#include "nsContentUtils.h"
|
||||
|
@ -33,7 +34,6 @@
|
|||
#include "nsIHTMLDocument.h" // for nsIHTMLDocument, etc
|
||||
#include "nsIInterfaceRequestorUtils.h" // for do_GetInterface
|
||||
#include "nsIPlaintextEditor.h" // for nsIPlaintextEditor, etc
|
||||
#include "nsIPresShell.h" // for nsIPresShell
|
||||
#include "nsIRefreshURI.h" // for nsIRefreshURI
|
||||
#include "nsIRequest.h" // for nsIRequest
|
||||
#include "nsITimer.h" // for nsITimer, etc
|
||||
|
@ -366,8 +366,11 @@ nsEditingSession::SetupEditorOnWindow(mozIDOMWindowProxy* aWindow) {
|
|||
// only if we haven't found some error above,
|
||||
nsCOMPtr<nsIDocShell> docShell = window->GetDocShell();
|
||||
NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
|
||||
nsCOMPtr<nsIPresShell> presShell = docShell->GetPresShell();
|
||||
NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);
|
||||
RefPtr<PresShell> presShell =
|
||||
static_cast<PresShell*>(docShell->GetPresShell());
|
||||
if (NS_WARN_IF(!presShell)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (!mInteractive) {
|
||||
// Disable animation of images in this document:
|
||||
|
@ -1203,8 +1206,11 @@ void nsEditingSession::RestoreAnimationMode(nsPIDOMWindowOuter* aWindow) {
|
|||
|
||||
nsCOMPtr<nsIDocShell> docShell = aWindow ? aWindow->GetDocShell() : nullptr;
|
||||
NS_ENSURE_TRUE_VOID(docShell);
|
||||
nsCOMPtr<nsIPresShell> presShell = docShell->GetPresShell();
|
||||
NS_ENSURE_TRUE_VOID(presShell);
|
||||
RefPtr<PresShell> presShell =
|
||||
static_cast<PresShell*>(docShell->GetPresShell());
|
||||
if (NS_WARN_IF(!presShell)) {
|
||||
return;
|
||||
}
|
||||
nsPresContext* presContext = presShell->GetPresContext();
|
||||
NS_ENSURE_TRUE_VOID(presContext);
|
||||
|
||||
|
@ -1291,8 +1297,11 @@ nsresult nsEditingSession::ReattachToWindow(mozIDOMWindowProxy* aWindow) {
|
|||
|
||||
if (!mInteractive) {
|
||||
// Disable animation of images in this document:
|
||||
nsCOMPtr<nsIPresShell> presShell = docShell->GetPresShell();
|
||||
NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);
|
||||
RefPtr<PresShell> presShell =
|
||||
static_cast<PresShell*>(docShell->GetPresShell());
|
||||
if (NS_WARN_IF(!presShell)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
nsPresContext* presContext = presShell->GetPresContext();
|
||||
NS_ENSURE_TRUE(presContext, NS_ERROR_FAILURE);
|
||||
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
#include "nsAString.h" // params
|
||||
#include "nsDebug.h" // for NS_ASSERTION, etc
|
||||
#include "nsError.h" // for NS_SUCCEEDED, NS_FAILED, etc
|
||||
#include "nsIPresShell.h" // nsISelectionController constants
|
||||
#include "nsRange.h" // local var
|
||||
#include "nsISelectionController.h" // for nsISelectionController constants
|
||||
#include "nsQueryObject.h" // for do_QueryObject
|
||||
|
||||
namespace mozilla {
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "mozilla/mozInlineSpellChecker.h" // for mozInlineSpellChecker
|
||||
#include "mozilla/mozSpellChecker.h" // for mozSpellChecker
|
||||
#include "mozilla/Preferences.h" // for Preferences
|
||||
#include "mozilla/PresShell.h" // for PresShell
|
||||
#include "mozilla/RangeBoundary.h" // for RawRangeBoundary, RangeBoundary
|
||||
#include "mozilla/dom/Selection.h" // for Selection, etc.
|
||||
#include "mozilla/Services.h" // for GetObserverService
|
||||
|
@ -87,7 +88,6 @@
|
|||
#include "nsNameSpaceManager.h" // for kNameSpaceID_None, etc.
|
||||
#include "nsINode.h" // for nsINode, etc.
|
||||
#include "nsIPlaintextEditor.h" // for nsIPlaintextEditor, etc.
|
||||
#include "nsIPresShell.h" // for nsIPresShell
|
||||
#include "nsISelectionController.h" // for nsISelectionController, etc.
|
||||
#include "nsISelectionDisplay.h" // for nsISelectionDisplay, etc.
|
||||
#include "nsISupportsBase.h" // for nsISupports
|
||||
|
@ -261,8 +261,7 @@ nsresult EditorBase::Init(Document& aDocument, Element* aRoot,
|
|||
mSelectionController = aSelectionController;
|
||||
selectionController = aSelectionController;
|
||||
} else {
|
||||
nsCOMPtr<nsIPresShell> presShell = GetPresShell();
|
||||
selectionController = do_QueryInterface(presShell);
|
||||
selectionController = GetPresShell();
|
||||
}
|
||||
MOZ_ASSERT(selectionController,
|
||||
"Selection controller should be available at this point");
|
||||
|
@ -450,7 +449,7 @@ bool EditorBase::GetDesiredSpellCheckState() {
|
|||
return false;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell = GetPresShell();
|
||||
PresShell* presShell = GetPresShell();
|
||||
if (presShell) {
|
||||
nsPresContext* context = presShell->GetPresContext();
|
||||
if (context && !context->IsDynamic()) {
|
||||
|
@ -642,11 +641,11 @@ EditorBase::GetDocument(Document** aDoc) {
|
|||
}
|
||||
|
||||
already_AddRefed<nsIWidget> EditorBase::GetWidget() {
|
||||
nsCOMPtr<nsIPresShell> ps = GetPresShell();
|
||||
NS_ENSURE_TRUE(ps, nullptr);
|
||||
nsPresContext* pc = ps->GetPresContext();
|
||||
NS_ENSURE_TRUE(pc, nullptr);
|
||||
nsCOMPtr<nsIWidget> widget = pc->GetRootWidget();
|
||||
nsPresContext* presContext = GetPresContext();
|
||||
if (NS_WARN_IF(!presContext)) {
|
||||
return nullptr;
|
||||
}
|
||||
nsCOMPtr<nsIWidget> widget = presContext->GetRootWidget();
|
||||
NS_ENSURE_TRUE(widget.get(), nullptr);
|
||||
return widget.forget();
|
||||
}
|
||||
|
@ -2950,9 +2949,9 @@ void EditorBase::DoSplitNode(const EditorDOMPoint& aStartOfRightNode,
|
|||
aError.SuppressException();
|
||||
|
||||
// Handle selection
|
||||
nsCOMPtr<nsIPresShell> ps = GetPresShell();
|
||||
if (ps) {
|
||||
ps->FlushPendingNotifications(FlushType::Frames);
|
||||
RefPtr<PresShell> presShell = GetPresShell();
|
||||
if (presShell) {
|
||||
presShell->FlushPendingNotifications(FlushType::Frames);
|
||||
}
|
||||
NS_WARNING_ASSERTION(!Destroyed(),
|
||||
"The editor is destroyed during splitting a node");
|
||||
|
@ -4379,11 +4378,6 @@ nsresult EditorBase::InitializeSelection(EventTarget* aFocusEventTarget) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell = GetPresShell();
|
||||
if (NS_WARN_IF(!presShell)) {
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISelectionController> selectionController =
|
||||
GetSelectionController();
|
||||
if (NS_WARN_IF(!selectionController)) {
|
||||
|
@ -4391,7 +4385,7 @@ nsresult EditorBase::InitializeSelection(EventTarget* aFocusEventTarget) {
|
|||
}
|
||||
|
||||
// Init the caret
|
||||
RefPtr<nsCaret> caret = presShell->GetCaret();
|
||||
RefPtr<nsCaret> caret = GetCaret();
|
||||
if (NS_WARN_IF(!caret)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -4482,12 +4476,11 @@ nsresult EditorBase::FinalizeSelection() {
|
|||
|
||||
SelectionRefPtr()->SetAncestorLimiter(nullptr);
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell = GetPresShell();
|
||||
if (NS_WARN_IF(!presShell)) {
|
||||
if (NS_WARN_IF(!GetPresShell())) {
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
if (RefPtr<nsCaret> caret = presShell->GetCaret()) {
|
||||
if (RefPtr<nsCaret> caret = GetCaret()) {
|
||||
caret->SetIgnoreUserModify(true);
|
||||
}
|
||||
|
||||
|
@ -4865,10 +4858,10 @@ void EditorBase::HideCaret(bool aHide) {
|
|||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell = GetPresShell();
|
||||
NS_ENSURE_TRUE_VOID(presShell);
|
||||
RefPtr<nsCaret> caret = presShell->GetCaret();
|
||||
NS_ENSURE_TRUE_VOID(caret);
|
||||
RefPtr<nsCaret> caret = GetCaret();
|
||||
if (NS_WARN_IF(!caret)) {
|
||||
return;
|
||||
}
|
||||
|
||||
mHidingCaret = aHide;
|
||||
if (aHide) {
|
||||
|
|
|
@ -40,12 +40,12 @@
|
|||
|
||||
class mozInlineSpellChecker;
|
||||
class nsAtom;
|
||||
class nsCaret;
|
||||
class nsIContent;
|
||||
class nsIDocumentStateListener;
|
||||
class nsIEditActionListener;
|
||||
class nsIEditorObserver;
|
||||
class nsINode;
|
||||
class nsIPresShell;
|
||||
class nsISupports;
|
||||
class nsITransferable;
|
||||
class nsITransaction;
|
||||
|
@ -77,6 +77,7 @@ class InsertNodeTransaction;
|
|||
class InsertTextTransaction;
|
||||
class JoinNodeTransaction;
|
||||
class PlaceholderTransaction;
|
||||
class PresShell;
|
||||
class SplitNodeResult;
|
||||
class SplitNodeTransaction;
|
||||
class TextComposition;
|
||||
|
@ -194,13 +195,20 @@ class EditorBase : public nsIEditor,
|
|||
|
||||
Document* GetDocument() const { return mDocument; }
|
||||
|
||||
nsIPresShell* GetPresShell() const {
|
||||
return mDocument ? mDocument->GetShell() : nullptr;
|
||||
PresShell* GetPresShell() const {
|
||||
return mDocument ? static_cast<PresShell*>(mDocument->GetShell()) : nullptr;
|
||||
}
|
||||
nsPresContext* GetPresContext() const {
|
||||
nsIPresShell* presShell = GetPresShell();
|
||||
PresShell* presShell = GetPresShell();
|
||||
return presShell ? presShell->GetPresContext() : nullptr;
|
||||
}
|
||||
already_AddRefed<nsCaret> GetCaret() const {
|
||||
PresShell* presShell = GetPresShell();
|
||||
if (NS_WARN_IF(!presShell)) {
|
||||
return nullptr;
|
||||
}
|
||||
return presShell->GetCaret();
|
||||
}
|
||||
|
||||
already_AddRefed<nsIWidget> GetWidget();
|
||||
|
||||
|
@ -211,12 +219,7 @@ class EditorBase : public nsIEditor,
|
|||
if (!mDocument) {
|
||||
return nullptr;
|
||||
}
|
||||
nsIPresShell* presShell = mDocument->GetShell();
|
||||
if (!presShell) {
|
||||
return nullptr;
|
||||
}
|
||||
nsISelectionController* sc = static_cast<PresShell*>(presShell);
|
||||
return sc;
|
||||
return static_cast<PresShell*>(mDocument->GetShell());
|
||||
}
|
||||
|
||||
nsresult GetSelection(SelectionType aSelectionType,
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "mozilla/EventStateManager.h" // for EventStateManager
|
||||
#include "mozilla/IMEStateManager.h" // for IMEStateManager
|
||||
#include "mozilla/Preferences.h" // for Preferences
|
||||
#include "mozilla/PresShell.h" // for PresShell
|
||||
#include "mozilla/TextEditor.h" // for TextEditor
|
||||
#include "mozilla/TextEvents.h" // for WidgetCompositionEvent
|
||||
#include "mozilla/dom/Element.h" // for Element
|
||||
|
@ -38,7 +39,6 @@
|
|||
#include "nsIFormControl.h" // for nsIFormControl, etc.
|
||||
#include "nsINode.h" // for nsINode, ::NODE_IS_EDITABLE, etc.
|
||||
#include "nsIPlaintextEditor.h" // for nsIPlaintextEditor, etc.
|
||||
#include "nsIPresShell.h" // for nsIPresShell
|
||||
#include "nsISelectionController.h" // for nsISelectionController, etc.
|
||||
#include "nsITransferable.h" // for kFileMime, kHTMLMime, etc.
|
||||
#include "nsIWidget.h" // for nsIWidget
|
||||
|
@ -254,13 +254,13 @@ void EditorEventListener::UninstallFromEditor() {
|
|||
TrustedEventsAtSystemGroupBubble());
|
||||
}
|
||||
|
||||
nsIPresShell* EditorEventListener::GetPresShell() const {
|
||||
PresShell* EditorEventListener::GetPresShell() const {
|
||||
MOZ_ASSERT(!DetachedFromEditor());
|
||||
return mEditorBase->GetPresShell();
|
||||
}
|
||||
|
||||
nsPresContext* EditorEventListener::GetPresContext() const {
|
||||
nsCOMPtr<nsIPresShell> presShell = GetPresShell();
|
||||
PresShell* presShell = GetPresShell();
|
||||
return presShell ? presShell->GetPresContext() : nullptr;
|
||||
}
|
||||
|
||||
|
@ -558,10 +558,14 @@ nsresult EditorEventListener::KeyPress(WidgetKeyboardEvent* aKeyboardEvent) {
|
|||
nsIWidget* widget = aKeyboardEvent->mWidget;
|
||||
// If the event is created by chrome script, the widget is always nullptr.
|
||||
if (!widget) {
|
||||
nsCOMPtr<nsIPresShell> ps = GetPresShell();
|
||||
nsPresContext* pc = ps ? ps->GetPresContext() : nullptr;
|
||||
widget = pc ? pc->GetNearestWidget() : nullptr;
|
||||
NS_ENSURE_TRUE(widget, NS_OK);
|
||||
nsPresContext* presContext = GetPresContext();
|
||||
if (NS_WARN_IF(!presContext)) {
|
||||
return NS_OK;
|
||||
}
|
||||
widget = presContext->GetNearestWidget();
|
||||
if (NS_WARN_IF(!widget)) {
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
RefPtr<Document> doc = editorBase->GetDocument();
|
||||
|
@ -630,7 +634,7 @@ nsresult EditorEventListener::MouseClick(WidgetMouseEvent* aMouseClickEvent) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell = GetPresShell();
|
||||
RefPtr<PresShell> presShell = GetPresShell();
|
||||
if (NS_WARN_IF(!presShell)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -689,8 +693,10 @@ nsresult EditorEventListener::DragEnter(DragEvent* aDragEvent) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell = GetPresShell();
|
||||
NS_ENSURE_TRUE(presShell, NS_OK);
|
||||
RefPtr<PresShell> presShell = GetPresShell();
|
||||
if (NS_WARN_IF(!presShell)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (!mCaret) {
|
||||
mCaret = new nsCaret();
|
||||
|
@ -751,7 +757,7 @@ void EditorEventListener::CleanupDragDropCaret() {
|
|||
|
||||
mCaret->SetVisible(false); // hide it, so that it turns off its timer
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell = GetPresShell();
|
||||
RefPtr<PresShell> presShell = GetPresShell();
|
||||
if (presShell) {
|
||||
presShell->RestoreCaret();
|
||||
}
|
||||
|
@ -1025,11 +1031,12 @@ nsresult EditorEventListener::Focus(InternalFocusEvent* aFocusEvent) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPresShell> ps = GetPresShell();
|
||||
NS_ENSURE_TRUE(ps, NS_OK);
|
||||
nsPresContext* presContext = GetPresContext();
|
||||
if (NS_WARN_IF(!presContext)) {
|
||||
return NS_OK;
|
||||
}
|
||||
nsCOMPtr<nsIContent> focusedContent = editorBase->GetFocusedContentForIME();
|
||||
IMEStateManager::OnFocusInEditor(ps->GetPresContext(), focusedContent,
|
||||
*editorBase);
|
||||
IMEStateManager::OnFocusInEditor(presContext, focusedContent, *editorBase);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
class nsCaret;
|
||||
class nsIContent;
|
||||
class nsIPresShell;
|
||||
class nsPresContext;
|
||||
|
||||
// X.h defines KeyPress
|
||||
|
@ -32,6 +31,7 @@ class nsPresContext;
|
|||
namespace mozilla {
|
||||
|
||||
class EditorBase;
|
||||
class PresShell;
|
||||
|
||||
namespace dom {
|
||||
class DragEvent;
|
||||
|
@ -86,7 +86,7 @@ class EditorEventListener : public nsIDOMEventListener {
|
|||
|
||||
MOZ_CAN_RUN_SCRIPT bool CanDrop(dom::DragEvent* aEvent);
|
||||
void CleanupDragDropCaret();
|
||||
nsIPresShell* GetPresShell() const;
|
||||
PresShell* GetPresShell() const;
|
||||
nsPresContext* GetPresContext() const;
|
||||
nsIContent* GetFocusedRootContent();
|
||||
// Returns true if IME consumes the mouse event.
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "TextEditUtils.h"
|
||||
#include "mozilla/EditAction.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/PresShell.h"
|
||||
#include "mozilla/TextEditRules.h"
|
||||
#include "mozilla/dom/Selection.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
|
@ -30,7 +31,6 @@
|
|||
#include "nsIDOMWindow.h"
|
||||
#include "nsIHTMLObjectResizer.h"
|
||||
#include "nsINode.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsISupportsImpl.h"
|
||||
#include "nsISupportsUtils.h"
|
||||
#include "nsLiteralString.h"
|
||||
|
@ -301,7 +301,7 @@ void HTMLEditor::HideGrabberInternal() {
|
|||
// We allow the pres shell to be null; when it is, we presume there
|
||||
// are no document observers to notify, but we still want to
|
||||
// UnbindFromTree.
|
||||
nsCOMPtr<nsIPresShell> presShell = GetPresShell();
|
||||
RefPtr<PresShell> presShell = GetPresShell();
|
||||
if (grabber) {
|
||||
DeleteRefToAnonymousNode(std::move(grabber), presShell);
|
||||
}
|
||||
|
@ -404,10 +404,12 @@ nsresult HTMLEditor::GrabberClicked() {
|
|||
|
||||
nsresult HTMLEditor::EndMoving() {
|
||||
if (mPositioningShadow) {
|
||||
nsCOMPtr<nsIPresShell> ps = GetPresShell();
|
||||
NS_ENSURE_TRUE(ps, NS_ERROR_NOT_INITIALIZED);
|
||||
RefPtr<PresShell> presShell = GetPresShell();
|
||||
if (NS_WARN_IF(!presShell)) {
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
DeleteRefToAnonymousNode(std::move(mPositioningShadow), ps);
|
||||
DeleteRefToAnonymousNode(std::move(mPositioningShadow), presShell);
|
||||
|
||||
mPositioningShadow = nullptr;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "mozilla/HTMLEditor.h"
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/PresShell.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/EventTarget.h"
|
||||
#include "mozilla/mozalloc.h"
|
||||
|
@ -26,7 +27,6 @@
|
|||
#include "nsIHTMLObjectResizer.h"
|
||||
#include "nsStubMutationObserver.h"
|
||||
#include "nsINode.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsISupportsImpl.h"
|
||||
#include "nsISupportsUtils.h"
|
||||
#include "nsLiteralString.h"
|
||||
|
@ -146,8 +146,8 @@ ManualNACPtr HTMLEditor::CreateAnonymousElement(nsAtom* aTag,
|
|||
}
|
||||
|
||||
// Get the pres shell
|
||||
nsCOMPtr<nsIPresShell> ps = GetPresShell();
|
||||
if (NS_WARN_IF(!ps)) {
|
||||
RefPtr<PresShell> presShell = GetPresShell();
|
||||
if (NS_WARN_IF(!presShell)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -192,7 +192,7 @@ ManualNACPtr HTMLEditor::CreateAnonymousElement(nsAtom* aTag,
|
|||
|
||||
// Must style the new element, otherwise the PostRecreateFramesFor call
|
||||
// below will do nothing.
|
||||
ServoStyleSet* styleSet = ps->StyleSet();
|
||||
ServoStyleSet* styleSet = presShell->StyleSet();
|
||||
// Sometimes editor likes to append anonymous content to elements
|
||||
// in display:none subtrees, so avoid styling in those cases.
|
||||
if (ServoStyleSet::MayTraverseFrom(newContent)) {
|
||||
|
@ -215,7 +215,7 @@ ManualNACPtr HTMLEditor::CreateAnonymousElement(nsAtom* aTag,
|
|||
#endif // DEBUG
|
||||
|
||||
// display the element
|
||||
ps->PostRecreateFramesFor(newContent);
|
||||
presShell->PostRecreateFramesFor(newContent);
|
||||
|
||||
return newContent;
|
||||
}
|
||||
|
@ -225,16 +225,16 @@ void HTMLEditor::RemoveListenerAndDeleteRef(const nsAString& aEvent,
|
|||
nsIDOMEventListener* aListener,
|
||||
bool aUseCapture,
|
||||
ManualNACPtr aElement,
|
||||
nsIPresShell* aShell) {
|
||||
PresShell* aPresShell) {
|
||||
if (aElement) {
|
||||
aElement->RemoveEventListener(aEvent, aListener, aUseCapture);
|
||||
}
|
||||
DeleteRefToAnonymousNode(std::move(aElement), aShell);
|
||||
DeleteRefToAnonymousNode(std::move(aElement), aPresShell);
|
||||
}
|
||||
|
||||
// Deletes all references to an anonymous element
|
||||
void HTMLEditor::DeleteRefToAnonymousNode(ManualNACPtr aContent,
|
||||
nsIPresShell* aShell) {
|
||||
PresShell* aPresShell) {
|
||||
// call ContentRemoved() for the anonymous content
|
||||
// node so its references get removed from the frame manager's
|
||||
// undisplay map, and its layout frames get destroyed!
|
||||
|
@ -250,15 +250,16 @@ void HTMLEditor::DeleteRefToAnonymousNode(ManualNACPtr aContent,
|
|||
}
|
||||
|
||||
nsAutoScriptBlocker scriptBlocker;
|
||||
// Need to check whether aShell has been destroyed (but not yet deleted).
|
||||
// Need to check whether aPresShell has been destroyed (but not yet deleted).
|
||||
// See bug 338129.
|
||||
if (aContent->IsInComposedDoc() && aShell && !aShell->IsDestroying()) {
|
||||
if (aContent->IsInComposedDoc() && aPresShell &&
|
||||
!aPresShell->IsDestroying()) {
|
||||
MOZ_ASSERT(aContent->IsRootOfAnonymousSubtree());
|
||||
MOZ_ASSERT(!aContent->GetPreviousSibling(), "NAC has no siblings");
|
||||
|
||||
// FIXME(emilio): This is the only caller to PresShell::ContentRemoved that
|
||||
// passes NAC into it. This is not great!
|
||||
aShell->ContentRemoved(aContent, nullptr);
|
||||
aPresShell->ContentRemoved(aContent, nullptr);
|
||||
}
|
||||
|
||||
// The ManualNACPtr destructor will invoke UnbindFromTree.
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "mozilla/EditorDOMPoint.h"
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "mozilla/mozInlineSpellChecker.h"
|
||||
#include "mozilla/PresShell.h"
|
||||
#include "mozilla/TextEvents.h"
|
||||
|
||||
#include "nsCRT.h"
|
||||
|
@ -38,7 +39,6 @@
|
|||
#include "nsContentUtils.h"
|
||||
#include "nsIDocumentEncoder.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsPresContext.h"
|
||||
#include "nsFocusManager.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
|
@ -196,10 +196,9 @@ HTMLEditor::~HTMLEditor() {
|
|||
mTypeInState = nullptr;
|
||||
|
||||
if (mLinkHandler && IsInitialized()) {
|
||||
nsCOMPtr<nsIPresShell> ps = GetPresShell();
|
||||
|
||||
if (ps && ps->GetPresContext()) {
|
||||
ps->GetPresContext()->SetLinkHandler(mLinkHandler);
|
||||
PresShell* presShell = GetPresShell();
|
||||
if (presShell && presShell->GetPresContext()) {
|
||||
presShell->GetPresContext()->SetLinkHandler(mLinkHandler);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -301,8 +300,10 @@ nsresult HTMLEditor::Init(Document& aDoc, Element* aRoot,
|
|||
mCSSEditUtils = MakeUnique<CSSEditUtils>(this);
|
||||
|
||||
// disable links
|
||||
nsCOMPtr<nsIPresShell> presShell = GetPresShell();
|
||||
NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);
|
||||
PresShell* presShell = GetPresShell();
|
||||
if (NS_WARN_IF(!presShell)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
nsPresContext* context = presShell->GetPresContext();
|
||||
NS_ENSURE_TRUE(context, NS_ERROR_NULL_POINTER);
|
||||
if (!IsPlaintextEditor() && !IsInteractionAllowed()) {
|
||||
|
@ -3083,7 +3084,7 @@ nsresult HTMLEditor::AddOverrideStyleSheetInternal(const nsAString& aURL) {
|
|||
}
|
||||
|
||||
// Make sure the pres shell doesn't disappear during the load.
|
||||
nsCOMPtr<nsIPresShell> presShell = GetPresShell();
|
||||
RefPtr<PresShell> presShell = GetPresShell();
|
||||
if (NS_WARN_IF(!presShell)) {
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
@ -3184,7 +3185,7 @@ nsresult HTMLEditor::RemoveOverrideStyleSheetInternal(const nsAString& aURL) {
|
|||
return NS_OK; // It's okay even if not found.
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell = GetPresShell();
|
||||
RefPtr<PresShell> presShell = GetPresShell();
|
||||
if (NS_WARN_IF(!presShell)) {
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
@ -3646,8 +3647,8 @@ nsresult HTMLEditor::SelectAllInternal() {
|
|||
SelectionRefPtr()->SetAncestorLimiter(nullptr);
|
||||
rootContent = mRootElement;
|
||||
} else {
|
||||
nsCOMPtr<nsIPresShell> ps = GetPresShell();
|
||||
rootContent = anchorContent->GetSelectionRootContent(ps);
|
||||
RefPtr<PresShell> presShell = GetPresShell();
|
||||
rootContent = anchorContent->GetSelectionRootContent(presShell);
|
||||
}
|
||||
|
||||
if (NS_WARN_IF(!rootContent)) {
|
||||
|
@ -4604,14 +4605,18 @@ nsresult HTMLEditor::GetElementOrigin(Element& aElement, int32_t& aX,
|
|||
if (NS_WARN_IF(!IsInitialized())) {
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
nsCOMPtr<nsIPresShell> ps = GetPresShell();
|
||||
NS_ENSURE_TRUE(ps, NS_ERROR_NOT_INITIALIZED);
|
||||
PresShell* presShell = GetPresShell();
|
||||
if (NS_WARN_IF(!presShell)) {
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
nsIFrame* frame = aElement.GetPrimaryFrame();
|
||||
NS_ENSURE_TRUE(frame, NS_OK);
|
||||
|
||||
nsIFrame* container = ps->GetAbsoluteContainingBlock(frame);
|
||||
NS_ENSURE_TRUE(container, NS_OK);
|
||||
nsIFrame* container = presShell->GetAbsoluteContainingBlock(frame);
|
||||
if (NS_WARN_IF(!container)) {
|
||||
return NS_OK;
|
||||
}
|
||||
nsPoint off = frame->GetOffsetTo(container);
|
||||
aX = nsPresContext::AppUnitsToIntCSSPixels(off.x);
|
||||
aY = nsPresContext::AppUnitsToIntCSSPixels(off.y);
|
||||
|
|
|
@ -2126,8 +2126,8 @@ class HTMLEditor final : public TextEditor,
|
|||
void RemoveListenerAndDeleteRef(const nsAString& aEvent,
|
||||
nsIDOMEventListener* aListener,
|
||||
bool aUseCapture, ManualNACPtr aElement,
|
||||
nsIPresShell* aShell);
|
||||
void DeleteRefToAnonymousNode(ManualNACPtr aContent, nsIPresShell* aShell);
|
||||
PresShell* aPresShell);
|
||||
void DeleteRefToAnonymousNode(ManualNACPtr aContent, PresShell* aPresShell);
|
||||
|
||||
/**
|
||||
* RefereshEditingUI() may refresh editing UIs for current Selection, focus,
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#include "nsIEditingSession.h" // for nsIEditingSession, etc
|
||||
#include "nsIEditor.h" // for nsIEditor
|
||||
#include "nsIPlaintextEditor.h" // for nsIPlaintextEditor, etc
|
||||
#include "nsIPresShell.h" // for nsIPresShell
|
||||
#include "nsISelectionController.h" // for nsISelectionController
|
||||
#include "nsISupportsImpl.h" // for nsPresContext::Release
|
||||
#include "nsISupportsUtils.h" // for NS_IF_ADDREF
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "mozilla/LookAndFeel.h"
|
||||
#include "mozilla/MathAlgorithms.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/PresShell.h"
|
||||
#include "mozilla/mozalloc.h"
|
||||
#include "mozilla/dom/Event.h"
|
||||
#include "mozilla/dom/MouseEvent.h"
|
||||
|
@ -25,7 +26,6 @@
|
|||
#include "nsIContent.h"
|
||||
#include "nsID.h"
|
||||
#include "mozilla/dom/Document.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsISupportsUtils.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
@ -449,7 +449,7 @@ nsresult HTMLEditor::HideResizersInternal() {
|
|||
}
|
||||
|
||||
// get the presshell's document observer interface.
|
||||
nsCOMPtr<nsIPresShell> presShell = GetPresShell();
|
||||
RefPtr<PresShell> presShell = GetPresShell();
|
||||
NS_WARNING_ASSERTION(presShell, "There is no presShell");
|
||||
// We allow the pres shell to be null; when it is, we presume there
|
||||
// are no document observers to notify, but we still want to
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "mozilla/HTMLEditor.h"
|
||||
|
||||
#include "HTMLEditUtils.h"
|
||||
#include "mozilla/PresShell.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "nsAString.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
@ -13,7 +14,6 @@
|
|||
#include "nsGenericHTMLElement.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIHTMLObjectResizer.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsLiteralString.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsString.h"
|
||||
|
@ -167,7 +167,7 @@ void HTMLEditor::HideInlineTableEditingUIInternal() {
|
|||
RemoveMouseClickListener(mAddRowAfterButton);
|
||||
|
||||
// get the presshell's document observer interface.
|
||||
nsCOMPtr<nsIPresShell> ps = GetPresShell();
|
||||
RefPtr<PresShell> presShell = GetPresShell();
|
||||
// We allow the pres shell to be null; when it is, we presume there
|
||||
// are no document observers to notify, but we still want to
|
||||
// UnbindFromTree.
|
||||
|
@ -183,12 +183,12 @@ void HTMLEditor::HideInlineTableEditingUIInternal() {
|
|||
ManualNACPtr removeRowButton(std::move(mRemoveRowButton));
|
||||
ManualNACPtr addRowAfterButton(std::move(mAddRowAfterButton));
|
||||
|
||||
DeleteRefToAnonymousNode(std::move(addColumnBeforeButton), ps);
|
||||
DeleteRefToAnonymousNode(std::move(removeColumnButton), ps);
|
||||
DeleteRefToAnonymousNode(std::move(addColumnAfterButton), ps);
|
||||
DeleteRefToAnonymousNode(std::move(addRowBeforeButton), ps);
|
||||
DeleteRefToAnonymousNode(std::move(removeRowButton), ps);
|
||||
DeleteRefToAnonymousNode(std::move(addRowAfterButton), ps);
|
||||
DeleteRefToAnonymousNode(std::move(addColumnBeforeButton), presShell);
|
||||
DeleteRefToAnonymousNode(std::move(removeColumnButton), presShell);
|
||||
DeleteRefToAnonymousNode(std::move(addColumnAfterButton), presShell);
|
||||
DeleteRefToAnonymousNode(std::move(addRowBeforeButton), presShell);
|
||||
DeleteRefToAnonymousNode(std::move(removeRowButton), presShell);
|
||||
DeleteRefToAnonymousNode(std::move(addRowAfterButton), presShell);
|
||||
}
|
||||
|
||||
nsresult HTMLEditor::DoInlineTableEditingAction(const Element& aElement) {
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "mozilla/EditorDOMPoint.h"
|
||||
#include "mozilla/EditorUtils.h"
|
||||
#include "mozilla/FlushType.h"
|
||||
#include "mozilla/PresShell.h"
|
||||
#include "mozilla/dom/Selection.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "nsAString.h"
|
||||
|
@ -26,7 +27,6 @@
|
|||
#include "nsIContent.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsINode.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsISupportsUtils.h"
|
||||
#include "nsITableCellLayout.h" // For efficient access to table cell
|
||||
#include "nsLiteralString.h"
|
||||
|
@ -772,7 +772,7 @@ nsresult HTMLEditor::InsertTableRowsWithTransaction(
|
|||
// SetSelectionAfterTableEdit from AutoSelectionSetterAfterTableEdit will
|
||||
// access frame selection, so we need reframe.
|
||||
// Because GetTableCellElementAt() depends on frame.
|
||||
nsCOMPtr<nsIPresShell> presShell = GetPresShell();
|
||||
RefPtr<PresShell> presShell = GetPresShell();
|
||||
if (presShell) {
|
||||
presShell->FlushPendingNotifications(FlushType::Frames);
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
#include "nsFrameSelection.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIEditor.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsISupportsImpl.h"
|
||||
#include "nsPresContext.h"
|
||||
#include "nscore.h"
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "mozilla/IMEStateManager.h"
|
||||
#include "mozilla/mozalloc.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/PresShell.h"
|
||||
#include "mozilla/TextEditRules.h"
|
||||
#include "mozilla/TextComposition.h"
|
||||
#include "mozilla/TextEvents.h"
|
||||
|
@ -42,7 +43,6 @@
|
|||
#include "nsIContent.h"
|
||||
#include "nsIDocumentEncoder.h"
|
||||
#include "nsINode.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsISelectionController.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
#include "nsITransferable.h"
|
||||
|
@ -1322,8 +1322,7 @@ nsresult TextEditor::OnCompositionChange(
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIPresShell* presShell = GetPresShell();
|
||||
if (NS_WARN_IF(!presShell)) {
|
||||
if (NS_WARN_IF(!GetPresShell())) {
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
|
@ -1342,7 +1341,7 @@ nsresult TextEditor::OnCompositionChange(
|
|||
compositionChangeEventHandlingMarker(mComposition,
|
||||
&aCompositionChangeEvent);
|
||||
|
||||
RefPtr<nsCaret> caretP = presShell->GetCaret();
|
||||
RefPtr<nsCaret> caret = GetCaret();
|
||||
|
||||
nsresult rv;
|
||||
{
|
||||
|
@ -1355,8 +1354,8 @@ nsresult TextEditor::OnCompositionChange(
|
|||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
|
||||
"Failed to insert new composition string");
|
||||
|
||||
if (caretP) {
|
||||
caretP->SetSelection(SelectionRefPtr());
|
||||
if (caret) {
|
||||
caret->SetSelection(SelectionRefPtr());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1755,7 +1754,7 @@ bool TextEditor::FireClipboardEvent(EventMessage aEventMessage,
|
|||
CommitComposition();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell = GetPresShell();
|
||||
RefPtr<PresShell> presShell = GetPresShell();
|
||||
if (NS_WARN_IF(!presShell)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
package org.mozilla.gecko;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.PendingIntent;
|
||||
import android.appwidget.AppWidgetManager;
|
||||
|
@ -108,10 +109,15 @@ public class LauncherActivity extends Activity {
|
|||
/**
|
||||
* Launch tab queue service to display overlay.
|
||||
*/
|
||||
@SuppressLint("NewApi")
|
||||
private void dispatchTabQueueIntent() {
|
||||
Intent intent = new Intent(getIntent());
|
||||
intent.setClass(getApplicationContext(), TabQueueService.class);
|
||||
startService(intent);
|
||||
if (AppConstants.Versions.preO) {
|
||||
startService(intent);
|
||||
} else {
|
||||
startForegroundService(intent);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
package org.mozilla.gecko.tabqueue;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
|
@ -12,6 +14,7 @@ import android.content.Intent;
|
|||
import android.content.SharedPreferences;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.os.Build;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.text.TextUtils;
|
||||
|
@ -263,6 +266,36 @@ public class TabQueueHelper {
|
|||
notificationManager.notify(TabQueueHelper.TAB_QUEUE_NOTIFICATION_ID, builder.build());
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a foreground service notification used from Android O prompting the user that a tab
|
||||
* is being added to the queue.
|
||||
*
|
||||
* @param context
|
||||
* @return startupNotification
|
||||
*/
|
||||
@TargetApi(Build.VERSION_CODES.O)
|
||||
public static Notification getStartupNotification(final Context context) {
|
||||
final Resources resources = context.getResources();
|
||||
|
||||
NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
|
||||
inboxStyle.setBigContentTitle(resources.getString(R.string.tab_queue_notification_prompt));
|
||||
inboxStyle.setSummaryText(resources.getString(R.string.tab_queue_notification_title));
|
||||
|
||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
|
||||
.setSmallIcon(R.drawable.ic_status_logo)
|
||||
.setContentTitle(resources.getString(R.string.tab_queue_notification_prompt))
|
||||
.setContentText(resources.getString(R.string.tab_queue_notification_title))
|
||||
.setStyle(inboxStyle)
|
||||
.setColor(ContextCompat.getColor(context, R.color.fennec_ui_accent));
|
||||
|
||||
if (!AppConstants.Versions.preO) {
|
||||
builder.setChannelId(NotificationHelper.getInstance(context)
|
||||
.getNotificationChannel(NotificationHelper.Channel.DEFAULT).getId());
|
||||
}
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
public static boolean shouldOpenTabQueueUrls(final Context context) {
|
||||
ThreadUtils.assertNotOnUiThread();
|
||||
|
||||
|
|
|
@ -53,7 +53,8 @@ import java.util.concurrent.Executors;
|
|||
* timeout (TOAST_TIMEOUT), the url is added to a file which is then read in Fennec on next launch, this allows the
|
||||
* user to quickly queue urls to open without having to open Fennec each time. If the Service receives an Intent whilst
|
||||
* the created View is still active, the old url is immediately processed and the View is re-purposed with the new
|
||||
* Intent data.
|
||||
* Intent data. From Android O, due to background limitations, this is a foreground service as it may be started
|
||||
* from the background.
|
||||
* <p/>
|
||||
* The SYSTEM_ALERT_WINDOW permission is used to allow us to insert a View from this Service which responds to user
|
||||
* interaction, whilst still allowing whatever is in the background to be seen and interacted with.
|
||||
|
@ -104,10 +105,10 @@ public class TabQueueService extends Service {
|
|||
|
||||
final Resources resources = getResources();
|
||||
|
||||
TextView messageView = (TextView) toastLayout.findViewById(R.id.toast_message);
|
||||
TextView messageView = toastLayout.findViewById(R.id.toast_message);
|
||||
messageView.setText(resources.getText(R.string.tab_queue_toast_message));
|
||||
|
||||
openNowButton = (Button) toastLayout.findViewById(R.id.toast_button);
|
||||
openNowButton = toastLayout.findViewById(R.id.toast_button);
|
||||
openNowButton.setText(resources.getText(R.string.tab_queue_toast_action));
|
||||
|
||||
toastLayoutParams = new WindowManager.LayoutParams(
|
||||
|
@ -126,6 +127,10 @@ public class TabQueueService extends Service {
|
|||
|
||||
@Override
|
||||
public int onStartCommand(final Intent intent, final int flags, final int startId) {
|
||||
if (!AppConstants.Versions.preO) {
|
||||
startForeground(TabQueueHelper.TAB_QUEUE_NOTIFICATION_ID, TabQueueHelper.getStartupNotification(TabQueueService.this));
|
||||
}
|
||||
|
||||
// If this is a redelivery then lets bypass the entire double tap to open now code as that's a big can of worms,
|
||||
// we also don't expect redeliveries because of the short time window associated with this feature.
|
||||
if (flags != START_FLAG_REDELIVERY) {
|
||||
|
@ -142,26 +147,24 @@ public class TabQueueService extends Service {
|
|||
|
||||
if (!TextUtils.isEmpty(lastUrl) && lastUrl.equals(intentUrl) && isWithinDoubleTapTimeLimit) {
|
||||
// Background thread because we could do some file IO if we have to remove a url from the list.
|
||||
tabQueueHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// If there is a runnable around, that means that the previous process hasn't yet completed, so
|
||||
// we will need to prevent it from running and remove the view from the window manager.
|
||||
// If there is no runnable around then the url has already been added to the list, so we'll
|
||||
// need to remove it before proceeding or that url will open multiple times.
|
||||
if (stopServiceRunnable != null) {
|
||||
tabQueueHandler.removeCallbacks(stopServiceRunnable);
|
||||
stopSelfResult(stopServiceRunnable.getStartId());
|
||||
stopServiceRunnable = null;
|
||||
removeView();
|
||||
} else {
|
||||
TabQueueHelper.removeURLFromFile(applicationContext, intentUrl, TabQueueHelper.FILE_NAME);
|
||||
}
|
||||
openNow(safeIntent.getUnsafe());
|
||||
|
||||
Telemetry.sendUIEvent(TelemetryContract.Event.LOAD_URL, TelemetryContract.Method.INTENT, "tabqueue-doubletap");
|
||||
stopSelfResult(startId);
|
||||
tabQueueHandler.post(() -> {
|
||||
// If there is a runnable around, that means that the previous process hasn't yet completed, so
|
||||
// we will need to prevent it from running and remove the view from the window manager.
|
||||
// If there is no runnable around then the url has already been added to the list, so we'll
|
||||
// need to remove it before proceeding or that url will open multiple times.
|
||||
if (stopServiceRunnable != null) {
|
||||
tabQueueHandler.removeCallbacks(stopServiceRunnable);
|
||||
stopForeground(false);
|
||||
stopSelfResult(stopServiceRunnable.getStartId());
|
||||
stopServiceRunnable = null;
|
||||
removeView();
|
||||
} else {
|
||||
TabQueueHelper.removeURLFromFile(applicationContext, intentUrl, TabQueueHelper.FILE_NAME);
|
||||
}
|
||||
openNow(safeIntent.getUnsafe());
|
||||
|
||||
Telemetry.sendUIEvent(TelemetryContract.Event.LOAD_URL, TelemetryContract.Method.INTENT, "tabqueue-doubletap");
|
||||
stopSelfResult(startId);
|
||||
});
|
||||
|
||||
return START_REDELIVER_INTENT;
|
||||
|
@ -194,17 +197,14 @@ public class TabQueueService extends Service {
|
|||
}
|
||||
};
|
||||
|
||||
openNowButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(final View view) {
|
||||
tabQueueHandler.removeCallbacks(stopServiceRunnable);
|
||||
stopServiceRunnable = null;
|
||||
removeView();
|
||||
openNow(intent);
|
||||
openNowButton.setOnClickListener(view -> {
|
||||
tabQueueHandler.removeCallbacks(stopServiceRunnable);
|
||||
stopServiceRunnable = null;
|
||||
removeView();
|
||||
openNow(intent);
|
||||
|
||||
Telemetry.sendUIEvent(TelemetryContract.Event.LOAD_URL, TelemetryContract.Method.INTENT, "tabqueue-now");
|
||||
stopSelfResult(startId);
|
||||
}
|
||||
Telemetry.sendUIEvent(TelemetryContract.Event.LOAD_URL, TelemetryContract.Method.INTENT, "tabqueue-now");
|
||||
stopSelfResult(startId);
|
||||
});
|
||||
|
||||
tabQueueHandler.postDelayed(stopServiceRunnable, TOAST_TIMEOUT);
|
||||
|
@ -218,18 +218,16 @@ public class TabQueueService extends Service {
|
|||
forwardIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(forwardIntent);
|
||||
|
||||
stopForeground(false);
|
||||
TabQueueHelper.removeNotification(getApplicationContext());
|
||||
|
||||
GeckoSharedPrefs.forApp(getApplicationContext()).edit().remove(GeckoPreferences.PREFS_TAB_QUEUE_LAST_SITE)
|
||||
.remove(GeckoPreferences.PREFS_TAB_QUEUE_LAST_TIME)
|
||||
.apply();
|
||||
|
||||
executorService.submit(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
int queuedTabCount = TabQueueHelper.getTabQueueLength(TabQueueService.this);
|
||||
Telemetry.addToHistogram("FENNEC_TABQUEUE_QUEUESIZE", queuedTabCount);
|
||||
}
|
||||
executorService.submit(() -> {
|
||||
int queuedTabCount = TabQueueHelper.getTabQueueLength(TabQueueService.this);
|
||||
Telemetry.addToHistogram("FENNEC_TABQUEUE_QUEUESIZE", queuedTabCount);
|
||||
});
|
||||
|
||||
}
|
||||
|
@ -290,23 +288,20 @@ public class TabQueueService extends Service {
|
|||
final String intentData = safeIntent.getDataString();
|
||||
|
||||
// As we're doing disk IO, let's run this stuff in a separate thread.
|
||||
executorService.submit(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Context applicationContext = getApplicationContext();
|
||||
final GeckoProfile profile = GeckoProfile.get(applicationContext);
|
||||
int tabsQueued = TabQueueHelper.queueURL(profile, intentData, filename);
|
||||
List<String> urls = TabQueueHelper.getLastURLs(applicationContext, filename);
|
||||
executorService.submit(() -> {
|
||||
Context applicationContext = getApplicationContext();
|
||||
final GeckoProfile profile = GeckoProfile.get(applicationContext);
|
||||
int tabsQueued = TabQueueHelper.queueURL(profile, intentData, filename);
|
||||
List<String> urls = TabQueueHelper.getLastURLs(applicationContext, filename);
|
||||
|
||||
TabQueueHelper.showNotification(applicationContext, tabsQueued, urls);
|
||||
TabQueueHelper.showNotification(applicationContext, tabsQueued, urls);
|
||||
|
||||
// Store the number of URLs queued so that we don't have to read and process the file to see if we have
|
||||
// any urls to open.
|
||||
// TODO: Use profile shared prefs when bug 1147925 gets fixed.
|
||||
final SharedPreferences prefs = GeckoSharedPrefs.forApp(applicationContext);
|
||||
// Store the number of URLs queued so that we don't have to read and process the file to see if we have
|
||||
// any urls to open.
|
||||
// TODO: Use profile shared prefs when bug 1147925 gets fixed.
|
||||
final SharedPreferences prefs = GeckoSharedPrefs.forApp(applicationContext);
|
||||
|
||||
prefs.edit().putInt(TabQueueHelper.PREF_TAB_QUEUE_COUNT, tabsQueued).apply();
|
||||
}
|
||||
prefs.edit().putInt(TabQueueHelper.PREF_TAB_QUEUE_COUNT, tabsQueued).apply();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -324,7 +319,7 @@ public class TabQueueService extends Service {
|
|||
|
||||
private final int startId;
|
||||
|
||||
public StopServiceRunnable(final int startId) {
|
||||
/*package*/ StopServiceRunnable(final int startId) {
|
||||
this.startId = startId;
|
||||
}
|
||||
|
||||
|
@ -339,10 +334,11 @@ public class TabQueueService extends Service {
|
|||
removeView();
|
||||
}
|
||||
|
||||
stopForeground(false);
|
||||
stopSelfResult(startId);
|
||||
}
|
||||
|
||||
public int getStartId() {
|
||||
/*package*/ int getStartId() {
|
||||
return startId;
|
||||
}
|
||||
|
||||
|
|
|
@ -341,6 +341,9 @@
|
|||
<!-- Localization note (tab_queue_prompt_settings_button): This button is shown if the user needs to
|
||||
enable a permission in Android's setting in order to enable tab queues. -->
|
||||
<!ENTITY tab_queue_prompt_settings_button "Go to Settings">
|
||||
<!-- Localization note (tab_queue_notification_prompt): This is the text of the default notification
|
||||
shown from Android O while a tab is being queued.-->
|
||||
<!ENTITY tab_queue_notification_prompt "Adding new tab to queue…">
|
||||
<!ENTITY tab_queue_notification_title "&brandShortName;">
|
||||
<!-- Localization note (tab_queue_notification_text_plural2) : The
|
||||
formatD is replaced with the number of tabs queued. The
|
||||
|
|
|
@ -302,6 +302,7 @@
|
|||
<string name="tab_queue_toast_action">&tab_queue_toast_action;</string>
|
||||
<string name="tab_queue_notification_text_singular">&tab_queue_notification_text_singular2;</string>
|
||||
<string name="tab_queue_notification_text_plural">&tab_queue_notification_text_plural2;</string>
|
||||
<string name="tab_queue_notification_prompt">&tab_queue_notification_prompt;</string>
|
||||
<string name="tab_queue_notification_title">&tab_queue_notification_title;</string>
|
||||
<string name="tab_queue_notification_settings">&tab_queue_notification_settings;</string>
|
||||
|
||||
|
|
|
@ -164,19 +164,30 @@ promise_test(async () => {
|
|||
const elem = document.createElement(localName);
|
||||
document.body.appendChild(elem);
|
||||
elem.disabled = true;
|
||||
const eventPromises = [
|
||||
"animationstart",
|
||||
"animationiteration",
|
||||
"animationend",
|
||||
].map(eventType => {
|
||||
return new Promise(r => {
|
||||
elem.addEventListener(eventType, r, { once: true });
|
||||
const animationStartPromise = new Promise(r => {
|
||||
elem.addEventListener("animationstart", () => {
|
||||
// Seek to the second iteration to trigger the animationiteration event
|
||||
elem.style.animationDelay = "-100s"
|
||||
r();
|
||||
});
|
||||
});
|
||||
elem.style.animation = "fade .1s 2";
|
||||
const animationIterationPromise = new Promise(r => {
|
||||
elem.addEventListener("animationiteration", ()=>{
|
||||
elem.style.animationDelay = "-200s"
|
||||
r();
|
||||
});
|
||||
});
|
||||
const animationEndPromise = new Promise(r => {
|
||||
elem.addEventListener("animationend", r);
|
||||
});
|
||||
elem.style.animation = "fade 100s 2";
|
||||
elem.classList.add("animate");
|
||||
// All the events fire...
|
||||
await Promise.all(eventPromises);
|
||||
await Promise.all([
|
||||
animationStartPromise,
|
||||
animationIterationPromise,
|
||||
animationEndPromise,
|
||||
]);
|
||||
elem.remove();
|
||||
}
|
||||
}, "CSS Animation animationstart, animationiteration, animationend fire on disabled form elements");
|
||||
|
|
|
@ -96,6 +96,7 @@ scheme = https
|
|||
skip-if = toolkit == 'android' # autocomplete
|
||||
[test_one_doorhanger_per_un_pw.html]
|
||||
scheme = https
|
||||
skip-if = toolkit == 'android' # bug 1535505
|
||||
[test_onsubmit_value_change.html]
|
||||
[test_passwords_in_type_password.html]
|
||||
[test_prompt.html]
|
||||
|
|
|
@ -21,17 +21,16 @@ var PageThumbUtils = {
|
|||
HTML_NAMESPACE: "http://www.w3.org/1999/xhtml",
|
||||
|
||||
/**
|
||||
* Creates a new canvas element in the context of aWindow, or if aWindow
|
||||
* is undefined, in the context of hiddenDOMWindow.
|
||||
* Creates a new canvas element in the context of aWindow.
|
||||
*
|
||||
* @param aWindow (optional) The document of this window will be used to
|
||||
* create the canvas. If not given, the hidden window will be used.
|
||||
* @param aWindow The document of this window will be used to
|
||||
* create the canvas.
|
||||
* @param aWidth (optional) width of the canvas to create
|
||||
* @param aHeight (optional) height of the canvas to create
|
||||
* @return The newly created canvas.
|
||||
*/
|
||||
createCanvas(aWindow, aWidth = 0, aHeight = 0) {
|
||||
let doc = (aWindow || Services.appShell.hiddenDOMWindow).document;
|
||||
let doc = aWindow.document;
|
||||
let canvas = doc.createElementNS(this.HTML_NAMESPACE, "canvas");
|
||||
canvas.mozOpaque = true;
|
||||
canvas.imageSmoothingEnabled = true;
|
||||
|
|
|
@ -163,7 +163,7 @@ var PageThumbs = {
|
|||
}
|
||||
|
||||
return new Promise(resolve => {
|
||||
let canvas = this.createCanvas(aBrowser.contentWindow);
|
||||
let canvas = this.createCanvas(aBrowser.ownerGlobal);
|
||||
this.captureToCanvas(aBrowser, canvas, () => {
|
||||
canvas.toBlob(blob => {
|
||||
resolve(blob, this.contentType);
|
||||
|
@ -261,7 +261,7 @@ var PageThumbs = {
|
|||
return;
|
||||
}
|
||||
// The content is a local page, grab a thumbnail sync.
|
||||
PageThumbUtils.createSnapshotThumbnail(aBrowser.contentWindow,
|
||||
PageThumbUtils.createSnapshotThumbnail(aBrowser.ownerGlobal,
|
||||
aCanvas,
|
||||
aArgs);
|
||||
|
||||
|
|
|
@ -406,7 +406,8 @@ nsDependentCSubstring IMContextWrapper::GetIMName() const {
|
|||
// If the context is XIM, actual engine must be specified with
|
||||
// |XMODIFIERS=@im=foo|.
|
||||
const char* xmodifiersChar = PR_GetEnv("XMODIFIERS");
|
||||
if (!im.EqualsLiteral("xim") || !xmodifiersChar) {
|
||||
if (!xmodifiersChar ||
|
||||
(!im.EqualsLiteral("xim") && !im.EqualsLiteral("wayland"))) {
|
||||
return im;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче