2017-10-27 20:33:53 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04: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/. */
|
2000-07-12 03:37:00 +04:00
|
|
|
#ifndef nsResizerFrame_h___
|
|
|
|
#define nsResizerFrame_h___
|
|
|
|
|
2012-09-14 20:10:08 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2013-10-28 13:03:19 +04:00
|
|
|
#include "mozilla/EventForwards.h"
|
2000-07-12 03:37:00 +04:00
|
|
|
#include "nsTitleBarFrame.h"
|
|
|
|
|
2009-12-23 21:45:44 +03:00
|
|
|
class nsIBaseWindow;
|
|
|
|
|
2019-04-16 10:24:49 +03:00
|
|
|
namespace mozilla {
|
|
|
|
class PresShell;
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2017-05-02 04:50:16 +03:00
|
|
|
class nsResizerFrame final : public nsTitleBarFrame {
|
2000-07-12 03:37:00 +04:00
|
|
|
protected:
|
2018-11-13 01:20:52 +03:00
|
|
|
typedef mozilla::LayoutDeviceIntPoint LayoutDeviceIntPoint;
|
|
|
|
typedef mozilla::LayoutDeviceIntRect LayoutDeviceIntRect;
|
|
|
|
|
2008-06-16 05:36:28 +04:00
|
|
|
struct Direction {
|
2012-08-22 19:56:38 +04:00
|
|
|
int8_t mHorizontal;
|
|
|
|
int8_t mVertical;
|
2000-07-12 03:37:00 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
public:
|
2017-05-26 13:11:11 +03:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS(nsResizerFrame)
|
2009-09-12 20:49:24 +04:00
|
|
|
|
2019-04-16 10:24:49 +03:00
|
|
|
friend nsIFrame* NS_NewResizerFrame(mozilla::PresShell* aPresShell,
|
2018-03-22 21:20:41 +03:00
|
|
|
ComputedStyle* aStyle);
|
2000-07-12 03:37:00 +04:00
|
|
|
|
2019-02-05 19:45:54 +03:00
|
|
|
explicit nsResizerFrame(ComputedStyle* aStyle, nsPresContext* aPresContext);
|
2000-07-12 03:37:00 +04:00
|
|
|
|
2014-02-18 11:47:48 +04:00
|
|
|
virtual nsresult HandleEvent(nsPresContext* aPresContext,
|
2014-02-18 12:36:33 +04:00
|
|
|
mozilla::WidgetGUIEvent* aEvent,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsEventStatus* aEventStatus) override;
|
2000-07-12 03:37:00 +04:00
|
|
|
|
2019-04-30 04:35:30 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
2015-12-08 02:30:05 +03:00
|
|
|
virtual void MouseClicked(mozilla::WidgetMouseEvent* aEvent) override;
|
2000-07-12 03:37:00 +04:00
|
|
|
|
|
|
|
protected:
|
2019-04-16 10:25:10 +03:00
|
|
|
nsIContent* GetContentToResize(mozilla::PresShell* aPresShell,
|
2009-12-23 21:45:44 +03:00
|
|
|
nsIBaseWindow** aWindow);
|
|
|
|
|
2008-06-16 05:36:28 +04:00
|
|
|
Direction GetDirection();
|
2012-07-31 04:43:29 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Adjust the window position and size in a direction according to the mouse
|
|
|
|
* movement and the resizer direction. The minimum and maximum size is used
|
|
|
|
* to constrain the size.
|
|
|
|
*
|
|
|
|
* @param aPos left or top position
|
|
|
|
* @param aSize width or height
|
|
|
|
* @param aMinSize minimum width or height
|
|
|
|
* @param aMacSize maximum width or height
|
|
|
|
* @param aMovement the amount the mouse was moved
|
|
|
|
* @param aResizerDirection resizer direction returned by GetDirection
|
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
static void AdjustDimensions(int32_t* aPos, int32_t* aSize, int32_t aMinSize,
|
|
|
|
int32_t aMaxSize, int32_t aMovement,
|
|
|
|
int8_t aResizerDirection);
|
2000-07-12 03:37:00 +04:00
|
|
|
|
2011-08-18 18:25:36 +04:00
|
|
|
struct SizeInfo {
|
|
|
|
nsString width, height;
|
|
|
|
};
|
2017-10-03 01:05:19 +03:00
|
|
|
static void SizeInfoDtorFunc(void* aObject, nsAtom* aPropertyName,
|
2011-08-18 18:25:36 +04:00
|
|
|
void* aPropertyValue, void* aData);
|
|
|
|
static void ResizeContent(nsIContent* aContent, const Direction& aDirection,
|
|
|
|
const SizeInfo& aSizeInfo,
|
|
|
|
SizeInfo* aOriginalSizeInfo);
|
|
|
|
static void MaybePersistOriginalSize(nsIContent* aContent,
|
|
|
|
const SizeInfo& aSizeInfo);
|
|
|
|
static void RestoreOriginalSize(nsIContent* aContent);
|
2012-07-28 02:01:12 +04:00
|
|
|
|
2000-07-12 03:37:00 +04:00
|
|
|
protected:
|
2015-02-15 21:52:28 +03:00
|
|
|
LayoutDeviceIntRect mMouseDownRect;
|
2015-02-02 01:27:41 +03:00
|
|
|
LayoutDeviceIntPoint mMouseDownPoint;
|
2000-07-12 03:37:00 +04:00
|
|
|
}; // class nsResizerFrame
|
|
|
|
|
|
|
|
#endif /* nsResizerFrame_h___ */
|