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

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

Issue 642003002: Move PinchViewport to the Oilpan heap. (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
« no previous file with comments | « Source/core/frame/PinchViewport.h ('k') | no next file » | 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 64
65 namespace blink { 65 namespace blink {
66 66
67 PinchViewport::PinchViewport(FrameHost& owner) 67 PinchViewport::PinchViewport(FrameHost& owner)
68 : m_frameHost(owner) 68 : m_frameHost(owner)
69 , m_scale(1) 69 , m_scale(1)
70 { 70 {
71 reset(); 71 reset();
72 } 72 }
73 73
74 PinchViewport::~PinchViewport() { } 74 PinchViewport::~PinchViewport()
75 {
76 }
77
78 void PinchViewport::trace(Visitor* visitor)
79 {
80 visitor->trace(m_frameHost);
81 }
75 82
76 void PinchViewport::setSize(const IntSize& size) 83 void PinchViewport::setSize(const IntSize& size)
77 { 84 {
78 if (m_size == size) 85 if (m_size == size)
79 return; 86 return;
80 87
81 TRACE_EVENT2("blink", "PinchViewport::setSize", "width", size.width(), "heig ht", size.height()); 88 TRACE_EVENT2("blink", "PinchViewport::setSize", "width", size.width(), "heig ht", size.height());
82 m_size = size; 89 m_size = size;
83 90
84 clampToBoundaries(); 91 clampToBoundaries();
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 mainFrame()->loader().saveScrollState(); 185 mainFrame()->loader().saveScrollState();
179 186
180 return; 187 return;
181 } 188 }
182 189
183 FloatPoint clampedOffset(clampOffsetToBoundaries(location)); 190 FloatPoint clampedOffset(clampOffsetToBoundaries(location));
184 191
185 if (clampedOffset != m_offset) { 192 if (clampedOffset != m_offset) {
186 m_offset = clampedOffset; 193 m_offset = clampedOffset;
187 194
188 ScrollingCoordinator* coordinator = m_frameHost.page().scrollingCoordina tor(); 195 ScrollingCoordinator* coordinator = frameHost().page().scrollingCoordina tor();
189 ASSERT(coordinator); 196 ASSERT(coordinator);
190 coordinator->scrollableAreaScrollLayerDidChange(this); 197 coordinator->scrollableAreaScrollLayerDidChange(this);
191 198
192 valuesChanged = true; 199 valuesChanged = true;
193 } 200 }
194 201
195 if (!valuesChanged) 202 if (!valuesChanged)
196 return; 203 return;
197 204
198 mainFrame()->loader().saveScrollState(); 205 mainFrame()->loader().saveScrollState();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 && !m_innerViewportContainerLayer); 243 && !m_innerViewportContainerLayer);
237 244
238 // FIXME: The root transform layer should only be created on demand. 245 // FIXME: The root transform layer should only be created on demand.
239 m_rootTransformLayer = GraphicsLayer::create(graphicsLayerFactory, this) ; 246 m_rootTransformLayer = GraphicsLayer::create(graphicsLayerFactory, this) ;
240 m_innerViewportContainerLayer = GraphicsLayer::create(graphicsLayerFacto ry, this); 247 m_innerViewportContainerLayer = GraphicsLayer::create(graphicsLayerFacto ry, this);
241 m_pageScaleLayer = GraphicsLayer::create(graphicsLayerFactory, this); 248 m_pageScaleLayer = GraphicsLayer::create(graphicsLayerFactory, this);
242 m_innerViewportScrollLayer = GraphicsLayer::create(graphicsLayerFactory, this); 249 m_innerViewportScrollLayer = GraphicsLayer::create(graphicsLayerFactory, this);
243 m_overlayScrollbarHorizontal = GraphicsLayer::create(graphicsLayerFactor y, this); 250 m_overlayScrollbarHorizontal = GraphicsLayer::create(graphicsLayerFactor y, this);
244 m_overlayScrollbarVertical = GraphicsLayer::create(graphicsLayerFactory, this); 251 m_overlayScrollbarVertical = GraphicsLayer::create(graphicsLayerFactory, this);
245 252
246 blink::ScrollingCoordinator* coordinator = m_frameHost.page().scrollingC oordinator(); 253 blink::ScrollingCoordinator* coordinator = frameHost().page().scrollingC oordinator();
247 ASSERT(coordinator); 254 ASSERT(coordinator);
248 coordinator->setLayerIsContainerForFixedPositionLayers(m_innerViewportSc rollLayer.get(), true); 255 coordinator->setLayerIsContainerForFixedPositionLayers(m_innerViewportSc rollLayer.get(), true);
249 256
250 // Set masks to bounds so the compositor doesn't clobber a manually 257 // Set masks to bounds so the compositor doesn't clobber a manually
251 // set inner viewport container layer size. 258 // set inner viewport container layer size.
252 m_innerViewportContainerLayer->setMasksToBounds(m_frameHost.settings().m ainFrameClipsContent()); 259 m_innerViewportContainerLayer->setMasksToBounds(frameHost().settings().m ainFrameClipsContent());
253 m_innerViewportContainerLayer->setSize(m_size); 260 m_innerViewportContainerLayer->setSize(m_size);
254 261
255 m_innerViewportScrollLayer->platformLayer()->setScrollClipLayer( 262 m_innerViewportScrollLayer->platformLayer()->setScrollClipLayer(
256 m_innerViewportContainerLayer->platformLayer()); 263 m_innerViewportContainerLayer->platformLayer());
257 m_innerViewportScrollLayer->platformLayer()->setUserScrollable(true, tru e); 264 m_innerViewportScrollLayer->platformLayer()->setUserScrollable(true, tru e);
258 265
259 m_rootTransformLayer->addChild(m_innerViewportContainerLayer.get()); 266 m_rootTransformLayer->addChild(m_innerViewportContainerLayer.get());
260 m_innerViewportContainerLayer->addChild(m_pageScaleLayer.get()); 267 m_innerViewportContainerLayer->addChild(m_pageScaleLayer.get());
261 m_pageScaleLayer->addChild(m_innerViewportScrollLayer.get()); 268 m_pageScaleLayer->addChild(m_innerViewportScrollLayer.get());
262 m_innerViewportContainerLayer->addChild(m_overlayScrollbarHorizontal.get ()); 269 m_innerViewportContainerLayer->addChild(m_overlayScrollbarHorizontal.get ());
(...skipping 12 matching lines...) Expand all
275 } 282 }
276 283
277 void PinchViewport::setupScrollbar(WebScrollbar::Orientation orientation) 284 void PinchViewport::setupScrollbar(WebScrollbar::Orientation orientation)
278 { 285 {
279 bool isHorizontal = orientation == WebScrollbar::Horizontal; 286 bool isHorizontal = orientation == WebScrollbar::Horizontal;
280 GraphicsLayer* scrollbarGraphicsLayer = isHorizontal ? 287 GraphicsLayer* scrollbarGraphicsLayer = isHorizontal ?
281 m_overlayScrollbarHorizontal.get() : m_overlayScrollbarVertical.get(); 288 m_overlayScrollbarHorizontal.get() : m_overlayScrollbarVertical.get();
282 OwnPtr<WebScrollbarLayer>& webScrollbarLayer = isHorizontal ? 289 OwnPtr<WebScrollbarLayer>& webScrollbarLayer = isHorizontal ?
283 m_webOverlayScrollbarHorizontal : m_webOverlayScrollbarVertical; 290 m_webOverlayScrollbarHorizontal : m_webOverlayScrollbarVertical;
284 291
285 int thumbThickness = m_frameHost.settings().pinchOverlayScrollbarThickness() ; 292 int thumbThickness = frameHost().settings().pinchOverlayScrollbarThickness() ;
286 int scrollbarThickness = thumbThickness; 293 int scrollbarThickness = thumbThickness;
287 294
288 // FIXME: Rather than manually creating scrollbar layers, we should create 295 // FIXME: Rather than manually creating scrollbar layers, we should create
289 // real scrollbars so we can reuse all the machinery from ScrollbarTheme. 296 // real scrollbars so we can reuse all the machinery from ScrollbarTheme.
290 #if OS(ANDROID) 297 #if OS(ANDROID)
291 thumbThickness = ScrollbarTheme::theme()->thumbThickness(0); 298 thumbThickness = ScrollbarTheme::theme()->thumbThickness(0);
292 scrollbarThickness = ScrollbarTheme::theme()->scrollbarThickness(RegularScro llbar); 299 scrollbarThickness = ScrollbarTheme::theme()->scrollbarThickness(RegularScro llbar);
293 #endif 300 #endif
294 301
295 if (!webScrollbarLayer) { 302 if (!webScrollbarLayer) {
296 ScrollingCoordinator* coordinator = m_frameHost.page().scrollingCoordina tor(); 303 ScrollingCoordinator* coordinator = frameHost().page().scrollingCoordina tor();
297 ASSERT(coordinator); 304 ASSERT(coordinator);
298 ScrollbarOrientation webcoreOrientation = isHorizontal ? HorizontalScrol lbar : VerticalScrollbar; 305 ScrollbarOrientation webcoreOrientation = isHorizontal ? HorizontalScrol lbar : VerticalScrollbar;
299 webScrollbarLayer = coordinator->createSolidColorScrollbarLayer(webcoreO rientation, thumbThickness, 0, false); 306 webScrollbarLayer = coordinator->createSolidColorScrollbarLayer(webcoreO rientation, thumbThickness, 0, false);
300 307
301 webScrollbarLayer->setClipLayer(m_innerViewportContainerLayer->platformL ayer()); 308 webScrollbarLayer->setClipLayer(m_innerViewportContainerLayer->platformL ayer());
302 scrollbarGraphicsLayer->setContentsToPlatformLayer(webScrollbarLayer->la yer()); 309 scrollbarGraphicsLayer->setContentsToPlatformLayer(webScrollbarLayer->la yer());
303 scrollbarGraphicsLayer->setDrawsContent(false); 310 scrollbarGraphicsLayer->setDrawsContent(false);
304 } 311 }
305 312
306 int xPosition = isHorizontal ? 0 : m_innerViewportContainerLayer->size().wid th() - scrollbarThickness; 313 int xPosition = isHorizontal ? 0 : m_innerViewportContainerLayer->size().wid th() - scrollbarThickness;
307 int yPosition = isHorizontal ? m_innerViewportContainerLayer->size().height( ) - scrollbarThickness : 0; 314 int yPosition = isHorizontal ? m_innerViewportContainerLayer->size().height( ) - scrollbarThickness : 0;
308 int width = isHorizontal ? m_innerViewportContainerLayer->size().width() - s crollbarThickness : scrollbarThickness; 315 int width = isHorizontal ? m_innerViewportContainerLayer->size().width() - s crollbarThickness : scrollbarThickness;
309 int height = isHorizontal ? scrollbarThickness : m_innerViewportContainerLay er->size().height() - scrollbarThickness; 316 int height = isHorizontal ? scrollbarThickness : m_innerViewportContainerLay er->size().height() - scrollbarThickness;
310 317
311 // Use the GraphicsLayer to position the scrollbars. 318 // Use the GraphicsLayer to position the scrollbars.
312 scrollbarGraphicsLayer->setPosition(IntPoint(xPosition, yPosition)); 319 scrollbarGraphicsLayer->setPosition(IntPoint(xPosition, yPosition));
313 scrollbarGraphicsLayer->setSize(IntSize(width, height)); 320 scrollbarGraphicsLayer->setSize(IntSize(width, height));
314 scrollbarGraphicsLayer->setContentsRect(IntRect(0, 0, width, height)); 321 scrollbarGraphicsLayer->setContentsRect(IntRect(0, 0, width, height));
315 } 322 }
316 323
317 void PinchViewport::registerLayersWithTreeView(WebLayerTreeView* layerTreeView) const 324 void PinchViewport::registerLayersWithTreeView(WebLayerTreeView* layerTreeView) const
318 { 325 {
319 TRACE_EVENT0("blink", "PinchViewport::registerLayersWithTreeView"); 326 TRACE_EVENT0("blink", "PinchViewport::registerLayersWithTreeView");
320 ASSERT(layerTreeView); 327 ASSERT(layerTreeView);
321 ASSERT(m_frameHost.page().mainFrame()); 328 ASSERT(frameHost().page().mainFrame());
322 ASSERT(m_frameHost.page().mainFrame()->isLocalFrame()); 329 ASSERT(frameHost().page().mainFrame()->isLocalFrame());
323 ASSERT(m_frameHost.page().deprecatedLocalMainFrame()->contentRenderer()); 330 ASSERT(frameHost().page().deprecatedLocalMainFrame()->contentRenderer());
324 331
325 RenderLayerCompositor* compositor = m_frameHost.page().deprecatedLocalMainFr ame()->contentRenderer()->compositor(); 332 RenderLayerCompositor* compositor = frameHost().page().deprecatedLocalMainFr ame()->contentRenderer()->compositor();
326 // Get the outer viewport scroll layer. 333 // Get the outer viewport scroll layer.
327 WebLayer* scrollLayer = compositor->scrollLayer()->platformLayer(); 334 WebLayer* scrollLayer = compositor->scrollLayer()->platformLayer();
328 335
329 m_webOverlayScrollbarHorizontal->setScrollLayer(scrollLayer); 336 m_webOverlayScrollbarHorizontal->setScrollLayer(scrollLayer);
330 m_webOverlayScrollbarVertical->setScrollLayer(scrollLayer); 337 m_webOverlayScrollbarVertical->setScrollLayer(scrollLayer);
331 338
332 ASSERT(compositor); 339 ASSERT(compositor);
333 layerTreeView->registerViewportLayers( 340 layerTreeView->registerViewportLayers(
334 m_pageScaleLayer->platformLayer(), 341 m_pageScaleLayer->platformLayer(),
335 m_innerViewportScrollLayer->platformLayer(), 342 m_innerViewportScrollLayer->platformLayer(),
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 void PinchViewport::notifyAnimationStarted(const GraphicsLayer*, double monotoni cTime) 445 void PinchViewport::notifyAnimationStarted(const GraphicsLayer*, double monotoni cTime)
439 { 446 {
440 } 447 }
441 448
442 void PinchViewport::paintContents(const GraphicsLayer*, GraphicsContext&, Graphi csLayerPaintingPhase, const IntRect& inClip) 449 void PinchViewport::paintContents(const GraphicsLayer*, GraphicsContext&, Graphi csLayerPaintingPhase, const IntRect& inClip)
443 { 450 {
444 } 451 }
445 452
446 LocalFrame* PinchViewport::mainFrame() const 453 LocalFrame* PinchViewport::mainFrame() const
447 { 454 {
448 return m_frameHost.page().mainFrame() && m_frameHost.page().mainFrame()->isL ocalFrame() ? m_frameHost.page().deprecatedLocalMainFrame() : 0; 455 return frameHost().page().mainFrame() && frameHost().page().mainFrame()->isL ocalFrame() ? frameHost().page().deprecatedLocalMainFrame() : 0;
449 } 456 }
450 457
451 FloatPoint PinchViewport::clampOffsetToBoundaries(const FloatPoint& offset) 458 FloatPoint PinchViewport::clampOffsetToBoundaries(const FloatPoint& offset)
452 { 459 {
453 FloatPoint clampedOffset(offset); 460 FloatPoint clampedOffset(offset);
454 clampedOffset = clampedOffset.shrunkTo(FloatPoint(maximumScrollPosition())); 461 clampedOffset = clampedOffset.shrunkTo(FloatPoint(maximumScrollPosition()));
455 clampedOffset = clampedOffset.expandedTo(FloatPoint(minimumScrollPosition()) ); 462 clampedOffset = clampedOffset.expandedTo(FloatPoint(minimumScrollPosition()) );
456 return clampedOffset; 463 return clampedOffset;
457 } 464 }
458 465
(...skipping 16 matching lines...) Expand all
475 } else if (graphicsLayer == m_overlayScrollbarVertical.get()) { 482 } else if (graphicsLayer == m_overlayScrollbarVertical.get()) {
476 name = "Overlay Scrollbar Vertical Layer"; 483 name = "Overlay Scrollbar Vertical Layer";
477 } else { 484 } else {
478 ASSERT_NOT_REACHED(); 485 ASSERT_NOT_REACHED();
479 } 486 }
480 487
481 return name; 488 return name;
482 } 489 }
483 490
484 } // namespace blink 491 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/frame/PinchViewport.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698