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

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

Issue 1645753002: [Line Layout API] Convert a few RootInlineBox uses of layoutObject() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2_api_shim_ax
Patch Set: without patchset dependency Created 4 years, 10 months 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 2841 matching lines...) Expand 10 before | Expand all | Expand 10 after
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* 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. 2853 // our object. We know this if the selection did not end inside our object.
2854 if (paintsOwnSelection && (childState == SelectionStart || sawSelect ionEnd)) 2854 if (paintsOwnSelection && (childState == SelectionStart || sawSelect ionEnd))
2855 childState = SelectionNone; 2855 childState = SelectionNone;
2856 2856
2857 // Fill side gaps on this object based off its state. 2857 // Fill side gaps on this object based off its state.
2858 bool leftGap, rightGap; 2858 bool leftGap, rightGap;
2859 getSelectionGapInfo(childState, leftGap, rightGap); 2859 getSelectionGapInfo(childState, leftGap, rightGap);
2860 2860
2861 if (leftGap) 2861 if (leftGap)
2862 result.uniteLeft(logicalLeftSelectionGap(rootBlock, rootBlockPhy sicalPosition, offsetFromRootBlock, this, curr->logicalLeft(), curr->logicalTop( ), curr->logicalHeight(), paintInfo)); 2862 result.uniteLeft(logicalLeftSelectionGap(rootBlock, rootBlockPhy sicalPosition, offsetFromRootBlock, LineLayoutItem(const_cast<LayoutBlockFlow*>( this)), curr->logicalLeft(), curr->logicalTop(), curr->logicalHeight(), paintInf o));
2863 if (rightGap) 2863 if (rightGap)
2864 result.uniteRight(logicalRightSelectionGap(rootBlock, rootBlockP hysicalPosition, offsetFromRootBlock, this, curr->logicalRight(), curr->logicalT op(), curr->logicalHeight(), paintInfo)); 2864 result.uniteRight(logicalRightSelectionGap(rootBlock, rootBlockP hysicalPosition, offsetFromRootBlock, LineLayoutItem(const_cast<LayoutBlockFlow* >(this)), curr->logicalRight(), curr->logicalTop(), curr->logicalHeight(), paint Info));
2865 2865
2866 // Update lastLogicalTop to be just underneath the object. lastLogi calLeft and lastLogicalRight extend as far as 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 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. 2868 // to the border of the root selection block.
2869 lastLogicalTop = rootBlock->blockDirectionOffset(offsetFromRootBlock ) + curr->logicalBottom(); 2869 lastLogicalTop = rootBlock->blockDirectionOffset(offsetFromRootBlock ) + curr->logicalBottom();
2870 lastLogicalLeft = logicalLeftSelectionOffset(rootBlock, curr->logica lBottom()); 2870 lastLogicalLeft = logicalLeftSelectionOffset(rootBlock, curr->logica lBottom());
2871 lastLogicalRight = logicalRightSelectionOffset(rootBlock, curr->logi calBottom()); 2871 lastLogicalRight = logicalRightSelectionOffset(rootBlock, curr->logi calBottom());
2872 } else if (childState != SelectionNone && curr->isLayoutBlockFlow()) { 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. 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()), 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)); 2875 lastLogicalTop, lastLogicalLeft, lastLogicalRight, paintInfo));
2876 } 2876 }
2877 } 2877 }
2878 return result; 2878 return result;
2879 } 2879 }
2880 2880
2881 LayoutRect LayoutBlockFlow::logicalLeftSelectionGap(const LayoutBlock* rootBlock , const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRoot Block, 2881 LayoutRect LayoutBlockFlow::logicalLeftSelectionGap(const LayoutBlock* rootBlock , const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRoot Block,
2882 const LayoutObject* selObj, LayoutUnit logicalLeft, LayoutUnit logicalTop, L ayoutUnit logicalHeight, const PaintInfo* paintInfo) const 2882 const LineLayoutItem selObj, LayoutUnit logicalLeft, LayoutUnit logicalTop, LayoutUnit logicalHeight, const PaintInfo* paintInfo) const
2883 { 2883 {
2884 LayoutUnit rootBlockLogicalTop = rootBlock->blockDirectionOffset(offsetFromR ootBlock) + logicalTop; 2884 LayoutUnit rootBlockLogicalTop = rootBlock->blockDirectionOffset(offsetFromR ootBlock) + logicalTop;
2885 LayoutUnit rootBlockLogicalLeft = std::max(logicalLeftSelectionOffset(rootBl ock, logicalTop), logicalLeftSelectionOffset(rootBlock, logicalTop + logicalHeig ht)); 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))); 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; 2887 LayoutUnit rootBlockLogicalWidth = rootBlockLogicalRight - rootBlockLogicalL eft;
2888 if (rootBlockLogicalWidth <= 0) 2888 if (rootBlockLogicalWidth <= 0)
2889 return LayoutRect(); 2889 return LayoutRect();
2890 2890
2891 LayoutRect gapRect = rootBlock->logicalRectToPhysicalRect(rootBlockPhysicalP osition, LayoutRect(rootBlockLogicalLeft, rootBlockLogicalTop, rootBlockLogicalW idth, logicalHeight)); 2891 LayoutRect gapRect = rootBlock->logicalRectToPhysicalRect(rootBlockPhysicalP osition, LayoutRect(rootBlockLogicalLeft, rootBlockLogicalTop, rootBlockLogicalW idth, logicalHeight));
2892 if (paintInfo) { 2892 if (paintInfo) {
2893 IntRect selectionGapRect = alignSelectionRectToDevicePixels(gapRect); 2893 IntRect selectionGapRect = alignSelectionRectToDevicePixels(gapRect);
2894 paintInfo->context.fillRect(selectionGapRect, selObj->selectionBackgroun dColor()); 2894 paintInfo->context.fillRect(selectionGapRect, selObj.selectionBackground Color());
2895 } 2895 }
2896 return gapRect; 2896 return gapRect;
2897 } 2897 }
2898 2898
2899 LayoutRect LayoutBlockFlow::logicalRightSelectionGap(const LayoutBlock* rootBloc k, const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRoo tBlock, 2899 LayoutRect LayoutBlockFlow::logicalRightSelectionGap(const LayoutBlock* rootBloc k, const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRoo tBlock,
2900 const LayoutObject* selObj, LayoutUnit logicalRight, LayoutUnit logicalTop, LayoutUnit logicalHeight, const PaintInfo* paintInfo) const 2900 const LineLayoutItem selObj, LayoutUnit logicalRight, LayoutUnit logicalTop, LayoutUnit logicalHeight, const PaintInfo* paintInfo) const
2901 { 2901 {
2902 LayoutUnit rootBlockLogicalTop = rootBlock->blockDirectionOffset(offsetFromR ootBlock) + logicalTop; 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))); 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)); 2904 LayoutUnit rootBlockLogicalRight = std::min(logicalRightSelectionOffset(root Block, logicalTop), logicalRightSelectionOffset(rootBlock, logicalTop + logicalH eight));
2905 LayoutUnit rootBlockLogicalWidth = rootBlockLogicalRight - rootBlockLogicalL eft; 2905 LayoutUnit rootBlockLogicalWidth = rootBlockLogicalRight - rootBlockLogicalL eft;
2906 if (rootBlockLogicalWidth <= 0) 2906 if (rootBlockLogicalWidth <= 0)
2907 return LayoutRect(); 2907 return LayoutRect();
2908 2908
2909 LayoutRect gapRect = rootBlock->logicalRectToPhysicalRect(rootBlockPhysicalP osition, LayoutRect(rootBlockLogicalLeft, rootBlockLogicalTop, rootBlockLogicalW idth, logicalHeight)); 2909 LayoutRect gapRect = rootBlock->logicalRectToPhysicalRect(rootBlockPhysicalP osition, LayoutRect(rootBlockLogicalLeft, rootBlockLogicalTop, rootBlockLogicalW idth, logicalHeight));
2910 if (paintInfo) { 2910 if (paintInfo) {
2911 IntRect selectionGapRect = alignSelectionRectToDevicePixels(gapRect); 2911 IntRect selectionGapRect = alignSelectionRectToDevicePixels(gapRect);
2912 paintInfo->context.fillRect(selectionGapRect, selObj->selectionBackgroun dColor()); 2912 paintInfo->context.fillRect(selectionGapRect, selObj.selectionBackground Color());
2913 } 2913 }
2914 return gapRect; 2914 return gapRect;
2915 } 2915 }
2916 2916
2917 void LayoutBlockFlow::getSelectionGapInfo(SelectionState state, bool& leftGap, b ool& rightGap) const 2917 void LayoutBlockFlow::getSelectionGapInfo(SelectionState state, bool& leftGap, b ool& rightGap) const
2918 { 2918 {
2919 bool ltr = style()->isLeftToRightDirection(); 2919 bool ltr = style()->isLeftToRightDirection();
2920 leftGap = (state == SelectionInside) 2920 leftGap = (state == SelectionInside)
2921 || (state == SelectionEnd && ltr) 2921 || (state == SelectionEnd && ltr)
2922 || (state == SelectionStart && !ltr); 2922 || (state == SelectionStart && !ltr);
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
3124 FrameView* frameView = document().view(); 3124 FrameView* frameView = document().view();
3125 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr ollOffset().height(); 3125 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr ollOffset().height();
3126 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height( ); 3126 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height( );
3127 if (size().height() < visibleHeight) 3127 if (size().height() < visibleHeight)
3128 top += (visibleHeight - size().height()) / 2; 3128 top += (visibleHeight - size().height()) / 2;
3129 setY(top); 3129 setY(top);
3130 dialog->setCentered(top); 3130 dialog->setCentered(top);
3131 } 3131 }
3132 3132
3133 } // namespace blink 3133 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBlockFlow.h ('k') | third_party/WebKit/Source/core/layout/line/RootInlineBox.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698