Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | /* base class of all rendering objects */ |
michael@0 | 7 | |
michael@0 | 8 | #ifndef nsFrame_h___ |
michael@0 | 9 | #define nsFrame_h___ |
michael@0 | 10 | |
michael@0 | 11 | #include "mozilla/Attributes.h" |
michael@0 | 12 | #include "mozilla/EventForwards.h" |
michael@0 | 13 | #include "mozilla/Likely.h" |
michael@0 | 14 | #include "nsBox.h" |
michael@0 | 15 | #include "prlog.h" |
michael@0 | 16 | |
michael@0 | 17 | #include "nsIPresShell.h" |
michael@0 | 18 | #include "nsHTMLReflowState.h" |
michael@0 | 19 | #include "nsHTMLParts.h" |
michael@0 | 20 | #include "nsISelectionDisplay.h" |
michael@0 | 21 | |
michael@0 | 22 | /** |
michael@0 | 23 | * nsFrame logging constants. We redefine the nspr |
michael@0 | 24 | * PRLogModuleInfo.level field to be a bitfield. Each bit controls a |
michael@0 | 25 | * specific type of logging. Each logging operation has associated |
michael@0 | 26 | * inline methods defined below. |
michael@0 | 27 | */ |
michael@0 | 28 | #define NS_FRAME_TRACE_CALLS 0x1 |
michael@0 | 29 | #define NS_FRAME_TRACE_PUSH_PULL 0x2 |
michael@0 | 30 | #define NS_FRAME_TRACE_CHILD_REFLOW 0x4 |
michael@0 | 31 | #define NS_FRAME_TRACE_NEW_FRAMES 0x8 |
michael@0 | 32 | |
michael@0 | 33 | #define NS_FRAME_LOG_TEST(_lm,_bit) (int((_lm)->level) & (_bit)) |
michael@0 | 34 | |
michael@0 | 35 | #ifdef DEBUG |
michael@0 | 36 | #define NS_FRAME_LOG(_bit,_args) \ |
michael@0 | 37 | PR_BEGIN_MACRO \ |
michael@0 | 38 | if (NS_FRAME_LOG_TEST(nsFrame::GetLogModuleInfo(),_bit)) { \ |
michael@0 | 39 | PR_LogPrint _args; \ |
michael@0 | 40 | } \ |
michael@0 | 41 | PR_END_MACRO |
michael@0 | 42 | #else |
michael@0 | 43 | #define NS_FRAME_LOG(_bit,_args) |
michael@0 | 44 | #endif |
michael@0 | 45 | |
michael@0 | 46 | // XXX Need to rework this so that logging is free when it's off |
michael@0 | 47 | #ifdef DEBUG |
michael@0 | 48 | #define NS_FRAME_TRACE_IN(_method) Trace(_method, true) |
michael@0 | 49 | |
michael@0 | 50 | #define NS_FRAME_TRACE_OUT(_method) Trace(_method, false) |
michael@0 | 51 | |
michael@0 | 52 | // XXX remove me |
michael@0 | 53 | #define NS_FRAME_TRACE_MSG(_bit,_args) \ |
michael@0 | 54 | PR_BEGIN_MACRO \ |
michael@0 | 55 | if (NS_FRAME_LOG_TEST(nsFrame::GetLogModuleInfo(),_bit)) { \ |
michael@0 | 56 | TraceMsg _args; \ |
michael@0 | 57 | } \ |
michael@0 | 58 | PR_END_MACRO |
michael@0 | 59 | |
michael@0 | 60 | #define NS_FRAME_TRACE(_bit,_args) \ |
michael@0 | 61 | PR_BEGIN_MACRO \ |
michael@0 | 62 | if (NS_FRAME_LOG_TEST(nsFrame::GetLogModuleInfo(),_bit)) { \ |
michael@0 | 63 | TraceMsg _args; \ |
michael@0 | 64 | } \ |
michael@0 | 65 | PR_END_MACRO |
michael@0 | 66 | |
michael@0 | 67 | #define NS_FRAME_TRACE_REFLOW_IN(_method) Trace(_method, true) |
michael@0 | 68 | |
michael@0 | 69 | #define NS_FRAME_TRACE_REFLOW_OUT(_method, _status) \ |
michael@0 | 70 | Trace(_method, false, _status) |
michael@0 | 71 | |
michael@0 | 72 | #else |
michael@0 | 73 | #define NS_FRAME_TRACE(_bits,_args) |
michael@0 | 74 | #define NS_FRAME_TRACE_IN(_method) |
michael@0 | 75 | #define NS_FRAME_TRACE_OUT(_method) |
michael@0 | 76 | #define NS_FRAME_TRACE_MSG(_bits,_args) |
michael@0 | 77 | #define NS_FRAME_TRACE_REFLOW_IN(_method) |
michael@0 | 78 | #define NS_FRAME_TRACE_REFLOW_OUT(_method, _status) |
michael@0 | 79 | #endif |
michael@0 | 80 | |
michael@0 | 81 | // Frame allocation boilerplate macros. Every subclass of nsFrame |
michael@0 | 82 | // must define its own operator new and GetAllocatedSize. If they do |
michael@0 | 83 | // not, the per-frame recycler lists in nsPresArena will not work |
michael@0 | 84 | // correctly, with potentially catastrophic consequences (not enough |
michael@0 | 85 | // memory is allocated for a frame object). |
michael@0 | 86 | |
michael@0 | 87 | #define NS_DECL_FRAMEARENA_HELPERS \ |
michael@0 | 88 | void* operator new(size_t, nsIPresShell*) MOZ_MUST_OVERRIDE; \ |
michael@0 | 89 | virtual nsQueryFrame::FrameIID GetFrameId() MOZ_MUST_OVERRIDE; |
michael@0 | 90 | |
michael@0 | 91 | #define NS_IMPL_FRAMEARENA_HELPERS(class) \ |
michael@0 | 92 | void* class::operator new(size_t sz, nsIPresShell* aShell) \ |
michael@0 | 93 | { return aShell->AllocateFrame(nsQueryFrame::class##_id, sz); } \ |
michael@0 | 94 | nsQueryFrame::FrameIID class::GetFrameId() \ |
michael@0 | 95 | { return nsQueryFrame::class##_id; } |
michael@0 | 96 | |
michael@0 | 97 | //---------------------------------------------------------------------- |
michael@0 | 98 | |
michael@0 | 99 | struct nsBoxLayoutMetrics; |
michael@0 | 100 | class nsDisplayBackgroundImage; |
michael@0 | 101 | struct nsRect; |
michael@0 | 102 | |
michael@0 | 103 | /** |
michael@0 | 104 | * Implementation of a simple frame that's not splittable and has no |
michael@0 | 105 | * child frames. |
michael@0 | 106 | * |
michael@0 | 107 | * Sets the NS_FRAME_SYNCHRONIZE_FRAME_AND_VIEW bit, so the default |
michael@0 | 108 | * behavior is to keep the frame and view position and size in sync. |
michael@0 | 109 | */ |
michael@0 | 110 | class nsFrame : public nsBox |
michael@0 | 111 | { |
michael@0 | 112 | public: |
michael@0 | 113 | /** |
michael@0 | 114 | * Create a new "empty" frame that maps a given piece of content into a |
michael@0 | 115 | * 0,0 area. |
michael@0 | 116 | */ |
michael@0 | 117 | friend nsIFrame* NS_NewEmptyFrame(nsIPresShell* aShell, |
michael@0 | 118 | nsStyleContext* aContext); |
michael@0 | 119 | |
michael@0 | 120 | private: |
michael@0 | 121 | // Left undefined; nsFrame objects are never allocated from the heap. |
michael@0 | 122 | void* operator new(size_t sz) CPP_THROW_NEW; |
michael@0 | 123 | |
michael@0 | 124 | protected: |
michael@0 | 125 | // Overridden to prevent the global delete from being called, since |
michael@0 | 126 | // the memory came out of an arena instead of the heap. |
michael@0 | 127 | // |
michael@0 | 128 | // Ideally this would be private and undefined, like the normal |
michael@0 | 129 | // operator new. Unfortunately, the C++ standard requires an |
michael@0 | 130 | // overridden operator delete to be accessible to any subclass that |
michael@0 | 131 | // defines a virtual destructor, so we can only make it protected; |
michael@0 | 132 | // worse, some C++ compilers will synthesize calls to this function |
michael@0 | 133 | // from the "deleting destructors" that they emit in case of |
michael@0 | 134 | // delete-expressions, so it can't even be undefined. |
michael@0 | 135 | void operator delete(void* aPtr, size_t sz); |
michael@0 | 136 | |
michael@0 | 137 | public: |
michael@0 | 138 | |
michael@0 | 139 | // nsQueryFrame |
michael@0 | 140 | NS_DECL_QUERYFRAME |
michael@0 | 141 | NS_DECL_FRAMEARENA_HELPERS |
michael@0 | 142 | |
michael@0 | 143 | // nsIFrame |
michael@0 | 144 | virtual void Init(nsIContent* aContent, |
michael@0 | 145 | nsIFrame* aParent, |
michael@0 | 146 | nsIFrame* asPrevInFlow) MOZ_OVERRIDE; |
michael@0 | 147 | virtual nsresult SetInitialChildList(ChildListID aListID, |
michael@0 | 148 | nsFrameList& aChildList) MOZ_OVERRIDE; |
michael@0 | 149 | virtual nsresult AppendFrames(ChildListID aListID, |
michael@0 | 150 | nsFrameList& aFrameList) MOZ_OVERRIDE; |
michael@0 | 151 | virtual nsresult InsertFrames(ChildListID aListID, |
michael@0 | 152 | nsIFrame* aPrevFrame, |
michael@0 | 153 | nsFrameList& aFrameList) MOZ_OVERRIDE; |
michael@0 | 154 | virtual nsresult RemoveFrame(ChildListID aListID, |
michael@0 | 155 | nsIFrame* aOldFrame) MOZ_OVERRIDE; |
michael@0 | 156 | virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE; |
michael@0 | 157 | virtual nsStyleContext* GetAdditionalStyleContext(int32_t aIndex) const MOZ_OVERRIDE; |
michael@0 | 158 | virtual void SetAdditionalStyleContext(int32_t aIndex, |
michael@0 | 159 | nsStyleContext* aStyleContext) MOZ_OVERRIDE; |
michael@0 | 160 | virtual void SetParent(nsIFrame* aParent) MOZ_OVERRIDE; |
michael@0 | 161 | virtual nscoord GetBaseline() const MOZ_OVERRIDE; |
michael@0 | 162 | virtual const nsFrameList& GetChildList(ChildListID aListID) const MOZ_OVERRIDE; |
michael@0 | 163 | virtual void GetChildLists(nsTArray<ChildList>* aLists) const MOZ_OVERRIDE; |
michael@0 | 164 | |
michael@0 | 165 | virtual nsresult HandleEvent(nsPresContext* aPresContext, |
michael@0 | 166 | mozilla::WidgetGUIEvent* aEvent, |
michael@0 | 167 | nsEventStatus* aEventStatus) MOZ_OVERRIDE; |
michael@0 | 168 | virtual nsresult GetContentForEvent(mozilla::WidgetEvent* aEvent, |
michael@0 | 169 | nsIContent** aContent) MOZ_OVERRIDE; |
michael@0 | 170 | virtual nsresult GetCursor(const nsPoint& aPoint, |
michael@0 | 171 | nsIFrame::Cursor& aCursor) MOZ_OVERRIDE; |
michael@0 | 172 | |
michael@0 | 173 | virtual nsresult GetPointFromOffset(int32_t inOffset, |
michael@0 | 174 | nsPoint* outPoint) MOZ_OVERRIDE; |
michael@0 | 175 | |
michael@0 | 176 | virtual nsresult GetChildFrameContainingOffset(int32_t inContentOffset, |
michael@0 | 177 | bool inHint, |
michael@0 | 178 | int32_t* outFrameContentOffset, |
michael@0 | 179 | nsIFrame** outChildFrame) MOZ_OVERRIDE; |
michael@0 | 180 | |
michael@0 | 181 | static nsresult GetNextPrevLineFromeBlockFrame(nsPresContext* aPresContext, |
michael@0 | 182 | nsPeekOffsetStruct *aPos, |
michael@0 | 183 | nsIFrame *aBlockFrame, |
michael@0 | 184 | int32_t aLineStart, |
michael@0 | 185 | int8_t aOutSideLimit |
michael@0 | 186 | ); |
michael@0 | 187 | |
michael@0 | 188 | virtual nsresult CharacterDataChanged(CharacterDataChangeInfo* aInfo) MOZ_OVERRIDE; |
michael@0 | 189 | virtual nsresult AttributeChanged(int32_t aNameSpaceID, |
michael@0 | 190 | nsIAtom* aAttribute, |
michael@0 | 191 | int32_t aModType) MOZ_OVERRIDE; |
michael@0 | 192 | virtual nsSplittableType GetSplittableType() const MOZ_OVERRIDE; |
michael@0 | 193 | virtual nsIFrame* GetPrevContinuation() const MOZ_OVERRIDE; |
michael@0 | 194 | virtual void SetPrevContinuation(nsIFrame*) MOZ_OVERRIDE; |
michael@0 | 195 | virtual nsIFrame* GetNextContinuation() const MOZ_OVERRIDE; |
michael@0 | 196 | virtual void SetNextContinuation(nsIFrame*) MOZ_OVERRIDE; |
michael@0 | 197 | virtual nsIFrame* GetPrevInFlowVirtual() const MOZ_OVERRIDE; |
michael@0 | 198 | virtual void SetPrevInFlow(nsIFrame*) MOZ_OVERRIDE; |
michael@0 | 199 | virtual nsIFrame* GetNextInFlowVirtual() const MOZ_OVERRIDE; |
michael@0 | 200 | virtual void SetNextInFlow(nsIFrame*) MOZ_OVERRIDE; |
michael@0 | 201 | virtual nsIAtom* GetType() const MOZ_OVERRIDE; |
michael@0 | 202 | |
michael@0 | 203 | virtual nsresult IsSelectable(bool* aIsSelectable, uint8_t* aSelectStyle) const MOZ_OVERRIDE; |
michael@0 | 204 | |
michael@0 | 205 | virtual nsresult GetSelectionController(nsPresContext *aPresContext, nsISelectionController **aSelCon) MOZ_OVERRIDE; |
michael@0 | 206 | |
michael@0 | 207 | virtual FrameSearchResult PeekOffsetNoAmount(bool aForward, int32_t* aOffset) MOZ_OVERRIDE; |
michael@0 | 208 | virtual FrameSearchResult PeekOffsetCharacter(bool aForward, int32_t* aOffset, |
michael@0 | 209 | bool aRespectClusters = true) MOZ_OVERRIDE; |
michael@0 | 210 | virtual FrameSearchResult PeekOffsetWord(bool aForward, bool aWordSelectEatSpace, bool aIsKeyboardSelect, |
michael@0 | 211 | int32_t* aOffset, PeekWordState *aState) MOZ_OVERRIDE; |
michael@0 | 212 | /** |
michael@0 | 213 | * Check whether we should break at a boundary between punctuation and |
michael@0 | 214 | * non-punctuation. Only call it at a punctuation boundary |
michael@0 | 215 | * (i.e. exactly one of the previous and next characters are punctuation). |
michael@0 | 216 | * @param aForward true if we're moving forward in content order |
michael@0 | 217 | * @param aPunctAfter true if the next character is punctuation |
michael@0 | 218 | * @param aWhitespaceAfter true if the next character is whitespace |
michael@0 | 219 | */ |
michael@0 | 220 | bool BreakWordBetweenPunctuation(const PeekWordState* aState, |
michael@0 | 221 | bool aForward, |
michael@0 | 222 | bool aPunctAfter, bool aWhitespaceAfter, |
michael@0 | 223 | bool aIsKeyboardSelect); |
michael@0 | 224 | |
michael@0 | 225 | virtual nsresult CheckVisibility(nsPresContext* aContext, int32_t aStartIndex, int32_t aEndIndex, bool aRecurse, bool *aFinished, bool *_retval) MOZ_OVERRIDE; |
michael@0 | 226 | |
michael@0 | 227 | virtual nsresult GetOffsets(int32_t &aStart, int32_t &aEnd) const MOZ_OVERRIDE; |
michael@0 | 228 | virtual void ChildIsDirty(nsIFrame* aChild) MOZ_OVERRIDE; |
michael@0 | 229 | |
michael@0 | 230 | #ifdef ACCESSIBILITY |
michael@0 | 231 | virtual mozilla::a11y::AccType AccessibleType() MOZ_OVERRIDE; |
michael@0 | 232 | #endif |
michael@0 | 233 | |
michael@0 | 234 | virtual nsIFrame* GetParentStyleContextFrame() const MOZ_OVERRIDE { |
michael@0 | 235 | return DoGetParentStyleContextFrame(); |
michael@0 | 236 | } |
michael@0 | 237 | |
michael@0 | 238 | /** |
michael@0 | 239 | * Do the work for getting the parent style context frame so that |
michael@0 | 240 | * other frame's |GetParentStyleContextFrame| methods can call this |
michael@0 | 241 | * method on *another* frame. (This function handles out-of-flow |
michael@0 | 242 | * frames by using the frame manager's placeholder map and it also |
michael@0 | 243 | * handles block-within-inline and generated content wrappers.) |
michael@0 | 244 | */ |
michael@0 | 245 | nsIFrame* DoGetParentStyleContextFrame() const; |
michael@0 | 246 | |
michael@0 | 247 | virtual bool IsEmpty() MOZ_OVERRIDE; |
michael@0 | 248 | virtual bool IsSelfEmpty() MOZ_OVERRIDE; |
michael@0 | 249 | |
michael@0 | 250 | virtual void MarkIntrinsicWidthsDirty() MOZ_OVERRIDE; |
michael@0 | 251 | virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE; |
michael@0 | 252 | virtual nscoord GetPrefWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE; |
michael@0 | 253 | virtual void AddInlineMinWidth(nsRenderingContext *aRenderingContext, |
michael@0 | 254 | InlineMinWidthData *aData) MOZ_OVERRIDE; |
michael@0 | 255 | virtual void AddInlinePrefWidth(nsRenderingContext *aRenderingContext, |
michael@0 | 256 | InlinePrefWidthData *aData) MOZ_OVERRIDE; |
michael@0 | 257 | virtual IntrinsicWidthOffsetData |
michael@0 | 258 | IntrinsicWidthOffsets(nsRenderingContext* aRenderingContext) MOZ_OVERRIDE; |
michael@0 | 259 | virtual mozilla::IntrinsicSize GetIntrinsicSize() MOZ_OVERRIDE; |
michael@0 | 260 | virtual nsSize GetIntrinsicRatio() MOZ_OVERRIDE; |
michael@0 | 261 | |
michael@0 | 262 | virtual nsSize ComputeSize(nsRenderingContext *aRenderingContext, |
michael@0 | 263 | nsSize aCBSize, nscoord aAvailableWidth, |
michael@0 | 264 | nsSize aMargin, nsSize aBorder, nsSize aPadding, |
michael@0 | 265 | uint32_t aFlags) MOZ_OVERRIDE; |
michael@0 | 266 | |
michael@0 | 267 | // Compute tight bounds assuming this frame honours its border, background |
michael@0 | 268 | // and outline, its children's tight bounds, and nothing else. |
michael@0 | 269 | nsRect ComputeSimpleTightBounds(gfxContext* aContext) const; |
michael@0 | 270 | |
michael@0 | 271 | /** |
michael@0 | 272 | * A helper, used by |nsFrame::ComputeSize| (for frames that need to |
michael@0 | 273 | * override only this part of ComputeSize), that computes the size |
michael@0 | 274 | * that should be returned when 'width', 'height', and |
michael@0 | 275 | * min/max-width/height are all 'auto' or equivalent. |
michael@0 | 276 | * |
michael@0 | 277 | * In general, frames that can accept any computed width/height should |
michael@0 | 278 | * override only ComputeAutoSize, and frames that cannot do so need to |
michael@0 | 279 | * override ComputeSize to enforce their width/height invariants. |
michael@0 | 280 | * |
michael@0 | 281 | * Implementations may optimize by returning a garbage width if |
michael@0 | 282 | * StylePosition()->mWidth.GetUnit() != eStyleUnit_Auto, and |
michael@0 | 283 | * likewise for height, since in such cases the result is guaranteed |
michael@0 | 284 | * to be unused. |
michael@0 | 285 | */ |
michael@0 | 286 | virtual nsSize ComputeAutoSize(nsRenderingContext *aRenderingContext, |
michael@0 | 287 | nsSize aCBSize, nscoord aAvailableWidth, |
michael@0 | 288 | nsSize aMargin, nsSize aBorder, |
michael@0 | 289 | nsSize aPadding, bool aShrinkWrap); |
michael@0 | 290 | |
michael@0 | 291 | /** |
michael@0 | 292 | * Utility function for ComputeAutoSize implementations. Return |
michael@0 | 293 | * max(GetMinWidth(), min(aWidthInCB, GetPrefWidth())) |
michael@0 | 294 | */ |
michael@0 | 295 | nscoord ShrinkWidthToFit(nsRenderingContext *aRenderingContext, |
michael@0 | 296 | nscoord aWidthInCB); |
michael@0 | 297 | |
michael@0 | 298 | virtual nsresult WillReflow(nsPresContext* aPresContext) MOZ_OVERRIDE; |
michael@0 | 299 | /** |
michael@0 | 300 | * Calculates the size of this frame after reflowing (calling Reflow on, and |
michael@0 | 301 | * updating the size and position of) its children, as necessary. The |
michael@0 | 302 | * calculated size is returned to the caller via the nsHTMLReflowMetrics |
michael@0 | 303 | * outparam. (The caller is responsible for setting the actual size and |
michael@0 | 304 | * position of this frame.) |
michael@0 | 305 | * |
michael@0 | 306 | * A frame's children must _all_ be reflowed if the frame is dirty (the |
michael@0 | 307 | * NS_FRAME_IS_DIRTY bit is set on it). Otherwise, individual children |
michael@0 | 308 | * must be reflowed if they are dirty or have the NS_FRAME_HAS_DIRTY_CHILDREN |
michael@0 | 309 | * bit set on them. Otherwise, whether children need to be reflowed depends |
michael@0 | 310 | * on the frame's type (it's up to individual Reflow methods), and on what |
michael@0 | 311 | * has changed. For example, a change in the width of the frame may require |
michael@0 | 312 | * all of its children to be reflowed (even those without dirty bits set on |
michael@0 | 313 | * them), whereas a change in its height might not. |
michael@0 | 314 | * (nsHTMLReflowState::ShouldReflowAllKids may be helpful in deciding whether |
michael@0 | 315 | * to reflow all the children, but for some frame types it might result in |
michael@0 | 316 | * over-reflow.) |
michael@0 | 317 | * |
michael@0 | 318 | * Note: if it's only the overflow rect(s) of a frame that need to be |
michael@0 | 319 | * updated, then UpdateOverflow should be called instead of Reflow. |
michael@0 | 320 | */ |
michael@0 | 321 | virtual nsresult Reflow(nsPresContext* aPresContext, |
michael@0 | 322 | nsHTMLReflowMetrics& aDesiredSize, |
michael@0 | 323 | const nsHTMLReflowState& aReflowState, |
michael@0 | 324 | nsReflowStatus& aStatus) MOZ_OVERRIDE; |
michael@0 | 325 | virtual nsresult DidReflow(nsPresContext* aPresContext, |
michael@0 | 326 | const nsHTMLReflowState* aReflowState, |
michael@0 | 327 | nsDidReflowStatus aStatus) MOZ_OVERRIDE; |
michael@0 | 328 | |
michael@0 | 329 | /** |
michael@0 | 330 | * NOTE: aStatus is assumed to be already-initialized. The reflow statuses of |
michael@0 | 331 | * any reflowed absolute children will be merged into aStatus; aside from |
michael@0 | 332 | * that, this method won't modify aStatus. |
michael@0 | 333 | */ |
michael@0 | 334 | void ReflowAbsoluteFrames(nsPresContext* aPresContext, |
michael@0 | 335 | nsHTMLReflowMetrics& aDesiredSize, |
michael@0 | 336 | const nsHTMLReflowState& aReflowState, |
michael@0 | 337 | nsReflowStatus& aStatus, |
michael@0 | 338 | bool aConstrainHeight = true); |
michael@0 | 339 | void FinishReflowWithAbsoluteFrames(nsPresContext* aPresContext, |
michael@0 | 340 | nsHTMLReflowMetrics& aDesiredSize, |
michael@0 | 341 | const nsHTMLReflowState& aReflowState, |
michael@0 | 342 | nsReflowStatus& aStatus, |
michael@0 | 343 | bool aConstrainHeight = true); |
michael@0 | 344 | virtual bool CanContinueTextRun() const MOZ_OVERRIDE; |
michael@0 | 345 | |
michael@0 | 346 | virtual bool UpdateOverflow() MOZ_OVERRIDE; |
michael@0 | 347 | |
michael@0 | 348 | // Selection Methods |
michael@0 | 349 | |
michael@0 | 350 | NS_IMETHOD HandlePress(nsPresContext* aPresContext, |
michael@0 | 351 | mozilla::WidgetGUIEvent* aEvent, |
michael@0 | 352 | nsEventStatus* aEventStatus); |
michael@0 | 353 | |
michael@0 | 354 | NS_IMETHOD HandleMultiplePress(nsPresContext* aPresContext, |
michael@0 | 355 | mozilla::WidgetGUIEvent* aEvent, |
michael@0 | 356 | nsEventStatus* aEventStatus, |
michael@0 | 357 | bool aControlHeld); |
michael@0 | 358 | |
michael@0 | 359 | NS_IMETHOD HandleDrag(nsPresContext* aPresContext, |
michael@0 | 360 | mozilla::WidgetGUIEvent* aEvent, |
michael@0 | 361 | nsEventStatus* aEventStatus); |
michael@0 | 362 | |
michael@0 | 363 | NS_IMETHOD HandleRelease(nsPresContext* aPresContext, |
michael@0 | 364 | mozilla::WidgetGUIEvent* aEvent, |
michael@0 | 365 | nsEventStatus* aEventStatus); |
michael@0 | 366 | |
michael@0 | 367 | enum { SELECT_ACCUMULATE = 0x01 }; |
michael@0 | 368 | |
michael@0 | 369 | nsresult PeekBackwardAndForward(nsSelectionAmount aAmountBack, |
michael@0 | 370 | nsSelectionAmount aAmountForward, |
michael@0 | 371 | int32_t aStartPos, |
michael@0 | 372 | nsPresContext* aPresContext, |
michael@0 | 373 | bool aJumpLines, |
michael@0 | 374 | uint32_t aSelectFlags); |
michael@0 | 375 | |
michael@0 | 376 | nsresult SelectByTypeAtPoint(nsPresContext* aPresContext, |
michael@0 | 377 | const nsPoint& aPoint, |
michael@0 | 378 | nsSelectionAmount aBeginAmountType, |
michael@0 | 379 | nsSelectionAmount aEndAmountType, |
michael@0 | 380 | uint32_t aSelectFlags); |
michael@0 | 381 | |
michael@0 | 382 | // Helper for GetContentAndOffsetsFromPoint; calculation of content offsets |
michael@0 | 383 | // in this function assumes there is no child frame that can be targeted. |
michael@0 | 384 | virtual ContentOffsets CalcContentOffsetsFromFramePoint(nsPoint aPoint); |
michael@0 | 385 | |
michael@0 | 386 | // Box layout methods |
michael@0 | 387 | virtual nsSize GetPrefSize(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE; |
michael@0 | 388 | virtual nsSize GetMinSize(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE; |
michael@0 | 389 | virtual nsSize GetMaxSize(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE; |
michael@0 | 390 | virtual nscoord GetFlex(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE; |
michael@0 | 391 | virtual nscoord GetBoxAscent(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE; |
michael@0 | 392 | |
michael@0 | 393 | // We compute and store the HTML content's overflow area. So don't |
michael@0 | 394 | // try to compute it in the box code. |
michael@0 | 395 | virtual bool ComputesOwnOverflowArea() MOZ_OVERRIDE { return true; } |
michael@0 | 396 | |
michael@0 | 397 | //-------------------------------------------------- |
michael@0 | 398 | // Additional methods |
michael@0 | 399 | |
michael@0 | 400 | // Helper function that tests if the frame tree is too deep; if it is |
michael@0 | 401 | // it marks the frame as "unflowable", zeroes out the metrics, sets |
michael@0 | 402 | // the reflow status, and returns true. Otherwise, the frame is |
michael@0 | 403 | // unmarked "unflowable" and the metrics and reflow status are not |
michael@0 | 404 | // touched and false is returned. |
michael@0 | 405 | bool IsFrameTreeTooDeep(const nsHTMLReflowState& aReflowState, |
michael@0 | 406 | nsHTMLReflowMetrics& aMetrics, |
michael@0 | 407 | nsReflowStatus& aStatus); |
michael@0 | 408 | |
michael@0 | 409 | // Incorporate the child overflow areas into aOverflowAreas. |
michael@0 | 410 | // If the child does not have a overflow, use the child area. |
michael@0 | 411 | void ConsiderChildOverflow(nsOverflowAreas& aOverflowAreas, |
michael@0 | 412 | nsIFrame* aChildFrame); |
michael@0 | 413 | |
michael@0 | 414 | /** |
michael@0 | 415 | * @return true if we should avoid a page/column break in this frame. |
michael@0 | 416 | */ |
michael@0 | 417 | bool ShouldAvoidBreakInside(const nsHTMLReflowState& aReflowState) const { |
michael@0 | 418 | return !aReflowState.mFlags.mIsTopOfPage && |
michael@0 | 419 | NS_STYLE_PAGE_BREAK_AVOID == StyleDisplay()->mBreakInside && |
michael@0 | 420 | !GetPrevInFlow(); |
michael@0 | 421 | } |
michael@0 | 422 | |
michael@0 | 423 | #ifdef DEBUG |
michael@0 | 424 | /** |
michael@0 | 425 | * Tracing method that writes a method enter/exit routine to the |
michael@0 | 426 | * nspr log using the nsIFrame log module. The tracing is only |
michael@0 | 427 | * done when the NS_FRAME_TRACE_CALLS bit is set in the log module's |
michael@0 | 428 | * level field. |
michael@0 | 429 | */ |
michael@0 | 430 | void Trace(const char* aMethod, bool aEnter); |
michael@0 | 431 | void Trace(const char* aMethod, bool aEnter, nsReflowStatus aStatus); |
michael@0 | 432 | void TraceMsg(const char* fmt, ...); |
michael@0 | 433 | |
michael@0 | 434 | // Helper function that verifies that each frame in the list has the |
michael@0 | 435 | // NS_FRAME_IS_DIRTY bit set |
michael@0 | 436 | static void VerifyDirtyBitSet(const nsFrameList& aFrameList); |
michael@0 | 437 | |
michael@0 | 438 | static void XMLQuote(nsString& aString); |
michael@0 | 439 | |
michael@0 | 440 | /** |
michael@0 | 441 | * Dump out the "base classes" regression data. This should dump |
michael@0 | 442 | * out the interior data, not the "frame" XML container. And it |
michael@0 | 443 | * should call the base classes same named method before doing |
michael@0 | 444 | * anything specific in a derived class. This means that derived |
michael@0 | 445 | * classes need not override DumpRegressionData unless they need |
michael@0 | 446 | * some custom behavior that requires changing how the outer "frame" |
michael@0 | 447 | * XML container is dumped. |
michael@0 | 448 | */ |
michael@0 | 449 | virtual void DumpBaseRegressionData(nsPresContext* aPresContext, FILE* out, int32_t aIndent); |
michael@0 | 450 | |
michael@0 | 451 | // Display Reflow Debugging |
michael@0 | 452 | static void* DisplayReflowEnter(nsPresContext* aPresContext, |
michael@0 | 453 | nsIFrame* aFrame, |
michael@0 | 454 | const nsHTMLReflowState& aReflowState); |
michael@0 | 455 | static void* DisplayLayoutEnter(nsIFrame* aFrame); |
michael@0 | 456 | static void* DisplayIntrinsicWidthEnter(nsIFrame* aFrame, |
michael@0 | 457 | const char* aType); |
michael@0 | 458 | static void* DisplayIntrinsicSizeEnter(nsIFrame* aFrame, |
michael@0 | 459 | const char* aType); |
michael@0 | 460 | static void DisplayReflowExit(nsPresContext* aPresContext, |
michael@0 | 461 | nsIFrame* aFrame, |
michael@0 | 462 | nsHTMLReflowMetrics& aMetrics, |
michael@0 | 463 | uint32_t aStatus, |
michael@0 | 464 | void* aFrameTreeNode); |
michael@0 | 465 | static void DisplayLayoutExit(nsIFrame* aFrame, |
michael@0 | 466 | void* aFrameTreeNode); |
michael@0 | 467 | static void DisplayIntrinsicWidthExit(nsIFrame* aFrame, |
michael@0 | 468 | const char* aType, |
michael@0 | 469 | nscoord aResult, |
michael@0 | 470 | void* aFrameTreeNode); |
michael@0 | 471 | static void DisplayIntrinsicSizeExit(nsIFrame* aFrame, |
michael@0 | 472 | const char* aType, |
michael@0 | 473 | nsSize aResult, |
michael@0 | 474 | void* aFrameTreeNode); |
michael@0 | 475 | |
michael@0 | 476 | static void DisplayReflowStartup(); |
michael@0 | 477 | static void DisplayReflowShutdown(); |
michael@0 | 478 | #endif |
michael@0 | 479 | |
michael@0 | 480 | /** |
michael@0 | 481 | * Adds display items for standard CSS background if necessary. |
michael@0 | 482 | * Does not check IsVisibleForPainting. |
michael@0 | 483 | * @param aForceBackground draw the background even if the frame |
michael@0 | 484 | * background style appears to have no background --- this is useful |
michael@0 | 485 | * for frames that might receive a propagated background via |
michael@0 | 486 | * nsCSSRendering::FindBackground |
michael@0 | 487 | * @return whether a themed background item was created. |
michael@0 | 488 | */ |
michael@0 | 489 | bool DisplayBackgroundUnconditional(nsDisplayListBuilder* aBuilder, |
michael@0 | 490 | const nsDisplayListSet& aLists, |
michael@0 | 491 | bool aForceBackground); |
michael@0 | 492 | /** |
michael@0 | 493 | * Adds display items for standard CSS borders, background and outline for |
michael@0 | 494 | * for this frame, as necessary. Checks IsVisibleForPainting and won't |
michael@0 | 495 | * display anything if the frame is not visible. |
michael@0 | 496 | * @param aForceBackground draw the background even if the frame |
michael@0 | 497 | * background style appears to have no background --- this is useful |
michael@0 | 498 | * for frames that might receive a propagated background via |
michael@0 | 499 | * nsCSSRendering::FindBackground |
michael@0 | 500 | */ |
michael@0 | 501 | void DisplayBorderBackgroundOutline(nsDisplayListBuilder* aBuilder, |
michael@0 | 502 | const nsDisplayListSet& aLists, |
michael@0 | 503 | bool aForceBackground = false); |
michael@0 | 504 | /** |
michael@0 | 505 | * Add a display item for the CSS outline. Does not check visibility. |
michael@0 | 506 | */ |
michael@0 | 507 | void DisplayOutlineUnconditional(nsDisplayListBuilder* aBuilder, |
michael@0 | 508 | const nsDisplayListSet& aLists); |
michael@0 | 509 | /** |
michael@0 | 510 | * Add a display item for the CSS outline, after calling |
michael@0 | 511 | * IsVisibleForPainting to confirm we are visible. |
michael@0 | 512 | */ |
michael@0 | 513 | void DisplayOutline(nsDisplayListBuilder* aBuilder, |
michael@0 | 514 | const nsDisplayListSet& aLists); |
michael@0 | 515 | |
michael@0 | 516 | /** |
michael@0 | 517 | * Adjust the given parent frame to the right style context parent frame for |
michael@0 | 518 | * the child, given the pseudo-type of the prospective child. This handles |
michael@0 | 519 | * things like walking out of table pseudos and so forth. |
michael@0 | 520 | * |
michael@0 | 521 | * @param aProspectiveParent what GetParent() on the child returns. |
michael@0 | 522 | * Must not be null. |
michael@0 | 523 | * @param aChildPseudo the child's pseudo type, if any. |
michael@0 | 524 | */ |
michael@0 | 525 | static nsIFrame* |
michael@0 | 526 | CorrectStyleParentFrame(nsIFrame* aProspectiveParent, nsIAtom* aChildPseudo); |
michael@0 | 527 | |
michael@0 | 528 | protected: |
michael@0 | 529 | // Protected constructor and destructor |
michael@0 | 530 | nsFrame(nsStyleContext* aContext); |
michael@0 | 531 | virtual ~nsFrame(); |
michael@0 | 532 | |
michael@0 | 533 | /** |
michael@0 | 534 | * To be called by |BuildDisplayLists| of this class or derived classes to add |
michael@0 | 535 | * a translucent overlay if this frame's content is selected. |
michael@0 | 536 | * @param aContentType an nsISelectionDisplay DISPLAY_ constant identifying |
michael@0 | 537 | * which kind of content this is for |
michael@0 | 538 | */ |
michael@0 | 539 | void DisplaySelectionOverlay(nsDisplayListBuilder* aBuilder, |
michael@0 | 540 | nsDisplayList* aList, uint16_t aContentType = nsISelectionDisplay::DISPLAY_FRAMES); |
michael@0 | 541 | |
michael@0 | 542 | int16_t DisplaySelection(nsPresContext* aPresContext, bool isOkToTurnOn = false); |
michael@0 | 543 | |
michael@0 | 544 | // Style post processing hook |
michael@0 | 545 | virtual void DidSetStyleContext(nsStyleContext* aOldStyleContext) MOZ_OVERRIDE; |
michael@0 | 546 | |
michael@0 | 547 | public: |
michael@0 | 548 | //given a frame five me the first/last leaf available |
michael@0 | 549 | //XXX Robert O'Callahan wants to move these elsewhere |
michael@0 | 550 | static void GetLastLeaf(nsPresContext* aPresContext, nsIFrame **aFrame); |
michael@0 | 551 | static void GetFirstLeaf(nsPresContext* aPresContext, nsIFrame **aFrame); |
michael@0 | 552 | |
michael@0 | 553 | // Return the line number of the aFrame, and (optionally) the containing block |
michael@0 | 554 | // frame. |
michael@0 | 555 | // If aScrollLock is true, don't break outside scrollframes when looking for a |
michael@0 | 556 | // containing block frame. |
michael@0 | 557 | static int32_t GetLineNumber(nsIFrame *aFrame, |
michael@0 | 558 | bool aLockScroll, |
michael@0 | 559 | nsIFrame** aContainingBlock = nullptr); |
michael@0 | 560 | |
michael@0 | 561 | /** |
michael@0 | 562 | * Returns true if aFrame should apply overflow clipping. |
michael@0 | 563 | */ |
michael@0 | 564 | static bool ShouldApplyOverflowClipping(const nsIFrame* aFrame, |
michael@0 | 565 | const nsStyleDisplay* aDisp) |
michael@0 | 566 | { |
michael@0 | 567 | // clip overflow:-moz-hidden-unscrollable ... |
michael@0 | 568 | if (MOZ_UNLIKELY(aDisp->mOverflowX == NS_STYLE_OVERFLOW_CLIP)) { |
michael@0 | 569 | return true; |
michael@0 | 570 | } |
michael@0 | 571 | |
michael@0 | 572 | // and overflow:hidden that we should interpret as -moz-hidden-unscrollable |
michael@0 | 573 | if (aDisp->mOverflowX == NS_STYLE_OVERFLOW_HIDDEN && |
michael@0 | 574 | aDisp->mOverflowY == NS_STYLE_OVERFLOW_HIDDEN) { |
michael@0 | 575 | // REVIEW: these are the frame types that set up clipping. |
michael@0 | 576 | nsIAtom* type = aFrame->GetType(); |
michael@0 | 577 | if (type == nsGkAtoms::tableFrame || |
michael@0 | 578 | type == nsGkAtoms::tableCellFrame || |
michael@0 | 579 | type == nsGkAtoms::bcTableCellFrame || |
michael@0 | 580 | type == nsGkAtoms::svgOuterSVGFrame || |
michael@0 | 581 | type == nsGkAtoms::svgInnerSVGFrame || |
michael@0 | 582 | type == nsGkAtoms::svgForeignObjectFrame) { |
michael@0 | 583 | return true; |
michael@0 | 584 | } |
michael@0 | 585 | if (aFrame->IsFrameOfType(nsIFrame::eReplacedContainsBlock)) { |
michael@0 | 586 | if (type == nsGkAtoms::textInputFrame) { |
michael@0 | 587 | // It always has an anonymous scroll frame that handles any overflow. |
michael@0 | 588 | return false; |
michael@0 | 589 | } |
michael@0 | 590 | return true; |
michael@0 | 591 | } |
michael@0 | 592 | } |
michael@0 | 593 | |
michael@0 | 594 | if ((aFrame->GetStateBits() & NS_FRAME_SVG_LAYOUT)) { |
michael@0 | 595 | return false; |
michael@0 | 596 | } |
michael@0 | 597 | |
michael@0 | 598 | // If we're paginated and a block, and have NS_BLOCK_CLIP_PAGINATED_OVERFLOW |
michael@0 | 599 | // set, then we want to clip our overflow. |
michael@0 | 600 | return |
michael@0 | 601 | (aFrame->GetStateBits() & NS_BLOCK_CLIP_PAGINATED_OVERFLOW) != 0 && |
michael@0 | 602 | aFrame->PresContext()->IsPaginated() && |
michael@0 | 603 | aFrame->GetType() == nsGkAtoms::blockFrame; |
michael@0 | 604 | } |
michael@0 | 605 | |
michael@0 | 606 | protected: |
michael@0 | 607 | |
michael@0 | 608 | // Test if we are selecting a table object: |
michael@0 | 609 | // Most table/cell selection requires that Ctrl (Cmd on Mac) key is down |
michael@0 | 610 | // during a mouse click or drag. Exception is using Shift+click when |
michael@0 | 611 | // already in "table/cell selection mode" to extend a block selection |
michael@0 | 612 | // Get the parent content node and offset of the frame |
michael@0 | 613 | // of the enclosing cell or table (if not inside a cell) |
michael@0 | 614 | // aTarget tells us what table element to select (currently only cell and table supported) |
michael@0 | 615 | // (enums for this are defined in nsIFrame.h) |
michael@0 | 616 | NS_IMETHOD GetDataForTableSelection(const nsFrameSelection* aFrameSelection, |
michael@0 | 617 | nsIPresShell* aPresShell, |
michael@0 | 618 | mozilla::WidgetMouseEvent* aMouseEvent, |
michael@0 | 619 | nsIContent** aParentContent, |
michael@0 | 620 | int32_t* aContentOffset, |
michael@0 | 621 | int32_t* aTarget); |
michael@0 | 622 | |
michael@0 | 623 | // Fills aCursor with the appropriate information from ui |
michael@0 | 624 | static void FillCursorInformationFromStyle(const nsStyleUserInterface* ui, |
michael@0 | 625 | nsIFrame::Cursor& aCursor); |
michael@0 | 626 | NS_IMETHOD DoLayout(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE; |
michael@0 | 627 | |
michael@0 | 628 | #ifdef DEBUG_LAYOUT |
michael@0 | 629 | virtual void GetBoxName(nsAutoString& aName) MOZ_OVERRIDE; |
michael@0 | 630 | #endif |
michael@0 | 631 | |
michael@0 | 632 | void InitBoxMetrics(bool aClear); |
michael@0 | 633 | nsBoxLayoutMetrics* BoxMetrics() const; |
michael@0 | 634 | |
michael@0 | 635 | // Fire DOM event. If no aContent argument use frame's mContent. |
michael@0 | 636 | void FireDOMEvent(const nsAString& aDOMEventName, nsIContent *aContent = nullptr); |
michael@0 | 637 | |
michael@0 | 638 | private: |
michael@0 | 639 | nsresult BoxReflow(nsBoxLayoutState& aState, |
michael@0 | 640 | nsPresContext* aPresContext, |
michael@0 | 641 | nsHTMLReflowMetrics& aDesiredSize, |
michael@0 | 642 | nsRenderingContext* aRenderingContext, |
michael@0 | 643 | nscoord aX, |
michael@0 | 644 | nscoord aY, |
michael@0 | 645 | nscoord aWidth, |
michael@0 | 646 | nscoord aHeight, |
michael@0 | 647 | bool aMoveFrame = true); |
michael@0 | 648 | |
michael@0 | 649 | NS_IMETHODIMP RefreshSizeCache(nsBoxLayoutState& aState); |
michael@0 | 650 | |
michael@0 | 651 | virtual nsILineIterator* GetLineIterator() MOZ_OVERRIDE; |
michael@0 | 652 | |
michael@0 | 653 | #ifdef DEBUG_FRAME_DUMP |
michael@0 | 654 | public: |
michael@0 | 655 | /** |
michael@0 | 656 | * Get a printable from of the name of the frame type. |
michael@0 | 657 | * XXX This should be eliminated and we use GetType() instead... |
michael@0 | 658 | */ |
michael@0 | 659 | virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE; |
michael@0 | 660 | nsresult MakeFrameName(const nsAString& aKind, nsAString& aResult) const; |
michael@0 | 661 | // Helper function to return the index in parent of the frame's content |
michael@0 | 662 | // object. Returns -1 on error or if the frame doesn't have a content object |
michael@0 | 663 | static int32_t ContentIndexInContainer(const nsIFrame* aFrame); |
michael@0 | 664 | #endif |
michael@0 | 665 | |
michael@0 | 666 | #ifdef DEBUG |
michael@0 | 667 | public: |
michael@0 | 668 | /** |
michael@0 | 669 | * Return the state bits that are relevant to regression tests (that |
michael@0 | 670 | * is, those bits which indicate a real difference when they differ |
michael@0 | 671 | */ |
michael@0 | 672 | virtual nsFrameState GetDebugStateBits() const MOZ_OVERRIDE; |
michael@0 | 673 | /** |
michael@0 | 674 | * Called to dump out regression data that describes the layout |
michael@0 | 675 | * of the frame and its children, and so on. The format of the |
michael@0 | 676 | * data is dictated to be XML (using a specific DTD); the |
michael@0 | 677 | * specific kind of data dumped is up to the frame itself, with |
michael@0 | 678 | * the caveat that some base types are defined. |
michael@0 | 679 | * For more information, see XXX. |
michael@0 | 680 | */ |
michael@0 | 681 | virtual nsresult DumpRegressionData(nsPresContext* aPresContext, |
michael@0 | 682 | FILE* out, int32_t aIndent) MOZ_OVERRIDE; |
michael@0 | 683 | |
michael@0 | 684 | /** |
michael@0 | 685 | * See if style tree verification is enabled. To enable style tree |
michael@0 | 686 | * verification add "styleverifytree:1" to your NSPR_LOG_MODULES |
michael@0 | 687 | * environment variable (any non-zero debug level will work). Or, |
michael@0 | 688 | * call SetVerifyStyleTreeEnable with true. |
michael@0 | 689 | */ |
michael@0 | 690 | static bool GetVerifyStyleTreeEnable(); |
michael@0 | 691 | |
michael@0 | 692 | /** |
michael@0 | 693 | * Set the verify-style-tree enable flag. |
michael@0 | 694 | */ |
michael@0 | 695 | static void SetVerifyStyleTreeEnable(bool aEnabled); |
michael@0 | 696 | |
michael@0 | 697 | /** |
michael@0 | 698 | * The frame class and related classes share an nspr log module |
michael@0 | 699 | * for logging frame activity. |
michael@0 | 700 | * |
michael@0 | 701 | * Note: the log module is created during library initialization which |
michael@0 | 702 | * means that you cannot perform logging before then. |
michael@0 | 703 | */ |
michael@0 | 704 | static PRLogModuleInfo* GetLogModuleInfo(); |
michael@0 | 705 | |
michael@0 | 706 | // Show frame borders when rendering |
michael@0 | 707 | static void ShowFrameBorders(bool aEnable); |
michael@0 | 708 | static bool GetShowFrameBorders(); |
michael@0 | 709 | |
michael@0 | 710 | // Show frame border of event target |
michael@0 | 711 | static void ShowEventTargetFrameBorder(bool aEnable); |
michael@0 | 712 | static bool GetShowEventTargetFrameBorder(); |
michael@0 | 713 | |
michael@0 | 714 | #endif |
michael@0 | 715 | #ifdef MOZ_DUMP_PAINTING |
michael@0 | 716 | public: |
michael@0 | 717 | |
michael@0 | 718 | static void PrintDisplayItem(nsDisplayListBuilder* aBuilder, |
michael@0 | 719 | nsDisplayItem* aItem, |
michael@0 | 720 | FILE* aFile = stdout, |
michael@0 | 721 | bool aDumpSublist = false, |
michael@0 | 722 | bool aDumpHtml = false); |
michael@0 | 723 | |
michael@0 | 724 | static void PrintDisplayList(nsDisplayListBuilder* aBuilder, |
michael@0 | 725 | const nsDisplayList& aList, |
michael@0 | 726 | FILE* aFile = stdout, |
michael@0 | 727 | bool aDumpHtml = false); |
michael@0 | 728 | static void PrintDisplayListSet(nsDisplayListBuilder* aBuilder, |
michael@0 | 729 | const nsDisplayListSet& aList, |
michael@0 | 730 | FILE* aFile = stdout, |
michael@0 | 731 | bool aDumpHtml = false); |
michael@0 | 732 | |
michael@0 | 733 | #endif |
michael@0 | 734 | }; |
michael@0 | 735 | |
michael@0 | 736 | // Start Display Reflow Debugging |
michael@0 | 737 | #ifdef DEBUG |
michael@0 | 738 | |
michael@0 | 739 | struct DR_cookie { |
michael@0 | 740 | DR_cookie(nsPresContext* aPresContext, |
michael@0 | 741 | nsIFrame* aFrame, |
michael@0 | 742 | const nsHTMLReflowState& aReflowState, |
michael@0 | 743 | nsHTMLReflowMetrics& aMetrics, |
michael@0 | 744 | nsReflowStatus& aStatus); |
michael@0 | 745 | ~DR_cookie(); |
michael@0 | 746 | void Change() const; |
michael@0 | 747 | |
michael@0 | 748 | nsPresContext* mPresContext; |
michael@0 | 749 | nsIFrame* mFrame; |
michael@0 | 750 | const nsHTMLReflowState& mReflowState; |
michael@0 | 751 | nsHTMLReflowMetrics& mMetrics; |
michael@0 | 752 | nsReflowStatus& mStatus; |
michael@0 | 753 | void* mValue; |
michael@0 | 754 | }; |
michael@0 | 755 | |
michael@0 | 756 | struct DR_layout_cookie { |
michael@0 | 757 | DR_layout_cookie(nsIFrame* aFrame); |
michael@0 | 758 | ~DR_layout_cookie(); |
michael@0 | 759 | |
michael@0 | 760 | nsIFrame* mFrame; |
michael@0 | 761 | void* mValue; |
michael@0 | 762 | }; |
michael@0 | 763 | |
michael@0 | 764 | struct DR_intrinsic_width_cookie { |
michael@0 | 765 | DR_intrinsic_width_cookie(nsIFrame* aFrame, const char* aType, |
michael@0 | 766 | nscoord& aResult); |
michael@0 | 767 | ~DR_intrinsic_width_cookie(); |
michael@0 | 768 | |
michael@0 | 769 | nsIFrame* mFrame; |
michael@0 | 770 | const char* mType; |
michael@0 | 771 | nscoord& mResult; |
michael@0 | 772 | void* mValue; |
michael@0 | 773 | }; |
michael@0 | 774 | |
michael@0 | 775 | struct DR_intrinsic_size_cookie { |
michael@0 | 776 | DR_intrinsic_size_cookie(nsIFrame* aFrame, const char* aType, |
michael@0 | 777 | nsSize& aResult); |
michael@0 | 778 | ~DR_intrinsic_size_cookie(); |
michael@0 | 779 | |
michael@0 | 780 | nsIFrame* mFrame; |
michael@0 | 781 | const char* mType; |
michael@0 | 782 | nsSize& mResult; |
michael@0 | 783 | void* mValue; |
michael@0 | 784 | }; |
michael@0 | 785 | |
michael@0 | 786 | struct DR_init_constraints_cookie { |
michael@0 | 787 | DR_init_constraints_cookie(nsIFrame* aFrame, nsHTMLReflowState* aState, |
michael@0 | 788 | nscoord aCBWidth, nscoord aCBHeight, |
michael@0 | 789 | const nsMargin* aBorder, |
michael@0 | 790 | const nsMargin* aPadding); |
michael@0 | 791 | ~DR_init_constraints_cookie(); |
michael@0 | 792 | |
michael@0 | 793 | nsIFrame* mFrame; |
michael@0 | 794 | nsHTMLReflowState* mState; |
michael@0 | 795 | void* mValue; |
michael@0 | 796 | }; |
michael@0 | 797 | |
michael@0 | 798 | struct DR_init_offsets_cookie { |
michael@0 | 799 | DR_init_offsets_cookie(nsIFrame* aFrame, nsCSSOffsetState* aState, |
michael@0 | 800 | nscoord aHorizontalPercentBasis, |
michael@0 | 801 | nscoord aVerticalPercentBasis, |
michael@0 | 802 | const nsMargin* aBorder, |
michael@0 | 803 | const nsMargin* aPadding); |
michael@0 | 804 | ~DR_init_offsets_cookie(); |
michael@0 | 805 | |
michael@0 | 806 | nsIFrame* mFrame; |
michael@0 | 807 | nsCSSOffsetState* mState; |
michael@0 | 808 | void* mValue; |
michael@0 | 809 | }; |
michael@0 | 810 | |
michael@0 | 811 | struct DR_init_type_cookie { |
michael@0 | 812 | DR_init_type_cookie(nsIFrame* aFrame, nsHTMLReflowState* aState); |
michael@0 | 813 | ~DR_init_type_cookie(); |
michael@0 | 814 | |
michael@0 | 815 | nsIFrame* mFrame; |
michael@0 | 816 | nsHTMLReflowState* mState; |
michael@0 | 817 | void* mValue; |
michael@0 | 818 | }; |
michael@0 | 819 | |
michael@0 | 820 | #define DISPLAY_REFLOW(dr_pres_context, dr_frame, dr_rf_state, dr_rf_metrics, dr_rf_status) \ |
michael@0 | 821 | DR_cookie dr_cookie(dr_pres_context, dr_frame, dr_rf_state, dr_rf_metrics, dr_rf_status); |
michael@0 | 822 | #define DISPLAY_REFLOW_CHANGE() \ |
michael@0 | 823 | dr_cookie.Change(); |
michael@0 | 824 | #define DISPLAY_LAYOUT(dr_frame) \ |
michael@0 | 825 | DR_layout_cookie dr_cookie(dr_frame); |
michael@0 | 826 | #define DISPLAY_MIN_WIDTH(dr_frame, dr_result) \ |
michael@0 | 827 | DR_intrinsic_width_cookie dr_cookie(dr_frame, "Min", dr_result) |
michael@0 | 828 | #define DISPLAY_PREF_WIDTH(dr_frame, dr_result) \ |
michael@0 | 829 | DR_intrinsic_width_cookie dr_cookie(dr_frame, "Pref", dr_result) |
michael@0 | 830 | #define DISPLAY_PREF_SIZE(dr_frame, dr_result) \ |
michael@0 | 831 | DR_intrinsic_size_cookie dr_cookie(dr_frame, "Pref", dr_result) |
michael@0 | 832 | #define DISPLAY_MIN_SIZE(dr_frame, dr_result) \ |
michael@0 | 833 | DR_intrinsic_size_cookie dr_cookie(dr_frame, "Min", dr_result) |
michael@0 | 834 | #define DISPLAY_MAX_SIZE(dr_frame, dr_result) \ |
michael@0 | 835 | DR_intrinsic_size_cookie dr_cookie(dr_frame, "Max", dr_result) |
michael@0 | 836 | #define DISPLAY_INIT_CONSTRAINTS(dr_frame, dr_state, dr_cbw, dr_cbh, \ |
michael@0 | 837 | dr_bdr, dr_pad) \ |
michael@0 | 838 | DR_init_constraints_cookie dr_cookie(dr_frame, dr_state, dr_cbw, dr_cbh, \ |
michael@0 | 839 | dr_bdr, dr_pad) |
michael@0 | 840 | #define DISPLAY_INIT_OFFSETS(dr_frame, dr_state, dr_hpb, dr_vpb, dr_bdr, dr_pad) \ |
michael@0 | 841 | DR_init_offsets_cookie dr_cookie(dr_frame, dr_state, dr_hpb, dr_vpb, dr_bdr, dr_pad) |
michael@0 | 842 | #define DISPLAY_INIT_TYPE(dr_frame, dr_result) \ |
michael@0 | 843 | DR_init_type_cookie dr_cookie(dr_frame, dr_result) |
michael@0 | 844 | |
michael@0 | 845 | #else |
michael@0 | 846 | |
michael@0 | 847 | #define DISPLAY_REFLOW(dr_pres_context, dr_frame, dr_rf_state, dr_rf_metrics, dr_rf_status) |
michael@0 | 848 | #define DISPLAY_REFLOW_CHANGE() |
michael@0 | 849 | #define DISPLAY_LAYOUT(dr_frame) PR_BEGIN_MACRO PR_END_MACRO |
michael@0 | 850 | #define DISPLAY_MIN_WIDTH(dr_frame, dr_result) PR_BEGIN_MACRO PR_END_MACRO |
michael@0 | 851 | #define DISPLAY_PREF_WIDTH(dr_frame, dr_result) PR_BEGIN_MACRO PR_END_MACRO |
michael@0 | 852 | #define DISPLAY_PREF_SIZE(dr_frame, dr_result) PR_BEGIN_MACRO PR_END_MACRO |
michael@0 | 853 | #define DISPLAY_MIN_SIZE(dr_frame, dr_result) PR_BEGIN_MACRO PR_END_MACRO |
michael@0 | 854 | #define DISPLAY_MAX_SIZE(dr_frame, dr_result) PR_BEGIN_MACRO PR_END_MACRO |
michael@0 | 855 | #define DISPLAY_INIT_CONSTRAINTS(dr_frame, dr_state, dr_cbw, dr_cbh, \ |
michael@0 | 856 | dr_bdr, dr_pad) \ |
michael@0 | 857 | PR_BEGIN_MACRO PR_END_MACRO |
michael@0 | 858 | #define DISPLAY_INIT_OFFSETS(dr_frame, dr_state, dr_hpb, dr_vpb, dr_bdr, dr_pad) \ |
michael@0 | 859 | PR_BEGIN_MACRO PR_END_MACRO |
michael@0 | 860 | #define DISPLAY_INIT_TYPE(dr_frame, dr_result) PR_BEGIN_MACRO PR_END_MACRO |
michael@0 | 861 | |
michael@0 | 862 | #endif |
michael@0 | 863 | // End Display Reflow Debugging |
michael@0 | 864 | |
michael@0 | 865 | // similar to NS_ENSURE_TRUE but with no return value |
michael@0 | 866 | #define ENSURE_TRUE(x) \ |
michael@0 | 867 | PR_BEGIN_MACRO \ |
michael@0 | 868 | if (!(x)) { \ |
michael@0 | 869 | NS_WARNING("ENSURE_TRUE(" #x ") failed"); \ |
michael@0 | 870 | return; \ |
michael@0 | 871 | } \ |
michael@0 | 872 | PR_END_MACRO |
michael@0 | 873 | #endif /* nsFrame_h___ */ |