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

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

Issue 967213004: Removed FrameView's windowToContents and contentsToWindow methods. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 9 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) 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 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 ASSERT(!m_pagePopup); 523 ASSERT(!m_pagePopup);
524 } 524 }
525 525
526 m_lastMouseDownPoint = WebPoint(event.x, event.y); 526 m_lastMouseDownPoint = WebPoint(event.x, event.y);
527 527
528 // Take capture on a mouse down on a plugin so we can send it mouse events. 528 // Take capture on a mouse down on a plugin so we can send it mouse events.
529 // If the hit node is a plugin but a scrollbar is over it don't start mouse 529 // If the hit node is a plugin but a scrollbar is over it don't start mouse
530 // capture because it will interfere with the scrollbar receiving events. 530 // capture because it will interfere with the scrollbar receiving events.
531 IntPoint point(event.x, event.y); 531 IntPoint point(event.x, event.y);
532 if (event.button == WebMouseEvent::ButtonLeft && m_page->mainFrame()->isLoca lFrame()) { 532 if (event.button == WebMouseEvent::ButtonLeft && m_page->mainFrame()->isLoca lFrame()) {
533 point = m_page->deprecatedLocalMainFrame()->view()->windowToContents(poi nt); 533 point = m_page->deprecatedLocalMainFrame()->view()->rootFrameToContents( point);
534 HitTestResult result(m_page->deprecatedLocalMainFrame()->eventHandler(). hitTestResultAtPoint(point)); 534 HitTestResult result(m_page->deprecatedLocalMainFrame()->eventHandler(). hitTestResultAtPoint(point));
535 result.setToShadowHostIfInClosedShadowRoot(); 535 result.setToShadowHostIfInClosedShadowRoot();
536 Node* hitNode = result.innerNonSharedNode(); 536 Node* hitNode = result.innerNonSharedNode();
537 537
538 if (!result.scrollbar() && hitNode && hitNode->renderer() && hitNode->re nderer()->isEmbeddedObject()) { 538 if (!result.scrollbar() && hitNode && hitNode->renderer() && hitNode->re nderer()->isEmbeddedObject()) {
539 m_mouseCaptureNode = hitNode; 539 m_mouseCaptureNode = hitNode;
540 TRACE_EVENT_ASYNC_BEGIN0("input", "capturing mouse", this); 540 TRACE_EVENT_ASYNC_BEGIN0("input", "capturing mouse", this);
541 } 541 }
542 } 542 }
543 543
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 void WebViewImpl::mouseContextMenu(const WebMouseEvent& event) 585 void WebViewImpl::mouseContextMenu(const WebMouseEvent& event)
586 { 586 {
587 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) 587 if (!mainFrameImpl() || !mainFrameImpl()->frameView())
588 return; 588 return;
589 589
590 m_page->contextMenuController().clearContextMenu(); 590 m_page->contextMenuController().clearContextMenu();
591 591
592 PlatformMouseEventBuilder pme(mainFrameImpl()->frameView(), event); 592 PlatformMouseEventBuilder pme(mainFrameImpl()->frameView(), event);
593 593
594 // Find the right target frame. See issue 1186900. 594 // Find the right target frame. See issue 1186900.
595 HitTestResult result = hitTestResultForWindowPos(pme.position()); 595 HitTestResult result = hitTestResultForRootFramePos(pme.position());
596 Frame* targetFrame; 596 Frame* targetFrame;
597 if (result.innerNonSharedNode()) 597 if (result.innerNonSharedNode())
598 targetFrame = result.innerNonSharedNode()->document().frame(); 598 targetFrame = result.innerNonSharedNode()->document().frame();
599 else 599 else
600 targetFrame = m_page->focusController().focusedOrMainFrame(); 600 targetFrame = m_page->focusController().focusedOrMainFrame();
601 601
602 if (!targetFrame->isLocalFrame()) 602 if (!targetFrame->isLocalFrame())
603 return; 603 return;
604 604
605 LocalFrame* targetLocalFrame = toLocalFrame(targetFrame); 605 LocalFrame* targetLocalFrame = toLocalFrame(targetFrame);
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 RefPtrWillBeRawPtr<PopupContainer> selectPopup = nullptr; 776 RefPtrWillBeRawPtr<PopupContainer> selectPopup = nullptr;
777 selectPopup = m_selectPopup; 777 selectPopup = m_selectPopup;
778 hideSelectPopup(); 778 hideSelectPopup();
779 ASSERT(!m_selectPopup); 779 ASSERT(!m_selectPopup);
780 780
781 // Don't trigger a disambiguation popup on sites designed for mobile dev ices. 781 // Don't trigger a disambiguation popup on sites designed for mobile dev ices.
782 // Instead, assume that the page has been designed with big enough butto ns and links. 782 // Instead, assume that the page has been designed with big enough butto ns and links.
783 // Don't trigger a disambiguation popup when screencasting, since it's i mplemented outside of 783 // Don't trigger a disambiguation popup when screencasting, since it's i mplemented outside of
784 // compositor pipeline and is not being screencasted itself. This leads to bad user experience. 784 // compositor pipeline and is not being screencasted itself. This leads to bad user experience.
785 if (event.data.tap.width > 0 && !shouldDisableDesktopWorkarounds() && !p age()->inspectorController().screencastEnabled()) { 785 if (event.data.tap.width > 0 && !shouldDisableDesktopWorkarounds() && !p age()->inspectorController().screencastEnabled()) {
786 WebGestureEvent scaledEvent = event; 786 IntRect boundingBox(page()->frameHost().pinchViewport().viewportToRo otFrame(IntRect(
787 scaledEvent.x = event.x / pageScaleFactor(); 787 event.x - event.data.tap.width / 2,
788 scaledEvent.y = event.y / pageScaleFactor(); 788 event.y - event.data.tap.height / 2,
789 scaledEvent.data.tap.width = event.data.tap.width / pageScaleFactor( ); 789 event.data.tap.width,
790 scaledEvent.data.tap.height = event.data.tap.height / pageScaleFacto r(); 790 event.data.tap.height)));
791 IntRect boundingBox(
792 scaledEvent.x - scaledEvent.data.tap.width / 2,
793 scaledEvent.y - scaledEvent.data.tap.height / 2,
794 scaledEvent.data.tap.width,
795 scaledEvent.data.tap.height);
796 791
797 WebSize pinchViewportOffset = pinchVirtualViewportEnabled() ? 792 // FIXME: We shouldn't pass details of the PinchViewport offset to r ender_view_impl.
798 flooredIntSize(page()->frameHost().pinchViewport().location()) : IntSize(); 793 WebSize pinchViewportOffset = flooredIntSize(page()->frameHost().pin chViewport().location());
799
800 // Keep bounding box relative to the main frame.
801 boundingBox.move(pinchViewportOffset);
802 794
803 Vector<IntRect> goodTargets; 795 Vector<IntRect> goodTargets;
804 WillBeHeapVector<RawPtrWillBeMember<Node>> highlightNodes; 796 WillBeHeapVector<RawPtrWillBeMember<Node>> highlightNodes;
805 findGoodTouchTargets(boundingBox, mainFrameImpl()->frame(), goodTarg ets, highlightNodes); 797 findGoodTouchTargets(boundingBox, mainFrameImpl()->frame(), goodTarg ets, highlightNodes);
806 // FIXME: replace touch adjustment code when numberOfGoodTargets == 1? 798 // FIXME: replace touch adjustment code when numberOfGoodTargets == 1?
807 // Single candidate case is currently handled by: https://bugs.webki t.org/show_bug.cgi?id=85101 799 // Single candidate case is currently handled by: https://bugs.webki t.org/show_bug.cgi?id=85101
808 if (goodTargets.size() >= 2 && m_client 800 if (goodTargets.size() >= 2 && m_client
809 && m_client->didTapMultipleTargets(pinchViewportOffset, bounding Box, goodTargets)) { 801 && m_client->didTapMultipleTargets(pinchViewportOffset, bounding Box, goodTargets)) {
810 802
811 enableTapHighlights(highlightNodes); 803 enableTapHighlights(highlightNodes);
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
1119 // events. 1111 // events.
1120 if (evt.isSystemKey()) 1112 if (evt.isSystemKey())
1121 return false; 1113 return false;
1122 1114
1123 if (!suppress && !handler.keyEvent(evt)) 1115 if (!suppress && !handler.keyEvent(evt))
1124 return keyEventDefault(event); 1116 return keyEventDefault(event);
1125 1117
1126 return true; 1118 return true;
1127 } 1119 }
1128 1120
1129 WebRect WebViewImpl::computeBlockBound(const WebPoint& webPoint, bool ignoreClip ping) 1121 WebRect WebViewImpl::computeBlockBound(const WebPoint& pointInRootFrame, bool ig noreClipping)
1130 { 1122 {
1131 if (!mainFrameImpl()) 1123 if (!mainFrameImpl())
1132 return WebRect(); 1124 return WebRect();
1133 1125
1134 // Use the point-based hit test to find the node. 1126 // Use the point-based hit test to find the node.
1135 IntPoint point = mainFrameImpl()->frameView()->windowToContents(IntPoint(web Point.x, webPoint.y)); 1127 IntPoint point = mainFrameImpl()->frameView()->rootFrameToContents(IntPoint( pointInRootFrame.x, pointInRootFrame.y));
1136 HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitT estRequest::Active | (ignoreClipping ? HitTestRequest::IgnoreClipping : 0); 1128 HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitT estRequest::Active | (ignoreClipping ? HitTestRequest::IgnoreClipping : 0);
1137 HitTestResult result = mainFrameImpl()->frame()->eventHandler().hitTestResul tAtPoint(point, hitType); 1129 HitTestResult result = mainFrameImpl()->frame()->eventHandler().hitTestResul tAtPoint(point, hitType);
1138 result.setToShadowHostIfInClosedShadowRoot(); 1130 result.setToShadowHostIfInClosedShadowRoot();
1139 1131
1140 Node* node = result.innerNonSharedNode(); 1132 Node* node = result.innerNonSharedNode();
1141 if (!node) 1133 if (!node)
1142 return WebRect(); 1134 return WebRect();
1143 1135
1144 // Find the block type node based on the hit node. 1136 // Find the block type node based on the hit node.
1145 // FIXME: This wants to walk composed tree with NodeRenderingTraversal::pare nt(). 1137 // FIXME: This wants to walk composed tree with NodeRenderingTraversal::pare nt().
1146 while (node && (!node->renderer() || node->renderer()->isInline())) 1138 while (node && (!node->renderer() || node->renderer()->isInline()))
1147 node = NodeRenderingTraversal::parent(*node); 1139 node = NodeRenderingTraversal::parent(*node);
1148 1140
1149 // Return the bounding box in the window coordinate system. 1141 // Return the bounding box in the root frame's coordinate space.
1150 if (node) { 1142 if (node) {
1151 IntRect rect = node->Node::pixelSnappedBoundingBox(); 1143 IntRect pointInRootFrame = node->Node::pixelSnappedBoundingBox();
1152 LocalFrame* frame = node->document().frame(); 1144 LocalFrame* frame = node->document().frame();
1153 return frame->view()->contentsToWindow(rect); 1145 return frame->view()->contentsToRootFrame(pointInRootFrame);
1154 } 1146 }
1155 return WebRect(); 1147 return WebRect();
1156 } 1148 }
1157 1149
1158 WebRect WebViewImpl::widenRectWithinPageBounds(const WebRect& source, int target Margin, int minimumMargin) 1150 WebRect WebViewImpl::widenRectWithinPageBounds(const WebRect& source, int target Margin, int minimumMargin)
1159 { 1151 {
1160 WebSize maxSize; 1152 WebSize maxSize;
1161 if (mainFrame()) 1153 if (mainFrame())
1162 maxSize = mainFrame()->contentsSize(); 1154 maxSize = mainFrame()->contentsSize();
1163 IntSize scrollOffset; 1155 IntSize scrollOffset;
(...skipping 27 matching lines...) Expand all
1191 { 1183 {
1192 // Pages should be as legible as on desktop when at dpi scale, so no 1184 // Pages should be as legible as on desktop when at dpi scale, so no
1193 // need to zoom in further when automatically determining zoom level 1185 // need to zoom in further when automatically determining zoom level
1194 // (after double tap, find in page, etc), though the user should still 1186 // (after double tap, find in page, etc), though the user should still
1195 // be allowed to manually pinch zoom in further if they desire. 1187 // be allowed to manually pinch zoom in further if they desire.
1196 if (page()) 1188 if (page())
1197 return m_maximumLegibleScale * page()->settings().accessibilityFontScale Factor(); 1189 return m_maximumLegibleScale * page()->settings().accessibilityFontScale Factor();
1198 return m_maximumLegibleScale; 1190 return m_maximumLegibleScale;
1199 } 1191 }
1200 1192
1201 void WebViewImpl::computeScaleAndScrollForBlockRect(const WebPoint& hitPoint, co nst WebRect& blockRect, float padding, float defaultScaleWhenAlreadyLegible, flo at& scale, WebPoint& scroll) 1193 void WebViewImpl::computeScaleAndScrollForBlockRect(const WebPoint& hitPointInRo otFrame, const WebRect& blockRectInRootFrame, float padding, float defaultScaleW henAlreadyLegible, float& scale, WebPoint& scroll)
1202 { 1194 {
1203 scale = pageScaleFactor(); 1195 scale = pageScaleFactor();
1204 scroll.x = scroll.y = 0; 1196 scroll.x = scroll.y = 0;
1205 1197
1206 WebRect rect = blockRect; 1198 WebRect rect = blockRectInRootFrame;
1207 1199
1208 if (!rect.isEmpty()) { 1200 if (!rect.isEmpty()) {
1209 float defaultMargin = doubleTapZoomContentDefaultMargin; 1201 float defaultMargin = doubleTapZoomContentDefaultMargin;
1210 float minimumMargin = doubleTapZoomContentMinimumMargin; 1202 float minimumMargin = doubleTapZoomContentMinimumMargin;
1211 // We want the margins to have the same physical size, which means we 1203 // We want the margins to have the same physical size, which means we
1212 // need to express them in post-scale size. To do that we'd need to know 1204 // need to express them in post-scale size. To do that we'd need to know
1213 // the scale we're scaling to, but that depends on the margins. Instead 1205 // the scale we're scaling to, but that depends on the margins. Instead
1214 // we express them as a fraction of the target rectangle: this will be 1206 // we express them as a fraction of the target rectangle: this will be
1215 // correct if we end up fully zooming to it, and won't matter if we 1207 // correct if we end up fully zooming to it, and won't matter if we
1216 // don't. 1208 // don't.
(...skipping 18 matching lines...) Expand all
1235 float screenWidth = m_size.width / scale; 1227 float screenWidth = m_size.width / scale;
1236 float screenHeight = m_size.height / scale; 1228 float screenHeight = m_size.height / scale;
1237 1229
1238 // Scroll to vertically align the block. 1230 // Scroll to vertically align the block.
1239 if (rect.height < screenHeight) { 1231 if (rect.height < screenHeight) {
1240 // Vertically center short blocks. 1232 // Vertically center short blocks.
1241 rect.y -= 0.5 * (screenHeight - rect.height); 1233 rect.y -= 0.5 * (screenHeight - rect.height);
1242 } else { 1234 } else {
1243 // Ensure position we're zooming to (+ padding) isn't off the bottom of 1235 // Ensure position we're zooming to (+ padding) isn't off the bottom of
1244 // the screen. 1236 // the screen.
1245 rect.y = std::max<float>(rect.y, hitPoint.y + padding - screenHeight); 1237 rect.y = std::max<float>(rect.y, hitPointInRootFrame.y + padding - scree nHeight);
1246 } // Otherwise top align the block. 1238 } // Otherwise top align the block.
1247 1239
1248 // Do the same thing for horizontal alignment. 1240 // Do the same thing for horizontal alignment.
1249 if (rect.width < screenWidth) 1241 if (rect.width < screenWidth)
1250 rect.x -= 0.5 * (screenWidth - rect.width); 1242 rect.x -= 0.5 * (screenWidth - rect.width);
1251 else 1243 else
1252 rect.x = std::max<float>(rect.x, hitPoint.x + padding - screenWidth); 1244 rect.x = std::max<float>(rect.x, hitPointInRootFrame.x + padding - scree nWidth);
1253 scroll.x = rect.x; 1245 scroll.x = rect.x;
1254 scroll.y = rect.y; 1246 scroll.y = rect.y;
1255 1247
1256 scale = clampPageScaleFactorToLimits(scale); 1248 scale = clampPageScaleFactorToLimits(scale);
1257 scroll = mainFrameImpl()->frameView()->windowToContents(scroll); 1249 scroll = mainFrameImpl()->frameView()->rootFrameToContents(scroll);
1258 scroll = clampOffsetAtScale(scroll, scale); 1250 scroll = clampOffsetAtScale(scroll, scale);
1259 } 1251 }
1260 1252
1261 static Node* findCursorDefiningAncestor(Node* node, LocalFrame* frame) 1253 static Node* findCursorDefiningAncestor(Node* node, LocalFrame* frame)
1262 { 1254 {
1263 // Go up the tree to find the node that defines a mouse cursor style 1255 // Go up the tree to find the node that defines a mouse cursor style
1264 while (node) { 1256 while (node) {
1265 if (node->renderer()) { 1257 if (node->renderer()) {
1266 ECursor cursor = node->renderer()->style()->cursor(); 1258 ECursor cursor = node->renderer()->style()->cursor();
1267 if (cursor != CURSOR_AUTO || frame->eventHandler().useHandCursor(nod e, node->isLink())) 1259 if (cursor != CURSOR_AUTO || frame->eventHandler().useHandCursor(nod e, node->isLink()))
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1358 // Safari documentation for -webkit-tap-highlight-color says if the spec ified color has 0 alpha, 1350 // Safari documentation for -webkit-tap-highlight-color says if the spec ified color has 0 alpha,
1359 // then tap highlighting is disabled. 1351 // then tap highlighting is disabled.
1360 // http://developer.apple.com/library/safari/#documentation/appleapplica tions/reference/safaricssref/articles/standardcssproperties.html 1352 // http://developer.apple.com/library/safari/#documentation/appleapplica tions/reference/safaricssref/articles/standardcssproperties.html
1361 if (!highlightColor.alpha()) 1353 if (!highlightColor.alpha())
1362 continue; 1354 continue;
1363 1355
1364 m_linkHighlights.append(LinkHighlight::create(node, this)); 1356 m_linkHighlights.append(LinkHighlight::create(node, this));
1365 } 1357 }
1366 } 1358 }
1367 1359
1368 void WebViewImpl::animateDoubleTapZoom(const IntPoint& point) 1360 void WebViewImpl::animateDoubleTapZoom(const IntPoint& pointInRootFrame)
1369 { 1361 {
1370 if (!mainFrameImpl()) 1362 if (!mainFrameImpl())
1371 return; 1363 return;
1372 1364
1373 WebRect blockBounds = computeBlockBound(point, false); 1365 WebRect blockBounds = computeBlockBound(pointInRootFrame, false);
1374 float scale; 1366 float scale;
1375 WebPoint scroll; 1367 WebPoint scroll;
1376 1368
1377 computeScaleAndScrollForBlockRect(point, blockBounds, touchPointPadding, min imumPageScaleFactor() * doubleTapZoomAlreadyLegibleRatio, scale, scroll); 1369 computeScaleAndScrollForBlockRect(pointInRootFrame, blockBounds, touchPointP adding, minimumPageScaleFactor() * doubleTapZoomAlreadyLegibleRatio, scale, scro ll);
1378 1370
1379 bool stillAtPreviousDoubleTapScale = (pageScaleFactor() == m_doubleTapZoomPa geScaleFactor 1371 bool stillAtPreviousDoubleTapScale = (pageScaleFactor() == m_doubleTapZoomPa geScaleFactor
1380 && m_doubleTapZoomPageScaleFactor != minimumPageScaleFactor()) 1372 && m_doubleTapZoomPageScaleFactor != minimumPageScaleFactor())
1381 || m_doubleTapZoomPending; 1373 || m_doubleTapZoomPending;
1382 1374
1383 bool scaleUnchanged = fabs(pageScaleFactor() - scale) < minScaleDifference; 1375 bool scaleUnchanged = fabs(pageScaleFactor() - scale) < minScaleDifference;
1384 bool shouldZoomOut = blockBounds.isEmpty() || scaleUnchanged || stillAtPrevi ousDoubleTapScale; 1376 bool shouldZoomOut = blockBounds.isEmpty() || scaleUnchanged || stillAtPrevi ousDoubleTapScale;
1385 1377
1386 bool isAnimating; 1378 bool isAnimating;
1387 1379
1388 if (shouldZoomOut) { 1380 if (shouldZoomOut) {
1389 scale = minimumPageScaleFactor(); 1381 scale = minimumPageScaleFactor();
1390 isAnimating = startPageScaleAnimation(mainFrameImpl()->frameView()->wind owToContents(point), true, scale, doubleTapZoomAnimationDurationInSeconds); 1382 isAnimating = startPageScaleAnimation(mainFrameImpl()->frameView()->root FrameToContents(pointInRootFrame), true, scale, doubleTapZoomAnimationDurationIn Seconds);
1391 } else { 1383 } else {
1392 isAnimating = startPageScaleAnimation(scroll, false, scale, doubleTapZoo mAnimationDurationInSeconds); 1384 isAnimating = startPageScaleAnimation(scroll, false, scale, doubleTapZoo mAnimationDurationInSeconds);
1393 } 1385 }
1394 1386
1395 if (isAnimating) { 1387 if (isAnimating) {
1396 m_doubleTapZoomPageScaleFactor = scale; 1388 m_doubleTapZoomPageScaleFactor = scale;
1397 m_doubleTapZoomPending = true; 1389 m_doubleTapZoomPending = true;
1398 } 1390 }
1399 } 1391 }
1400 1392
1401 void WebViewImpl::zoomToFindInPageRect(const WebRect& rect) 1393 void WebViewImpl::zoomToFindInPageRect(const WebRect& rectInRootFrame)
1402 { 1394 {
1403 if (!mainFrameImpl()) 1395 if (!mainFrameImpl())
1404 return; 1396 return;
1405 1397
1406 WebRect blockBounds = computeBlockBound(WebPoint(rect.x + rect.width / 2, re ct.y + rect.height / 2), true); 1398 WebRect blockBounds = computeBlockBound(WebPoint(rectInRootFrame.x + rectInR ootFrame.width / 2, rectInRootFrame.y + rectInRootFrame.height / 2), true);
1407 1399
1408 if (blockBounds.isEmpty()) { 1400 if (blockBounds.isEmpty()) {
1409 // Keep current scale (no need to scroll as x,y will normally already 1401 // Keep current scale (no need to scroll as x,y will normally already
1410 // be visible). FIXME: Revisit this if it isn't always true. 1402 // be visible). FIXME: Revisit this if it isn't always true.
1411 return; 1403 return;
1412 } 1404 }
1413 1405
1414 float scale; 1406 float scale;
1415 WebPoint scroll; 1407 WebPoint scroll;
1416 1408
1417 computeScaleAndScrollForBlockRect(WebPoint(rect.x, rect.y), blockBounds, non UserInitiatedPointPadding, minimumPageScaleFactor(), scale, scroll); 1409 computeScaleAndScrollForBlockRect(WebPoint(rectInRootFrame.x, rectInRootFram e.y), blockBounds, nonUserInitiatedPointPadding, minimumPageScaleFactor(), scale , scroll);
1418 1410
1419 startPageScaleAnimation(scroll, false, scale, findInPageAnimationDurationInS econds); 1411 startPageScaleAnimation(scroll, false, scale, findInPageAnimationDurationInS econds);
1420 } 1412 }
1421 1413
1422 bool WebViewImpl::zoomToMultipleTargetsRect(const WebRect& rect) 1414 bool WebViewImpl::zoomToMultipleTargetsRect(const WebRect& rectInRootFrame)
1423 { 1415 {
1424 if (!mainFrameImpl()) 1416 if (!mainFrameImpl())
1425 return false; 1417 return false;
1426 1418
1427 float scale; 1419 float scale;
1428 WebPoint scroll; 1420 WebPoint scroll;
1429 1421
1430 computeScaleAndScrollForBlockRect(WebPoint(rect.x, rect.y), rect, nonUserIni tiatedPointPadding, minimumPageScaleFactor(), scale, scroll); 1422 computeScaleAndScrollForBlockRect(WebPoint(rectInRootFrame.x, rectInRootFram e.y), rectInRootFrame, nonUserInitiatedPointPadding, minimumPageScaleFactor(), s cale, scroll);
1431 1423
1432 if (scale <= pageScaleFactor()) 1424 if (scale <= pageScaleFactor())
1433 return false; 1425 return false;
1434 1426
1435 startPageScaleAnimation(scroll, false, scale, multipleTargetsZoomAnimationDu rationInSeconds); 1427 startPageScaleAnimation(scroll, false, scale, multipleTargetsZoomAnimationDu rationInSeconds);
1436 return true; 1428 return true;
1437 } 1429 }
1438 1430
1439 void WebViewImpl::hasTouchEventHandlers(bool hasTouchHandlers) 1431 void WebViewImpl::hasTouchEventHandlers(bool hasTouchHandlers)
1440 { 1432 {
(...skipping 1131 matching lines...) Expand 10 before | Expand all | Expand 10 after
2572 anchor = localFrame->editor().firstRectForRange(range.get()); 2564 anchor = localFrame->editor().firstRectForRange(range.get());
2573 2565
2574 range = Range::create(selectedRange->endContainer()->document(), 2566 range = Range::create(selectedRange->endContainer()->document(),
2575 selectedRange->endContainer(), 2567 selectedRange->endContainer(),
2576 selectedRange->endOffset(), 2568 selectedRange->endOffset(),
2577 selectedRange->endContainer(), 2569 selectedRange->endContainer(),
2578 selectedRange->endOffset()); 2570 selectedRange->endOffset());
2579 focus = localFrame->editor().firstRectForRange(range.get()); 2571 focus = localFrame->editor().firstRectForRange(range.get());
2580 } 2572 }
2581 2573
2582 IntRect scaledAnchor(localFrame->view()->contentsToWindow(anchor)); 2574 anchor = localFrame->view()->contentsToViewport(anchor);
2583 IntRect scaledFocus(localFrame->view()->contentsToWindow(focus)); 2575 focus = localFrame->view()->contentsToViewport(focus);
2584
2585 if (pinchVirtualViewportEnabled()) {
2586 // FIXME(http://crbug.com/371902) - We shouldn't have to do this
2587 // manually, the contentsToWindow methods above should be fixed to do
2588 // this.
2589 IntPoint pinchViewportOffset =
2590 roundedIntPoint(page()->frameHost().pinchViewport().visibleRect().lo cation());
2591 scaledAnchor.moveBy(-pinchViewportOffset);
2592 scaledFocus.moveBy(-pinchViewportOffset);
2593 }
2594
2595 scaledAnchor.scale(pageScaleFactor());
2596 scaledFocus.scale(pageScaleFactor());
2597 anchor = scaledAnchor;
2598 focus = scaledFocus;
2599 2576
2600 if (!selection.selection().isBaseFirst()) 2577 if (!selection.selection().isBaseFirst())
2601 std::swap(anchor, focus); 2578 std::swap(anchor, focus);
2602 return true; 2579 return true;
2603 } 2580 }
2604 2581
2605 InputMethodContext* WebViewImpl::inputMethodContext() 2582 InputMethodContext* WebViewImpl::inputMethodContext()
2606 { 2583 {
2607 if (!m_imeAcceptEvents) 2584 if (!m_imeAcceptEvents)
2608 return 0; 2585 return 0;
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
2914 return false; 2891 return false;
2915 2892
2916 if (!m_webSettings->autoZoomFocusedNodeToLegibleScale()) { 2893 if (!m_webSettings->autoZoomFocusedNodeToLegibleScale()) {
2917 PinchViewport& pinchViewport = page()->frameHost().pinchViewport(); 2894 PinchViewport& pinchViewport = page()->frameHost().pinchViewport();
2918 2895
2919 // FIXME: The pixel snapping shouldn't be done ad-hoc. crbug.com/458579. 2896 // FIXME: The pixel snapping shouldn't be done ad-hoc. crbug.com/458579.
2920 IntRect viewportRectInRootFrame( 2897 IntRect viewportRectInRootFrame(
2921 ceiledIntPoint(pinchViewport.location()), 2898 ceiledIntPoint(pinchViewport.location()),
2922 expandedIntSize(pinchViewport.visibleSize())); 2899 expandedIntSize(pinchViewport.visibleSize()));
2923 2900
2924 // FIXME: Use viewportToRootFrame when coordinate refactoring CL lands. 2901 FloatRect targetRectInRootFrame = pinchViewport.viewportToRootFrame(rect InViewport);
2925 FloatRect targetRectInRootFrame(
2926 rectInViewport.x,
2927 rectInViewport.y,
2928 rectInViewport.width,
2929 rectInViewport.height);
2930 targetRectInRootFrame.scale(1 / pinchViewport.scale());
2931 targetRectInRootFrame.moveBy(viewportRectInRootFrame.location());
2932
2933 DoubleSize remainder = frame->view()->scrollElementToRect(element, IntRe ct(targetRectInRootFrame)); 2902 DoubleSize remainder = frame->view()->scrollElementToRect(element, IntRe ct(targetRectInRootFrame));
2934 2903
2935 // Scroll the remainder in the pinch viewport. 2904 // Scroll the remainder in the pinch viewport.
2936 page()->frameHost().pinchViewport().move(FloatPoint(remainder.width(), r emainder.height())); 2905 page()->frameHost().pinchViewport().move(FloatPoint(remainder.width(), r emainder.height()));
2937 return false; 2906 return false;
2938 } 2907 }
2939 2908
2940 float scale; 2909 float scale;
2941 IntPoint scroll; 2910 IntPoint scroll;
2942 bool needAnimation; 2911 bool needAnimation;
2943 computeScaleAndScrollForFocusedNode(element, scale, scroll, needAnimation); 2912 computeScaleAndScrollForFocusedNode(element, scale, scroll, needAnimation);
2944 if (needAnimation) 2913 if (needAnimation)
2945 return startPageScaleAnimation(scroll, false, scale, scrollAndScaleAnima tionDurationInSeconds); 2914 return startPageScaleAnimation(scroll, false, scale, scrollAndScaleAnima tionDurationInSeconds);
2946 2915
2947 return false; 2916 return false;
2948 } 2917 }
2949 2918
2950 void WebViewImpl::computeScaleAndScrollForFocusedNode(Node* focusedNode, float& newScale, IntPoint& newScroll, bool& needAnimation) 2919 void WebViewImpl::computeScaleAndScrollForFocusedNode(Node* focusedNode, float& newScale, IntPoint& newScroll, bool& needAnimation)
2951 { 2920 {
2952 focusedNode->document().updateLayoutIgnorePendingStylesheets(); 2921 focusedNode->document().updateLayoutIgnorePendingStylesheets();
2953 2922
2954 // 'caret' is rect encompassing the blinking cursor. 2923 // 'caret' is rect encompassing the blinking cursor.
2955 IntRect textboxRect = focusedNode->document().view()->contentsToWindow(pixel SnappedIntRect(focusedNode->Node::boundingBox())); 2924 IntRect textboxRectInRootFrame = focusedNode->document().view()->contentsToR ootFrame(pixelSnappedIntRect(focusedNode->Node::boundingBox()));
2956 WebRect caret, unusedEnd; 2925 WebRect caret, unusedEnd;
2957 selectionBounds(caret, unusedEnd); 2926 selectionBounds(caret, unusedEnd);
2958 IntRect unscaledCaret = caret; 2927 IntRect unscaledCaret = caret;
2959 unscaledCaret.scale(1 / pageScaleFactor()); 2928 unscaledCaret.scale(1 / pageScaleFactor());
2960 caret = unscaledCaret; 2929 caret = unscaledCaret;
2961 2930
2962 if (shouldDisableDesktopWorkarounds()) { 2931 if (shouldDisableDesktopWorkarounds()) {
2963 newScale = pageScaleFactor(); 2932 newScale = pageScaleFactor();
2964 } else { 2933 } else {
2965 // Pick a scale which is reasonably readable. This is the scale at which 2934 // Pick a scale which is reasonably readable. This is the scale at which
2966 // the caret height will become minReadableCaretHeightForNode (adjusted 2935 // the caret height will become minReadableCaretHeightForNode (adjusted
2967 // for dpi and font scale factor). 2936 // for dpi and font scale factor).
2968 const int minReadableCaretHeightForNode = textboxRect.height() >= 2 * ca ret.height ? minReadableCaretHeightForTextArea : minReadableCaretHeight; 2937 const int minReadableCaretHeightForNode = textboxRectInRootFrame.height( ) >= 2 * caret.height ? minReadableCaretHeightForTextArea : minReadableCaretHeig ht;
2969 newScale = clampPageScaleFactorToLimits(maximumLegiblePageScale() * minR eadableCaretHeightForNode / caret.height); 2938 newScale = clampPageScaleFactorToLimits(maximumLegiblePageScale() * minR eadableCaretHeightForNode / caret.height);
2970 newScale = std::max(newScale, pageScaleFactor()); 2939 newScale = std::max(newScale, pageScaleFactor());
2971 } 2940 }
2972 const float deltaScale = newScale / pageScaleFactor(); 2941 const float deltaScale = newScale / pageScaleFactor();
2973 2942
2974 needAnimation = false; 2943 needAnimation = false;
2975 // If we are at less than the target zoom level, zoom in. 2944 // If we are at less than the target zoom level, zoom in.
2976 if (deltaScale > minScaleChangeToTriggerZoom) 2945 if (deltaScale > minScaleChangeToTriggerZoom)
2977 needAnimation = true; 2946 needAnimation = true;
2978 else 2947 else
2979 newScale = pageScaleFactor(); 2948 newScale = pageScaleFactor();
2980 2949
2981 // Convert the rects to absolute space in the new scale. 2950 // Convert the rects to absolute space in the new scale.
2982 IntRect textboxRectInDocumentCoordinates = textboxRect; 2951 IntRect textboxRectInDocumentCoordinates = mainFrameImpl()->frameView()->fra meToContents(textboxRectInRootFrame);
2983 textboxRectInDocumentCoordinates.move(mainFrame()->scrollOffset());
2984 IntRect caretInDocumentCoordinates = caret; 2952 IntRect caretInDocumentCoordinates = caret;
2985 caretInDocumentCoordinates.move(mainFrame()->scrollOffset()); 2953 caretInDocumentCoordinates.move(mainFrame()->scrollOffset());
2986 2954
2987 int viewWidth = m_size.width / newScale; 2955 int viewWidth = m_size.width / newScale;
2988 int viewHeight = m_size.height / newScale; 2956 int viewHeight = m_size.height / newScale;
2989 2957
2990 // If the caret is offscreen, then animate. 2958 // If the caret is offscreen, then animate.
2991 IntRect sizeRect(0, 0, viewWidth, viewHeight); 2959 IntRect sizeRect(0, 0, viewWidth, viewHeight);
2992 sizeRect.scale(newScale / pageScaleFactor()); 2960 sizeRect.scale(newScale / pageScaleFactor());
2993 if (!sizeRect.contains(caret)) 2961 if (!sizeRect.contains(caret))
2994 needAnimation = true; 2962 needAnimation = true;
2995 2963
2996 // If the box is partially offscreen and it's possible to bring it fully 2964 // If the box is partially offscreen and it's possible to bring it fully
2997 // onscreen, then animate. 2965 // onscreen, then animate.
2998 if (sizeRect.contains(textboxRectInDocumentCoordinates.width(), textboxRectI nDocumentCoordinates.height()) && !sizeRect.contains(textboxRect)) 2966 if (sizeRect.contains(textboxRectInDocumentCoordinates.width(), textboxRectI nDocumentCoordinates.height()) && !sizeRect.contains(textboxRectInRootFrame))
2999 needAnimation = true; 2967 needAnimation = true;
3000 2968
3001 if (!needAnimation) 2969 if (!needAnimation)
3002 return; 2970 return;
3003 2971
3004 if (textboxRectInDocumentCoordinates.width() <= viewWidth) { 2972 if (textboxRectInDocumentCoordinates.width() <= viewWidth) {
3005 // Field is narrower than screen. Try to leave padding on left so field' s 2973 // Field is narrower than screen. Try to leave padding on left so field' s
3006 // label is visible, but it's more important to ensure entire field is 2974 // label is visible, but it's more important to ensure entire field is
3007 // onscreen. 2975 // onscreen.
3008 int idealLeftPadding = viewWidth * leftBoxRatio; 2976 int idealLeftPadding = viewWidth * leftBoxRatio;
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
3525 m_pageScaleConstraintsSet.setNeedsReset(true); 3493 m_pageScaleConstraintsSet.setNeedsReset(true);
3526 3494
3527 // Clobber saved scales and scroll offsets. 3495 // Clobber saved scales and scroll offsets.
3528 if (FrameView* view = page()->deprecatedLocalMainFrame()->document()->view() ) 3496 if (FrameView* view = page()->deprecatedLocalMainFrame()->document()->view() )
3529 view->cacheCurrentScrollPosition(); 3497 view->cacheCurrentScrollPosition();
3530 } 3498 }
3531 3499
3532 void WebViewImpl::performMediaPlayerAction(const WebMediaPlayerAction& action, 3500 void WebViewImpl::performMediaPlayerAction(const WebMediaPlayerAction& action,
3533 const WebPoint& location) 3501 const WebPoint& location)
3534 { 3502 {
3535 HitTestResult result = hitTestResultForWindowPos(location); 3503 // FIXME: location is probably in viewport coordinates.
3504 HitTestResult result = hitTestResultForRootFramePos(location);
3536 RefPtrWillBeRawPtr<Node> node = result.innerNonSharedNode(); 3505 RefPtrWillBeRawPtr<Node> node = result.innerNonSharedNode();
3537 if (!isHTMLVideoElement(*node) && !isHTMLAudioElement(*node)) 3506 if (!isHTMLVideoElement(*node) && !isHTMLAudioElement(*node))
3538 return; 3507 return;
3539 3508
3540 RefPtrWillBeRawPtr<HTMLMediaElement> mediaElement = static_pointer_cast<HTML MediaElement>(node); 3509 RefPtrWillBeRawPtr<HTMLMediaElement> mediaElement = static_pointer_cast<HTML MediaElement>(node);
3541 switch (action.type) { 3510 switch (action.type) {
3542 case WebMediaPlayerAction::Play: 3511 case WebMediaPlayerAction::Play:
3543 if (action.enable) 3512 if (action.enable)
3544 mediaElement->play(); 3513 mediaElement->play();
3545 else 3514 else
3546 mediaElement->pause(); 3515 mediaElement->pause();
3547 break; 3516 break;
3548 case WebMediaPlayerAction::Mute: 3517 case WebMediaPlayerAction::Mute:
3549 mediaElement->setMuted(action.enable); 3518 mediaElement->setMuted(action.enable);
3550 break; 3519 break;
3551 case WebMediaPlayerAction::Loop: 3520 case WebMediaPlayerAction::Loop:
3552 mediaElement->setLoop(action.enable); 3521 mediaElement->setLoop(action.enable);
3553 break; 3522 break;
3554 case WebMediaPlayerAction::Controls: 3523 case WebMediaPlayerAction::Controls:
3555 mediaElement->setBooleanAttribute(HTMLNames::controlsAttr, action.enable ); 3524 mediaElement->setBooleanAttribute(HTMLNames::controlsAttr, action.enable );
3556 break; 3525 break;
3557 default: 3526 default:
3558 ASSERT_NOT_REACHED(); 3527 ASSERT_NOT_REACHED();
3559 } 3528 }
3560 } 3529 }
3561 3530
3562 void WebViewImpl::performPluginAction(const WebPluginAction& action, 3531 void WebViewImpl::performPluginAction(const WebPluginAction& action,
3563 const WebPoint& location) 3532 const WebPoint& location)
3564 { 3533 {
3565 HitTestResult result = hitTestResultForWindowPos(location); 3534 // FIXME: Location is probably in viewport coordinates
3535 HitTestResult result = hitTestResultForRootFramePos(location);
3566 RefPtrWillBeRawPtr<Node> node = result.innerNonSharedNode(); 3536 RefPtrWillBeRawPtr<Node> node = result.innerNonSharedNode();
3567 if (!isHTMLObjectElement(*node) && !isHTMLEmbedElement(*node)) 3537 if (!isHTMLObjectElement(*node) && !isHTMLEmbedElement(*node))
3568 return; 3538 return;
3569 3539
3570 LayoutObject* object = node->renderer(); 3540 LayoutObject* object = node->renderer();
3571 if (object && object->isLayoutPart()) { 3541 if (object && object->isLayoutPart()) {
3572 Widget* widget = toLayoutPart(object)->widget(); 3542 Widget* widget = toLayoutPart(object)->widget();
3573 if (widget && widget->isPluginContainer()) { 3543 if (widget && widget->isPluginContainer()) {
3574 WebPluginContainerImpl* plugin = toWebPluginContainerImpl(widget); 3544 WebPluginContainerImpl* plugin = toWebPluginContainerImpl(widget);
3575 switch (action.type) { 3545 switch (action.type) {
3576 case WebPluginAction::Rotate90Clockwise: 3546 case WebPluginAction::Rotate90Clockwise:
3577 plugin->plugin()->rotateView(WebPlugin::RotationType90Clockwise) ; 3547 plugin->plugin()->rotateView(WebPlugin::RotationType90Clockwise) ;
3578 break; 3548 break;
3579 case WebPluginAction::Rotate90Counterclockwise: 3549 case WebPluginAction::Rotate90Counterclockwise:
3580 plugin->plugin()->rotateView(WebPlugin::RotationType90Counterclo ckwise); 3550 plugin->plugin()->rotateView(WebPlugin::RotationType90Counterclo ckwise);
3581 break; 3551 break;
3582 default: 3552 default:
3583 ASSERT_NOT_REACHED(); 3553 ASSERT_NOT_REACHED();
3584 } 3554 }
3585 } 3555 }
3586 } 3556 }
3587 } 3557 }
3588 3558
3589 WebHitTestResult WebViewImpl::hitTestResultAt(const WebPoint& point) 3559 WebHitTestResult WebViewImpl::hitTestResultAt(const WebPoint& point)
3590 { 3560 {
3591 return coreHitTestResultAt(point); 3561 return coreHitTestResultAt(point);
3592 } 3562 }
3593 3563
3594 HitTestResult WebViewImpl::coreHitTestResultAt(const WebPoint& point) 3564 HitTestResult WebViewImpl::coreHitTestResultAt(const WebPoint& pointInViewport)
3595 { 3565 {
3596 FloatPoint scaledPoint(point.x, point.y); 3566 FrameView* view = mainFrameImpl()->frameView();
3597 scaledPoint.scale(1 / pageScaleFactor(), 1 / pageScaleFactor()); 3567 IntPoint pointInRootFrame = view->contentsToFrame(view->viewportToContents(p ointInViewport));
3598 scaledPoint.moveBy(pinchViewportOffset()); 3568 return hitTestResultForRootFramePos(pointInRootFrame);
3599 return hitTestResultForWindowPos(flooredIntPoint(scaledPoint));
3600 } 3569 }
3601 3570
3602 void WebViewImpl::copyImageAt(const WebPoint& point) 3571 void WebViewImpl::copyImageAt(const WebPoint& point)
3603 { 3572 {
3604 if (!m_page) 3573 if (!m_page)
3605 return; 3574 return;
3606 3575
3607 HitTestResult result = hitTestResultForWindowPos(point); 3576 // FIXME: point is probably in viewport coordinates.
3577 HitTestResult result = hitTestResultForRootFramePos(point);
3608 if (!isHTMLCanvasElement(result.innerNonSharedNode()) && result.absoluteImag eURL().isEmpty()) { 3578 if (!isHTMLCanvasElement(result.innerNonSharedNode()) && result.absoluteImag eURL().isEmpty()) {
3609 // There isn't actually an image at these coordinates. Might be because 3579 // There isn't actually an image at these coordinates. Might be because
3610 // the window scrolled while the context menu was open or because the pa ge 3580 // the window scrolled while the context menu was open or because the pa ge
3611 // changed itself between when we thought there was an image here and wh en 3581 // changed itself between when we thought there was an image here and wh en
3612 // we actually tried to retreive the image. 3582 // we actually tried to retreive the image.
3613 // 3583 //
3614 // FIXME: implement a cache of the most recent HitTestResult to avoid ha ving 3584 // FIXME: implement a cache of the most recent HitTestResult to avoid ha ving
3615 // to do two hit tests. 3585 // to do two hit tests.
3616 return; 3586 return;
3617 } 3587 }
3618 3588
3619 m_page->deprecatedLocalMainFrame()->editor().copyImage(result); 3589 m_page->deprecatedLocalMainFrame()->editor().copyImage(result);
3620 } 3590 }
3621 3591
3622 void WebViewImpl::saveImageAt(const WebPoint& point) 3592 void WebViewImpl::saveImageAt(const WebPoint& point)
3623 { 3593 {
3624 if (!m_client) 3594 if (!m_client)
3625 return; 3595 return;
3626 3596
3627 Node* node = hitTestResultForWindowPos(point).innerNonSharedNode(); 3597 // FIXME: point is probably in viewport coordinates.
3598 Node* node = hitTestResultForRootFramePos(point).innerNonSharedNode();
3628 if (!node || !(isHTMLCanvasElement(*node) || isHTMLImageElement(*node))) 3599 if (!node || !(isHTMLCanvasElement(*node) || isHTMLImageElement(*node)))
3629 return; 3600 return;
3630 3601
3631 String url = toElement(*node).imageSourceURL(); 3602 String url = toElement(*node).imageSourceURL();
3632 if (!KURL(KURL(), url).protocolIsData()) 3603 if (!KURL(KURL(), url).protocolIsData())
3633 return; 3604 return;
3634 3605
3635 m_client->saveImageFromDataURL(url); 3606 m_client->saveImageFromDataURL(url);
3636 } 3607 }
3637 3608
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
3818 mainFrameImpl()->frame()->view()->enableAutoSizeMode(m_minAutoSize, m_ma xAutoSize); 3789 mainFrameImpl()->frame()->view()->enableAutoSizeMode(m_minAutoSize, m_ma xAutoSize);
3819 else 3790 else
3820 mainFrameImpl()->frame()->view()->disableAutoSizeMode(); 3791 mainFrameImpl()->frame()->view()->disableAutoSizeMode();
3821 } 3792 }
3822 3793
3823 unsigned long WebViewImpl::createUniqueIdentifierForRequest() 3794 unsigned long WebViewImpl::createUniqueIdentifierForRequest()
3824 { 3795 {
3825 return createUniqueIdentifier(); 3796 return createUniqueIdentifier();
3826 } 3797 }
3827 3798
3828 void WebViewImpl::inspectElementAt(const WebPoint& point) 3799 void WebViewImpl::inspectElementAt(const WebPoint& pointInRootFrame)
3829 { 3800 {
3830 if (!m_page) 3801 if (!m_page)
3831 return; 3802 return;
3832 3803
3833 if (point.x == -1 || point.y == -1) { 3804 if (pointInRootFrame.x == -1 || pointInRootFrame.y == -1) {
3834 m_page->inspectorController().inspect(0); 3805 m_page->inspectorController().inspect(0);
3835 } else { 3806 } else {
3836 HitTestRequest::HitTestRequestType hitType = HitTestRequest::Move | HitT estRequest::ReadOnly | HitTestRequest::AllowChildFrameContent; 3807 HitTestRequest::HitTestRequestType hitType = HitTestRequest::Move | HitT estRequest::ReadOnly | HitTestRequest::AllowChildFrameContent;
3837 HitTestRequest request(hitType); 3808 HitTestRequest request(hitType);
3838 3809
3839 WebMouseEvent dummyEvent; 3810 WebMouseEvent dummyEvent;
3840 dummyEvent.type = WebInputEvent::MouseDown; 3811 dummyEvent.type = WebInputEvent::MouseDown;
3841 dummyEvent.x = point.x; 3812 dummyEvent.x = pointInRootFrame.x;
3842 dummyEvent.y = point.y; 3813 dummyEvent.y = pointInRootFrame.y;
3843 IntPoint transformedPoint = PlatformMouseEventBuilder(m_page->deprecated LocalMainFrame()->view(), dummyEvent).position(); 3814 IntPoint transformedPoint = PlatformMouseEventBuilder(m_page->deprecated LocalMainFrame()->view(), dummyEvent).position();
3844 HitTestResult result(m_page->deprecatedLocalMainFrame()->view()->windowT oContents(transformedPoint)); 3815 HitTestResult result(m_page->deprecatedLocalMainFrame()->view()->rootFra meToContents(transformedPoint));
3845 m_page->deprecatedLocalMainFrame()->contentRenderer()->hitTest(request, result); 3816 m_page->deprecatedLocalMainFrame()->contentRenderer()->hitTest(request, result);
3846 Node* node = result.innerNode(); 3817 Node* node = result.innerNode();
3847 if (!node && m_page->deprecatedLocalMainFrame()->document()) 3818 if (!node && m_page->deprecatedLocalMainFrame()->document())
3848 node = m_page->deprecatedLocalMainFrame()->document()->documentEleme nt(); 3819 node = m_page->deprecatedLocalMainFrame()->document()->documentEleme nt();
3849 m_page->inspectorController().inspect(node); 3820 m_page->inspectorController().inspect(node);
3850 } 3821 }
3851 } 3822 }
3852 3823
3853 void WebViewImpl::setCompositorDeviceScaleFactorOverride(float deviceScaleFactor ) 3824 void WebViewImpl::setCompositorDeviceScaleFactorOverride(float deviceScaleFactor )
3854 { 3825 {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
3902 if (!page()) 3873 if (!page())
3903 return; 3874 return;
3904 3875
3905 page()->contextMenuController().clearContextMenu(); 3876 page()->contextMenuController().clearContextMenu();
3906 m_contextMenuAllowed = true; 3877 m_contextMenuAllowed = true;
3907 if (LocalFrame* focusedFrame = toLocalFrame(page()->focusController().focuse dOrMainFrame())) 3878 if (LocalFrame* focusedFrame = toLocalFrame(page()->focusController().focuse dOrMainFrame()))
3908 focusedFrame->eventHandler().sendContextMenuEventForKey(); 3879 focusedFrame->eventHandler().sendContextMenuEventForKey();
3909 m_contextMenuAllowed = false; 3880 m_contextMenuAllowed = false;
3910 } 3881 }
3911 3882
3912 void WebViewImpl::extractSmartClipData(WebRect rect, WebString& clipText, WebStr ing& clipHtml, WebRect& clipRect) 3883 void WebViewImpl::extractSmartClipData(WebRect rectInViewport, WebString& clipTe xt, WebString& clipHtml, WebRect& clipRectInViewport)
3913 { 3884 {
3914 LocalFrame* localFrame = toLocalFrame(focusedCoreFrame()); 3885 LocalFrame* localFrame = toLocalFrame(focusedCoreFrame());
3915 if (!localFrame) 3886 if (!localFrame)
3916 return; 3887 return;
3917 SmartClipData clipData = SmartClip(localFrame).dataForRect(rect); 3888 SmartClipData clipData = SmartClip(localFrame).dataForRect(rectInViewport);
3918 clipText = clipData.clipData(); 3889 clipText = clipData.clipData();
3919 clipRect = clipData.rect(); 3890 clipRectInViewport = clipData.rectInViewport();
3920 3891
3921 WebLocalFrameImpl* frame = mainFrameImpl(); 3892 WebLocalFrameImpl* frame = mainFrameImpl();
3922 if (!frame) 3893 if (!frame)
3923 return; 3894 return;
3924 WebPoint startPoint(rect.x, rect.y); 3895 WebPoint startPoint(rectInViewport.x, rectInViewport.y);
3925 WebPoint endPoint(rect.x + rect.width, rect.y + rect.height); 3896 WebPoint endPoint(rectInViewport.x + rectInViewport.width, rectInViewport.y + rectInViewport.height);
3926 VisiblePosition startVisiblePosition = frame->visiblePositionForWindowPoint( startPoint); 3897 VisiblePosition startVisiblePosition = frame->visiblePositionForViewportPoin t(startPoint);
3927 VisiblePosition endVisiblePosition = frame->visiblePositionForWindowPoint(en dPoint); 3898 VisiblePosition endVisiblePosition = frame->visiblePositionForViewportPoint( endPoint);
3928 3899
3929 Position startPosition = startVisiblePosition.deepEquivalent(); 3900 Position startPosition = startVisiblePosition.deepEquivalent();
3930 Position endPosition = endVisiblePosition.deepEquivalent(); 3901 Position endPosition = endVisiblePosition.deepEquivalent();
3931 3902
3932 // document() will return null if -webkit-user-select is set to none. 3903 // document() will return null if -webkit-user-select is set to none.
3933 if (!startPosition.document() || !endPosition.document()) 3904 if (!startPosition.document() || !endPosition.document())
3934 return; 3905 return;
3935 3906
3936 RefPtrWillBeRawPtr<Range> range = Range::create(*startPosition.document(), s tartPosition, endPosition); 3907 RefPtrWillBeRawPtr<Range> range = Range::create(*startPosition.document(), s tartPosition, endPosition);
3937 if (!range) 3908 if (!range)
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
4224 if (!frame || !frame->isLocalFrame()) 4195 if (!frame || !frame->isLocalFrame())
4225 return 0; 4196 return 0;
4226 4197
4227 Document* document = toLocalFrame(frame)->document(); 4198 Document* document = toLocalFrame(frame)->document();
4228 if (!document) 4199 if (!document)
4229 return 0; 4200 return 0;
4230 4201
4231 return document->focusedElement(); 4202 return document->focusedElement();
4232 } 4203 }
4233 4204
4234 HitTestResult WebViewImpl::hitTestResultForWindowPos(const IntPoint& pos) 4205 HitTestResult WebViewImpl::hitTestResultForRootFramePos(const IntPoint& pos)
4235 { 4206 {
4236 if (!m_page->mainFrame()->isLocalFrame()) 4207 if (!m_page->mainFrame()->isLocalFrame())
4237 return HitTestResult(); 4208 return HitTestResult();
4238 IntPoint docPoint(m_page->deprecatedLocalMainFrame()->view()->windowToConten ts(pos)); 4209 IntPoint docPoint(m_page->deprecatedLocalMainFrame()->view()->rootFrameToCon tents(pos));
4239 HitTestResult result = m_page->deprecatedLocalMainFrame()->eventHandler().hi tTestResultAtPoint(docPoint, HitTestRequest::ReadOnly | HitTestRequest::Active); 4210 HitTestResult result = m_page->deprecatedLocalMainFrame()->eventHandler().hi tTestResultAtPoint(docPoint, HitTestRequest::ReadOnly | HitTestRequest::Active);
4240 result.setToShadowHostIfInClosedShadowRoot(); 4211 result.setToShadowHostIfInClosedShadowRoot();
4241 return result; 4212 return result;
4242 } 4213 }
4243 4214
4244 WebHitTestResult WebViewImpl::hitTestResultForTap(const WebPoint& tapPointWindow Pos, const WebSize& tapArea) 4215 WebHitTestResult WebViewImpl::hitTestResultForTap(const WebPoint& tapPointWindow Pos, const WebSize& tapArea)
4245 { 4216 {
4246 if (!m_page->mainFrame()->isLocalFrame()) 4217 if (!m_page->mainFrame()->isLocalFrame())
4247 return HitTestResult(); 4218 return HitTestResult();
4248 4219
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
4689 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width 4660 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width
4690 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); 4661 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1);
4691 } 4662 }
4692 4663
4693 void WebViewImpl::forceNextWebGLContextCreationToFail() 4664 void WebViewImpl::forceNextWebGLContextCreationToFail()
4694 { 4665 {
4695 WebGLRenderingContext::forceNextWebGLContextCreationToFail(); 4666 WebGLRenderingContext::forceNextWebGLContextCreationToFail();
4696 } 4667 }
4697 4668
4698 } // namespace blink 4669 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698