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

Side by Side Diff: sky/engine/core/rendering/RenderBox.cpp

Issue 877043002: Remove RenderLayerScrollableArea (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 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
« no previous file with comments | « sky/engine/core/rendering/RenderBox.h ('k') | sky/engine/core/rendering/RenderFlexibleBox.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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com)
6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed. 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed.
7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. 7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 return snapSizeToPixel(offsetWidth(), x() + clientLeft()); 181 return snapSizeToPixel(offsetWidth(), x() + clientLeft());
182 } 182 }
183 183
184 int RenderBox::pixelSnappedOffsetHeight() const 184 int RenderBox::pixelSnappedOffsetHeight() const
185 { 185 {
186 return snapSizeToPixel(offsetHeight(), y() + clientTop()); 186 return snapSizeToPixel(offsetHeight(), y() + clientTop());
187 } 187 }
188 188
189 LayoutUnit RenderBox::scrollWidth() const 189 LayoutUnit RenderBox::scrollWidth() const
190 { 190 {
191 if (hasOverflowClip()) 191 // FIXME(sky): Remove.
192 return layer()->scrollableArea()->scrollWidth();
193 // For objects with visible overflow, this matches IE. 192 // For objects with visible overflow, this matches IE.
194 // FIXME: Need to work right with writing modes. 193 // FIXME: Need to work right with writing modes.
195 if (style()->isLeftToRightDirection()) 194 if (style()->isLeftToRightDirection())
196 return std::max(clientWidth(), layoutOverflowRect().maxX() - borderLeft( )); 195 return std::max(clientWidth(), layoutOverflowRect().maxX() - borderLeft( ));
197 return clientWidth() - std::min<LayoutUnit>(0, layoutOverflowRect().x() - bo rderLeft()); 196 return clientWidth() - std::min<LayoutUnit>(0, layoutOverflowRect().x() - bo rderLeft());
198 } 197 }
199 198
200 LayoutUnit RenderBox::scrollHeight() const 199 LayoutUnit RenderBox::scrollHeight() const
201 { 200 {
202 if (hasOverflowClip()) 201 // FIXME(sky): Remove.
203 return layer()->scrollableArea()->scrollHeight();
204 // For objects with visible overflow, this matches IE. 202 // For objects with visible overflow, this matches IE.
205 // FIXME: Need to work right with writing modes. 203 // FIXME: Need to work right with writing modes.
206 return std::max(clientHeight(), layoutOverflowRect().maxY() - borderTop()); 204 return std::max(clientHeight(), layoutOverflowRect().maxY() - borderTop());
207 } 205 }
208 206
209 LayoutUnit RenderBox::scrollLeft() const 207 LayoutUnit RenderBox::scrollLeft() const
210 { 208 {
211 return hasOverflowClip() ? layer()->scrollableArea()->scrollXOffset() : 0; 209 // FIXME(sky): Remove.
210 return 0;
212 } 211 }
213 212
214 LayoutUnit RenderBox::scrollTop() const 213 LayoutUnit RenderBox::scrollTop() const
215 { 214 {
216 return hasOverflowClip() ? layer()->scrollableArea()->scrollYOffset() : 0; 215 // FIXME(sky): Remove.
216 return 0;
217 } 217 }
218 218
219 int RenderBox::pixelSnappedScrollWidth() const 219 int RenderBox::pixelSnappedScrollWidth() const
220 { 220 {
221 // FIXME(sky): Remove.
221 return snapSizeToPixel(scrollWidth(), x() + clientLeft()); 222 return snapSizeToPixel(scrollWidth(), x() + clientLeft());
222 } 223 }
223 224
224 int RenderBox::pixelSnappedScrollHeight() const 225 int RenderBox::pixelSnappedScrollHeight() const
225 { 226 {
226 if (hasOverflowClip()) 227 // FIXME(sky): Remove.
227 return layer()->scrollableArea()->scrollHeight();
228 // For objects with visible overflow, this matches IE. 228 // For objects with visible overflow, this matches IE.
229 // FIXME: Need to work right with writing modes. 229 // FIXME: Need to work right with writing modes.
230 return snapSizeToPixel(scrollHeight(), y() + clientTop()); 230 return snapSizeToPixel(scrollHeight(), y() + clientTop());
231 } 231 }
232 232
233 void RenderBox::setScrollLeft(LayoutUnit newLeft) 233 void RenderBox::setScrollLeft(LayoutUnit newLeft)
234 { 234 {
235 if (hasOverflowClip()) 235 // FIXME(sky): Remove.
236 layer()->scrollableArea()->scrollToXOffset(newLeft, ScrollOffsetClamped) ;
237 } 236 }
238 237
239 void RenderBox::setScrollTop(LayoutUnit newTop) 238 void RenderBox::setScrollTop(LayoutUnit newTop)
240 { 239 {
241 if (hasOverflowClip()) 240 // FIXME(sky): Remove.
242 layer()->scrollableArea()->scrollToYOffset(newTop, ScrollOffsetClamped);
243 } 241 }
244 242
245 void RenderBox::scrollToOffset(const IntSize& offset) 243 void RenderBox::scrollToOffset(const IntSize& offset)
246 { 244 {
247 ASSERT(hasOverflowClip()); 245 // FIXME(sky): Remove.
248 layer()->scrollableArea()->scrollToOffset(offset, ScrollOffsetClamped);
249 } 246 }
250 247
251 void RenderBox::scrollRectToVisible(const LayoutRect& rect, const ScrollAlignmen t& alignX, const ScrollAlignment& alignY) 248 void RenderBox::scrollRectToVisible(const LayoutRect& rect, const ScrollAlignmen t& alignX, const ScrollAlignment& alignY)
252 { 249 {
253 RenderBox* parentBox = 0; 250 // FIXME(sky): Remove.
254 LayoutRect newRect = rect;
255
256 if (parent()) {
257 parentBox = parent()->enclosingBox();
258 }
259
260 if (hasOverflowClip()) {
261 // Don't scroll to reveal an overflow layer that is restricted by the -w ebkit-line-clamp property.
262 // This will prevent us from revealing text hidden by the slider in Safa ri RSS.
263 newRect = layer()->scrollableArea()->exposeRect(rect, alignX, alignY);
264 }
265
266 if (frame()->page()->autoscrollController().autoscrollInProgress())
267 parentBox = enclosingScrollableBox();
268
269 if (parentBox)
270 parentBox->scrollRectToVisible(newRect, alignX, alignY);
271 } 251 }
272 252
273 void RenderBox::absoluteQuads(Vector<FloatQuad>& quads) const 253 void RenderBox::absoluteQuads(Vector<FloatQuad>& quads) const
274 { 254 {
275 quads.append(localToAbsoluteQuad(FloatRect(0, 0, width().toFloat(), height() .toFloat()), 0 /* mode */)); 255 quads.append(localToAbsoluteQuad(FloatRect(0, 0, width().toFloat(), height() .toFloat()), 0 /* mode */));
276 } 256 }
277 257
278 void RenderBox::updateLayerTransformAfterLayout() 258 void RenderBox::updateLayerTransformAfterLayout()
279 { 259 {
280 // Transform-origin depends on box size, so we need to update the layer tran sform after layout. 260 // Transform-origin depends on box size, so we need to update the layer tran sform after layout.
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 } 308 }
329 309
330 void RenderBox::addFocusRingRects(Vector<IntRect>& rects, const LayoutPoint& add itionalOffset, const RenderLayerModelObject*) const 310 void RenderBox::addFocusRingRects(Vector<IntRect>& rects, const LayoutPoint& add itionalOffset, const RenderLayerModelObject*) const
331 { 311 {
332 if (!size().isEmpty()) 312 if (!size().isEmpty())
333 rects.append(pixelSnappedIntRect(additionalOffset, size())); 313 rects.append(pixelSnappedIntRect(additionalOffset, size()));
334 } 314 }
335 315
336 bool RenderBox::scroll(ScrollDirection direction, ScrollGranularity granularity, float delta) 316 bool RenderBox::scroll(ScrollDirection direction, ScrollGranularity granularity, float delta)
337 { 317 {
338 if (!layer() || !layer()->scrollableArea()) 318 // FIXME(sky): Remove.
339 return false; 319 return false;
340 return layer()->scrollableArea()->scroll(direction, granularity, delta);
341 }
342
343 bool RenderBox::canBeScrolledAndHasScrollableArea() const
344 {
345 return canBeProgramaticallyScrolled() && (pixelSnappedScrollHeight() != pixe lSnappedClientHeight() || pixelSnappedScrollWidth() != pixelSnappedClientWidth() );
346 } 320 }
347 321
348 bool RenderBox::canBeProgramaticallyScrolled() const 322 bool RenderBox::canBeProgramaticallyScrolled() const
349 { 323 {
350 Node* node = this->node(); 324 Node* node = this->node();
351 if (node && node->isDocumentNode()) 325 if (node && node->isDocumentNode())
352 return true; 326 return true;
353 327
354 if (!hasOverflowClip()) 328 if (!hasOverflowClip())
355 return false; 329 return false;
(...skipping 20 matching lines...) Expand all
376 } 350 }
377 351
378 bool RenderBox::autoscrollInProgress() const 352 bool RenderBox::autoscrollInProgress() const
379 { 353 {
380 return frame() && frame()->page() && frame()->page()->autoscrollController() .autoscrollInProgress(this); 354 return frame() && frame()->page() && frame()->page()->autoscrollController() .autoscrollInProgress(this);
381 } 355 }
382 356
383 // FIXME(sky): Replace with canBeScrolledAndHasScrollableArea. 357 // FIXME(sky): Replace with canBeScrolledAndHasScrollableArea.
384 bool RenderBox::canAutoscroll() const 358 bool RenderBox::canAutoscroll() const
385 { 359 {
386 return canBeScrolledAndHasScrollableArea(); 360 // FIXME(sky): Remove.
361 return false;
387 } 362 }
388 363
389 // If specified point is in border belt, returned offset denotes direction of 364 // If specified point is in border belt, returned offset denotes direction of
390 // scrolling. 365 // scrolling.
391 IntSize RenderBox::calculateAutoscrollDirection(const IntPoint& windowPoint) con st 366 IntSize RenderBox::calculateAutoscrollDirection(const IntPoint& windowPoint) con st
392 { 367 {
393 if (!frame()) 368 if (!frame())
394 return IntSize(); 369 return IntSize();
395 370
396 FrameView* frameView = frame()->view(); 371 FrameView* frameView = frame()->view();
(...skipping 22 matching lines...) Expand all
419 { 394 {
420 while (renderer && !(renderer->isBox() && toRenderBox(renderer)->canAutoscro ll())) { 395 while (renderer && !(renderer->isBox() && toRenderBox(renderer)->canAutoscro ll())) {
421 renderer = renderer->parent(); 396 renderer = renderer->parent();
422 } 397 }
423 398
424 return renderer && renderer->isBox() ? toRenderBox(renderer) : 0; 399 return renderer && renderer->isBox() ? toRenderBox(renderer) : 0;
425 } 400 }
426 401
427 void RenderBox::scrollByRecursively(const IntSize& delta, ScrollOffsetClamping c lamp) 402 void RenderBox::scrollByRecursively(const IntSize& delta, ScrollOffsetClamping c lamp)
428 { 403 {
429 if (delta.isZero()) 404 // FIXME(sky): Remove.
430 return;
431
432 if (hasOverflowClip()) {
433 IntSize newScrollOffset = layer()->scrollableArea()->adjustedScrollOffse t() + delta;
434 layer()->scrollableArea()->scrollToOffset(newScrollOffset, clamp);
435
436 // If this layer can't do the scroll we ask the next layer up that can s croll to try
437 IntSize remainingScrollOffset = newScrollOffset - layer()->scrollableAre a()->adjustedScrollOffset();
438 if (!remainingScrollOffset.isZero() && parent()) {
439 if (RenderBox* scrollableBox = enclosingScrollableBox())
440 scrollableBox->scrollByRecursively(remainingScrollOffset, clamp) ;
441
442 LocalFrame* frame = this->frame();
443 if (frame && frame->page())
444 frame->page()->autoscrollController().updateAutoscrollRenderer() ;
445 }
446 }
447 } 405 }
448 406
449 bool RenderBox::needsPreferredWidthsRecalculation() const 407 bool RenderBox::needsPreferredWidthsRecalculation() const
450 { 408 {
451 return style()->paddingStart().isPercent() || style()->paddingEnd().isPercen t(); 409 return style()->paddingStart().isPercent() || style()->paddingEnd().isPercen t();
452 } 410 }
453 411
454 IntSize RenderBox::scrolledContentOffset() const 412 IntSize RenderBox::scrolledContentOffset() const
455 { 413 {
456 ASSERT(hasOverflowClip()); 414 // FIXME(sky): Remove.
457 ASSERT(hasLayer()); 415 return IntSize();
458 return layer()->scrollableArea()->scrollOffset();
459 } 416 }
460 417
461 void RenderBox::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Layou tUnit& maxLogicalWidth) const 418 void RenderBox::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Layou tUnit& maxLogicalWidth) const
462 { 419 {
463 minLogicalWidth = minPreferredLogicalWidth() - borderAndPaddingLogicalWidth( ); 420 minLogicalWidth = minPreferredLogicalWidth() - borderAndPaddingLogicalWidth( );
464 maxLogicalWidth = maxPreferredLogicalWidth() - borderAndPaddingLogicalWidth( ); 421 maxLogicalWidth = maxPreferredLogicalWidth() - borderAndPaddingLogicalWidth( );
465 } 422 }
466 423
467 LayoutUnit RenderBox::minPreferredLogicalWidth() const 424 LayoutUnit RenderBox::minPreferredLogicalWidth() const
468 { 425 {
(...skipping 2469 matching lines...) Expand 10 before | Expand all | Expand 10 after
2938 2895
2939 RenderBox::BoxDecorationData::BoxDecorationData(const RenderStyle& style) 2896 RenderBox::BoxDecorationData::BoxDecorationData(const RenderStyle& style)
2940 { 2897 {
2941 backgroundColor = style.colorIncludingFallback(CSSPropertyBackgroundColor); 2898 backgroundColor = style.colorIncludingFallback(CSSPropertyBackgroundColor);
2942 hasBackground = backgroundColor.alpha() || style.hasBackgroundImage(); 2899 hasBackground = backgroundColor.alpha() || style.hasBackgroundImage();
2943 ASSERT(hasBackground == style.hasBackground()); 2900 ASSERT(hasBackground == style.hasBackground());
2944 hasBorder = style.hasBorder(); 2901 hasBorder = style.hasBorder();
2945 } 2902 }
2946 2903
2947 } // namespace blink 2904 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/rendering/RenderBox.h ('k') | sky/engine/core/rendering/RenderFlexibleBox.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698