OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2000 Dirk Mueller (mueller@kde.org) | 3 * Copyright (C) 2000 Dirk Mueller (mueller@kde.org) |
4 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. | 4 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. |
5 * Copyright (C) Research In Motion Limited 2011-2012. All rights reserved. | 5 * Copyright (C) Research In Motion Limited 2011-2012. All rights reserved. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 // for that value. | 502 // for that value. |
503 // ------------------------------------------------------------------------- | 503 // ------------------------------------------------------------------------- |
504 } else if (logicalTop.isAuto()) { | 504 } else if (logicalTop.isAuto()) { |
505 marginBeforeAlias = | 505 marginBeforeAlias = |
506 valueForLength(marginBefore, containerRelativeLogicalWidth); | 506 valueForLength(marginBefore, containerRelativeLogicalWidth); |
507 marginAfterAlias = | 507 marginAfterAlias = |
508 valueForLength(marginAfter, containerRelativeLogicalWidth); | 508 valueForLength(marginAfter, containerRelativeLogicalWidth); |
509 logicalBottomValue = valueForLength(logicalBottom, containerLogicalHeight); | 509 logicalBottomValue = valueForLength(logicalBottom, containerLogicalHeight); |
510 | 510 |
511 // Solve for 'top' | 511 // Solve for 'top' |
512 logicalTopValue = availableSpace - (logicalBottomValue + marginBeforeAlias + | 512 logicalTopValue = |
513 marginAfterAlias); | 513 availableSpace - |
| 514 (logicalBottomValue + marginBeforeAlias + marginAfterAlias); |
514 } else if (logicalBottom.isAuto()) { | 515 } else if (logicalBottom.isAuto()) { |
515 marginBeforeAlias = | 516 marginBeforeAlias = |
516 valueForLength(marginBefore, containerRelativeLogicalWidth); | 517 valueForLength(marginBefore, containerRelativeLogicalWidth); |
517 marginAfterAlias = | 518 marginAfterAlias = |
518 valueForLength(marginAfter, containerRelativeLogicalWidth); | 519 valueForLength(marginAfter, containerRelativeLogicalWidth); |
519 logicalTopValue = valueForLength(logicalTop, containerLogicalHeight); | 520 logicalTopValue = valueForLength(logicalTop, containerLogicalHeight); |
520 | 521 |
521 // Solve for 'bottom' | 522 // Solve for 'bottom' |
522 // NOTE: It is not necessary to solve for 'bottom' because we don't ever | 523 // NOTE: It is not necessary to solve for 'bottom' because we don't ever |
523 // use the value. | 524 // use the value. |
524 } else if (marginBefore.isAuto()) { | 525 } else if (marginBefore.isAuto()) { |
525 marginAfterAlias = | 526 marginAfterAlias = |
526 valueForLength(marginAfter, containerRelativeLogicalWidth); | 527 valueForLength(marginAfter, containerRelativeLogicalWidth); |
527 logicalTopValue = valueForLength(logicalTop, containerLogicalHeight); | 528 logicalTopValue = valueForLength(logicalTop, containerLogicalHeight); |
528 logicalBottomValue = valueForLength(logicalBottom, containerLogicalHeight); | 529 logicalBottomValue = valueForLength(logicalBottom, containerLogicalHeight); |
529 | 530 |
530 // Solve for 'margin-top' | 531 // Solve for 'margin-top' |
531 marginBeforeAlias = availableSpace - (logicalTopValue + logicalBottomValue + | 532 marginBeforeAlias = |
532 marginAfterAlias); | 533 availableSpace - |
| 534 (logicalTopValue + logicalBottomValue + marginAfterAlias); |
533 } else if (marginAfter.isAuto()) { | 535 } else if (marginAfter.isAuto()) { |
534 marginBeforeAlias = | 536 marginBeforeAlias = |
535 valueForLength(marginBefore, containerRelativeLogicalWidth); | 537 valueForLength(marginBefore, containerRelativeLogicalWidth); |
536 logicalTopValue = valueForLength(logicalTop, containerLogicalHeight); | 538 logicalTopValue = valueForLength(logicalTop, containerLogicalHeight); |
537 logicalBottomValue = valueForLength(logicalBottom, containerLogicalHeight); | 539 logicalBottomValue = valueForLength(logicalBottom, containerLogicalHeight); |
538 | 540 |
539 // Solve for 'margin-bottom' | 541 // Solve for 'margin-bottom' |
540 marginAfterAlias = availableSpace - (logicalTopValue + logicalBottomValue + | 542 marginAfterAlias = |
541 marginBeforeAlias); | 543 availableSpace - |
| 544 (logicalTopValue + logicalBottomValue + marginBeforeAlias); |
542 } else { | 545 } else { |
543 // Nothing is 'auto', just calculate the values. | 546 // Nothing is 'auto', just calculate the values. |
544 marginBeforeAlias = | 547 marginBeforeAlias = |
545 valueForLength(marginBefore, containerRelativeLogicalWidth); | 548 valueForLength(marginBefore, containerRelativeLogicalWidth); |
546 marginAfterAlias = | 549 marginAfterAlias = |
547 valueForLength(marginAfter, containerRelativeLogicalWidth); | 550 valueForLength(marginAfter, containerRelativeLogicalWidth); |
548 logicalTopValue = valueForLength(logicalTop, containerLogicalHeight); | 551 logicalTopValue = valueForLength(logicalTop, containerLogicalHeight); |
549 // NOTE: It is not necessary to solve for 'bottom' because we don't ever | 552 // NOTE: It is not necessary to solve for 'bottom' because we don't ever |
550 // use the value. | 553 // use the value. |
551 } | 554 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 : this->intrinsicSize(); | 588 : this->intrinsicSize(); |
586 if (!intrinsicSize.width() || !intrinsicSize.height()) | 589 if (!intrinsicSize.width() || !intrinsicSize.height()) |
587 return contentRect; | 590 return contentRect; |
588 | 591 |
589 LayoutRect finalRect = contentRect; | 592 LayoutRect finalRect = contentRect; |
590 switch (objectFit) { | 593 switch (objectFit) { |
591 case ObjectFitContain: | 594 case ObjectFitContain: |
592 case ObjectFitScaleDown: | 595 case ObjectFitScaleDown: |
593 case ObjectFitCover: | 596 case ObjectFitCover: |
594 finalRect.setSize(finalRect.size().fitToAspectRatio( | 597 finalRect.setSize(finalRect.size().fitToAspectRatio( |
595 intrinsicSize, objectFit == ObjectFitCover ? AspectRatioFitGrow | 598 intrinsicSize, |
596 : AspectRatioFitShrink)); | 599 objectFit == ObjectFitCover ? AspectRatioFitGrow |
| 600 : AspectRatioFitShrink)); |
597 if (objectFit != ObjectFitScaleDown || | 601 if (objectFit != ObjectFitScaleDown || |
598 finalRect.width() <= intrinsicSize.width()) | 602 finalRect.width() <= intrinsicSize.width()) |
599 break; | 603 break; |
600 // fall through | 604 // fall through |
601 case ObjectFitNone: | 605 case ObjectFitNone: |
602 finalRect.setSize(intrinsicSize); | 606 finalRect.setSize(intrinsicSize); |
603 break; | 607 break; |
604 case ObjectFitFill: | 608 case ObjectFitFill: |
605 break; | 609 break; |
606 default: | 610 default: |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
830 m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = | 834 m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = |
831 computeReplacedLogicalWidth(ComputePreferred); | 835 computeReplacedLogicalWidth(ComputePreferred); |
832 | 836 |
833 const ComputedStyle& styleToUse = styleRef(); | 837 const ComputedStyle& styleToUse = styleRef(); |
834 if (styleToUse.logicalWidth().isPercentOrCalc() || | 838 if (styleToUse.logicalWidth().isPercentOrCalc() || |
835 styleToUse.logicalMaxWidth().isPercentOrCalc()) | 839 styleToUse.logicalMaxWidth().isPercentOrCalc()) |
836 m_minPreferredLogicalWidth = LayoutUnit(); | 840 m_minPreferredLogicalWidth = LayoutUnit(); |
837 | 841 |
838 if (styleToUse.logicalMinWidth().isFixed() && | 842 if (styleToUse.logicalMinWidth().isFixed() && |
839 styleToUse.logicalMinWidth().value() > 0) { | 843 styleToUse.logicalMinWidth().value() > 0) { |
840 m_maxPreferredLogicalWidth = std::max( | 844 m_maxPreferredLogicalWidth = |
841 m_maxPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing( | 845 std::max(m_maxPreferredLogicalWidth, |
842 styleToUse.logicalMinWidth().value())); | 846 adjustContentBoxLogicalWidthForBoxSizing( |
843 m_minPreferredLogicalWidth = std::max( | 847 styleToUse.logicalMinWidth().value())); |
844 m_minPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing( | 848 m_minPreferredLogicalWidth = |
845 styleToUse.logicalMinWidth().value())); | 849 std::max(m_minPreferredLogicalWidth, |
| 850 adjustContentBoxLogicalWidthForBoxSizing( |
| 851 styleToUse.logicalMinWidth().value())); |
846 } | 852 } |
847 | 853 |
848 if (styleToUse.logicalMaxWidth().isFixed()) { | 854 if (styleToUse.logicalMaxWidth().isFixed()) { |
849 m_maxPreferredLogicalWidth = std::min( | 855 m_maxPreferredLogicalWidth = |
850 m_maxPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing( | 856 std::min(m_maxPreferredLogicalWidth, |
851 styleToUse.logicalMaxWidth().value())); | 857 adjustContentBoxLogicalWidthForBoxSizing( |
852 m_minPreferredLogicalWidth = std::min( | 858 styleToUse.logicalMaxWidth().value())); |
853 m_minPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing( | 859 m_minPreferredLogicalWidth = |
854 styleToUse.logicalMaxWidth().value())); | 860 std::min(m_minPreferredLogicalWidth, |
| 861 adjustContentBoxLogicalWidthForBoxSizing( |
| 862 styleToUse.logicalMaxWidth().value())); |
855 } | 863 } |
856 | 864 |
857 LayoutUnit borderAndPadding = borderAndPaddingLogicalWidth(); | 865 LayoutUnit borderAndPadding = borderAndPaddingLogicalWidth(); |
858 m_minPreferredLogicalWidth += borderAndPadding; | 866 m_minPreferredLogicalWidth += borderAndPadding; |
859 m_maxPreferredLogicalWidth += borderAndPadding; | 867 m_maxPreferredLogicalWidth += borderAndPadding; |
860 | 868 |
861 clearPreferredLogicalWidthsDirty(); | 869 clearPreferredLogicalWidthsDirty(); |
862 } | 870 } |
863 | 871 |
864 PositionWithAffinity LayoutReplaced::positionForPoint( | 872 PositionWithAffinity LayoutReplaced::positionForPoint( |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
927 inlineBoxWrapper()->root().setHasSelectedChildren(state != SelectionNone); | 935 inlineBoxWrapper()->root().setHasSelectedChildren(state != SelectionNone); |
928 } | 936 } |
929 | 937 |
930 void LayoutReplaced::IntrinsicSizingInfo::transpose() { | 938 void LayoutReplaced::IntrinsicSizingInfo::transpose() { |
931 size = size.transposedSize(); | 939 size = size.transposedSize(); |
932 aspectRatio = aspectRatio.transposedSize(); | 940 aspectRatio = aspectRatio.transposedSize(); |
933 std::swap(hasWidth, hasHeight); | 941 std::swap(hasWidth, hasHeight); |
934 } | 942 } |
935 | 943 |
936 } // namespace blink | 944 } // namespace blink |
OLD | NEW |