XULResizerElement.h (2036B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef mozilla_dom_XULResizerElement_h 8 #define mozilla_dom_XULResizerElement_h 9 10 #include "Units.h" 11 #include "nsXULElement.h" 12 13 namespace mozilla::dom { 14 15 nsXULElement* NS_NewXULResizerElement( 16 already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo); 17 18 class XULResizerElement final : public nsXULElement { 19 public: 20 explicit XULResizerElement(already_AddRefed<dom::NodeInfo>&& aNodeInfo) 21 : nsXULElement(std::move(aNodeInfo)) {} 22 23 MOZ_CAN_RUN_SCRIPT 24 nsresult PostHandleEvent(EventChainPostVisitor&) override; 25 26 private: 27 virtual ~XULResizerElement() = default; 28 JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) final; 29 30 MOZ_CAN_RUN_SCRIPT 31 void PostHandleEventInternal(EventChainPostVisitor&); 32 33 struct Direction { 34 int8_t mHorizontal; 35 int8_t mVertical; 36 }; 37 Direction GetDirection(); 38 39 nsIContent* GetContentToResize() const; 40 // The current size of the content to resize (if available). 41 Maybe<nsSize> GetCurrentSize() const; 42 43 struct SizeInfo { 44 nsCString width, height; 45 }; 46 static void SizeInfoDtorFunc(void* aObject, nsAtom* aPropertyName, 47 void* aPropertyValue, void* aData); 48 static void ResizeContent(nsIContent* aContent, const Direction& aDirection, 49 const SizeInfo& aSizeInfo, 50 SizeInfo* aOriginalSizeInfo); 51 static void MaybePersistOriginalSize(nsIContent* aContent, 52 const SizeInfo& aSizeInfo); 53 static void RestoreOriginalSize(nsIContent* aContent); 54 55 nsSize mMouseDownSize; 56 LayoutDeviceIntPoint mMouseDownPoint; 57 bool mTrackingMouseMove = false; 58 }; 59 60 } // namespace mozilla::dom 61 62 #endif // XULResizerElement_h