| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 IntRect SmartClipData::rectInViewport() const | 62 IntRect SmartClipData::rectInViewport() const |
| 63 { | 63 { |
| 64 return m_rectInViewport; | 64 return m_rectInViewport; |
| 65 } | 65 } |
| 66 | 66 |
| 67 const String& SmartClipData::clipData() const | 67 const String& SmartClipData::clipData() const |
| 68 { | 68 { |
| 69 return m_string; | 69 return m_string; |
| 70 } | 70 } |
| 71 | 71 |
| 72 SmartClip::SmartClip(PassRefPtrWillBeRawPtr<LocalFrame> frame) | 72 SmartClip::SmartClip(RawPtr<LocalFrame> frame) |
| 73 : m_frame(frame) | 73 : m_frame(frame) |
| 74 { | 74 { |
| 75 } | 75 } |
| 76 | 76 |
| 77 SmartClipData SmartClip::dataForRect(const IntRect& cropRectInViewport) | 77 SmartClipData SmartClip::dataForRect(const IntRect& cropRectInViewport) |
| 78 { | 78 { |
| 79 Node* bestNode = findBestOverlappingNode(m_frame->document(), cropRectInView
port); | 79 Node* bestNode = findBestOverlappingNode(m_frame->document(), cropRectInView
port); |
| 80 if (!bestNode) | 80 if (!bestNode) |
| 81 return SmartClipData(); | 81 return SmartClipData(); |
| 82 | 82 |
| 83 if (Node* nodeFromFrame = nodeInsideFrame(bestNode)) { | 83 if (Node* nodeFromFrame = nodeInsideFrame(bestNode)) { |
| 84 // FIXME: This code only hit-tests a single iframe. It seems like we oug
ht support nested frames. | 84 // FIXME: This code only hit-tests a single iframe. It seems like we oug
ht support nested frames. |
| 85 if (Node* bestNodeInFrame = findBestOverlappingNode(nodeFromFrame, cropR
ectInViewport)) | 85 if (Node* bestNodeInFrame = findBestOverlappingNode(nodeFromFrame, cropR
ectInViewport)) |
| 86 bestNode = bestNodeInFrame; | 86 bestNode = bestNodeInFrame; |
| 87 } | 87 } |
| 88 | 88 |
| 89 WillBeHeapVector<RawPtrWillBeMember<Node>> hitNodes; | 89 HeapVector<Member<Node>> hitNodes; |
| 90 collectOverlappingChildNodes(bestNode, cropRectInViewport, hitNodes); | 90 collectOverlappingChildNodes(bestNode, cropRectInViewport, hitNodes); |
| 91 | 91 |
| 92 if (hitNodes.isEmpty() || hitNodes.size() == bestNode->countChildren()) { | 92 if (hitNodes.isEmpty() || hitNodes.size() == bestNode->countChildren()) { |
| 93 hitNodes.clear(); | 93 hitNodes.clear(); |
| 94 hitNodes.append(bestNode); | 94 hitNodes.append(bestNode); |
| 95 } | 95 } |
| 96 | 96 |
| 97 // Unite won't work with the empty rect, so we initialize to the first rect. | 97 // Unite won't work with the empty rect, so we initialize to the first rect. |
| 98 IntRect unitedRects = hitNodes[0]->pixelSnappedBoundingBox(); | 98 IntRect unitedRects = hitNodes[0]->pixelSnappedBoundingBox(); |
| 99 StringBuilder collectedText; | 99 StringBuilder collectedText; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 // image out of a CSS background, you're probably going to specify a height | 207 // image out of a CSS background, you're probably going to specify a height |
| 208 // or a width. On the other hand, if we've got a legit background image, | 208 // or a width. On the other hand, if we've got a legit background image, |
| 209 // it's very likely the height or the width will be set to auto. | 209 // it's very likely the height or the width will be set to auto. |
| 210 LayoutObject* layoutObject = node->layoutObject(); | 210 LayoutObject* layoutObject = node->layoutObject(); |
| 211 if (layoutObject && (layoutObject->style()->logicalHeight().isAuto() || layo
utObject->style()->logicalWidth().isAuto())) | 211 if (layoutObject && (layoutObject->style()->logicalHeight().isAuto() || layo
utObject->style()->logicalWidth().isAuto())) |
| 212 return true; | 212 return true; |
| 213 | 213 |
| 214 return false; | 214 return false; |
| 215 } | 215 } |
| 216 | 216 |
| 217 void SmartClip::collectOverlappingChildNodes(Node* parentNode, const IntRect& cr
opRectInViewport, WillBeHeapVector<RawPtrWillBeMember<Node>>& hitNodes) | 217 void SmartClip::collectOverlappingChildNodes(Node* parentNode, const IntRect& cr
opRectInViewport, HeapVector<Member<Node>>& hitNodes) |
| 218 { | 218 { |
| 219 if (!parentNode) | 219 if (!parentNode) |
| 220 return; | 220 return; |
| 221 IntRect resizedCropRect = convertToContentCoordinatesWithoutCollapsingToZero
(cropRectInViewport, parentNode->document().view()); | 221 IntRect resizedCropRect = convertToContentCoordinatesWithoutCollapsingToZero
(cropRectInViewport, parentNode->document().view()); |
| 222 for (Node* child = parentNode->firstChild(); child; child = child->nextSibli
ng()) { | 222 for (Node* child = parentNode->firstChild(); child; child = child->nextSibli
ng()) { |
| 223 IntRect childRect = child->pixelSnappedBoundingBox(); | 223 IntRect childRect = child->pixelSnappedBoundingBox(); |
| 224 if (resizedCropRect.intersects(childRect)) | 224 if (resizedCropRect.intersects(childRect)) |
| 225 hitNodes.append(child); | 225 hitNodes.append(child); |
| 226 } | 226 } |
| 227 } | 227 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 257 | 257 |
| 258 result.append(nodeValue); | 258 result.append(nodeValue); |
| 259 } | 259 } |
| 260 } | 260 } |
| 261 } | 261 } |
| 262 | 262 |
| 263 return result.toString(); | 263 return result.toString(); |
| 264 } | 264 } |
| 265 | 265 |
| 266 } // namespace blink | 266 } // namespace blink |
| OLD | NEW |