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

Side by Side Diff: third_party/WebKit/Source/platform/scroll/ScrollableArea.cpp

Issue 1957103002: Exclude scrollbars from visual viewport dimensions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit Created 4 years, 7 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/platform/scroll/ScrollableArea.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) 2010, Google Inc. All rights reserved. 2 * Copyright (c) 2010, Google Inc. All rights reserved.
3 * Copyright (C) 2008, 2011 Apple Inc. All Rights Reserved. 3 * Copyright (C) 2008, 2011 Apple Inc. All Rights Reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 return true; 539 return true;
540 } 540 }
541 541
542 DoubleRect ScrollableArea::visibleContentRectDouble(IncludeScrollbarsInRect scro llbarInclusion) const 542 DoubleRect ScrollableArea::visibleContentRectDouble(IncludeScrollbarsInRect scro llbarInclusion) const
543 { 543 {
544 return visibleContentRect(scrollbarInclusion); 544 return visibleContentRect(scrollbarInclusion);
545 } 545 }
546 546
547 IntRect ScrollableArea::visibleContentRect(IncludeScrollbarsInRect scrollbarIncl usion) const 547 IntRect ScrollableArea::visibleContentRect(IncludeScrollbarsInRect scrollbarIncl usion) const
548 { 548 {
549 int verticalScrollbarWidth = 0; 549 int scrollbarWidth = scrollbarInclusion == IncludeScrollbars ? verticalScrol lbarWidth() : 0;
550 int horizontalScrollbarHeight = 0; 550 int scrollbarHeight = scrollbarInclusion == IncludeScrollbars ? horizontalSc rollbarHeight() : 0;
551 551
552 if (scrollbarInclusion == IncludeScrollbars) { 552 return IntRect(
553 if (Scrollbar* verticalBar = verticalScrollbar()) 553 scrollPosition().x(),
554 verticalScrollbarWidth = !verticalBar->isOverlayScrollbar() ? vertic alBar->width() : 0; 554 scrollPosition().y(),
555 if (Scrollbar* horizontalBar = horizontalScrollbar()) 555 std::max(0, visibleWidth() + scrollbarWidth),
556 horizontalScrollbarHeight = !horizontalBar->isOverlayScrollbar() ? h orizontalBar->height() : 0; 556 std::max(0, visibleHeight() + scrollbarHeight));
557 }
558
559 return IntRect(scrollPosition().x(),
560 scrollPosition().y(),
561 std::max(0, visibleWidth() + verticalScrollbarWidth),
562 std::max(0, visibleHeight() + horizontalScrollbarHeight));
563 } 557 }
564 558
565 IntPoint ScrollableArea::clampScrollPosition(const IntPoint& scrollPosition) con st 559 IntPoint ScrollableArea::clampScrollPosition(const IntPoint& scrollPosition) con st
566 { 560 {
567 return scrollPosition.shrunkTo(maximumScrollPosition()).expandedTo(minimumSc rollPosition()); 561 return scrollPosition.shrunkTo(maximumScrollPosition()).expandedTo(minimumSc rollPosition());
568 } 562 }
569 563
570 DoublePoint ScrollableArea::clampScrollPosition(const DoublePoint& scrollPositio n) const 564 DoublePoint ScrollableArea::clampScrollPosition(const DoublePoint& scrollPositio n) const
571 { 565 {
572 return scrollPosition.shrunkTo(maximumScrollPositionDouble()).expandedTo(min imumScrollPositionDouble()); 566 return scrollPosition.shrunkTo(maximumScrollPositionDouble()).expandedTo(min imumScrollPositionDouble());
(...skipping 17 matching lines...) Expand all
590 int ScrollableArea::documentStep(ScrollbarOrientation orientation) const 584 int ScrollableArea::documentStep(ScrollbarOrientation orientation) const
591 { 585 {
592 return scrollSize(orientation); 586 return scrollSize(orientation);
593 } 587 }
594 588
595 float ScrollableArea::pixelStep(ScrollbarOrientation) const 589 float ScrollableArea::pixelStep(ScrollbarOrientation) const
596 { 590 {
597 return 1; 591 return 1;
598 } 592 }
599 593
594 int ScrollableArea::verticalScrollbarWidth() const
595 {
596 if (Scrollbar* verticalBar = verticalScrollbar())
597 return !verticalBar->isOverlayScrollbar() ? verticalBar->width() : 0;
598 return 0;
599 }
600
601 int ScrollableArea::horizontalScrollbarHeight() const
602 {
603 if (Scrollbar* horizontalBar = horizontalScrollbar())
604 return !horizontalBar->isOverlayScrollbar() ? horizontalBar->height() : 0;
605 return 0;
606 }
607
600 IntSize ScrollableArea::excludeScrollbars(const IntSize& size) const 608 IntSize ScrollableArea::excludeScrollbars(const IntSize& size) const
601 { 609 {
602 int verticalScrollbarWidth = 0; 610 return IntSize(std::max(0, size.width() - verticalScrollbarWidth()),
603 int horizontalScrollbarHeight = 0; 611 std::max(0, size.height() - horizontalScrollbarHeight()));
604
605 if (Scrollbar* verticalBar = verticalScrollbar())
606 verticalScrollbarWidth = !verticalBar->isOverlayScrollbar() ? verticalBa r->width() : 0;
607 if (Scrollbar* horizontalBar = horizontalScrollbar())
608 horizontalScrollbarHeight = !horizontalBar->isOverlayScrollbar() ? horiz ontalBar->height() : 0;
609
610 return IntSize(std::max(0, size.width() - verticalScrollbarWidth),
611 std::max(0, size.height() - horizontalScrollbarHeight));
612 } 612 }
613 613
614 DEFINE_TRACE(ScrollableArea) 614 DEFINE_TRACE(ScrollableArea)
615 { 615 {
616 visitor->trace(m_scrollAnimator); 616 visitor->trace(m_scrollAnimator);
617 visitor->trace(m_programmaticScrollAnimator); 617 visitor->trace(m_programmaticScrollAnimator);
618 } 618 }
619 619
620 } // namespace blink 620 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/scroll/ScrollableArea.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698