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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 | 63 |
64 // FIXME: SmartClipData is eventually returned via | 64 // FIXME: SmartClipData is eventually returned via |
65 // SLookSmartClip.DataExtractionListener: | 65 // SLookSmartClip.DataExtractionListener: |
66 // http://img-developer.samsung.com/onlinedocs/sms/com/samsung/android/sdk/look/
... | 66 // http://img-developer.samsung.com/onlinedocs/sms/com/samsung/android/sdk/look/
... |
67 // however the original author of this change chose to use a string-serializatio
n | 67 // however the original author of this change chose to use a string-serializatio
n |
68 // format (presumably to make IPC easy?). | 68 // format (presumably to make IPC easy?). |
69 // If we're going to use this as a Pickle format, we should at least have the | 69 // If we're going to use this as a Pickle format, we should at least have the |
70 // read/write code in one place! | 70 // read/write code in one place! |
71 String SmartClipData::toString() | 71 String SmartClipData::toString() |
72 { | 72 { |
73 if (!m_node) | 73 if (m_isEmpty) |
74 return emptyString(); | 74 return emptyString(); |
75 | 75 |
76 const UChar fieldSeparator = 0xFFFE; | 76 const UChar fieldSeparator = 0xFFFE; |
77 const UChar rowSeparator = 0xFFFF; | 77 const UChar rowSeparator = 0xFFFF; |
78 | 78 |
79 StringBuilder result; | 79 StringBuilder result; |
80 result.append(String::number(m_rect.x())); | 80 result.append(String::number(m_rect.x())); |
81 result.append(fieldSeparator); | 81 result.append(fieldSeparator); |
82 result.append(String::number(m_rect.y())); | 82 result.append(String::number(m_rect.y())); |
83 result.append(fieldSeparator); | 83 result.append(fieldSeparator); |
(...skipping 18 matching lines...) Expand all Loading... |
102 Node* bestNode = findBestOverlappingNode(m_frame->document(), resizedCropRec
t); | 102 Node* bestNode = findBestOverlappingNode(m_frame->document(), resizedCropRec
t); |
103 if (!bestNode) | 103 if (!bestNode) |
104 return SmartClipData(); | 104 return SmartClipData(); |
105 | 105 |
106 if (Node* nodeFromFrame = nodeInsideFrame(bestNode)) { | 106 if (Node* nodeFromFrame = nodeInsideFrame(bestNode)) { |
107 // FIXME: This code only hit-tests a single iframe. It seems like we oug
ht support nested frames. | 107 // FIXME: This code only hit-tests a single iframe. It seems like we oug
ht support nested frames. |
108 if (Node* bestNodeInFrame = findBestOverlappingNode(nodeFromFrame, resiz
edCropRect)) | 108 if (Node* bestNodeInFrame = findBestOverlappingNode(nodeFromFrame, resiz
edCropRect)) |
109 bestNode = bestNodeInFrame; | 109 bestNode = bestNodeInFrame; |
110 } | 110 } |
111 | 111 |
112 Vector<Node*> hitNodes; | 112 WillBeHeapVector<RawPtrWillBeMember<Node> > hitNodes; |
113 collectOverlappingChildNodes(bestNode, resizedCropRect, hitNodes); | 113 collectOverlappingChildNodes(bestNode, resizedCropRect, hitNodes); |
114 | 114 |
115 if (hitNodes.isEmpty() || hitNodes.size() == bestNode->countChildren()) { | 115 if (hitNodes.isEmpty() || hitNodes.size() == bestNode->countChildren()) { |
116 hitNodes.clear(); | 116 hitNodes.clear(); |
117 hitNodes.append(bestNode); | 117 hitNodes.append(bestNode); |
118 } | 118 } |
119 | 119 |
120 // Unite won't work with the empty rect, so we initialize to the first rect. | 120 // Unite won't work with the empty rect, so we initialize to the first rect. |
121 IntRect unitedRects = hitNodes[0]->pixelSnappedBoundingBox(); | 121 IntRect unitedRects = hitNodes[0]->pixelSnappedBoundingBox(); |
122 StringBuilder collectedText; | 122 StringBuilder collectedText; |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 // image out of a CSS background, you're probably going to specify a height | 230 // image out of a CSS background, you're probably going to specify a height |
231 // or a width. On the other hand, if we've got a legit background image, | 231 // or a width. On the other hand, if we've got a legit background image, |
232 // it's very likely the height or the width will be set to auto. | 232 // it's very likely the height or the width will be set to auto. |
233 RenderObject* renderer = node->renderer(); | 233 RenderObject* renderer = node->renderer(); |
234 if (renderer && (renderer->style()->logicalHeight().isAuto() || renderer->st
yle()->logicalWidth().isAuto())) | 234 if (renderer && (renderer->style()->logicalHeight().isAuto() || renderer->st
yle()->logicalWidth().isAuto())) |
235 return true; | 235 return true; |
236 | 236 |
237 return false; | 237 return false; |
238 } | 238 } |
239 | 239 |
240 void SmartClip::collectOverlappingChildNodes(Node* parentNode, const IntRect& cr
opRect, Vector<Node*>& hitNodes) | 240 void SmartClip::collectOverlappingChildNodes(Node* parentNode, const IntRect& cr
opRect, WillBeHeapVector<RawPtrWillBeMember<Node> >& hitNodes) |
241 { | 241 { |
242 if (!parentNode) | 242 if (!parentNode) |
243 return; | 243 return; |
244 IntRect resizedCropRect = parentNode->document().view()->windowToContents(cr
opRect); | 244 IntRect resizedCropRect = parentNode->document().view()->windowToContents(cr
opRect); |
245 for (Node* child = parentNode->firstChild(); child; child = child->nextSibli
ng()) { | 245 for (Node* child = parentNode->firstChild(); child; child = child->nextSibli
ng()) { |
246 IntRect childRect = child->pixelSnappedBoundingBox(); | 246 IntRect childRect = child->pixelSnappedBoundingBox(); |
247 if (resizedCropRect.intersects(childRect)) | 247 if (resizedCropRect.intersects(childRect)) |
248 hitNodes.append(child); | 248 hitNodes.append(child); |
249 } | 249 } |
250 } | 250 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 | 287 |
288 result.append(nodeValue); | 288 result.append(nodeValue); |
289 } | 289 } |
290 } | 290 } |
291 } | 291 } |
292 | 292 |
293 return result.toString(); | 293 return result.toString(); |
294 } | 294 } |
295 | 295 |
296 } // namespace WebCore | 296 } // namespace WebCore |
OLD | NEW |