| Index: Source/core/frame/SmartClip.cpp | 
| diff --git a/Source/core/frame/SmartClip.cpp b/Source/core/frame/SmartClip.cpp | 
| index 1d21000d3e734054a13832698cea4036e433ebda..9d285cb4fc03a4a614280b7c299b57b7a8b23aca 100644 | 
| --- a/Source/core/frame/SmartClip.cpp | 
| +++ b/Source/core/frame/SmartClip.cpp | 
| @@ -43,15 +43,14 @@ | 
|  | 
| namespace blink { | 
|  | 
| -static IntRect applyScaleWithoutCollapsingToZero(const IntRect& rect, float scale) | 
| +static IntRect convertToContentCoordinatesWithoutCollapsingToZero(const IntRect& rectInViewport, const FrameView* view) | 
| { | 
| -    IntRect result = rect; | 
| -    result.scale(scale); | 
| -    if (rect.width() > 0 && !result.width()) | 
| -        result.setWidth(1); | 
| -    if (rect.height() > 0 && !result.height()) | 
| -        result.setHeight(1); | 
| -    return result; | 
| +    IntRect rectInContents = view->viewportToContents(rectInViewport); | 
| +    if (rectInViewport.width() > 0 && !rectInContents.width()) | 
| +        rectInContents.setWidth(1); | 
| +    if (rectInViewport.height() > 0 && !rectInContents.height()) | 
| +        rectInContents.setHeight(1); | 
| +    return rectInContents; | 
| } | 
|  | 
| static Node* nodeInsideFrame(Node* node) | 
| @@ -61,9 +60,9 @@ static Node* nodeInsideFrame(Node* node) | 
| return nullptr; | 
| } | 
|  | 
| -IntRect SmartClipData::rect() const | 
| +IntRect SmartClipData::rectInViewport() const | 
| { | 
| -    return m_rect; | 
| +    return m_rectInViewport; | 
| } | 
|  | 
| const String& SmartClipData::clipData() const | 
| @@ -76,22 +75,20 @@ SmartClip::SmartClip(PassRefPtrWillBeRawPtr<LocalFrame> frame) | 
| { | 
| } | 
|  | 
| -SmartClipData SmartClip::dataForRect(const IntRect& cropRect) | 
| +SmartClipData SmartClip::dataForRect(const IntRect& cropRectInViewport) | 
| { | 
| -    IntRect resizedCropRect = applyScaleWithoutCollapsingToZero(cropRect, 1 / pageScaleFactor()); | 
| - | 
| -    Node* bestNode = findBestOverlappingNode(m_frame->document(), resizedCropRect); | 
| +    Node* bestNode = findBestOverlappingNode(m_frame->document(), cropRectInViewport); | 
| if (!bestNode) | 
| return SmartClipData(); | 
|  | 
| if (Node* nodeFromFrame = nodeInsideFrame(bestNode)) { | 
| // FIXME: This code only hit-tests a single iframe. It seems like we ought support nested frames. | 
| -        if (Node* bestNodeInFrame = findBestOverlappingNode(nodeFromFrame, resizedCropRect)) | 
| +        if (Node* bestNodeInFrame = findBestOverlappingNode(nodeFromFrame, cropRectInViewport)) | 
| bestNode = bestNodeInFrame; | 
| } | 
|  | 
| WillBeHeapVector<RawPtrWillBeMember<Node>> hitNodes; | 
| -    collectOverlappingChildNodes(bestNode, resizedCropRect, hitNodes); | 
| +    collectOverlappingChildNodes(bestNode, cropRectInViewport, hitNodes); | 
|  | 
| if (hitNodes.isEmpty() || hitNodes.size() == bestNode->countChildren()) { | 
| hitNodes.clear(); | 
| @@ -106,7 +103,7 @@ SmartClipData SmartClip::dataForRect(const IntRect& cropRect) | 
| unitedRects.unite(hitNodes[i]->pixelSnappedBoundingBox()); | 
| } | 
|  | 
| -    return SmartClipData(bestNode, convertRectToWindow(unitedRects), collectedText.toString()); | 
| +    return SmartClipData(bestNode, m_frame->document()->view()->contentsToViewport(unitedRects), collectedText.toString()); | 
| } | 
|  | 
| float SmartClip::pageScaleFactor() | 
| @@ -159,12 +156,12 @@ Node* SmartClip::minNodeContainsNodes(Node* minNode, Node* newNode) | 
| return nullptr; | 
| } | 
|  | 
| -Node* SmartClip::findBestOverlappingNode(Node* rootNode, const IntRect& cropRect) | 
| +Node* SmartClip::findBestOverlappingNode(Node* rootNode, const IntRect& cropRectInViewport) | 
| { | 
| if (!rootNode) | 
| return nullptr; | 
|  | 
| -    IntRect resizedCropRect = rootNode->document().view()->windowToContents(cropRect); | 
| +    IntRect resizedCropRect = convertToContentCoordinatesWithoutCollapsingToZero(cropRectInViewport, rootNode->document().view()); | 
|  | 
| Node* node = rootNode; | 
| Node* minNode = nullptr; | 
| @@ -218,11 +215,11 @@ bool SmartClip::shouldSkipBackgroundImage(Node* node) | 
| return false; | 
| } | 
|  | 
| -void SmartClip::collectOverlappingChildNodes(Node* parentNode, const IntRect& cropRect, WillBeHeapVector<RawPtrWillBeMember<Node>>& hitNodes) | 
| +void SmartClip::collectOverlappingChildNodes(Node* parentNode, const IntRect& cropRectInViewport, WillBeHeapVector<RawPtrWillBeMember<Node>>& hitNodes) | 
| { | 
| if (!parentNode) | 
| return; | 
| -    IntRect resizedCropRect = parentNode->document().view()->windowToContents(cropRect); | 
| +    IntRect resizedCropRect = convertToContentCoordinatesWithoutCollapsingToZero(cropRectInViewport, parentNode->document().view()); | 
| for (Node* child = parentNode->firstChild(); child; child = child->nextSibling()) { | 
| IntRect childRect = child->pixelSnappedBoundingBox(); | 
| if (resizedCropRect.intersects(childRect)) | 
| @@ -230,13 +227,6 @@ void SmartClip::collectOverlappingChildNodes(Node* parentNode, const IntRect& cr | 
| } | 
| } | 
|  | 
| -IntRect SmartClip::convertRectToWindow(const IntRect& nodeRect) | 
| -{ | 
| -    IntRect result = m_frame->document()->view()->contentsToWindow(nodeRect); | 
| -    result.scale(pageScaleFactor()); | 
| -    return result; | 
| -} | 
| - | 
| String SmartClip::extractTextFromNode(Node* node) | 
| { | 
| // Science has proven that no text nodes are ever positioned at y == -99999. | 
|  |