2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-01-03 05:23:11 -08:00
|
|
|
#include "nsView.h"
|
2013-01-03 05:23:08 -08:00
|
|
|
|
2012-12-14 15:58:45 -08:00
|
|
|
#include "mozilla/Attributes.h"
|
2013-09-25 04:21:22 -07:00
|
|
|
#include "mozilla/BasicEvents.h"
|
2012-12-14 15:58:45 -08:00
|
|
|
#include "mozilla/DebugOnly.h"
|
|
|
|
#include "mozilla/Likely.h"
|
2013-05-07 11:48:59 -07:00
|
|
|
#include "mozilla/Poison.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIWidget.h"
|
|
|
|
#include "nsViewManager.h"
|
2012-08-15 11:52:42 -07:00
|
|
|
#include "nsIFrame.h"
|
2013-04-29 05:11:04 -07:00
|
|
|
#include "nsPresArena.h"
|
2012-08-15 11:52:42 -07:00
|
|
|
#include "nsXULPopupManager.h"
|
|
|
|
#include "nsIWidgetListener.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-12-02 00:56:54 -08:00
|
|
|
using namespace mozilla;
|
|
|
|
|
2013-01-03 05:23:11 -08:00
|
|
|
nsView::nsView(nsViewManager* aViewManager, nsViewVisibility aVisibility)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-01-03 05:23:11 -08:00
|
|
|
MOZ_COUNT_CTOR(nsView);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
mVis = aVisibility;
|
|
|
|
// Views should be transparent by default. Not being transparent is
|
|
|
|
// a promise that the view will paint all its pixels opaquely. Views
|
|
|
|
// should make this promise explicitly by calling
|
|
|
|
// SetViewContentTransparency.
|
|
|
|
mVFlags = 0;
|
|
|
|
mViewManager = aViewManager;
|
2012-07-30 07:20:58 -07:00
|
|
|
mDirtyRegion = nullptr;
|
2011-10-17 07:59:28 -07:00
|
|
|
mWidgetIsTopLevel = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-01-03 05:23:11 -08:00
|
|
|
void nsView::DropMouseGrabbing()
|
2009-09-13 06:13:16 -07:00
|
|
|
{
|
2011-11-21 09:53:20 -08:00
|
|
|
nsIPresShell* presShell = mViewManager->GetPresShell();
|
|
|
|
if (presShell)
|
|
|
|
presShell->ClearMouseCaptureOnView(this);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-01-03 05:23:11 -08:00
|
|
|
nsView::~nsView()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-01-03 05:23:11 -08:00
|
|
|
MOZ_COUNT_DTOR(nsView);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
while (GetFirstChild())
|
|
|
|
{
|
2013-01-03 05:23:11 -08:00
|
|
|
nsView* child = GetFirstChild();
|
2007-03-22 10:30:00 -07:00
|
|
|
if (child->GetViewManager() == mViewManager) {
|
|
|
|
child->Destroy();
|
|
|
|
} else {
|
|
|
|
// just unhook it. Someone else will want to destroy this.
|
|
|
|
RemoveChild(child);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mViewManager)
|
|
|
|
{
|
|
|
|
DropMouseGrabbing();
|
|
|
|
|
2013-01-04 19:13:05 -08:00
|
|
|
nsView *rootView = mViewManager->GetRootView();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
if (rootView)
|
|
|
|
{
|
|
|
|
// Root views can have parents!
|
|
|
|
if (mParent)
|
|
|
|
{
|
|
|
|
mViewManager->RemoveChild(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rootView == this)
|
|
|
|
{
|
|
|
|
// Inform the view manager that the root view has gone away...
|
2012-07-30 07:20:58 -07:00
|
|
|
mViewManager->SetRootView(nullptr);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (mParent)
|
|
|
|
{
|
|
|
|
mParent->RemoveChild(this);
|
|
|
|
}
|
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
mViewManager = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
else if (mParent)
|
|
|
|
{
|
|
|
|
mParent->RemoveChild(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Destroy and release the widget
|
2011-03-21 11:28:10 -07:00
|
|
|
DestroyWidget();
|
|
|
|
|
|
|
|
delete mDirtyRegion;
|
|
|
|
}
|
|
|
|
|
2013-05-28 01:11:11 -07:00
|
|
|
class DestroyWidgetRunnable : public nsRunnable {
|
|
|
|
public:
|
|
|
|
NS_DECL_NSIRUNNABLE
|
|
|
|
|
|
|
|
explicit DestroyWidgetRunnable(nsIWidget* aWidget) : mWidget(aWidget) {}
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsCOMPtr<nsIWidget> mWidget;
|
|
|
|
};
|
|
|
|
|
|
|
|
NS_IMETHODIMP DestroyWidgetRunnable::Run()
|
|
|
|
{
|
|
|
|
mWidget->Destroy();
|
|
|
|
mWidget = nullptr;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-01-03 05:23:11 -08:00
|
|
|
void nsView::DestroyWidget()
|
2011-03-21 11:28:10 -07:00
|
|
|
{
|
2007-03-22 10:30:00 -07:00
|
|
|
if (mWindow)
|
|
|
|
{
|
2010-06-24 19:01:06 -07:00
|
|
|
// If we are not attached to a base window, we're going to tear down our
|
|
|
|
// widget here. However, if we're attached to somebody elses widget, we
|
|
|
|
// want to leave the widget alone: don't reset the client data or call
|
|
|
|
// Destroy. Just clear our event view ptr and free our reference to it.
|
|
|
|
if (mWidgetIsTopLevel) {
|
2012-08-15 11:53:14 -07:00
|
|
|
mWindow->SetAttachedWidgetListener(nullptr);
|
2010-06-24 19:01:06 -07:00
|
|
|
}
|
|
|
|
else {
|
2012-08-15 11:52:42 -07:00
|
|
|
mWindow->SetWidgetListener(nullptr);
|
2013-05-28 01:11:11 -07:00
|
|
|
|
|
|
|
nsCOMPtr<nsIRunnable> widgetDestroyer =
|
|
|
|
new DestroyWidgetRunnable(mWindow);
|
|
|
|
|
|
|
|
NS_DispatchToMainThread(widgetDestroyer);
|
2010-06-24 19:01:06 -07:00
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_RELEASE(mWindow);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-03 05:23:11 -08:00
|
|
|
nsView* nsView::GetViewFor(nsIWidget* aWidget)
|
2012-08-15 11:53:14 -07:00
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
NS_PRECONDITION(nullptr != aWidget, "null widget ptr");
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-15 11:53:14 -07:00
|
|
|
nsIWidgetListener* listener = aWidget->GetWidgetListener();
|
|
|
|
if (listener) {
|
2013-01-03 05:23:11 -08:00
|
|
|
nsView* view = listener->GetView();
|
2012-08-15 11:53:14 -07:00
|
|
|
if (view)
|
|
|
|
return view;
|
2011-12-16 16:24:11 -08:00
|
|
|
}
|
2010-06-24 19:01:06 -07:00
|
|
|
|
2012-08-15 11:53:14 -07:00
|
|
|
listener = aWidget->GetAttachedWidgetListener();
|
|
|
|
return listener ? listener->GetView() : nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-01-03 05:23:11 -08:00
|
|
|
void nsView::Destroy()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-04-29 05:11:04 -07:00
|
|
|
this->~nsView();
|
2013-05-07 11:48:59 -07:00
|
|
|
mozWritePoison(this, sizeof(*this));
|
2013-04-29 05:11:04 -07:00
|
|
|
nsView::operator delete(this);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-01-03 05:23:11 -08:00
|
|
|
void nsView::SetPosition(nscoord aX, nscoord aY)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
mDimBounds.x += aX - mPosX;
|
|
|
|
mDimBounds.y += aY - mPosY;
|
|
|
|
mPosX = aX;
|
|
|
|
mPosY = aY;
|
|
|
|
|
|
|
|
NS_ASSERTION(GetParent() || (aX == 0 && aY == 0),
|
|
|
|
"Don't try to move the root widget to something non-zero");
|
|
|
|
|
2011-12-23 19:52:23 -08:00
|
|
|
ResetWidgetBounds(true, false);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-01-03 05:23:11 -08:00
|
|
|
void nsView::ResetWidgetBounds(bool aRecurse, bool aForceSync)
|
2011-12-23 19:52:23 -08:00
|
|
|
{
|
2007-03-22 10:30:00 -07:00
|
|
|
if (mWindow) {
|
2011-12-23 19:52:23 -08:00
|
|
|
if (!aForceSync) {
|
|
|
|
// Don't change widget geometry synchronously, since that can
|
|
|
|
// cause synchronous painting.
|
2007-03-22 10:30:00 -07:00
|
|
|
mViewManager->PostPendingUpdate();
|
2011-12-23 19:52:23 -08:00
|
|
|
} else {
|
|
|
|
DoResetWidgetBounds(false, true);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2011-12-23 19:52:23 -08:00
|
|
|
return;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-12-23 19:52:23 -08:00
|
|
|
if (aRecurse) {
|
2007-03-22 10:30:00 -07:00
|
|
|
// reposition any widgets under this view
|
2013-01-03 05:23:11 -08:00
|
|
|
for (nsView* v = GetFirstChild(); v; v = v->GetNextSibling()) {
|
2011-12-23 19:52:23 -08:00
|
|
|
v->ResetWidgetBounds(true, aForceSync);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-03 05:23:11 -08:00
|
|
|
bool nsView::IsEffectivelyVisible()
|
2009-07-29 19:54:42 -07:00
|
|
|
{
|
2013-01-03 05:23:11 -08:00
|
|
|
for (nsView* v = this; v; v = v->mParent) {
|
2009-07-29 19:54:42 -07:00
|
|
|
if (v->GetVisibility() == nsViewVisibility_kHide)
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2009-07-29 19:54:42 -07:00
|
|
|
}
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2009-07-29 19:54:42 -07:00
|
|
|
}
|
|
|
|
|
2013-01-03 05:23:11 -08:00
|
|
|
nsIntRect nsView::CalcWidgetBounds(nsWindowType aType)
|
2007-05-25 20:45:00 -07:00
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t p2a = mViewManager->AppUnitsPerDevPixel();
|
2007-05-25 20:45:00 -07:00
|
|
|
|
|
|
|
nsRect viewBounds(mDimBounds);
|
|
|
|
|
2013-01-03 05:23:11 -08:00
|
|
|
nsView* parent = GetParent();
|
2013-07-30 09:22:41 -07:00
|
|
|
nsIWidget* parentWidget = nullptr;
|
2010-07-18 19:23:47 -07:00
|
|
|
if (parent) {
|
2007-05-25 20:45:00 -07:00
|
|
|
nsPoint offset;
|
2013-07-30 09:22:41 -07:00
|
|
|
parentWidget = parent->GetNearestWidget(&offset, p2a);
|
2010-04-22 17:21:54 -07:00
|
|
|
// make viewBounds be relative to the parent widget, in appunits
|
2007-05-25 20:45:00 -07:00
|
|
|
viewBounds += offset;
|
|
|
|
|
2007-05-31 16:23:32 -07:00
|
|
|
if (parentWidget && aType == eWindowType_popup &&
|
2009-07-29 19:54:42 -07:00
|
|
|
IsEffectivelyVisible()) {
|
2010-06-24 19:01:06 -07:00
|
|
|
// put offset into screen coordinates. (based on client area origin)
|
2009-02-18 16:11:49 -08:00
|
|
|
nsIntPoint screenPoint = parentWidget->WidgetToScreenOffset();
|
|
|
|
viewBounds += nsPoint(NSIntPixelsToAppUnits(screenPoint.x, p2a),
|
|
|
|
NSIntPixelsToAppUnits(screenPoint.y, p2a));
|
2007-05-25 20:45:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-04-22 17:21:54 -07:00
|
|
|
// Compute widget bounds in device pixels
|
2009-05-07 19:31:04 -07:00
|
|
|
nsIntRect newBounds = viewBounds.ToNearestPixels(p2a);
|
2007-05-25 20:45:00 -07:00
|
|
|
|
2013-07-30 09:22:41 -07:00
|
|
|
#ifdef XP_MACOSX
|
|
|
|
// cocoa rounds widget coordinates to the nearest global "display pixel"
|
|
|
|
// integer value. So we avoid fractional display pixel values by rounding
|
|
|
|
// to the nearest value that won't yield a fractional display pixel.
|
|
|
|
nsIWidget* widget = parentWidget ? parentWidget : mWindow;
|
|
|
|
uint32_t round;
|
|
|
|
if (aType == eWindowType_popup && widget &&
|
|
|
|
((round = widget->RoundsWidgetCoordinatesTo()) > 1)) {
|
|
|
|
nsIntSize pixelRoundedSize = newBounds.Size();
|
|
|
|
// round the top left and bottom right to the nearest round pixel
|
|
|
|
newBounds.x = NSToIntRoundUp(NSAppUnitsToDoublePixels(viewBounds.x, p2a) / round) * round;
|
|
|
|
newBounds.y = NSToIntRoundUp(NSAppUnitsToDoublePixels(viewBounds.y, p2a) / round) * round;
|
|
|
|
newBounds.width =
|
|
|
|
NSToIntRoundUp(NSAppUnitsToDoublePixels(viewBounds.XMost(), p2a) / round) * round - newBounds.x;
|
|
|
|
newBounds.height =
|
|
|
|
NSToIntRoundUp(NSAppUnitsToDoublePixels(viewBounds.YMost(), p2a) / round) * round - newBounds.y;
|
|
|
|
// but if that makes the widget larger then our frame may not paint the
|
|
|
|
// extra pixels, so reduce the size to the nearest round value
|
|
|
|
if (newBounds.width > pixelRoundedSize.width) {
|
|
|
|
newBounds.width -= round;
|
|
|
|
}
|
|
|
|
if (newBounds.height > pixelRoundedSize.height) {
|
|
|
|
newBounds.height -= round;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-07-18 19:23:47 -07:00
|
|
|
// Compute where the top-left of our widget ended up relative to the parent
|
|
|
|
// widget, in appunits.
|
2007-05-25 20:45:00 -07:00
|
|
|
nsPoint roundedOffset(NSIntPixelsToAppUnits(newBounds.x, p2a),
|
|
|
|
NSIntPixelsToAppUnits(newBounds.y, p2a));
|
2010-04-22 17:21:54 -07:00
|
|
|
|
|
|
|
// mViewToWidgetOffset is added to coordinates relative to the view origin
|
|
|
|
// to get coordinates relative to the widget.
|
|
|
|
// The view origin, relative to the parent widget, is at
|
|
|
|
// (mPosX,mPosY) - mDimBounds.TopLeft() + viewBounds.TopLeft().
|
|
|
|
// Our widget, relative to the parent widget, is roundedOffset.
|
|
|
|
mViewToWidgetOffset = nsPoint(mPosX, mPosY)
|
|
|
|
- mDimBounds.TopLeft() + viewBounds.TopLeft() - roundedOffset;
|
2007-05-25 20:45:00 -07:00
|
|
|
|
|
|
|
return newBounds;
|
|
|
|
}
|
|
|
|
|
2013-01-03 05:23:11 -08:00
|
|
|
void nsView::DoResetWidgetBounds(bool aMoveOnly,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aInvalidateChangedSize) {
|
2007-03-22 10:30:00 -07:00
|
|
|
// The geometry of a root view's widget is controlled externally,
|
|
|
|
// NOT by sizing or positioning the view
|
2013-01-04 19:13:05 -08:00
|
|
|
if (mViewManager->GetRootView() == this) {
|
2007-03-22 10:30:00 -07:00
|
|
|
return;
|
|
|
|
}
|
2013-05-01 14:21:32 -07:00
|
|
|
|
|
|
|
NS_PRECONDITION(mWindow, "Why was this called??");
|
|
|
|
|
2013-05-01 14:21:33 -07:00
|
|
|
// Hold this ref to make sure it stays alive.
|
|
|
|
nsCOMPtr<nsIWidget> widget = mWindow;
|
|
|
|
|
|
|
|
// Stash a copy of these and use them so we can handle this being deleted (say
|
|
|
|
// from sync painting/flushing from Show/Move/Resize on the widget).
|
|
|
|
nsIntRect newBounds;
|
2013-05-10 00:13:49 -07:00
|
|
|
nsRefPtr<nsDeviceContext> dx = mViewManager->GetDeviceContext();
|
2013-05-01 14:21:33 -07:00
|
|
|
|
|
|
|
nsWindowType type;
|
|
|
|
widget->GetWindowType(type);
|
2013-05-01 14:21:32 -07:00
|
|
|
|
2009-01-14 19:27:09 -08:00
|
|
|
nsIntRect curBounds;
|
2013-05-01 14:21:33 -07:00
|
|
|
widget->GetClientBounds(curBounds);
|
2013-05-01 14:21:33 -07:00
|
|
|
bool invisiblePopup = type == eWindowType_popup &&
|
|
|
|
((curBounds.IsEmpty() && mDimBounds.IsEmpty()) ||
|
|
|
|
mVis == nsViewVisibility_kHide);
|
2010-06-24 19:01:06 -07:00
|
|
|
|
2013-05-01 14:21:33 -07:00
|
|
|
if (invisiblePopup) {
|
2013-05-01 14:21:33 -07:00
|
|
|
// We're going to hit the early exit below, avoid calling CalcWidgetBounds.
|
|
|
|
} else {
|
|
|
|
newBounds = CalcWidgetBounds(type);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool curVisibility = widget->IsVisible();
|
|
|
|
bool newVisibility = IsEffectivelyVisible();
|
|
|
|
if (curVisibility && !newVisibility) {
|
|
|
|
widget->Show(false);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-05-01 14:21:33 -07:00
|
|
|
if (invisiblePopup) {
|
2012-09-19 20:12:36 -07:00
|
|
|
// Don't manipulate empty or hidden popup widgets. For example there's no
|
|
|
|
// point moving hidden comboboxes around, or doing X server roundtrips
|
2007-03-22 10:30:00 -07:00
|
|
|
// to compute their true screen position. This could mean that WidgetToScreen
|
|
|
|
// operations on these widgets don't return up-to-date values, but popup
|
|
|
|
// positions aren't reliable anyway because of correction to be on or off-screen.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool changedPos = curBounds.TopLeft() != newBounds.TopLeft();
|
|
|
|
bool changedSize = curBounds.Size() != newBounds.Size();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-06-24 19:01:06 -07:00
|
|
|
// Child views are never attached to top level widgets, this is safe.
|
2012-12-06 09:31:34 -08:00
|
|
|
|
|
|
|
// Coordinates are converted to display pixels for window Move/Resize APIs,
|
|
|
|
// because of the potential for device-pixel coordinate spaces for mixed
|
|
|
|
// hidpi/lodpi screens to overlap each other and result in bad placement
|
|
|
|
// (bug 814434).
|
2013-04-18 08:35:49 -07:00
|
|
|
double invScale;
|
|
|
|
|
|
|
|
// Bug 861270: for correct widget manipulation at arbitrary scale factors,
|
2013-05-01 14:21:33 -07:00
|
|
|
// prefer to base scaling on widget->GetDefaultScale(). But only do this if
|
2013-04-18 08:35:49 -07:00
|
|
|
// it matches the view manager's device context scale after allowing for the
|
|
|
|
// quantization to app units, because of OS X multiscreen issues (where the
|
|
|
|
// only two scales are 1.0 or 2.0, and so the quantization doesn't actually
|
|
|
|
// cause problems anyhow).
|
|
|
|
// In the case of a mismatch, fall back to scaling based on the dev context's
|
|
|
|
// unscaledAppUnitsPerDevPixel value. On platforms where the device-pixel
|
|
|
|
// scale is uniform across all displays (currently all except OS X), we'll
|
|
|
|
// always use the precise value from mWindow->GetDefaultScale here.
|
2013-09-17 17:45:19 -07:00
|
|
|
CSSToLayoutDeviceScale scale = widget->GetDefaultScale();
|
|
|
|
if (NSToIntRound(60.0 / scale.scale) == dx->UnscaledAppUnitsPerDevPixel()) {
|
|
|
|
invScale = 1.0 / scale.scale;
|
2013-04-18 08:35:49 -07:00
|
|
|
} else {
|
|
|
|
invScale = dx->UnscaledAppUnitsPerDevPixel() / 60.0;
|
|
|
|
}
|
2012-12-06 09:31:34 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (changedPos) {
|
|
|
|
if (changedSize && !aMoveOnly) {
|
2013-05-01 14:21:33 -07:00
|
|
|
widget->ResizeClient(newBounds.x * invScale,
|
|
|
|
newBounds.y * invScale,
|
|
|
|
newBounds.width * invScale,
|
|
|
|
newBounds.height * invScale,
|
|
|
|
aInvalidateChangedSize);
|
2007-03-22 10:30:00 -07:00
|
|
|
} else {
|
2013-05-01 14:21:33 -07:00
|
|
|
widget->MoveClient(newBounds.x * invScale,
|
|
|
|
newBounds.y * invScale);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (changedSize && !aMoveOnly) {
|
2013-05-01 14:21:33 -07:00
|
|
|
widget->ResizeClient(newBounds.width * invScale,
|
|
|
|
newBounds.height * invScale,
|
|
|
|
aInvalidateChangedSize);
|
2007-03-22 10:30:00 -07:00
|
|
|
} // else do nothing!
|
|
|
|
}
|
2013-05-01 14:21:32 -07:00
|
|
|
|
|
|
|
if (!curVisibility && newVisibility) {
|
2013-05-01 14:21:33 -07:00
|
|
|
widget->Show(true);
|
2013-05-01 14:21:32 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-01-03 05:23:11 -08:00
|
|
|
void nsView::SetDimensions(const nsRect& aRect, bool aPaint, bool aResizeWidget)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
nsRect dims = aRect;
|
|
|
|
dims.MoveBy(mPosX, mPosY);
|
|
|
|
|
|
|
|
// Don't use nsRect's operator== here, since it returns true when
|
|
|
|
// both rects are empty even if they have different widths and we
|
|
|
|
// have cases where that sort of thing matters to us.
|
|
|
|
if (mDimBounds.TopLeft() == dims.TopLeft() &&
|
|
|
|
mDimBounds.Size() == dims.Size()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mDimBounds = dims;
|
|
|
|
|
|
|
|
if (aResizeWidget) {
|
2011-12-23 19:52:23 -08:00
|
|
|
ResetWidgetBounds(false, false);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-03 05:23:11 -08:00
|
|
|
void nsView::NotifyEffectiveVisibilityChanged(bool aEffectivelyVisible)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2009-07-29 19:54:42 -07:00
|
|
|
if (!aEffectivelyVisible)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
DropMouseGrabbing();
|
|
|
|
}
|
|
|
|
|
2013-02-25 13:18:48 -08:00
|
|
|
SetForcedRepaint(true);
|
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
if (nullptr != mWindow)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-05-01 14:21:32 -07:00
|
|
|
ResetWidgetBounds(false, false);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-01-03 05:23:11 -08:00
|
|
|
for (nsView* child = mFirstChild; child; child = child->mNextSibling) {
|
2009-07-29 19:54:42 -07:00
|
|
|
if (child->mVis == nsViewVisibility_kHide) {
|
|
|
|
// It was effectively hidden and still is
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// Our child is visible if we are
|
|
|
|
child->NotifyEffectiveVisibilityChanged(aEffectivelyVisible);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-03 05:23:11 -08:00
|
|
|
void nsView::SetVisibility(nsViewVisibility aVisibility)
|
2009-07-29 19:54:42 -07:00
|
|
|
{
|
|
|
|
mVis = aVisibility;
|
|
|
|
NotifyEffectiveVisibilityChanged(IsEffectivelyVisible());
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-01-03 05:23:11 -08:00
|
|
|
void nsView::SetFloating(bool aFloatingView)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
if (aFloatingView)
|
|
|
|
mVFlags |= NS_VIEW_FLAG_FLOATING;
|
|
|
|
else
|
|
|
|
mVFlags &= ~NS_VIEW_FLAG_FLOATING;
|
|
|
|
}
|
|
|
|
|
2013-01-03 05:23:11 -08:00
|
|
|
void nsView::InvalidateHierarchy(nsViewManager *aViewManagerParent)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-01-04 19:13:05 -08:00
|
|
|
if (mViewManager->GetRootView() == this)
|
2007-03-22 10:30:00 -07:00
|
|
|
mViewManager->InvalidateHierarchy();
|
|
|
|
|
2013-01-03 05:23:11 -08:00
|
|
|
for (nsView *child = mFirstChild; child; child = child->GetNextSibling())
|
2007-03-22 10:30:00 -07:00
|
|
|
child->InvalidateHierarchy(aViewManagerParent);
|
|
|
|
}
|
|
|
|
|
2013-01-03 05:23:11 -08:00
|
|
|
void nsView::InsertChild(nsView *aChild, nsView *aSibling)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
NS_PRECONDITION(nullptr != aChild, "null ptr");
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
if (nullptr != aChild)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
if (nullptr != aSibling)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-06-25 12:59:42 -07:00
|
|
|
#ifdef DEBUG
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_ASSERTION(aSibling->GetParent() == this, "tried to insert view with invalid sibling");
|
|
|
|
#endif
|
|
|
|
//insert after sibling
|
|
|
|
aChild->SetNextSibling(aSibling->GetNextSibling());
|
|
|
|
aSibling->SetNextSibling(aChild);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
aChild->SetNextSibling(mFirstChild);
|
|
|
|
mFirstChild = aChild;
|
|
|
|
}
|
|
|
|
aChild->SetParent(this);
|
|
|
|
|
|
|
|
// If we just inserted a root view, then update the RootViewManager
|
|
|
|
// on all view managers in the new subtree.
|
|
|
|
|
2013-01-04 19:13:23 -08:00
|
|
|
nsViewManager *vm = aChild->GetViewManager();
|
2013-01-04 19:13:05 -08:00
|
|
|
if (vm->GetRootView() == aChild)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
aChild->InvalidateHierarchy(nullptr); // don't care about releasing grabs
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-03 05:23:11 -08:00
|
|
|
void nsView::RemoveChild(nsView *child)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
NS_PRECONDITION(nullptr != child, "null ptr");
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
if (nullptr != child)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-01-03 05:23:11 -08:00
|
|
|
nsView* prevKid = nullptr;
|
|
|
|
nsView* kid = mFirstChild;
|
2012-12-02 00:56:54 -08:00
|
|
|
DebugOnly<bool> found = false;
|
2012-07-30 07:20:58 -07:00
|
|
|
while (nullptr != kid) {
|
2007-03-22 10:30:00 -07:00
|
|
|
if (kid == child) {
|
2012-07-30 07:20:58 -07:00
|
|
|
if (nullptr != prevKid) {
|
2007-03-22 10:30:00 -07:00
|
|
|
prevKid->SetNextSibling(kid->GetNextSibling());
|
|
|
|
} else {
|
|
|
|
mFirstChild = kid->GetNextSibling();
|
|
|
|
}
|
2012-07-30 07:20:58 -07:00
|
|
|
child->SetParent(nullptr);
|
2011-10-17 07:59:28 -07:00
|
|
|
found = true;
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
prevKid = kid;
|
|
|
|
kid = kid->GetNextSibling();
|
|
|
|
}
|
|
|
|
NS_ASSERTION(found, "tried to remove non child");
|
|
|
|
|
|
|
|
// If we just removed a root view, then update the RootViewManager
|
|
|
|
// on all view managers in the removed subtree.
|
|
|
|
|
2013-01-04 19:13:23 -08:00
|
|
|
nsViewManager *vm = child->GetViewManager();
|
2013-01-04 19:13:05 -08:00
|
|
|
if (vm->GetRootView() == child)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-01-04 19:13:23 -08:00
|
|
|
child->InvalidateHierarchy(GetViewManager());
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Native widgets ultimately just can't deal with the awesome power of
|
|
|
|
// CSS2 z-index. However, we set the z-index on the widget anyway
|
|
|
|
// because in many simple common cases the widgets do end up in the
|
|
|
|
// right order. We set each widget's z-index to the z-index of the
|
|
|
|
// nearest ancestor that has non-auto z-index.
|
2013-01-03 05:23:11 -08:00
|
|
|
static void UpdateNativeWidgetZIndexes(nsView* aView, int32_t aZIndex)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
if (aView->HasWidget()) {
|
|
|
|
nsIWidget* widget = aView->GetWidget();
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t curZ;
|
2007-03-22 10:30:00 -07:00
|
|
|
widget->GetZIndex(&curZ);
|
|
|
|
if (curZ != aZIndex) {
|
|
|
|
widget->SetZIndex(aZIndex);
|
|
|
|
}
|
|
|
|
} else {
|
2013-01-03 05:23:11 -08:00
|
|
|
for (nsView* v = aView->GetFirstChild(); v; v = v->GetNextSibling()) {
|
2007-03-22 10:30:00 -07:00
|
|
|
if (v->GetZIndexIsAuto()) {
|
|
|
|
UpdateNativeWidgetZIndexes(v, aZIndex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-03 05:23:11 -08:00
|
|
|
static int32_t FindNonAutoZIndex(nsView* aView)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
while (aView) {
|
|
|
|
if (!aView->GetZIndexIsAuto()) {
|
|
|
|
return aView->GetZIndex();
|
|
|
|
}
|
|
|
|
aView = aView->GetParent();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-08-23 23:28:16 -07:00
|
|
|
struct DefaultWidgetInitData : public nsWidgetInitData {
|
|
|
|
DefaultWidgetInitData() : nsWidgetInitData()
|
|
|
|
{
|
|
|
|
mWindowType = eWindowType_child;
|
2011-10-17 07:59:28 -07:00
|
|
|
clipChildren = true;
|
|
|
|
clipSiblings = true;
|
2010-08-23 23:28:16 -07:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-01-03 05:23:11 -08:00
|
|
|
nsresult nsView::CreateWidget(nsWidgetInitData *aWidgetInitData,
|
2013-01-03 05:23:08 -08:00
|
|
|
bool aEnableDragDrop,
|
|
|
|
bool aResetVisibility)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-08-20 12:29:02 -07:00
|
|
|
AssertNoWindow();
|
2010-08-20 12:29:02 -07:00
|
|
|
NS_ABORT_IF_FALSE(!aWidgetInitData ||
|
|
|
|
aWidgetInitData->mWindowType != eWindowType_popup,
|
|
|
|
"Use CreateWidgetForPopup");
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-08-23 23:28:16 -07:00
|
|
|
DefaultWidgetInitData defaultInitData;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool initDataPassedIn = !!aWidgetInitData;
|
2010-08-23 23:28:16 -07:00
|
|
|
aWidgetInitData = aWidgetInitData ? aWidgetInitData : &defaultInitData;
|
2010-08-24 00:48:46 -07:00
|
|
|
defaultInitData.mListenForResizes =
|
|
|
|
(!initDataPassedIn && GetParent() &&
|
|
|
|
GetParent()->GetViewManager() != mViewManager);
|
2010-08-20 12:29:01 -07:00
|
|
|
|
|
|
|
nsIntRect trect = CalcWidgetBounds(aWidgetInitData->mWindowType);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-05-10 00:13:49 -07:00
|
|
|
nsRefPtr<nsDeviceContext> dx = mViewManager->GetDeviceContext();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-08-20 12:29:02 -07:00
|
|
|
nsIWidget* parentWidget =
|
2012-07-30 07:20:58 -07:00
|
|
|
GetParent() ? GetParent()->GetNearestWidget(nullptr) : nullptr;
|
2010-08-20 12:29:02 -07:00
|
|
|
if (!parentWidget) {
|
2013-01-03 05:23:11 -08:00
|
|
|
NS_ERROR("nsView::CreateWidget without suitable parent widget??");
|
2010-08-20 12:29:02 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2010-08-20 12:29:02 -07:00
|
|
|
|
2010-08-20 12:29:02 -07:00
|
|
|
// XXX: using aForceUseIWidgetParent=true to preserve previous
|
|
|
|
// semantics. It's not clear that it's actually needed.
|
2012-08-15 11:53:09 -07:00
|
|
|
mWindow = parentWidget->CreateChild(trect, dx, aWidgetInitData,
|
2011-10-17 07:59:28 -07:00
|
|
|
true).get();
|
2010-08-20 12:29:02 -07:00
|
|
|
if (!mWindow) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2010-08-20 12:29:02 -07:00
|
|
|
InitializeWindow(aEnableDragDrop, aResetVisibility);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-01-03 05:23:11 -08:00
|
|
|
nsresult nsView::CreateWidgetForParent(nsIWidget* aParentWidget,
|
2013-01-03 05:23:08 -08:00
|
|
|
nsWidgetInitData *aWidgetInitData,
|
|
|
|
bool aEnableDragDrop,
|
|
|
|
bool aResetVisibility)
|
2010-08-20 12:29:02 -07:00
|
|
|
{
|
2010-08-20 12:29:02 -07:00
|
|
|
AssertNoWindow();
|
2010-08-20 12:29:02 -07:00
|
|
|
NS_ABORT_IF_FALSE(!aWidgetInitData ||
|
|
|
|
aWidgetInitData->mWindowType != eWindowType_popup,
|
|
|
|
"Use CreateWidgetForPopup");
|
|
|
|
NS_ABORT_IF_FALSE(aParentWidget, "Parent widget required");
|
|
|
|
|
2010-08-23 23:28:16 -07:00
|
|
|
DefaultWidgetInitData defaultInitData;
|
|
|
|
aWidgetInitData = aWidgetInitData ? aWidgetInitData : &defaultInitData;
|
|
|
|
|
|
|
|
nsIntRect trect = CalcWidgetBounds(aWidgetInitData->mWindowType);
|
2010-08-20 12:29:02 -07:00
|
|
|
|
2013-05-10 00:13:49 -07:00
|
|
|
nsRefPtr<nsDeviceContext> dx = mViewManager->GetDeviceContext();
|
2010-08-20 12:29:02 -07:00
|
|
|
|
2010-08-20 12:29:02 -07:00
|
|
|
mWindow =
|
2012-08-15 11:53:09 -07:00
|
|
|
aParentWidget->CreateChild(trect, dx, aWidgetInitData).get();
|
2010-08-20 12:29:02 -07:00
|
|
|
if (!mWindow) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2010-08-20 12:29:02 -07:00
|
|
|
|
|
|
|
InitializeWindow(aEnableDragDrop, aResetVisibility);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-01-03 05:23:11 -08:00
|
|
|
nsresult nsView::CreateWidgetForPopup(nsWidgetInitData *aWidgetInitData,
|
2013-01-03 05:23:08 -08:00
|
|
|
nsIWidget* aParentWidget,
|
|
|
|
bool aEnableDragDrop,
|
|
|
|
bool aResetVisibility)
|
2010-08-20 12:29:02 -07:00
|
|
|
{
|
2010-08-20 12:29:02 -07:00
|
|
|
AssertNoWindow();
|
2010-08-20 12:29:02 -07:00
|
|
|
NS_ABORT_IF_FALSE(aWidgetInitData, "Widget init data required");
|
|
|
|
NS_ABORT_IF_FALSE(aWidgetInitData->mWindowType == eWindowType_popup,
|
|
|
|
"Use one of the other CreateWidget methods");
|
|
|
|
|
|
|
|
nsIntRect trect = CalcWidgetBounds(aWidgetInitData->mWindowType);
|
|
|
|
|
2013-05-10 00:13:49 -07:00
|
|
|
nsRefPtr<nsDeviceContext> dx = mViewManager->GetDeviceContext();
|
2010-08-20 12:29:02 -07:00
|
|
|
|
|
|
|
// XXX/cjones: having these two separate creation cases seems ... um
|
|
|
|
// ... unnecessary, but it's the way the old code did it. Please
|
|
|
|
// unify them by first finding a suitable parent nsIWidget, then
|
2010-08-20 12:29:02 -07:00
|
|
|
// getting rid of aForceUseIWidgetParent.
|
2010-08-20 12:29:02 -07:00
|
|
|
if (aParentWidget) {
|
2010-08-20 12:29:02 -07:00
|
|
|
// XXX: using aForceUseIWidgetParent=true to preserve previous
|
|
|
|
// semantics. It's not clear that it's actually needed.
|
2012-08-15 11:53:09 -07:00
|
|
|
mWindow = aParentWidget->CreateChild(trect, dx, aWidgetInitData,
|
2011-10-17 07:59:28 -07:00
|
|
|
true).get();
|
2010-08-20 12:29:01 -07:00
|
|
|
}
|
|
|
|
else {
|
2012-07-30 07:20:58 -07:00
|
|
|
nsIWidget* nearestParent = GetParent() ? GetParent()->GetNearestWidget(nullptr)
|
|
|
|
: nullptr;
|
2010-08-20 12:29:02 -07:00
|
|
|
if (!nearestParent) {
|
|
|
|
// Without a parent, we can't make a popup. This can happen
|
|
|
|
// when printing
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2010-08-20 12:29:02 -07:00
|
|
|
mWindow =
|
2012-08-15 11:53:09 -07:00
|
|
|
nearestParent->CreateChild(trect, dx, aWidgetInitData).get();
|
2010-08-20 12:29:02 -07:00
|
|
|
}
|
|
|
|
if (!mWindow) {
|
|
|
|
return NS_ERROR_FAILURE;
|
2010-08-20 12:29:01 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-08-20 12:29:01 -07:00
|
|
|
InitializeWindow(aEnableDragDrop, aResetVisibility);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-01-03 05:23:11 -08:00
|
|
|
nsView::InitializeWindow(bool aEnableDragDrop, bool aResetVisibility)
|
2010-08-20 12:29:01 -07:00
|
|
|
{
|
|
|
|
NS_ABORT_IF_FALSE(mWindow, "Must have a window to initialize");
|
|
|
|
|
2012-08-15 11:53:14 -07:00
|
|
|
mWindow->SetWidgetListener(this);
|
2010-08-20 12:29:02 -07:00
|
|
|
|
2010-08-20 12:29:01 -07:00
|
|
|
if (aEnableDragDrop) {
|
2011-10-17 07:59:28 -07:00
|
|
|
mWindow->EnableDragDrop(true);
|
2010-08-20 12:29:01 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// propagate the z-index to the widget.
|
|
|
|
UpdateNativeWidgetZIndexes(this, FindNonAutoZIndex(this));
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
//make sure visibility state is accurate
|
2007-05-25 20:45:00 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (aResetVisibility) {
|
2010-08-20 12:29:01 -07:00
|
|
|
SetVisibility(GetVisibility());
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-24 19:01:06 -07:00
|
|
|
// Attach to a top level widget and start receiving mirrored events.
|
2013-01-03 05:23:11 -08:00
|
|
|
nsresult nsView::AttachToTopLevelWidget(nsIWidget* aWidget)
|
2010-06-24 19:01:06 -07:00
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
NS_PRECONDITION(nullptr != aWidget, "null widget ptr");
|
2010-06-24 19:01:06 -07:00
|
|
|
/// XXXjimm This is a temporary workaround to an issue w/document
|
|
|
|
// viewer (bug 513162).
|
2012-08-15 11:53:14 -07:00
|
|
|
nsIWidgetListener* listener = aWidget->GetAttachedWidgetListener();
|
|
|
|
if (listener) {
|
2013-01-03 05:23:11 -08:00
|
|
|
nsView *oldView = listener->GetView();
|
2012-08-15 11:53:14 -07:00
|
|
|
if (oldView) {
|
|
|
|
oldView->DetachFromTopLevelWidget();
|
|
|
|
}
|
2010-06-24 19:01:06 -07:00
|
|
|
}
|
|
|
|
|
2013-05-10 00:13:49 -07:00
|
|
|
nsRefPtr<nsDeviceContext> dx = mViewManager->GetDeviceContext();
|
2010-06-24 19:01:06 -07:00
|
|
|
|
|
|
|
// Note, the previous device context will be released. Detaching
|
|
|
|
// will not restore the old one.
|
2012-08-15 11:53:09 -07:00
|
|
|
nsresult rv = aWidget->AttachViewToTopLevel(!nsIWidget::UsePuppetWidgets(), dx);
|
2010-06-24 19:01:06 -07:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
mWindow = aWidget;
|
|
|
|
NS_ADDREF(mWindow);
|
|
|
|
|
2013-01-03 05:23:08 -08:00
|
|
|
mWindow->SetAttachedWidgetListener(this);
|
2011-10-17 07:59:28 -07:00
|
|
|
mWindow->EnableDragDrop(true);
|
|
|
|
mWidgetIsTopLevel = true;
|
2010-06-24 19:01:06 -07:00
|
|
|
|
|
|
|
// Refresh the view bounds
|
|
|
|
nsWindowType type;
|
|
|
|
mWindow->GetWindowType(type);
|
|
|
|
CalcWidgetBounds(type);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Detach this view from an attached widget.
|
2013-01-03 05:23:11 -08:00
|
|
|
nsresult nsView::DetachFromTopLevelWidget()
|
2010-06-24 19:01:06 -07:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(mWidgetIsTopLevel, "Not attached currently!");
|
|
|
|
NS_PRECONDITION(mWindow, "null mWindow for DetachFromTopLevelWidget!");
|
|
|
|
|
2012-08-15 11:53:14 -07:00
|
|
|
mWindow->SetAttachedWidgetListener(nullptr);
|
2010-06-24 19:01:06 -07:00
|
|
|
NS_RELEASE(mWindow);
|
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
mWidgetIsTopLevel = false;
|
2010-06-24 19:01:06 -07:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-07-30 14:10:28 -07:00
|
|
|
void nsView::SetZIndex(bool aAuto, int32_t aZIndex)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-09-28 23:19:26 -07:00
|
|
|
bool oldIsAuto = GetZIndexIsAuto();
|
2007-03-22 10:30:00 -07:00
|
|
|
mVFlags = (mVFlags & ~NS_VIEW_FLAG_AUTO_ZINDEX) | (aAuto ? NS_VIEW_FLAG_AUTO_ZINDEX : 0);
|
|
|
|
mZIndex = aZIndex;
|
|
|
|
|
|
|
|
if (HasWidget() || !oldIsAuto || !aAuto) {
|
|
|
|
UpdateNativeWidgetZIndexes(this, FindNonAutoZIndex(this));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-03 05:23:11 -08:00
|
|
|
void nsView::AssertNoWindow()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-08-20 12:29:02 -07:00
|
|
|
// XXX: it would be nice to make this a strong assert
|
2012-10-26 06:32:10 -07:00
|
|
|
if (MOZ_UNLIKELY(mWindow)) {
|
2010-08-20 12:29:02 -07:00
|
|
|
NS_ERROR("We already have a window for this view? BAD");
|
2012-08-15 11:52:42 -07:00
|
|
|
mWindow->SetWidgetListener(nullptr);
|
2010-08-20 12:29:02 -07:00
|
|
|
mWindow->Destroy();
|
|
|
|
NS_RELEASE(mWindow);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2010-08-20 12:29:02 -07:00
|
|
|
//
|
|
|
|
// internal window creation functions
|
|
|
|
//
|
2013-01-03 05:23:11 -08:00
|
|
|
void nsView::AttachWidgetEventHandler(nsIWidget* aWidget)
|
2009-07-21 17:45:00 -07:00
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
2012-08-15 11:52:42 -07:00
|
|
|
NS_ASSERTION(!aWidget->GetWidgetListener(), "Already have a widget listener");
|
2009-07-21 17:45:00 -07:00
|
|
|
#endif
|
|
|
|
|
2013-01-03 05:23:08 -08:00
|
|
|
aWidget->SetWidgetListener(this);
|
2009-07-21 17:45:00 -07:00
|
|
|
}
|
|
|
|
|
2013-01-03 05:23:11 -08:00
|
|
|
void nsView::DetachWidgetEventHandler(nsIWidget* aWidget)
|
2009-07-21 17:45:00 -07:00
|
|
|
{
|
2012-08-15 11:53:14 -07:00
|
|
|
NS_ASSERTION(!aWidget->GetWidgetListener() ||
|
|
|
|
aWidget->GetWidgetListener()->GetView() == this, "Wrong view");
|
2012-08-15 11:52:42 -07:00
|
|
|
aWidget->SetWidgetListener(nullptr);
|
2009-07-21 17:45:00 -07:00
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef DEBUG
|
2013-01-03 05:23:11 -08:00
|
|
|
void nsView::List(FILE* out, int32_t aIndent) const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t i;
|
2007-03-22 10:30:00 -07:00
|
|
|
for (i = aIndent; --i >= 0; ) fputs(" ", out);
|
|
|
|
fprintf(out, "%p ", (void*)this);
|
2012-07-30 07:20:58 -07:00
|
|
|
if (nullptr != mWindow) {
|
2010-07-18 19:23:47 -07:00
|
|
|
nscoord p2a = mViewManager->AppUnitsPerDevPixel();
|
2009-01-14 19:27:09 -08:00
|
|
|
nsIntRect rect;
|
|
|
|
mWindow->GetClientBounds(rect);
|
2009-05-07 19:31:04 -07:00
|
|
|
nsRect windowBounds = rect.ToAppUnits(p2a);
|
2009-01-14 19:27:09 -08:00
|
|
|
mWindow->GetBounds(rect);
|
2009-05-07 19:31:04 -07:00
|
|
|
nsRect nonclientBounds = rect.ToAppUnits(p2a);
|
2007-03-22 10:30:00 -07:00
|
|
|
nsrefcnt widgetRefCnt = mWindow->AddRef() - 1;
|
|
|
|
mWindow->Release();
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t Z;
|
2007-03-22 10:30:00 -07:00
|
|
|
mWindow->GetZIndex(&Z);
|
|
|
|
fprintf(out, "(widget=%p[%d] z=%d pos={%d,%d,%d,%d}) ",
|
|
|
|
(void*)mWindow, widgetRefCnt, Z,
|
|
|
|
nonclientBounds.x, nonclientBounds.y,
|
|
|
|
windowBounds.width, windowBounds.height);
|
|
|
|
}
|
|
|
|
nsRect brect = GetBounds();
|
|
|
|
fprintf(out, "{%d,%d,%d,%d}",
|
|
|
|
brect.x, brect.y, brect.width, brect.height);
|
2011-11-21 09:53:20 -08:00
|
|
|
fprintf(out, " z=%d vis=%d frame=%p <\n",
|
2012-03-30 13:36:43 -07:00
|
|
|
mZIndex, mVis, static_cast<void*>(mFrame));
|
2013-01-03 05:23:11 -08:00
|
|
|
for (nsView* kid = mFirstChild; kid; kid = kid->GetNextSibling()) {
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_ASSERTION(kid->GetParent() == this, "incorrect parent");
|
|
|
|
kid->List(out, aIndent + 1);
|
|
|
|
}
|
|
|
|
for (i = aIndent; --i >= 0; ) fputs(" ", out);
|
|
|
|
fputs(">\n", out);
|
|
|
|
}
|
|
|
|
#endif // DEBUG
|
|
|
|
|
2013-01-03 05:23:11 -08:00
|
|
|
nsPoint nsView::GetOffsetTo(const nsView* aOther) const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-01-04 19:13:23 -08:00
|
|
|
return GetOffsetTo(aOther, GetViewManager()->AppUnitsPerDevPixel());
|
2010-07-18 19:23:47 -07:00
|
|
|
}
|
|
|
|
|
2013-01-03 05:23:11 -08:00
|
|
|
nsPoint nsView::GetOffsetTo(const nsView* aOther, const int32_t aAPD) const
|
2010-07-18 19:23:47 -07:00
|
|
|
{
|
2010-10-21 20:37:49 -07:00
|
|
|
NS_ABORT_IF_FALSE(GetParent() || !aOther || aOther->GetParent() ||
|
|
|
|
this == aOther, "caller of (outer) GetOffsetTo must not "
|
|
|
|
"pass unrelated views");
|
2010-07-18 19:23:47 -07:00
|
|
|
// We accumulate the final result in offset
|
2007-03-22 10:30:00 -07:00
|
|
|
nsPoint offset(0, 0);
|
2010-07-18 19:23:47 -07:00
|
|
|
// The offset currently accumulated at the current APD
|
|
|
|
nsPoint docOffset(0, 0);
|
2013-01-03 05:23:11 -08:00
|
|
|
const nsView* v = this;
|
2013-01-04 19:13:23 -08:00
|
|
|
nsViewManager* currVM = v->GetViewManager();
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t currAPD = currVM->AppUnitsPerDevPixel();
|
2013-01-03 05:23:11 -08:00
|
|
|
const nsView* root = nullptr;
|
2010-07-18 19:23:47 -07:00
|
|
|
for ( ; v != aOther && v; root = v, v = v->GetParent()) {
|
2013-01-04 19:13:23 -08:00
|
|
|
nsViewManager* newVM = v->GetViewManager();
|
2010-07-18 19:23:47 -07:00
|
|
|
if (newVM != currVM) {
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t newAPD = newVM->AppUnitsPerDevPixel();
|
2010-07-18 19:23:47 -07:00
|
|
|
if (newAPD != currAPD) {
|
|
|
|
offset += docOffset.ConvertAppUnits(currAPD, aAPD);
|
|
|
|
docOffset.x = docOffset.y = 0;
|
|
|
|
currAPD = newAPD;
|
|
|
|
}
|
|
|
|
currVM = newVM;
|
|
|
|
}
|
|
|
|
docOffset += v->GetPosition();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2010-07-18 19:23:47 -07:00
|
|
|
offset += docOffset.ConvertAppUnits(currAPD, aAPD);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
if (v != aOther) {
|
|
|
|
// Looks like aOther wasn't an ancestor of |this|. So now we have
|
2010-07-18 19:23:47 -07:00
|
|
|
// the root-VM-relative position of |this| in |offset|. Get the
|
|
|
|
// root-VM-relative position of aOther and subtract it.
|
|
|
|
nsPoint negOffset = aOther->GetOffsetTo(root, aAPD);
|
|
|
|
offset -= negOffset;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return offset;
|
|
|
|
}
|
|
|
|
|
2013-01-03 05:23:11 -08:00
|
|
|
nsPoint nsView::GetOffsetToWidget(nsIWidget* aWidget) const
|
2010-07-18 19:23:47 -07:00
|
|
|
{
|
|
|
|
nsPoint pt;
|
|
|
|
// Get the view for widget
|
2013-01-03 05:23:11 -08:00
|
|
|
nsView* widgetView = GetViewFor(aWidget);
|
2013-01-03 05:23:08 -08:00
|
|
|
if (!widgetView) {
|
2010-07-18 19:23:47 -07:00
|
|
|
return pt;
|
|
|
|
}
|
2010-08-20 12:29:01 -07:00
|
|
|
|
2010-07-18 19:23:47 -07:00
|
|
|
// Get the offset to the widget view in the widget view's APD
|
|
|
|
// We get the offset in the widget view's APD first and then convert to our
|
|
|
|
// APD afterwards so that we can include the widget view's ViewToWidgetOffset
|
|
|
|
// in the sum in its native APD, and then convert the whole thing to our APD
|
|
|
|
// so that we don't have to convert the APD of the relatively small
|
|
|
|
// ViewToWidgetOffset by itself with a potentially large relative rounding
|
|
|
|
// error.
|
2013-01-03 05:23:08 -08:00
|
|
|
pt = -widgetView->GetOffsetTo(this);
|
2010-07-18 19:23:47 -07:00
|
|
|
// Add in the offset to the widget.
|
|
|
|
pt += widgetView->ViewToWidgetOffset();
|
|
|
|
|
|
|
|
// Convert to our appunits.
|
2013-01-04 19:13:23 -08:00
|
|
|
int32_t widgetAPD = widgetView->GetViewManager()->AppUnitsPerDevPixel();
|
|
|
|
int32_t ourAPD = GetViewManager()->AppUnitsPerDevPixel();
|
2010-07-18 19:23:47 -07:00
|
|
|
pt = pt.ConvertAppUnits(widgetAPD, ourAPD);
|
|
|
|
return pt;
|
|
|
|
}
|
|
|
|
|
2013-01-03 05:23:11 -08:00
|
|
|
nsIWidget* nsView::GetNearestWidget(nsPoint* aOffset) const
|
2010-07-18 19:23:47 -07:00
|
|
|
{
|
2013-01-04 19:13:23 -08:00
|
|
|
return GetNearestWidget(aOffset, GetViewManager()->AppUnitsPerDevPixel());
|
2010-07-18 19:23:47 -07:00
|
|
|
}
|
|
|
|
|
2013-01-03 05:23:11 -08:00
|
|
|
nsIWidget* nsView::GetNearestWidget(nsPoint* aOffset, const int32_t aAPD) const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-06-24 19:01:06 -07:00
|
|
|
// aOffset is based on the view's position, which ignores any chrome on
|
|
|
|
// attached parent widgets.
|
|
|
|
|
2010-07-18 19:23:47 -07:00
|
|
|
// We accumulate the final result in pt
|
2007-03-22 10:30:00 -07:00
|
|
|
nsPoint pt(0, 0);
|
2010-07-18 19:23:47 -07:00
|
|
|
// The offset currently accumulated at the current APD
|
|
|
|
nsPoint docPt(0,0);
|
2013-01-03 05:23:11 -08:00
|
|
|
const nsView* v = this;
|
2013-01-04 19:13:23 -08:00
|
|
|
nsViewManager* currVM = v->GetViewManager();
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t currAPD = currVM->AppUnitsPerDevPixel();
|
2010-07-18 19:23:47 -07:00
|
|
|
for ( ; v && !v->HasWidget(); v = v->GetParent()) {
|
2013-01-04 19:13:23 -08:00
|
|
|
nsViewManager* newVM = v->GetViewManager();
|
2010-07-18 19:23:47 -07:00
|
|
|
if (newVM != currVM) {
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t newAPD = newVM->AppUnitsPerDevPixel();
|
2010-07-18 19:23:47 -07:00
|
|
|
if (newAPD != currAPD) {
|
|
|
|
pt += docPt.ConvertAppUnits(currAPD, aAPD);
|
|
|
|
docPt.x = docPt.y = 0;
|
|
|
|
currAPD = newAPD;
|
|
|
|
}
|
|
|
|
currVM = newVM;
|
|
|
|
}
|
|
|
|
docPt += v->GetPosition();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
if (!v) {
|
|
|
|
if (aOffset) {
|
2010-07-18 19:23:47 -07:00
|
|
|
pt += docPt.ConvertAppUnits(currAPD, aAPD);
|
2007-03-22 10:30:00 -07:00
|
|
|
*aOffset = pt;
|
|
|
|
}
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2010-07-18 19:23:47 -07:00
|
|
|
// pt is now the offset from v's origin to this view's origin.
|
|
|
|
// We add the ViewToWidgetOffset to get the offset to the widget.
|
2007-03-22 10:30:00 -07:00
|
|
|
if (aOffset) {
|
2010-07-18 19:23:47 -07:00
|
|
|
docPt += v->ViewToWidgetOffset();
|
|
|
|
pt += docPt.ConvertAppUnits(currAPD, aAPD);
|
|
|
|
*aOffset = pt;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
return v->GetWidget();
|
|
|
|
}
|
|
|
|
|
2013-01-03 05:23:11 -08:00
|
|
|
bool nsView::IsRoot() const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-01-03 05:23:11 -08:00
|
|
|
NS_ASSERTION(mViewManager != nullptr," View manager is null in nsView::IsRoot()");
|
2013-01-04 19:13:05 -08:00
|
|
|
return mViewManager->GetRootView() == this;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2010-07-18 19:23:47 -07:00
|
|
|
nsRect
|
2013-01-03 05:23:11 -08:00
|
|
|
nsView::GetBoundsInParentUnits() const
|
2010-07-18 19:23:47 -07:00
|
|
|
{
|
2013-01-03 05:23:11 -08:00
|
|
|
nsView* parent = GetParent();
|
2013-01-04 19:13:23 -08:00
|
|
|
nsViewManager* VM = GetViewManager();
|
2013-01-04 19:13:05 -08:00
|
|
|
if (this != VM->GetRootView() || !parent) {
|
2010-07-18 19:23:47 -07:00
|
|
|
return mDimBounds;
|
|
|
|
}
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t ourAPD = VM->AppUnitsPerDevPixel();
|
2013-01-04 19:13:23 -08:00
|
|
|
int32_t parentAPD = parent->GetViewManager()->AppUnitsPerDevPixel();
|
2010-07-18 19:23:47 -07:00
|
|
|
return mDimBounds.ConvertAppUnitsRoundOut(ourAPD, parentAPD);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsPoint
|
2013-01-03 05:23:11 -08:00
|
|
|
nsView::ConvertFromParentCoords(nsPoint aPt) const
|
2010-07-18 19:23:47 -07:00
|
|
|
{
|
2013-01-03 05:23:11 -08:00
|
|
|
const nsView* parent = GetParent();
|
2010-07-18 19:23:47 -07:00
|
|
|
if (parent) {
|
2013-01-04 19:13:23 -08:00
|
|
|
aPt = aPt.ConvertAppUnits(parent->GetViewManager()->AppUnitsPerDevPixel(),
|
|
|
|
GetViewManager()->AppUnitsPerDevPixel());
|
2010-07-18 19:23:47 -07:00
|
|
|
}
|
|
|
|
aPt -= GetPosition();
|
|
|
|
return aPt;
|
|
|
|
}
|
2012-08-15 11:53:14 -07:00
|
|
|
|
|
|
|
static bool
|
|
|
|
IsPopupWidget(nsIWidget* aWidget)
|
|
|
|
{
|
|
|
|
nsWindowType type;
|
|
|
|
aWidget->GetWindowType(type);
|
|
|
|
return (type == eWindowType_popup);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIPresShell*
|
2013-01-03 05:23:11 -08:00
|
|
|
nsView::GetPresShell()
|
2012-08-15 11:53:14 -07:00
|
|
|
{
|
|
|
|
return GetViewManager()->GetPresShell();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-01-03 05:23:11 -08:00
|
|
|
nsView::WindowMoved(nsIWidget* aWidget, int32_t x, int32_t y)
|
2012-08-15 11:53:14 -07:00
|
|
|
{
|
|
|
|
nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
|
|
|
|
if (pm && IsPopupWidget(aWidget)) {
|
|
|
|
pm->PopupMoved(mFrame, nsIntPoint(x, y));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-01-03 05:23:11 -08:00
|
|
|
nsView::WindowResized(nsIWidget* aWidget, int32_t aWidth, int32_t aHeight)
|
2012-08-15 11:53:14 -07:00
|
|
|
{
|
|
|
|
// The root view may not be set if this is the resize associated with
|
|
|
|
// window creation
|
2012-08-20 19:40:45 -07:00
|
|
|
SetForcedRepaint(true);
|
2012-08-15 11:53:14 -07:00
|
|
|
if (this == mViewManager->GetRootView()) {
|
2013-05-10 00:13:49 -07:00
|
|
|
nsRefPtr<nsDeviceContext> devContext = mViewManager->GetDeviceContext();
|
2013-01-30 04:04:19 -08:00
|
|
|
// ensure DPI is up-to-date, in case of window being opened and sized
|
|
|
|
// on a non-default-dpi display (bug 829963)
|
|
|
|
devContext->CheckDPIChange();
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t p2a = devContext->AppUnitsPerDevPixel();
|
2012-08-15 11:53:14 -07:00
|
|
|
mViewManager->SetWindowDimensions(NSIntPixelsToAppUnits(aWidth, p2a),
|
|
|
|
NSIntPixelsToAppUnits(aHeight, p2a));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (IsPopupWidget(aWidget)) {
|
|
|
|
nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
|
|
|
|
if (pm) {
|
|
|
|
pm->PopupResized(mFrame, nsIntSize(aWidth, aHeight));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-01-03 05:23:11 -08:00
|
|
|
nsView::RequestWindowClose(nsIWidget* aWidget)
|
2012-08-15 11:53:14 -07:00
|
|
|
{
|
|
|
|
if (mFrame && IsPopupWidget(aWidget) &&
|
|
|
|
mFrame->GetType() == nsGkAtoms::menuPopupFrame) {
|
|
|
|
nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
|
|
|
|
if (pm) {
|
|
|
|
pm->HidePopup(mFrame->GetContent(), false, true, false);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-01-28 11:34:08 -08:00
|
|
|
nsView::WillPaintWindow(nsIWidget* aWidget)
|
2012-08-15 11:53:14 -07:00
|
|
|
{
|
2013-01-04 19:12:42 -08:00
|
|
|
nsRefPtr<nsViewManager> vm = mViewManager;
|
2013-01-28 11:34:08 -08:00
|
|
|
vm->WillPaintWindow(aWidget);
|
2012-08-15 11:53:14 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-05-23 07:49:18 -07:00
|
|
|
nsView::PaintWindow(nsIWidget* aWidget, nsIntRegion aRegion)
|
2012-08-15 11:53:14 -07:00
|
|
|
{
|
2013-01-03 05:23:11 -08:00
|
|
|
NS_ASSERTION(this == nsView::GetViewFor(aWidget), "wrong view for widget?");
|
2012-12-12 13:57:08 -08:00
|
|
|
|
2013-01-04 19:12:42 -08:00
|
|
|
nsRefPtr<nsViewManager> vm = mViewManager;
|
2013-05-23 07:49:18 -07:00
|
|
|
bool result = vm->PaintWindow(aWidget, aRegion);
|
2012-10-14 21:53:37 -07:00
|
|
|
return result;
|
2012-08-15 11:53:14 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-01-03 05:23:11 -08:00
|
|
|
nsView::DidPaintWindow()
|
2012-08-15 11:53:14 -07:00
|
|
|
{
|
2013-01-04 19:12:42 -08:00
|
|
|
nsRefPtr<nsViewManager> vm = mViewManager;
|
2012-10-22 06:53:31 -07:00
|
|
|
vm->DidPaintWindow();
|
2012-08-15 11:53:14 -07:00
|
|
|
}
|
|
|
|
|
2012-12-17 19:42:02 -08:00
|
|
|
void
|
2013-01-03 05:23:11 -08:00
|
|
|
nsView::RequestRepaint()
|
2012-12-17 19:42:02 -08:00
|
|
|
{
|
|
|
|
nsIPresShell* presShell = mViewManager->GetPresShell();
|
|
|
|
if (presShell) {
|
|
|
|
presShell->ScheduleViewManagerFlush();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-15 11:53:14 -07:00
|
|
|
nsEventStatus
|
2013-10-01 20:46:03 -07:00
|
|
|
nsView::HandleEvent(WidgetGUIEvent* aEvent,
|
|
|
|
bool aUseAttachedEvents)
|
2012-08-15 11:53:14 -07:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(nullptr != aEvent->widget, "null widget ptr");
|
|
|
|
|
|
|
|
nsEventStatus result = nsEventStatus_eIgnore;
|
2013-01-03 05:23:11 -08:00
|
|
|
nsView* view;
|
2012-08-15 11:53:14 -07:00
|
|
|
if (aUseAttachedEvents) {
|
|
|
|
nsIWidgetListener* listener = aEvent->widget->GetAttachedWidgetListener();
|
|
|
|
view = listener ? listener->GetView() : nullptr;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
view = GetViewFor(aEvent->widget);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (view) {
|
2013-01-04 19:12:42 -08:00
|
|
|
nsRefPtr<nsViewManager> vm = view->GetViewManager();
|
2012-08-15 11:53:14 -07:00
|
|
|
vm->DispatchEvent(aEvent, view, &result);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|