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

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

Issue 1447273003: Make the FloatSize constructor from an IntSize explicit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 99
100 bool autosizerNeedsUpdating = 100 bool autosizerNeedsUpdating =
101 (size.width() != m_size.width()) 101 (size.width() != m_size.width())
102 && mainFrame()->settings() 102 && mainFrame()->settings()
103 && mainFrame()->settings()->textAutosizingEnabled(); 103 && mainFrame()->settings()->textAutosizingEnabled();
104 104
105 TRACE_EVENT2("blink", "VisualViewport::setSize", "width", size.width(), "hei ght", size.height()); 105 TRACE_EVENT2("blink", "VisualViewport::setSize", "width", size.width(), "hei ght", size.height());
106 m_size = size; 106 m_size = size;
107 107
108 if (m_innerViewportContainerLayer) { 108 if (m_innerViewportContainerLayer) {
109 m_innerViewportContainerLayer->setSize(m_size); 109 m_innerViewportContainerLayer->setSize(FloatSize(m_size));
110 110
111 // Need to re-compute sizes for the overlay scrollbars. 111 // Need to re-compute sizes for the overlay scrollbars.
112 initializeScrollbars(); 112 initializeScrollbars();
113 } 113 }
114 114
115 if (autosizerNeedsUpdating) { 115 if (autosizerNeedsUpdating) {
116 // This needs to happen after setting the m_size member since it'll be r ead in the update call. 116 // This needs to happen after setting the m_size member since it'll be r ead in the update call.
117 if (TextAutosizer* textAutosizer = mainFrame()->document()->textAutosize r()) 117 if (TextAutosizer* textAutosizer = mainFrame()->document()->textAutosize r())
118 textAutosizer->updatePageInfoInAllFrames(); 118 textAutosizer->updatePageInfoInAllFrames();
119 } 119 }
120 } 120 }
121 121
122 void VisualViewport::reset() 122 void VisualViewport::reset()
123 { 123 {
124 setScaleAndLocation(1, FloatPoint()); 124 setScaleAndLocation(1, FloatPoint());
125 } 125 }
126 126
127 void VisualViewport::mainFrameDidChangeSize() 127 void VisualViewport::mainFrameDidChangeSize()
128 { 128 {
129 TRACE_EVENT0("blink", "VisualViewport::mainFrameDidChangeSize"); 129 TRACE_EVENT0("blink", "VisualViewport::mainFrameDidChangeSize");
130 130
131 // In unit tests we may not have initialized the layer tree. 131 // In unit tests we may not have initialized the layer tree.
132 if (m_innerViewportScrollLayer) 132 if (m_innerViewportScrollLayer)
133 m_innerViewportScrollLayer->setSize(contentsSize()); 133 m_innerViewportScrollLayer->setSize(FloatSize(contentsSize()));
134 134
135 clampToBoundaries(); 135 clampToBoundaries();
136 } 136 }
137 137
138 FloatSize VisualViewport::visibleSize() const 138 FloatSize VisualViewport::visibleSize() const
139 { 139 {
140 FloatSize scaledSize(m_size); 140 FloatSize scaledSize(m_size);
141 scaledSize.expand(0, m_topControlsAdjustment); 141 scaledSize.expand(0, m_topControlsAdjustment);
142 scaledSize.scale(1 / m_scale); 142 scaledSize.scale(1 / m_scale);
143 return scaledSize; 143 return scaledSize;
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 m_overlayScrollbarHorizontal = GraphicsLayer::create(graphicsLayerFactor y, this); 312 m_overlayScrollbarHorizontal = GraphicsLayer::create(graphicsLayerFactor y, this);
313 m_overlayScrollbarVertical = GraphicsLayer::create(graphicsLayerFactory, this); 313 m_overlayScrollbarVertical = GraphicsLayer::create(graphicsLayerFactory, this);
314 314
315 ScrollingCoordinator* coordinator = frameHost().page().scrollingCoordina tor(); 315 ScrollingCoordinator* coordinator = frameHost().page().scrollingCoordina tor();
316 ASSERT(coordinator); 316 ASSERT(coordinator);
317 coordinator->setLayerIsContainerForFixedPositionLayers(m_innerViewportSc rollLayer.get(), true); 317 coordinator->setLayerIsContainerForFixedPositionLayers(m_innerViewportSc rollLayer.get(), true);
318 318
319 // Set masks to bounds so the compositor doesn't clobber a manually 319 // Set masks to bounds so the compositor doesn't clobber a manually
320 // set inner viewport container layer size. 320 // set inner viewport container layer size.
321 m_innerViewportContainerLayer->setMasksToBounds(frameHost().settings().m ainFrameClipsContent()); 321 m_innerViewportContainerLayer->setMasksToBounds(frameHost().settings().m ainFrameClipsContent());
322 m_innerViewportContainerLayer->setSize(m_size); 322 m_innerViewportContainerLayer->setSize(FloatSize(m_size));
323 323
324 m_innerViewportScrollLayer->platformLayer()->setScrollClipLayer( 324 m_innerViewportScrollLayer->platformLayer()->setScrollClipLayer(
325 m_innerViewportContainerLayer->platformLayer()); 325 m_innerViewportContainerLayer->platformLayer());
326 m_innerViewportScrollLayer->platformLayer()->setUserScrollable(true, tru e); 326 m_innerViewportScrollLayer->platformLayer()->setUserScrollable(true, tru e);
327 327
328 m_rootTransformLayer->addChild(m_innerViewportContainerLayer.get()); 328 m_rootTransformLayer->addChild(m_innerViewportContainerLayer.get());
329 m_innerViewportContainerLayer->addChild(m_overscrollElasticityLayer.get( )); 329 m_innerViewportContainerLayer->addChild(m_overscrollElasticityLayer.get( ));
330 m_overscrollElasticityLayer->addChild(m_pageScaleLayer.get()); 330 m_overscrollElasticityLayer->addChild(m_pageScaleLayer.get());
331 m_pageScaleLayer->addChild(m_innerViewportScrollLayer.get()); 331 m_pageScaleLayer->addChild(m_innerViewportScrollLayer.get());
332 332
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 scrollbarGraphicsLayer->setDrawsContent(false); 382 scrollbarGraphicsLayer->setDrawsContent(false);
383 } 383 }
384 384
385 int xPosition = isHorizontal ? 0 : m_innerViewportContainerLayer->size().wid th() - scrollbarThickness; 385 int xPosition = isHorizontal ? 0 : m_innerViewportContainerLayer->size().wid th() - scrollbarThickness;
386 int yPosition = isHorizontal ? m_innerViewportContainerLayer->size().height( ) - scrollbarThickness : 0; 386 int yPosition = isHorizontal ? m_innerViewportContainerLayer->size().height( ) - scrollbarThickness : 0;
387 int width = isHorizontal ? m_innerViewportContainerLayer->size().width() - s crollbarThickness : scrollbarThickness; 387 int width = isHorizontal ? m_innerViewportContainerLayer->size().width() - s crollbarThickness : scrollbarThickness;
388 int height = isHorizontal ? scrollbarThickness : m_innerViewportContainerLay er->size().height() - scrollbarThickness; 388 int height = isHorizontal ? scrollbarThickness : m_innerViewportContainerLay er->size().height() - scrollbarThickness;
389 389
390 // Use the GraphicsLayer to position the scrollbars. 390 // Use the GraphicsLayer to position the scrollbars.
391 scrollbarGraphicsLayer->setPosition(IntPoint(xPosition, yPosition)); 391 scrollbarGraphicsLayer->setPosition(IntPoint(xPosition, yPosition));
392 scrollbarGraphicsLayer->setSize(IntSize(width, height)); 392 scrollbarGraphicsLayer->setSize(FloatSize(width, height));
393 scrollbarGraphicsLayer->setContentsRect(IntRect(0, 0, width, height)); 393 scrollbarGraphicsLayer->setContentsRect(IntRect(0, 0, width, height));
394 } 394 }
395 395
396 void VisualViewport::registerLayersWithTreeView(WebLayerTreeView* layerTreeView) const 396 void VisualViewport::registerLayersWithTreeView(WebLayerTreeView* layerTreeView) const
397 { 397 {
398 TRACE_EVENT0("blink", "VisualViewport::registerLayersWithTreeView"); 398 TRACE_EVENT0("blink", "VisualViewport::registerLayersWithTreeView");
399 ASSERT(layerTreeView); 399 ASSERT(layerTreeView);
400 400
401 if (!mainFrame()) 401 if (!mainFrame())
402 return; 402 return;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 477
478 // FIXME: We probably shouldn't be storing the bounds in a float. crbug.com/ 422331. 478 // FIXME: We probably shouldn't be storing the bounds in a float. crbug.com/ 422331.
479 FloatSize frameViewSize(contentsSize()); 479 FloatSize frameViewSize(contentsSize());
480 480
481 if (m_topControlsAdjustment) { 481 if (m_topControlsAdjustment) {
482 float minScale = frameHost().pageScaleConstraintsSet().finalConstraints( ).minimumScale; 482 float minScale = frameHost().pageScaleConstraintsSet().finalConstraints( ).minimumScale;
483 frameViewSize.expand(0, m_topControlsAdjustment / minScale); 483 frameViewSize.expand(0, m_topControlsAdjustment / minScale);
484 } 484 }
485 485
486 frameViewSize.scale(m_scale); 486 frameViewSize.scale(m_scale);
487 frameViewSize = flooredIntSize(frameViewSize); 487 frameViewSize = FloatSize(flooredIntSize(frameViewSize));
488 488
489 FloatSize viewportSize(m_size); 489 FloatSize viewportSize(m_size);
490 viewportSize.expand(0, m_topControlsAdjustment); 490 viewportSize.expand(0, m_topControlsAdjustment);
491 491
492 FloatSize maxPosition = frameViewSize - viewportSize; 492 FloatSize maxPosition = frameViewSize - viewportSize;
493 maxPosition.scale(1 / m_scale); 493 maxPosition.scale(1 / m_scale);
494 return DoublePoint(maxPosition); 494 return DoublePoint(maxPosition);
495 } 495 }
496 496
497 IntPoint VisualViewport::clampDocumentOffsetAtScale(const IntPoint& offset, floa t scale) 497 IntPoint VisualViewport::clampDocumentOffsetAtScale(const IntPoint& offset, floa t scale)
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 } else if (graphicsLayer == m_rootTransformLayer) { 736 } else if (graphicsLayer == m_rootTransformLayer) {
737 name = "Root Transform Layer"; 737 name = "Root Transform Layer";
738 } else { 738 } else {
739 ASSERT_NOT_REACHED(); 739 ASSERT_NOT_REACHED();
740 } 740 }
741 741
742 return name; 742 return name;
743 } 743 }
744 744
745 } // namespace blink 745 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/PageScaleConstraintsSet.cpp ('k') | third_party/WebKit/Source/core/layout/LayoutView.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698