OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 2085 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2096 | 2096 |
2097 m_paintInvalidationLogicalTop = 0; | 2097 m_paintInvalidationLogicalTop = 0; |
2098 m_paintInvalidationLogicalBottom = 0; | 2098 m_paintInvalidationLogicalBottom = 0; |
2099 } | 2099 } |
2100 | 2100 |
2101 void LayoutBlockFlow::paintFloats(const PaintInfo& paintInfo, const LayoutPoint&
paintOffset) const | 2101 void LayoutBlockFlow::paintFloats(const PaintInfo& paintInfo, const LayoutPoint&
paintOffset) const |
2102 { | 2102 { |
2103 BlockFlowPainter(*this).paintFloats(paintInfo, paintOffset); | 2103 BlockFlowPainter(*this).paintFloats(paintInfo, paintOffset); |
2104 } | 2104 } |
2105 | 2105 |
2106 void LayoutBlockFlow::paintSelection(const PaintInfo& paintInfo, const LayoutPoi
nt& paintOffset) const | |
2107 { | |
2108 BlockFlowPainter(*this).paintSelection(paintInfo, paintOffset); | |
2109 } | |
2110 | |
2111 void LayoutBlockFlow::clipOutFloatingObjects(const LayoutBlock* rootBlock, ClipS
cope& clipScope, | 2106 void LayoutBlockFlow::clipOutFloatingObjects(const LayoutBlock* rootBlock, ClipS
cope& clipScope, |
2112 const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRo
otBlock) const | 2107 const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRo
otBlock) const |
2113 { | 2108 { |
2114 if (!m_floatingObjects) | 2109 if (!m_floatingObjects) |
2115 return; | 2110 return; |
2116 | 2111 |
2117 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); | 2112 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); |
2118 FloatingObjectSetIterator end = floatingObjectSet.end(); | 2113 FloatingObjectSetIterator end = floatingObjectSet.end(); |
2119 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++
it) { | 2114 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++
it) { |
2120 const FloatingObject& floatingObject = *it->get(); | 2115 const FloatingObject& floatingObject = *it->get(); |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2636 } | 2631 } |
2637 | 2632 |
2638 LayoutUnit LayoutBlockFlow::logicalRightFloatOffsetForLine(LayoutUnit logicalTop
, LayoutUnit fixedOffset, LayoutUnit logicalHeight) const | 2633 LayoutUnit LayoutBlockFlow::logicalRightFloatOffsetForLine(LayoutUnit logicalTop
, LayoutUnit fixedOffset, LayoutUnit logicalHeight) const |
2639 { | 2634 { |
2640 if (m_floatingObjects && m_floatingObjects->hasRightObjects()) | 2635 if (m_floatingObjects && m_floatingObjects->hasRightObjects()) |
2641 return m_floatingObjects->logicalRightOffset(fixedOffset, logicalTop, lo
gicalHeight); | 2636 return m_floatingObjects->logicalRightOffset(fixedOffset, logicalTop, lo
gicalHeight); |
2642 | 2637 |
2643 return fixedOffset; | 2638 return fixedOffset; |
2644 } | 2639 } |
2645 | 2640 |
2646 LayoutRect LayoutBlockFlow::selectionRectForPaintInvalidation(const LayoutBoxMod
elObject* paintInvalidationContainer) const | |
2647 { | |
2648 LayoutRect rect = selectionGapRectsForPaintInvalidation(paintInvalidationCon
tainer); | |
2649 // FIXME: groupedMapping() leaks the squashing abstraction. | |
2650 if (paintInvalidationContainer->layer()->groupedMapping()) | |
2651 PaintLayer::mapRectToPaintBackingCoordinates(paintInvalidationContainer,
rect); | |
2652 return rect; | |
2653 } | |
2654 | |
2655 GapRects LayoutBlockFlow::selectionGapRectsForPaintInvalidation(const LayoutBoxM
odelObject* paintInvalidationContainer) const | |
2656 { | |
2657 ASSERT(!needsLayout()); | |
2658 | |
2659 if (!shouldPaintSelectionGaps()) | |
2660 return GapRects(); | |
2661 | |
2662 TransformState transformState(TransformState::ApplyTransformDirection, Float
Point()); | |
2663 mapLocalToAncestor(paintInvalidationContainer, transformState, ApplyContaine
rFlip | UseTransforms); | |
2664 LayoutPoint offsetFromPaintInvalidationContainer = roundedLayoutPoint(transf
ormState.mappedPoint()); | |
2665 | |
2666 if (hasOverflowClip()) | |
2667 offsetFromPaintInvalidationContainer -= scrolledContentOffset(); | |
2668 | |
2669 LayoutUnit lastTop = 0; | |
2670 LayoutUnit lastLeft = logicalLeftSelectionOffset(this, lastTop); | |
2671 LayoutUnit lastRight = logicalRightSelectionOffset(this, lastTop); | |
2672 | |
2673 return selectionGaps(this, offsetFromPaintInvalidationContainer, LayoutSize(
), lastTop, lastLeft, lastRight); | |
2674 } | |
2675 | |
2676 static void clipOutPositionedObjects(ClipScope& clipScope, const LayoutPoint& of
fset, TrackedLayoutBoxListHashSet* positionedObjects) | |
2677 { | |
2678 if (!positionedObjects) | |
2679 return; | |
2680 | |
2681 TrackedLayoutBoxListHashSet::const_iterator end = positionedObjects->end(); | |
2682 for (TrackedLayoutBoxListHashSet::const_iterator it = positionedObjects->beg
in(); it != end; ++it) { | |
2683 LayoutBox* r = *it; | |
2684 clipScope.clip(LayoutRect(flooredIntPoint(r->location() + offset), floor
edIntSize(r->size())), SkRegion::kDifference_Op); | |
2685 } | |
2686 } | |
2687 | |
2688 GapRects LayoutBlockFlow::selectionGaps(const LayoutBlock* rootBlock, const Layo
utPoint& rootBlockPhysicalPosition, | |
2689 const LayoutSize& offsetFromRootBlock, LayoutUnit& lastLogicalTop, LayoutUni
t& lastLogicalLeft, LayoutUnit& lastLogicalRight, | |
2690 const PaintInfo* paintInfo, ClipScope* clipScope) const | |
2691 { | |
2692 // IMPORTANT: Callers of this method that intend for painting to happen need
to do a save/restore. | |
2693 if (clipScope) { | |
2694 // Note that we don't clip out overflow for positioned objects. We just
stick to the border box. | |
2695 LayoutRect flippedBlockRect(LayoutPoint(offsetFromRootBlock), size()); | |
2696 rootBlock->flipForWritingMode(flippedBlockRect); | |
2697 flippedBlockRect.moveBy(rootBlockPhysicalPosition); | |
2698 clipOutPositionedObjects(*clipScope, flippedBlockRect.location(), positi
onedObjects()); | |
2699 if (isBody() || isDocumentElement()) // The <body> must make sure to exa
mine its containingBlock's positioned objects. | |
2700 for (LayoutBlock* cb = containingBlock(); cb && !cb->isLayoutView();
cb = cb->containingBlock()) | |
2701 clipOutPositionedObjects(*clipScope, cb->location(), cb->positio
nedObjects()); // FIXME: Not right for flipped writing modes. | |
2702 clipOutFloatingObjects(rootBlock, *clipScope, rootBlockPhysicalPosition,
offsetFromRootBlock); | |
2703 } | |
2704 | |
2705 GapRects result; | |
2706 | |
2707 if (hasTransformRelatedProperty() || style()->columnSpan()) | |
2708 return result; | |
2709 | |
2710 if (childrenInline()) | |
2711 result = inlineSelectionGaps(rootBlock, rootBlockPhysicalPosition, offse
tFromRootBlock, lastLogicalTop, lastLogicalLeft, lastLogicalRight, paintInfo); | |
2712 else | |
2713 result = blockSelectionGaps(rootBlock, rootBlockPhysicalPosition, offset
FromRootBlock, lastLogicalTop, lastLogicalLeft, lastLogicalRight, paintInfo); | |
2714 | |
2715 // Go ahead and fill the vertical gap all the way to the bottom of our block
if the selection extends past our block. | |
2716 if (rootBlock == this && (selectionState() != SelectionBoth && selectionStat
e() != SelectionEnd)) { | |
2717 result.uniteCenter(blockSelectionGap(rootBlock, rootBlockPhysicalPositio
n, offsetFromRootBlock, | |
2718 lastLogicalTop, lastLogicalLeft, lastLogicalRight, logicalHeight(),
paintInfo)); | |
2719 } | |
2720 return result; | |
2721 } | |
2722 | |
2723 | |
2724 GapRects LayoutBlockFlow::inlineSelectionGaps(const LayoutBlock* rootBlock, cons
t LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock, | |
2725 LayoutUnit& lastLogicalTop, LayoutUnit& lastLogicalLeft, LayoutUnit& lastLog
icalRight, const PaintInfo* paintInfo) const | |
2726 { | |
2727 GapRects result; | |
2728 | |
2729 bool containsStart = selectionState() == SelectionStart || selectionState()
== SelectionBoth; | |
2730 | |
2731 if (!firstLineBox()) { | |
2732 if (containsStart) { | |
2733 // Go ahead and update our lastLogicalTop to be the bottom of the bl
ock. <hr>s or empty blocks with height can trip this | |
2734 // case. | |
2735 lastLogicalTop = rootBlock->blockDirectionOffset(offsetFromRootBlock
) + logicalHeight(); | |
2736 lastLogicalLeft = logicalLeftSelectionOffset(rootBlock, logicalHeigh
t()); | |
2737 lastLogicalRight = logicalRightSelectionOffset(rootBlock, logicalHei
ght()); | |
2738 } | |
2739 return result; | |
2740 } | |
2741 | |
2742 RootInlineBox* lastSelectedLine = nullptr; | |
2743 RootInlineBox* curr; | |
2744 for (curr = firstRootBox(); curr && !curr->hasSelectedChildren(); curr = cur
r->nextRootBox()) { } | |
2745 | |
2746 // Now paint the gaps for the lines. | |
2747 for (; curr && curr->hasSelectedChildren(); curr = curr->nextRootBox()) { | |
2748 LayoutUnit selTop = curr->selectionTopAdjustedForPrecedingBlock(); | |
2749 LayoutUnit selHeight = curr->selectionHeightAdjustedForPrecedingBlock(); | |
2750 | |
2751 if (!containsStart && !lastSelectedLine && selectionState() != Selection
Start && selectionState() != SelectionBoth) { | |
2752 result.uniteCenter(blockSelectionGap(rootBlock, rootBlockPhysicalPos
ition, offsetFromRootBlock, lastLogicalTop, | |
2753 lastLogicalLeft, lastLogicalRight, selTop, paintInfo)); | |
2754 } | |
2755 | |
2756 LayoutRect logicalRect(curr->logicalLeft(), selTop, curr->logicalWidth()
, selTop + selHeight); | |
2757 logicalRect.move(isHorizontalWritingMode() ? offsetFromRootBlock : offse
tFromRootBlock.transposedSize()); | |
2758 LayoutRect physicalRect = rootBlock->logicalRectToPhysicalRect(rootBlock
PhysicalPosition, logicalRect); | |
2759 if (!paintInfo || paintInfo->cullRect().intersectsCullRect(enclosingIntR
ect(physicalRect))) | |
2760 result.unite(curr->lineSelectionGap(rootBlock, rootBlockPhysicalPosi
tion, offsetFromRootBlock, selTop, selHeight, paintInfo)); | |
2761 | |
2762 lastSelectedLine = curr; | |
2763 } | |
2764 | |
2765 if (containsStart && !lastSelectedLine) { | |
2766 // VisibleSelection must start just after our last line. | |
2767 lastSelectedLine = lastRootBox(); | |
2768 } | |
2769 | |
2770 if (lastSelectedLine && selectionState() != SelectionEnd && selectionState()
!= SelectionBoth) { | |
2771 // Go ahead and update our lastY to be the bottom of the last selected l
ine. | |
2772 lastLogicalTop = rootBlock->blockDirectionOffset(offsetFromRootBlock) +
lastSelectedLine->selectionBottom(); | |
2773 lastLogicalLeft = logicalLeftSelectionOffset(rootBlock, lastSelectedLine
->selectionBottom()); | |
2774 lastLogicalRight = logicalRightSelectionOffset(rootBlock, lastSelectedLi
ne->selectionBottom()); | |
2775 } | |
2776 return result; | |
2777 } | |
2778 | |
2779 IntRect alignSelectionRectToDevicePixels(LayoutRect& rect) | 2641 IntRect alignSelectionRectToDevicePixels(LayoutRect& rect) |
2780 { | 2642 { |
2781 LayoutUnit roundedX = rect.x().round(); | 2643 LayoutUnit roundedX = rect.x().round(); |
2782 return IntRect(roundedX, rect.y().round(), | 2644 return IntRect(roundedX, rect.y().round(), |
2783 (rect.maxX() - roundedX).round(), | 2645 (rect.maxX() - roundedX).round(), |
2784 snapSizeToPixel(rect.height(), rect.y())); | 2646 snapSizeToPixel(rect.height(), rect.y())); |
2785 } | 2647 } |
2786 | 2648 |
2787 bool LayoutBlockFlow::shouldPaintSelectionGaps() const | |
2788 { | |
2789 if (RuntimeEnabledFeatures::selectionPaintingWithoutSelectionGapsEnabled()) | |
2790 return false; | |
2791 return selectionState() != SelectionNone && style()->visibility() == VISIBLE
&& isSelectionRoot(); | |
2792 } | |
2793 | |
2794 LayoutRect LayoutBlockFlow::blockSelectionGap(const LayoutBlock* rootBlock, cons
t LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock, | |
2795 LayoutUnit lastLogicalTop, LayoutUnit lastLogicalLeft, LayoutUnit lastLogica
lRight, LayoutUnit logicalBottom, const PaintInfo* paintInfo) const | |
2796 { | |
2797 LayoutUnit logicalTop = lastLogicalTop; | |
2798 LayoutUnit logicalHeight = rootBlock->blockDirectionOffset(offsetFromRootBlo
ck) + logicalBottom - logicalTop; | |
2799 if (logicalHeight <= 0) | |
2800 return LayoutRect(); | |
2801 | |
2802 // Get the selection offsets for the bottom of the gap | |
2803 LayoutUnit logicalLeft = std::max(lastLogicalLeft, logicalLeftSelectionOffse
t(rootBlock, logicalBottom)); | |
2804 LayoutUnit logicalRight = std::min(lastLogicalRight, logicalRightSelectionOf
fset(rootBlock, logicalBottom)); | |
2805 LayoutUnit logicalWidth = logicalRight - logicalLeft; | |
2806 if (logicalWidth <= 0) | |
2807 return LayoutRect(); | |
2808 | |
2809 LayoutRect gapRect = rootBlock->logicalRectToPhysicalRect(rootBlockPhysicalP
osition, LayoutRect(logicalLeft, logicalTop, logicalWidth, logicalHeight)); | |
2810 if (paintInfo) { | |
2811 IntRect selectionGapRect = alignSelectionRectToDevicePixels(gapRect); | |
2812 paintInfo->context.fillRect(selectionGapRect, selectionBackgroundColor()
); | |
2813 } | |
2814 return gapRect; | |
2815 } | |
2816 | |
2817 GapRects LayoutBlockFlow::blockSelectionGaps(const LayoutBlock* rootBlock, const
LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock, | |
2818 LayoutUnit& lastLogicalTop, LayoutUnit& lastLogicalLeft, LayoutUnit& lastLog
icalRight, const PaintInfo* paintInfo) const | |
2819 { | |
2820 GapRects result; | |
2821 | |
2822 // Go ahead and jump right to the first block child that contains some selec
ted objects. | |
2823 LayoutBox* curr; | |
2824 for (curr = firstChildBox(); curr && curr->selectionState() == SelectionNone
; curr = curr->nextSiblingBox()) { } | |
2825 | |
2826 for (bool sawSelectionEnd = false; curr && !sawSelectionEnd; curr = curr->ne
xtSiblingBox()) { | |
2827 SelectionState childState = curr->selectionState(); | |
2828 if (childState == SelectionBoth || childState == SelectionEnd) | |
2829 sawSelectionEnd = true; | |
2830 | |
2831 if (curr->isFloatingOrOutOfFlowPositioned()) | |
2832 continue; // We must be a normal flow object in order to even be con
sidered. | |
2833 | |
2834 if (curr->isInFlowPositioned() && curr->hasLayer()) { | |
2835 // If the relposition offset is anything other than 0, then treat th
is just like an absolute positioned element. | |
2836 // Just disregard it completely. | |
2837 LayoutSize relOffset = curr->layer()->offsetForInFlowPosition(); | |
2838 if (relOffset.width() || relOffset.height()) | |
2839 continue; | |
2840 } | |
2841 | |
2842 bool paintsOwnSelection = curr->shouldPaintSelectionGaps() || curr->isTa
ble(); // FIXME: Eventually we won't special-case table like this. | |
2843 bool fillBlockGaps = paintsOwnSelection || (curr->canBeSelectionLeaf() &
& childState != SelectionNone); | |
2844 if (fillBlockGaps) { | |
2845 // We need to fill the vertical gap above this object. | |
2846 if (childState == SelectionEnd || childState == SelectionInside) { | |
2847 // Fill the gap above the object. | |
2848 result.uniteCenter(blockSelectionGap(rootBlock, rootBlockPhysica
lPosition, offsetFromRootBlock, lastLogicalTop, lastLogicalLeft, lastLogicalRigh
t, | |
2849 curr->logicalTop(), paintInfo)); | |
2850 } | |
2851 | |
2852 // Only fill side gaps for objects that paint their own selection if
we know for sure the selection is going to extend all the way *past* | |
2853 // our object. We know this if the selection did not end inside our
object. | |
2854 if (paintsOwnSelection && (childState == SelectionStart || sawSelect
ionEnd)) | |
2855 childState = SelectionNone; | |
2856 | |
2857 // Fill side gaps on this object based off its state. | |
2858 bool leftGap, rightGap; | |
2859 getSelectionGapInfo(childState, leftGap, rightGap); | |
2860 | |
2861 if (leftGap) | |
2862 result.uniteLeft(logicalLeftSelectionGap(rootBlock, rootBlockPhy
sicalPosition, offsetFromRootBlock, LineLayoutItem(const_cast<LayoutBlockFlow*>(
this)), curr->logicalLeft(), curr->logicalTop(), curr->logicalHeight(), paintInf
o)); | |
2863 if (rightGap) | |
2864 result.uniteRight(logicalRightSelectionGap(rootBlock, rootBlockP
hysicalPosition, offsetFromRootBlock, LineLayoutItem(const_cast<LayoutBlockFlow*
>(this)), curr->logicalRight(), curr->logicalTop(), curr->logicalHeight(), paint
Info)); | |
2865 | |
2866 // Update lastLogicalTop to be just underneath the object. lastLogi
calLeft and lastLogicalRight extend as far as | |
2867 // they can without bumping into floating or positioned objects. Id
eally they will go right up | |
2868 // to the border of the root selection block. | |
2869 lastLogicalTop = rootBlock->blockDirectionOffset(offsetFromRootBlock
) + curr->logicalBottom(); | |
2870 lastLogicalLeft = logicalLeftSelectionOffset(rootBlock, curr->logica
lBottom()); | |
2871 lastLogicalRight = logicalRightSelectionOffset(rootBlock, curr->logi
calBottom()); | |
2872 } else if (childState != SelectionNone && curr->isLayoutBlockFlow()) { | |
2873 // We must be a block that has some selected object inside it. Go a
head and recur. | |
2874 result.unite(toLayoutBlockFlow(curr)->selectionGaps(rootBlock, rootB
lockPhysicalPosition, LayoutSize(offsetFromRootBlock.width() + curr->location().
x(), offsetFromRootBlock.height() + curr->location().y()), | |
2875 lastLogicalTop, lastLogicalLeft, lastLogicalRight, paintInfo)); | |
2876 } | |
2877 } | |
2878 return result; | |
2879 } | |
2880 | |
2881 LayoutRect LayoutBlockFlow::logicalLeftSelectionGap(const LayoutBlock* rootBlock
, const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRoot
Block, | |
2882 const LineLayoutItem selObj, LayoutUnit logicalLeft, LayoutUnit logicalTop,
LayoutUnit logicalHeight, const PaintInfo* paintInfo) const | |
2883 { | |
2884 LayoutUnit rootBlockLogicalTop = rootBlock->blockDirectionOffset(offsetFromR
ootBlock) + logicalTop; | |
2885 LayoutUnit rootBlockLogicalLeft = std::max(logicalLeftSelectionOffset(rootBl
ock, logicalTop), logicalLeftSelectionOffset(rootBlock, logicalTop + logicalHeig
ht)); | |
2886 LayoutUnit rootBlockLogicalRight = std::min(rootBlock->inlineDirectionOffset
(offsetFromRootBlock) + logicalLeft, std::min(logicalRightSelectionOffset(rootBl
ock, logicalTop), logicalRightSelectionOffset(rootBlock, logicalTop + logicalHei
ght))); | |
2887 LayoutUnit rootBlockLogicalWidth = rootBlockLogicalRight - rootBlockLogicalL
eft; | |
2888 if (rootBlockLogicalWidth <= 0) | |
2889 return LayoutRect(); | |
2890 | |
2891 LayoutRect gapRect = rootBlock->logicalRectToPhysicalRect(rootBlockPhysicalP
osition, LayoutRect(rootBlockLogicalLeft, rootBlockLogicalTop, rootBlockLogicalW
idth, logicalHeight)); | |
2892 if (paintInfo) { | |
2893 IntRect selectionGapRect = alignSelectionRectToDevicePixels(gapRect); | |
2894 paintInfo->context.fillRect(selectionGapRect, selObj.selectionBackground
Color()); | |
2895 } | |
2896 return gapRect; | |
2897 } | |
2898 | |
2899 LayoutRect LayoutBlockFlow::logicalRightSelectionGap(const LayoutBlock* rootBloc
k, const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRoo
tBlock, | |
2900 const LineLayoutItem selObj, LayoutUnit logicalRight, LayoutUnit logicalTop,
LayoutUnit logicalHeight, const PaintInfo* paintInfo) const | |
2901 { | |
2902 LayoutUnit rootBlockLogicalTop = rootBlock->blockDirectionOffset(offsetFromR
ootBlock) + logicalTop; | |
2903 LayoutUnit rootBlockLogicalLeft = std::max(rootBlock->inlineDirectionOffset(
offsetFromRootBlock) + logicalRight, max(logicalLeftSelectionOffset(rootBlock, l
ogicalTop), logicalLeftSelectionOffset(rootBlock, logicalTop + logicalHeight))); | |
2904 LayoutUnit rootBlockLogicalRight = std::min(logicalRightSelectionOffset(root
Block, logicalTop), logicalRightSelectionOffset(rootBlock, logicalTop + logicalH
eight)); | |
2905 LayoutUnit rootBlockLogicalWidth = rootBlockLogicalRight - rootBlockLogicalL
eft; | |
2906 if (rootBlockLogicalWidth <= 0) | |
2907 return LayoutRect(); | |
2908 | |
2909 LayoutRect gapRect = rootBlock->logicalRectToPhysicalRect(rootBlockPhysicalP
osition, LayoutRect(rootBlockLogicalLeft, rootBlockLogicalTop, rootBlockLogicalW
idth, logicalHeight)); | |
2910 if (paintInfo) { | |
2911 IntRect selectionGapRect = alignSelectionRectToDevicePixels(gapRect); | |
2912 paintInfo->context.fillRect(selectionGapRect, selObj.selectionBackground
Color()); | |
2913 } | |
2914 return gapRect; | |
2915 } | |
2916 | |
2917 void LayoutBlockFlow::getSelectionGapInfo(SelectionState state, bool& leftGap, b
ool& rightGap) const | |
2918 { | |
2919 bool ltr = style()->isLeftToRightDirection(); | |
2920 leftGap = (state == SelectionInside) | |
2921 || (state == SelectionEnd && ltr) | |
2922 || (state == SelectionStart && !ltr); | |
2923 rightGap = (state == SelectionInside) | |
2924 || (state == SelectionStart && ltr) | |
2925 || (state == SelectionEnd && !ltr); | |
2926 } | |
2927 | |
2928 bool LayoutBlockFlow::allowsPaginationStrut() const | 2649 bool LayoutBlockFlow::allowsPaginationStrut() const |
2929 { | 2650 { |
2930 // The block needs to be contained by a LayoutBlockFlow (and not by e.g. a f
lexbox, grid, or a | 2651 // The block needs to be contained by a LayoutBlockFlow (and not by e.g. a f
lexbox, grid, or a |
2931 // table (the latter being the case for table cell or table caption)). The r
eason for this | 2652 // table (the latter being the case for table cell or table caption)). The r
eason for this |
2932 // limitation is simply that LayoutBlockFlow child layout code is the only p
lace where we pick | 2653 // limitation is simply that LayoutBlockFlow child layout code is the only p
lace where we pick |
2933 // up the struts and handle them. We handle floats and regular in-flow child
ren, and that's | 2654 // up the struts and handle them. We handle floats and regular in-flow child
ren, and that's |
2934 // all. We could handle this in other layout modes as well (and even for out
-of-flow children), | 2655 // all. We could handle this in other layout modes as well (and even for out
-of-flow children), |
2935 // but currently we don't. | 2656 // but currently we don't. |
2936 // TODO(mstensho): But we *should*. | 2657 // TODO(mstensho): But we *should*. |
2937 if (isOutOfFlowPositioned()) | 2658 if (isOutOfFlowPositioned()) |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3124 FrameView* frameView = document().view(); | 2845 FrameView* frameView = document().view(); |
3125 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr
ollOffset().height(); | 2846 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr
ollOffset().height(); |
3126 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height(
); | 2847 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height(
); |
3127 if (size().height() < visibleHeight) | 2848 if (size().height() < visibleHeight) |
3128 top += (visibleHeight - size().height()) / 2; | 2849 top += (visibleHeight - size().height()) / 2; |
3129 setY(top); | 2850 setY(top); |
3130 dialog->setCentered(top); | 2851 dialog->setCentered(top); |
3131 } | 2852 } |
3132 | 2853 |
3133 } // namespace blink | 2854 } // namespace blink |
OLD | NEW |