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

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

Issue 610423004: Preserve fractional scroll offset for JS scrolling API (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
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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 void PinchViewport::scrollIntoView(const FloatRect& rect) 129 void PinchViewport::scrollIntoView(const FloatRect& rect)
130 { 130 {
131 if (!mainFrame() || !mainFrame()->view()) 131 if (!mainFrame() || !mainFrame()->view())
132 return; 132 return;
133 133
134 FrameView* view = mainFrame()->view(); 134 FrameView* view = mainFrame()->view();
135 135
136 float centeringOffsetX = (visibleRect().width() - rect.width()) / 2; 136 float centeringOffsetX = (visibleRect().width() - rect.width()) / 2;
137 float centeringOffsetY = (visibleRect().height() - rect.height()) / 2; 137 float centeringOffsetY = (visibleRect().height() - rect.height()) / 2;
138 138
139 FloatPoint targetOffset( 139 DoublePoint targetOffset(
140 rect.x() - centeringOffsetX - visibleRect().x(), 140 rect.x() - centeringOffsetX - visibleRect().x(),
141 rect.y() - centeringOffsetY - visibleRect().y()); 141 rect.y() - centeringOffsetY - visibleRect().y());
142 142
143 view->setScrollPosition(flooredIntPoint(targetOffset)); 143 view->setScrollPosition(targetOffset);
144 144
145 FloatPoint remainder = FloatPoint(targetOffset - view->scrollPosition()); 145 DoublePoint remainder = DoublePoint(targetOffset - view->scrollPositionDoubl e());
146 move(remainder); 146 move(toFloatPoint(remainder));
147 } 147 }
148 148
149 void PinchViewport::setLocation(const FloatPoint& newLocation) 149 void PinchViewport::setLocation(const FloatPoint& newLocation)
150 { 150 {
151 setScaleAndLocation(m_scale, newLocation); 151 setScaleAndLocation(m_scale, newLocation);
152 } 152 }
153 153
154 void PinchViewport::move(const FloatPoint& delta) 154 void PinchViewport::move(const FloatPoint& delta)
155 { 155 {
156 setLocation(m_offset + delta); 156 setLocation(m_offset + delta);
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 } else if (graphicsLayer == m_overlayScrollbarVertical.get()) { 475 } else if (graphicsLayer == m_overlayScrollbarVertical.get()) {
476 name = "Overlay Scrollbar Vertical Layer"; 476 name = "Overlay Scrollbar Vertical Layer";
477 } else { 477 } else {
478 ASSERT_NOT_REACHED(); 478 ASSERT_NOT_REACHED();
479 } 479 }
480 480
481 return name; 481 return name;
482 } 482 }
483 483
484 } // namespace blink 484 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698