OLD | NEW |
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 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 ASSERT(!m_pagePopup); | 516 ASSERT(!m_pagePopup); |
517 } | 517 } |
518 | 518 |
519 m_lastMouseDownPoint = WebPoint(event.x, event.y); | 519 m_lastMouseDownPoint = WebPoint(event.x, event.y); |
520 | 520 |
521 // Take capture on a mouse down on a plugin so we can send it mouse events. | 521 // Take capture on a mouse down on a plugin so we can send it mouse events. |
522 // If the hit node is a plugin but a scrollbar is over it don't start mouse | 522 // If the hit node is a plugin but a scrollbar is over it don't start mouse |
523 // capture because it will interfere with the scrollbar receiving events. | 523 // capture because it will interfere with the scrollbar receiving events. |
524 IntPoint point(event.x, event.y); | 524 IntPoint point(event.x, event.y); |
525 if (event.button == WebMouseEvent::ButtonLeft && m_page->mainFrame()->isLoca
lFrame()) { | 525 if (event.button == WebMouseEvent::ButtonLeft && m_page->mainFrame()->isLoca
lFrame()) { |
526 point = m_page->deprecatedLocalMainFrame()->view()->windowToContents(poi
nt); | 526 point = m_page->deprecatedLocalMainFrame()->view()->rootFrameToContents(
point); |
527 HitTestResult result(m_page->deprecatedLocalMainFrame()->eventHandler().
hitTestResultAtPoint(point)); | 527 HitTestResult result(m_page->deprecatedLocalMainFrame()->eventHandler().
hitTestResultAtPoint(point)); |
528 result.setToShadowHostIfInClosedShadowRoot(); | 528 result.setToShadowHostIfInClosedShadowRoot(); |
529 Node* hitNode = result.innerNonSharedNode(); | 529 Node* hitNode = result.innerNonSharedNode(); |
530 | 530 |
531 if (!result.scrollbar() && hitNode && hitNode->layoutObject() && hitNode
->layoutObject()->isEmbeddedObject()) { | 531 if (!result.scrollbar() && hitNode && hitNode->layoutObject() && hitNode
->layoutObject()->isEmbeddedObject()) { |
532 m_mouseCaptureNode = hitNode; | 532 m_mouseCaptureNode = hitNode; |
533 TRACE_EVENT_ASYNC_BEGIN0("input", "capturing mouse", this); | 533 TRACE_EVENT_ASYNC_BEGIN0("input", "capturing mouse", this); |
534 } | 534 } |
535 } | 535 } |
536 | 536 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 void WebViewImpl::mouseContextMenu(const WebMouseEvent& event) | 579 void WebViewImpl::mouseContextMenu(const WebMouseEvent& event) |
580 { | 580 { |
581 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) | 581 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) |
582 return; | 582 return; |
583 | 583 |
584 m_page->contextMenuController().clearContextMenu(); | 584 m_page->contextMenuController().clearContextMenu(); |
585 | 585 |
586 PlatformMouseEventBuilder pme(mainFrameImpl()->frameView(), event); | 586 PlatformMouseEventBuilder pme(mainFrameImpl()->frameView(), event); |
587 | 587 |
588 // Find the right target frame. See issue 1186900. | 588 // Find the right target frame. See issue 1186900. |
589 HitTestResult result = hitTestResultForWindowPos(pme.position()); | 589 HitTestResult result = hitTestResultForRootFramePos(pme.position()); |
590 Frame* targetFrame; | 590 Frame* targetFrame; |
591 if (result.innerNonSharedNode()) | 591 if (result.innerNonSharedNode()) |
592 targetFrame = result.innerNonSharedNode()->document().frame(); | 592 targetFrame = result.innerNonSharedNode()->document().frame(); |
593 else | 593 else |
594 targetFrame = m_page->focusController().focusedOrMainFrame(); | 594 targetFrame = m_page->focusController().focusedOrMainFrame(); |
595 | 595 |
596 if (!targetFrame->isLocalFrame()) | 596 if (!targetFrame->isLocalFrame()) |
597 return; | 597 return; |
598 | 598 |
599 LocalFrame* targetLocalFrame = toLocalFrame(targetFrame); | 599 LocalFrame* targetLocalFrame = toLocalFrame(targetFrame); |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
774 selectPopup = m_selectPopup; | 774 selectPopup = m_selectPopup; |
775 hideSelectPopup(); | 775 hideSelectPopup(); |
776 ASSERT(!m_selectPopup); | 776 ASSERT(!m_selectPopup); |
777 | 777 |
778 // Don't trigger a disambiguation popup on sites designed for mobile dev
ices. | 778 // Don't trigger a disambiguation popup on sites designed for mobile dev
ices. |
779 // Instead, assume that the page has been designed with big enough butto
ns and links. | 779 // Instead, assume that the page has been designed with big enough butto
ns and links. |
780 // Don't trigger a disambiguation popup when screencasting, since it's i
mplemented outside of | 780 // Don't trigger a disambiguation popup when screencasting, since it's i
mplemented outside of |
781 // compositor pipeline and is not being screencasted itself. This leads
to bad user experience. | 781 // compositor pipeline and is not being screencasted itself. This leads
to bad user experience. |
782 bool screencastEnabled = m_devToolsAgent && m_devToolsAgent->screencastE
nabled(); | 782 bool screencastEnabled = m_devToolsAgent && m_devToolsAgent->screencastE
nabled(); |
783 if (event.data.tap.width > 0 && !shouldDisableDesktopWorkarounds() && !s
creencastEnabled) { | 783 if (event.data.tap.width > 0 && !shouldDisableDesktopWorkarounds() && !s
creencastEnabled) { |
784 WebGestureEvent scaledEvent = event; | 784 IntRect boundingBox(page()->frameHost().pinchViewport().viewportToRo
otFrame(IntRect( |
785 scaledEvent.x = event.x / pageScaleFactor(); | 785 event.x - event.data.tap.width / 2, |
786 scaledEvent.y = event.y / pageScaleFactor(); | 786 event.y - event.data.tap.height / 2, |
787 scaledEvent.data.tap.width = event.data.tap.width / pageScaleFactor(
); | 787 event.data.tap.width, |
788 scaledEvent.data.tap.height = event.data.tap.height / pageScaleFacto
r(); | 788 event.data.tap.height))); |
789 IntRect boundingBox( | |
790 scaledEvent.x - scaledEvent.data.tap.width / 2, | |
791 scaledEvent.y - scaledEvent.data.tap.height / 2, | |
792 scaledEvent.data.tap.width, | |
793 scaledEvent.data.tap.height); | |
794 | 789 |
795 WebSize pinchViewportOffset = pinchVirtualViewportEnabled() ? | 790 // FIXME: We shouldn't pass details of the PinchViewport offset to r
ender_view_impl. |
796 flooredIntSize(page()->frameHost().pinchViewport().location()) :
IntSize(); | 791 WebSize pinchViewportOffset = flooredIntSize(page()->frameHost().pin
chViewport().location()); |
797 | |
798 // Keep bounding box relative to the main frame. | |
799 boundingBox.move(pinchViewportOffset); | |
800 | 792 |
801 Vector<IntRect> goodTargets; | 793 Vector<IntRect> goodTargets; |
802 WillBeHeapVector<RawPtrWillBeMember<Node>> highlightNodes; | 794 WillBeHeapVector<RawPtrWillBeMember<Node>> highlightNodes; |
803 findGoodTouchTargets(boundingBox, mainFrameImpl()->frame(), goodTarg
ets, highlightNodes); | 795 findGoodTouchTargets(boundingBox, mainFrameImpl()->frame(), goodTarg
ets, highlightNodes); |
804 // FIXME: replace touch adjustment code when numberOfGoodTargets ==
1? | 796 // FIXME: replace touch adjustment code when numberOfGoodTargets ==
1? |
805 // Single candidate case is currently handled by: https://bugs.webki
t.org/show_bug.cgi?id=85101 | 797 // Single candidate case is currently handled by: https://bugs.webki
t.org/show_bug.cgi?id=85101 |
806 if (goodTargets.size() >= 2 && m_client | 798 if (goodTargets.size() >= 2 && m_client |
807 && m_client->didTapMultipleTargets(pinchViewportOffset, bounding
Box, goodTargets)) { | 799 && m_client->didTapMultipleTargets(pinchViewportOffset, bounding
Box, goodTargets)) { |
808 | 800 |
809 enableTapHighlights(highlightNodes); | 801 enableTapHighlights(highlightNodes); |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1128 // events. | 1120 // events. |
1129 if (evt.isSystemKey()) | 1121 if (evt.isSystemKey()) |
1130 return false; | 1122 return false; |
1131 | 1123 |
1132 if (!suppress && !handler.keyEvent(evt)) | 1124 if (!suppress && !handler.keyEvent(evt)) |
1133 return keyEventDefault(event); | 1125 return keyEventDefault(event); |
1134 | 1126 |
1135 return true; | 1127 return true; |
1136 } | 1128 } |
1137 | 1129 |
1138 WebRect WebViewImpl::computeBlockBound(const WebPoint& webPoint, bool ignoreClip
ping) | 1130 WebRect WebViewImpl::computeBlockBound(const WebPoint& pointInRootFrame, bool ig
noreClipping) |
1139 { | 1131 { |
1140 if (!mainFrameImpl()) | 1132 if (!mainFrameImpl()) |
1141 return WebRect(); | 1133 return WebRect(); |
1142 | 1134 |
1143 // Use the point-based hit test to find the node. | 1135 // Use the point-based hit test to find the node. |
1144 IntPoint point = mainFrameImpl()->frameView()->windowToContents(IntPoint(web
Point.x, webPoint.y)); | 1136 IntPoint point = mainFrameImpl()->frameView()->rootFrameToContents(IntPoint(
pointInRootFrame.x, pointInRootFrame.y)); |
1145 HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitT
estRequest::Active | (ignoreClipping ? HitTestRequest::IgnoreClipping : 0); | 1137 HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitT
estRequest::Active | (ignoreClipping ? HitTestRequest::IgnoreClipping : 0); |
1146 HitTestResult result = mainFrameImpl()->frame()->eventHandler().hitTestResul
tAtPoint(point, hitType); | 1138 HitTestResult result = mainFrameImpl()->frame()->eventHandler().hitTestResul
tAtPoint(point, hitType); |
1147 result.setToShadowHostIfInClosedShadowRoot(); | 1139 result.setToShadowHostIfInClosedShadowRoot(); |
1148 | 1140 |
1149 Node* node = result.innerNonSharedNode(); | 1141 Node* node = result.innerNonSharedNode(); |
1150 if (!node) | 1142 if (!node) |
1151 return WebRect(); | 1143 return WebRect(); |
1152 | 1144 |
1153 // Find the block type node based on the hit node. | 1145 // Find the block type node based on the hit node. |
1154 // FIXME: This wants to walk composed tree with NodeRenderingTraversal::pare
nt(). | 1146 // FIXME: This wants to walk composed tree with NodeRenderingTraversal::pare
nt(). |
1155 while (node && (!node->layoutObject() || node->layoutObject()->isInline())) | 1147 while (node && (!node->layoutObject() || node->layoutObject()->isInline())) |
1156 node = NodeRenderingTraversal::parent(*node); | 1148 node = NodeRenderingTraversal::parent(*node); |
1157 | 1149 |
1158 // Return the bounding box in the window coordinate system. | 1150 // Return the bounding box in the root frame's coordinate space. |
1159 if (node) { | 1151 if (node) { |
1160 IntRect rect = node->Node::pixelSnappedBoundingBox(); | 1152 IntRect pointInRootFrame = node->Node::pixelSnappedBoundingBox(); |
1161 LocalFrame* frame = node->document().frame(); | 1153 LocalFrame* frame = node->document().frame(); |
1162 return frame->view()->contentsToWindow(rect); | 1154 return frame->view()->contentsToRootFrame(pointInRootFrame); |
1163 } | 1155 } |
1164 return WebRect(); | 1156 return WebRect(); |
1165 } | 1157 } |
1166 | 1158 |
1167 WebRect WebViewImpl::widenRectWithinPageBounds(const WebRect& source, int target
Margin, int minimumMargin) | 1159 WebRect WebViewImpl::widenRectWithinPageBounds(const WebRect& source, int target
Margin, int minimumMargin) |
1168 { | 1160 { |
1169 WebSize maxSize; | 1161 WebSize maxSize; |
1170 if (mainFrame()) | 1162 if (mainFrame()) |
1171 maxSize = mainFrame()->contentsSize(); | 1163 maxSize = mainFrame()->contentsSize(); |
1172 IntSize scrollOffset; | 1164 IntSize scrollOffset; |
(...skipping 27 matching lines...) Expand all Loading... |
1200 { | 1192 { |
1201 // Pages should be as legible as on desktop when at dpi scale, so no | 1193 // Pages should be as legible as on desktop when at dpi scale, so no |
1202 // need to zoom in further when automatically determining zoom level | 1194 // need to zoom in further when automatically determining zoom level |
1203 // (after double tap, find in page, etc), though the user should still | 1195 // (after double tap, find in page, etc), though the user should still |
1204 // be allowed to manually pinch zoom in further if they desire. | 1196 // be allowed to manually pinch zoom in further if they desire. |
1205 if (page()) | 1197 if (page()) |
1206 return m_maximumLegibleScale * page()->settings().accessibilityFontScale
Factor(); | 1198 return m_maximumLegibleScale * page()->settings().accessibilityFontScale
Factor(); |
1207 return m_maximumLegibleScale; | 1199 return m_maximumLegibleScale; |
1208 } | 1200 } |
1209 | 1201 |
1210 void WebViewImpl::computeScaleAndScrollForBlockRect(const WebPoint& hitPoint, co
nst WebRect& blockRect, float padding, float defaultScaleWhenAlreadyLegible, flo
at& scale, WebPoint& scroll) | 1202 void WebViewImpl::computeScaleAndScrollForBlockRect(const WebPoint& hitPointInRo
otFrame, const WebRect& blockRectInRootFrame, float padding, float defaultScaleW
henAlreadyLegible, float& scale, WebPoint& scroll) |
1211 { | 1203 { |
1212 scale = pageScaleFactor(); | 1204 scale = pageScaleFactor(); |
1213 scroll.x = scroll.y = 0; | 1205 scroll.x = scroll.y = 0; |
1214 | 1206 |
1215 WebRect rect = blockRect; | 1207 WebRect rect = blockRectInRootFrame; |
1216 | 1208 |
1217 if (!rect.isEmpty()) { | 1209 if (!rect.isEmpty()) { |
1218 float defaultMargin = doubleTapZoomContentDefaultMargin; | 1210 float defaultMargin = doubleTapZoomContentDefaultMargin; |
1219 float minimumMargin = doubleTapZoomContentMinimumMargin; | 1211 float minimumMargin = doubleTapZoomContentMinimumMargin; |
1220 // We want the margins to have the same physical size, which means we | 1212 // We want the margins to have the same physical size, which means we |
1221 // need to express them in post-scale size. To do that we'd need to know | 1213 // need to express them in post-scale size. To do that we'd need to know |
1222 // the scale we're scaling to, but that depends on the margins. Instead | 1214 // the scale we're scaling to, but that depends on the margins. Instead |
1223 // we express them as a fraction of the target rectangle: this will be | 1215 // we express them as a fraction of the target rectangle: this will be |
1224 // correct if we end up fully zooming to it, and won't matter if we | 1216 // correct if we end up fully zooming to it, and won't matter if we |
1225 // don't. | 1217 // don't. |
(...skipping 18 matching lines...) Expand all Loading... |
1244 float screenWidth = m_size.width / scale; | 1236 float screenWidth = m_size.width / scale; |
1245 float screenHeight = m_size.height / scale; | 1237 float screenHeight = m_size.height / scale; |
1246 | 1238 |
1247 // Scroll to vertically align the block. | 1239 // Scroll to vertically align the block. |
1248 if (rect.height < screenHeight) { | 1240 if (rect.height < screenHeight) { |
1249 // Vertically center short blocks. | 1241 // Vertically center short blocks. |
1250 rect.y -= 0.5 * (screenHeight - rect.height); | 1242 rect.y -= 0.5 * (screenHeight - rect.height); |
1251 } else { | 1243 } else { |
1252 // Ensure position we're zooming to (+ padding) isn't off the bottom of | 1244 // Ensure position we're zooming to (+ padding) isn't off the bottom of |
1253 // the screen. | 1245 // the screen. |
1254 rect.y = std::max<float>(rect.y, hitPoint.y + padding - screenHeight); | 1246 rect.y = std::max<float>(rect.y, hitPointInRootFrame.y + padding - scree
nHeight); |
1255 } // Otherwise top align the block. | 1247 } // Otherwise top align the block. |
1256 | 1248 |
1257 // Do the same thing for horizontal alignment. | 1249 // Do the same thing for horizontal alignment. |
1258 if (rect.width < screenWidth) | 1250 if (rect.width < screenWidth) |
1259 rect.x -= 0.5 * (screenWidth - rect.width); | 1251 rect.x -= 0.5 * (screenWidth - rect.width); |
1260 else | 1252 else |
1261 rect.x = std::max<float>(rect.x, hitPoint.x + padding - screenWidth); | 1253 rect.x = std::max<float>(rect.x, hitPointInRootFrame.x + padding - scree
nWidth); |
1262 scroll.x = rect.x; | 1254 scroll.x = rect.x; |
1263 scroll.y = rect.y; | 1255 scroll.y = rect.y; |
1264 | 1256 |
1265 scale = clampPageScaleFactorToLimits(scale); | 1257 scale = clampPageScaleFactorToLimits(scale); |
1266 scroll = mainFrameImpl()->frameView()->windowToContents(scroll); | 1258 scroll = mainFrameImpl()->frameView()->rootFrameToContents(scroll); |
1267 scroll = clampOffsetAtScale(scroll, scale); | 1259 scroll = clampOffsetAtScale(scroll, scale); |
1268 } | 1260 } |
1269 | 1261 |
1270 static Node* findCursorDefiningAncestor(Node* node, LocalFrame* frame) | 1262 static Node* findCursorDefiningAncestor(Node* node, LocalFrame* frame) |
1271 { | 1263 { |
1272 // Go up the tree to find the node that defines a mouse cursor style | 1264 // Go up the tree to find the node that defines a mouse cursor style |
1273 while (node) { | 1265 while (node) { |
1274 if (node->layoutObject()) { | 1266 if (node->layoutObject()) { |
1275 ECursor cursor = node->layoutObject()->style()->cursor(); | 1267 ECursor cursor = node->layoutObject()->style()->cursor(); |
1276 if (cursor != CURSOR_AUTO || frame->eventHandler().useHandCursor(nod
e, node->isLink())) | 1268 if (cursor != CURSOR_AUTO || frame->eventHandler().useHandCursor(nod
e, node->isLink())) |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1367 // Safari documentation for -webkit-tap-highlight-color says if the spec
ified color has 0 alpha, | 1359 // Safari documentation for -webkit-tap-highlight-color says if the spec
ified color has 0 alpha, |
1368 // then tap highlighting is disabled. | 1360 // then tap highlighting is disabled. |
1369 // http://developer.apple.com/library/safari/#documentation/appleapplica
tions/reference/safaricssref/articles/standardcssproperties.html | 1361 // http://developer.apple.com/library/safari/#documentation/appleapplica
tions/reference/safaricssref/articles/standardcssproperties.html |
1370 if (!highlightColor.alpha()) | 1362 if (!highlightColor.alpha()) |
1371 continue; | 1363 continue; |
1372 | 1364 |
1373 m_linkHighlights.append(LinkHighlight::create(node, this)); | 1365 m_linkHighlights.append(LinkHighlight::create(node, this)); |
1374 } | 1366 } |
1375 } | 1367 } |
1376 | 1368 |
1377 void WebViewImpl::animateDoubleTapZoom(const IntPoint& point) | 1369 void WebViewImpl::animateDoubleTapZoom(const IntPoint& pointInRootFrame) |
1378 { | 1370 { |
1379 if (!mainFrameImpl()) | 1371 if (!mainFrameImpl()) |
1380 return; | 1372 return; |
1381 | 1373 |
1382 WebRect blockBounds = computeBlockBound(point, false); | 1374 WebRect blockBounds = computeBlockBound(pointInRootFrame, false); |
1383 float scale; | 1375 float scale; |
1384 WebPoint scroll; | 1376 WebPoint scroll; |
1385 | 1377 |
1386 computeScaleAndScrollForBlockRect(point, blockBounds, touchPointPadding, min
imumPageScaleFactor() * doubleTapZoomAlreadyLegibleRatio, scale, scroll); | 1378 computeScaleAndScrollForBlockRect(pointInRootFrame, blockBounds, touchPointP
adding, minimumPageScaleFactor() * doubleTapZoomAlreadyLegibleRatio, scale, scro
ll); |
1387 | 1379 |
1388 bool stillAtPreviousDoubleTapScale = (pageScaleFactor() == m_doubleTapZoomPa
geScaleFactor | 1380 bool stillAtPreviousDoubleTapScale = (pageScaleFactor() == m_doubleTapZoomPa
geScaleFactor |
1389 && m_doubleTapZoomPageScaleFactor != minimumPageScaleFactor()) | 1381 && m_doubleTapZoomPageScaleFactor != minimumPageScaleFactor()) |
1390 || m_doubleTapZoomPending; | 1382 || m_doubleTapZoomPending; |
1391 | 1383 |
1392 bool scaleUnchanged = fabs(pageScaleFactor() - scale) < minScaleDifference; | 1384 bool scaleUnchanged = fabs(pageScaleFactor() - scale) < minScaleDifference; |
1393 bool shouldZoomOut = blockBounds.isEmpty() || scaleUnchanged || stillAtPrevi
ousDoubleTapScale; | 1385 bool shouldZoomOut = blockBounds.isEmpty() || scaleUnchanged || stillAtPrevi
ousDoubleTapScale; |
1394 | 1386 |
1395 bool isAnimating; | 1387 bool isAnimating; |
1396 | 1388 |
1397 if (shouldZoomOut) { | 1389 if (shouldZoomOut) { |
1398 scale = minimumPageScaleFactor(); | 1390 scale = minimumPageScaleFactor(); |
1399 isAnimating = startPageScaleAnimation(mainFrameImpl()->frameView()->wind
owToContents(point), true, scale, doubleTapZoomAnimationDurationInSeconds); | 1391 isAnimating = startPageScaleAnimation(mainFrameImpl()->frameView()->root
FrameToContents(pointInRootFrame), true, scale, doubleTapZoomAnimationDurationIn
Seconds); |
1400 } else { | 1392 } else { |
1401 isAnimating = startPageScaleAnimation(scroll, false, scale, doubleTapZoo
mAnimationDurationInSeconds); | 1393 isAnimating = startPageScaleAnimation(scroll, false, scale, doubleTapZoo
mAnimationDurationInSeconds); |
1402 } | 1394 } |
1403 | 1395 |
1404 if (isAnimating) { | 1396 if (isAnimating) { |
1405 m_doubleTapZoomPageScaleFactor = scale; | 1397 m_doubleTapZoomPageScaleFactor = scale; |
1406 m_doubleTapZoomPending = true; | 1398 m_doubleTapZoomPending = true; |
1407 } | 1399 } |
1408 } | 1400 } |
1409 | 1401 |
1410 void WebViewImpl::zoomToFindInPageRect(const WebRect& rect) | 1402 void WebViewImpl::zoomToFindInPageRect(const WebRect& rectInRootFrame) |
1411 { | 1403 { |
1412 if (!mainFrameImpl()) | 1404 if (!mainFrameImpl()) |
1413 return; | 1405 return; |
1414 | 1406 |
1415 WebRect blockBounds = computeBlockBound(WebPoint(rect.x + rect.width / 2, re
ct.y + rect.height / 2), true); | 1407 WebRect blockBounds = computeBlockBound(WebPoint(rectInRootFrame.x + rectInR
ootFrame.width / 2, rectInRootFrame.y + rectInRootFrame.height / 2), true); |
1416 | 1408 |
1417 if (blockBounds.isEmpty()) { | 1409 if (blockBounds.isEmpty()) { |
1418 // Keep current scale (no need to scroll as x,y will normally already | 1410 // Keep current scale (no need to scroll as x,y will normally already |
1419 // be visible). FIXME: Revisit this if it isn't always true. | 1411 // be visible). FIXME: Revisit this if it isn't always true. |
1420 return; | 1412 return; |
1421 } | 1413 } |
1422 | 1414 |
1423 float scale; | 1415 float scale; |
1424 WebPoint scroll; | 1416 WebPoint scroll; |
1425 | 1417 |
1426 computeScaleAndScrollForBlockRect(WebPoint(rect.x, rect.y), blockBounds, non
UserInitiatedPointPadding, minimumPageScaleFactor(), scale, scroll); | 1418 computeScaleAndScrollForBlockRect(WebPoint(rectInRootFrame.x, rectInRootFram
e.y), blockBounds, nonUserInitiatedPointPadding, minimumPageScaleFactor(), scale
, scroll); |
1427 | 1419 |
1428 startPageScaleAnimation(scroll, false, scale, findInPageAnimationDurationInS
econds); | 1420 startPageScaleAnimation(scroll, false, scale, findInPageAnimationDurationInS
econds); |
1429 } | 1421 } |
1430 | 1422 |
1431 bool WebViewImpl::zoomToMultipleTargetsRect(const WebRect& rect) | 1423 bool WebViewImpl::zoomToMultipleTargetsRect(const WebRect& rectInRootFrame) |
1432 { | 1424 { |
1433 if (!mainFrameImpl()) | 1425 if (!mainFrameImpl()) |
1434 return false; | 1426 return false; |
1435 | 1427 |
1436 float scale; | 1428 float scale; |
1437 WebPoint scroll; | 1429 WebPoint scroll; |
1438 | 1430 |
1439 computeScaleAndScrollForBlockRect(WebPoint(rect.x, rect.y), rect, nonUserIni
tiatedPointPadding, minimumPageScaleFactor(), scale, scroll); | 1431 computeScaleAndScrollForBlockRect(WebPoint(rectInRootFrame.x, rectInRootFram
e.y), rectInRootFrame, nonUserInitiatedPointPadding, minimumPageScaleFactor(), s
cale, scroll); |
1440 | 1432 |
1441 if (scale <= pageScaleFactor()) | 1433 if (scale <= pageScaleFactor()) |
1442 return false; | 1434 return false; |
1443 | 1435 |
1444 startPageScaleAnimation(scroll, false, scale, multipleTargetsZoomAnimationDu
rationInSeconds); | 1436 startPageScaleAnimation(scroll, false, scale, multipleTargetsZoomAnimationDu
rationInSeconds); |
1445 return true; | 1437 return true; |
1446 } | 1438 } |
1447 | 1439 |
1448 void WebViewImpl::hasTouchEventHandlers(bool hasTouchHandlers) | 1440 void WebViewImpl::hasTouchEventHandlers(bool hasTouchHandlers) |
1449 { | 1441 { |
(...skipping 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2598 anchor = localFrame->editor().firstRectForRange(range.get()); | 2590 anchor = localFrame->editor().firstRectForRange(range.get()); |
2599 | 2591 |
2600 range = Range::create(selectedRange->endContainer()->document(), | 2592 range = Range::create(selectedRange->endContainer()->document(), |
2601 selectedRange->endContainer(), | 2593 selectedRange->endContainer(), |
2602 selectedRange->endOffset(), | 2594 selectedRange->endOffset(), |
2603 selectedRange->endContainer(), | 2595 selectedRange->endContainer(), |
2604 selectedRange->endOffset()); | 2596 selectedRange->endOffset()); |
2605 focus = localFrame->editor().firstRectForRange(range.get()); | 2597 focus = localFrame->editor().firstRectForRange(range.get()); |
2606 } | 2598 } |
2607 | 2599 |
2608 IntRect scaledAnchor(localFrame->view()->contentsToWindow(anchor)); | 2600 anchor = localFrame->view()->contentsToViewport(anchor); |
2609 IntRect scaledFocus(localFrame->view()->contentsToWindow(focus)); | 2601 focus = localFrame->view()->contentsToViewport(focus); |
2610 | |
2611 if (pinchVirtualViewportEnabled()) { | |
2612 // FIXME(http://crbug.com/371902) - We shouldn't have to do this | |
2613 // manually, the contentsToWindow methods above should be fixed to do | |
2614 // this. | |
2615 IntPoint pinchViewportOffset = | |
2616 roundedIntPoint(page()->frameHost().pinchViewport().visibleRect().lo
cation()); | |
2617 scaledAnchor.moveBy(-pinchViewportOffset); | |
2618 scaledFocus.moveBy(-pinchViewportOffset); | |
2619 } | |
2620 | |
2621 scaledAnchor.scale(pageScaleFactor()); | |
2622 scaledFocus.scale(pageScaleFactor()); | |
2623 anchor = scaledAnchor; | |
2624 focus = scaledFocus; | |
2625 | 2602 |
2626 if (!selection.selection().isBaseFirst()) | 2603 if (!selection.selection().isBaseFirst()) |
2627 std::swap(anchor, focus); | 2604 std::swap(anchor, focus); |
2628 return true; | 2605 return true; |
2629 } | 2606 } |
2630 | 2607 |
2631 InputMethodContext* WebViewImpl::inputMethodContext() | 2608 InputMethodContext* WebViewImpl::inputMethodContext() |
2632 { | 2609 { |
2633 if (!m_imeAcceptEvents) | 2610 if (!m_imeAcceptEvents) |
2634 return 0; | 2611 return 0; |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2940 return false; | 2917 return false; |
2941 | 2918 |
2942 if (!m_webSettings->autoZoomFocusedNodeToLegibleScale()) { | 2919 if (!m_webSettings->autoZoomFocusedNodeToLegibleScale()) { |
2943 PinchViewport& pinchViewport = page()->frameHost().pinchViewport(); | 2920 PinchViewport& pinchViewport = page()->frameHost().pinchViewport(); |
2944 | 2921 |
2945 // FIXME: The pixel snapping shouldn't be done ad-hoc. crbug.com/458579. | 2922 // FIXME: The pixel snapping shouldn't be done ad-hoc. crbug.com/458579. |
2946 IntRect viewportRectInRootFrame( | 2923 IntRect viewportRectInRootFrame( |
2947 ceiledIntPoint(pinchViewport.location()), | 2924 ceiledIntPoint(pinchViewport.location()), |
2948 expandedIntSize(pinchViewport.visibleSize())); | 2925 expandedIntSize(pinchViewport.visibleSize())); |
2949 | 2926 |
2950 // FIXME: Use viewportToRootFrame when coordinate refactoring CL lands. | 2927 FloatRect targetRectInRootFrame = pinchViewport.viewportToRootFrame(rect
InViewport); |
2951 FloatRect targetRectInRootFrame( | |
2952 rectInViewport.x, | |
2953 rectInViewport.y, | |
2954 rectInViewport.width, | |
2955 rectInViewport.height); | |
2956 targetRectInRootFrame.scale(1 / pinchViewport.scale()); | |
2957 targetRectInRootFrame.moveBy(viewportRectInRootFrame.location()); | |
2958 | |
2959 DoubleSize remainder = frame->view()->scrollElementToRect(element, IntRe
ct(targetRectInRootFrame)); | 2928 DoubleSize remainder = frame->view()->scrollElementToRect(element, IntRe
ct(targetRectInRootFrame)); |
2960 | 2929 |
2961 // Scroll the remainder in the pinch viewport. | 2930 // Scroll the remainder in the pinch viewport. |
2962 page()->frameHost().pinchViewport().move(FloatPoint(remainder.width(), r
emainder.height())); | 2931 page()->frameHost().pinchViewport().move(FloatPoint(remainder.width(), r
emainder.height())); |
2963 return false; | 2932 return false; |
2964 } | 2933 } |
2965 | 2934 |
2966 float scale; | 2935 float scale; |
2967 IntPoint scroll; | 2936 IntPoint scroll; |
2968 bool needAnimation; | 2937 bool needAnimation; |
2969 computeScaleAndScrollForFocusedNode(element, scale, scroll, needAnimation); | 2938 computeScaleAndScrollForFocusedNode(element, scale, scroll, needAnimation); |
2970 if (needAnimation) | 2939 if (needAnimation) |
2971 return startPageScaleAnimation(scroll, false, scale, scrollAndScaleAnima
tionDurationInSeconds); | 2940 return startPageScaleAnimation(scroll, false, scale, scrollAndScaleAnima
tionDurationInSeconds); |
2972 | 2941 |
2973 return false; | 2942 return false; |
2974 } | 2943 } |
2975 | 2944 |
2976 void WebViewImpl::computeScaleAndScrollForFocusedNode(Node* focusedNode, float&
newScale, IntPoint& newScroll, bool& needAnimation) | 2945 void WebViewImpl::computeScaleAndScrollForFocusedNode(Node* focusedNode, float&
newScale, IntPoint& newScroll, bool& needAnimation) |
2977 { | 2946 { |
2978 focusedNode->document().updateLayoutIgnorePendingStylesheets(); | 2947 focusedNode->document().updateLayoutIgnorePendingStylesheets(); |
2979 | 2948 |
2980 // 'caret' is rect encompassing the blinking cursor. | 2949 // 'caret' is rect encompassing the blinking cursor. |
2981 IntRect textboxRect = focusedNode->document().view()->contentsToWindow(pixel
SnappedIntRect(focusedNode->Node::boundingBox())); | 2950 IntRect textboxRectInRootFrame = focusedNode->document().view()->contentsToR
ootFrame(pixelSnappedIntRect(focusedNode->Node::boundingBox())); |
2982 WebRect caret, unusedEnd; | 2951 WebRect caret, unusedEnd; |
2983 selectionBounds(caret, unusedEnd); | 2952 selectionBounds(caret, unusedEnd); |
2984 IntRect unscaledCaret = caret; | 2953 IntRect unscaledCaret = caret; |
2985 unscaledCaret.scale(1 / pageScaleFactor()); | 2954 unscaledCaret.scale(1 / pageScaleFactor()); |
2986 caret = unscaledCaret; | 2955 caret = unscaledCaret; |
2987 | 2956 |
2988 if (shouldDisableDesktopWorkarounds()) { | 2957 if (shouldDisableDesktopWorkarounds()) { |
2989 newScale = pageScaleFactor(); | 2958 newScale = pageScaleFactor(); |
2990 } else { | 2959 } else { |
2991 // Pick a scale which is reasonably readable. This is the scale at which | 2960 // Pick a scale which is reasonably readable. This is the scale at which |
2992 // the caret height will become minReadableCaretHeightForNode (adjusted | 2961 // the caret height will become minReadableCaretHeightForNode (adjusted |
2993 // for dpi and font scale factor). | 2962 // for dpi and font scale factor). |
2994 const int minReadableCaretHeightForNode = textboxRect.height() >= 2 * ca
ret.height ? minReadableCaretHeightForTextArea : minReadableCaretHeight; | 2963 const int minReadableCaretHeightForNode = textboxRectInRootFrame.height(
) >= 2 * caret.height ? minReadableCaretHeightForTextArea : minReadableCaretHeig
ht; |
2995 newScale = clampPageScaleFactorToLimits(maximumLegiblePageScale() * minR
eadableCaretHeightForNode / caret.height); | 2964 newScale = clampPageScaleFactorToLimits(maximumLegiblePageScale() * minR
eadableCaretHeightForNode / caret.height); |
2996 newScale = std::max(newScale, pageScaleFactor()); | 2965 newScale = std::max(newScale, pageScaleFactor()); |
2997 } | 2966 } |
2998 const float deltaScale = newScale / pageScaleFactor(); | 2967 const float deltaScale = newScale / pageScaleFactor(); |
2999 | 2968 |
3000 needAnimation = false; | 2969 needAnimation = false; |
3001 // If we are at less than the target zoom level, zoom in. | 2970 // If we are at less than the target zoom level, zoom in. |
3002 if (deltaScale > minScaleChangeToTriggerZoom) | 2971 if (deltaScale > minScaleChangeToTriggerZoom) |
3003 needAnimation = true; | 2972 needAnimation = true; |
3004 else | 2973 else |
3005 newScale = pageScaleFactor(); | 2974 newScale = pageScaleFactor(); |
3006 | 2975 |
3007 // Convert the rects to absolute space in the new scale. | 2976 // Convert the rects to absolute space in the new scale. |
3008 IntRect textboxRectInDocumentCoordinates = textboxRect; | 2977 IntRect textboxRectInDocumentCoordinates = mainFrameImpl()->frameView()->fra
meToContents(textboxRectInRootFrame); |
3009 textboxRectInDocumentCoordinates.move(mainFrame()->scrollOffset()); | |
3010 IntRect caretInDocumentCoordinates = caret; | 2978 IntRect caretInDocumentCoordinates = caret; |
3011 caretInDocumentCoordinates.move(mainFrame()->scrollOffset()); | 2979 caretInDocumentCoordinates.move(mainFrame()->scrollOffset()); |
3012 | 2980 |
3013 int viewWidth = m_size.width / newScale; | 2981 int viewWidth = m_size.width / newScale; |
3014 int viewHeight = m_size.height / newScale; | 2982 int viewHeight = m_size.height / newScale; |
3015 | 2983 |
3016 // If the caret is offscreen, then animate. | 2984 // If the caret is offscreen, then animate. |
3017 IntRect sizeRect(0, 0, viewWidth, viewHeight); | 2985 IntRect sizeRect(0, 0, viewWidth, viewHeight); |
3018 sizeRect.scale(newScale / pageScaleFactor()); | 2986 sizeRect.scale(newScale / pageScaleFactor()); |
3019 if (!sizeRect.contains(caret)) | 2987 if (!sizeRect.contains(caret)) |
3020 needAnimation = true; | 2988 needAnimation = true; |
3021 | 2989 |
3022 // If the box is partially offscreen and it's possible to bring it fully | 2990 // If the box is partially offscreen and it's possible to bring it fully |
3023 // onscreen, then animate. | 2991 // onscreen, then animate. |
3024 if (sizeRect.contains(textboxRectInDocumentCoordinates.width(), textboxRectI
nDocumentCoordinates.height()) && !sizeRect.contains(textboxRect)) | 2992 if (sizeRect.contains(textboxRectInDocumentCoordinates.width(), textboxRectI
nDocumentCoordinates.height()) && !sizeRect.contains(textboxRectInRootFrame)) |
3025 needAnimation = true; | 2993 needAnimation = true; |
3026 | 2994 |
3027 if (!needAnimation) | 2995 if (!needAnimation) |
3028 return; | 2996 return; |
3029 | 2997 |
3030 if (textboxRectInDocumentCoordinates.width() <= viewWidth) { | 2998 if (textboxRectInDocumentCoordinates.width() <= viewWidth) { |
3031 // Field is narrower than screen. Try to leave padding on left so field'
s | 2999 // Field is narrower than screen. Try to leave padding on left so field'
s |
3032 // label is visible, but it's more important to ensure entire field is | 3000 // label is visible, but it's more important to ensure entire field is |
3033 // onscreen. | 3001 // onscreen. |
3034 int idealLeftPadding = viewWidth * leftBoxRatio; | 3002 int idealLeftPadding = viewWidth * leftBoxRatio; |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3551 m_pageScaleConstraintsSet.setNeedsReset(true); | 3519 m_pageScaleConstraintsSet.setNeedsReset(true); |
3552 | 3520 |
3553 // Clobber saved scales and scroll offsets. | 3521 // Clobber saved scales and scroll offsets. |
3554 if (FrameView* view = page()->deprecatedLocalMainFrame()->document()->view()
) | 3522 if (FrameView* view = page()->deprecatedLocalMainFrame()->document()->view()
) |
3555 view->cacheCurrentScrollPosition(); | 3523 view->cacheCurrentScrollPosition(); |
3556 } | 3524 } |
3557 | 3525 |
3558 void WebViewImpl::performMediaPlayerAction(const WebMediaPlayerAction& action, | 3526 void WebViewImpl::performMediaPlayerAction(const WebMediaPlayerAction& action, |
3559 const WebPoint& location) | 3527 const WebPoint& location) |
3560 { | 3528 { |
3561 HitTestResult result = hitTestResultForWindowPos(location); | 3529 HitTestResult result = hitTestResultForViewportPos(location); |
3562 RefPtrWillBeRawPtr<Node> node = result.innerNonSharedNode(); | 3530 RefPtrWillBeRawPtr<Node> node = result.innerNonSharedNode(); |
3563 if (!isHTMLVideoElement(*node) && !isHTMLAudioElement(*node)) | 3531 if (!isHTMLVideoElement(*node) && !isHTMLAudioElement(*node)) |
3564 return; | 3532 return; |
3565 | 3533 |
3566 RefPtrWillBeRawPtr<HTMLMediaElement> mediaElement = static_pointer_cast<HTML
MediaElement>(node); | 3534 RefPtrWillBeRawPtr<HTMLMediaElement> mediaElement = static_pointer_cast<HTML
MediaElement>(node); |
3567 switch (action.type) { | 3535 switch (action.type) { |
3568 case WebMediaPlayerAction::Play: | 3536 case WebMediaPlayerAction::Play: |
3569 if (action.enable) | 3537 if (action.enable) |
3570 mediaElement->play(); | 3538 mediaElement->play(); |
3571 else | 3539 else |
3572 mediaElement->pause(); | 3540 mediaElement->pause(); |
3573 break; | 3541 break; |
3574 case WebMediaPlayerAction::Mute: | 3542 case WebMediaPlayerAction::Mute: |
3575 mediaElement->setMuted(action.enable); | 3543 mediaElement->setMuted(action.enable); |
3576 break; | 3544 break; |
3577 case WebMediaPlayerAction::Loop: | 3545 case WebMediaPlayerAction::Loop: |
3578 mediaElement->setLoop(action.enable); | 3546 mediaElement->setLoop(action.enable); |
3579 break; | 3547 break; |
3580 case WebMediaPlayerAction::Controls: | 3548 case WebMediaPlayerAction::Controls: |
3581 mediaElement->setBooleanAttribute(HTMLNames::controlsAttr, action.enable
); | 3549 mediaElement->setBooleanAttribute(HTMLNames::controlsAttr, action.enable
); |
3582 break; | 3550 break; |
3583 default: | 3551 default: |
3584 ASSERT_NOT_REACHED(); | 3552 ASSERT_NOT_REACHED(); |
3585 } | 3553 } |
3586 } | 3554 } |
3587 | 3555 |
3588 void WebViewImpl::performPluginAction(const WebPluginAction& action, | 3556 void WebViewImpl::performPluginAction(const WebPluginAction& action, |
3589 const WebPoint& location) | 3557 const WebPoint& location) |
3590 { | 3558 { |
3591 HitTestResult result = hitTestResultForWindowPos(location); | 3559 // FIXME: Location is probably in viewport coordinates |
| 3560 HitTestResult result = hitTestResultForRootFramePos(location); |
3592 RefPtrWillBeRawPtr<Node> node = result.innerNonSharedNode(); | 3561 RefPtrWillBeRawPtr<Node> node = result.innerNonSharedNode(); |
3593 if (!isHTMLObjectElement(*node) && !isHTMLEmbedElement(*node)) | 3562 if (!isHTMLObjectElement(*node) && !isHTMLEmbedElement(*node)) |
3594 return; | 3563 return; |
3595 | 3564 |
3596 LayoutObject* object = node->layoutObject(); | 3565 LayoutObject* object = node->layoutObject(); |
3597 if (object && object->isLayoutPart()) { | 3566 if (object && object->isLayoutPart()) { |
3598 Widget* widget = toLayoutPart(object)->widget(); | 3567 Widget* widget = toLayoutPart(object)->widget(); |
3599 if (widget && widget->isPluginContainer()) { | 3568 if (widget && widget->isPluginContainer()) { |
3600 WebPluginContainerImpl* plugin = toWebPluginContainerImpl(widget); | 3569 WebPluginContainerImpl* plugin = toWebPluginContainerImpl(widget); |
3601 switch (action.type) { | 3570 switch (action.type) { |
3602 case WebPluginAction::Rotate90Clockwise: | 3571 case WebPluginAction::Rotate90Clockwise: |
3603 plugin->plugin()->rotateView(WebPlugin::RotationType90Clockwise)
; | 3572 plugin->plugin()->rotateView(WebPlugin::RotationType90Clockwise)
; |
3604 break; | 3573 break; |
3605 case WebPluginAction::Rotate90Counterclockwise: | 3574 case WebPluginAction::Rotate90Counterclockwise: |
3606 plugin->plugin()->rotateView(WebPlugin::RotationType90Counterclo
ckwise); | 3575 plugin->plugin()->rotateView(WebPlugin::RotationType90Counterclo
ckwise); |
3607 break; | 3576 break; |
3608 default: | 3577 default: |
3609 ASSERT_NOT_REACHED(); | 3578 ASSERT_NOT_REACHED(); |
3610 } | 3579 } |
3611 } | 3580 } |
3612 } | 3581 } |
3613 } | 3582 } |
3614 | 3583 |
3615 WebHitTestResult WebViewImpl::hitTestResultAt(const WebPoint& point) | 3584 WebHitTestResult WebViewImpl::hitTestResultAt(const WebPoint& point) |
3616 { | 3585 { |
3617 return coreHitTestResultAt(point); | 3586 return coreHitTestResultAt(point); |
3618 } | 3587 } |
3619 | 3588 |
3620 HitTestResult WebViewImpl::coreHitTestResultAt(const WebPoint& point) | 3589 HitTestResult WebViewImpl::coreHitTestResultAt(const WebPoint& pointInViewport) |
3621 { | 3590 { |
3622 FloatPoint scaledPoint(point.x, point.y); | 3591 FrameView* view = mainFrameImpl()->frameView(); |
3623 scaledPoint.scale(1 / pageScaleFactor(), 1 / pageScaleFactor()); | 3592 IntPoint pointInRootFrame = view->contentsToFrame(view->viewportToContents(p
ointInViewport)); |
3624 scaledPoint.moveBy(pinchViewportOffset()); | 3593 return hitTestResultForRootFramePos(pointInRootFrame); |
3625 return hitTestResultForWindowPos(flooredIntPoint(scaledPoint)); | |
3626 } | 3594 } |
3627 | 3595 |
3628 void WebViewImpl::copyImageAt(const WebPoint& point) | 3596 void WebViewImpl::copyImageAt(const WebPoint& point) |
3629 { | 3597 { |
3630 if (!m_page) | 3598 if (!m_page) |
3631 return; | 3599 return; |
3632 | 3600 |
3633 HitTestResult result = hitTestResultForWindowPos(point); | 3601 HitTestResult result = hitTestResultForViewportPos(point); |
3634 if (!isHTMLCanvasElement(result.innerNonSharedNode()) && result.absoluteImag
eURL().isEmpty()) { | 3602 if (!isHTMLCanvasElement(result.innerNonSharedNode()) && result.absoluteImag
eURL().isEmpty()) { |
3635 // There isn't actually an image at these coordinates. Might be because | 3603 // There isn't actually an image at these coordinates. Might be because |
3636 // the window scrolled while the context menu was open or because the pa
ge | 3604 // the window scrolled while the context menu was open or because the pa
ge |
3637 // changed itself between when we thought there was an image here and wh
en | 3605 // changed itself between when we thought there was an image here and wh
en |
3638 // we actually tried to retreive the image. | 3606 // we actually tried to retreive the image. |
3639 // | 3607 // |
3640 // FIXME: implement a cache of the most recent HitTestResult to avoid ha
ving | 3608 // FIXME: implement a cache of the most recent HitTestResult to avoid ha
ving |
3641 // to do two hit tests. | 3609 // to do two hit tests. |
3642 return; | 3610 return; |
3643 } | 3611 } |
3644 | 3612 |
3645 m_page->deprecatedLocalMainFrame()->editor().copyImage(result); | 3613 m_page->deprecatedLocalMainFrame()->editor().copyImage(result); |
3646 } | 3614 } |
3647 | 3615 |
3648 void WebViewImpl::saveImageAt(const WebPoint& point) | 3616 void WebViewImpl::saveImageAt(const WebPoint& point) |
3649 { | 3617 { |
3650 if (!m_client) | 3618 if (!m_client) |
3651 return; | 3619 return; |
3652 | 3620 |
3653 Node* node = hitTestResultForWindowPos(point).innerNonSharedNode(); | 3621 Node* node = hitTestResultForViewportPos(point).innerNonSharedNode(); |
3654 if (!node || !(isHTMLCanvasElement(*node) || isHTMLImageElement(*node))) | 3622 if (!node || !(isHTMLCanvasElement(*node) || isHTMLImageElement(*node))) |
3655 return; | 3623 return; |
3656 | 3624 |
3657 String url = toElement(*node).imageSourceURL(); | 3625 String url = toElement(*node).imageSourceURL(); |
3658 if (!KURL(KURL(), url).protocolIsData()) | 3626 if (!KURL(KURL(), url).protocolIsData()) |
3659 return; | 3627 return; |
3660 | 3628 |
3661 m_client->saveImageFromDataURL(url); | 3629 m_client->saveImageFromDataURL(url); |
3662 } | 3630 } |
3663 | 3631 |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3914 if (!page()) | 3882 if (!page()) |
3915 return; | 3883 return; |
3916 | 3884 |
3917 page()->contextMenuController().clearContextMenu(); | 3885 page()->contextMenuController().clearContextMenu(); |
3918 m_contextMenuAllowed = true; | 3886 m_contextMenuAllowed = true; |
3919 if (LocalFrame* focusedFrame = toLocalFrame(page()->focusController().focuse
dOrMainFrame())) | 3887 if (LocalFrame* focusedFrame = toLocalFrame(page()->focusController().focuse
dOrMainFrame())) |
3920 focusedFrame->eventHandler().sendContextMenuEventForKey(); | 3888 focusedFrame->eventHandler().sendContextMenuEventForKey(); |
3921 m_contextMenuAllowed = false; | 3889 m_contextMenuAllowed = false; |
3922 } | 3890 } |
3923 | 3891 |
3924 void WebViewImpl::extractSmartClipData(WebRect rect, WebString& clipText, WebStr
ing& clipHtml, WebRect& clipRect) | 3892 void WebViewImpl::extractSmartClipData(WebRect rectInViewport, WebString& clipTe
xt, WebString& clipHtml, WebRect& clipRectInViewport) |
3925 { | 3893 { |
3926 LocalFrame* localFrame = toLocalFrame(focusedCoreFrame()); | 3894 LocalFrame* localFrame = toLocalFrame(focusedCoreFrame()); |
3927 if (!localFrame) | 3895 if (!localFrame) |
3928 return; | 3896 return; |
3929 SmartClipData clipData = SmartClip(localFrame).dataForRect(rect); | 3897 SmartClipData clipData = SmartClip(localFrame).dataForRect(rectInViewport); |
3930 clipText = clipData.clipData(); | 3898 clipText = clipData.clipData(); |
3931 clipRect = clipData.rect(); | 3899 clipRectInViewport = clipData.rectInViewport(); |
3932 | 3900 |
3933 WebLocalFrameImpl* frame = mainFrameImpl(); | 3901 WebLocalFrameImpl* frame = mainFrameImpl(); |
3934 if (!frame) | 3902 if (!frame) |
3935 return; | 3903 return; |
3936 WebPoint startPoint(rect.x, rect.y); | 3904 WebPoint startPoint(rectInViewport.x, rectInViewport.y); |
3937 WebPoint endPoint(rect.x + rect.width, rect.y + rect.height); | 3905 WebPoint endPoint(rectInViewport.x + rectInViewport.width, rectInViewport.y
+ rectInViewport.height); |
3938 VisiblePosition startVisiblePosition = frame->visiblePositionForWindowPoint(
startPoint); | 3906 VisiblePosition startVisiblePosition = frame->visiblePositionForViewportPoin
t(startPoint); |
3939 VisiblePosition endVisiblePosition = frame->visiblePositionForWindowPoint(en
dPoint); | 3907 VisiblePosition endVisiblePosition = frame->visiblePositionForViewportPoint(
endPoint); |
3940 | 3908 |
3941 Position startPosition = startVisiblePosition.deepEquivalent(); | 3909 Position startPosition = startVisiblePosition.deepEquivalent(); |
3942 Position endPosition = endVisiblePosition.deepEquivalent(); | 3910 Position endPosition = endVisiblePosition.deepEquivalent(); |
3943 | 3911 |
3944 // document() will return null if -webkit-user-select is set to none. | 3912 // document() will return null if -webkit-user-select is set to none. |
3945 if (!startPosition.document() || !endPosition.document()) | 3913 if (!startPosition.document() || !endPosition.document()) |
3946 return; | 3914 return; |
3947 | 3915 |
3948 RefPtrWillBeRawPtr<Range> range = Range::create(*startPosition.document(), s
tartPosition, endPosition); | 3916 RefPtrWillBeRawPtr<Range> range = Range::create(*startPosition.document(), s
tartPosition, endPosition); |
3949 if (!range) | 3917 if (!range) |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4238 if (!frame || !frame->isLocalFrame()) | 4206 if (!frame || !frame->isLocalFrame()) |
4239 return 0; | 4207 return 0; |
4240 | 4208 |
4241 Document* document = toLocalFrame(frame)->document(); | 4209 Document* document = toLocalFrame(frame)->document(); |
4242 if (!document) | 4210 if (!document) |
4243 return 0; | 4211 return 0; |
4244 | 4212 |
4245 return document->focusedElement(); | 4213 return document->focusedElement(); |
4246 } | 4214 } |
4247 | 4215 |
4248 HitTestResult WebViewImpl::hitTestResultForWindowPos(const IntPoint& pos) | 4216 HitTestResult WebViewImpl::hitTestResultForViewportPos(const IntPoint& posInView
port) |
| 4217 { |
| 4218 IntPoint rootFramePoint(m_page->frameHost().pinchViewport().viewportToRootFr
ame(posInViewport)); |
| 4219 return hitTestResultForRootFramePos(rootFramePoint); |
| 4220 } |
| 4221 |
| 4222 HitTestResult WebViewImpl::hitTestResultForRootFramePos(const IntPoint& posInRoo
tFrame) |
4249 { | 4223 { |
4250 if (!m_page->mainFrame()->isLocalFrame()) | 4224 if (!m_page->mainFrame()->isLocalFrame()) |
4251 return HitTestResult(); | 4225 return HitTestResult(); |
4252 IntPoint docPoint(m_page->deprecatedLocalMainFrame()->view()->windowToConten
ts(pos)); | 4226 IntPoint docPoint(m_page->deprecatedLocalMainFrame()->view()->rootFrameToCon
tents(posInRootFrame)); |
4253 HitTestResult result = m_page->deprecatedLocalMainFrame()->eventHandler().hi
tTestResultAtPoint(docPoint, HitTestRequest::ReadOnly | HitTestRequest::Active); | 4227 HitTestResult result = m_page->deprecatedLocalMainFrame()->eventHandler().hi
tTestResultAtPoint(docPoint, HitTestRequest::ReadOnly | HitTestRequest::Active); |
4254 result.setToShadowHostIfInClosedShadowRoot(); | 4228 result.setToShadowHostIfInClosedShadowRoot(); |
4255 return result; | 4229 return result; |
4256 } | 4230 } |
4257 | 4231 |
4258 WebHitTestResult WebViewImpl::hitTestResultForTap(const WebPoint& tapPointWindow
Pos, const WebSize& tapArea) | 4232 WebHitTestResult WebViewImpl::hitTestResultForTap(const WebPoint& tapPointWindow
Pos, const WebSize& tapArea) |
4259 { | 4233 { |
4260 if (!m_page->mainFrame()->isLocalFrame()) | 4234 if (!m_page->mainFrame()->isLocalFrame()) |
4261 return HitTestResult(); | 4235 return HitTestResult(); |
4262 | 4236 |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4689 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width | 4663 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width |
4690 || (constraints.minimumScale == constraints.maximumScale && constraints.
minimumScale != -1); | 4664 || (constraints.minimumScale == constraints.maximumScale && constraints.
minimumScale != -1); |
4691 } | 4665 } |
4692 | 4666 |
4693 void WebViewImpl::forceNextWebGLContextCreationToFail() | 4667 void WebViewImpl::forceNextWebGLContextCreationToFail() |
4694 { | 4668 { |
4695 WebGLRenderingContext::forceNextWebGLContextCreationToFail(); | 4669 WebGLRenderingContext::forceNextWebGLContextCreationToFail(); |
4696 } | 4670 } |
4697 | 4671 |
4698 } // namespace blink | 4672 } // namespace blink |
OLD | NEW |