Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 142 return rectInViewport; | 142 return rectInViewport; |
| 143 } | 143 } |
| 144 | 144 |
| 145 void PinchViewport::scrollIntoView(const LayoutRect& rect) | 145 void PinchViewport::scrollIntoView(const LayoutRect& rect) |
| 146 { | 146 { |
| 147 if (!mainFrame() || !mainFrame()->view()) | 147 if (!mainFrame() || !mainFrame()->view()) |
| 148 return; | 148 return; |
| 149 | 149 |
| 150 FrameView* view = mainFrame()->view(); | 150 FrameView* view = mainFrame()->view(); |
| 151 | 151 |
| 152 // Snap the visible rect to layout units to match the input rect. | 152 // Snap the visible rect to layout units to match the input rect. Intersect |
| 153 FloatRect visible = LayoutRect(visibleRect()); | 153 // with the FrameView so that we exclude scrollbars from the visible area. |
| 154 FloatRect visible = intersection( | |
| 155 LayoutRect(visibleRectInDocument()), | |
| 156 LayoutRect(view->visibleContentRect())); | |
| 154 | 157 |
| 155 float centeringOffsetX = (visible.width() - rect.width()) / 2; | 158 float centeringOffsetX = (visible.width() - rect.width()) / 2; |
| 156 float centeringOffsetY = (visible.height() - rect.height()) / 2; | 159 float centeringOffsetY = (visible.height() - rect.height()) / 2; |
| 157 | 160 |
| 158 DoublePoint targetOffset( | 161 DoublePoint targetOffset( |
| 159 rect.x() - centeringOffsetX - visible.x(), | 162 rect.x() - centeringOffsetX, |
| 160 rect.y() - centeringOffsetY - visible.y()); | 163 rect.y() - centeringOffsetY); |
|
bokan
2015/01/15 23:53:01
visibleRect() is relative to the FrameView, since
| |
| 161 | 164 |
| 162 view->setScrollPosition(targetOffset); | 165 view->setScrollPosition(targetOffset); |
| 163 | 166 |
| 164 DoublePoint remainder = DoublePoint(targetOffset - view->scrollPositionDoubl e()); | 167 DoublePoint remainder = DoublePoint(targetOffset - view->scrollPositionDoubl e()); |
| 165 move(toFloatPoint(remainder)); | 168 move(toFloatPoint(remainder)); |
| 166 } | 169 } |
| 167 | 170 |
| 168 void PinchViewport::setLocation(const FloatPoint& newLocation) | 171 void PinchViewport::setLocation(const FloatPoint& newLocation) |
| 169 { | 172 { |
| 170 setScaleAndLocation(m_scale, newLocation); | 173 setScaleAndLocation(m_scale, newLocation); |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 546 } else if (graphicsLayer == m_rootTransformLayer) { | 549 } else if (graphicsLayer == m_rootTransformLayer) { |
| 547 name = "Root Transform Layer"; | 550 name = "Root Transform Layer"; |
| 548 } else { | 551 } else { |
| 549 ASSERT_NOT_REACHED(); | 552 ASSERT_NOT_REACHED(); |
| 550 } | 553 } |
| 551 | 554 |
| 552 return name; | 555 return name; |
| 553 } | 556 } |
| 554 | 557 |
| 555 } // namespace blink | 558 } // namespace blink |
| OLD | NEW |