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

Side by Side Diff: Source/web/WebViewImpl.cpp

Issue 843683005: Fix a bit of C++11 in web/ (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 11 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 // Change the text zoom level by kTextSizeMultiplierRatio each time the user 204 // Change the text zoom level by kTextSizeMultiplierRatio each time the user
205 // zooms text in or out (ie., change by 20%). The min and max values limit 205 // zooms text in or out (ie., change by 20%). The min and max values limit
206 // text zoom to half and 3x the original text size. These three values match 206 // text zoom to half and 3x the original text size. These three values match
207 // those in Apple's port in WebKit/WebKit/WebView/WebView.mm 207 // those in Apple's port in WebKit/WebKit/WebView/WebView.mm
208 const double WebView::textSizeMultiplierRatio = 1.2; 208 const double WebView::textSizeMultiplierRatio = 1.2;
209 const double WebView::minTextSizeMultiplier = 0.5; 209 const double WebView::minTextSizeMultiplier = 0.5;
210 const double WebView::maxTextSizeMultiplier = 3.0; 210 const double WebView::maxTextSizeMultiplier = 3.0;
211 211
212 // Used to defer all page activity in cases where the embedder wishes to run 212 // Used to defer all page activity in cases where the embedder wishes to run
213 // a nested event loop. Using a stack enables nesting of message loop invocation s. 213 // a nested event loop. Using a stack enables nesting of message loop invocation s.
214 static WillBeHeapVector<RawPtrWillBeMember<ScopedPageLoadDeferrer> >& pageLoadDe ferrerStack() 214 static WillBeHeapVector<RawPtrWillBeMember<ScopedPageLoadDeferrer>>& pageLoadDef errerStack()
215 { 215 {
216 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<WillBeHeapVector<RawPtrWillBeMemb er<ScopedPageLoadDeferrer> > >, deferrerStack, (adoptPtrWillBeNoop(new WillBeHea pVector<RawPtrWillBeMember<ScopedPageLoadDeferrer> > ()))); 216 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<WillBeHeapVector<RawPtrWillBeMemb er<ScopedPageLoadDeferrer>>>, deferrerStack, (adoptPtrWillBeNoop(new WillBeHeapV ector<RawPtrWillBeMember<ScopedPageLoadDeferrer>>())));
217 return *deferrerStack; 217 return *deferrerStack;
218 } 218 }
219 219
220 // Ensure that the WebDragOperation enum values stay in sync with the original 220 // Ensure that the WebDragOperation enum values stay in sync with the original
221 // DragOperation constants. 221 // DragOperation constants.
222 #define STATIC_ASSERT_MATCHING_ENUM(coreName) \ 222 #define STATIC_ASSERT_MATCHING_ENUM(coreName) \
223 static_assert(int(coreName) == int(Web##coreName), "DragOperation and WebDra gOperation enum mismatch: " #coreName) 223 static_assert(int(coreName) == int(Web##coreName), "DragOperation and WebDra gOperation enum mismatch: " #coreName)
224 STATIC_ASSERT_MATCHING_ENUM(DragOperationNone); 224 STATIC_ASSERT_MATCHING_ENUM(DragOperationNone);
225 STATIC_ASSERT_MATCHING_ENUM(DragOperationCopy); 225 STATIC_ASSERT_MATCHING_ENUM(DragOperationCopy);
226 STATIC_ASSERT_MATCHING_ENUM(DragOperationLink); 226 STATIC_ASSERT_MATCHING_ENUM(DragOperationLink);
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 scaledEvent.data.tap.width, 749 scaledEvent.data.tap.width,
750 scaledEvent.data.tap.height); 750 scaledEvent.data.tap.height);
751 751
752 WebSize pinchViewportOffset = pinchVirtualViewportEnabled() ? 752 WebSize pinchViewportOffset = pinchVirtualViewportEnabled() ?
753 flooredIntSize(page()->frameHost().pinchViewport().location()) : IntSize(); 753 flooredIntSize(page()->frameHost().pinchViewport().location()) : IntSize();
754 754
755 // Keep bounding box relative to the main frame. 755 // Keep bounding box relative to the main frame.
756 boundingBox.move(pinchViewportOffset); 756 boundingBox.move(pinchViewportOffset);
757 757
758 Vector<IntRect> goodTargets; 758 Vector<IntRect> goodTargets;
759 WillBeHeapVector<RawPtrWillBeMember<Node> > highlightNodes; 759 WillBeHeapVector<RawPtrWillBeMember<Node>> highlightNodes;
760 findGoodTouchTargets(boundingBox, mainFrameImpl()->frame(), goodTarg ets, highlightNodes); 760 findGoodTouchTargets(boundingBox, mainFrameImpl()->frame(), goodTarg ets, highlightNodes);
761 // FIXME: replace touch adjustment code when numberOfGoodTargets == 1? 761 // FIXME: replace touch adjustment code when numberOfGoodTargets == 1?
762 // Single candidate case is currently handled by: https://bugs.webki t.org/show_bug.cgi?id=85101 762 // Single candidate case is currently handled by: https://bugs.webki t.org/show_bug.cgi?id=85101
763 if (goodTargets.size() >= 2 && m_client 763 if (goodTargets.size() >= 2 && m_client
764 && m_client->didTapMultipleTargets(pinchViewportOffset, bounding Box, goodTargets)) { 764 && m_client->didTapMultipleTargets(pinchViewportOffset, bounding Box, goodTargets)) {
765 765
766 enableTapHighlights(highlightNodes); 766 enableTapHighlights(highlightNodes);
767 for (size_t i = 0; i < m_linkHighlights.size(); ++i) 767 for (size_t i = 0; i < m_linkHighlights.size(); ++i)
768 m_linkHighlights[i]->startHighlightAnimationIfNeeded(); 768 m_linkHighlights[i]->startHighlightAnimationIfNeeded();
769 eventSwallowed = true; 769 eventSwallowed = true;
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
1229 m_page->deprecatedLocalMainFrame()); 1229 m_page->deprecatedLocalMainFrame());
1230 } while (cursorDefiningAncestor && showsHandCursor(cursorDefiningAncestor, m _page->deprecatedLocalMainFrame())); 1230 } while (cursorDefiningAncestor && showsHandCursor(cursorDefiningAncestor, m _page->deprecatedLocalMainFrame()));
1231 1231
1232 return bestTouchNode; 1232 return bestTouchNode;
1233 } 1233 }
1234 1234
1235 void WebViewImpl::enableTapHighlightAtPoint(const GestureEventWithHitTestResults & targetedTapEvent) 1235 void WebViewImpl::enableTapHighlightAtPoint(const GestureEventWithHitTestResults & targetedTapEvent)
1236 { 1236 {
1237 Node* touchNode = bestTapNode(targetedTapEvent); 1237 Node* touchNode = bestTapNode(targetedTapEvent);
1238 1238
1239 WillBeHeapVector<RawPtrWillBeMember<Node> > highlightNodes; 1239 WillBeHeapVector<RawPtrWillBeMember<Node>> highlightNodes;
1240 highlightNodes.append(touchNode); 1240 highlightNodes.append(touchNode);
1241 1241
1242 enableTapHighlights(highlightNodes); 1242 enableTapHighlights(highlightNodes);
1243 } 1243 }
1244 1244
1245 void WebViewImpl::enableTapHighlights(WillBeHeapVector<RawPtrWillBeMember<Node> >& highlightNodes) 1245 void WebViewImpl::enableTapHighlights(WillBeHeapVector<RawPtrWillBeMember<Node>> & highlightNodes)
1246 { 1246 {
1247 if (highlightNodes.isEmpty()) 1247 if (highlightNodes.isEmpty())
1248 return; 1248 return;
1249 1249
1250 // Always clear any existing highlight when this is invoked, even if we 1250 // Always clear any existing highlight when this is invoked, even if we
1251 // don't get a new target to highlight. 1251 // don't get a new target to highlight.
1252 m_linkHighlights.clear(); 1252 m_linkHighlights.clear();
1253 1253
1254 // LinkHighlight reads out layout and compositing state, so we need to make sure that's all up to date. 1254 // LinkHighlight reads out layout and compositing state, so we need to make sure that's all up to date.
1255 layout(); 1255 layout();
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
1582 m_page->willBeDestroyed(); 1582 m_page->willBeDestroyed();
1583 m_page.clear(); 1583 m_page.clear();
1584 } 1584 }
1585 1585
1586 // Should happen after m_page.clear(). 1586 // Should happen after m_page.clear().
1587 if (m_devToolsAgent) 1587 if (m_devToolsAgent)
1588 m_devToolsAgent.clear(); 1588 m_devToolsAgent.clear();
1589 1589
1590 // Reset the delegate to prevent notifications being sent as we're being 1590 // Reset the delegate to prevent notifications being sent as we're being
1591 // deleted. 1591 // deleted.
1592 m_client = 0; 1592 m_client = nullptr;
1593 1593
1594 deref(); // Balances ref() acquired in WebView::create 1594 deref(); // Balances ref() acquired in WebView::create
1595 } 1595 }
1596 1596
1597 void WebViewImpl::willStartLiveResize() 1597 void WebViewImpl::willStartLiveResize()
1598 { 1598 {
1599 if (mainFrameImpl() && mainFrameImpl()->frameView()) 1599 if (mainFrameImpl() && mainFrameImpl()->frameView())
1600 mainFrameImpl()->frameView()->willStartLiveResize(); 1600 mainFrameImpl()->frameView()->willStartLiveResize();
1601 1601
1602 LocalFrame* frame = mainFrameImpl()->frame(); 1602 LocalFrame* frame = mainFrameImpl()->frame();
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
1946 bool WebViewImpl::hasHorizontalScrollbar() 1946 bool WebViewImpl::hasHorizontalScrollbar()
1947 { 1947 {
1948 return mainFrameImpl()->frameView()->horizontalScrollbar(); 1948 return mainFrameImpl()->frameView()->horizontalScrollbar();
1949 } 1949 }
1950 1950
1951 bool WebViewImpl::hasVerticalScrollbar() 1951 bool WebViewImpl::hasVerticalScrollbar()
1952 { 1952 {
1953 return mainFrameImpl()->frameView()->verticalScrollbar(); 1953 return mainFrameImpl()->frameView()->verticalScrollbar();
1954 } 1954 }
1955 1955
1956 const WebInputEvent* WebViewImpl::m_currentInputEvent = 0; 1956 const WebInputEvent* WebViewImpl::m_currentInputEvent = nullptr;
1957 1957
1958 // FIXME: autogenerate this kind of code, and use it throughout Blink rather tha n 1958 // FIXME: autogenerate this kind of code, and use it throughout Blink rather tha n
1959 // the one-offs for subsets of these values. 1959 // the one-offs for subsets of these values.
1960 static String inputTypeToName(WebInputEvent::Type type) 1960 static String inputTypeToName(WebInputEvent::Type type)
1961 { 1961 {
1962 switch (type) { 1962 switch (type) {
1963 case WebInputEvent::MouseDown: 1963 case WebInputEvent::MouseDown:
1964 return EventTypeNames::mousedown; 1964 return EventTypeNames::mousedown;
1965 case WebInputEvent::MouseUp: 1965 case WebInputEvent::MouseUp:
1966 return EventTypeNames::mouseup; 1966 return EventTypeNames::mouseup;
(...skipping 2143 matching lines...) Expand 10 before | Expand all | Expand 10 after
4110 suppressInvalidations(true); 4110 suppressInvalidations(true);
4111 4111
4112 if (pinchVirtualViewportEnabled()) { 4112 if (pinchVirtualViewportEnabled()) {
4113 PinchViewport& pinchViewport = page()->frameHost().pinchViewport(); 4113 PinchViewport& pinchViewport = page()->frameHost().pinchViewport();
4114 pinchViewport.attachToLayerTree(layer, graphicsLayerFactory()); 4114 pinchViewport.attachToLayerTree(layer, graphicsLayerFactory());
4115 if (layer) { 4115 if (layer) {
4116 m_rootGraphicsLayer = pinchViewport.rootGraphicsLayer(); 4116 m_rootGraphicsLayer = pinchViewport.rootGraphicsLayer();
4117 m_rootLayer = pinchViewport.rootGraphicsLayer()->platformLayer(); 4117 m_rootLayer = pinchViewport.rootGraphicsLayer()->platformLayer();
4118 m_rootTransformLayer = pinchViewport.rootGraphicsLayer(); 4118 m_rootTransformLayer = pinchViewport.rootGraphicsLayer();
4119 } else { 4119 } else {
4120 m_rootGraphicsLayer = 0; 4120 m_rootGraphicsLayer = nullptr;
4121 m_rootLayer = 0; 4121 m_rootLayer = nullptr;
4122 m_rootTransformLayer = 0; 4122 m_rootTransformLayer = nullptr;
4123 } 4123 }
4124 } else { 4124 } else {
4125 m_rootGraphicsLayer = layer; 4125 m_rootGraphicsLayer = layer;
4126 m_rootLayer = layer ? layer->platformLayer() : 0; 4126 m_rootLayer = layer ? layer->platformLayer() : 0;
4127 m_rootTransformLayer = 0; 4127 m_rootTransformLayer = nullptr;
4128 } 4128 }
4129 4129
4130 setIsAcceleratedCompositingActive(layer != 0); 4130 setIsAcceleratedCompositingActive(layer != 0);
4131 4131
4132 updateRootLayerTransform(); 4132 updateRootLayerTransform();
4133 4133
4134 if (m_layerTreeView) { 4134 if (m_layerTreeView) {
4135 if (m_rootLayer) { 4135 if (m_rootLayer) {
4136 m_layerTreeView->setRootLayer(*m_rootLayer); 4136 m_layerTreeView->setRootLayer(*m_rootLayer);
4137 // We register viewport layers here since there may not be a layer 4137 // We register viewport layers here since there may not be a layer
4138 // tree view prior to this point. 4138 // tree view prior to this point.
4139 if (pinchVirtualViewportEnabled()) { 4139 if (pinchVirtualViewportEnabled()) {
4140 page()->frameHost().pinchViewport().registerLayersWithTreeView(m _layerTreeView); 4140 page()->frameHost().pinchViewport().registerLayersWithTreeView(m _layerTreeView);
4141 } else { 4141 } else {
4142 GraphicsLayer* rootScrollLayer = compositor()->scrollLayer(); 4142 GraphicsLayer* rootScrollLayer = compositor()->scrollLayer();
4143 ASSERT(rootScrollLayer); 4143 ASSERT(rootScrollLayer);
4144 WebLayer* pageScaleLayer = rootScrollLayer->parent() ? rootScrol lLayer->parent()->platformLayer() : 0; 4144 WebLayer* pageScaleLayer = rootScrollLayer->parent() ? rootScrol lLayer->parent()->platformLayer() : nullptr;
4145 // Note that it is invalid to have 0 as a scroll elasticity laye r when using pinch virtual viewport. 4145 // Note that it is invalid to have 0 as a scroll elasticity laye r when using pinch virtual viewport.
4146 m_layerTreeView->registerViewportLayers(0, pageScaleLayer, rootS crollLayer->platformLayer(), 0); 4146 m_layerTreeView->registerViewportLayers(0, pageScaleLayer, rootS crollLayer->platformLayer(), 0);
4147 } 4147 }
4148 } else { 4148 } else {
4149 m_layerTreeView->clearRootLayer(); 4149 m_layerTreeView->clearRootLayer();
4150 if (pinchVirtualViewportEnabled()) 4150 if (pinchVirtualViewportEnabled())
4151 page()->frameHost().pinchViewport().clearLayersForTreeView(m_lay erTreeView); 4151 page()->frameHost().pinchViewport().clearLayersForTreeView(m_lay erTreeView);
4152 else 4152 else
4153 m_layerTreeView->clearViewportLayers(); 4153 m_layerTreeView->clearViewportLayers();
4154 } 4154 }
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
4530 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width 4530 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width
4531 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); 4531 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1);
4532 } 4532 }
4533 4533
4534 void WebViewImpl::forceNextWebGLContextCreationToFail() 4534 void WebViewImpl::forceNextWebGLContextCreationToFail()
4535 { 4535 {
4536 WebGLRenderingContext::forceNextWebGLContextCreationToFail(); 4536 WebGLRenderingContext::forceNextWebGLContextCreationToFail();
4537 } 4537 }
4538 4538
4539 } // namespace blink 4539 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698