|
Lines 2883-2896
void RenderBox::computePositionedLogical
Source/WebCore/rendering/RenderBox.cpp_sec1
|
| 2883 |
// We don't use containingBlock(), since we may be positioned by an enclosing relpositioned inline. |
2883 |
// We don't use containingBlock(), since we may be positioned by an enclosing relpositioned inline. |
| 2884 |
const RenderBoxModelObject* containerBlock = toRenderBoxModelObject(container()); |
2884 |
const RenderBoxModelObject* containerBlock = toRenderBoxModelObject(container()); |
| 2885 |
|
2885 |
|
| 2886 |
const int containerHeight = containingBlockLogicalHeightForPositioned(containerBlock); |
2886 |
const int containerLogicalHeight = containingBlockLogicalHeightForPositioned(containerBlock); |
| 2887 |
|
2887 |
|
| 2888 |
// Variables to solve. |
2888 |
// Variables to solve. |
| 2889 |
Length top = style()->top(); |
2889 |
bool isHorizontal = style()->isHorizontalWritingMode(); |
| 2890 |
Length bottom = style()->bottom(); |
2890 |
bool isFlipped = style()->isFlippedBlocksWritingMode(); |
| 2891 |
Length marginTop = style()->marginTop(); |
2891 |
Length marginBefore = style()->marginBefore(); |
| 2892 |
Length marginBottom = style()->marginBottom(); |
2892 |
Length marginAfter = style()->marginAfter(); |
|
|
2893 |
int& marginBeforeAlias = isHorizontal ? (isFlipped ? m_marginBottom : m_marginTop) : (isFlipped ? m_marginRight: m_marginLeft); |
| 2894 |
int& marginAfterAlias = isHorizontal ? (isFlipped ? m_marginTop : m_marginBottom) : (isFlipped ? m_marginLeft: m_marginRight); |
| 2893 |
|
2895 |
|
|
|
2896 |
Length logicalTop = style()->logicalTop(); |
| 2897 |
Length logicalBottom = style()->logicalBottom(); |
| 2894 |
|
2898 |
|
| 2895 |
/*-----------------------------------------------------------------------*\ |
2899 |
/*-----------------------------------------------------------------------*\ |
| 2896 |
* 1. The used value of 'height' is determined as for inline replaced |
2900 |
* 1. The used value of 'height' is determined as for inline replaced |
|
Lines 2899-2920
void RenderBox::computePositionedLogical
Source/WebCore/rendering/RenderBox.cpp_sec2
|
| 2899 |
// NOTE: This value of height is FINAL in that the min/max height calculations |
2903 |
// NOTE: This value of height is FINAL in that the min/max height calculations |
| 2900 |
// are dealt with in computeReplacedHeight(). This means that the steps to produce |
2904 |
// are dealt with in computeReplacedHeight(). This means that the steps to produce |
| 2901 |
// correct max/min in the non-replaced version, are not necessary. |
2905 |
// correct max/min in the non-replaced version, are not necessary. |
| 2902 |
setHeight(computeReplacedLogicalHeight() + borderAndPaddingHeight()); |
2906 |
setLogicalHeight(computeReplacedLogicalHeight() + borderAndPaddingLogicalHeight()); |
| 2903 |
const int availableSpace = containerHeight - height(); |
2907 |
const int availableSpace = containerLogicalHeight - logicalHeight(); |
| 2904 |
|
2908 |
|
| 2905 |
/*-----------------------------------------------------------------------*\ |
2909 |
/*-----------------------------------------------------------------------*\ |
| 2906 |
* 2. If both 'top' and 'bottom' have the value 'auto', replace 'top' |
2910 |
* 2. If both 'top' and 'bottom' have the value 'auto', replace 'top' |
| 2907 |
* with the element's static position. |
2911 |
* with the element's static position. |
| 2908 |
\*-----------------------------------------------------------------------*/ |
2912 |
\*-----------------------------------------------------------------------*/ |
| 2909 |
// see FIXME 2 |
2913 |
// see FIXME 2 |
| 2910 |
if (top.isAuto() && bottom.isAuto()) { |
2914 |
// FIXME: The static distance computation has not been patched for writing modes yet. |
|
|
2915 |
if (logicalTop.isAuto() && logicalBottom.isAuto()) { |
| 2911 |
// staticY should already have been set through layout of the parent(). |
2916 |
// staticY should already have been set through layout of the parent(). |
| 2912 |
int staticTop = layer()->staticY() - containerBlock->borderTop(); |
2917 |
int staticTop = layer()->staticY() - containerBlock->borderTop(); |
| 2913 |
for (RenderObject* po = parent(); po && po != containerBlock; po = po->parent()) { |
2918 |
for (RenderObject* po = parent(); po && po != containerBlock; po = po->parent()) { |
| 2914 |
if (po->isBox() && !po->isTableRow()) |
2919 |
if (po->isBox() && !po->isTableRow()) |
| 2915 |
staticTop += toRenderBox(po)->y(); |
2920 |
staticTop += toRenderBox(po)->y(); |
| 2916 |
} |
2921 |
} |
| 2917 |
top.setValue(Fixed, staticTop); |
2922 |
logicalTop.setValue(Fixed, staticTop); |
| 2918 |
} |
2923 |
} |
| 2919 |
|
2924 |
|
| 2920 |
/*-----------------------------------------------------------------------*\ |
2925 |
/*-----------------------------------------------------------------------*\ |
|
Lines 2923-2933
void RenderBox::computePositionedLogical
Source/WebCore/rendering/RenderBox.cpp_sec3
|
| 2923 |
\*-----------------------------------------------------------------------*/ |
2928 |
\*-----------------------------------------------------------------------*/ |
| 2924 |
// FIXME: The spec. says that this step should only be taken when bottom is |
2929 |
// FIXME: The spec. says that this step should only be taken when bottom is |
| 2925 |
// auto, but if only top is auto, this makes step 4 impossible. |
2930 |
// auto, but if only top is auto, this makes step 4 impossible. |
| 2926 |
if (top.isAuto() || bottom.isAuto()) { |
2931 |
if (logicalTop.isAuto() || logicalBottom.isAuto()) { |
| 2927 |
if (marginTop.isAuto()) |
2932 |
if (marginBefore.isAuto()) |
| 2928 |
marginTop.setValue(Fixed, 0); |
2933 |
marginBefore.setValue(Fixed, 0); |
| 2929 |
if (marginBottom.isAuto()) |
2934 |
if (marginAfter.isAuto()) |
| 2930 |
marginBottom.setValue(Fixed, 0); |
2935 |
marginAfter.setValue(Fixed, 0); |
| 2931 |
} |
2936 |
} |
| 2932 |
|
2937 |
|
| 2933 |
/*-----------------------------------------------------------------------*\ |
2938 |
/*-----------------------------------------------------------------------*\ |
|
Lines 2935-2993
void RenderBox::computePositionedLogical
Source/WebCore/rendering/RenderBox.cpp_sec4
|
| 2935 |
* 'auto', solve the equation under the extra constraint that the two |
2940 |
* 'auto', solve the equation under the extra constraint that the two |
| 2936 |
* margins must get equal values. |
2941 |
* margins must get equal values. |
| 2937 |
\*-----------------------------------------------------------------------*/ |
2942 |
\*-----------------------------------------------------------------------*/ |
| 2938 |
int topValue = 0; |
2943 |
int logicalTopValue = 0; |
| 2939 |
int bottomValue = 0; |
2944 |
int logicalBottomValue = 0; |
| 2940 |
|
2945 |
|
| 2941 |
if (marginTop.isAuto() && marginBottom.isAuto()) { |
2946 |
if (marginBefore.isAuto() && marginAfter.isAuto()) { |
| 2942 |
// 'top' and 'bottom' cannot be 'auto' due to step 2 and 3 combined. |
2947 |
// 'top' and 'bottom' cannot be 'auto' due to step 2 and 3 combined. |
| 2943 |
ASSERT(!(top.isAuto() || bottom.isAuto())); |
2948 |
ASSERT(!(logicalTop.isAuto() || logicalBottom.isAuto())); |
| 2944 |
|
2949 |
|
| 2945 |
topValue = top.calcValue(containerHeight); |
2950 |
logicalTopValue = logicalTop.calcValue(containerLogicalHeight); |
| 2946 |
bottomValue = bottom.calcValue(containerHeight); |
2951 |
logicalBottomValue = logicalBottom.calcValue(containerLogicalHeight); |
| 2947 |
|
2952 |
|
| 2948 |
int difference = availableSpace - (topValue + bottomValue); |
2953 |
int difference = availableSpace - (logicalTopValue + logicalBottomValue); |
| 2949 |
// NOTE: This may result in negative values. |
2954 |
// NOTE: This may result in negative values. |
| 2950 |
m_marginTop = difference / 2; // split the difference |
2955 |
marginBeforeAlias = difference / 2; // split the difference |
| 2951 |
m_marginBottom = difference - m_marginTop; // account for odd valued differences |
2956 |
marginAfterAlias = difference - marginBeforeAlias; // account for odd valued differences |
| 2952 |
|
2957 |
|
| 2953 |
/*-----------------------------------------------------------------------*\ |
2958 |
/*-----------------------------------------------------------------------*\ |
| 2954 |
* 5. If at this point there is only one 'auto' left, solve the equation |
2959 |
* 5. If at this point there is only one 'auto' left, solve the equation |
| 2955 |
* for that value. |
2960 |
* for that value. |
| 2956 |
\*-----------------------------------------------------------------------*/ |
2961 |
\*-----------------------------------------------------------------------*/ |
| 2957 |
} else if (top.isAuto()) { |
2962 |
} else if (logicalTop.isAuto()) { |
| 2958 |
m_marginTop = marginTop.calcValue(containerHeight); |
2963 |
marginBeforeAlias = marginBefore.calcValue(containerLogicalHeight); |
| 2959 |
m_marginBottom = marginBottom.calcValue(containerHeight); |
2964 |
marginAfterAlias = marginAfter.calcValue(containerLogicalHeight); |
| 2960 |
bottomValue = bottom.calcValue(containerHeight); |
2965 |
logicalBottomValue = logicalBottom.calcValue(containerLogicalHeight); |
| 2961 |
|
2966 |
|
| 2962 |
// Solve for 'top' |
2967 |
// Solve for 'top' |
| 2963 |
topValue = availableSpace - (bottomValue + m_marginTop + m_marginBottom); |
2968 |
logicalTopValue = availableSpace - (logicalBottomValue + marginBeforeAlias + marginAfterAlias); |
| 2964 |
} else if (bottom.isAuto()) { |
2969 |
} else if (logicalBottom.isAuto()) { |
| 2965 |
m_marginTop = marginTop.calcValue(containerHeight); |
2970 |
marginBeforeAlias = marginBefore.calcValue(containerLogicalHeight); |
| 2966 |
m_marginBottom = marginBottom.calcValue(containerHeight); |
2971 |
marginAfterAlias = marginAfter.calcValue(containerLogicalHeight); |
| 2967 |
topValue = top.calcValue(containerHeight); |
2972 |
logicalTopValue = logicalTop.calcValue(containerLogicalHeight); |
| 2968 |
|
2973 |
|
| 2969 |
// Solve for 'bottom' |
2974 |
// Solve for 'bottom' |
| 2970 |
// NOTE: It is not necessary to solve for 'bottom' because we don't ever |
2975 |
// NOTE: It is not necessary to solve for 'bottom' because we don't ever |
| 2971 |
// use the value. |
2976 |
// use the value. |
| 2972 |
} else if (marginTop.isAuto()) { |
2977 |
} else if (marginBefore.isAuto()) { |
| 2973 |
m_marginBottom = marginBottom.calcValue(containerHeight); |
2978 |
marginAfterAlias = marginAfter.calcValue(containerLogicalHeight); |
| 2974 |
topValue = top.calcValue(containerHeight); |
2979 |
logicalTopValue = logicalTop.calcValue(containerLogicalHeight); |
| 2975 |
bottomValue = bottom.calcValue(containerHeight); |
2980 |
logicalBottomValue = logicalBottom.calcValue(containerLogicalHeight); |
| 2976 |
|
2981 |
|
| 2977 |
// Solve for 'margin-top' |
2982 |
// Solve for 'margin-top' |
| 2978 |
m_marginTop = availableSpace - (topValue + bottomValue + m_marginBottom); |
2983 |
marginBeforeAlias = availableSpace - (logicalTopValue + logicalBottomValue + marginAfterAlias); |
| 2979 |
} else if (marginBottom.isAuto()) { |
2984 |
} else if (marginAfter.isAuto()) { |
| 2980 |
m_marginTop = marginTop.calcValue(containerHeight); |
2985 |
marginBeforeAlias = marginBefore.calcValue(containerLogicalHeight); |
| 2981 |
topValue = top.calcValue(containerHeight); |
2986 |
logicalTopValue = logicalTop.calcValue(containerLogicalHeight); |
| 2982 |
bottomValue = bottom.calcValue(containerHeight); |
2987 |
logicalBottomValue = logicalBottom.calcValue(containerLogicalHeight); |
| 2983 |
|
2988 |
|
| 2984 |
// Solve for 'margin-bottom' |
2989 |
// Solve for 'margin-bottom' |
| 2985 |
m_marginBottom = availableSpace - (topValue + bottomValue + m_marginTop); |
2990 |
marginAfterAlias = availableSpace - (logicalTopValue + logicalBottomValue + marginBeforeAlias); |
| 2986 |
} else { |
2991 |
} else { |
| 2987 |
// Nothing is 'auto', just calculate the values. |
2992 |
// Nothing is 'auto', just calculate the values. |
| 2988 |
m_marginTop = marginTop.calcValue(containerHeight); |
2993 |
marginBeforeAlias = marginBefore.calcValue(containerLogicalHeight); |
| 2989 |
m_marginBottom = marginBottom.calcValue(containerHeight); |
2994 |
marginAfterAlias = marginAfter.calcValue(containerLogicalHeight); |
| 2990 |
topValue = top.calcValue(containerHeight); |
2995 |
logicalTopValue = logicalTop.calcValue(containerLogicalHeight); |
| 2991 |
// NOTE: It is not necessary to solve for 'bottom' because we don't ever |
2996 |
// NOTE: It is not necessary to solve for 'bottom' because we don't ever |
| 2992 |
// use the value. |
2997 |
// use the value. |
| 2993 |
} |
2998 |
} |
|
Lines 2999-3007
void RenderBox::computePositionedLogical
Source/WebCore/rendering/RenderBox.cpp_sec5
|
| 2999 |
// NOTE: It is not necessary to do this step because we don't end up using |
3004 |
// NOTE: It is not necessary to do this step because we don't end up using |
| 3000 |
// the value of 'bottom' regardless of whether the values are over-constrained |
3005 |
// the value of 'bottom' regardless of whether the values are over-constrained |
| 3001 |
// or not. |
3006 |
// or not. |
|
|
3007 |
|
| 3008 |
// FIXME: Deal with differing writing modes here. Our offset needs to be in the containing block's coordinate space, so that |
| 3009 |
// can make the result here rather complicated to compute. |
| 3002 |
|
3010 |
|
| 3003 |
// Use computed values to calculate the vertical position. |
3011 |
// Use computed values to calculate the vertical position. |
| 3004 |
m_frameRect.setY(topValue + m_marginTop + containerBlock->borderTop()); |
3012 |
int logicalTopPos = logicalTopValue + marginBeforeAlias; |
|
|
3013 |
|
| 3014 |
// Our offset is from the logical bottom edge in a flipped environment, e.g., right for vertical-rl and bottom for horizontal-bt. |
| 3015 |
if (isFlipped) { |
| 3016 |
if (isHorizontal) |
| 3017 |
logicalTopPos += containerBlock->borderBottom(); |
| 3018 |
else |
| 3019 |
logicalTopPos += containerBlock->borderRight(); |
| 3020 |
} else { |
| 3021 |
if (isHorizontal) |
| 3022 |
logicalTopPos += containerBlock->borderTop(); |
| 3023 |
else |
| 3024 |
logicalTopPos += containerBlock->borderLeft(); |
| 3025 |
} |
| 3026 |
|
| 3027 |
setLogicalTop(logicalTopPos); |
| 3005 |
} |
3028 |
} |
| 3006 |
|
3029 |
|
| 3007 |
IntRect RenderBox::localCaretRect(InlineBox* box, int caretOffset, int* extraWidthToEndOfLine) |
3030 |
IntRect RenderBox::localCaretRect(InlineBox* box, int caretOffset, int* extraWidthToEndOfLine) |