зеркало из https://github.com/mozilla/pjs.git
Maded DetermineFrameType a callable static method; removed gratuitous line-height calculations
This commit is contained in:
Родитель
8c14c6224a
Коммит
712958e437
|
@ -83,23 +83,17 @@ nsHTMLReflowState::GetContainingBlockContentWidth(const nsReflowState* aParentRS
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX there is no CLEAN way to detect the "replaced" attribute (yet)
|
nsCSSFrameType
|
||||||
void
|
nsHTMLReflowState::DetermineFrameType(nsIFrame* aFrame)
|
||||||
nsHTMLReflowState::DetermineFrameType(nsIPresContext& aPresContext)
|
|
||||||
{
|
{
|
||||||
nsIAtom* tag = nsnull;
|
nsCSSFrameType frameType;
|
||||||
nsIContent* content;
|
|
||||||
if (NS_SUCCEEDED(frame->GetContent(&content)) && (nsnull != content)) {
|
|
||||||
content->GetTag(tag);
|
|
||||||
NS_RELEASE(content);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Section 9.7 indicates that absolute position takes precedence
|
// Section 9.7 of the CSS2 spec indicates that absolute position
|
||||||
// over float which takes precedence over display.
|
// takes precedence over float which takes precedence over display.
|
||||||
const nsStyleDisplay* display;
|
const nsStyleDisplay* display;
|
||||||
frame->GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&)display);
|
aFrame->GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&)display);
|
||||||
const nsStylePosition* pos;
|
const nsStylePosition* pos;
|
||||||
frame->GetStyleData(eStyleStruct_Position, (const nsStyleStruct*&)pos);
|
aFrame->GetStyleData(eStyleStruct_Position, (const nsStyleStruct*&)pos);
|
||||||
if (pos->IsAbsolutelyPositioned()) {
|
if (pos->IsAbsolutelyPositioned()) {
|
||||||
frameType = NS_CSS_FRAME_TYPE_ABSOLUTE;
|
frameType = NS_CSS_FRAME_TYPE_ABSOLUTE;
|
||||||
}
|
}
|
||||||
|
@ -146,11 +140,12 @@ nsHTMLReflowState::DetermineFrameType(nsIPresContext& aPresContext)
|
||||||
|
|
||||||
// See if the frame is replaced
|
// See if the frame is replaced
|
||||||
nsFrameState frameState;
|
nsFrameState frameState;
|
||||||
frame->GetFrameState(&frameState);
|
aFrame->GetFrameState(&frameState);
|
||||||
if (frameState & NS_FRAME_REPLACED_ELEMENT) {
|
if (frameState & NS_FRAME_REPLACED_ELEMENT) {
|
||||||
frameType = NS_FRAME_REPLACED(frameType);
|
frameType = NS_FRAME_REPLACED(frameType);
|
||||||
}
|
}
|
||||||
NS_IF_RELEASE(tag);
|
|
||||||
|
return frameType;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper function that re-calculates the left and right margin based on
|
// Helper function that re-calculates the left and right margin based on
|
||||||
|
@ -601,6 +596,9 @@ nsHTMLReflowState::InitAbsoluteConstraints(nsIPresContext& aPresContext,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// XXX refactor this code to have methods for each set of properties
|
||||||
|
// we are computing: width,height,line-height; margin; offsets
|
||||||
|
|
||||||
void
|
void
|
||||||
nsHTMLReflowState::InitConstraints(nsIPresContext& aPresContext)
|
nsHTMLReflowState::InitConstraints(nsIPresContext& aPresContext)
|
||||||
{
|
{
|
||||||
|
@ -616,6 +614,7 @@ nsHTMLReflowState::InitConstraints(nsIPresContext& aPresContext)
|
||||||
computedMargin.SizeTo(0, 0, 0, 0);
|
computedMargin.SizeTo(0, 0, 0, 0);
|
||||||
computedOffsets.SizeTo(0, 0, 0, 0);
|
computedOffsets.SizeTo(0, 0, 0, 0);
|
||||||
|
|
||||||
|
// XXX what about other properties...
|
||||||
} else {
|
} else {
|
||||||
// Get the containing block reflow state
|
// Get the containing block reflow state
|
||||||
const nsHTMLReflowState* cbrs =
|
const nsHTMLReflowState* cbrs =
|
||||||
|
@ -632,23 +631,11 @@ nsHTMLReflowState::InitConstraints(nsIPresContext& aPresContext)
|
||||||
|
|
||||||
// Compute margins from the specified margin style information. These
|
// Compute margins from the specified margin style information. These
|
||||||
// become the default computed values, and may be adjusted below
|
// become the default computed values, and may be adjusted below
|
||||||
|
|
||||||
|
// XXX fix to provide 0,0 for the top&bottom marings for
|
||||||
|
// inline-non-replaced elements
|
||||||
ComputeMarginFor(frame, parentReflowState, computedMargin);
|
ComputeMarginFor(frame, parentReflowState, computedMargin);
|
||||||
|
|
||||||
// Calculate the line height.
|
|
||||||
// XXX Do we need to do this for all elements or just inline non-replaced
|
|
||||||
// elements?
|
|
||||||
mLineHeight = CalcLineHeight(aPresContext, frame);
|
|
||||||
|
|
||||||
// See if it's an inline non-replaced element
|
|
||||||
if (NS_CSS_FRAME_TYPE_INLINE == frameType) {
|
|
||||||
// 'width' property doesn't apply to inline non-replaced elements. The
|
|
||||||
// 'height' is given by the element's 'line-height' value
|
|
||||||
if (mLineHeight >= 0) {
|
|
||||||
computedHeight = mLineHeight;
|
|
||||||
}
|
|
||||||
return; // nothing else to compute
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the containing block width and height. We'll need them when
|
// Get the containing block width and height. We'll need them when
|
||||||
// calculating the computed width and height. For all elements other
|
// calculating the computed width and height. For all elements other
|
||||||
// than absolutely positioned elements, the containing block is formed
|
// than absolutely positioned elements, the containing block is formed
|
||||||
|
|
|
@ -83,23 +83,17 @@ nsHTMLReflowState::GetContainingBlockContentWidth(const nsReflowState* aParentRS
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX there is no CLEAN way to detect the "replaced" attribute (yet)
|
nsCSSFrameType
|
||||||
void
|
nsHTMLReflowState::DetermineFrameType(nsIFrame* aFrame)
|
||||||
nsHTMLReflowState::DetermineFrameType(nsIPresContext& aPresContext)
|
|
||||||
{
|
{
|
||||||
nsIAtom* tag = nsnull;
|
nsCSSFrameType frameType;
|
||||||
nsIContent* content;
|
|
||||||
if (NS_SUCCEEDED(frame->GetContent(&content)) && (nsnull != content)) {
|
|
||||||
content->GetTag(tag);
|
|
||||||
NS_RELEASE(content);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Section 9.7 indicates that absolute position takes precedence
|
// Section 9.7 of the CSS2 spec indicates that absolute position
|
||||||
// over float which takes precedence over display.
|
// takes precedence over float which takes precedence over display.
|
||||||
const nsStyleDisplay* display;
|
const nsStyleDisplay* display;
|
||||||
frame->GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&)display);
|
aFrame->GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&)display);
|
||||||
const nsStylePosition* pos;
|
const nsStylePosition* pos;
|
||||||
frame->GetStyleData(eStyleStruct_Position, (const nsStyleStruct*&)pos);
|
aFrame->GetStyleData(eStyleStruct_Position, (const nsStyleStruct*&)pos);
|
||||||
if (pos->IsAbsolutelyPositioned()) {
|
if (pos->IsAbsolutelyPositioned()) {
|
||||||
frameType = NS_CSS_FRAME_TYPE_ABSOLUTE;
|
frameType = NS_CSS_FRAME_TYPE_ABSOLUTE;
|
||||||
}
|
}
|
||||||
|
@ -146,11 +140,12 @@ nsHTMLReflowState::DetermineFrameType(nsIPresContext& aPresContext)
|
||||||
|
|
||||||
// See if the frame is replaced
|
// See if the frame is replaced
|
||||||
nsFrameState frameState;
|
nsFrameState frameState;
|
||||||
frame->GetFrameState(&frameState);
|
aFrame->GetFrameState(&frameState);
|
||||||
if (frameState & NS_FRAME_REPLACED_ELEMENT) {
|
if (frameState & NS_FRAME_REPLACED_ELEMENT) {
|
||||||
frameType = NS_FRAME_REPLACED(frameType);
|
frameType = NS_FRAME_REPLACED(frameType);
|
||||||
}
|
}
|
||||||
NS_IF_RELEASE(tag);
|
|
||||||
|
return frameType;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper function that re-calculates the left and right margin based on
|
// Helper function that re-calculates the left and right margin based on
|
||||||
|
@ -601,6 +596,9 @@ nsHTMLReflowState::InitAbsoluteConstraints(nsIPresContext& aPresContext,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// XXX refactor this code to have methods for each set of properties
|
||||||
|
// we are computing: width,height,line-height; margin; offsets
|
||||||
|
|
||||||
void
|
void
|
||||||
nsHTMLReflowState::InitConstraints(nsIPresContext& aPresContext)
|
nsHTMLReflowState::InitConstraints(nsIPresContext& aPresContext)
|
||||||
{
|
{
|
||||||
|
@ -616,6 +614,7 @@ nsHTMLReflowState::InitConstraints(nsIPresContext& aPresContext)
|
||||||
computedMargin.SizeTo(0, 0, 0, 0);
|
computedMargin.SizeTo(0, 0, 0, 0);
|
||||||
computedOffsets.SizeTo(0, 0, 0, 0);
|
computedOffsets.SizeTo(0, 0, 0, 0);
|
||||||
|
|
||||||
|
// XXX what about other properties...
|
||||||
} else {
|
} else {
|
||||||
// Get the containing block reflow state
|
// Get the containing block reflow state
|
||||||
const nsHTMLReflowState* cbrs =
|
const nsHTMLReflowState* cbrs =
|
||||||
|
@ -632,23 +631,11 @@ nsHTMLReflowState::InitConstraints(nsIPresContext& aPresContext)
|
||||||
|
|
||||||
// Compute margins from the specified margin style information. These
|
// Compute margins from the specified margin style information. These
|
||||||
// become the default computed values, and may be adjusted below
|
// become the default computed values, and may be adjusted below
|
||||||
|
|
||||||
|
// XXX fix to provide 0,0 for the top&bottom marings for
|
||||||
|
// inline-non-replaced elements
|
||||||
ComputeMarginFor(frame, parentReflowState, computedMargin);
|
ComputeMarginFor(frame, parentReflowState, computedMargin);
|
||||||
|
|
||||||
// Calculate the line height.
|
|
||||||
// XXX Do we need to do this for all elements or just inline non-replaced
|
|
||||||
// elements?
|
|
||||||
mLineHeight = CalcLineHeight(aPresContext, frame);
|
|
||||||
|
|
||||||
// See if it's an inline non-replaced element
|
|
||||||
if (NS_CSS_FRAME_TYPE_INLINE == frameType) {
|
|
||||||
// 'width' property doesn't apply to inline non-replaced elements. The
|
|
||||||
// 'height' is given by the element's 'line-height' value
|
|
||||||
if (mLineHeight >= 0) {
|
|
||||||
computedHeight = mLineHeight;
|
|
||||||
}
|
|
||||||
return; // nothing else to compute
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the containing block width and height. We'll need them when
|
// Get the containing block width and height. We'll need them when
|
||||||
// calculating the computed width and height. For all elements other
|
// calculating the computed width and height. For all elements other
|
||||||
// than absolutely positioned elements, the containing block is formed
|
// than absolutely positioned elements, the containing block is formed
|
||||||
|
|
Загрузка…
Ссылка в новой задаче