Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: Source/core/rendering/RenderBlockFlow.cpp

Issue 720313002: Push selection gaps logic down to RenderBlockFlow (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: move even MOAR! Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/rendering/RenderBlockFlow.h ('k') | Source/core/rendering/RenderLayer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 19 matching lines...) Expand all
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "core/rendering/RenderBlockFlow.h" 32 #include "core/rendering/RenderBlockFlow.h"
33 33
34 #include "core/accessibility/AXObjectCache.h" 34 #include "core/accessibility/AXObjectCache.h"
35 #include "core/frame/FrameView.h" 35 #include "core/frame/FrameView.h"
36 #include "core/frame/LocalFrame.h" 36 #include "core/frame/LocalFrame.h"
37 #include "core/frame/Settings.h" 37 #include "core/frame/Settings.h"
38 #include "core/html/HTMLDialogElement.h" 38 #include "core/html/HTMLDialogElement.h"
39 #include "core/paint/BlockFlowPainter.h" 39 #include "core/paint/BlockFlowPainter.h"
40 #include "core/paint/DrawingRecorder.h"
40 #include "core/rendering/HitTestLocation.h" 41 #include "core/rendering/HitTestLocation.h"
41 #include "core/rendering/RenderFlowThread.h" 42 #include "core/rendering/RenderFlowThread.h"
42 #include "core/rendering/RenderLayer.h" 43 #include "core/rendering/RenderLayer.h"
43 #include "core/rendering/RenderMultiColumnFlowThread.h" 44 #include "core/rendering/RenderMultiColumnFlowThread.h"
44 #include "core/rendering/RenderPagedFlowThread.h" 45 #include "core/rendering/RenderPagedFlowThread.h"
45 #include "core/rendering/RenderText.h" 46 #include "core/rendering/RenderText.h"
46 #include "core/rendering/RenderView.h" 47 #include "core/rendering/RenderView.h"
47 #include "core/rendering/TextAutosizer.h" 48 #include "core/rendering/TextAutosizer.h"
48 #include "core/rendering/line/LineWidth.h" 49 #include "core/rendering/line/LineWidth.h"
50 #include "platform/geometry/TransformState.h"
49 #include "platform/text/BidiTextRun.h" 51 #include "platform/text/BidiTextRun.h"
50 52
51 namespace blink { 53 namespace blink {
52 54
53 bool RenderBlockFlow::s_canPropagateFloatIntoSibling = false; 55 bool RenderBlockFlow::s_canPropagateFloatIntoSibling = false;
54 56
55 struct SameSizeAsMarginInfo { 57 struct SameSizeAsMarginInfo {
56 uint16_t bitfields; 58 uint16_t bitfields;
57 LayoutUnit margins[2]; 59 LayoutUnit margins[2];
58 }; 60 };
(...skipping 2039 matching lines...) Expand 10 before | Expand all | Expand 10 after
2098 2100
2099 m_paintInvalidationLogicalTop = 0; 2101 m_paintInvalidationLogicalTop = 0;
2100 m_paintInvalidationLogicalBottom = 0; 2102 m_paintInvalidationLogicalBottom = 0;
2101 } 2103 }
2102 2104
2103 void RenderBlockFlow::paintFloats(PaintInfo& paintInfo, const LayoutPoint& paint Offset, bool preservePhase) 2105 void RenderBlockFlow::paintFloats(PaintInfo& paintInfo, const LayoutPoint& paint Offset, bool preservePhase)
2104 { 2106 {
2105 BlockFlowPainter(*this).paintFloats(paintInfo, paintOffset, preservePhase); 2107 BlockFlowPainter(*this).paintFloats(paintInfo, paintOffset, preservePhase);
2106 } 2108 }
2107 2109
2110 void RenderBlockFlow::paintSelection(PaintInfo& paintInfo, const LayoutPoint& pa intOffset)
2111 {
2112 BlockFlowPainter(*this).paintSelection(paintInfo, paintOffset);
2113 }
2114
2108 void RenderBlockFlow::clipOutFloatingObjects(const RenderBlock* rootBlock, const PaintInfo* paintInfo, const LayoutPoint& rootBlockPhysicalPosition, const Layou tSize& offsetFromRootBlock) const 2115 void RenderBlockFlow::clipOutFloatingObjects(const RenderBlock* rootBlock, const PaintInfo* paintInfo, const LayoutPoint& rootBlockPhysicalPosition, const Layou tSize& offsetFromRootBlock) const
2109 { 2116 {
2110 if (m_floatingObjects) { 2117 if (m_floatingObjects) {
2111 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); 2118 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
2112 FloatingObjectSetIterator end = floatingObjectSet.end(); 2119 FloatingObjectSetIterator end = floatingObjectSet.end();
2113 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end ; ++it) { 2120 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end ; ++it) {
2114 FloatingObject* floatingObject = it->get(); 2121 FloatingObject* floatingObject = it->get();
2115 LayoutRect floatBox(offsetFromRootBlock.width() + xPositionForFloatI ncludingMargin(floatingObject), 2122 LayoutRect floatBox(offsetFromRootBlock.width() + xPositionForFloatI ncludingMargin(floatingObject),
2116 offsetFromRootBlock.height() + yPositionForFloatIncludingMargin( floatingObject), 2123 offsetFromRootBlock.height() + yPositionForFloatIncludingMargin( floatingObject),
2117 floatingObject->renderer()->width(), floatingObject->renderer()- >height()); 2124 floatingObject->renderer()->width(), floatingObject->renderer()- >height());
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
2637 } 2644 }
2638 2645
2639 LayoutUnit RenderBlockFlow::logicalRightFloatOffsetForLine(LayoutUnit logicalTop , LayoutUnit fixedOffset, LayoutUnit logicalHeight) const 2646 LayoutUnit RenderBlockFlow::logicalRightFloatOffsetForLine(LayoutUnit logicalTop , LayoutUnit fixedOffset, LayoutUnit logicalHeight) const
2640 { 2647 {
2641 if (m_floatingObjects && m_floatingObjects->hasRightObjects()) 2648 if (m_floatingObjects && m_floatingObjects->hasRightObjects())
2642 return m_floatingObjects->logicalRightOffset(fixedOffset, logicalTop, lo gicalHeight); 2649 return m_floatingObjects->logicalRightOffset(fixedOffset, logicalTop, lo gicalHeight);
2643 2650
2644 return fixedOffset; 2651 return fixedOffset;
2645 } 2652 }
2646 2653
2654 LayoutRect RenderBlockFlow::selectionRectForPaintInvalidation(const RenderLayerM odelObject* paintInvalidationContainer) const
2655 {
2656 LayoutRect rect = selectionGapRectsForPaintInvalidation(paintInvalidationCon tainer);
2657 // FIXME: groupedMapping() leaks the squashing abstraction.
2658 if (paintInvalidationContainer->layer()->groupedMapping())
2659 RenderLayer::mapRectToPaintBackingCoordinates(paintInvalidationContainer , rect);
2660 return rect;
2661 }
2662
2663 GapRects RenderBlockFlow::selectionGapRectsForPaintInvalidation(const RenderLaye rModelObject* paintInvalidationContainer) const
2664 {
2665 ASSERT(!needsLayout());
2666
2667 if (!shouldPaintSelectionGaps())
2668 return GapRects();
2669
2670 TransformState transformState(TransformState::ApplyTransformDirection, Float Point());
2671 mapLocalToContainer(paintInvalidationContainer, transformState, ApplyContain erFlip | UseTransforms);
2672 LayoutPoint offsetFromPaintInvalidationContainer = roundedLayoutPoint(transf ormState.mappedPoint());
2673
2674 if (hasOverflowClip())
2675 offsetFromPaintInvalidationContainer -= scrolledContentOffset();
2676
2677 LayoutUnit lastTop = 0;
2678 LayoutUnit lastLeft = logicalLeftSelectionOffset(this, lastTop);
2679 LayoutUnit lastRight = logicalRightSelectionOffset(this, lastTop);
2680
2681 return selectionGaps(this, offsetFromPaintInvalidationContainer, IntSize(), lastTop, lastLeft, lastRight);
2682 }
2683
2684 static void clipOutPositionedObjects(const PaintInfo& paintInfo, const LayoutPoi nt& offset, TrackedRendererListHashSet* positionedObjects)
2685 {
2686 if (!positionedObjects)
2687 return;
2688
2689 TrackedRendererListHashSet::const_iterator end = positionedObjects->end();
2690 for (TrackedRendererListHashSet::const_iterator it = positionedObjects->begi n(); it != end; ++it) {
2691 RenderBox* r = *it;
2692 paintInfo.context->clipOut(IntRect(offset.x() + r->x(), offset.y() + r-> y(), r->width(), r->height()));
2693 }
2694 }
2695
2696 GapRects RenderBlockFlow::selectionGaps(const RenderBlock* rootBlock, const Layo utPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock,
2697 LayoutUnit& lastLogicalTop, LayoutUnit& lastLogicalLeft, LayoutUnit& lastLog icalRight, const PaintInfo* paintInfo) const
2698 {
2699 // IMPORTANT: Callers of this method that intend for painting to happen need to do a save/restore.
2700 if (paintInfo) {
2701 // Note that we don't clip out overflow for positioned objects. We just stick to the border box.
2702 LayoutRect flippedBlockRect(offsetFromRootBlock.width(), offsetFromRootB lock.height(), width(), height());
2703 rootBlock->flipForWritingMode(flippedBlockRect);
2704 flippedBlockRect.moveBy(rootBlockPhysicalPosition);
2705 clipOutPositionedObjects(*paintInfo, flippedBlockRect.location(), positi onedObjects());
2706 if (isBody() || isDocumentElement()) // The <body> must make sure to exa mine its containingBlock's positioned objects.
2707 for (RenderBlock* cb = containingBlock(); cb && !cb->isRenderView(); cb = cb->containingBlock())
2708 clipOutPositionedObjects(*paintInfo, LayoutPoint(cb->x(), cb->y( )), cb->positionedObjects()); // FIXME: Not right for flipped writing modes.
2709 clipOutFloatingObjects(rootBlock, paintInfo, rootBlockPhysicalPosition, offsetFromRootBlock);
2710 }
2711
2712 GapRects result;
2713
2714 if (hasColumns() || hasTransformRelatedProperty() || style()->columnSpan())
2715 return result;
2716
2717 if (childrenInline())
2718 result = inlineSelectionGaps(rootBlock, rootBlockPhysicalPosition, offse tFromRootBlock, lastLogicalTop, lastLogicalLeft, lastLogicalRight, paintInfo);
2719 else
2720 result = blockSelectionGaps(rootBlock, rootBlockPhysicalPosition, offset FromRootBlock, lastLogicalTop, lastLogicalLeft, lastLogicalRight, paintInfo);
2721
2722 // Go ahead and fill the vertical gap all the way to the bottom of our block if the selection extends past our block.
2723 if (rootBlock == this && (selectionState() != SelectionBoth && selectionStat e() != SelectionEnd)) {
2724 result.uniteCenter(blockSelectionGap(rootBlock, rootBlockPhysicalPositio n, offsetFromRootBlock,
2725 lastLogicalTop, lastLogicalLeft, lastLogicalRight, logicalHeight(), paintInfo));
2726 }
2727 return result;
2728 }
2729
2730
2647 GapRects RenderBlockFlow::inlineSelectionGaps(const RenderBlock* rootBlock, cons t LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock, 2731 GapRects RenderBlockFlow::inlineSelectionGaps(const RenderBlock* rootBlock, cons t LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock,
2648 LayoutUnit& lastLogicalTop, LayoutUnit& lastLogicalLeft, LayoutUnit& lastLog icalRight, const PaintInfo* paintInfo) const 2732 LayoutUnit& lastLogicalTop, LayoutUnit& lastLogicalLeft, LayoutUnit& lastLog icalRight, const PaintInfo* paintInfo) const
2649 { 2733 {
2650 GapRects result; 2734 GapRects result;
2651 2735
2652 bool containsStart = selectionState() == SelectionStart || selectionState() == SelectionBoth; 2736 bool containsStart = selectionState() == SelectionStart || selectionState() == SelectionBoth;
2653 2737
2654 if (!firstLineBox()) { 2738 if (!firstLineBox()) {
2655 if (containsStart) { 2739 if (containsStart) {
2656 // Go ahead and update our lastLogicalTop to be the bottom of the bl ock. <hr>s or empty blocks with height can trip this 2740 // Go ahead and update our lastLogicalTop to be the bottom of the bl ock. <hr>s or empty blocks with height can trip this
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2693 2777
2694 if (lastSelectedLine && selectionState() != SelectionEnd && selectionState() != SelectionBoth) { 2778 if (lastSelectedLine && selectionState() != SelectionEnd && selectionState() != SelectionBoth) {
2695 // Go ahead and update our lastY to be the bottom of the last selected l ine. 2779 // Go ahead and update our lastY to be the bottom of the last selected l ine.
2696 lastLogicalTop = rootBlock->blockDirectionOffset(offsetFromRootBlock) + lastSelectedLine->selectionBottom(); 2780 lastLogicalTop = rootBlock->blockDirectionOffset(offsetFromRootBlock) + lastSelectedLine->selectionBottom();
2697 lastLogicalLeft = logicalLeftSelectionOffset(rootBlock, lastSelectedLine ->selectionBottom()); 2781 lastLogicalLeft = logicalLeftSelectionOffset(rootBlock, lastSelectedLine ->selectionBottom());
2698 lastLogicalRight = logicalRightSelectionOffset(rootBlock, lastSelectedLi ne->selectionBottom()); 2782 lastLogicalRight = logicalRightSelectionOffset(rootBlock, lastSelectedLi ne->selectionBottom());
2699 } 2783 }
2700 return result; 2784 return result;
2701 } 2785 }
2702 2786
2787 IntRect alignSelectionRectToDevicePixels(LayoutRect& rect)
2788 {
2789 LayoutUnit roundedX = rect.x().round();
2790 return IntRect(roundedX, rect.y().round(),
2791 (rect.maxX() - roundedX).round(),
2792 snapSizeToPixel(rect.height(), rect.y()));
2793 }
2794
2795 bool RenderBlockFlow::shouldPaintSelectionGaps() const
2796 {
2797 return selectionState() != SelectionNone && style()->visibility() == VISIBLE && isSelectionRoot();
2798 }
2799
2800 LayoutRect RenderBlockFlow::blockSelectionGap(const RenderBlock* rootBlock, cons t LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock,
2801 LayoutUnit lastLogicalTop, LayoutUnit lastLogicalLeft, LayoutUnit lastLogica lRight, LayoutUnit logicalBottom, const PaintInfo* paintInfo) const
2802 {
2803 LayoutUnit logicalTop = lastLogicalTop;
2804 LayoutUnit logicalHeight = rootBlock->blockDirectionOffset(offsetFromRootBlo ck) + logicalBottom - logicalTop;
2805 if (logicalHeight <= 0)
2806 return LayoutRect();
2807
2808 // Get the selection offsets for the bottom of the gap
2809 LayoutUnit logicalLeft = std::max(lastLogicalLeft, logicalLeftSelectionOffse t(rootBlock, logicalBottom));
2810 LayoutUnit logicalRight = std::min(lastLogicalRight, logicalRightSelectionOf fset(rootBlock, logicalBottom));
2811 LayoutUnit logicalWidth = logicalRight - logicalLeft;
2812 if (logicalWidth <= 0)
2813 return LayoutRect();
2814
2815 LayoutRect gapRect = rootBlock->logicalRectToPhysicalRect(rootBlockPhysicalP osition, LayoutRect(logicalLeft, logicalTop, logicalWidth, logicalHeight));
2816 if (paintInfo) {
2817 IntRect selectionGapRect = alignSelectionRectToDevicePixels(gapRect);
2818 DrawingRecorder recorder(paintInfo->context, this, paintInfo->phase, sel ectionGapRect);
2819 paintInfo->context->fillRect(selectionGapRect, selectionBackgroundColor( ));
2820 }
2821 return gapRect;
2822 }
2823
2824 GapRects RenderBlockFlow::blockSelectionGaps(const RenderBlock* rootBlock, const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock,
2825 LayoutUnit& lastLogicalTop, LayoutUnit& lastLogicalLeft, LayoutUnit& lastLog icalRight, const PaintInfo* paintInfo) const
2826 {
2827 GapRects result;
2828
2829 // Go ahead and jump right to the first block child that contains some selec ted objects.
2830 RenderBox* curr;
2831 for (curr = firstChildBox(); curr && curr->selectionState() == SelectionNone ; curr = curr->nextSiblingBox()) { }
2832
2833 for (bool sawSelectionEnd = false; curr && !sawSelectionEnd; curr = curr->ne xtSiblingBox()) {
2834 SelectionState childState = curr->selectionState();
2835 if (childState == SelectionBoth || childState == SelectionEnd)
2836 sawSelectionEnd = true;
2837
2838 if (curr->isFloatingOrOutOfFlowPositioned())
2839 continue; // We must be a normal flow object in order to even be con sidered.
2840
2841 if (curr->isRelPositioned() && curr->hasLayer()) {
2842 // If the relposition offset is anything other than 0, then treat th is just like an absolute positioned element.
2843 // Just disregard it completely.
2844 LayoutSize relOffset = curr->layer()->offsetForInFlowPosition();
2845 if (relOffset.width() || relOffset.height())
2846 continue;
2847 }
2848
2849 bool paintsOwnSelection = curr->shouldPaintSelectionGaps() || curr->isTa ble(); // FIXME: Eventually we won't special-case table like this.
2850 bool fillBlockGaps = paintsOwnSelection || (curr->canBeSelectionLeaf() & & childState != SelectionNone);
2851 if (fillBlockGaps) {
2852 // We need to fill the vertical gap above this object.
2853 if (childState == SelectionEnd || childState == SelectionInside) {
2854 // Fill the gap above the object.
2855 result.uniteCenter(blockSelectionGap(rootBlock, rootBlockPhysica lPosition, offsetFromRootBlock, lastLogicalTop, lastLogicalLeft, lastLogicalRigh t,
2856 curr->logicalTop(), paintInfo));
2857 }
2858
2859 // 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*
2860 // our object. We know this if the selection did not end inside our object.
2861 if (paintsOwnSelection && (childState == SelectionStart || sawSelect ionEnd))
2862 childState = SelectionNone;
2863
2864 // Fill side gaps on this object based off its state.
2865 bool leftGap, rightGap;
2866 getSelectionGapInfo(childState, leftGap, rightGap);
2867
2868 if (leftGap)
2869 result.uniteLeft(logicalLeftSelectionGap(rootBlock, rootBlockPhy sicalPosition, offsetFromRootBlock, this, curr->logicalLeft(), curr->logicalTop( ), curr->logicalHeight(), paintInfo));
2870 if (rightGap)
2871 result.uniteRight(logicalRightSelectionGap(rootBlock, rootBlockP hysicalPosition, offsetFromRootBlock, this, curr->logicalRight(), curr->logicalT op(), curr->logicalHeight(), paintInfo));
2872
2873 // Update lastLogicalTop to be just underneath the object. lastLogi calLeft and lastLogicalRight extend as far as
2874 // they can without bumping into floating or positioned objects. Id eally they will go right up
2875 // to the border of the root selection block.
2876 lastLogicalTop = rootBlock->blockDirectionOffset(offsetFromRootBlock ) + curr->logicalBottom();
2877 lastLogicalLeft = logicalLeftSelectionOffset(rootBlock, curr->logica lBottom());
2878 lastLogicalRight = logicalRightSelectionOffset(rootBlock, curr->logi calBottom());
2879 } else if (childState != SelectionNone && curr->isRenderBlockFlow()) {
2880 // We must be a block that has some selected object inside it. Go a head and recur.
2881 result.unite(toRenderBlockFlow(curr)->selectionGaps(rootBlock, rootB lockPhysicalPosition, LayoutSize(offsetFromRootBlock.width() + curr->x(), offset FromRootBlock.height() + curr->y()),
2882 lastLogicalTop, lastLogicalLeft, lastLogicalRight, paintInfo));
2883 }
2884 }
2885 return result;
2886 }
2887
2888 LayoutRect RenderBlockFlow::logicalLeftSelectionGap(const RenderBlock* rootBlock , const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRoot Block,
2889 const RenderObject* selObj, LayoutUnit logicalLeft, LayoutUnit logicalTop, L ayoutUnit logicalHeight, const PaintInfo* paintInfo) const
2890 {
2891 LayoutUnit rootBlockLogicalTop = rootBlock->blockDirectionOffset(offsetFromR ootBlock) + logicalTop;
2892 LayoutUnit rootBlockLogicalLeft = std::max(logicalLeftSelectionOffset(rootBl ock, logicalTop), logicalLeftSelectionOffset(rootBlock, logicalTop + logicalHeig ht));
2893 LayoutUnit rootBlockLogicalRight = std::min(rootBlock->inlineDirectionOffset (offsetFromRootBlock) + logicalLeft, std::min(logicalRightSelectionOffset(rootBl ock, logicalTop), logicalRightSelectionOffset(rootBlock, logicalTop + logicalHei ght)));
2894 LayoutUnit rootBlockLogicalWidth = rootBlockLogicalRight - rootBlockLogicalL eft;
2895 if (rootBlockLogicalWidth <= 0)
2896 return LayoutRect();
2897
2898 LayoutRect gapRect = rootBlock->logicalRectToPhysicalRect(rootBlockPhysicalP osition, LayoutRect(rootBlockLogicalLeft, rootBlockLogicalTop, rootBlockLogicalW idth, logicalHeight));
2899 if (paintInfo) {
2900 IntRect selectionGapRect = alignSelectionRectToDevicePixels(gapRect);
2901 DrawingRecorder recorder(paintInfo->context, this, paintInfo->phase, sel ectionGapRect);
2902 paintInfo->context->fillRect(selectionGapRect, selObj->selectionBackgrou ndColor());
2903 }
2904 return gapRect;
2905 }
2906
2907 LayoutRect RenderBlockFlow::logicalRightSelectionGap(const RenderBlock* rootBloc k, const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRoo tBlock,
2908 const RenderObject* selObj, LayoutUnit logicalRight, LayoutUnit logicalTop, LayoutUnit logicalHeight, const PaintInfo* paintInfo) const
2909 {
2910 LayoutUnit rootBlockLogicalTop = rootBlock->blockDirectionOffset(offsetFromR ootBlock) + logicalTop;
2911 LayoutUnit rootBlockLogicalLeft = std::max(rootBlock->inlineDirectionOffset( offsetFromRootBlock) + logicalRight, max(logicalLeftSelectionOffset(rootBlock, l ogicalTop), logicalLeftSelectionOffset(rootBlock, logicalTop + logicalHeight)));
2912 LayoutUnit rootBlockLogicalRight = std::min(logicalRightSelectionOffset(root Block, logicalTop), logicalRightSelectionOffset(rootBlock, logicalTop + logicalH eight));
2913 LayoutUnit rootBlockLogicalWidth = rootBlockLogicalRight - rootBlockLogicalL eft;
2914 if (rootBlockLogicalWidth <= 0)
2915 return LayoutRect();
2916
2917 LayoutRect gapRect = rootBlock->logicalRectToPhysicalRect(rootBlockPhysicalP osition, LayoutRect(rootBlockLogicalLeft, rootBlockLogicalTop, rootBlockLogicalW idth, logicalHeight));
2918 if (paintInfo) {
2919 IntRect selectionGapRect = alignSelectionRectToDevicePixels(gapRect);
2920 DrawingRecorder recorder(paintInfo->context, this, paintInfo->phase, sel ectionGapRect);
2921 paintInfo->context->fillRect(selectionGapRect, selObj->selectionBackgrou ndColor());
2922 }
2923 return gapRect;
2924 }
2925
2926 void RenderBlockFlow::getSelectionGapInfo(SelectionState state, bool& leftGap, b ool& rightGap) const
2927 {
2928 bool ltr = style()->isLeftToRightDirection();
2929 leftGap = (state == RenderObject::SelectionInside)
2930 || (state == RenderObject::SelectionEnd && ltr)
2931 || (state == RenderObject::SelectionStart && !ltr);
2932 rightGap = (state == RenderObject::SelectionInside)
2933 || (state == RenderObject::SelectionStart && ltr)
2934 || (state == RenderObject::SelectionEnd && !ltr);
2935 }
2936
2703 void RenderBlockFlow::setPaginationStrut(LayoutUnit strut) 2937 void RenderBlockFlow::setPaginationStrut(LayoutUnit strut)
2704 { 2938 {
2705 if (!m_rareData) { 2939 if (!m_rareData) {
2706 if (!strut) 2940 if (!strut)
2707 return; 2941 return;
2708 m_rareData = adoptPtrWillBeNoop(new RenderBlockFlowRareData(this)); 2942 m_rareData = adoptPtrWillBeNoop(new RenderBlockFlowRareData(this));
2709 } 2943 }
2710 m_rareData->m_paginationStrut = strut; 2944 m_rareData->m_paginationStrut = strut;
2711 } 2945 }
2712 2946
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
2844 FrameView* frameView = document().view(); 3078 FrameView* frameView = document().view();
2845 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr ollOffset().height(); 3079 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr ollOffset().height();
2846 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height( ); 3080 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height( );
2847 if (height() < visibleHeight) 3081 if (height() < visibleHeight)
2848 top += (visibleHeight - height()) / 2; 3082 top += (visibleHeight - height()) / 2;
2849 setY(top); 3083 setY(top);
2850 dialog->setCentered(top); 3084 dialog->setCentered(top);
2851 } 3085 }
2852 3086
2853 } // namespace blink 3087 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderBlockFlow.h ('k') | Source/core/rendering/RenderLayer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698