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

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

Issue 1672973002: ScrollableArea::pixelsPerLine should return viewport pixels in use-zoom-for-dsf mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 #if ENABLE(ASSERT) && ENABLE(OILPAN) 53 #if ENABLE(ASSERT) && ENABLE(OILPAN)
54 VerifyEagerFinalization verifyEager; 54 VerifyEagerFinalization verifyEager;
55 #endif 55 #endif
56 OwnPtrWillBeMember<void*> pointer[2]; 56 OwnPtrWillBeMember<void*> pointer[2];
57 unsigned bitfields : 16; 57 unsigned bitfields : 16;
58 IntPoint origin; 58 IntPoint origin;
59 }; 59 };
60 60
61 static_assert(sizeof(ScrollableArea) == sizeof(SameSizeAsScrollableArea), "Scrol lableArea should stay small"); 61 static_assert(sizeof(ScrollableArea) == sizeof(SameSizeAsScrollableArea), "Scrol lableArea should stay small");
62 62
63 int ScrollableArea::pixelsPerLineStep() 63 int ScrollableArea::pixelsPerLineStep(HostWindow* host)
64 { 64 {
65 return kPixelsPerLineStep; 65 if (!host)
66 return kPixelsPerLineStep;
67 FloatRect tmpRectInViewport = host->windowToViewport(FloatRect(1, 0, 0, 0));
skobes 2016/02/09 23:42:32 Can we introduce a clearer API that doesn't use re
oshima 2016/02/16 06:09:53 I was asked to either made this symmetric to viewp
68 return kPixelsPerLineStep * tmpRectInViewport.x();
66 } 69 }
67 70
68 float ScrollableArea::minFractionToStepWhenPaging() 71 float ScrollableArea::minFractionToStepWhenPaging()
69 { 72 {
70 return kMinFractionToStepWhenPaging; 73 return kMinFractionToStepWhenPaging;
71 } 74 }
72 75
73 int ScrollableArea::maxOverlapBetweenPages() 76 int ScrollableArea::maxOverlapBetweenPages()
74 { 77 {
75 static int maxOverlapBetweenPages = ScrollbarTheme::theme().maxOverlapBetwee nPages(); 78 static int maxOverlapBetweenPages = ScrollbarTheme::theme().maxOverlapBetwee nPages();
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 return scrollPosition.shrunkTo(maximumScrollPosition()).expandedTo(minimumSc rollPosition()); 562 return scrollPosition.shrunkTo(maximumScrollPosition()).expandedTo(minimumSc rollPosition());
560 } 563 }
561 564
562 DoublePoint ScrollableArea::clampScrollPosition(const DoublePoint& scrollPositio n) const 565 DoublePoint ScrollableArea::clampScrollPosition(const DoublePoint& scrollPositio n) const
563 { 566 {
564 return scrollPosition.shrunkTo(maximumScrollPositionDouble()).expandedTo(min imumScrollPositionDouble()); 567 return scrollPosition.shrunkTo(maximumScrollPositionDouble()).expandedTo(min imumScrollPositionDouble());
565 } 568 }
566 569
567 int ScrollableArea::lineStep(ScrollbarOrientation) const 570 int ScrollableArea::lineStep(ScrollbarOrientation) const
568 { 571 {
569 return pixelsPerLineStep(); 572 return pixelsPerLineStep(hostWindow());
570 } 573 }
571 574
572 int ScrollableArea::pageStep(ScrollbarOrientation orientation) const 575 int ScrollableArea::pageStep(ScrollbarOrientation orientation) const
573 { 576 {
574 IntRect visibleRect = visibleContentRect(IncludeScrollbars); 577 IntRect visibleRect = visibleContentRect(IncludeScrollbars);
575 int length = (orientation == HorizontalScrollbar) ? visibleRect.width() : vi sibleRect.height(); 578 int length = (orientation == HorizontalScrollbar) ? visibleRect.width() : vi sibleRect.height();
576 int minPageStep = static_cast<float>(length) * minFractionToStepWhenPaging() ; 579 int minPageStep = static_cast<float>(length) * minFractionToStepWhenPaging() ;
577 int pageStep = std::max(minPageStep, length - maxOverlapBetweenPages()); 580 int pageStep = std::max(minPageStep, length - maxOverlapBetweenPages());
578 581
579 return std::max(pageStep, 1); 582 return std::max(pageStep, 1);
580 } 583 }
581 584
582 int ScrollableArea::documentStep(ScrollbarOrientation orientation) const 585 int ScrollableArea::documentStep(ScrollbarOrientation orientation) const
583 { 586 {
584 return scrollSize(orientation); 587 return scrollSize(orientation);
585 } 588 }
586 589
587 float ScrollableArea::pixelStep(ScrollbarOrientation) const 590 float ScrollableArea::pixelStep(ScrollbarOrientation) const
588 { 591 {
592 if (HostWindow* window = hostWindow())
593 return window->windowToViewport(FloatRect(1, 0, 0, 0)).x();
589 return 1; 594 return 1;
590 } 595 }
591 596
592 IntSize ScrollableArea::excludeScrollbars(const IntSize& size) const 597 IntSize ScrollableArea::excludeScrollbars(const IntSize& size) const
593 { 598 {
594 int verticalScrollbarWidth = 0; 599 int verticalScrollbarWidth = 0;
595 int horizontalScrollbarHeight = 0; 600 int horizontalScrollbarHeight = 0;
596 601
597 if (Scrollbar* verticalBar = verticalScrollbar()) 602 if (Scrollbar* verticalBar = verticalScrollbar())
598 verticalScrollbarWidth = !verticalBar->isOverlayScrollbar() ? verticalBa r->width() : 0; 603 verticalScrollbarWidth = !verticalBar->isOverlayScrollbar() ? verticalBa r->width() : 0;
599 if (Scrollbar* horizontalBar = horizontalScrollbar()) 604 if (Scrollbar* horizontalBar = horizontalScrollbar())
600 horizontalScrollbarHeight = !horizontalBar->isOverlayScrollbar() ? horiz ontalBar->height() : 0; 605 horizontalScrollbarHeight = !horizontalBar->isOverlayScrollbar() ? horiz ontalBar->height() : 0;
601 606
602 return IntSize(std::max(0, size.width() - verticalScrollbarWidth), 607 return IntSize(std::max(0, size.width() - verticalScrollbarWidth),
603 std::max(0, size.height() - horizontalScrollbarHeight)); 608 std::max(0, size.height() - horizontalScrollbarHeight));
604 } 609 }
605 610
606 DEFINE_TRACE(ScrollableArea) 611 DEFINE_TRACE(ScrollableArea)
607 { 612 {
608 visitor->trace(m_scrollAnimator); 613 visitor->trace(m_scrollAnimator);
609 visitor->trace(m_programmaticScrollAnimator); 614 visitor->trace(m_programmaticScrollAnimator);
610 } 615 }
611 616
612 } // namespace blink 617 } // 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