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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 82 } | 82 } |
| 83 | 83 |
| 84 DEFINE_TRACE(VisualViewport) | 84 DEFINE_TRACE(VisualViewport) |
| 85 { | 85 { |
| 86 visitor->trace(m_frameHost); | 86 visitor->trace(m_frameHost); |
| 87 ScrollableArea::trace(visitor); | 87 ScrollableArea::trace(visitor); |
| 88 } | 88 } |
| 89 | 89 |
| 90 void VisualViewport::setSize(const IntSize& size) | 90 void VisualViewport::setSize(const IntSize& size) |
| 91 { | 91 { |
| 92 // When the main frame is remote, we won't have an associated frame. | |
| 93 if (!mainFrame()) | |
| 94 return; | |
| 95 | |
| 96 if (m_size == size) | 92 if (m_size == size) |
| 97 return; | 93 return; |
| 98 | 94 |
| 99 bool autosizerNeedsUpdating = | 95 bool autosizerNeedsUpdating = (size.width() != m_size.width()) |
| 100 (size.width() != m_size.width()) | 96 && mainFrame() |
| 101 && mainFrame()->settings() | 97 && mainFrame()->settings() |
| 102 && mainFrame()->settings()->textAutosizingEnabled(); | 98 && mainFrame()->settings()->textAutosizingEnabled(); |
| 103 | 99 |
| 104 TRACE_EVENT2("blink", "VisualViewport::setSize", "width", size.width(), "hei ght", size.height()); | 100 TRACE_EVENT2("blink", "VisualViewport::setSize", "width", size.width(), "hei ght", size.height()); |
| 105 m_size = size; | 101 m_size = size; |
| 106 | 102 |
| 107 if (m_innerViewportContainerLayer) { | 103 if (m_innerViewportContainerLayer) { |
| 108 m_innerViewportContainerLayer->setSize(FloatSize(m_size)); | 104 m_innerViewportContainerLayer->setSize(FloatSize(m_size)); |
| 109 | 105 |
| 110 // Need to re-compute sizes for the overlay scrollbars. | 106 // Need to re-compute sizes for the overlay scrollbars. |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 185 void VisualViewport::move(const FloatSize& delta) | 181 void VisualViewport::move(const FloatSize& delta) |
| 186 { | 182 { |
| 187 setLocation(m_offset + delta); | 183 setLocation(m_offset + delta); |
| 188 } | 184 } |
| 189 | 185 |
| 190 void VisualViewport::setScale(float scale) | 186 void VisualViewport::setScale(float scale) |
| 191 { | 187 { |
| 192 setScaleAndLocation(scale, m_offset); | 188 setScaleAndLocation(scale, m_offset); |
| 193 } | 189 } |
| 194 | 190 |
| 195 void VisualViewport::setScaleAndLocation(float scale, const FloatPoint& location ) | 191 void VisualViewport::setScaleAndLocation(float scale, const FloatPoint& location ) |
|
dcheng
2016/01/08 21:36:06
What actually needs to run in here for a WebView w
bokan
2016/01/11 16:36:34
Can a remote frame even be pinch-zoomed? I think m
kenrb
2016/01/11 17:07:24
Pinch zoom doesn't really make sense on remote fra
bokan
2016/01/11 18:18:58
It sounds fine in principle but practically speaki
kenrb
2016/01/11 20:50:26
I've removed this in the most recent patchset, sin
| |
| 196 { | 192 { |
| 197 if (!mainFrame()) | |
| 198 return; | |
| 199 | |
| 200 bool valuesChanged = false; | 193 bool valuesChanged = false; |
| 201 | 194 |
| 202 if (scale != m_scale) { | 195 if (scale != m_scale) { |
| 203 m_scale = scale; | 196 m_scale = scale; |
| 204 valuesChanged = true; | 197 valuesChanged = true; |
| 205 frameHost().chromeClient().pageScaleFactorChanged(); | 198 frameHost().chromeClient().pageScaleFactorChanged(); |
| 206 } | 199 } |
| 207 | 200 |
| 208 FloatPoint clampedOffset(clampOffsetToBoundaries(location)); | 201 FloatPoint clampedOffset(clampOffsetToBoundaries(location)); |
| 209 | 202 |
| 210 if (clampedOffset != m_offset) { | 203 if (clampedOffset != m_offset) { |
| 211 m_offset = clampedOffset; | 204 m_offset = clampedOffset; |
| 212 scrollAnimator().setCurrentPosition(m_offset); | 205 scrollAnimator().setCurrentPosition(m_offset); |
| 213 | 206 |
| 214 // SVG runs with accelerated compositing disabled so no ScrollingCoordin ator. | 207 // SVG runs with accelerated compositing disabled so no ScrollingCoordin ator. |
| 215 if (ScrollingCoordinator* coordinator = frameHost().page().scrollingCoor dinator()) | 208 if (ScrollingCoordinator* coordinator = frameHost().page().scrollingCoor dinator()) |
| 216 coordinator->scrollableAreaScrollLayerDidChange(this); | 209 coordinator->scrollableAreaScrollLayerDidChange(this); |
| 217 | 210 |
| 218 if (!frameHost().settings().inertVisualViewport()) { | 211 if (!frameHost().settings().inertVisualViewport() && mainFrame()) { |
| 219 if (Document* document = mainFrame()->document()) | 212 if (Document* document = mainFrame()->document()) |
| 220 document->enqueueScrollEventForNode(document); | 213 document->enqueueScrollEventForNode(document); |
| 221 } | 214 } |
| 222 | 215 |
| 223 mainFrame()->loader().client()->didChangeScrollOffset(); | 216 if (mainFrame()) |
| 217 mainFrame()->loader().client()->didChangeScrollOffset(); | |
| 224 valuesChanged = true; | 218 valuesChanged = true; |
| 225 } | 219 } |
| 226 | 220 |
| 227 if (!valuesChanged) | 221 if (!valuesChanged) |
| 228 return; | 222 return; |
| 229 | 223 |
| 230 InspectorInstrumentation::didUpdateLayout(mainFrame()); | 224 if (mainFrame()) { |
| 231 mainFrame()->loader().saveScrollState(); | 225 InspectorInstrumentation::didUpdateLayout(mainFrame()); |
| 226 mainFrame()->loader().saveScrollState(); | |
| 227 } | |
| 232 | 228 |
| 233 clampToBoundaries(); | 229 clampToBoundaries(); |
| 234 } | 230 } |
| 235 | 231 |
| 236 bool VisualViewport::magnifyScaleAroundAnchor(float magnifyDelta, const FloatPoi nt& anchor) | 232 bool VisualViewport::magnifyScaleAroundAnchor(float magnifyDelta, const FloatPoi nt& anchor) |
| 237 { | 233 { |
| 238 const float oldPageScale = scale(); | 234 const float oldPageScale = scale(); |
| 239 const float newPageScale = frameHost().chromeClient().clampPageScaleFactorTo Limits( | 235 const float newPageScale = frameHost().chromeClient().clampPageScaleFactorTo Limits( |
| 240 magnifyDelta * oldPageScale); | 236 magnifyDelta * oldPageScale); |
| 241 if (newPageScale == oldPageScale) | 237 if (newPageScale == oldPageScale) |
| (...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 739 } else if (graphicsLayer == m_rootTransformLayer) { | 735 } else if (graphicsLayer == m_rootTransformLayer) { |
| 740 name = "Root Transform Layer"; | 736 name = "Root Transform Layer"; |
| 741 } else { | 737 } else { |
| 742 ASSERT_NOT_REACHED(); | 738 ASSERT_NOT_REACHED(); |
| 743 } | 739 } |
| 744 | 740 |
| 745 return name; | 741 return name; |
| 746 } | 742 } |
| 747 | 743 |
| 748 } // namespace blink | 744 } // namespace blink |
| OLD | NEW |