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

Side by Side Diff: sky/engine/web/WebViewImpl.cpp

Issue 866733007: Remove more unused code in WebViewImpl (Closed) Base URL: git@github.com:domokit/mojo.git@master
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
« no previous file with comments | « sky/engine/web/WebViewImpl.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) 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 m_spellCheckClient = spellCheckClient; 127 m_spellCheckClient = spellCheckClient;
128 } 128 }
129 129
130 WebViewImpl::WebViewImpl(WebViewClient* client) 130 WebViewImpl::WebViewImpl(WebViewClient* client)
131 : m_client(client) 131 : m_client(client)
132 , m_spellCheckClient(0) 132 , m_spellCheckClient(0)
133 , m_chromeClientImpl(this) 133 , m_chromeClientImpl(this)
134 , m_editorClientImpl(this) 134 , m_editorClientImpl(this)
135 , m_spellCheckerClientImpl(this) 135 , m_spellCheckerClientImpl(this)
136 , m_fixedLayoutSizeLock(false) 136 , m_fixedLayoutSizeLock(false)
137 , m_ignoreInputEvents(false)
138 , m_compositorDeviceScaleFactorOverride(0)
139 , m_rootLayerScale(1) 137 , m_rootLayerScale(1)
140 , m_suppressNextKeypressEvent(false) 138 , m_suppressNextKeypressEvent(false)
141 , m_imeAcceptEvents(true) 139 , m_imeAcceptEvents(true)
142 , m_isTransparent(false) 140 , m_isTransparent(false)
143 , m_tabsToLinks(false)
144 , m_rootLayer(0) 141 , m_rootLayer(0)
145 , m_matchesHeuristicsForGpuRasterization(false) 142 , m_matchesHeuristicsForGpuRasterization(false)
146 , m_recreatingGraphicsContext(false) 143 , m_recreatingGraphicsContext(false)
147 , m_flingModifier(0) 144 , m_flingModifier(0)
148 , m_flingSourceDevice(false) 145 , m_flingSourceDevice(false)
149 , m_showPaintRects(false) 146 , m_showPaintRects(false)
150 , m_showDebugBorders(false) 147 , m_showDebugBorders(false)
151 , m_continuousPaintingEnabled(false)
152 , m_showScrollBottleneckRects(false) 148 , m_showScrollBottleneckRects(false)
153 , m_baseBackgroundColor(Color::white) 149 , m_baseBackgroundColor(Color::white)
154 , m_backgroundColorOverride(Color::transparent) 150 , m_backgroundColorOverride(Color::transparent)
155 , m_userGestureObserved(false) 151 , m_userGestureObserved(false)
156 { 152 {
157 Page::PageClients pageClients; 153 Page::PageClients pageClients;
158 pageClients.chromeClient = &m_chromeClientImpl; 154 pageClients.chromeClient = &m_chromeClientImpl;
159 pageClients.editorClient = &m_editorClientImpl; 155 pageClients.editorClient = &m_editorClientImpl;
160 pageClients.spellCheckerClient = &m_spellCheckerClientImpl; 156 pageClients.spellCheckerClient = &m_spellCheckerClientImpl;
161 157
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 bool eventCancelled = false; // for disambiguation 203 bool eventCancelled = false; // for disambiguation
208 204
209 PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), even t); 205 PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), even t);
210 206
211 // FIXME: Remove redundant hit tests by pushing the call to EventHandler::ta rgetGestureEvent 207 // FIXME: Remove redundant hit tests by pushing the call to EventHandler::ta rgetGestureEvent
212 // up to this point and pass GestureEventWithHitTestResults around. 208 // up to this point and pass GestureEventWithHitTestResults around.
213 209
214 switch (event.type) { 210 switch (event.type) {
215 case WebInputEvent::GestureTap: { 211 case WebInputEvent::GestureTap: {
216 m_client->cancelScheduledContentIntents(); 212 m_client->cancelScheduledContentIntents();
217 if (detectContentOnTouch(platformEvent.position())) {
218 eventSwallowed = true;
219 break;
220 }
221
222 eventSwallowed = mainFrameImpl()->frame()->eventHandler().handleGestureE vent(platformEvent); 213 eventSwallowed = mainFrameImpl()->frame()->eventHandler().handleGestureE vent(platformEvent);
223 break; 214 break;
224 } 215 }
225 case WebInputEvent::GestureTwoFingerTap: 216 case WebInputEvent::GestureTwoFingerTap:
226 case WebInputEvent::GestureLongPress: 217 case WebInputEvent::GestureLongPress:
227 case WebInputEvent::GestureLongTap: { 218 case WebInputEvent::GestureLongTap: {
228 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) 219 if (!mainFrameImpl() || !mainFrameImpl()->frameView())
229 break; 220 break;
230 221
231 m_client->cancelScheduledContentIntents(); 222 m_client->cancelScheduledContentIntents();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 void WebViewImpl::setShowPaintRects(bool show) 258 void WebViewImpl::setShowPaintRects(bool show)
268 { 259 {
269 m_showPaintRects = show; 260 m_showPaintRects = show;
270 } 261 }
271 262
272 void WebViewImpl::setShowDebugBorders(bool show) 263 void WebViewImpl::setShowDebugBorders(bool show)
273 { 264 {
274 m_showDebugBorders = show; 265 m_showDebugBorders = show;
275 } 266 }
276 267
277 void WebViewImpl::setContinuousPaintingEnabled(bool enabled)
278 {
279 m_continuousPaintingEnabled = enabled;
280 m_client->scheduleAnimation();
281 }
282
283 void WebViewImpl::setShowScrollBottleneckRects(bool show) 268 void WebViewImpl::setShowScrollBottleneckRects(bool show)
284 { 269 {
285 m_showScrollBottleneckRects = show; 270 m_showScrollBottleneckRects = show;
286 } 271 }
287 272
288 void WebViewImpl::acceptLanguagesChanged() 273 void WebViewImpl::acceptLanguagesChanged()
289 { 274 {
290 if (!page()) 275 if (!page())
291 return; 276 return;
292 277
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 511
527 WebBeginFrameArgs validFrameTime(frameTime); 512 WebBeginFrameArgs validFrameTime(frameTime);
528 if (!validFrameTime.lastFrameTimeMonotonic) 513 if (!validFrameTime.lastFrameTimeMonotonic)
529 validFrameTime.lastFrameTimeMonotonic = monotonicallyIncreasingTime(); 514 validFrameTime.lastFrameTimeMonotonic = monotonicallyIncreasingTime();
530 515
531 WTF_LOG(ScriptedAnimationController, "WebViewImpl::beginFrame: page = %d", ! m_page ? 0 : 1); 516 WTF_LOG(ScriptedAnimationController, "WebViewImpl::beginFrame: page = %d", ! m_page ? 0 : 1);
532 if (!m_page) 517 if (!m_page)
533 return; 518 return;
534 519
535 PageWidgetDelegate::animate(m_page.get(), validFrameTime.lastFrameTimeMonoto nic); 520 PageWidgetDelegate::animate(m_page.get(), validFrameTime.lastFrameTimeMonoto nic);
536
537 if (m_continuousPaintingEnabled)
538 m_client->scheduleAnimation();
539 } 521 }
540 522
541 void WebViewImpl::layout() 523 void WebViewImpl::layout()
542 { 524 {
543 TRACE_EVENT0("blink", "WebViewImpl::layout"); 525 TRACE_EVENT0("blink", "WebViewImpl::layout");
544 if (!localFrameRootTemporary()) 526 if (!localFrameRootTemporary())
545 return; 527 return;
546 PageWidgetDelegate::layout(m_page.get(), localFrameRootTemporary()->frame()) ; 528 PageWidgetDelegate::layout(m_page.get(), localFrameRootTemporary()->frame()) ;
547 } 529 }
548 530
549 void WebViewImpl::paint(WebCanvas* canvas, const WebRect& rect) 531 void WebViewImpl::paint(WebCanvas* canvas, const WebRect& rect)
550 { 532 {
551 double paintStart = currentTime();
552 PageWidgetDelegate::paint(m_page.get(), canvas, rect, isTransparent() ? Page WidgetDelegate::Translucent : PageWidgetDelegate::Opaque); 533 PageWidgetDelegate::paint(m_page.get(), canvas, rect, isTransparent() ? Page WidgetDelegate::Translucent : PageWidgetDelegate::Opaque);
553 double paintEnd = currentTime();
554 double pixelsPerSec = (rect.width * rect.height) / (paintEnd - paintStart);
555 Platform::current()->histogramCustomCounts("Renderer4.SoftwarePaintDurationM S", (paintEnd - paintStart) * 1000, 0, 120, 30);
556 Platform::current()->histogramCustomCounts("Renderer4.SoftwarePaintMegapixPe rSecond", pixelsPerSec / 1000000, 10, 210, 30);
557 } 534 }
558 535
559 const WebInputEvent* WebViewImpl::m_currentInputEvent = 0; 536 const WebInputEvent* WebViewImpl::m_currentInputEvent = 0;
560 537
561 // FIXME: autogenerate this kind of code, and use it throughout Blink rather tha n 538 // FIXME: autogenerate this kind of code, and use it throughout Blink rather tha n
562 // the one-offs for subsets of these values. 539 // the one-offs for subsets of these values.
563 static String inputTypeToName(WebInputEvent::Type type) 540 static String inputTypeToName(WebInputEvent::Type type)
564 { 541 {
565 switch (type) { 542 switch (type) {
566 case WebInputEvent::MouseDown: 543 case WebInputEvent::MouseDown:
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 return EventTypeNames::touchcancel; 580 return EventTypeNames::touchcancel;
604 default: 581 default:
605 return String("unknown"); 582 return String("unknown");
606 } 583 }
607 } 584 }
608 585
609 bool WebViewImpl::handleInputEvent(const WebInputEvent& inputEvent) 586 bool WebViewImpl::handleInputEvent(const WebInputEvent& inputEvent)
610 { 587 {
611 TRACE_EVENT1("input", "WebViewImpl::handleInputEvent", "type", inputTypeToNa me(inputEvent.type).ascii().data()); 588 TRACE_EVENT1("input", "WebViewImpl::handleInputEvent", "type", inputTypeToNa me(inputEvent.type).ascii().data());
612 589
613 // Report the event to be NOT processed by WebKit, so that the browser can h andle it appropriately.
614 if (m_ignoreInputEvents)
615 return false;
616
617 TemporaryChange<const WebInputEvent*> currentEventChange(m_currentInputEvent , &inputEvent); 590 TemporaryChange<const WebInputEvent*> currentEventChange(m_currentInputEvent , &inputEvent);
618 591
619 if (m_mouseCaptureNode && WebInputEvent::isMouseEventType(inputEvent.type)) { 592 if (m_mouseCaptureNode && WebInputEvent::isMouseEventType(inputEvent.type)) {
620 TRACE_EVENT1("input", "captured mouse event", "type", inputEvent.type); 593 TRACE_EVENT1("input", "captured mouse event", "type", inputEvent.type);
621 // Save m_mouseCaptureNode since mouseCaptureLost() will clear it. 594 // Save m_mouseCaptureNode since mouseCaptureLost() will clear it.
622 RefPtr<Node> node = m_mouseCaptureNode; 595 RefPtr<Node> node = m_mouseCaptureNode;
623 596
624 // Not all platforms call mouseCaptureLost() directly. 597 // Not all platforms call mouseCaptureLost() directly.
625 if (inputEvent.type == WebInputEvent::MouseUp) 598 if (inputEvent.type == WebInputEvent::MouseUp)
626 mouseCaptureLost(); 599 mouseCaptureLost();
(...skipping 23 matching lines...) Expand all
650 623
651 node->dispatchMouseEvent( 624 node->dispatchMouseEvent(
652 PlatformMouseEventBuilder(mainFrameImpl()->frameView(), static_cast< const WebMouseEvent&>(inputEvent)), 625 PlatformMouseEventBuilder(mainFrameImpl()->frameView(), static_cast< const WebMouseEvent&>(inputEvent)),
653 eventType, static_cast<const WebMouseEvent&>(inputEvent).clickCount) ; 626 eventType, static_cast<const WebMouseEvent&>(inputEvent).clickCount) ;
654 return true; 627 return true;
655 } 628 }
656 629
657 return PageWidgetDelegate::handleInputEvent(m_page.get(), *this, inputEvent) ; 630 return PageWidgetDelegate::handleInputEvent(m_page.get(), *this, inputEvent) ;
658 } 631 }
659 632
660 void WebViewImpl::setCursorVisibilityState(bool isVisible)
661 {
662 if (m_page)
663 m_page->setIsCursorVisible(isVisible);
664 }
665
666 void WebViewImpl::mouseCaptureLost() 633 void WebViewImpl::mouseCaptureLost()
667 { 634 {
668 TRACE_EVENT_ASYNC_END0("input", "capturing mouse", this); 635 TRACE_EVENT_ASYNC_END0("input", "capturing mouse", this);
669 m_mouseCaptureNode = nullptr; 636 m_mouseCaptureNode = nullptr;
670 } 637 }
671 638
672 void WebViewImpl::setFocus(bool enable) 639 void WebViewImpl::setFocus(bool enable)
673 { 640 {
674 m_page->focusController().setFocused(enable); 641 m_page->focusController().setFocused(enable);
675 if (enable) { 642 if (enable) {
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 m_webSettings = adoptPtr(new WebSettingsImpl(&m_page->settings())); 935 m_webSettings = adoptPtr(new WebSettingsImpl(&m_page->settings()));
969 ASSERT(m_webSettings); 936 ASSERT(m_webSettings);
970 return m_webSettings.get(); 937 return m_webSettings.get();
971 } 938 }
972 939
973 WebSettings* WebViewImpl::settings() 940 WebSettings* WebViewImpl::settings()
974 { 941 {
975 return settingsImpl(); 942 return settingsImpl();
976 } 943 }
977 944
978 WebString WebViewImpl::pageEncoding() const
979 {
980 // FIXME(sky): remove.
981 if (!m_page)
982 return WebString();
983
984 return m_page->mainFrame()->document()->encodingName();
985 }
986
987 void WebViewImpl::setPageEncoding(const WebString& encodingName)
988 {
989 // FIXME(sky): remove
990 }
991
992 WebFrame* WebViewImpl::mainFrame() 945 WebFrame* WebViewImpl::mainFrame()
993 { 946 {
994 return WebFrame::fromFrame(m_page ? m_page->mainFrame() : 0); 947 return WebFrame::fromFrame(m_page ? m_page->mainFrame() : 0);
995 } 948 }
996 949
997 WebFrame* WebViewImpl::focusedFrame() 950 WebFrame* WebViewImpl::focusedFrame()
998 { 951 {
999 return WebFrame::fromFrame(focusedCoreFrame()); 952 return WebFrame::fromFrame(focusedCoreFrame());
1000 } 953 }
1001 954
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
1147 { 1100 {
1148 // FIXME: This is wrong. The FrameView is responsible sending a resizeEvent 1101 // FIXME: This is wrong. The FrameView is responsible sending a resizeEvent
1149 // as part of layout. Layout is also responsible for sending invalidations 1102 // as part of layout. Layout is also responsible for sending invalidations
1150 // to the embedder. This method and all callers may be wrong. -- eseidel. 1103 // to the embedder. This method and all callers may be wrong. -- eseidel.
1151 if (localFrameRootTemporary()->frameView()) { 1104 if (localFrameRootTemporary()->frameView()) {
1152 // Enqueues the resize event. 1105 // Enqueues the resize event.
1153 localFrameRootTemporary()->frame()->document()->enqueueResizeEvent(); 1106 localFrameRootTemporary()->frame()->document()->enqueueResizeEvent();
1154 } 1107 }
1155 } 1108 }
1156 1109
1157 void WebViewImpl::setCompositorDeviceScaleFactorOverride(float deviceScaleFactor )
1158 {
1159 m_compositorDeviceScaleFactorOverride = deviceScaleFactor;
1160 }
1161
1162 void WebViewImpl::setIsTransparent(bool isTransparent) 1110 void WebViewImpl::setIsTransparent(bool isTransparent)
1163 { 1111 {
1164 // Set any existing frames to be transparent. 1112 // Set any existing frames to be transparent.
1165 m_page->mainFrame()->view()->setTransparent(isTransparent); 1113 m_page->mainFrame()->view()->setTransparent(isTransparent);
1166 1114
1167 // Future frames check this to know whether to be transparent. 1115 // Future frames check this to know whether to be transparent.
1168 m_isTransparent = isTransparent; 1116 m_isTransparent = isTransparent;
1169 } 1117 }
1170 1118
1171 bool WebViewImpl::isTransparent() const 1119 bool WebViewImpl::isTransparent() const
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1205 UserGestureIndicator::clearProcessedUserGestureSinceLoad(); 1153 UserGestureIndicator::clearProcessedUserGestureSinceLoad();
1206 } 1154 }
1207 1155
1208 void WebViewImpl::layoutUpdated(WebLocalFrameImpl* webframe) 1156 void WebViewImpl::layoutUpdated(WebLocalFrameImpl* webframe)
1209 { 1157 {
1210 if (!m_client) 1158 if (!m_client)
1211 return; 1159 return;
1212 m_client->didUpdateLayout(); 1160 m_client->didUpdateLayout();
1213 } 1161 }
1214 1162
1215 void WebViewImpl::setIgnoreInputEvents(bool newValue)
1216 {
1217 ASSERT(m_ignoreInputEvents != newValue);
1218 m_ignoreInputEvents = newValue;
1219 }
1220
1221 void WebViewImpl::setBackgroundColorOverride(WebColor color) 1163 void WebViewImpl::setBackgroundColorOverride(WebColor color)
1222 { 1164 {
1223 m_backgroundColorOverride = color; 1165 m_backgroundColorOverride = color;
1224 } 1166 }
1225 1167
1226 Element* WebViewImpl::focusedElement() const 1168 Element* WebViewImpl::focusedElement() const
1227 { 1169 {
1228 LocalFrame* frame = m_page->focusController().focusedFrame(); 1170 LocalFrame* frame = m_page->focusController().focusedFrame();
1229 if (!frame) 1171 if (!frame)
1230 return 0; 1172 return 0;
1231 1173
1232 Document* document = frame->document(); 1174 Document* document = frame->document();
1233 if (!document) 1175 if (!document)
1234 return 0; 1176 return 0;
1235 1177
1236 return document->focusedElement(); 1178 return document->focusedElement();
1237 } 1179 }
1238 1180
1239 HitTestResult WebViewImpl::hitTestResultForWindowPos(const IntPoint& pos) 1181 HitTestResult WebViewImpl::hitTestResultForWindowPos(const IntPoint& pos)
1240 { 1182 {
1241 IntPoint docPoint(m_page->mainFrame()->view()->windowToContents(pos)); 1183 IntPoint docPoint(m_page->mainFrame()->view()->windowToContents(pos));
1242 HitTestResult result = m_page->mainFrame()->eventHandler().hitTestResultAtPo int(docPoint, HitTestRequest::ReadOnly | HitTestRequest::Active); 1184 HitTestResult result = m_page->mainFrame()->eventHandler().hitTestResultAtPo int(docPoint, HitTestRequest::ReadOnly | HitTestRequest::Active);
1243 return result; 1185 return result;
1244 } 1186 }
1245 1187
1246 void WebViewImpl::setTabsToLinks(bool enable)
1247 {
1248 m_tabsToLinks = enable;
1249 }
1250
1251 bool WebViewImpl::tabsToLinks() const
1252 {
1253 return m_tabsToLinks;
1254 }
1255
1256 void WebViewImpl::scheduleAnimation() 1188 void WebViewImpl::scheduleAnimation()
1257 { 1189 {
1258 m_client->scheduleAnimation(); 1190 m_client->scheduleAnimation();
1259 } 1191 }
1260 1192
1261 bool WebViewImpl::detectContentOnTouch(const WebPoint& position)
1262 {
1263 HitTestResult touchHit = hitTestResultForWindowPos(position);
1264
1265 if (touchHit.isContentEditable())
1266 return false;
1267
1268 Node* node = touchHit.innerNode();
1269 if (!node || !node->isTextNode())
1270 return false;
1271
1272 // Ignore when tapping on links or nodes listening to click events.
1273 for (; node; node = NodeRenderingTraversal::parent(node)) {
1274 if (node->isLink() || node->willRespondToTouchEvents() || node->willResp ondToMouseClickEvents())
1275 return false;
1276 }
1277
1278 WebContentDetectionResult content = m_client->detectContentAround(touchHit);
1279 if (!content.isValid())
1280 return false;
1281
1282 m_client->scheduleContentIntent(content.intent());
1283 return true;
1284 }
1285
1286 void WebViewImpl::setVisibilityState(WebPageVisibilityState visibilityState, 1193 void WebViewImpl::setVisibilityState(WebPageVisibilityState visibilityState,
1287 bool isInitialState) { 1194 bool isInitialState) {
1288 if (!page()) 1195 if (!page())
1289 return; 1196 return;
1290 1197
1291 ASSERT(visibilityState == WebPageVisibilityStateVisible || visibilityState = = WebPageVisibilityStateHidden); 1198 ASSERT(visibilityState == WebPageVisibilityStateVisible || visibilityState = = WebPageVisibilityStateHidden);
1292 m_page->setVisibilityState(static_cast<PageVisibilityState>(static_cast<int> (visibilityState)), isInitialState); 1199 m_page->setVisibilityState(static_cast<PageVisibilityState>(static_cast<int> (visibilityState)), isInitialState);
1293 } 1200 }
1294 1201
1295 } // namespace blink 1202 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/web/WebViewImpl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698