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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp

Issue 1512803004: Use refs for GraphicsContext (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ScrollbarTheme
Patch Set: Created 5 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
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 2792 matching lines...) Expand 10 before | Expand all | Expand 10 after
2803 // Get the selection offsets for the bottom of the gap 2803 // Get the selection offsets for the bottom of the gap
2804 LayoutUnit logicalLeft = std::max(lastLogicalLeft, logicalLeftSelectionOffse t(rootBlock, logicalBottom)); 2804 LayoutUnit logicalLeft = std::max(lastLogicalLeft, logicalLeftSelectionOffse t(rootBlock, logicalBottom));
2805 LayoutUnit logicalRight = std::min(lastLogicalRight, logicalRightSelectionOf fset(rootBlock, logicalBottom)); 2805 LayoutUnit logicalRight = std::min(lastLogicalRight, logicalRightSelectionOf fset(rootBlock, logicalBottom));
2806 LayoutUnit logicalWidth = logicalRight - logicalLeft; 2806 LayoutUnit logicalWidth = logicalRight - logicalLeft;
2807 if (logicalWidth <= 0) 2807 if (logicalWidth <= 0)
2808 return LayoutRect(); 2808 return LayoutRect();
2809 2809
2810 LayoutRect gapRect = rootBlock->logicalRectToPhysicalRect(rootBlockPhysicalP osition, LayoutRect(logicalLeft, logicalTop, logicalWidth, logicalHeight)); 2810 LayoutRect gapRect = rootBlock->logicalRectToPhysicalRect(rootBlockPhysicalP osition, LayoutRect(logicalLeft, logicalTop, logicalWidth, logicalHeight));
2811 if (paintInfo) { 2811 if (paintInfo) {
2812 IntRect selectionGapRect = alignSelectionRectToDevicePixels(gapRect); 2812 IntRect selectionGapRect = alignSelectionRectToDevicePixels(gapRect);
2813 paintInfo->context->fillRect(selectionGapRect, selectionBackgroundColor( )); 2813 paintInfo->context.fillRect(selectionGapRect, selectionBackgroundColor() );
2814 } 2814 }
2815 return gapRect; 2815 return gapRect;
2816 } 2816 }
2817 2817
2818 GapRects LayoutBlockFlow::blockSelectionGaps(const LayoutBlock* rootBlock, const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock, 2818 GapRects LayoutBlockFlow::blockSelectionGaps(const LayoutBlock* rootBlock, const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock,
2819 LayoutUnit& lastLogicalTop, LayoutUnit& lastLogicalLeft, LayoutUnit& lastLog icalRight, const PaintInfo* paintInfo) const 2819 LayoutUnit& lastLogicalTop, LayoutUnit& lastLogicalLeft, LayoutUnit& lastLog icalRight, const PaintInfo* paintInfo) const
2820 { 2820 {
2821 GapRects result; 2821 GapRects result;
2822 2822
2823 // Go ahead and jump right to the first block child that contains some selec ted objects. 2823 // 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
2885 LayoutUnit rootBlockLogicalTop = rootBlock->blockDirectionOffset(offsetFromR ootBlock) + logicalTop; 2885 LayoutUnit rootBlockLogicalTop = rootBlock->blockDirectionOffset(offsetFromR ootBlock) + logicalTop;
2886 LayoutUnit rootBlockLogicalLeft = std::max(logicalLeftSelectionOffset(rootBl ock, logicalTop), logicalLeftSelectionOffset(rootBlock, logicalTop + logicalHeig ht)); 2886 LayoutUnit rootBlockLogicalLeft = std::max(logicalLeftSelectionOffset(rootBl ock, logicalTop), logicalLeftSelectionOffset(rootBlock, logicalTop + logicalHeig ht));
2887 LayoutUnit rootBlockLogicalRight = std::min(rootBlock->inlineDirectionOffset (offsetFromRootBlock) + logicalLeft, std::min(logicalRightSelectionOffset(rootBl ock, logicalTop), logicalRightSelectionOffset(rootBlock, logicalTop + logicalHei ght))); 2887 LayoutUnit rootBlockLogicalRight = std::min(rootBlock->inlineDirectionOffset (offsetFromRootBlock) + logicalLeft, std::min(logicalRightSelectionOffset(rootBl ock, logicalTop), logicalRightSelectionOffset(rootBlock, logicalTop + logicalHei ght)));
2888 LayoutUnit rootBlockLogicalWidth = rootBlockLogicalRight - rootBlockLogicalL eft; 2888 LayoutUnit rootBlockLogicalWidth = rootBlockLogicalRight - rootBlockLogicalL eft;
2889 if (rootBlockLogicalWidth <= 0) 2889 if (rootBlockLogicalWidth <= 0)
2890 return LayoutRect(); 2890 return LayoutRect();
2891 2891
2892 LayoutRect gapRect = rootBlock->logicalRectToPhysicalRect(rootBlockPhysicalP osition, LayoutRect(rootBlockLogicalLeft, rootBlockLogicalTop, rootBlockLogicalW idth, logicalHeight)); 2892 LayoutRect gapRect = rootBlock->logicalRectToPhysicalRect(rootBlockPhysicalP osition, LayoutRect(rootBlockLogicalLeft, rootBlockLogicalTop, rootBlockLogicalW idth, logicalHeight));
2893 if (paintInfo) { 2893 if (paintInfo) {
2894 IntRect selectionGapRect = alignSelectionRectToDevicePixels(gapRect); 2894 IntRect selectionGapRect = alignSelectionRectToDevicePixels(gapRect);
2895 paintInfo->context->fillRect(selectionGapRect, selObj->selectionBackgrou ndColor()); 2895 paintInfo->context.fillRect(selectionGapRect, selObj->selectionBackgroun dColor());
2896 } 2896 }
2897 return gapRect; 2897 return gapRect;
2898 } 2898 }
2899 2899
2900 LayoutRect LayoutBlockFlow::logicalRightSelectionGap(const LayoutBlock* rootBloc k, const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRoo tBlock, 2900 LayoutRect LayoutBlockFlow::logicalRightSelectionGap(const LayoutBlock* rootBloc k, const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRoo tBlock,
2901 const LayoutObject* selObj, LayoutUnit logicalRight, LayoutUnit logicalTop, LayoutUnit logicalHeight, const PaintInfo* paintInfo) const 2901 const LayoutObject* selObj, LayoutUnit logicalRight, LayoutUnit logicalTop, LayoutUnit logicalHeight, const PaintInfo* paintInfo) const
2902 { 2902 {
2903 LayoutUnit rootBlockLogicalTop = rootBlock->blockDirectionOffset(offsetFromR ootBlock) + logicalTop; 2903 LayoutUnit rootBlockLogicalTop = rootBlock->blockDirectionOffset(offsetFromR ootBlock) + logicalTop;
2904 LayoutUnit rootBlockLogicalLeft = std::max(rootBlock->inlineDirectionOffset( offsetFromRootBlock) + logicalRight, max(logicalLeftSelectionOffset(rootBlock, l ogicalTop), logicalLeftSelectionOffset(rootBlock, logicalTop + logicalHeight))); 2904 LayoutUnit rootBlockLogicalLeft = std::max(rootBlock->inlineDirectionOffset( offsetFromRootBlock) + logicalRight, max(logicalLeftSelectionOffset(rootBlock, l ogicalTop), logicalLeftSelectionOffset(rootBlock, logicalTop + logicalHeight)));
2905 LayoutUnit rootBlockLogicalRight = std::min(logicalRightSelectionOffset(root Block, logicalTop), logicalRightSelectionOffset(rootBlock, logicalTop + logicalH eight)); 2905 LayoutUnit rootBlockLogicalRight = std::min(logicalRightSelectionOffset(root Block, logicalTop), logicalRightSelectionOffset(rootBlock, logicalTop + logicalH eight));
2906 LayoutUnit rootBlockLogicalWidth = rootBlockLogicalRight - rootBlockLogicalL eft; 2906 LayoutUnit rootBlockLogicalWidth = rootBlockLogicalRight - rootBlockLogicalL eft;
2907 if (rootBlockLogicalWidth <= 0) 2907 if (rootBlockLogicalWidth <= 0)
2908 return LayoutRect(); 2908 return LayoutRect();
2909 2909
2910 LayoutRect gapRect = rootBlock->logicalRectToPhysicalRect(rootBlockPhysicalP osition, LayoutRect(rootBlockLogicalLeft, rootBlockLogicalTop, rootBlockLogicalW idth, logicalHeight)); 2910 LayoutRect gapRect = rootBlock->logicalRectToPhysicalRect(rootBlockPhysicalP osition, LayoutRect(rootBlockLogicalLeft, rootBlockLogicalTop, rootBlockLogicalW idth, logicalHeight));
2911 if (paintInfo) { 2911 if (paintInfo) {
2912 IntRect selectionGapRect = alignSelectionRectToDevicePixels(gapRect); 2912 IntRect selectionGapRect = alignSelectionRectToDevicePixels(gapRect);
2913 paintInfo->context->fillRect(selectionGapRect, selObj->selectionBackgrou ndColor()); 2913 paintInfo->context.fillRect(selectionGapRect, selObj->selectionBackgroun dColor());
2914 } 2914 }
2915 return gapRect; 2915 return gapRect;
2916 } 2916 }
2917 2917
2918 void LayoutBlockFlow::getSelectionGapInfo(SelectionState state, bool& leftGap, b ool& rightGap) const 2918 void LayoutBlockFlow::getSelectionGapInfo(SelectionState state, bool& leftGap, b ool& rightGap) const
2919 { 2919 {
2920 bool ltr = style()->isLeftToRightDirection(); 2920 bool ltr = style()->isLeftToRightDirection();
2921 leftGap = (state == SelectionInside) 2921 leftGap = (state == SelectionInside)
2922 || (state == SelectionEnd && ltr) 2922 || (state == SelectionEnd && ltr)
2923 || (state == SelectionStart && !ltr); 2923 || (state == SelectionStart && !ltr);
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
3125 FrameView* frameView = document().view(); 3125 FrameView* frameView = document().view();
3126 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr ollOffset().height(); 3126 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr ollOffset().height();
3127 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height( ); 3127 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height( );
3128 if (size().height() < visibleHeight) 3128 if (size().height() < visibleHeight)
3129 top += (visibleHeight - size().height()) / 2; 3129 top += (visibleHeight - size().height()) / 2;
3130 setY(top); 3130 setY(top);
3131 dialog->setCentered(top); 3131 dialog->setCentered(top);
3132 } 3132 }
3133 3133
3134 } // namespace blink 3134 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698