1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* ***** BEGIN LICENSE BLOCK *****
3 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 : *
5 : * The contents of this file are subject to the Mozilla Public License Version
6 : * 1.1 (the "License"); you may not use this file except in compliance with
7 : * the License. You may obtain a copy of the License at
8 : * http://www.mozilla.org/MPL/
9 : *
10 : * Software distributed under the License is distributed on an "AS IS" basis,
11 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 : * for the specific language governing rights and limitations under the
13 : * License.
14 : *
15 : * The Original Code is mozilla.org code.
16 : *
17 : * The Initial Developer of the Original Code is
18 : * Netscape Communications Corporation.
19 : * Portions created by the Initial Developer are Copyright (C) 1998
20 : * the Initial Developer. All Rights Reserved.
21 : *
22 : * Contributor(s):
23 : *
24 : * Alternatively, the contents of this file may be used under the terms of
25 : * either of the GNU General Public License Version 2 or later (the "GPL"),
26 : * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 : * in which case the provisions of the GPL or the LGPL are applicable instead
28 : * of those above. If you wish to allow use of your version of this file only
29 : * under the terms of either the GPL or the LGPL, and not to allow others to
30 : * use your version of this file under the terms of the MPL, indicate your
31 : * decision by deleting the provisions above and replace them with the notice
32 : * and other provisions required by the GPL or the LGPL. If you do not delete
33 : * the provisions above, a recipient may use your version of this file under
34 : * the terms of any one of the MPL, the GPL or the LGPL.
35 : *
36 : * ***** END LICENSE BLOCK ***** */
37 :
38 : /*
39 : * code for managing absolutely positioned children of a rendering
40 : * object that is a containing block for them
41 : */
42 :
43 : #include "nsCOMPtr.h"
44 : #include "nsAbsoluteContainingBlock.h"
45 : #include "nsContainerFrame.h"
46 : #include "nsIPresShell.h"
47 : #include "nsHTMLParts.h"
48 : #include "nsPresContext.h"
49 : #include "nsFrameManager.h"
50 : #include "nsCSSFrameConstructor.h"
51 :
52 : #ifdef DEBUG
53 : #include "nsBlockFrame.h"
54 : #endif
55 :
56 : nsresult
57 0 : nsAbsoluteContainingBlock::SetInitialChildList(nsIFrame* aDelegatingFrame,
58 : ChildListID aListID,
59 : nsFrameList& aChildList)
60 : {
61 0 : NS_PRECONDITION(GetChildListID() == aListID, "unexpected child list name");
62 : #ifdef NS_DEBUG
63 0 : nsFrame::VerifyDirtyBitSet(aChildList);
64 : #endif
65 0 : mAbsoluteFrames.SetFrames(aChildList);
66 0 : return NS_OK;
67 : }
68 :
69 : nsresult
70 0 : nsAbsoluteContainingBlock::AppendFrames(nsIFrame* aDelegatingFrame,
71 : ChildListID aListID,
72 : nsFrameList& aFrameList)
73 : {
74 0 : NS_ASSERTION(GetChildListID() == aListID, "unexpected child list");
75 :
76 : // Append the frames to our list of absolutely positioned frames
77 : #ifdef NS_DEBUG
78 0 : nsFrame::VerifyDirtyBitSet(aFrameList);
79 : #endif
80 0 : mAbsoluteFrames.AppendFrames(nsnull, aFrameList);
81 :
82 : // no damage to intrinsic widths, since absolutely positioned frames can't
83 : // change them
84 0 : aDelegatingFrame->PresContext()->PresShell()->
85 : FrameNeedsReflow(aDelegatingFrame, nsIPresShell::eResize,
86 0 : NS_FRAME_HAS_DIRTY_CHILDREN);
87 :
88 0 : return NS_OK;
89 : }
90 :
91 : nsresult
92 0 : nsAbsoluteContainingBlock::InsertFrames(nsIFrame* aDelegatingFrame,
93 : ChildListID aListID,
94 : nsIFrame* aPrevFrame,
95 : nsFrameList& aFrameList)
96 : {
97 0 : NS_ASSERTION(GetChildListID() == aListID, "unexpected child list");
98 0 : NS_ASSERTION(!aPrevFrame || aPrevFrame->GetParent() == aDelegatingFrame,
99 : "inserting after sibling frame with different parent");
100 :
101 : #ifdef NS_DEBUG
102 0 : nsFrame::VerifyDirtyBitSet(aFrameList);
103 : #endif
104 0 : mAbsoluteFrames.InsertFrames(nsnull, aPrevFrame, aFrameList);
105 :
106 : // no damage to intrinsic widths, since absolutely positioned frames can't
107 : // change them
108 0 : aDelegatingFrame->PresContext()->PresShell()->
109 : FrameNeedsReflow(aDelegatingFrame, nsIPresShell::eResize,
110 0 : NS_FRAME_HAS_DIRTY_CHILDREN);
111 :
112 0 : return NS_OK;
113 : }
114 :
115 : void
116 0 : nsAbsoluteContainingBlock::RemoveFrame(nsIFrame* aDelegatingFrame,
117 : ChildListID aListID,
118 : nsIFrame* aOldFrame)
119 : {
120 0 : NS_ASSERTION(GetChildListID() == aListID, "unexpected child list");
121 0 : nsIFrame* nif = aOldFrame->GetNextInFlow();
122 0 : if (nif) {
123 0 : static_cast<nsContainerFrame*>(nif->GetParent())
124 0 : ->DeleteNextInFlowChild(aOldFrame->PresContext(), nif, false);
125 : }
126 :
127 0 : mAbsoluteFrames.DestroyFrame(aOldFrame);
128 0 : }
129 :
130 : nsresult
131 0 : nsAbsoluteContainingBlock::Reflow(nsContainerFrame* aDelegatingFrame,
132 : nsPresContext* aPresContext,
133 : const nsHTMLReflowState& aReflowState,
134 : nsReflowStatus& aReflowStatus,
135 : nscoord aContainingBlockWidth,
136 : nscoord aContainingBlockHeight,
137 : bool aConstrainHeight,
138 : bool aCBWidthChanged,
139 : bool aCBHeightChanged,
140 : nsOverflowAreas* aOverflowAreas)
141 : {
142 0 : nsReflowStatus reflowStatus = NS_FRAME_COMPLETE;
143 :
144 0 : bool reflowAll = aReflowState.ShouldReflowAllKids();
145 :
146 : nsIFrame* kidFrame;
147 0 : nsOverflowContinuationTracker tracker(aPresContext, aDelegatingFrame, true);
148 0 : for (kidFrame = mAbsoluteFrames.FirstChild(); kidFrame; kidFrame = kidFrame->GetNextSibling()) {
149 0 : bool kidNeedsReflow = reflowAll || NS_SUBTREE_DIRTY(kidFrame) ||
150 0 : FrameDependsOnContainer(kidFrame, aCBWidthChanged, aCBHeightChanged);
151 0 : if (kidNeedsReflow && !aPresContext->HasPendingInterrupt()) {
152 : // Reflow the frame
153 0 : nsReflowStatus kidStatus = NS_FRAME_COMPLETE;
154 : ReflowAbsoluteFrame(aDelegatingFrame, aPresContext, aReflowState,
155 : aContainingBlockWidth, aContainingBlockHeight,
156 : aConstrainHeight, kidFrame, kidStatus,
157 0 : aOverflowAreas);
158 0 : nsIFrame* nextFrame = kidFrame->GetNextInFlow();
159 0 : if (!NS_FRAME_IS_FULLY_COMPLETE(kidStatus)) {
160 : // Need a continuation
161 0 : if (!nextFrame) {
162 : nsresult rv = aPresContext->PresShell()->FrameConstructor()->
163 0 : CreateContinuingFrame(aPresContext, kidFrame, aDelegatingFrame, &nextFrame);
164 0 : NS_ENSURE_SUCCESS(rv, rv);
165 : }
166 : // Add it as an overflow container.
167 : //XXXfr This is a hack to fix some of our printing dataloss.
168 : // See bug 154892. Not sure how to do it "right" yet; probably want
169 : // to keep continuations within an nsAbsoluteContainingBlock eventually.
170 0 : tracker.Insert(nextFrame, kidStatus);
171 0 : NS_MergeReflowStatusInto(&reflowStatus, kidStatus);
172 : }
173 : else {
174 : // Delete any continuations
175 0 : if (nextFrame) {
176 0 : tracker.Finish(kidFrame);
177 0 : static_cast<nsContainerFrame*>(nextFrame->GetParent())
178 0 : ->DeleteNextInFlowChild(aPresContext, nextFrame, true);
179 : }
180 : }
181 : }
182 : else {
183 0 : tracker.Skip(kidFrame, reflowStatus);
184 0 : if (aOverflowAreas) {
185 0 : aDelegatingFrame->ConsiderChildOverflow(*aOverflowAreas, kidFrame);
186 : }
187 : }
188 :
189 : // Make a CheckForInterrupt call, here, not just HasPendingInterrupt. That
190 : // will make sure that we end up reflowing aDelegatingFrame in cases when
191 : // one of our kids interrupted. Otherwise we'd set the dirty or
192 : // dirty-children bit on the kid in the condition below, and then when
193 : // reflow completes and we go to mark dirty bits on all ancestors of that
194 : // kid we'll immediately bail out, because the kid already has a dirty bit.
195 : // In particular, we won't set any dirty bits on aDelegatingFrame, so when
196 : // the following reflow happens we won't reflow the kid in question. This
197 : // might be slightly suboptimal in cases where |kidFrame| itself did not
198 : // interrupt, since we'll trigger a reflow of it too when it's not strictly
199 : // needed. But the logic to not do that is enough more complicated, and
200 : // the case enough of an edge case, that this is probably better.
201 0 : if (kidNeedsReflow && aPresContext->CheckForInterrupt(aDelegatingFrame)) {
202 0 : if (aDelegatingFrame->GetStateBits() & NS_FRAME_IS_DIRTY) {
203 0 : kidFrame->AddStateBits(NS_FRAME_IS_DIRTY);
204 : } else {
205 0 : kidFrame->AddStateBits(NS_FRAME_HAS_DIRTY_CHILDREN);
206 : }
207 : }
208 : }
209 :
210 : // Abspos frames can't cause their parent to be incomplete,
211 : // only overflow incomplete.
212 0 : if (NS_FRAME_IS_NOT_COMPLETE(reflowStatus))
213 0 : NS_FRAME_SET_OVERFLOW_INCOMPLETE(reflowStatus);
214 :
215 0 : NS_MergeReflowStatusInto(&aReflowStatus, reflowStatus);
216 0 : return NS_OK;
217 : }
218 :
219 0 : static inline bool IsFixedPaddingSize(const nsStyleCoord& aCoord)
220 0 : { return aCoord.ConvertsToLength(); }
221 0 : static inline bool IsFixedMarginSize(const nsStyleCoord& aCoord)
222 0 : { return aCoord.ConvertsToLength(); }
223 0 : static inline bool IsFixedOffset(const nsStyleCoord& aCoord)
224 0 : { return aCoord.ConvertsToLength(); }
225 :
226 : bool
227 0 : nsAbsoluteContainingBlock::FrameDependsOnContainer(nsIFrame* f,
228 : bool aCBWidthChanged,
229 : bool aCBHeightChanged)
230 : {
231 0 : const nsStylePosition* pos = f->GetStylePosition();
232 : // See if f's position might have changed because it depends on a
233 : // placeholder's position
234 : // This can happen in the following cases:
235 : // 1) Vertical positioning. "top" must be auto and "bottom" must be auto
236 : // (otherwise the vertical position is completely determined by
237 : // whichever of them is not auto and the height).
238 : // 2) Horizontal positioning. "left" must be auto and "right" must be auto
239 : // (otherwise the horizontal position is completely determined by
240 : // whichever of them is not auto and the width).
241 : // See nsHTMLReflowState::InitAbsoluteConstraints -- these are the
242 : // only cases when we call CalculateHypotheticalBox().
243 0 : if ((pos->mOffset.GetTopUnit() == eStyleUnit_Auto &&
244 0 : pos->mOffset.GetBottomUnit() == eStyleUnit_Auto) ||
245 0 : (pos->mOffset.GetLeftUnit() == eStyleUnit_Auto &&
246 0 : pos->mOffset.GetRightUnit() == eStyleUnit_Auto)) {
247 0 : return true;
248 : }
249 0 : if (!aCBWidthChanged && !aCBHeightChanged) {
250 : // skip getting style data
251 0 : return false;
252 : }
253 0 : const nsStylePadding* padding = f->GetStylePadding();
254 0 : const nsStyleMargin* margin = f->GetStyleMargin();
255 0 : if (aCBWidthChanged) {
256 : // See if f's width might have changed.
257 : // If border-left, border-right, padding-left, padding-right,
258 : // width, min-width, and max-width are all lengths, 'none', or enumerated,
259 : // then our frame width does not depend on the parent width.
260 : // Note that borders never depend on the parent width
261 : // XXX All of the enumerated values except -moz-available are ok too.
262 0 : if (pos->WidthDependsOnContainer() ||
263 0 : pos->MinWidthDependsOnContainer() ||
264 0 : pos->MaxWidthDependsOnContainer() ||
265 0 : !IsFixedPaddingSize(padding->mPadding.GetLeft()) ||
266 0 : !IsFixedPaddingSize(padding->mPadding.GetRight())) {
267 0 : return true;
268 : }
269 :
270 : // See if f's position might have changed. If we're RTL then the
271 : // rules are slightly different. We'll assume percentage or auto
272 : // margins will always induce a dependency on the size
273 0 : if (!IsFixedMarginSize(margin->mMargin.GetLeft()) ||
274 0 : !IsFixedMarginSize(margin->mMargin.GetRight())) {
275 0 : return true;
276 : }
277 0 : if (f->GetStyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL) {
278 : // Note that even if 'left' is a length, our position can
279 : // still depend on the containing block width, because if
280 : // 'right' is also a length we will discard 'left' and be
281 : // positioned relative to the containing block right edge.
282 : // 'left' length and 'right' auto is the only combination
283 : // we can be sure of.
284 0 : if (!IsFixedOffset(pos->mOffset.GetLeft()) ||
285 0 : pos->mOffset.GetRightUnit() != eStyleUnit_Auto) {
286 0 : return true;
287 : }
288 : } else {
289 0 : if (!IsFixedOffset(pos->mOffset.GetLeft())) {
290 0 : return true;
291 : }
292 : }
293 : }
294 0 : if (aCBHeightChanged) {
295 : // See if f's height might have changed.
296 : // If border-top, border-bottom, padding-top, padding-bottom,
297 : // min-height, and max-height are all lengths or 'none',
298 : // and height is a length or height and bottom are auto and top is not auto,
299 : // then our frame height does not depend on the parent height.
300 : // Note that borders never depend on the parent height
301 0 : if ((pos->HeightDependsOnContainer() &&
302 0 : !(pos->mHeight.GetUnit() == eStyleUnit_Auto &&
303 0 : pos->mOffset.GetBottomUnit() == eStyleUnit_Auto &&
304 0 : pos->mOffset.GetTopUnit() != eStyleUnit_Auto)) ||
305 0 : pos->MinHeightDependsOnContainer() ||
306 0 : pos->MaxHeightDependsOnContainer() ||
307 0 : !IsFixedPaddingSize(padding->mPadding.GetTop()) ||
308 0 : !IsFixedPaddingSize(padding->mPadding.GetBottom())) {
309 0 : return true;
310 : }
311 :
312 : // See if f's position might have changed.
313 0 : if (!IsFixedMarginSize(margin->mMargin.GetTop()) ||
314 0 : !IsFixedMarginSize(margin->mMargin.GetBottom())) {
315 0 : return true;
316 : }
317 0 : if (!IsFixedOffset(pos->mOffset.GetTop())) {
318 0 : return true;
319 : }
320 : }
321 0 : return false;
322 : }
323 :
324 : void
325 0 : nsAbsoluteContainingBlock::DestroyFrames(nsIFrame* aDelegatingFrame,
326 : nsIFrame* aDestructRoot)
327 : {
328 0 : mAbsoluteFrames.DestroyFramesFrom(aDestructRoot);
329 0 : }
330 :
331 : void
332 0 : nsAbsoluteContainingBlock::MarkSizeDependentFramesDirty()
333 : {
334 0 : DoMarkFramesDirty(false);
335 0 : }
336 :
337 : void
338 0 : nsAbsoluteContainingBlock::MarkAllFramesDirty()
339 : {
340 0 : DoMarkFramesDirty(true);
341 0 : }
342 :
343 : void
344 0 : nsAbsoluteContainingBlock::DoMarkFramesDirty(bool aMarkAllDirty)
345 : {
346 0 : for (nsIFrame* kidFrame = mAbsoluteFrames.FirstChild();
347 : kidFrame;
348 : kidFrame = kidFrame->GetNextSibling()) {
349 0 : if (aMarkAllDirty) {
350 0 : kidFrame->AddStateBits(NS_FRAME_IS_DIRTY);
351 0 : } else if (FrameDependsOnContainer(kidFrame, true, true)) {
352 : // Add the weakest flags that will make sure we reflow this frame later
353 0 : kidFrame->AddStateBits(NS_FRAME_HAS_DIRTY_CHILDREN);
354 : }
355 : }
356 0 : }
357 :
358 : // XXX Optimize the case where it's a resize reflow and the absolutely
359 : // positioned child has the exact same size and position and skip the
360 : // reflow...
361 :
362 : // When bug 154892 is checked in, make sure that when
363 : // GetChildListID() == kFixedList, the height is unconstrained.
364 : // since we don't allow replicated frames to split.
365 :
366 : nsresult
367 0 : nsAbsoluteContainingBlock::ReflowAbsoluteFrame(nsIFrame* aDelegatingFrame,
368 : nsPresContext* aPresContext,
369 : const nsHTMLReflowState& aReflowState,
370 : nscoord aContainingBlockWidth,
371 : nscoord aContainingBlockHeight,
372 : bool aConstrainHeight,
373 : nsIFrame* aKidFrame,
374 : nsReflowStatus& aStatus,
375 : nsOverflowAreas* aOverflowAreas)
376 : {
377 : #ifdef DEBUG
378 0 : if (nsBlockFrame::gNoisyReflow) {
379 0 : nsFrame::IndentBy(stdout,nsBlockFrame::gNoiseIndent);
380 0 : printf("abs pos ");
381 0 : if (aKidFrame) {
382 0 : nsAutoString name;
383 0 : aKidFrame->GetFrameName(name);
384 0 : printf("%s ", NS_LossyConvertUTF16toASCII(name).get());
385 : }
386 :
387 : char width[16];
388 : char height[16];
389 0 : PrettyUC(aReflowState.availableWidth, width);
390 0 : PrettyUC(aReflowState.availableHeight, height);
391 0 : printf(" a=%s,%s ", width, height);
392 0 : PrettyUC(aReflowState.ComputedWidth(), width);
393 0 : PrettyUC(aReflowState.ComputedHeight(), height);
394 0 : printf("c=%s,%s \n", width, height);
395 : }
396 0 : AutoNoisyIndenter indent(nsBlockFrame::gNoisy);
397 : #endif // DEBUG
398 :
399 : // Store position and overflow rect so taht we can invalidate the correct
400 : // area if the position changes
401 0 : nsRect oldOverflowRect(aKidFrame->GetVisualOverflowRect() +
402 0 : aKidFrame->GetPosition());
403 0 : nsRect oldRect = aKidFrame->GetRect();
404 :
405 : nsresult rv;
406 : // Get the border values
407 0 : const nsMargin& border = aReflowState.mStyleBorder->GetActualBorder();
408 :
409 0 : nscoord availWidth = aContainingBlockWidth;
410 0 : if (availWidth == -1) {
411 0 : NS_ASSERTION(aReflowState.ComputedWidth() != NS_UNCONSTRAINEDSIZE,
412 : "Must have a useful width _somewhere_");
413 : availWidth =
414 0 : aReflowState.ComputedWidth() + aReflowState.mComputedPadding.LeftRight();
415 : }
416 :
417 0 : nsHTMLReflowMetrics kidDesiredSize;
418 : nsHTMLReflowState kidReflowState(aPresContext, aReflowState, aKidFrame,
419 : nsSize(availWidth, NS_UNCONSTRAINEDSIZE),
420 : aContainingBlockWidth,
421 0 : aContainingBlockHeight);
422 :
423 : // Send the WillReflow() notification and position the frame
424 0 : aKidFrame->WillReflow(aPresContext);
425 :
426 : bool constrainHeight = (aReflowState.availableHeight != NS_UNCONSTRAINEDSIZE)
427 : && aConstrainHeight
428 : // Don't split if told not to (e.g. for fixed frames)
429 0 : && (aDelegatingFrame->GetType() != nsGkAtoms::inlineFrame)
430 : //XXX we don't handle splitting frames for inline absolute containing blocks yet
431 0 : && (aKidFrame->GetRect().y <= aReflowState.availableHeight);
432 : // Don't split things below the fold. (Ideally we shouldn't *have*
433 : // anything totally below the fold, but we can't position frames
434 : // across next-in-flow breaks yet.
435 0 : if (constrainHeight) {
436 : kidReflowState.availableHeight = aReflowState.availableHeight - border.top
437 0 : - kidReflowState.mComputedMargin.top;
438 0 : if (NS_AUTOOFFSET != kidReflowState.mComputedOffsets.top)
439 0 : kidReflowState.availableHeight -= kidReflowState.mComputedOffsets.top;
440 : }
441 :
442 : // Do the reflow
443 0 : rv = aKidFrame->Reflow(aPresContext, kidDesiredSize, kidReflowState, aStatus);
444 :
445 : // If we're solving for 'left' or 'top', then compute it now that we know the
446 : // width/height
447 0 : if ((NS_AUTOOFFSET == kidReflowState.mComputedOffsets.left) ||
448 : (NS_AUTOOFFSET == kidReflowState.mComputedOffsets.top)) {
449 0 : if (-1 == aContainingBlockWidth) {
450 : // Get the containing block width/height
451 : kidReflowState.ComputeContainingBlockRectangle(aPresContext,
452 : &aReflowState,
453 : aContainingBlockWidth,
454 0 : aContainingBlockHeight);
455 : }
456 :
457 0 : if (NS_AUTOOFFSET == kidReflowState.mComputedOffsets.left) {
458 0 : NS_ASSERTION(NS_AUTOOFFSET != kidReflowState.mComputedOffsets.right,
459 : "Can't solve for both left and right");
460 : kidReflowState.mComputedOffsets.left = aContainingBlockWidth -
461 : kidReflowState.mComputedOffsets.right -
462 : kidReflowState.mComputedMargin.right -
463 : kidDesiredSize.width -
464 0 : kidReflowState.mComputedMargin.left;
465 : }
466 0 : if (NS_AUTOOFFSET == kidReflowState.mComputedOffsets.top) {
467 : kidReflowState.mComputedOffsets.top = aContainingBlockHeight -
468 : kidReflowState.mComputedOffsets.bottom -
469 : kidReflowState.mComputedMargin.bottom -
470 : kidDesiredSize.height -
471 0 : kidReflowState.mComputedMargin.top;
472 : }
473 : }
474 :
475 : // Position the child relative to our padding edge
476 : nsRect rect(border.left + kidReflowState.mComputedOffsets.left + kidReflowState.mComputedMargin.left,
477 : border.top + kidReflowState.mComputedOffsets.top + kidReflowState.mComputedMargin.top,
478 0 : kidDesiredSize.width, kidDesiredSize.height);
479 0 : aKidFrame->SetRect(rect);
480 :
481 0 : nsIView* view = aKidFrame->GetView();
482 0 : if (view) {
483 : // Size and position the view and set its opacity, visibility, content
484 : // transparency, and clip
485 : nsContainerFrame::SyncFrameViewAfterReflow(aPresContext, aKidFrame, view,
486 0 : kidDesiredSize.VisualOverflow());
487 : } else {
488 0 : nsContainerFrame::PositionChildViews(aKidFrame);
489 : }
490 :
491 0 : if (oldRect.TopLeft() != rect.TopLeft() ||
492 0 : (aDelegatingFrame->GetStateBits() & NS_FRAME_FIRST_REFLOW)) {
493 : // The frame moved
494 0 : aKidFrame->GetParent()->Invalidate(oldOverflowRect);
495 0 : aKidFrame->InvalidateFrameSubtree();
496 0 : } else if (oldRect.Size() != rect.Size()) {
497 : // Invalidate the area where the frame changed size.
498 0 : nscoord innerWidth = NS_MIN(oldRect.width, rect.width);
499 0 : nscoord innerHeight = NS_MIN(oldRect.height, rect.height);
500 0 : nscoord outerWidth = NS_MAX(oldRect.width, rect.width);
501 0 : nscoord outerHeight = NS_MAX(oldRect.height, rect.height);
502 : aKidFrame->GetParent()->Invalidate(
503 0 : nsRect(rect.x + innerWidth, rect.y, outerWidth - innerWidth, outerHeight));
504 : // Invalidate the horizontal strip
505 : aKidFrame->GetParent()->Invalidate(
506 0 : nsRect(rect.x, rect.y + innerHeight, outerWidth, outerHeight - innerHeight));
507 : }
508 0 : aKidFrame->DidReflow(aPresContext, &kidReflowState, NS_FRAME_REFLOW_FINISHED);
509 :
510 : #ifdef DEBUG
511 0 : if (nsBlockFrame::gNoisyReflow) {
512 0 : nsFrame::IndentBy(stdout,nsBlockFrame::gNoiseIndent - 1);
513 0 : printf("abs pos ");
514 0 : if (aKidFrame) {
515 0 : nsAutoString name;
516 0 : aKidFrame->GetFrameName(name);
517 0 : printf("%s ", NS_LossyConvertUTF16toASCII(name).get());
518 : }
519 : printf("%p rect=%d,%d,%d,%d\n", static_cast<void*>(aKidFrame),
520 0 : rect.x, rect.y, rect.width, rect.height);
521 : }
522 : #endif
523 :
524 0 : if (aOverflowAreas) {
525 0 : aOverflowAreas->UnionWith(kidDesiredSize.mOverflowAreas + rect.TopLeft());
526 : }
527 :
528 0 : return rv;
529 : }
530 :
531 : #ifdef DEBUG
532 0 : void nsAbsoluteContainingBlock::PrettyUC(nscoord aSize,
533 : char* aBuf)
534 : {
535 0 : if (NS_UNCONSTRAINEDSIZE == aSize) {
536 0 : strcpy(aBuf, "UC");
537 : }
538 : else {
539 0 : if((PRInt32)0xdeadbeef == aSize)
540 : {
541 0 : strcpy(aBuf, "deadbeef");
542 : }
543 : else {
544 0 : sprintf(aBuf, "%d", aSize);
545 : }
546 : }
547 0 : }
548 : #endif
|