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 14 matching lines...) Expand all Loading... | |
25 | 25 |
26 #include "core/editing/PositionWithAffinity.h" | 26 #include "core/editing/PositionWithAffinity.h" |
27 #include "core/layout/LayoutAnalyzer.h" | 27 #include "core/layout/LayoutAnalyzer.h" |
28 #include "core/layout/LayoutBlock.h" | 28 #include "core/layout/LayoutBlock.h" |
29 #include "core/layout/LayoutImage.h" | 29 #include "core/layout/LayoutImage.h" |
30 #include "core/layout/LayoutInline.h" | 30 #include "core/layout/LayoutInline.h" |
31 #include "core/layout/LayoutView.h" | 31 #include "core/layout/LayoutView.h" |
32 #include "core/paint/PaintInfo.h" | 32 #include "core/paint/PaintInfo.h" |
33 #include "core/paint/PaintLayer.h" | 33 #include "core/paint/PaintLayer.h" |
34 #include "core/paint/ReplacedPainter.h" | 34 #include "core/paint/ReplacedPainter.h" |
35 #include "core/svg/SVGSVGElement.h" | |
36 #include "platform/LengthFunctions.h" | 35 #include "platform/LengthFunctions.h" |
37 | 36 |
38 namespace blink { | 37 namespace blink { |
39 | 38 |
40 const int LayoutReplaced::defaultWidth = 300; | 39 const int LayoutReplaced::defaultWidth = 300; |
41 const int LayoutReplaced::defaultHeight = 150; | 40 const int LayoutReplaced::defaultHeight = 150; |
42 | 41 |
43 LayoutReplaced::LayoutReplaced(Element* element) | 42 LayoutReplaced::LayoutReplaced(Element* element) |
44 : LayoutBox(element) | 43 : LayoutBox(element) |
45 , m_intrinsicSize(defaultWidth, defaultHeight) | 44 , m_intrinsicSize(defaultWidth, defaultHeight) |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
536 ASSERT(!embeddedContentBox()); | 535 ASSERT(!embeddedContentBox()); |
537 intrinsicSizingInfo.size = FloatSize(intrinsicLogicalWidth().toFloat(), intr insicLogicalHeight().toFloat()); | 536 intrinsicSizingInfo.size = FloatSize(intrinsicLogicalWidth().toFloat(), intr insicLogicalHeight().toFloat()); |
538 | 537 |
539 // Figure out if we need to compute an intrinsic ratio. | 538 // Figure out if we need to compute an intrinsic ratio. |
540 if (intrinsicSizingInfo.size.isEmpty() || !layoutObjectHasAspectRatio(this)) | 539 if (intrinsicSizingInfo.size.isEmpty() || !layoutObjectHasAspectRatio(this)) |
541 return; | 540 return; |
542 | 541 |
543 intrinsicSizingInfo.aspectRatio = intrinsicSizingInfo.size.width() / intrins icSizingInfo.size.height(); | 542 intrinsicSizingInfo.aspectRatio = intrinsicSizingInfo.size.width() / intrins icSizingInfo.size.height(); |
544 } | 543 } |
545 | 544 |
546 static bool hasIntrinsicWidthForLayoutBox(LayoutBox* layoutObject) | |
547 { | |
548 if (layoutObject && layoutObject->isSVGRoot()) { | |
549 SVGSVGElement* svg = toSVGSVGElement(layoutObject->node()); | |
550 ASSERT(svg); | |
551 return svg->hasIntrinsicWidth(); | |
552 } | |
553 | |
554 return false; | |
555 } | |
556 | |
557 static bool hasIntrinsicHeightForLayoutBox(LayoutBox* layoutObject) | |
558 { | |
559 if (layoutObject && layoutObject->isSVGRoot()) { | |
560 SVGSVGElement* svg = toSVGSVGElement(layoutObject->node()); | |
561 ASSERT(svg); | |
562 return svg->hasIntrinsicHeight(); | |
563 } | |
564 | |
565 return false; | |
566 } | |
567 | |
568 LayoutUnit LayoutReplaced::computeReplacedLogicalWidth(ShouldComputePreferred sh ouldComputePreferred) const | 545 LayoutUnit LayoutReplaced::computeReplacedLogicalWidth(ShouldComputePreferred sh ouldComputePreferred) const |
569 { | 546 { |
570 if (style()->logicalWidth().isSpecified() || style()->logicalWidth().isIntri nsic()) | 547 if (style()->logicalWidth().isSpecified() || style()->logicalWidth().isIntri nsic()) |
571 return computeReplacedLogicalWidthRespectingMinMaxWidth(computeReplacedL ogicalWidthUsing(MainOrPreferredSize, style()->logicalWidth()), shouldComputePre ferred); | 548 return computeReplacedLogicalWidthRespectingMinMaxWidth(computeReplacedL ogicalWidthUsing(MainOrPreferredSize, style()->logicalWidth()), shouldComputePre ferred); |
572 | 549 |
573 LayoutBox* contentLayoutObject = embeddedContentBox(); | 550 LayoutBox* contentLayoutObject = embeddedContentBox(); |
574 | 551 |
575 // 10.3.2 Inline, replaced elements: http://www.w3.org/TR/CSS21/visudet.html #inline-replaced-width | 552 // 10.3.2 Inline, replaced elements: http://www.w3.org/TR/CSS21/visudet.html #inline-replaced-width |
576 IntrinsicSizingInfo intrinsicSizingInfo; | 553 IntrinsicSizingInfo intrinsicSizingInfo; |
577 computeIntrinsicSizingInfoForLayoutBox(contentLayoutObject, intrinsicSizingI nfo); | 554 computeIntrinsicSizingInfoForLayoutBox(contentLayoutObject, intrinsicSizingI nfo); |
578 FloatSize constrainedSize = constrainIntrinsicSizeToMinMax(intrinsicSizingIn fo); | 555 FloatSize constrainedSize = constrainIntrinsicSizeToMinMax(intrinsicSizingIn fo); |
579 | 556 |
580 if (style()->logicalWidth().isAuto()) { | 557 if (style()->logicalWidth().isAuto()) { |
581 bool computedHeightIsAuto = hasAutoHeightOrContainingBlockWithAutoHeight (); | 558 bool computedHeightIsAuto = hasAutoHeightOrContainingBlockWithAutoHeight (); |
582 // TODO(shanmuga.m@samsung.com): hasIntrinsicWidth/Height information sh ould be obtained | 559 bool hasIntrinsicWidth = !intrinsicSizingInfo.emptyWidth; |
fs
2016/02/09 18:37:54
Maybe consider adding accessors on IntrinsicSizing
davve
2016/02/11 08:52:37
Turned it around to avoid "empty" prefix. Hopefull
| |
583 // from LayoutBox::computeIntrinsicSizingInfo(). | |
584 bool hasIntrinsicWidth = constrainedSize.width() > 0 || hasIntrinsicWidt hForLayoutBox(contentLayoutObject); | |
585 | 560 |
586 // If 'height' and 'width' both have computed values of 'auto' and the e lement also has an intrinsic width, then that intrinsic width is the used value of 'width'. | 561 // If 'height' and 'width' both have computed values of 'auto' and the e lement also has an intrinsic width, then that intrinsic width is the used value of 'width'. |
587 if (computedHeightIsAuto && hasIntrinsicWidth) | 562 if (computedHeightIsAuto && hasIntrinsicWidth) |
588 return computeReplacedLogicalWidthRespectingMinMaxWidth(LayoutUnit(c onstrainedSize.width()), shouldComputePreferred); | 563 return computeReplacedLogicalWidthRespectingMinMaxWidth(LayoutUnit(c onstrainedSize.width()), shouldComputePreferred); |
589 | 564 |
590 bool hasIntrinsicHeight = constrainedSize.height() > 0 || hasIntrinsicHe ightForLayoutBox(contentLayoutObject); | 565 bool hasIntrinsicHeight = !intrinsicSizingInfo.emptyHeight; |
591 | 566 |
592 if (intrinsicSizingInfo.aspectRatio) { | 567 if (intrinsicSizingInfo.aspectRatio) { |
593 // If 'height' and 'width' both have computed values of 'auto' and t he element has no intrinsic width, but does have an intrinsic height and intrins ic ratio; | 568 // If 'height' and 'width' both have computed values of 'auto' and t he element has no intrinsic width, but does have an intrinsic height and intrins ic ratio; |
594 // or if 'width' has a computed value of 'auto', 'height' has some o ther computed value, and the element does have an intrinsic ratio; then the used value | 569 // or if 'width' has a computed value of 'auto', 'height' has some o ther computed value, and the element does have an intrinsic ratio; then the used value |
595 // of 'width' is: (used height) * (intrinsic ratio) | 570 // of 'width' is: (used height) * (intrinsic ratio) |
596 if (intrinsicSizingInfo.aspectRatio && ((computedHeightIsAuto && !ha sIntrinsicWidth && hasIntrinsicHeight) || !computedHeightIsAuto)) { | 571 if (intrinsicSizingInfo.aspectRatio && ((computedHeightIsAuto && !ha sIntrinsicWidth && hasIntrinsicHeight) || !computedHeightIsAuto)) { |
597 LayoutUnit logicalHeight = computeReplacedLogicalHeight(); | 572 LayoutUnit logicalHeight = computeReplacedLogicalHeight(); |
598 return computeReplacedLogicalWidthRespectingMinMaxWidth(LayoutUn it(logicalHeight * intrinsicSizingInfo.aspectRatio), shouldComputePreferred); | 573 return computeReplacedLogicalWidthRespectingMinMaxWidth(LayoutUn it(logicalHeight * intrinsicSizingInfo.aspectRatio), shouldComputePreferred); |
599 } | 574 } |
600 | 575 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
637 return computeReplacedLogicalHeightRespectingMinMaxHeight(computeReplace dLogicalHeightUsing(MainOrPreferredSize, style()->logicalHeight())); | 612 return computeReplacedLogicalHeightRespectingMinMaxHeight(computeReplace dLogicalHeightUsing(MainOrPreferredSize, style()->logicalHeight())); |
638 | 613 |
639 LayoutBox* contentLayoutObject = embeddedContentBox(); | 614 LayoutBox* contentLayoutObject = embeddedContentBox(); |
640 | 615 |
641 // 10.6.2 Inline, replaced elements: http://www.w3.org/TR/CSS21/visudet.html #inline-replaced-height | 616 // 10.6.2 Inline, replaced elements: http://www.w3.org/TR/CSS21/visudet.html #inline-replaced-height |
642 IntrinsicSizingInfo intrinsicSizingInfo; | 617 IntrinsicSizingInfo intrinsicSizingInfo; |
643 computeIntrinsicSizingInfoForLayoutBox(contentLayoutObject, intrinsicSizingI nfo); | 618 computeIntrinsicSizingInfoForLayoutBox(contentLayoutObject, intrinsicSizingI nfo); |
644 FloatSize constrainedSize = constrainIntrinsicSizeToMinMax(intrinsicSizingIn fo); | 619 FloatSize constrainedSize = constrainIntrinsicSizeToMinMax(intrinsicSizingIn fo); |
645 | 620 |
646 bool widthIsAuto = style()->logicalWidth().isAuto(); | 621 bool widthIsAuto = style()->logicalWidth().isAuto(); |
647 // TODO(shanmuga.m@samsung.com): hasIntrinsicWidth/Height information should be obtained | 622 bool hasIntrinsicHeight = !intrinsicSizingInfo.emptyHeight; |
648 // from LayoutBox::computeIntrinsicSizingInfo(). | |
649 bool hasIntrinsicHeight = constrainedSize.height() > 0 || hasIntrinsicHeight ForLayoutBox(contentLayoutObject); | |
650 | 623 |
651 // If 'height' and 'width' both have computed values of 'auto' and the eleme nt also has an intrinsic height, then that intrinsic height is the used value of 'height'. | 624 // If 'height' and 'width' both have computed values of 'auto' and the eleme nt also has an intrinsic height, then that intrinsic height is the used value of 'height'. |
652 if (widthIsAuto && hasIntrinsicHeight) | 625 if (widthIsAuto && hasIntrinsicHeight) |
653 return computeReplacedLogicalHeightRespectingMinMaxHeight(constrainedSiz e.height()); | 626 return computeReplacedLogicalHeightRespectingMinMaxHeight(constrainedSiz e.height()); |
654 | 627 |
655 // Otherwise, if 'height' has a computed value of 'auto', and the element ha s an intrinsic ratio then the used value of 'height' is: | 628 // Otherwise, if 'height' has a computed value of 'auto', and the element ha s an intrinsic ratio then the used value of 'height' is: |
656 // (used width) / (intrinsic ratio) | 629 // (used width) / (intrinsic ratio) |
657 if (intrinsicSizingInfo.aspectRatio) | 630 if (intrinsicSizingInfo.aspectRatio) |
658 return computeReplacedLogicalHeightRespectingMinMaxHeight(LayoutUnit(ava ilableLogicalWidth() / intrinsicSizingInfo.aspectRatio)); | 631 return computeReplacedLogicalHeightRespectingMinMaxHeight(LayoutUnit(ava ilableLogicalWidth() / intrinsicSizingInfo.aspectRatio)); |
659 | 632 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
774 // We only include the space below the baseline in our layer's cached paint invalidation rect if the | 747 // We only include the space below the baseline in our layer's cached paint invalidation rect if the |
775 // image is selected. Since the selection state has changed update the rect. | 748 // image is selected. Since the selection state has changed update the rect. |
776 if (hasLayer()) | 749 if (hasLayer()) |
777 setPreviousPaintInvalidationRect(boundsRectForPaintInvalidation(containe rForPaintInvalidation())); | 750 setPreviousPaintInvalidationRect(boundsRectForPaintInvalidation(containe rForPaintInvalidation())); |
778 | 751 |
779 if (canUpdateSelectionOnRootLineBoxes()) | 752 if (canUpdateSelectionOnRootLineBoxes()) |
780 inlineBoxWrapper()->root().setHasSelectedChildren(state != SelectionNone ); | 753 inlineBoxWrapper()->root().setHasSelectedChildren(state != SelectionNone ); |
781 } | 754 } |
782 | 755 |
783 } // namespace blink | 756 } // namespace blink |
OLD | NEW |