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

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

Issue 1557373002: Simplify arguments to logical[Left,Right]OffsetForPositioningFloat (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBlockFlow.h ('k') | no next file » | 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 2158 matching lines...) Expand 10 before | Expand all | Expand 10 after
2169 return point; 2169 return point;
2170 2170
2171 // This is similar to LayoutBox::flipForWritingModeForChild. We have to subt ract out our left/top offsets twice, since 2171 // This is similar to LayoutBox::flipForWritingModeForChild. We have to subt ract out our left/top offsets twice, since
2172 // it's going to get added back in. We hide this complication here so that t he calling code looks normal for the unflipped 2172 // it's going to get added back in. We hide this complication here so that t he calling code looks normal for the unflipped
2173 // case. 2173 // case.
2174 if (isHorizontalWritingMode()) 2174 if (isHorizontalWritingMode())
2175 return LayoutPoint(point.x(), point.y() + size().height() - child.layout Object()->size().height() - 2 * yPositionForFloatIncludingMargin(child)); 2175 return LayoutPoint(point.x(), point.y() + size().height() - child.layout Object()->size().height() - 2 * yPositionForFloatIncludingMargin(child));
2176 return LayoutPoint(point.x() + size().width() - child.layoutObject()->size() .width() - 2 * xPositionForFloatIncludingMargin(child), point.y()); 2176 return LayoutPoint(point.x() + size().width() - child.layoutObject()->size() .width() - 2 * xPositionForFloatIncludingMargin(child), point.y());
2177 } 2177 }
2178 2178
2179 LayoutUnit LayoutBlockFlow::logicalLeftOffsetForPositioningFloat(LayoutUnit logi calTop, LayoutUnit fixedOffset, bool applyTextIndent, LayoutUnit* heightRemainin g) const 2179 LayoutUnit LayoutBlockFlow::logicalLeftOffsetForPositioningFloat(LayoutUnit logi calTop, LayoutUnit fixedOffset, LayoutUnit* heightRemaining) const
2180 { 2180 {
2181 LayoutUnit offset = fixedOffset; 2181 LayoutUnit offset = fixedOffset;
2182 if (m_floatingObjects && m_floatingObjects->hasLeftObjects()) 2182 if (m_floatingObjects && m_floatingObjects->hasLeftObjects())
2183 offset = m_floatingObjects->logicalLeftOffsetForPositioningFloat(fixedOf fset, logicalTop, heightRemaining); 2183 offset = m_floatingObjects->logicalLeftOffsetForPositioningFloat(fixedOf fset, logicalTop, heightRemaining);
2184 return adjustLogicalLeftOffsetForLine(offset, applyTextIndent); 2184 return adjustLogicalLeftOffsetForLine(offset, false);
2185 } 2185 }
2186 2186
2187 LayoutUnit LayoutBlockFlow::logicalRightOffsetForPositioningFloat(LayoutUnit log icalTop, LayoutUnit fixedOffset, bool applyTextIndent, LayoutUnit* heightRemaini ng) const 2187 LayoutUnit LayoutBlockFlow::logicalRightOffsetForPositioningFloat(LayoutUnit log icalTop, LayoutUnit fixedOffset, LayoutUnit* heightRemaining) const
2188 { 2188 {
2189 LayoutUnit offset = fixedOffset; 2189 LayoutUnit offset = fixedOffset;
2190 if (m_floatingObjects && m_floatingObjects->hasRightObjects()) 2190 if (m_floatingObjects && m_floatingObjects->hasRightObjects())
2191 offset = m_floatingObjects->logicalRightOffsetForPositioningFloat(fixedO ffset, logicalTop, heightRemaining); 2191 offset = m_floatingObjects->logicalRightOffsetForPositioningFloat(fixedO ffset, logicalTop, heightRemaining);
2192 return adjustLogicalRightOffsetForLine(offset, applyTextIndent); 2192 return adjustLogicalRightOffsetForLine(offset, false);
2193 } 2193 }
2194 2194
2195 LayoutUnit LayoutBlockFlow::adjustLogicalLeftOffsetForLine(LayoutUnit offsetFrom Floats, bool applyTextIndent) const 2195 LayoutUnit LayoutBlockFlow::adjustLogicalLeftOffsetForLine(LayoutUnit offsetFrom Floats, bool applyTextIndent) const
2196 { 2196 {
2197 LayoutUnit left = offsetFromFloats; 2197 LayoutUnit left = offsetFromFloats;
2198 2198
2199 if (applyTextIndent && style()->isLeftToRightDirection()) 2199 if (applyTextIndent && style()->isLeftToRightDirection())
2200 left += textIndentOffset(); 2200 left += textIndentOffset();
2201 2201
2202 return left; 2202 return left;
(...skipping 18 matching lines...) Expand all
2221 2221
2222 LayoutUnit floatLogicalWidth = std::min(logicalWidthForFloat(floatingObject) , logicalRightOffset - logicalLeftOffset); // The width we look for. 2222 LayoutUnit floatLogicalWidth = std::min(logicalWidthForFloat(floatingObject) , logicalRightOffset - logicalLeftOffset); // The width we look for.
2223 2223
2224 LayoutUnit floatLogicalLeft; 2224 LayoutUnit floatLogicalLeft;
2225 2225
2226 bool insideFlowThread = flowThreadContainingBlock(); 2226 bool insideFlowThread = flowThreadContainingBlock();
2227 2227
2228 if (childBox->style()->floating() == LeftFloat) { 2228 if (childBox->style()->floating() == LeftFloat) {
2229 LayoutUnit heightRemainingLeft = 1; 2229 LayoutUnit heightRemainingLeft = 1;
2230 LayoutUnit heightRemainingRight = 1; 2230 LayoutUnit heightRemainingRight = 1;
2231 floatLogicalLeft = logicalLeftOffsetForPositioningFloat(logicalTopOffset , logicalLeftOffset, false, &heightRemainingLeft); 2231 floatLogicalLeft = logicalLeftOffsetForPositioningFloat(logicalTopOffset , logicalLeftOffset, &heightRemainingLeft);
2232 while (logicalRightOffsetForPositioningFloat(logicalTopOffset, logicalRi ghtOffset, false, &heightRemainingRight) - floatLogicalLeft < floatLogicalWidth) { 2232 while (logicalRightOffsetForPositioningFloat(logicalTopOffset, logicalRi ghtOffset, &heightRemainingRight) - floatLogicalLeft < floatLogicalWidth) {
2233 logicalTopOffset += std::min<LayoutUnit>(heightRemainingLeft, height RemainingRight); 2233 logicalTopOffset += std::min<LayoutUnit>(heightRemainingLeft, height RemainingRight);
2234 floatLogicalLeft = logicalLeftOffsetForPositioningFloat(logicalTopOf fset, logicalLeftOffset, false, &heightRemainingLeft); 2234 floatLogicalLeft = logicalLeftOffsetForPositioningFloat(logicalTopOf fset, logicalLeftOffset, &heightRemainingLeft);
2235 if (insideFlowThread) { 2235 if (insideFlowThread) {
2236 // Have to re-evaluate all of our offsets, since they may have c hanged. 2236 // Have to re-evaluate all of our offsets, since they may have c hanged.
2237 logicalRightOffset = logicalRightOffsetForContent(); // Constant part of right offset. 2237 logicalRightOffset = logicalRightOffsetForContent(); // Constant part of right offset.
2238 logicalLeftOffset = logicalLeftOffsetForContent(); // Constant p art of left offset. 2238 logicalLeftOffset = logicalLeftOffsetForContent(); // Constant p art of left offset.
2239 floatLogicalWidth = std::min(logicalWidthForFloat(floatingObject ), logicalRightOffset - logicalLeftOffset); 2239 floatLogicalWidth = std::min(logicalWidthForFloat(floatingObject ), logicalRightOffset - logicalLeftOffset);
2240 } 2240 }
2241 } 2241 }
2242 floatLogicalLeft = std::max(logicalLeftOffset - borderAndPaddingLogicalL eft(), floatLogicalLeft); 2242 floatLogicalLeft = std::max(logicalLeftOffset - borderAndPaddingLogicalL eft(), floatLogicalLeft);
2243 } else { 2243 } else {
2244 LayoutUnit heightRemainingLeft = 1; 2244 LayoutUnit heightRemainingLeft = 1;
2245 LayoutUnit heightRemainingRight = 1; 2245 LayoutUnit heightRemainingRight = 1;
2246 floatLogicalLeft = logicalRightOffsetForPositioningFloat(logicalTopOffse t, logicalRightOffset, false, &heightRemainingRight); 2246 floatLogicalLeft = logicalRightOffsetForPositioningFloat(logicalTopOffse t, logicalRightOffset, &heightRemainingRight);
2247 while (floatLogicalLeft - logicalLeftOffsetForPositioningFloat(logicalTo pOffset, logicalLeftOffset, false, &heightRemainingLeft) < floatLogicalWidth) { 2247 while (floatLogicalLeft - logicalLeftOffsetForPositioningFloat(logicalTo pOffset, logicalLeftOffset, &heightRemainingLeft) < floatLogicalWidth) {
2248 logicalTopOffset += std::min(heightRemainingLeft, heightRemainingRig ht); 2248 logicalTopOffset += std::min(heightRemainingLeft, heightRemainingRig ht);
2249 floatLogicalLeft = logicalRightOffsetForPositioningFloat(logicalTopO ffset, logicalRightOffset, false, &heightRemainingRight); 2249 floatLogicalLeft = logicalRightOffsetForPositioningFloat(logicalTopO ffset, logicalRightOffset, &heightRemainingRight);
2250 if (insideFlowThread) { 2250 if (insideFlowThread) {
2251 // Have to re-evaluate all of our offsets, since they may have c hanged. 2251 // Have to re-evaluate all of our offsets, since they may have c hanged.
2252 logicalRightOffset = logicalRightOffsetForContent(); // Constant part of right offset. 2252 logicalRightOffset = logicalRightOffsetForContent(); // Constant part of right offset.
2253 logicalLeftOffset = logicalLeftOffsetForContent(); // Constant p art of left offset. 2253 logicalLeftOffset = logicalLeftOffsetForContent(); // Constant p art of left offset.
2254 floatLogicalWidth = std::min(logicalWidthForFloat(floatingObject ), logicalRightOffset - logicalLeftOffset); 2254 floatLogicalWidth = std::min(logicalWidthForFloat(floatingObject ), logicalRightOffset - logicalLeftOffset);
2255 } 2255 }
2256 } 2256 }
2257 // Use the original width of the float here, since the local variable 2257 // Use the original width of the float here, since the local variable
2258 // |floatLogicalWidth| was capped to the available line width. See 2258 // |floatLogicalWidth| was capped to the available line width. See
2259 // fast/block/float/clamped-right-float.html. 2259 // fast/block/float/clamped-right-float.html.
(...skipping 864 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') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698