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

Side by Side Diff: Source/core/frame/PinchViewport.cpp

Issue 655763002: Revert of Made top controls work with virtual viewport pinch-to-zoom. (Blink) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 2 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 | « Source/core/frame/PinchViewport.h ('k') | Source/web/PageScaleConstraintsSet.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) 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 using blink::WebScrollbarLayer; 60 using blink::WebScrollbarLayer;
61 using blink::FrameHost; 61 using blink::FrameHost;
62 using blink::GraphicsLayer; 62 using blink::GraphicsLayer;
63 using blink::GraphicsLayerFactory; 63 using blink::GraphicsLayerFactory;
64 64
65 namespace blink { 65 namespace blink {
66 66
67 PinchViewport::PinchViewport(FrameHost& owner) 67 PinchViewport::PinchViewport(FrameHost& owner)
68 : m_frameHost(owner) 68 : m_frameHost(owner)
69 , m_scale(1) 69 , m_scale(1)
70 , m_topControlsAdjustment(0)
71 { 70 {
72 reset(); 71 reset();
73 } 72 }
74 73
75 PinchViewport::~PinchViewport() { } 74 PinchViewport::~PinchViewport() { }
76 75
77 void PinchViewport::setSize(const IntSize& size) 76 void PinchViewport::setSize(const IntSize& size)
78 { 77 {
79 if (m_size == size) 78 if (m_size == size)
80 return; 79 return;
81 80
82 TRACE_EVENT2("blink", "PinchViewport::setSize", "width", size.width(), "heig ht", size.height()); 81 TRACE_EVENT2("blink", "PinchViewport::setSize", "width", size.width(), "heig ht", size.height());
83 m_size = size; 82 m_size = size;
84 83
84 clampToBoundaries();
85
85 if (m_innerViewportContainerLayer) { 86 if (m_innerViewportContainerLayer) {
86 m_innerViewportContainerLayer->setSize(m_size); 87 m_innerViewportContainerLayer->setSize(m_size);
87 88
88 // Need to re-compute sizes for the overlay scrollbars. 89 // Need to re-compute sizes for the overlay scrollbars.
89 setupScrollbar(WebScrollbar::Horizontal); 90 setupScrollbar(WebScrollbar::Horizontal);
90 setupScrollbar(WebScrollbar::Vertical); 91 setupScrollbar(WebScrollbar::Vertical);
91 } 92 }
92 } 93 }
93 94
94 void PinchViewport::reset() 95 void PinchViewport::reset()
95 { 96 {
96 setScaleAndLocation(1, FloatPoint()); 97 setScaleAndLocation(1, FloatPoint());
97 } 98 }
98 99
99 void PinchViewport::mainFrameDidChangeSize() 100 void PinchViewport::mainFrameDidChangeSize()
100 { 101 {
101 TRACE_EVENT0("blink", "PinchViewport::mainFrameDidChangeSize"); 102 TRACE_EVENT0("blink", "PinchViewport::mainFrameDidChangeSize");
102 103
103 // In unit tests we may not have initialized the layer tree. 104 // In unit tests we may not have initialized the layer tree.
104 if (m_innerViewportScrollLayer) 105 if (m_innerViewportScrollLayer)
105 m_innerViewportScrollLayer->setSize(contentsSize()); 106 m_innerViewportScrollLayer->setSize(contentsSize());
106 107
107 clampToBoundaries(); 108 clampToBoundaries();
108 } 109 }
109 110
110 FloatRect PinchViewport::visibleRect() const 111 FloatRect PinchViewport::visibleRect() const
111 { 112 {
112 FloatSize scaledSize(m_size); 113 FloatSize scaledSize(m_size);
113 scaledSize.expand(0, m_topControlsAdjustment);
114 scaledSize.scale(1 / m_scale); 114 scaledSize.scale(1 / m_scale);
115 return FloatRect(m_offset, scaledSize); 115 return FloatRect(m_offset, scaledSize);
116 } 116 }
117 117
118 FloatRect PinchViewport::visibleRectInDocument() const 118 FloatRect PinchViewport::visibleRectInDocument() const
119 { 119 {
120 if (!mainFrame() || !mainFrame()->view()) 120 if (!mainFrame() || !mainFrame()->view())
121 return FloatRect(); 121 return FloatRect();
122 122
123 FloatRect viewRect = mainFrame()->view()->visibleContentRect(); 123 FloatRect viewRect = mainFrame()->view()->visibleContentRect();
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 return (orientation == HorizontalScrollbar) ? scrollDimensions.width() : scr ollDimensions.height(); 349 return (orientation == HorizontalScrollbar) ? scrollDimensions.width() : scr ollDimensions.height();
350 } 350 }
351 351
352 IntPoint PinchViewport::minimumScrollPosition() const 352 IntPoint PinchViewport::minimumScrollPosition() const
353 { 353 {
354 return IntPoint(); 354 return IntPoint();
355 } 355 }
356 356
357 IntPoint PinchViewport::maximumScrollPosition() const 357 IntPoint PinchViewport::maximumScrollPosition() const
358 { 358 {
359 // FIXME: We probably shouldn't be storing the bounds in a float. crbug.com/ 422331. 359 return flooredIntPoint(FloatSize(contentsSize()) - visibleRect().size());
360 FloatSize frameViewSize(contentsSize());
361
362 if (m_topControlsAdjustment) {
363 float aspectRatio = visibleRect().width() / visibleRect().height();
364 float adjustment = frameViewSize.width() / aspectRatio - frameViewSize.h eight();
365 frameViewSize.expand(0, adjustment);
366 }
367
368 frameViewSize.scale(m_scale);
369 frameViewSize = flooredIntSize(frameViewSize);
370
371 FloatSize viewportSize(m_size);
372 viewportSize.expand(0, m_topControlsAdjustment);
373
374 FloatSize maxPosition = frameViewSize - viewportSize;
375 maxPosition.scale(1 / m_scale);
376
377 return flooredIntPoint(maxPosition);
378 } 360 }
379 361
380 IntPoint PinchViewport::clampDocumentOffsetAtScale(const IntPoint& offset, float scale) 362 IntPoint PinchViewport::clampDocumentOffsetAtScale(const IntPoint& offset, float scale)
381 { 363 {
382 if (!mainFrame() || !mainFrame()->view()) 364 if (!mainFrame() || !mainFrame()->view())
383 return IntPoint(); 365 return IntPoint();
384 366
385 FrameView* view = mainFrame()->view(); 367 FrameView* view = mainFrame()->view();
386 368
387 FloatSize scaledSize(m_size); 369 FloatSize scaledSize(m_size);
388 scaledSize.scale(1 / scale); 370 scaledSize.scale(1 / scale);
389 371
390 IntPoint pinchViewportMax = flooredIntPoint(FloatSize(contentsSize()) - scal edSize); 372 IntPoint pinchViewportMax = flooredIntPoint(FloatSize(contentsSize()) - scal edSize);
391 IntPoint max = view->maximumScrollPosition() + pinchViewportMax; 373 IntPoint max = view->maximumScrollPosition() + pinchViewportMax;
392 IntPoint min = view->minimumScrollPosition(); // PinchViewportMin should be (0, 0) 374 IntPoint min = view->minimumScrollPosition(); // PinchViewportMin should be (0, 0)
393 375
394 IntPoint clamped = offset; 376 IntPoint clamped = offset;
395 clamped = clamped.shrunkTo(max); 377 clamped = clamped.shrunkTo(max);
396 clamped = clamped.expandedTo(min); 378 clamped = clamped.expandedTo(min);
397 return clamped; 379 return clamped;
398 } 380 }
399 381
400 void PinchViewport::setTopControlsAdjustment(float adjustment)
401 {
402 m_topControlsAdjustment = adjustment;
403 }
404
405 IntRect PinchViewport::scrollableAreaBoundingBox() const 382 IntRect PinchViewport::scrollableAreaBoundingBox() const
406 { 383 {
407 // This method should return the bounding box in the parent view's coordinat e 384 // This method should return the bounding box in the parent view's coordinat e
408 // space; however, PinchViewport technically isn't a child of any Frames. 385 // space; however, PinchViewport technically isn't a child of any Frames.
409 // Nonetheless, the PinchViewport always occupies the entire main frame so j ust 386 // Nonetheless, the PinchViewport always occupies the entire main frame so j ust
410 // return that. 387 // return that.
411 LocalFrame* frame = mainFrame(); 388 LocalFrame* frame = mainFrame();
412 389
413 if (!frame || !frame->view()) 390 if (!frame || !frame->view())
414 return IntRect(); 391 return IntRect();
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 } else if (graphicsLayer == m_overlayScrollbarVertical.get()) { 475 } else if (graphicsLayer == m_overlayScrollbarVertical.get()) {
499 name = "Overlay Scrollbar Vertical Layer"; 476 name = "Overlay Scrollbar Vertical Layer";
500 } else { 477 } else {
501 ASSERT_NOT_REACHED(); 478 ASSERT_NOT_REACHED();
502 } 479 }
503 480
504 return name; 481 return name;
505 } 482 }
506 483
507 } // namespace blink 484 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/frame/PinchViewport.h ('k') | Source/web/PageScaleConstraintsSet.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698