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

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

Issue 678153003: Use layout units in PinchViewport::scrollIntoView. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 1 month 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/tests/PinchViewportTest.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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 { 126 {
127 if (!mainFrame() || !mainFrame()->view()) 127 if (!mainFrame() || !mainFrame()->view())
128 return FloatRect(); 128 return FloatRect();
129 129
130 FloatRect viewRect = mainFrame()->view()->visibleContentRect(); 130 FloatRect viewRect = mainFrame()->view()->visibleContentRect();
131 FloatRect pinchRect = visibleRect(); 131 FloatRect pinchRect = visibleRect();
132 pinchRect.moveBy(viewRect.location()); 132 pinchRect.moveBy(viewRect.location());
133 return pinchRect; 133 return pinchRect;
134 } 134 }
135 135
136 void PinchViewport::scrollIntoView(const FloatRect& rect) 136 void PinchViewport::scrollIntoView(const LayoutRect& rect)
137 { 137 {
138 if (!mainFrame() || !mainFrame()->view()) 138 if (!mainFrame() || !mainFrame()->view())
139 return; 139 return;
140 140
141 FrameView* view = mainFrame()->view(); 141 FrameView* view = mainFrame()->view();
142 142
143 float centeringOffsetX = (visibleRect().width() - rect.width()) / 2; 143 // Snap the visible rect to layout units to match the input rect.
144 float centeringOffsetY = (visibleRect().height() - rect.height()) / 2; 144 FloatRect visible = LayoutRect(visibleRect());
145
146 float centeringOffsetX = (visible.width() - rect.width()) / 2;
147 float centeringOffsetY = (visible.height() - rect.height()) / 2;
145 148
146 DoublePoint targetOffset( 149 DoublePoint targetOffset(
147 rect.x() - centeringOffsetX - visibleRect().x(), 150 rect.x() - centeringOffsetX - visible.x(),
148 rect.y() - centeringOffsetY - visibleRect().y()); 151 rect.y() - centeringOffsetY - visible.y());
149 152
150 view->setScrollPosition(targetOffset); 153 view->setScrollPosition(targetOffset);
151 154
152 DoublePoint remainder = DoublePoint(targetOffset - view->scrollPositionDoubl e()); 155 DoublePoint remainder = DoublePoint(targetOffset - view->scrollPositionDoubl e());
153 move(toFloatPoint(remainder)); 156 move(toFloatPoint(remainder));
154 } 157 }
155 158
156 void PinchViewport::setLocation(const FloatPoint& newLocation) 159 void PinchViewport::setLocation(const FloatPoint& newLocation)
157 { 160 {
158 setScaleAndLocation(m_scale, newLocation); 161 setScaleAndLocation(m_scale, newLocation);
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 } else if (graphicsLayer == m_rootTransformLayer) { 518 } else if (graphicsLayer == m_rootTransformLayer) {
516 name = "Root Transform Layer"; 519 name = "Root Transform Layer";
517 } else { 520 } else {
518 ASSERT_NOT_REACHED(); 521 ASSERT_NOT_REACHED();
519 } 522 }
520 523
521 return name; 524 return name;
522 } 525 }
523 526
524 } // namespace blink 527 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/frame/PinchViewport.h ('k') | Source/web/tests/PinchViewportTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698