68.14.8 - widget

This commit is contained in:
Fedor 2025-04-19 19:17:00 +03:00
parent 68568abe3a
commit 95cbc1282f
81 changed files with 264 additions and 209 deletions

View File

@ -897,6 +897,12 @@ class WidgetEvent : public WidgetEventTime {
// All wheel events are composed
mFlags.mComposed = mMessage == eWheel;
break;
case eMouseScrollEventClass:
// Legacy mouse scroll events are composed too, for consistency with
// wheel.
mFlags.mComposed = mMessage == eLegacyMouseLineOrPageScroll ||
mMessage == eLegacyMousePixelScroll;
break;
default:
mFlags.mComposed = false;
break;

View File

@ -6,6 +6,7 @@
#include "ClientLayerManager.h"
#include "gfxPlatform.h"
#include "nsRefreshDriver.h"
#include "mozilla/dom/BrowserChild.h"
#include "mozilla/dom/TabGroup.h"
#include "mozilla/gfx/gfxVars.h"
@ -160,7 +161,6 @@ void PuppetWidget::Destroy() {
Base::OnDestroy();
Base::Destroy();
mPaintTask.Revoke();
if (mMemoryPressureObserver) {
mMemoryPressureObserver->Unregister();
mMemoryPressureObserver = nullptr;
@ -267,13 +267,10 @@ void PuppetWidget::Invalidate(const LayoutDeviceIntRect& aRect) {
return;
}
mDirtyRegion.Or(mDirtyRegion, aRect);
if (mBrowserChild && !mDirtyRegion.IsEmpty() && !mPaintTask.IsPending()) {
mPaintTask = new PaintTask(this);
nsCOMPtr<nsIRunnable> event(mPaintTask.get());
if (mBrowserChild && !aRect.IsEmpty() && !mWidgetPaintTask.IsPending()) {
mWidgetPaintTask = new WidgetPaintTask(this);
nsCOMPtr<nsIRunnable> event(mWidgetPaintTask.get());
mBrowserChild->TabGroup()->Dispatch(TaskCategory::Other, event.forget());
return;
}
}
@ -705,6 +702,18 @@ bool PuppetWidget::HaveValidInputContextCache() const {
IMEStateManager::GetWidgetForActiveInputContext() == this);
}
nsRefreshDriver* PuppetWidget::GetTopLevelRefreshDriver() const {
if (!mBrowserChild) {
return nullptr;
}
if (PresShell* presShell = mBrowserChild->GetTopLevelPresShell()) {
return presShell->GetRefreshDriver();
}
return nullptr;
}
void PuppetWidget::SetInputContext(const InputContext& aContext,
const InputContextAction& aAction) {
mInputContext = aContext;
@ -974,64 +983,6 @@ void PuppetWidget::ClearCachedCursor() {
mCustomCursor = nullptr;
}
nsresult PuppetWidget::Paint() {
MOZ_ASSERT(!mDirtyRegion.IsEmpty(), "paint event logic messed up");
if (!GetCurrentWidgetListener()) return NS_OK;
LayoutDeviceIntRegion region = mDirtyRegion;
// reset repaint tracking
mDirtyRegion.SetEmpty();
mPaintTask.Revoke();
RefPtr<PuppetWidget> strongThis(this);
GetCurrentWidgetListener()->WillPaintWindow(this);
if (GetCurrentWidgetListener()) {
#ifdef DEBUG
debug_DumpPaintEvent(stderr, this, region.ToUnknownRegion(), "PuppetWidget",
0);
#endif
if (mLayerManager->GetBackendType() ==
mozilla::layers::LayersBackend::LAYERS_CLIENT ||
mLayerManager->GetBackendType() ==
mozilla::layers::LayersBackend::LAYERS_WR ||
(mozilla::layers::LayersBackend::LAYERS_BASIC ==
mLayerManager->GetBackendType() &&
mBrowserChild && mBrowserChild->IsLayersConnected().isSome())) {
// Do nothing, the compositor will handle drawing
if (mBrowserChild) {
mBrowserChild->NotifyPainted();
}
} else if (mozilla::layers::LayersBackend::LAYERS_BASIC ==
mLayerManager->GetBackendType()) {
RefPtr<gfxContext> ctx = gfxContext::CreateOrNull(mDrawTarget);
if (!ctx) {
gfxDevCrash(LogReason::InvalidContext)
<< "PuppetWidget context problem " << gfx::hexa(mDrawTarget);
return NS_ERROR_FAILURE;
}
ctx->Rectangle(gfxRect(0, 0, 0, 0));
ctx->Clip();
AutoLayerManagerSetup setupLayerManager(this, ctx,
BufferMode::BUFFER_NONE);
GetCurrentWidgetListener()->PaintWindow(this, region);
if (mBrowserChild) {
mBrowserChild->NotifyPainted();
}
}
}
if (GetCurrentWidgetListener()) {
GetCurrentWidgetListener()->DidPaintWindow();
}
return NS_OK;
}
void PuppetWidget::SetChild(PuppetWidget* aChild) {
MOZ_ASSERT(this != aChild, "can't parent a widget to itself");
MOZ_ASSERT(!aChild->mChild,
@ -1041,15 +992,29 @@ void PuppetWidget::SetChild(PuppetWidget* aChild) {
}
NS_IMETHODIMP
PuppetWidget::PaintTask::Run() {
PuppetWidget::WidgetPaintTask::Run() {
if (mWidget) {
mWidget->Paint();
}
return NS_OK;
}
void PuppetWidget::Paint() {
if (!GetCurrentWidgetListener()) return;
mWidgetPaintTask.Revoke();
RefPtr<PuppetWidget> strongThis(this);
GetCurrentWidgetListener()->WillPaintWindow(this);
if (GetCurrentWidgetListener()) {
GetCurrentWidgetListener()->DidPaintWindow();
}
}
void PuppetWidget::PaintNowIfNeeded() {
if (IsVisible() && mPaintTask.IsPending()) {
if (IsVisible() && mWidgetPaintTask.IsPending()) {
Paint();
}
}

View File

@ -320,7 +320,7 @@ class PuppetWidget : public nsBaseWidget,
virtual void OnMemoryPressure(layers::MemoryPressureReason aWhy) override;
private:
nsresult Paint();
void Paint();
void SetChild(PuppetWidget* aChild);
@ -346,17 +346,19 @@ class PuppetWidget : public nsBaseWidget,
// IMEStateManager, the cache is valid.
bool HaveValidInputContextCache() const;
class PaintTask : public Runnable {
class WidgetPaintTask : public Runnable {
public:
NS_DECL_NSIRUNNABLE
explicit PaintTask(PuppetWidget* widget)
: Runnable("PuppetWidget::PaintTask"), mWidget(widget) {}
explicit WidgetPaintTask(PuppetWidget* widget)
: Runnable("PuppetWidget::WidgetPaintTask"), mWidget(widget) {}
void Revoke() { mWidget = nullptr; }
private:
PuppetWidget* mWidget;
};
nsRefreshDriver* GetTopLevelRefreshDriver() const;
// BrowserChild normally holds a strong reference to this PuppetWidget
// or its root ancestor, but each PuppetWidget also needs a
// reference back to BrowserChild (e.g. to delegate nsIWidget IME calls
@ -367,8 +369,7 @@ class PuppetWidget : public nsBaseWidget,
// The "widget" to which we delegate events if we don't have an
// event handler.
RefPtr<PuppetWidget> mChild;
LayoutDeviceIntRegion mDirtyRegion;
nsRevocableEventPtr<PaintTask> mPaintTask;
nsRevocableEventPtr<WidgetPaintTask> mWidgetPaintTask;
RefPtr<layers::MemoryPressureObserver> mMemoryPressureObserver;
// XXX/cjones: keeping this around until we teach LayerManager to do
// retained-content-only transactions

View File

@ -208,7 +208,7 @@ Command GetInternalCommand(const char* aCommandName,
if (NS_FAILED(rv)) {
return Command::FormatJustifyNone;
}
cValue = NS_ConvertUTF16toUTF8(value);
CopyUTF16toUTF8(value, cValue);
}
if (cValue.LowerCaseEqualsASCII("left")) {
return Command::FormatJustifyLeft;

View File

@ -41,7 +41,7 @@ using mozilla::dom::ContentParent;
#include "nsIWidgetListener.h"
#include "nsIWindowWatcher.h"
#include "nsIXULWindow.h"
#include "nsIAppWindow.h"
#include "nsAppShell.h"
#include "nsFocusManager.h"
@ -1234,11 +1234,11 @@ void nsWindow::GeckoViewSupport::Open(
aInitData);
if (window->mWidgetListener) {
nsCOMPtr<nsIXULWindow> xulWindow(window->mWidgetListener->GetXULWindow());
if (xulWindow) {
// Our window is not intrinsically sized, so tell nsXULWindow to
nsCOMPtr<nsIAppWindow> appWindow(window->mWidgetListener->GetAppWindow());
if (appWindow) {
// Our window is not intrinsically sized, so tell AppWindow to
// not set a size for us.
xulWindow->SetIntrinsicallySized(false);
appWindow->SetIntrinsicallySized(false);
}
}
}

View File

@ -3,7 +3,7 @@ load 397209-1.html
load 403296-1.xhtml
load 419737-1.html
load 435223-1.html
load 444260-1.xul
load chrome://reftest/content/crashtests/widget/cocoa/crashtests/444260-1.xhtml
load 444864-1.html
load 449111-1.html
load 460349-1.xhtml

View File

@ -42,6 +42,9 @@
#include "nsIDOMWakeLockListener.h"
#include "nsIPowerManagerService.h"
#include "nsIObserverService.h"
#include "mozilla/Services.h"
using namespace mozilla;
using namespace mozilla::widget;
@ -877,6 +880,11 @@ nsAppShell::AfterProcessNextEvent(nsIThreadInternal* aThread, bool aEventWasProc
[currentEvent modifierFlags] & NSDeviceIndependentModifierFlagsMask;
}
nsCOMPtr<nsIObserverService> observerService = services::GetObserverService();
if (observerService) {
observerService->NotifyObservers(nullptr, NS_WIDGET_MAC_APP_ACTIVATE_OBSERVER_TOPIC, nullptr);
}
NS_OBJC_END_TRY_ABORT_BLOCK;
}

View File

@ -518,7 +518,7 @@ class nsChildView final : public nsBaseWidget {
NSView<mozView>* GetEditorView();
nsCocoaWindow* GetXULWindowWidget() const;
nsCocoaWindow* GetAppWindowWidget() const;
virtual void ReparentNativeWidget(nsIWidget* aNewParent) override;

View File

@ -494,7 +494,7 @@ void nsChildView::TearDownView() {
NS_OBJC_END_TRY_ABORT_BLOCK;
}
nsCocoaWindow* nsChildView::GetXULWindowWidget() const {
nsCocoaWindow* nsChildView::GetAppWindowWidget() const {
id windowDelegate = [[mView window] delegate];
if (windowDelegate && [windowDelegate isKindOfClass:[WindowDelegate class]]) {
return [(WindowDelegate*)windowDelegate geckoWidget];
@ -596,7 +596,7 @@ void* nsChildView::GetNativeData(uint32_t aDataType) {
nsTransparencyMode nsChildView::GetTransparencyMode() {
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
nsCocoaWindow* windowWidget = GetXULWindowWidget();
nsCocoaWindow* windowWidget = GetAppWindowWidget();
return windowWidget ? windowWidget->GetTransparencyMode() : eTransparencyOpaque;
NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(eTransparencyOpaque);
@ -607,7 +607,7 @@ nsTransparencyMode nsChildView::GetTransparencyMode() {
void nsChildView::SetTransparencyMode(nsTransparencyMode aMode) {
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
nsCocoaWindow* windowWidget = GetXULWindowWidget();
nsCocoaWindow* windowWidget = GetAppWindowWidget();
if (windowWidget) {
windowWidget->SetTransparencyMode(aMode);
}
@ -624,7 +624,7 @@ bool nsChildView::IsVisible() const {
return mVisible;
}
if (!GetXULWindowWidget()->IsVisible()) {
if (!GetAppWindowWidget()->IsVisible()) {
return false;
}
@ -831,7 +831,7 @@ void nsChildView::BackingScaleFactorChanged() {
mNativeLayerRoot->SetBackingScale(mBackingScaleFactor);
}
if (mWidgetListener && !mWidgetListener->GetXULWindow()) {
if (mWidgetListener && !mWidgetListener->GetAppWindow()) {
if (PresShell* presShell = mWidgetListener->GetPresShell()) {
presShell->BackingScaleFactorChanged();
}
@ -1165,7 +1165,7 @@ static NSMenuItem* NativeMenuItemWithLocation(NSMenu* menubar, NSString* locatio
bool nsChildView::SendEventToNativeMenuSystem(NSEvent* aEvent) {
bool handled = false;
nsCocoaWindow* widget = GetXULWindowWidget();
nsCocoaWindow* widget = GetAppWindowWidget();
if (widget) {
nsMenuBarX* mb = widget->GetMenuBar();
if (mb) {
@ -1230,7 +1230,7 @@ nsresult nsChildView::ActivateNativeMenuItemAt(const nsAString& indexString) {
nsresult nsChildView::ForceUpdateNativeMenuAt(const nsAString& indexString) {
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
nsCocoaWindow* widget = GetXULWindowWidget();
nsCocoaWindow* widget = GetAppWindowWidget();
if (widget) {
nsMenuBarX* mb = widget->GetMenuBar();
if (mb) {
@ -1913,7 +1913,7 @@ void nsChildView::PrepareWindowEffects() {
mIsCoveringTitlebar = [mView isCoveringTitlebar];
NSInteger styleMask = [[mView window] styleMask];
bool wasFullscreen = mIsFullscreen;
nsCocoaWindow* windowWidget = GetXULWindowWidget();
nsCocoaWindow* windowWidget = GetAppWindowWidget();
mIsFullscreen =
(styleMask & NSFullScreenWindowMask) || (windowWidget && windowWidget->InFullScreenMode());
@ -3417,7 +3417,7 @@ NSEvent* gLastDragMouseDownEvent = nil;
}
- (void)viewWillStartLiveResize {
nsCocoaWindow* windowWidget = mGeckoChild ? mGeckoChild->GetXULWindowWidget() : nullptr;
nsCocoaWindow* windowWidget = mGeckoChild ? mGeckoChild->GetAppWindowWidget() : nullptr;
if (windowWidget) {
windowWidget->NotifyLiveResizeStarted();
}
@ -3430,7 +3430,7 @@ NSEvent* gLastDragMouseDownEvent = nil;
// is null here, that might be problematic because we might get stuck with
// a content process that has the displayport suppressed. If that scenario
// arises (I'm not sure that it does) we will need to handle it gracefully.
nsCocoaWindow* windowWidget = mGeckoChild ? mGeckoChild->GetXULWindowWidget() : nullptr;
nsCocoaWindow* windowWidget = mGeckoChild ? mGeckoChild->GetAppWindowWidget() : nullptr;
if (windowWidget) {
windowWidget->NotifyLiveResizeStopped();
}

View File

@ -20,7 +20,7 @@
#include "nsIAppShellService.h"
#include "nsIOSPermissionRequest.h"
#include "nsIRunnable.h"
#include "nsIXULWindow.h"
#include "nsIAppWindow.h"
#include "nsIBaseWindow.h"
#include "nsMenuUtilsX.h"
#include "nsToolkit.h"
@ -271,7 +271,7 @@ nsIWidget* nsCocoaUtils::GetHiddenWindowWidget() {
return nullptr;
}
nsCOMPtr<nsIXULWindow> hiddenWindow;
nsCOMPtr<nsIAppWindow> hiddenWindow;
appShell->GetHiddenWindow(getter_AddRefs(hiddenWindow));
if (!hiddenWindow) {
// Don't warn, this happens during shutdown, bug 358607.
@ -281,7 +281,7 @@ nsIWidget* nsCocoaUtils::GetHiddenWindowWidget() {
nsCOMPtr<nsIBaseWindow> baseHiddenWindow;
baseHiddenWindow = do_GetInterface(hiddenWindow);
if (!baseHiddenWindow) {
NS_WARNING("Couldn't get nsIBaseWindow from hidden window (nsIXULWindow)");
NS_WARNING("Couldn't get nsIBaseWindow from hidden window (nsIAppWindow)");
return nullptr;
}

View File

@ -294,6 +294,7 @@ class nsCocoaWindow final : public nsBaseWidget, public nsPIWidgetCocoa {
virtual void SetWindowShadowStyle(mozilla::StyleWindowShadow aStyle) override;
virtual void SetWindowOpacity(float aOpacity) override;
virtual void SetWindowTransform(const mozilla::gfx::Matrix& aTransform) override;
virtual void SetWindowMouseTransparent(bool aIsTransparent) override;
virtual void SetShowsToolbarButton(bool aShow) override;
virtual void SetShowsFullScreenButton(bool aShow) override;
virtual void SetWindowAnimationType(WindowAnimationType aType) override;

View File

@ -17,7 +17,7 @@
#include "nsIAppShellService.h"
#include "nsIBaseWindow.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsIXULWindow.h"
#include "nsIAppWindow.h"
#include "nsToolkit.h"
#include "nsPIDOMWindow.h"
#include "nsThreadUtils.h"
@ -306,9 +306,8 @@ nsresult nsCocoaWindow::Create(nsIWidget* aParent, nsNativeWidget aNativeParent,
NS_ENSURE_SUCCESS(rv, rv);
if (mWindowType == eWindowType_popup) {
if (aInitData->mMouseTransparent) {
[mWindow setIgnoresMouseEvents:YES];
}
SetWindowMouseTransparent(aInitData->mMouseTransparent);
// now we can convert newBounds to device pixels for the window we created,
// as the child view expects a rect expressed in the dev pix of its parent
LayoutDeviceIntRect devRect = RoundedToInt(newBounds * GetDesktopToDeviceScale());
@ -653,7 +652,7 @@ void nsCocoaWindow::SetModal(bool aState) {
// appears over behave as they should. We can't rely on native methods to
// do this, for the following reason: The OS runs modal non-sheet windows
// in an event loop (using [NSApplication runModalForWindow:] or similar
// methods) that's incompatible with the modal event loop in nsXULWindow::
// methods) that's incompatible with the modal event loop in AppWindow::
// ShowModal() (each of these event loops is "exclusive", and can't run at
// the same time as other (similar) event loops).
if (mWindowType != eWindowType_sheet) {
@ -1617,7 +1616,7 @@ void nsCocoaWindow::BackingScaleFactorChanged() {
mBackingScaleFactor = newScale;
if (!mWidgetListener || mWidgetListener->GetXULWindow()) {
if (!mWidgetListener || mWidgetListener->GetAppWindow()) {
return;
}
@ -2063,6 +2062,15 @@ void nsCocoaWindow::SetWindowTransform(const gfx::Matrix& aTransform) {
NS_OBJC_END_TRY_ABORT_BLOCK;
}
void nsCocoaWindow::SetWindowMouseTransparent(bool aIsTransparent) {
MOZ_ASSERT(mWindowType == eWindowType_popup, "This should only be called on popup windows.");
if (aIsTransparent) {
[mWindow setIgnoresMouseEvents:YES];
} else {
[mWindow setIgnoresMouseEvents:NO];
}
}
void nsCocoaWindow::SetShowsToolbarButton(bool aShow) {
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;

View File

@ -28,7 +28,6 @@
#include "nsIContent.h"
#include "nsIDocumentObserver.h"
#include "nsIRollupListener.h"
#include "nsBindingManager.h"
#include "nsXULPopupManager.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/EventDispatcher.h"

View File

@ -3732,13 +3732,7 @@ nsresult nsWindow::Create(nsIWidget* aParent, nsNativeWidget aNativeParent,
}
// If the popup ignores mouse events, set an empty input shape.
if (aInitData->mMouseTransparent) {
cairo_rectangle_int_t rect = {0, 0, 0, 0};
cairo_region_t* region = cairo_region_create_rectangle(&rect);
gdk_window_input_shape_combine_region(mGdkWindow, region, 0, 0);
cairo_region_destroy(region);
}
SetWindowMouseTransparent(aInitData->mMouseTransparent);
}
} break;
@ -4328,6 +4322,21 @@ nsTransparencyMode nsWindow::GetTransparencyMode() {
return mIsTransparent ? eTransparencyTransparent : eTransparencyOpaque;
}
void nsWindow::SetWindowMouseTransparent(bool aIsTransparent) {
if (!mGdkWindow) {
return;
}
cairo_rectangle_int_t emptyRect = {0, 0, 0, 0};
cairo_region_t* region =
aIsTransparent ? cairo_region_create_rectangle(&emptyRect) : nullptr;
gdk_window_input_shape_combine_region(mGdkWindow, region, 0, 0);
if (region) {
cairo_region_destroy(region);
}
}
// For setting the draggable titlebar region from CSS
// with -moz-window-dragging: drag.
void nsWindow::UpdateWindowDraggingRegion(

View File

@ -300,6 +300,7 @@ class nsWindow final : public nsBaseWidget {
virtual void SetTransparencyMode(nsTransparencyMode aMode) override;
virtual nsTransparencyMode GetTransparencyMode() override;
virtual void SetWindowMouseTransparent(bool aIsTransparent) override;
virtual void UpdateOpaqueRegion(
const LayoutDeviceIntRegion& aOpaqueRegion) override;
virtual nsresult ConfigureChildren(

View File

@ -12,6 +12,7 @@
#include "nsCOMPtr.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsIFrame.h"
#include "nsINodeList.h" //MY68
#include "nsFrameLoaderOwner.h"
#include "nsIContent.h"
#include "nsViewManager.h"
@ -265,8 +266,7 @@ nsBaseDragService::InvokeDragSession(
//
// The best way to avoid this is to catch the dragstart event on the item
// being dragged, and then to call preventDefault() and stopPropagating() on
// it. Alternatively, use EventUtils.synthesizeDragStart, which will do this
// for you.
// it.
if (XRE_IsParentProcess()) {
MOZ_ASSERT(
!xpc::IsInAutomation(),

View File

@ -29,7 +29,7 @@
#include "BasicLayers.h"
#include "ClientLayerManager.h"
#include "mozilla/layers/Compositor.h"
#include "nsIXULWindow.h"
#include "nsIAppWindow.h"
#include "nsIBaseWindow.h"
#include "nsXULPopupManager.h"
#include "nsIWidgetListener.h"
@ -1645,10 +1645,10 @@ nsIRollupListener* nsBaseWidget::GetActiveRollupListener() {
void nsBaseWidget::NotifyWindowDestroyed() {
if (!mWidgetListener) return;
nsCOMPtr<nsIXULWindow> window = mWidgetListener->GetXULWindow();
nsCOMPtr<nsIBaseWindow> xulWindow(do_QueryInterface(window));
if (xulWindow) {
xulWindow->Destroy();
nsCOMPtr<nsIAppWindow> window = mWidgetListener->GetAppWindow();
nsCOMPtr<nsIBaseWindow> appWindow(do_QueryInterface(window));
if (appWindow) {
appWindow->Destroy();
}
}
@ -2029,11 +2029,11 @@ void nsBaseWidget::NotifyLiveResizeStarted() {
if (!mWidgetListener) {
return;
}
nsCOMPtr<nsIXULWindow> xulWindow = mWidgetListener->GetXULWindow();
if (!xulWindow) {
nsCOMPtr<nsIAppWindow> appWindow = mWidgetListener->GetAppWindow();
if (!appWindow) {
return;
}
mLiveResizeListeners = xulWindow->GetLiveResizeListeners();
mLiveResizeListeners = appWindow->GetLiveResizeListeners();
for (uint32_t i = 0; i < mLiveResizeListeners.Length(); i++) {
mLiveResizeListeners[i]->LiveResizeStarted();
}

View File

@ -262,6 +262,12 @@ enum nsTopLevelWidgetZPlacement { // for PlaceBehind()
*/
#define NS_WIDGET_RESUME_PROCESS_OBSERVER_TOPIC "resume_process_notification"
/**
* When an app(-shell) is activated by the OS, this topic is notified.
* Currently, this only happens on Mac OSX.
*/
#define NS_WIDGET_MAC_APP_ACTIVATE_OBSERVER_TOPIC "mac_app_activate"
namespace mozilla {
namespace widget {
@ -1114,6 +1120,13 @@ class nsIWidget : public nsISupports {
*/
virtual void SetWindowTransform(const mozilla::gfx::Matrix& aTransform) {}
/**
* Set whether the window should ignore mouse events or not.
*
* This is only used on popup windows.
*/
virtual void SetWindowMouseTransparent(bool aIsTransparent) {}
/*
* On Mac OS X, this method shows or hides the pill button in the titlebar
* that's used to collapse the toolbar.

View File

@ -7,14 +7,14 @@
#include "nsRegion.h"
#include "nsView.h"
#include "nsIWidget.h"
#include "nsIXULWindow.h"
#include "nsIAppWindow.h"
#include "mozilla/BasicEvents.h"
#include "mozilla/PresShell.h"
using namespace mozilla;
nsIXULWindow* nsIWidgetListener::GetXULWindow() { return nullptr; }
nsIAppWindow* nsIWidgetListener::GetAppWindow() { return nullptr; }
nsView* nsIWidgetListener::GetView() { return nullptr; }

View File

@ -16,7 +16,7 @@
class nsView;
class nsIWidget;
class nsIXULWindow;
class nsIAppWindow;
namespace mozilla {
class PresShell;
@ -45,11 +45,11 @@ enum nsWindowZ {
class nsIWidgetListener {
public:
/**
* If this listener is for an nsIXULWindow, return it. If this is null, then
* If this listener is for an nsIAppWindow, return it. If this is null, then
* this is likely a listener for a view, which can be determined using
* GetView. If both methods return null, this will be an nsWebBrowser.
*/
virtual nsIXULWindow* GetXULWindow();
virtual nsIAppWindow* GetAppWindow();
/**
* If this listener is for an nsView, return it.

View File

@ -4,7 +4,7 @@ const { AppConstants } = ChromeUtils.import(
"resource://gre/modules/AppConstants.jsm"
);
// Note: widget/tests/test_bug1123480.xul checks whether nsTransferable behaves
// Note: widget/tests/test_bug1123480.xhtml checks whether nsTransferable behaves
// as expected with regards to private browsing mode and the clipboard cache,
// i.e. that the clipboard is not cached to the disk when private browsing mode
// is enabled.

View File

@ -1,85 +1,85 @@
[DEFAULT]
skip-if = os == 'android'
support-files =
empty_window.xul
empty_window.xhtml
utils.js
[test_bug343416.xul]
[test_bug343416.xhtml]
skip-if = debug
[test_bug429954.xul]
support-files = window_bug429954.xul
[test_bug444800.xul]
[test_bug429954.xhtml]
support-files = window_bug429954.xhtml
[test_bug444800.xhtml]
tags = clipboard
[test_bug478536.xul]
[test_bug478536.xhtml]
skip-if = true # Bug 561929
support-files = window_bug478536.xul
[test_bug517396.xul]
support-files = window_bug478536.xhtml
[test_bug517396.xhtml]
skip-if = (verify && (os == 'win'))
[test_bug538242.xul]
support-files = window_bug538242.xul
[test_bug538242.xhtml]
support-files = window_bug538242.xhtml
[test_bug565392.html]
tags = clipboard
skip-if = toolkit != "windows"
[test_bug593307.xul]
support-files = window_bug593307_offscreen.xul window_bug593307_centerscreen.xul
[test_bug593307.xhtml]
support-files = window_bug593307_offscreen.xhtml window_bug593307_centerscreen.xhtml
[test_bug1151186.html]
skip-if = os == 'linux' && debug #Bug 1176038
[test_keycodes.xul]
[test_wheeltransaction.xul]
support-files = window_wheeltransaction.xul
[test_keycodes.xhtml]
[test_wheeltransaction.xhtml]
support-files = window_wheeltransaction.xhtml
[test_imestate.html]
support-files = window_imestate_iframes.html
[test_plugin_scroll_consistency.html]
[test_composition_text_querycontent.xul]
support-files = window_composition_text_querycontent.xul
[test_input_events_on_deactive_window.xul]
[test_composition_text_querycontent.xhtml]
support-files = window_composition_text_querycontent.xhtml
[test_input_events_on_deactive_window.xhtml]
support-files = file_input_events_on_deactive_window.html
[test_position_on_resize.xul]
[test_position_on_resize.xhtml]
skip-if = (verify && (os == 'win'))
[test_sizemode_events.xul]
[test_taskbar_progress.xul]
[test_sizemode_events.xhtml]
[test_taskbar_progress.xhtml]
skip-if = toolkit != "cocoa" && toolkit != "windows" || (os == "win" && os_version == "10.0" && !ccov) # Bug 1456811
[test_bug760802.xul]
[test_clipboard.xul]
[test_bug760802.xhtml]
[test_clipboard.xhtml]
tags = clipboard
[test_panel_mouse_coords.xul]
[test_panel_mouse_coords.xhtml]
skip-if = toolkit == "windows" # bug 1009955
# Cocoa
[test_native_menus.xul]
[test_native_menus.xhtml]
skip-if = toolkit != "cocoa"
support-files = native_menus_window.xul
[test_native_mouse_mac.xul]
support-files = native_menus_window.xhtml
[test_native_mouse_mac.xhtml]
skip-if = toolkit != "cocoa" || os_version == '10.14' # macosx1014: bug 1137575
support-files = native_mouse_mac_window.xul
support-files = native_mouse_mac_window.xhtml
[test_bug413277.html]
skip-if = toolkit != "cocoa"
[test_bug428405.xul]
[test_bug428405.xhtml]
skip-if = toolkit != "cocoa"
[test_bug466599.xul]
[test_bug466599.xhtml]
tags = clipboard
skip-if = toolkit != "cocoa"
[test_bug485118.xul]
[test_bug485118.xhtml]
skip-if = toolkit != "cocoa"
[test_bug522217.xul]
[test_bug522217.xhtml]
tags = fullscreen
skip-if = toolkit != "cocoa"
support-files = window_bug522217.xul
[test_platform_colors.xul]
support-files = window_bug522217.xhtml
[test_platform_colors.xhtml]
#skip-if = toolkit != "cocoa"
skip-if = true # Bug 1207190
[test_standalone_native_menu.xul]
[test_standalone_native_menu.xhtml]
skip-if = toolkit != "cocoa"
support-files = standalone_native_menu_window.xul
[test_bug586713.xul]
support-files = standalone_native_menu_window.xhtml
[test_bug586713.xhtml]
skip-if = toolkit != "cocoa"
support-files = bug586713_window.xul
[test_key_event_counts.xul]
support-files = bug586713_window.xhtml
[test_key_event_counts.xhtml]
skip-if = toolkit != "cocoa"
[test_bug596600.xul]
[test_bug596600.xhtml]
support-files = file_bug596600.html
skip-if = toolkit != "cocoa"
[test_bug673301.xul]
[test_bug673301.xhtml]
tags = clipboard
skip-if = toolkit != "cocoa"
[test_secure_input.html]
@ -87,29 +87,29 @@ support-files = file_secure_input.html
skip-if = toolkit != "cocoa"
[test_native_key_bindings_mac.html]
skip-if = toolkit != "cocoa" || verify
[test_system_status_bar.xul]
[test_system_status_bar.xhtml]
skip-if = toolkit != "cocoa"
[test_system_font_changes.xul]
support-files = system_font_changes.xul
[test_system_font_changes.xhtml]
support-files = system_font_changes.xhtml
run-if = toolkit == 'gtk3' # Currently the test works on only gtk3
# Windows
# taskbar_previews.xul
# window_state_windows.xul
[test_chrome_context_menus_win.xul]
# taskbar_previews.xhtml
# window_state_windows.xhtml
[test_chrome_context_menus_win.xhtml]
skip-if = toolkit != "windows"
support-files = chrome_context_menus_win.xul
support-files = chrome_context_menus_win.xhtml
[test_plugin_input_event.html]
skip-if = toolkit != "windows"
[test_mouse_scroll.xul]
[test_mouse_scroll.xhtml]
skip-if = toolkit != "windows"
support-files = window_mouse_scroll_win.html
# Privacy relevant
[test_bug1123480.xul]
[test_bug1123480.xhtml]
tags = clipboard
[test_transferable_overflow.xul]
[test_transferable_overflow.xhtml]
skip-if = (verify && (os == 'mac' || os == 'linux'))
tags = clipboard

View File

@ -62,7 +62,7 @@ with Files("*673301*"):
with Files("test_assign_event_data.html"):
BUG_COMPONENT = ("Core", "DOM: UI Events & Focus Handling")
with Files("test_input_events_on_deactive_window.xul"):
with Files("test_input_events_on_deactive_window.xhtml"):
BUG_COMPONENT = ("Core", "DOM: UI Events & Focus Handling")
with Files("*chrome_context_menus_win*"):
@ -98,7 +98,7 @@ with Files("*plugin*"):
with Files("*position_on_resize*"):
BUG_COMPONENT = ("Core", "Widget: Gtk")
with Files("test_sizemode_events.xul"):
with Files("test_sizemode_events.xhtml"):
BUG_COMPONENT = ("Core", "Widget: Cocoa")
with Files("*system_status_bar*"):

View File

@ -126,6 +126,7 @@
let menuitem = document.createElementNS(XUL_NS, "menuitem");
menuitem.setAttribute("label", "detached menu item");
/* eslint-disable-next-line no-shadow */
menuitem.addEventListener("command", function (e) {
itemActivated = true;
})

View File

@ -146,6 +146,7 @@ ok(removedObserver, "The nsIIdleService should allow us to remove the observer j
function testIdleTime()
{
/* eslint-disable-next-line no-shadow */
var gotIdleTime = false
try
{

View File

@ -32,7 +32,7 @@ SimpleTest.waitForFocus(function () {
var maxWidth = win.outerWidth, maxHeight = win.outerHeight;
win.restore();
window.open("window_bug429954.xul", "_blank",
window.open("window_bug429954.xhtml", "_blank",
"chrome,resizable,width=" + maxWidth + ",height=" + maxHeight +
"screenX=" + maxX + "screenY=" + maxY);
});

View File

@ -24,7 +24,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=478536
<![CDATA[
SimpleTest.waitForExplicitFinish();
window.open("window_bug478536.xul", "_blank",
window.open("window_bug478536.xhtml", "_blank",
"chrome,width=600,height=600");
]]>

View File

@ -24,7 +24,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=522217
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function () {
window.open("window_bug522217.xul", "_blank",
window.open("window_bug522217.xhtml", "_blank",
"chrome,resizable,width=400,height=300");
});

View File

@ -34,7 +34,7 @@ SimpleTest.waitForFocus(function () {
return;
}
var win = window.open("window_bug538242.xul", "_blank",
var win = window.open("window_bug538242.xhtml", "_blank",
"chrome=1,width=400,height=300,left=100,top=100");
SimpleTest.waitForFocus(function () {
is(win.screenX, 100, "window should open at 100, 100");

View File

@ -20,7 +20,7 @@
<![CDATA[
SimpleTest.waitForExplicitFinish();
window.open("bug586713_window.xul", "bug586713_window",
window.open("bug586713_window.xhtml", "bug586713_window",
"chrome,width=600,height=600");
]]>

View File

@ -30,7 +30,7 @@ function finish() {
var mainWindow = window.docShell.rootTreeItem.domWindow;
var offscreenWindow = mainWindow.openDialog("window_bug593307_offscreen.xul", "",
var offscreenWindow = mainWindow.openDialog("window_bug593307_offscreen.xhtml", "",
"dialog=no,chrome,width=200,height=200,screenX=-3000,screenY=-3000",
SimpleTest, finish);

View File

@ -32,9 +32,9 @@ function moveMouseTo(x, y, andThen) {
}
function openWindows() {
gLeftWindow = open('empty_window.xul', '_blank', 'chrome,screenX=50,screenY=50,width=200,height=200');
gLeftWindow = open('empty_window.xhtml', '_blank', 'chrome,screenX=50,screenY=50,width=200,height=200');
SimpleTest.waitForFocus(function () {
gRightWindow = open('empty_window.xul', '', 'chrome,screenX=300,screenY=50,width=200,height=200');
gRightWindow = open('empty_window.xhtml', '', 'chrome,screenX=300,screenY=50,width=200,height=200');
SimpleTest.waitForFocus(attachBrowserToLeftWindow, gRightWindow);
}, gLeftWindow);
}

View File

@ -13,7 +13,7 @@
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
SimpleTest.waitForExplicitFinish();
var w = window.open('chrome_context_menus_win.xul', '_blank', 'chrome,resizable=yes,width=600,height=600');
var w = window.open('chrome_context_menus_win.xhtml', '_blank', 'chrome,resizable=yes,width=600,height=600');
function done()
{

View File

@ -25,7 +25,7 @@
// Strangely, this doesn't occur with RDP on Windows.
SimpleTest.expectAssertions(0, 3);
SimpleTest.waitForExplicitFinish();
window.open("window_composition_text_querycontent.xul", "_blank",
window.open("window_composition_text_querycontent.xhtml", "_blank",
"chrome,width=600,height=600");
]]>

View File

@ -195,11 +195,9 @@ function runBasicTest(aIsEditable, aInDesignMode, aDescription) {
onIMEFocusBlurHandler = null;
var focusedElement = gFM.focusedElement;
if (focusedElement) {
var bindingParent = document.getBindingParent(focusedElement);
if (bindingParent) {
focusedElement = bindingParent;
}
// FIXME(emilio, bug 981248): This is needed just for <input type=number>
while (focusedElement && focusedElement.isNativeAnonymous) {
focusedElement = focusedElement.parentNode;
}
if (aTest.focusable) {
is(focusedElement, element,
@ -1276,7 +1274,7 @@ function runTestPasswordFieldOnDialog() {
observe(subject, topic, data) {
if (topic === "domwindowopened") {
ok(true, "dialog window is created");
dialog = subject.QueryInterface(Ci.nsIDOMWindow);
dialog = subject;
dialog.addEventListener("load", onPasswordDialogLoad);
}
},

View File

@ -196,6 +196,7 @@ function* runKeyEventTests()
function onKeyEvent(e)
{
/* eslint-disable-next-line no-shadow */
function removeFlag(e, aFlag)
{
if (e.type == "keydown") {
@ -210,6 +211,7 @@ function* runKeyEventTests()
return false;
}
/* eslint-disable-next-line no-shadow */
function isStateChangingModifierKeyEvent(e)
{
var flags = 0;
@ -4977,6 +4979,7 @@ function* runXULKeyTests()
keyElement.setAttribute("command", "expectedCommand");
}
/* eslint-disable-next-line no-shadow */
for (var id in commandElements) {
commandElements[id].activeCount = 0;
}
@ -5194,6 +5197,7 @@ function* runReservedKeyTests()
function finializeKeyElementTest()
{
/* eslint-disable-next-line no-shadow */
for (var i = 0; i < contents.length; i++) {
contents[i].removeEventListener("keydown", onKeyInDefaultEventGroup, true);
contents[i].removeEventListener("keypress", onKeyInDefaultEventGroup, true);
@ -5265,10 +5269,12 @@ function* runTextInputTests()
textbox.value = "";
textbox.focus();
/* eslint-disable-next-line no-shadow */
var currentTestName = eventToString(aEvent);
// Check if the text comes with keypress events rather than composition events.
var keypress = 0;
/* eslint-disable-next-line no-shadow */
function onKeypress(aEvent) {
keypress++;
if (keypress == 1 && aExpectText == "") {

View File

@ -20,7 +20,7 @@
<![CDATA[
SimpleTest.waitForExplicitFinish();
window.open("native_menus_window.xul", "NativeMenuWindow",
window.open("native_menus_window.xhtml", "NativeMenuWindow",
"chrome,width=600,height=600");
]]>

View File

@ -20,7 +20,7 @@
<![CDATA[
SimpleTest.waitForExplicitFinish();
window.open("native_mouse_mac_window.xul", "NativeMouseWindow",
window.open("native_mouse_mac_window.xhtml", "NativeMouseWindow",
"chrome,width=600,height=600");
]]>

View File

@ -56,7 +56,7 @@ function startTest() {
}
function openWindow() {
gWindow = open('empty_window.xul', '_blank', 'chrome,screenX=50,screenY=50,width=200,height=200,resizable');
gWindow = open('empty_window.xhtml', '_blank', 'chrome,screenX=50,screenY=50,width=200,height=200,resizable');
SimpleTest.waitForFocus(runTest, gWindow);
}

View File

@ -20,7 +20,7 @@
<![CDATA[
SimpleTest.waitForExplicitFinish();
window.open("standalone_native_menu_window.xul", "StandaloneNativeMenuWindow",
window.open("standalone_native_menu_window.xhtml", "StandaloneNativeMenuWindow",
"chrome,width=600,height=600");
]]>

View File

@ -19,7 +19,7 @@
<![CDATA[
SimpleTest.waitForExplicitFinish();
window.open("system_font_changes.xul", "system_font_changes_window",
window.open("system_font_changes.xhtml", "system_font_changes_window",
"chrome,width=600,height=600");
]]>

View File

@ -47,7 +47,7 @@
// that the deletion might not be immediate.
//
// To avoid intermittents, we only check the file descriptor counts on non-Windows.
// test_bug1123480.xul will do some basic testing for Windows.
// test_bug1123480.xhtml will do some basic testing for Windows.
const {AppConstants} = ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
return AppConstants.platform !== 'win';
}

View File

@ -19,7 +19,7 @@
<![CDATA[
SimpleTest.waitForExplicitFinish();
window.open("window_wheeltransaction.xul", "_blank",
window.open("window_wheeltransaction.xhtml", "_blank",
"chrome,width=600,height=600");
]]>

View File

@ -19,7 +19,7 @@ var finish = window.arguments[1];
function onLoad()
{
centerscreen = window.openDialog('window_bug593307_centerscreen.xul','', 'chrome,centerscreen,dependent,dialog=no');
centerscreen = window.openDialog('window_bug593307_centerscreen.xhtml','', 'chrome,centerscreen,dependent,dialog=no');
}
function finished() {

View File

@ -20,7 +20,7 @@
#include "nsIDocShell.h"
#include "nsISupportsImpl.h"
#include "nsIWidget.h"
#include "nsIXULWindow.h"
#include "nsIAppWindow.h"
#include "nsServiceManagerUtils.h"
#include "nsThreadUtils.h"
#include "nsWindowDefs.h"
@ -42,7 +42,7 @@ class HWNDGetter : public mozilla::Runnable {
// Jump through some hoops to locate the hidden window.
nsCOMPtr<nsIAppShellService> appShell(
do_GetService(NS_APPSHELLSERVICE_CONTRACTID));
nsCOMPtr<nsIXULWindow> hiddenWindow;
nsCOMPtr<nsIAppWindow> hiddenWindow;
nsresult rv = appShell->GetHiddenWindow(getter_AddRefs(hiddenWindow));
if (NS_FAILED(rv)) {

View File

@ -22,7 +22,7 @@
#include "nsQueryObject.h"
static const char* kPageSetupDialogURL =
"chrome://global/content/printPageSetup.xul";
"chrome://global/content/printPageSetup.xhtml";
using namespace mozilla;
using namespace mozilla::widget;

View File

@ -653,6 +653,7 @@ nsWindow::nsWindow(bool aIsChildWindow)
mIdleService = nullptr;
mSizeConstraintsScale = GetDefaultScale().scale;
mMaxTextureSize = -1; // Will be calculated when layer manager is created.
sInstanceCount++;
}
@ -1684,6 +1685,25 @@ void nsWindow::LockAspectRatio(bool aShouldLock) {
}
}
/**************************************************************
*
* SECTION: nsIWidget::SetWindowMouseTransparent
*
* Sets whether the window should ignore mouse events.
*
**************************************************************/
void nsWindow::SetWindowMouseTransparent(bool aIsTransparent) {
if (!mWnd) {
return;
}
LONG_PTR oldStyle = ::GetWindowLongPtrW(mWnd, GWL_EXSTYLE);
LONG_PTR newStyle = aIsTransparent ? (oldStyle | WS_EX_TRANSPARENT)
: (oldStyle & ~WS_EX_TRANSPARENT);
::SetWindowLongPtrW(mWnd, GWL_EXSTYLE, newStyle);
mMouseTransparent = aIsTransparent;
}
/**************************************************************
*
* SECTION: nsIWidget::Move, nsIWidget::Resize,
@ -1701,14 +1721,13 @@ void nsWindow::SetSizeConstraints(const SizeConstraints& aConstraints) {
c.mMinSize.height =
std::max(int32_t(::GetSystemMetrics(SM_CYMINTRACK)), c.mMinSize.height);
}
KnowsCompositor* knowsCompositor = GetLayerManager()->AsKnowsCompositor();
if (knowsCompositor) {
int32_t maxSize = knowsCompositor->GetMaxTextureSize();
if (mMaxTextureSize > 0) {
// We can't make ThebesLayers bigger than this anyway.. no point it letting
// a window grow bigger as we won't be able to draw content there in
// general.
c.mMaxSize.width = std::min(c.mMaxSize.width, maxSize);
c.mMaxSize.height = std::min(c.mMaxSize.height, maxSize);
c.mMaxSize.width = std::min(c.mMaxSize.width, mMaxTextureSize);
c.mMaxSize.height = std::min(c.mMaxSize.height, mMaxTextureSize);
}
mSizeConstraintsScale = GetDefaultScale().scale;
@ -3729,6 +3748,10 @@ bool nsWindow::HasPendingInputEvent() {
LayerManager* nsWindow::GetLayerManager(PLayerTransactionChild* aShadowManager,
LayersBackend aBackendHint,
LayerManagerPersistence aPersistence) {
if (mLayerManager) {
return mLayerManager;
}
RECT windowRect;
::GetClientRect(mWnd, &windowRect);
@ -3769,6 +3792,19 @@ LayerManager* nsWindow::GetLayerManager(PLayerTransactionChild* aShadowManager,
NS_ASSERTION(mLayerManager, "Couldn't provide a valid layer manager.");
if (mLayerManager) {
// Update the size constraints now that the layer manager has been
// created.
KnowsCompositor* knowsCompositor = mLayerManager->AsKnowsCompositor();
if (knowsCompositor) {
SizeConstraints c = mSizeConstraints;
mMaxTextureSize = knowsCompositor->GetMaxTextureSize();
c.mMaxSize.width = std::min(c.mMaxSize.width, mMaxTextureSize);
c.mMaxSize.height = std::min(c.mMaxSize.height, mMaxTextureSize);
nsBaseWidget::SetSizeConstraints(c);
}
}
return mLayerManager;
}

View File

@ -130,6 +130,7 @@ class nsWindow final : public nsWindowBase {
virtual void SetSizeConstraints(const SizeConstraints& aConstraints) override;
virtual void LockAspectRatio(bool aShouldLock) override;
virtual const SizeConstraints GetSizeConstraints() override;
virtual void SetWindowMouseTransparent(bool aIsTransparent) override;
virtual void Move(double aX, double aY) override;
virtual void Resize(double aWidth, double aHeight, bool aRepaint) override;
virtual void Resize(double aX, double aY, double aWidth, double aHeight,
@ -688,6 +689,7 @@ class nsWindow final : public nsWindowBase {
static void InitMouseWheelScrollData();
double mSizeConstraintsScale; // scale in effect when setting constraints
int32_t mMaxTextureSize;
// Pointer events processing and management
WinPointerEvents mPointerEvents;