OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) | 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) |
5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) | 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) |
6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed. | 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed. |
7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. | 7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. |
8 * | 8 * |
9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
(...skipping 2329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2340 // that don't stretch their kids lay out their children at their intrinsic w idths. | 2340 // that don't stretch their kids lay out their children at their intrinsic w idths. |
2341 // FIXME: Think about block-flow here. | 2341 // FIXME: Think about block-flow here. |
2342 // https://bugs.webkit.org/show_bug.cgi?id=46473 | 2342 // https://bugs.webkit.org/show_bug.cgi?id=46473 |
2343 if (parent()->isDeprecatedFlexibleBox() && (parent()->style()->boxOrient() = = HORIZONTAL || parent()->style()->boxAlign() != BSTRETCH)) | 2343 if (parent()->isDeprecatedFlexibleBox() && (parent()->style()->boxOrient() = = HORIZONTAL || parent()->style()->boxAlign() != BSTRETCH)) |
2344 return true; | 2344 return true; |
2345 | 2345 |
2346 // Button, input, select, textarea, and legend treat width value of 'auto' a s 'intrinsic' unless it's in a | 2346 // Button, input, select, textarea, and legend treat width value of 'auto' a s 'intrinsic' unless it's in a |
2347 // stretching column flexbox. | 2347 // stretching column flexbox. |
2348 // FIXME: Think about block-flow here. | 2348 // FIXME: Think about block-flow here. |
2349 // https://bugs.webkit.org/show_bug.cgi?id=46473 | 2349 // https://bugs.webkit.org/show_bug.cgi?id=46473 |
2350 if (logicalWidth.type() == Auto && !isStretchingColumnFlexItem(this) && node () && (node()->hasTagName(inputTag) | 2350 if (logicalWidth.type() == Auto && !isStretchingColumnFlexItem(this) && isEl ementWithIntrinsicWidth()) |
2351 || node()->hasTagName(selectTag) || node()->hasTagName(buttonTag) || isH TMLTextAreaElement(node()) || node()->hasTagName(legendTag))) | |
2352 return true; | 2351 return true; |
2353 | 2352 |
2354 if (isHorizontalWritingMode() != containingBlock()->isHorizontalWritingMode( )) | 2353 if (isHorizontalWritingMode() != containingBlock()->isHorizontalWritingMode( )) |
2355 return true; | 2354 return true; |
2356 | 2355 |
2357 return false; | 2356 return false; |
2358 } | 2357 } |
2359 | 2358 |
2359 bool RenderBox::isElementWithIntrinsicWidth() const | |
2360 { | |
2361 if (node() && (node()->hasTagName(inputTag) || node()->hasTagName(selectTag) || node()->hasTagName(buttonTag) | |
2362 || isHTMLTextAreaElement(node()) || node()->hasTagName(legendTag))) | |
2363 return true; | |
2364 | |
2365 return false; | |
2366 } | |
2367 | |
2360 void RenderBox::computeInlineDirectionMargins(RenderBlock* containingBlock, Layo utUnit containerWidth, LayoutUnit childWidth, LayoutUnit& marginStart, LayoutUni t& marginEnd) const | 2368 void RenderBox::computeInlineDirectionMargins(RenderBlock* containingBlock, Layo utUnit containerWidth, LayoutUnit childWidth, LayoutUnit& marginStart, LayoutUni t& marginEnd) const |
2361 { | 2369 { |
2362 const RenderStyle* containingBlockStyle = containingBlock->style(); | 2370 const RenderStyle* containingBlockStyle = containingBlock->style(); |
2363 Length marginStartLength = style()->marginStartUsing(containingBlockStyle); | 2371 Length marginStartLength = style()->marginStartUsing(containingBlockStyle); |
2364 Length marginEndLength = style()->marginEndUsing(containingBlockStyle); | 2372 Length marginEndLength = style()->marginEndUsing(containingBlockStyle); |
2365 RenderView* renderView = view(); | 2373 RenderView* renderView = view(); |
2366 | 2374 |
2367 if (isFloating() || isInline()) { | 2375 if (isFloating() || isInline()) { |
2368 // Inline blocks/tables and floats don't have their margins increased. | 2376 // Inline blocks/tables and floats don't have their margins increased. |
2369 marginStart = minimumValueForLength(marginStartLength, containerWidth, r enderView); | 2377 marginStart = minimumValueForLength(marginStartLength, containerWidth, r enderView); |
(...skipping 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3472 LayoutUnit preferredMinWidth = minPreferredLogicalWidth() - bordersP lusPadding; | 3480 LayoutUnit preferredMinWidth = minPreferredLogicalWidth() - bordersP lusPadding; |
3473 LayoutUnit availableWidth = availableSpace - logicalLeftValue; | 3481 LayoutUnit availableWidth = availableSpace - logicalLeftValue; |
3474 computedValues.m_extent = min(max(preferredMinWidth, availableWidth) , preferredWidth); | 3482 computedValues.m_extent = min(max(preferredMinWidth, availableWidth) , preferredWidth); |
3475 } else if (logicalLeftIsAuto && !logicalWidthIsAuto && !logicalRightIsAu to) { | 3483 } else if (logicalLeftIsAuto && !logicalWidthIsAuto && !logicalRightIsAu to) { |
3476 // RULE 4: (solve for left) | 3484 // RULE 4: (solve for left) |
3477 computedValues.m_extent = adjustContentBoxLogicalWidthForBoxSizing(v alueForLength(logicalWidth, containerLogicalWidth, renderView)); | 3485 computedValues.m_extent = adjustContentBoxLogicalWidthForBoxSizing(v alueForLength(logicalWidth, containerLogicalWidth, renderView)); |
3478 logicalLeftValue = availableSpace - (computedValues.m_extent + value ForLength(logicalRight, containerLogicalWidth, renderView)); | 3486 logicalLeftValue = availableSpace - (computedValues.m_extent + value ForLength(logicalRight, containerLogicalWidth, renderView)); |
3479 } else if (!logicalLeftIsAuto && logicalWidthIsAuto && !logicalRightIsAu to) { | 3487 } else if (!logicalLeftIsAuto && logicalWidthIsAuto && !logicalRightIsAu to) { |
3480 // RULE 5: (solve for width) | 3488 // RULE 5: (solve for width) |
3481 logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth , renderView); | 3489 logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth , renderView); |
3482 computedValues.m_extent = availableSpace - (logicalLeftValue + value ForLength(logicalRight, containerLogicalWidth, renderView)); | 3490 // Use shrink-to-fit for width for Button, input, select, textarea, and legend treat width value of |
3491 // 'auto' as 'intrinsic'. | |
3492 if (isElementWithIntrinsicWidth()) { | |
3493 LayoutUnit preferredWidth = maxPreferredLogicalWidth() - borders PlusPadding; | |
3494 LayoutUnit preferredMinWidth = minPreferredLogicalWidth() - bord ersPlusPadding; | |
3495 LayoutUnit availableWidth = availableSpace - logicalLeftValue; | |
3496 computedValues.m_extent = min(max(preferredMinWidth, availableWi dth), preferredWidth); | |
cbiesinger
2013/10/09 17:13:38
Is there a reasonable way to share this code with
pals
2013/10/10 05:30:54
Done.
| |
3497 } else { | |
3498 computedValues.m_extent = availableSpace - (logicalLeftValue + v alueForLength(logicalRight, containerLogicalWidth, renderView)); | |
3499 } | |
3483 } else if (!logicalLeftIsAuto && !logicalWidthIsAuto && logicalRightIsAu to) { | 3500 } else if (!logicalLeftIsAuto && !logicalWidthIsAuto && logicalRightIsAu to) { |
3484 // RULE 6: (no need solve for right) | 3501 // RULE 6: (no need solve for right) |
3485 logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth , renderView); | 3502 logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth , renderView); |
3486 computedValues.m_extent = adjustContentBoxLogicalWidthForBoxSizing(v alueForLength(logicalWidth, containerLogicalWidth, renderView)); | 3503 computedValues.m_extent = adjustContentBoxLogicalWidthForBoxSizing(v alueForLength(logicalWidth, containerLogicalWidth, renderView)); |
3487 } | 3504 } |
3488 } | 3505 } |
3489 | 3506 |
3490 // Use computed values to calculate the horizontal position. | 3507 // Use computed values to calculate the horizontal position. |
3491 | 3508 |
3492 // FIXME: This hack is needed to calculate the logical left position for a 'rtl' relatively | 3509 // FIXME: This hack is needed to calculate the logical left position for a 'rtl' relatively |
(...skipping 1290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4783 return 0; | 4800 return 0; |
4784 | 4801 |
4785 if (!layoutState && !flowThreadContainingBlock()) | 4802 if (!layoutState && !flowThreadContainingBlock()) |
4786 return 0; | 4803 return 0; |
4787 | 4804 |
4788 RenderBlock* containerBlock = containingBlock(); | 4805 RenderBlock* containerBlock = containingBlock(); |
4789 return containerBlock->offsetFromLogicalTopOfFirstPage() + logicalTop(); | 4806 return containerBlock->offsetFromLogicalTopOfFirstPage() + logicalTop(); |
4790 } | 4807 } |
4791 | 4808 |
4792 } // namespace WebCore | 4809 } // namespace WebCore |
OLD | NEW |