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

Side by Side Diff: third_party/WebKit/Source/core/frame/VisualViewport.cpp

Issue 2096783004: Seperate visualviewportchanged event into scroll and resize events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 89
90 void VisualViewport::updateStyleAndLayoutIgnorePendingStylesheets() 90 void VisualViewport::updateStyleAndLayoutIgnorePendingStylesheets()
91 { 91 {
92 if (!mainFrame()) 92 if (!mainFrame())
93 return; 93 return;
94 94
95 if (Document* document = mainFrame()->document()) 95 if (Document* document = mainFrame()->document())
96 document->updateStyleAndLayoutIgnorePendingStylesheets(); 96 document->updateStyleAndLayoutIgnorePendingStylesheets();
97 } 97 }
98 98
99 void VisualViewport::enqueueChangedEvent() 99 void VisualViewport::enqueueScrollEvent()
100 { 100 {
101 if (!RuntimeEnabledFeatures::visualViewportAPIEnabled()) 101 if (!RuntimeEnabledFeatures::visualViewportAPIEnabled())
102 return; 102 return;
103 103
104 if (Document* document = mainFrame()->document()) 104 if (Document* document = mainFrame()->document())
105 document->enqueueVisualViewportChangedEvent(); 105 document->enqueueVisualViewportScrollEvent();
106 }
107
108 void VisualViewport::enqueueResizeEvent()
109 {
110 if (!RuntimeEnabledFeatures::visualViewportAPIEnabled())
111 return;
112
113 if (Document* document = mainFrame()->document())
114 document->enqueueVisualViewportResizeEvent();
106 } 115 }
107 116
108 void VisualViewport::setSize(const IntSize& size) 117 void VisualViewport::setSize(const IntSize& size)
109 { 118 {
110 if (m_size == size) 119 if (m_size == size)
111 return; 120 return;
112 121
113 TRACE_EVENT2("blink", "VisualViewport::setSize", "width", size.width(), "hei ght", size.height()); 122 TRACE_EVENT2("blink", "VisualViewport::setSize", "width", size.width(), "hei ght", size.height());
114 bool widthDidChange = size.width() != m_size.width(); 123 bool widthDidChange = size.width() != m_size.width();
115 m_size = size; 124 m_size = size;
116 125
117 if (m_innerViewportContainerLayer) { 126 if (m_innerViewportContainerLayer) {
118 m_innerViewportContainerLayer->setSize(FloatSize(m_size)); 127 m_innerViewportContainerLayer->setSize(FloatSize(m_size));
119 128
120 // Need to re-compute sizes for the overlay scrollbars. 129 // Need to re-compute sizes for the overlay scrollbars.
121 initializeScrollbars(); 130 initializeScrollbars();
122 } 131 }
123 132
124 if (!mainFrame()) 133 if (!mainFrame())
125 return; 134 return;
126 135
127 enqueueChangedEvent(); 136 enqueueScrollEvent();
bokan 2016/06/24 21:52:37 Why are we sending a scroll event when the size ch
ymalik 2016/06/27 14:10:01 Yes!
128 137
129 bool autosizerNeedsUpdating = widthDidChange 138 bool autosizerNeedsUpdating = widthDidChange
130 && mainFrame()->settings() 139 && mainFrame()->settings()
131 && mainFrame()->settings()->textAutosizingEnabled(); 140 && mainFrame()->settings()->textAutosizingEnabled();
132 141
133 if (autosizerNeedsUpdating) { 142 if (autosizerNeedsUpdating) {
134 // This needs to happen after setting the m_size member since it'll be r ead in the update call. 143 // This needs to happen after setting the m_size member since it'll be r ead in the update call.
135 if (TextAutosizer* textAutosizer = mainFrame()->document()->textAutosize r()) 144 if (TextAutosizer* textAutosizer = mainFrame()->document()->textAutosize r())
136 textAutosizer->updatePageInfoInAllFrames(); 145 textAutosizer->updatePageInfoInAllFrames();
137 } 146 }
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 { 293 {
285 if (!mainFrame()) 294 if (!mainFrame())
286 return; 295 return;
287 296
288 bool valuesChanged = false; 297 bool valuesChanged = false;
289 298
290 if (scale != m_scale) { 299 if (scale != m_scale) {
291 m_scale = scale; 300 m_scale = scale;
292 valuesChanged = true; 301 valuesChanged = true;
293 frameHost().chromeClient().pageScaleFactorChanged(); 302 frameHost().chromeClient().pageScaleFactorChanged();
303 enqueueResizeEvent();
294 } 304 }
295 305
296 FloatPoint clampedOffset(clampOffsetToBoundaries(location)); 306 FloatPoint clampedOffset(clampOffsetToBoundaries(location));
297 307
298 if (clampedOffset != m_offset) { 308 if (clampedOffset != m_offset) {
299 m_offset = clampedOffset; 309 m_offset = clampedOffset;
300 scrollAnimator().setCurrentPosition(m_offset); 310 scrollAnimator().setCurrentPosition(m_offset);
301 311
302 // SVG runs with accelerated compositing disabled so no ScrollingCoordin ator. 312 // SVG runs with accelerated compositing disabled so no ScrollingCoordin ator.
303 if (ScrollingCoordinator* coordinator = frameHost().page().scrollingCoor dinator()) 313 if (ScrollingCoordinator* coordinator = frameHost().page().scrollingCoor dinator())
304 coordinator->scrollableAreaScrollLayerDidChange(this); 314 coordinator->scrollableAreaScrollLayerDidChange(this);
305 315
306 if (!frameHost().settings().inertVisualViewport()) { 316 if (!frameHost().settings().inertVisualViewport()) {
307 if (Document* document = mainFrame()->document()) 317 if (Document* document = mainFrame()->document())
308 document->enqueueScrollEventForNode(document); 318 document->enqueueScrollEventForNode(document);
309 } 319 }
310 320
321 enqueueScrollEvent();
322
311 mainFrame()->loader().client()->didChangeScrollOffset(); 323 mainFrame()->loader().client()->didChangeScrollOffset();
312 valuesChanged = true; 324 valuesChanged = true;
313 } 325 }
314 326
315 if (!valuesChanged) 327 if (!valuesChanged)
316 return; 328 return;
317 329
318 enqueueChangedEvent();
319
320 InspectorInstrumentation::didUpdateLayout(mainFrame()); 330 InspectorInstrumentation::didUpdateLayout(mainFrame());
321 mainFrame()->loader().saveScrollState(); 331 mainFrame()->loader().saveScrollState();
322 332
323 clampToBoundaries(); 333 clampToBoundaries();
324 } 334 }
325 335
326 bool VisualViewport::magnifyScaleAroundAnchor(float magnifyDelta, const FloatPoi nt& anchor) 336 bool VisualViewport::magnifyScaleAroundAnchor(float magnifyDelta, const FloatPoi nt& anchor)
327 { 337 {
328 const float oldPageScale = scale(); 338 const float oldPageScale = scale();
329 const float newPageScale = frameHost().chromeClient().clampPageScaleFactorTo Limits( 339 const float newPageScale = frameHost().chromeClient().clampPageScaleFactorTo Limits(
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 } else if (graphicsLayer == m_rootTransformLayer.get()) { 846 } else if (graphicsLayer == m_rootTransformLayer.get()) {
837 name = "Root Transform Layer"; 847 name = "Root Transform Layer";
838 } else { 848 } else {
839 ASSERT_NOT_REACHED(); 849 ASSERT_NOT_REACHED();
840 } 850 }
841 851
842 return name; 852 return name;
843 } 853 }
844 854
845 } // namespace blink 855 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698