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

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

Issue 783393006: Remove relayout due to scrollbars taking up width (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: 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
« no previous file with comments | « sky/engine/core/rendering/RenderLayerScrollableArea.h ('k') | sky/engine/public/web/WebFrame.h » ('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) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
3 * 3 *
4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation.
5 * 5 *
6 * Other contributors: 6 * Other contributors:
7 * Robert O'Callahan <roc+@cs.cmu.edu> 7 * Robert O'Callahan <roc+@cs.cmu.edu>
8 * David Baron <dbaron@fas.harvard.edu> 8 * David Baron <dbaron@fas.harvard.edu>
9 * Christian Biesinger <cbiesinger@web.de> 9 * Christian Biesinger <cbiesinger@web.de>
10 * Randall Jesup <rjesup@wgate.com> 10 * Randall Jesup <rjesup@wgate.com>
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 #include "sky/engine/platform/scroll/ScrollAnimator.h" 63 #include "sky/engine/platform/scroll/ScrollAnimator.h"
64 #include "sky/engine/platform/scroll/Scrollbar.h" 64 #include "sky/engine/platform/scroll/Scrollbar.h"
65 #include "sky/engine/public/platform/Platform.h" 65 #include "sky/engine/public/platform/Platform.h"
66 66
67 namespace blink { 67 namespace blink {
68 68
69 RenderLayerScrollableArea::RenderLayerScrollableArea(RenderLayer& layer) 69 RenderLayerScrollableArea::RenderLayerScrollableArea(RenderLayer& layer)
70 : m_layer(layer) 70 : m_layer(layer)
71 , m_scrollsOverflow(false) 71 , m_scrollsOverflow(false)
72 , m_scrollDimensionsDirty(true) 72 , m_scrollDimensionsDirty(true)
73 , m_inOverflowRelayout(false)
74 , m_nextTopmostScrollChild(0) 73 , m_nextTopmostScrollChild(0)
75 , m_topmostScrollChild(0) 74 , m_topmostScrollChild(0)
76 , m_needsCompositedScrolling(false) 75 , m_needsCompositedScrolling(false)
77 { 76 {
78 ScrollableArea::setConstrainsScrollingToContentEdge(false); 77 ScrollableArea::setConstrainsScrollingToContentEdge(false);
79 78
80 Node* node = box().node(); 79 Node* node = box().node();
81 if (node && node->isElementNode()) { 80 if (node && node->isElementNode()) {
82 // We save and restore only the scrollOffset as the other scroll values are recalculated. 81 // We save and restore only the scrollOffset as the other scroll values are recalculated.
83 Element* element = toElement(node); 82 Element* element = toElement(node);
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 IntSize clampedScrollOffset = clampScrollOffset(adjustedScrollOffset()); 400 IntSize clampedScrollOffset = clampScrollOffset(adjustedScrollOffset());
402 if (clampedScrollOffset != adjustedScrollOffset()) 401 if (clampedScrollOffset != adjustedScrollOffset())
403 scrollToOffset(clampedScrollOffset); 402 scrollToOffset(clampedScrollOffset);
404 403
405 if (originalScrollOffset != adjustedScrollOffset()) 404 if (originalScrollOffset != adjustedScrollOffset())
406 scrollToOffsetWithoutAnimation(-scrollOrigin() + adjustedScrollOffset()) ; 405 scrollToOffsetWithoutAnimation(-scrollOrigin() + adjustedScrollOffset()) ;
407 406
408 bool hasHorizontalOverflow = this->hasHorizontalOverflow(); 407 bool hasHorizontalOverflow = this->hasHorizontalOverflow();
409 bool hasVerticalOverflow = this->hasVerticalOverflow(); 408 bool hasVerticalOverflow = this->hasVerticalOverflow();
410 409
411 { 410 // overflow:scroll should just enable/disable.
412 // Hits in compositing/overflow/automatically-opt-into-composited-scroll ing-after-style-change.html. 411 if (box().style()->overflowX() == OSCROLL)
413 DisableCompositingQueryAsserts disabler; 412 horizontalScrollbar()->setEnabled(hasHorizontalOverflow);
414 413 if (box().style()->overflowY() == OSCROLL)
415 // overflow:scroll should just enable/disable. 414 verticalScrollbar()->setEnabled(hasVerticalOverflow);
416 if (box().style()->overflowX() == OSCROLL)
417 horizontalScrollbar()->setEnabled(hasHorizontalOverflow);
418 if (box().style()->overflowY() == OSCROLL)
419 verticalScrollbar()->setEnabled(hasVerticalOverflow);
420 }
421 415
422 // overflow:auto may need to lay out again if scrollbars got added/removed. 416 // overflow:auto may need to lay out again if scrollbars got added/removed.
423 bool autoHorizontalScrollBarChanged = box().hasAutoHorizontalScrollbar() && (hasHorizontalScrollbar() != hasHorizontalOverflow); 417 if (box().hasAutoHorizontalScrollbar())
424 bool autoVerticalScrollBarChanged = box().hasAutoVerticalScrollbar() && (has VerticalScrollbar() != hasVerticalOverflow); 418 setHasHorizontalScrollbar(hasHorizontalOverflow);
ojan 2014/12/10 03:40:38 These already have the hasHorizontalScrollbar() !=
419 if (box().hasAutoVerticalScrollbar())
420 setHasVerticalScrollbar(hasVerticalOverflow);
425 421
426 if (autoHorizontalScrollBarChanged || autoVerticalScrollBarChanged) { 422 // Set up the range (and page step/line step).
427 if (box().hasAutoHorizontalScrollbar()) 423 if (Scrollbar* horizontalScrollbar = this->horizontalScrollbar()) {
428 setHasHorizontalScrollbar(hasHorizontalOverflow); 424 int clientWidth = box().pixelSnappedClientWidth();
429 if (box().hasAutoVerticalScrollbar()) 425 horizontalScrollbar->setProportion(clientWidth, overflowRect().width());
430 setHasVerticalScrollbar(hasVerticalOverflow);
431
432 layer()->updateSelfPaintingLayer();
433
434 if (box().style()->overflowX() == OAUTO || box().style()->overflowY() == OAUTO) {
435 if (!m_inOverflowRelayout) {
436 // Our proprietary overflow: overlay value doesn't trigger a lay out.
437 m_inOverflowRelayout = true;
438 SubtreeLayoutScope layoutScope(box());
439 layoutScope.setNeedsLayout(&box());
440 if (box().isRenderBlock()) {
441 RenderBlock& block = toRenderBlock(box());
442 block.scrollbarsChanged(autoHorizontalScrollBarChanged, auto VerticalScrollBarChanged);
443 block.layoutBlock(true);
444 } else {
445 box().layout();
446 }
447 m_inOverflowRelayout = false;
448 }
449 }
450 } 426 }
451 427 if (Scrollbar* verticalScrollbar = this->verticalScrollbar()) {
452 { 428 int clientHeight = box().pixelSnappedClientHeight();
453 // Hits in compositing/overflow/automatically-opt-into-composited-scroll ing-after-style-change.html. 429 verticalScrollbar->setProportion(clientHeight, overflowRect().height());
454 DisableCompositingQueryAsserts disabler;
455
456 // Set up the range (and page step/line step).
457 if (Scrollbar* horizontalScrollbar = this->horizontalScrollbar()) {
458 int clientWidth = box().pixelSnappedClientWidth();
459 horizontalScrollbar->setProportion(clientWidth, overflowRect().width ());
460 }
461 if (Scrollbar* verticalScrollbar = this->verticalScrollbar()) {
462 int clientHeight = box().pixelSnappedClientHeight();
463 verticalScrollbar->setProportion(clientHeight, overflowRect().height ());
464 }
465 } 430 }
466 431
467 bool hasOverflow = hasScrollableHorizontalOverflow() || hasScrollableVertica lOverflow(); 432 bool hasOverflow = hasScrollableHorizontalOverflow() || hasScrollableVertica lOverflow();
468 updateScrollableAreaSet(hasOverflow); 433 updateScrollableAreaSet(hasOverflow);
469 434
470 if (hasOverflow) { 435 if (hasOverflow) {
471 DisableCompositingQueryAsserts disabler;
472 positionOverflowControls(IntSize()); 436 positionOverflowControls(IntSize());
473 } 437 }
474 } 438 }
475 439
476 bool RenderLayerScrollableArea::hasHorizontalOverflow() const 440 bool RenderLayerScrollableArea::hasHorizontalOverflow() const
477 { 441 {
478 ASSERT(!m_scrollDimensionsDirty); 442 ASSERT(!m_scrollDimensionsDirty);
479 443
480 return pixelSnappedScrollWidth() > box().pixelSnappedClientWidth(); 444 return pixelSnappedScrollWidth() > box().pixelSnappedClientWidth();
481 } 445 }
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 scrollbar->disconnectFromScrollableArea(); 620 scrollbar->disconnectFromScrollableArea();
657 scrollbar = nullptr; 621 scrollbar = nullptr;
658 } 622 }
659 623
660 void RenderLayerScrollableArea::setHasHorizontalScrollbar(bool hasScrollbar) 624 void RenderLayerScrollableArea::setHasHorizontalScrollbar(bool hasScrollbar)
661 { 625 {
662 if (hasScrollbar == hasHorizontalScrollbar()) 626 if (hasScrollbar == hasHorizontalScrollbar())
663 return; 627 return;
664 628
665 if (hasScrollbar) { 629 if (hasScrollbar) {
666 // This doesn't hit in any tests, but since the equivalent code in setHa sVerticalScrollbar
667 // does, presumably this code does as well.
668 DisableCompositingQueryAsserts disabler;
669 m_hBar = createScrollbar(HorizontalScrollbar); 630 m_hBar = createScrollbar(HorizontalScrollbar);
670 } else { 631 } else {
671 destroyScrollbar(HorizontalScrollbar); 632 destroyScrollbar(HorizontalScrollbar);
672 } 633 }
673 } 634 }
674 635
675 void RenderLayerScrollableArea::setHasVerticalScrollbar(bool hasScrollbar) 636 void RenderLayerScrollableArea::setHasVerticalScrollbar(bool hasScrollbar)
676 { 637 {
677 if (hasScrollbar == hasVerticalScrollbar()) 638 if (hasScrollbar == hasVerticalScrollbar())
678 return; 639 return;
679 640
680 if (hasScrollbar) { 641 if (hasScrollbar) {
681 // Hits in compositing/overflow/automatically-opt-into-composited-scroll ing-after-style-change.html
682 DisableCompositingQueryAsserts disabler;
683 m_vBar = createScrollbar(VerticalScrollbar); 642 m_vBar = createScrollbar(VerticalScrollbar);
684 } else { 643 } else {
685 destroyScrollbar(VerticalScrollbar); 644 destroyScrollbar(VerticalScrollbar);
686 } 645 }
687 } 646 }
688 647
689 void RenderLayerScrollableArea::positionOverflowControls(const IntSize& offsetFr omRoot) 648 void RenderLayerScrollableArea::positionOverflowControls(const IntSize& offsetFr omRoot)
690 { 649 {
691 if (!hasScrollbar()) 650 if (!hasScrollbar())
692 return; 651 return;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 void RenderLayerScrollableArea::setTopmostScrollChild(RenderLayer* scrollChild) 764 void RenderLayerScrollableArea::setTopmostScrollChild(RenderLayer* scrollChild)
806 { 765 {
807 // We only want to track the topmost scroll child for scrollable areas with 766 // We only want to track the topmost scroll child for scrollable areas with
808 // overlay scrollbars. 767 // overlay scrollbars.
809 if (!hasOverlayScrollbars()) 768 if (!hasOverlayScrollbars())
810 return; 769 return;
811 m_nextTopmostScrollChild = scrollChild; 770 m_nextTopmostScrollChild = scrollChild;
812 } 771 }
813 772
814 } // namespace blink 773 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/rendering/RenderLayerScrollableArea.h ('k') | sky/engine/public/web/WebFrame.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698