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

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

Issue 799563002: Use DrawingRecorder::canUseCachedDrawing (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years 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
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 2806 matching lines...) Expand 10 before | Expand all | Expand 10 after
2817 // Get the selection offsets for the bottom of the gap 2817 // Get the selection offsets for the bottom of the gap
2818 LayoutUnit logicalLeft = std::max(lastLogicalLeft, logicalLeftSelectionOffse t(rootBlock, logicalBottom)); 2818 LayoutUnit logicalLeft = std::max(lastLogicalLeft, logicalLeftSelectionOffse t(rootBlock, logicalBottom));
2819 LayoutUnit logicalRight = std::min(lastLogicalRight, logicalRightSelectionOf fset(rootBlock, logicalBottom)); 2819 LayoutUnit logicalRight = std::min(lastLogicalRight, logicalRightSelectionOf fset(rootBlock, logicalBottom));
2820 LayoutUnit logicalWidth = logicalRight - logicalLeft; 2820 LayoutUnit logicalWidth = logicalRight - logicalLeft;
2821 if (logicalWidth <= 0) 2821 if (logicalWidth <= 0)
2822 return LayoutRect(); 2822 return LayoutRect();
2823 2823
2824 LayoutRect gapRect = rootBlock->logicalRectToPhysicalRect(rootBlockPhysicalP osition, LayoutRect(logicalLeft, logicalTop, logicalWidth, logicalHeight)); 2824 LayoutRect gapRect = rootBlock->logicalRectToPhysicalRect(rootBlockPhysicalP osition, LayoutRect(logicalLeft, logicalTop, logicalWidth, logicalHeight));
2825 if (paintInfo) { 2825 if (paintInfo) {
2826 IntRect selectionGapRect = alignSelectionRectToDevicePixels(gapRect); 2826 IntRect selectionGapRect = alignSelectionRectToDevicePixels(gapRect);
2827 RenderDrawingRecorder recorder(paintInfo->context, this, paintInfo->phas e, selectionGapRect); 2827 RenderDrawingRecorder recorder(paintInfo->context, *this, paintInfo->pha se, selectionGapRect);
2828 paintInfo->context->fillRect(selectionGapRect, selectionBackgroundColor( )); 2828 if (!recorder.canUseCachedDrawing())
2829 paintInfo->context->fillRect(selectionGapRect, selectionBackgroundCo lor());
2829 } 2830 }
2830 return gapRect; 2831 return gapRect;
2831 } 2832 }
2832 2833
2833 GapRects RenderBlockFlow::blockSelectionGaps(const RenderBlock* rootBlock, const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock, 2834 GapRects RenderBlockFlow::blockSelectionGaps(const RenderBlock* rootBlock, const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock,
2834 LayoutUnit& lastLogicalTop, LayoutUnit& lastLogicalLeft, LayoutUnit& lastLog icalRight, const PaintInfo* paintInfo) const 2835 LayoutUnit& lastLogicalTop, LayoutUnit& lastLogicalLeft, LayoutUnit& lastLog icalRight, const PaintInfo* paintInfo) const
2835 { 2836 {
2836 GapRects result; 2837 GapRects result;
2837 2838
2838 // Go ahead and jump right to the first block child that contains some selec ted objects. 2839 // Go ahead and jump right to the first block child that contains some selec ted objects.
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
2900 LayoutUnit rootBlockLogicalTop = rootBlock->blockDirectionOffset(offsetFromR ootBlock) + logicalTop; 2901 LayoutUnit rootBlockLogicalTop = rootBlock->blockDirectionOffset(offsetFromR ootBlock) + logicalTop;
2901 LayoutUnit rootBlockLogicalLeft = std::max(logicalLeftSelectionOffset(rootBl ock, logicalTop), logicalLeftSelectionOffset(rootBlock, logicalTop + logicalHeig ht)); 2902 LayoutUnit rootBlockLogicalLeft = std::max(logicalLeftSelectionOffset(rootBl ock, logicalTop), logicalLeftSelectionOffset(rootBlock, logicalTop + logicalHeig ht));
2902 LayoutUnit rootBlockLogicalRight = std::min(rootBlock->inlineDirectionOffset (offsetFromRootBlock) + logicalLeft, std::min(logicalRightSelectionOffset(rootBl ock, logicalTop), logicalRightSelectionOffset(rootBlock, logicalTop + logicalHei ght))); 2903 LayoutUnit rootBlockLogicalRight = std::min(rootBlock->inlineDirectionOffset (offsetFromRootBlock) + logicalLeft, std::min(logicalRightSelectionOffset(rootBl ock, logicalTop), logicalRightSelectionOffset(rootBlock, logicalTop + logicalHei ght)));
2903 LayoutUnit rootBlockLogicalWidth = rootBlockLogicalRight - rootBlockLogicalL eft; 2904 LayoutUnit rootBlockLogicalWidth = rootBlockLogicalRight - rootBlockLogicalL eft;
2904 if (rootBlockLogicalWidth <= 0) 2905 if (rootBlockLogicalWidth <= 0)
2905 return LayoutRect(); 2906 return LayoutRect();
2906 2907
2907 LayoutRect gapRect = rootBlock->logicalRectToPhysicalRect(rootBlockPhysicalP osition, LayoutRect(rootBlockLogicalLeft, rootBlockLogicalTop, rootBlockLogicalW idth, logicalHeight)); 2908 LayoutRect gapRect = rootBlock->logicalRectToPhysicalRect(rootBlockPhysicalP osition, LayoutRect(rootBlockLogicalLeft, rootBlockLogicalTop, rootBlockLogicalW idth, logicalHeight));
2908 if (paintInfo) { 2909 if (paintInfo) {
2909 IntRect selectionGapRect = alignSelectionRectToDevicePixels(gapRect); 2910 IntRect selectionGapRect = alignSelectionRectToDevicePixels(gapRect);
2910 RenderDrawingRecorder recorder(paintInfo->context, this, paintInfo->phas e, selectionGapRect); 2911 RenderDrawingRecorder recorder(paintInfo->context, *this, paintInfo->pha se, selectionGapRect);
2911 paintInfo->context->fillRect(selectionGapRect, selObj->selectionBackgrou ndColor()); 2912 if (!recorder.canUseCachedDrawing())
2913 paintInfo->context->fillRect(selectionGapRect, selObj->selectionBack groundColor());
2912 } 2914 }
2913 return gapRect; 2915 return gapRect;
2914 } 2916 }
2915 2917
2916 LayoutRect RenderBlockFlow::logicalRightSelectionGap(const RenderBlock* rootBloc k, const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRoo tBlock, 2918 LayoutRect RenderBlockFlow::logicalRightSelectionGap(const RenderBlock* rootBloc k, const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRoo tBlock,
2917 const RenderObject* selObj, LayoutUnit logicalRight, LayoutUnit logicalTop, LayoutUnit logicalHeight, const PaintInfo* paintInfo) const 2919 const RenderObject* selObj, LayoutUnit logicalRight, LayoutUnit logicalTop, LayoutUnit logicalHeight, const PaintInfo* paintInfo) const
2918 { 2920 {
2919 LayoutUnit rootBlockLogicalTop = rootBlock->blockDirectionOffset(offsetFromR ootBlock) + logicalTop; 2921 LayoutUnit rootBlockLogicalTop = rootBlock->blockDirectionOffset(offsetFromR ootBlock) + logicalTop;
2920 LayoutUnit rootBlockLogicalLeft = std::max(rootBlock->inlineDirectionOffset( offsetFromRootBlock) + logicalRight, max(logicalLeftSelectionOffset(rootBlock, l ogicalTop), logicalLeftSelectionOffset(rootBlock, logicalTop + logicalHeight))); 2922 LayoutUnit rootBlockLogicalLeft = std::max(rootBlock->inlineDirectionOffset( offsetFromRootBlock) + logicalRight, max(logicalLeftSelectionOffset(rootBlock, l ogicalTop), logicalLeftSelectionOffset(rootBlock, logicalTop + logicalHeight)));
2921 LayoutUnit rootBlockLogicalRight = std::min(logicalRightSelectionOffset(root Block, logicalTop), logicalRightSelectionOffset(rootBlock, logicalTop + logicalH eight)); 2923 LayoutUnit rootBlockLogicalRight = std::min(logicalRightSelectionOffset(root Block, logicalTop), logicalRightSelectionOffset(rootBlock, logicalTop + logicalH eight));
2922 LayoutUnit rootBlockLogicalWidth = rootBlockLogicalRight - rootBlockLogicalL eft; 2924 LayoutUnit rootBlockLogicalWidth = rootBlockLogicalRight - rootBlockLogicalL eft;
2923 if (rootBlockLogicalWidth <= 0) 2925 if (rootBlockLogicalWidth <= 0)
2924 return LayoutRect(); 2926 return LayoutRect();
2925 2927
2926 LayoutRect gapRect = rootBlock->logicalRectToPhysicalRect(rootBlockPhysicalP osition, LayoutRect(rootBlockLogicalLeft, rootBlockLogicalTop, rootBlockLogicalW idth, logicalHeight)); 2928 LayoutRect gapRect = rootBlock->logicalRectToPhysicalRect(rootBlockPhysicalP osition, LayoutRect(rootBlockLogicalLeft, rootBlockLogicalTop, rootBlockLogicalW idth, logicalHeight));
2927 if (paintInfo) { 2929 if (paintInfo) {
2928 IntRect selectionGapRect = alignSelectionRectToDevicePixels(gapRect); 2930 IntRect selectionGapRect = alignSelectionRectToDevicePixels(gapRect);
2929 RenderDrawingRecorder recorder(paintInfo->context, this, paintInfo->phas e, selectionGapRect); 2931 RenderDrawingRecorder recorder(paintInfo->context, *this, paintInfo->pha se, selectionGapRect);
2930 paintInfo->context->fillRect(selectionGapRect, selObj->selectionBackgrou ndColor()); 2932 if (!recorder.canUseCachedDrawing())
2933 paintInfo->context->fillRect(selectionGapRect, selObj->selectionBack groundColor());
2931 } 2934 }
2932 return gapRect; 2935 return gapRect;
2933 } 2936 }
2934 2937
2935 void RenderBlockFlow::getSelectionGapInfo(SelectionState state, bool& leftGap, b ool& rightGap) const 2938 void RenderBlockFlow::getSelectionGapInfo(SelectionState state, bool& leftGap, b ool& rightGap) const
2936 { 2939 {
2937 bool ltr = style()->isLeftToRightDirection(); 2940 bool ltr = style()->isLeftToRightDirection();
2938 leftGap = (state == RenderObject::SelectionInside) 2941 leftGap = (state == RenderObject::SelectionInside)
2939 || (state == RenderObject::SelectionEnd && ltr) 2942 || (state == RenderObject::SelectionEnd && ltr)
2940 || (state == RenderObject::SelectionStart && !ltr); 2943 || (state == RenderObject::SelectionStart && !ltr);
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
3094 FrameView* frameView = document().view(); 3097 FrameView* frameView = document().view();
3095 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr ollOffset().height(); 3098 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr ollOffset().height();
3096 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height( ); 3099 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height( );
3097 if (size().height() < visibleHeight) 3100 if (size().height() < visibleHeight)
3098 top += (visibleHeight - size().height()) / 2; 3101 top += (visibleHeight - size().height()) / 2;
3099 setY(top); 3102 setY(top);
3100 dialog->setCentered(top); 3103 dialog->setCentered(top);
3101 } 3104 }
3102 3105
3103 } // namespace blink 3106 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/paint/ViewDisplayListTest.cpp ('k') | Source/platform/graphics/paint/DrawingRecorder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698