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 for rendering objects that do not have child lists */ |
michael@0 | 7 | |
michael@0 | 8 | #include "nsLeafFrame.h" |
michael@0 | 9 | #include "nsPresContext.h" |
michael@0 | 10 | |
michael@0 | 11 | nsLeafFrame::~nsLeafFrame() |
michael@0 | 12 | { |
michael@0 | 13 | } |
michael@0 | 14 | |
michael@0 | 15 | NS_IMPL_FRAMEARENA_HELPERS(nsLeafFrame) |
michael@0 | 16 | |
michael@0 | 17 | /* virtual */ nscoord |
michael@0 | 18 | nsLeafFrame::GetMinWidth(nsRenderingContext *aRenderingContext) |
michael@0 | 19 | { |
michael@0 | 20 | nscoord result; |
michael@0 | 21 | DISPLAY_MIN_WIDTH(this, result); |
michael@0 | 22 | |
michael@0 | 23 | result = GetIntrinsicWidth(); |
michael@0 | 24 | return result; |
michael@0 | 25 | } |
michael@0 | 26 | |
michael@0 | 27 | /* virtual */ nscoord |
michael@0 | 28 | nsLeafFrame::GetPrefWidth(nsRenderingContext *aRenderingContext) |
michael@0 | 29 | { |
michael@0 | 30 | nscoord result; |
michael@0 | 31 | DISPLAY_PREF_WIDTH(this, result); |
michael@0 | 32 | result = GetIntrinsicWidth(); |
michael@0 | 33 | return result; |
michael@0 | 34 | } |
michael@0 | 35 | |
michael@0 | 36 | /* virtual */ nsSize |
michael@0 | 37 | nsLeafFrame::ComputeAutoSize(nsRenderingContext *aRenderingContext, |
michael@0 | 38 | nsSize aCBSize, nscoord aAvailableWidth, |
michael@0 | 39 | nsSize aMargin, nsSize aBorder, |
michael@0 | 40 | nsSize aPadding, bool aShrinkWrap) |
michael@0 | 41 | { |
michael@0 | 42 | return nsSize(GetIntrinsicWidth(), GetIntrinsicHeight()); |
michael@0 | 43 | } |
michael@0 | 44 | |
michael@0 | 45 | nsresult |
michael@0 | 46 | nsLeafFrame::Reflow(nsPresContext* aPresContext, |
michael@0 | 47 | nsHTMLReflowMetrics& aMetrics, |
michael@0 | 48 | const nsHTMLReflowState& aReflowState, |
michael@0 | 49 | nsReflowStatus& aStatus) |
michael@0 | 50 | { |
michael@0 | 51 | DO_GLOBAL_REFLOW_COUNT("nsLeafFrame"); |
michael@0 | 52 | NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS, |
michael@0 | 53 | ("enter nsLeafFrame::Reflow: aMaxSize=%d,%d", |
michael@0 | 54 | aReflowState.AvailableWidth(), aReflowState.AvailableHeight())); |
michael@0 | 55 | |
michael@0 | 56 | NS_PRECONDITION(mState & NS_FRAME_IN_REFLOW, "frame is not in reflow"); |
michael@0 | 57 | |
michael@0 | 58 | DoReflow(aPresContext, aMetrics, aReflowState, aStatus); |
michael@0 | 59 | |
michael@0 | 60 | FinishAndStoreOverflow(&aMetrics); |
michael@0 | 61 | return NS_OK; |
michael@0 | 62 | } |
michael@0 | 63 | |
michael@0 | 64 | nsresult |
michael@0 | 65 | nsLeafFrame::DoReflow(nsPresContext* aPresContext, |
michael@0 | 66 | nsHTMLReflowMetrics& aMetrics, |
michael@0 | 67 | const nsHTMLReflowState& aReflowState, |
michael@0 | 68 | nsReflowStatus& aStatus) |
michael@0 | 69 | { |
michael@0 | 70 | NS_ASSERTION(aReflowState.ComputedWidth() != NS_UNCONSTRAINEDSIZE, |
michael@0 | 71 | "Shouldn't have unconstrained stuff here " |
michael@0 | 72 | "Thanks to the rules of reflow"); |
michael@0 | 73 | NS_ASSERTION(NS_INTRINSICSIZE != aReflowState.ComputedHeight(), |
michael@0 | 74 | "Shouldn't have unconstrained stuff here " |
michael@0 | 75 | "thanks to ComputeAutoSize"); |
michael@0 | 76 | |
michael@0 | 77 | aMetrics.Width() = aReflowState.ComputedWidth(); |
michael@0 | 78 | aMetrics.Height() = aReflowState.ComputedHeight(); |
michael@0 | 79 | |
michael@0 | 80 | AddBordersAndPadding(aReflowState, aMetrics); |
michael@0 | 81 | aStatus = NS_FRAME_COMPLETE; |
michael@0 | 82 | |
michael@0 | 83 | NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS, |
michael@0 | 84 | ("exit nsLeafFrame::DoReflow: size=%d,%d", |
michael@0 | 85 | aMetrics.Width(), aMetrics.Height())); |
michael@0 | 86 | NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aMetrics); |
michael@0 | 87 | |
michael@0 | 88 | aMetrics.SetOverflowAreasToDesiredBounds(); |
michael@0 | 89 | |
michael@0 | 90 | return NS_OK; |
michael@0 | 91 | } |
michael@0 | 92 | |
michael@0 | 93 | nscoord |
michael@0 | 94 | nsLeafFrame::GetIntrinsicHeight() |
michael@0 | 95 | { |
michael@0 | 96 | NS_NOTREACHED("Someone didn't override Reflow or ComputeAutoSize"); |
michael@0 | 97 | return 0; |
michael@0 | 98 | } |
michael@0 | 99 | |
michael@0 | 100 | // XXX how should border&padding effect baseline alignment? |
michael@0 | 101 | // => descent = borderPadding.bottom for example |
michael@0 | 102 | void |
michael@0 | 103 | nsLeafFrame::AddBordersAndPadding(const nsHTMLReflowState& aReflowState, |
michael@0 | 104 | nsHTMLReflowMetrics& aMetrics) |
michael@0 | 105 | { |
michael@0 | 106 | aMetrics.Width() += aReflowState.ComputedPhysicalBorderPadding().LeftRight(); |
michael@0 | 107 | aMetrics.Height() += aReflowState.ComputedPhysicalBorderPadding().TopBottom(); |
michael@0 | 108 | } |
michael@0 | 109 | |
michael@0 | 110 | void |
michael@0 | 111 | nsLeafFrame::SizeToAvailSize(const nsHTMLReflowState& aReflowState, |
michael@0 | 112 | nsHTMLReflowMetrics& aDesiredSize) |
michael@0 | 113 | { |
michael@0 | 114 | aDesiredSize.Width() = aReflowState.AvailableWidth(); // FRAME |
michael@0 | 115 | aDesiredSize.Height() = aReflowState.AvailableHeight(); |
michael@0 | 116 | aDesiredSize.SetOverflowAreasToDesiredBounds(); |
michael@0 | 117 | FinishAndStoreOverflow(&aDesiredSize); |
michael@0 | 118 | } |