OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 2583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2594 if (!gridAreaRect.contains(child->frameRect())) | 2594 if (!gridAreaRect.contains(child->frameRect())) |
2595 m_gridItemsOverflowingGridArea.push_back(child); | 2595 m_gridItemsOverflowingGridArea.push_back(child); |
2596 } | 2596 } |
2597 } | 2597 } |
2598 | 2598 |
2599 void LayoutGrid::prepareChildForPositionedLayout(LayoutBox& child) { | 2599 void LayoutGrid::prepareChildForPositionedLayout(LayoutBox& child) { |
2600 ASSERT(child.isOutOfFlowPositioned()); | 2600 ASSERT(child.isOutOfFlowPositioned()); |
2601 child.containingBlock()->insertPositionedObject(&child); | 2601 child.containingBlock()->insertPositionedObject(&child); |
2602 | 2602 |
2603 PaintLayer* childLayer = child.layer(); | 2603 PaintLayer* childLayer = child.layer(); |
2604 childLayer->setStaticInlinePosition(borderAndPaddingStart()); | 2604 childLayer->setStaticInlinePosition(LayoutUnit(borderStart())); |
2605 childLayer->setStaticBlockPosition(borderAndPaddingBefore()); | 2605 childLayer->setStaticBlockPosition(LayoutUnit(borderBefore())); |
svillar
2017/01/31 15:28:40
Mind explaining this change?
Manuel Rego
2017/02/01 09:08:20
This was a mistake, we shouldn't include padding h
svillar
2017/02/01 09:49:07
I guess you're adding a test for this change. In a
Manuel Rego
2017/02/01 11:10:34
This is the part that I've moved to a different pa
| |
2606 } | 2606 } |
2607 | 2607 |
2608 void LayoutGrid::layoutPositionedObjects(bool relayoutChildren, | 2608 void LayoutGrid::layoutPositionedObjects(bool relayoutChildren, |
2609 PositionedLayoutBehavior info) { | 2609 PositionedLayoutBehavior info) { |
2610 TrackedLayoutBoxListHashSet* positionedDescendants = positionedObjects(); | 2610 TrackedLayoutBoxListHashSet* positionedDescendants = positionedObjects(); |
2611 if (!positionedDescendants) | 2611 if (!positionedDescendants) |
2612 return; | 2612 return; |
2613 | 2613 |
2614 for (auto* child : *positionedDescendants) { | 2614 for (auto* child : *positionedDescendants) { |
2615 if (isOrthogonalChild(*child)) { | 2615 if (isOrthogonalChild(*child)) { |
2616 // FIXME: Properly support orthogonal writing mode. | 2616 // FIXME: Properly support orthogonal writing mode. |
2617 layoutPositionedObject(child, relayoutChildren, info); | 2617 layoutPositionedObject(child, relayoutChildren, info); |
2618 continue; | 2618 continue; |
2619 } | 2619 } |
2620 | 2620 |
2621 LayoutUnit columnOffset = LayoutUnit(); | 2621 LayoutUnit columnOffset = LayoutUnit(); |
2622 LayoutUnit columnBreadth = LayoutUnit(); | 2622 LayoutUnit columnBreadth = LayoutUnit(); |
2623 offsetAndBreadthForPositionedChild(*child, ForColumns, columnOffset, | 2623 offsetAndBreadthForPositionedChild(*child, ForColumns, columnOffset, |
2624 columnBreadth); | 2624 columnBreadth); |
2625 LayoutUnit rowOffset = LayoutUnit(); | 2625 LayoutUnit rowOffset = LayoutUnit(); |
2626 LayoutUnit rowBreadth = LayoutUnit(); | 2626 LayoutUnit rowBreadth = LayoutUnit(); |
2627 offsetAndBreadthForPositionedChild(*child, ForRows, rowOffset, rowBreadth); | 2627 offsetAndBreadthForPositionedChild(*child, ForRows, rowOffset, rowBreadth); |
2628 | 2628 |
2629 child->setOverrideContainingBlockContentLogicalWidth(columnBreadth); | 2629 child->setOverrideContainingBlockContentLogicalWidth(columnBreadth); |
2630 child->setOverrideContainingBlockContentLogicalHeight(rowBreadth); | 2630 child->setOverrideContainingBlockContentLogicalHeight(rowBreadth); |
2631 child->setExtraInlineOffset(columnOffset); | |
2632 child->setExtraBlockOffset(rowOffset); | |
2633 | 2631 |
2634 if (child->parent() == this) { | 2632 bool hasStaticInlinePosition = child->styleRef().hasStaticInlinePosition( |
2635 PaintLayer* childLayer = child->layer(); | 2633 child->isHorizontalWritingMode()); |
2636 childLayer->setStaticInlinePosition(borderStart() + columnOffset); | 2634 bool hasStaticBlockPosition = child->styleRef().hasStaticBlockPosition( |
2637 childLayer->setStaticBlockPosition(borderBefore() + rowOffset); | 2635 child->isHorizontalWritingMode()); |
2638 } | 2636 bool childNeedsLayout = child->needsLayout(); |
2637 | |
2638 if (hasStaticInlinePosition || childNeedsLayout) | |
2639 child->setX(LayoutUnit()); | |
2640 if (hasStaticBlockPosition || childNeedsLayout) | |
2641 child->setY(LayoutUnit()); | |
2639 | 2642 |
2640 layoutPositionedObject(child, relayoutChildren, info); | 2643 layoutPositionedObject(child, relayoutChildren, info); |
2644 | |
2645 LayoutUnit x = child->logicalLeft(); | |
2646 LayoutUnit y = child->logicalTop(); | |
2647 | |
2648 if (hasStaticInlinePosition || childNeedsLayout) | |
2649 x += columnOffset; | |
2650 if (hasStaticBlockPosition || childNeedsLayout) | |
2651 y += rowOffset; | |
2652 | |
2653 child->setLogicalLocation(LayoutPoint(x, y)); | |
svillar
2017/01/31 15:28:40
I don't get this part too...
Manuel Rego
2017/02/01 09:08:20
I agree this part is tricky but I didn't find a be
svillar
2017/02/01 09:49:07
Having conditions like (hasStaticBlockPosition ||
| |
2641 } | 2654 } |
2642 } | 2655 } |
2643 | 2656 |
2644 void LayoutGrid::offsetAndBreadthForPositionedChild( | 2657 void LayoutGrid::offsetAndBreadthForPositionedChild( |
2645 const LayoutBox& child, | 2658 const LayoutBox& child, |
2646 GridTrackSizingDirection direction, | 2659 GridTrackSizingDirection direction, |
2647 LayoutUnit& offset, | 2660 LayoutUnit& offset, |
2648 LayoutUnit& breadth) { | 2661 LayoutUnit& breadth) { |
2649 ASSERT(!isOrthogonalChild(child)); | 2662 ASSERT(!isOrthogonalChild(child)); |
2650 bool isForColumns = direction == ForColumns; | 2663 bool isForColumns = direction == ForColumns; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2716 if (endLine > 0 && endLine < lastLine) { | 2729 if (endLine > 0 && endLine < lastLine) { |
2717 DCHECK(!m_grid.needsItemsPlacement()); | 2730 DCHECK(!m_grid.needsItemsPlacement()); |
2718 end -= guttersSize(m_grid, direction, endLine - 1, 2, TrackSizing); | 2731 end -= guttersSize(m_grid, direction, endLine - 1, 2, TrackSizing); |
2719 end -= isForColumns ? m_offsetBetweenColumns : m_offsetBetweenRows; | 2732 end -= isForColumns ? m_offsetBetweenColumns : m_offsetBetweenRows; |
2720 } | 2733 } |
2721 } | 2734 } |
2722 | 2735 |
2723 breadth = std::max(end - start, LayoutUnit()); | 2736 breadth = std::max(end - start, LayoutUnit()); |
2724 offset = start; | 2737 offset = start; |
2725 | 2738 |
2726 if (isForColumns && !styleRef().isLeftToRightDirection() && | 2739 if (isForColumns && !styleRef().isLeftToRightDirection()) { |
2727 !child.styleRef().hasStaticInlinePosition( | 2740 // We always want to calculate the static position from the left |
2728 child.isHorizontalWritingMode())) { | |
2729 // If the child doesn't have a static inline position (i.e. "left" and/or | |
2730 // "right" aren't "auto", we need to calculate the offset from the left | |
2731 // (even if we're in RTL). | 2741 // (even if we're in RTL). |
2732 if (endIsAuto) { | 2742 if (endIsAuto) { |
2733 offset = LayoutUnit(); | 2743 offset = LayoutUnit(); |
2734 } else { | 2744 } else { |
2735 offset = translateRTLCoordinate(m_columnPositions[endLine]) - | 2745 offset = translateRTLCoordinate(m_columnPositions[endLine]) - |
2736 borderLogicalLeft(); | 2746 borderLogicalLeft(); |
2737 | 2747 |
2738 if (endLine > 0 && endLine < lastLine) { | 2748 if (endLine > 0 && endLine < lastLine) { |
2739 DCHECK(!m_grid.needsItemsPlacement()); | 2749 DCHECK(!m_grid.needsItemsPlacement()); |
2740 offset += guttersSize(m_grid, direction, endLine - 1, 2, TrackSizing); | 2750 offset += guttersSize(m_grid, direction, endLine - 1, 2, TrackSizing); |
(...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3628 if (direction == ForRows) | 3638 if (direction == ForRows) |
3629 return grid.numTracks(ForRows); | 3639 return grid.numTracks(ForRows); |
3630 | 3640 |
3631 return grid.numTracks(ForRows) | 3641 return grid.numTracks(ForRows) |
3632 ? grid.numTracks(ForColumns) | 3642 ? grid.numTracks(ForColumns) |
3633 : GridPositionsResolver::explicitGridColumnCount( | 3643 : GridPositionsResolver::explicitGridColumnCount( |
3634 styleRef(), grid.autoRepeatTracks(ForColumns)); | 3644 styleRef(), grid.autoRepeatTracks(ForColumns)); |
3635 } | 3645 } |
3636 | 3646 |
3637 } // namespace blink | 3647 } // namespace blink |
OLD | NEW |