michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* rendering object for HTML elements */ michael@0: michael@0: #ifndef nsHTMLFrameset_h___ michael@0: #define nsHTMLFrameset_h___ michael@0: michael@0: #include "mozilla/Attributes.h" michael@0: #include "nsContainerFrame.h" michael@0: #include "nsColor.h" michael@0: michael@0: class nsIContent; michael@0: class nsPresContext; michael@0: struct nsRect; michael@0: struct nsHTMLReflowState; michael@0: struct nsSize; michael@0: class nsIAtom; michael@0: class nsHTMLFramesetBorderFrame; michael@0: class nsHTMLFramesetFrame; michael@0: michael@0: #define NO_COLOR 0xFFFFFFFA michael@0: michael@0: // defined at HTMLFrameSetElement.h michael@0: struct nsFramesetSpec; michael@0: michael@0: struct nsBorderColor michael@0: { michael@0: nscolor mLeft; michael@0: nscolor mRight; michael@0: nscolor mTop; michael@0: nscolor mBottom; michael@0: michael@0: nsBorderColor() { Set(NO_COLOR); } michael@0: ~nsBorderColor() {} michael@0: void Set(nscolor aColor) { mLeft = mRight = mTop = mBottom = aColor; } michael@0: }; michael@0: michael@0: enum nsFrameborder { michael@0: eFrameborder_Yes = 0, michael@0: eFrameborder_No, michael@0: eFrameborder_Notset michael@0: }; michael@0: michael@0: struct nsFramesetDrag { michael@0: nsHTMLFramesetFrame* mSource; // frameset whose border was dragged to cause the resize michael@0: int32_t mIndex; // index of left col or top row of effected area michael@0: int32_t mChange; // pos for left to right or top to bottom, neg otherwise michael@0: bool mVertical; // vertical if true, otherwise horizontal michael@0: michael@0: nsFramesetDrag(); michael@0: void Reset(bool aVertical, michael@0: int32_t aIndex, michael@0: int32_t aChange, michael@0: nsHTMLFramesetFrame* aSource); michael@0: void UnSet(); michael@0: }; michael@0: michael@0: /******************************************************************************* michael@0: * nsHTMLFramesetFrame michael@0: ******************************************************************************/ michael@0: class nsHTMLFramesetFrame : public nsContainerFrame michael@0: { michael@0: public: michael@0: NS_DECL_QUERYFRAME_TARGET(nsHTMLFramesetFrame) michael@0: NS_DECL_QUERYFRAME michael@0: NS_DECL_FRAMEARENA_HELPERS michael@0: michael@0: nsHTMLFramesetFrame(nsStyleContext* aContext); michael@0: michael@0: virtual ~nsHTMLFramesetFrame(); michael@0: michael@0: virtual void Init(nsIContent* aContent, michael@0: nsIFrame* aParent, michael@0: nsIFrame* aPrevInFlow) MOZ_OVERRIDE; michael@0: michael@0: virtual nsresult SetInitialChildList(ChildListID aListID, michael@0: nsFrameList& aChildList) MOZ_OVERRIDE; michael@0: michael@0: static bool gDragInProgress; michael@0: michael@0: void GetSizeOfChild(nsIFrame* aChild, nsSize& aSize); michael@0: michael@0: void GetSizeOfChildAt(int32_t aIndexInParent, michael@0: nsSize& aSize, michael@0: nsIntPoint& aCellIndex); michael@0: michael@0: virtual nsresult HandleEvent(nsPresContext* aPresContext, michael@0: mozilla::WidgetGUIEvent* aEvent, michael@0: nsEventStatus* aEventStatus) MOZ_OVERRIDE; michael@0: michael@0: virtual nsresult GetCursor(const nsPoint& aPoint, michael@0: nsIFrame::Cursor& aCursor) MOZ_OVERRIDE; michael@0: michael@0: virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder, michael@0: const nsRect& aDirtyRect, michael@0: const nsDisplayListSet& aLists) MOZ_OVERRIDE; michael@0: michael@0: virtual nsresult Reflow(nsPresContext* aPresContext, michael@0: nsHTMLReflowMetrics& aDesiredSize, michael@0: const nsHTMLReflowState& aReflowState, michael@0: nsReflowStatus& aStatus) MOZ_OVERRIDE; michael@0: michael@0: virtual nsIAtom* GetType() const MOZ_OVERRIDE; michael@0: #ifdef DEBUG_FRAME_DUMP michael@0: virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE; michael@0: #endif michael@0: michael@0: virtual bool IsLeaf() const MOZ_OVERRIDE; michael@0: michael@0: void StartMouseDrag(nsPresContext* aPresContext, michael@0: nsHTMLFramesetBorderFrame* aBorder, michael@0: mozilla::WidgetGUIEvent* aEvent); michael@0: michael@0: void MouseDrag(nsPresContext* aPresContext, michael@0: mozilla::WidgetGUIEvent* aEvent); michael@0: michael@0: void EndMouseDrag(nsPresContext* aPresContext); michael@0: michael@0: nsFrameborder GetParentFrameborder() { return mParentFrameborder; } michael@0: michael@0: void SetParentFrameborder(nsFrameborder aValue) { mParentFrameborder = aValue; } michael@0: michael@0: nsFramesetDrag& GetDrag() { return mDrag; } michael@0: michael@0: void RecalculateBorderResize(); michael@0: michael@0: protected: michael@0: void Scale(nscoord aDesired, michael@0: int32_t aNumIndicies, michael@0: int32_t* aIndicies, michael@0: int32_t aNumItems, michael@0: int32_t* aItems); michael@0: michael@0: void CalculateRowCol(nsPresContext* aPresContext, michael@0: nscoord aSize, michael@0: int32_t aNumSpecs, michael@0: const nsFramesetSpec* aSpecs, michael@0: nscoord* aValues); michael@0: michael@0: void GenerateRowCol(nsPresContext* aPresContext, michael@0: nscoord aSize, michael@0: int32_t aNumSpecs, michael@0: const nsFramesetSpec* aSpecs, michael@0: nscoord* aValues, michael@0: nsString& aNewAttr); michael@0: michael@0: virtual void GetDesiredSize(nsPresContext* aPresContext, michael@0: const nsHTMLReflowState& aReflowState, michael@0: nsHTMLReflowMetrics& aDesiredSize); michael@0: michael@0: int32_t GetBorderWidth(nsPresContext* aPresContext, michael@0: bool aTakeForcingIntoAccount); michael@0: michael@0: int32_t GetParentBorderWidth() { return mParentBorderWidth; } michael@0: michael@0: void SetParentBorderWidth(int32_t aWidth) { mParentBorderWidth = aWidth; } michael@0: michael@0: nscolor GetParentBorderColor() { return mParentBorderColor; } michael@0: michael@0: void SetParentBorderColor(nscolor aColor) { mParentBorderColor = aColor; } michael@0: michael@0: nsFrameborder GetFrameBorder(); michael@0: michael@0: nsFrameborder GetFrameBorder(nsIContent* aContent); michael@0: michael@0: nscolor GetBorderColor(); michael@0: michael@0: nscolor GetBorderColor(nsIContent* aFrameContent); michael@0: michael@0: bool GetNoResize(nsIFrame* aChildFrame); michael@0: michael@0: void ReflowPlaceChild(nsIFrame* aChild, michael@0: nsPresContext* aPresContext, michael@0: const nsHTMLReflowState& aReflowState, michael@0: nsPoint& aOffset, michael@0: nsSize& aSize, michael@0: nsIntPoint* aCellIndex = 0); michael@0: michael@0: bool CanResize(bool aVertical, bool aLeft); michael@0: michael@0: bool CanChildResize(bool aVertical, bool aLeft, int32_t aChildX); michael@0: michael@0: void SetBorderResize(nsHTMLFramesetBorderFrame* aBorderFrame); michael@0: michael@0: static void FrameResizePrefCallback(const char* aPref, void* aClosure); michael@0: michael@0: nsFramesetDrag mDrag; michael@0: nsBorderColor mEdgeColors; michael@0: nsHTMLFramesetBorderFrame* mDragger; michael@0: nsHTMLFramesetFrame* mTopLevelFrameset; michael@0: nsHTMLFramesetBorderFrame** mVerBorders; // vertical borders michael@0: nsHTMLFramesetBorderFrame** mHorBorders; // horizontal borders michael@0: nsFrameborder* mChildFrameborder; // the frameborder attr of children michael@0: nsBorderColor* mChildBorderColors; michael@0: nscoord* mRowSizes; // currently computed row sizes michael@0: nscoord* mColSizes; // currently computed col sizes michael@0: nsIntPoint mFirstDragPoint; michael@0: int32_t mNumRows; michael@0: int32_t mNumCols; michael@0: int32_t mNonBorderChildCount; michael@0: int32_t mNonBlankChildCount; michael@0: int32_t mEdgeVisibility; michael@0: nsFrameborder mParentFrameborder; michael@0: nscolor mParentBorderColor; michael@0: int32_t mParentBorderWidth; michael@0: int32_t mPrevNeighborOrigSize; // used during resize michael@0: int32_t mNextNeighborOrigSize; michael@0: int32_t mMinDrag; michael@0: int32_t mChildCount; michael@0: bool mForceFrameResizability; michael@0: }; michael@0: michael@0: #endif