OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2008, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2008, 2011 Apple Inc. All rights reserved. |
3 * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies) |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 | 105 |
106 // Only copy the NodeSet in case of rect hit test. | 106 // Only copy the NodeSet in case of rect hit test. |
107 m_rectBasedTestResult = adoptPtr(other.m_rectBasedTestResult ? new NodeSet(*
other.m_rectBasedTestResult) : 0); | 107 m_rectBasedTestResult = adoptPtr(other.m_rectBasedTestResult ? new NodeSet(*
other.m_rectBasedTestResult) : 0); |
108 | 108 |
109 return *this; | 109 return *this; |
110 } | 110 } |
111 | 111 |
112 void HitTestResult::setToNodesInDocumentTreeScope() | 112 void HitTestResult::setToNodesInDocumentTreeScope() |
113 { | 113 { |
114 if (Node* node = innerNode()) { | 114 if (Node* node = innerNode()) { |
115 node = node->document()->ancestorInThisScope(node); | 115 node = node->document().ancestorInThisScope(node); |
116 setInnerNode(node); | 116 setInnerNode(node); |
117 } | 117 } |
118 | 118 |
119 if (Node* node = innerNonSharedNode()) { | 119 if (Node* node = innerNonSharedNode()) { |
120 node = node->document()->ancestorInThisScope(node); | 120 node = node->document().ancestorInThisScope(node); |
121 setInnerNonSharedNode(node); | 121 setInnerNonSharedNode(node); |
122 } | 122 } |
123 } | 123 } |
124 | 124 |
125 void HitTestResult::setToShadowHostIfInUserAgentShadowRoot() | 125 void HitTestResult::setToShadowHostIfInUserAgentShadowRoot() |
126 { | 126 { |
127 if (Node* node = innerNode()) { | 127 if (Node* node = innerNode()) { |
128 if (ShadowRoot* containingShadowRoot = node->containingShadowRoot()) { | 128 if (ShadowRoot* containingShadowRoot = node->containingShadowRoot()) { |
129 if (containingShadowRoot->type() == ShadowRoot::UserAgentShadowRoot) | 129 if (containingShadowRoot->type() == ShadowRoot::UserAgentShadowRoot) |
130 setInnerNode(node->shadowHost()); | 130 setInnerNode(node->shadowHost()); |
(...skipping 28 matching lines...) Expand all Loading... |
159 } | 159 } |
160 | 160 |
161 void HitTestResult::setScrollbar(Scrollbar* s) | 161 void HitTestResult::setScrollbar(Scrollbar* s) |
162 { | 162 { |
163 m_scrollbar = s; | 163 m_scrollbar = s; |
164 } | 164 } |
165 | 165 |
166 Frame* HitTestResult::innerNodeFrame() const | 166 Frame* HitTestResult::innerNodeFrame() const |
167 { | 167 { |
168 if (m_innerNonSharedNode) | 168 if (m_innerNonSharedNode) |
169 return m_innerNonSharedNode->document()->frame(); | 169 return m_innerNonSharedNode->document().frame(); |
170 if (m_innerNode) | 170 if (m_innerNode) |
171 return m_innerNode->document()->frame(); | 171 return m_innerNode->document().frame(); |
172 return 0; | 172 return 0; |
173 } | 173 } |
174 | 174 |
175 Frame* HitTestResult::targetFrame() const | 175 Frame* HitTestResult::targetFrame() const |
176 { | 176 { |
177 if (!m_innerURLElement) | 177 if (!m_innerURLElement) |
178 return 0; | 178 return 0; |
179 | 179 |
180 Frame* frame = m_innerURLElement->document()->frame(); | 180 Frame* frame = m_innerURLElement->document().frame(); |
181 if (!frame) | 181 if (!frame) |
182 return 0; | 182 return 0; |
183 | 183 |
184 return frame->tree()->find(m_innerURLElement->target()); | 184 return frame->tree()->find(m_innerURLElement->target()); |
185 } | 185 } |
186 | 186 |
187 bool HitTestResult::isSelected() const | 187 bool HitTestResult::isSelected() const |
188 { | 188 { |
189 if (!m_innerNonSharedNode) | 189 if (!m_innerNonSharedNode) |
190 return false; | 190 return false; |
191 | 191 |
192 Frame* frame = m_innerNonSharedNode->document()->frame(); | 192 Frame* frame = m_innerNonSharedNode->document().frame(); |
193 if (!frame) | 193 if (!frame) |
194 return false; | 194 return false; |
195 | 195 |
196 return frame->selection()->contains(m_hitTestLocation.point()); | 196 return frame->selection()->contains(m_hitTestLocation.point()); |
197 } | 197 } |
198 | 198 |
199 String HitTestResult::spellingToolTip(TextDirection& dir) const | 199 String HitTestResult::spellingToolTip(TextDirection& dir) const |
200 { | 200 { |
201 dir = LTR; | 201 dir = LTR; |
202 // Return the tool tip string associated with this point, if any. Only marke
rs associated with bad grammar | 202 // Return the tool tip string associated with this point, if any. Only marke
rs associated with bad grammar |
203 // currently supply strings, but maybe someday markers associated with missp
elled words will also. | 203 // currently supply strings, but maybe someday markers associated with missp
elled words will also. |
204 if (!m_innerNonSharedNode) | 204 if (!m_innerNonSharedNode) |
205 return String(); | 205 return String(); |
206 | 206 |
207 DocumentMarker* marker = m_innerNonSharedNode->document()->markers()->marker
ContainingPoint(m_hitTestLocation.point(), DocumentMarker::Grammar); | 207 DocumentMarker* marker = m_innerNonSharedNode->document().markers()->markerC
ontainingPoint(m_hitTestLocation.point(), DocumentMarker::Grammar); |
208 if (!marker) | 208 if (!marker) |
209 return String(); | 209 return String(); |
210 | 210 |
211 if (RenderObject* renderer = m_innerNonSharedNode->renderer()) | 211 if (RenderObject* renderer = m_innerNonSharedNode->renderer()) |
212 dir = renderer->style()->direction(); | 212 dir = renderer->style()->direction(); |
213 return marker->description(); | 213 return marker->description(); |
214 } | 214 } |
215 | 215 |
216 String HitTestResult::title(TextDirection& dir) const | 216 String HitTestResult::title(TextDirection& dir) const |
217 { | 217 { |
(...skipping 10 matching lines...) Expand all Loading... |
228 } | 228 } |
229 } | 229 } |
230 } | 230 } |
231 return String(); | 231 return String(); |
232 } | 232 } |
233 | 233 |
234 String displayString(const String& string, const Node* node) | 234 String displayString(const String& string, const Node* node) |
235 { | 235 { |
236 if (!node) | 236 if (!node) |
237 return string; | 237 return string; |
238 return node->document()->displayStringModifiedByEncoding(string); | 238 return node->document().displayStringModifiedByEncoding(string); |
239 } | 239 } |
240 | 240 |
241 String HitTestResult::altDisplayString() const | 241 String HitTestResult::altDisplayString() const |
242 { | 242 { |
243 if (!m_innerNonSharedNode) | 243 if (!m_innerNonSharedNode) |
244 return String(); | 244 return String(); |
245 | 245 |
246 if (m_innerNonSharedNode->hasTagName(imgTag)) { | 246 if (m_innerNonSharedNode->hasTagName(imgTag)) { |
247 HTMLImageElement* image = toHTMLImageElement(m_innerNonSharedNode.get())
; | 247 HTMLImageElement* image = toHTMLImageElement(m_innerNonSharedNode.get())
; |
248 return displayString(image->getAttribute(altAttr), m_innerNonSharedNode.
get()); | 248 return displayString(image->getAttribute(altAttr), m_innerNonSharedNode.
get()); |
(...skipping 24 matching lines...) Expand all Loading... |
273 | 273 |
274 IntRect HitTestResult::imageRect() const | 274 IntRect HitTestResult::imageRect() const |
275 { | 275 { |
276 if (!image()) | 276 if (!image()) |
277 return IntRect(); | 277 return IntRect(); |
278 return m_innerNonSharedNode->renderBox()->absoluteContentQuad().enclosingBou
ndingBox(); | 278 return m_innerNonSharedNode->renderBox()->absoluteContentQuad().enclosingBou
ndingBox(); |
279 } | 279 } |
280 | 280 |
281 KURL HitTestResult::absoluteImageURL() const | 281 KURL HitTestResult::absoluteImageURL() const |
282 { | 282 { |
283 if (!(m_innerNonSharedNode && m_innerNonSharedNode->document())) | 283 if (!m_innerNonSharedNode) |
284 return KURL(); | 284 return KURL(); |
285 | 285 |
286 if (!(m_innerNonSharedNode->renderer() && m_innerNonSharedNode->renderer()->
isImage())) | 286 if (!(m_innerNonSharedNode->renderer() && m_innerNonSharedNode->renderer()->
isImage())) |
287 return KURL(); | 287 return KURL(); |
288 | 288 |
289 AtomicString urlString; | 289 AtomicString urlString; |
290 if (m_innerNonSharedNode->hasTagName(embedTag) | 290 if (m_innerNonSharedNode->hasTagName(embedTag) |
291 || m_innerNonSharedNode->hasTagName(imgTag) | 291 || m_innerNonSharedNode->hasTagName(imgTag) |
292 || m_innerNonSharedNode->hasTagName(inputTag) | 292 || m_innerNonSharedNode->hasTagName(inputTag) |
293 || m_innerNonSharedNode->hasTagName(objectTag) | 293 || m_innerNonSharedNode->hasTagName(objectTag) |
294 || m_innerNonSharedNode->hasTagName(SVGNames::imageTag) | 294 || m_innerNonSharedNode->hasTagName(SVGNames::imageTag) |
295 ) { | 295 ) { |
296 Element* element = toElement(m_innerNonSharedNode.get()); | 296 Element* element = toElement(m_innerNonSharedNode.get()); |
297 urlString = element->imageSourceURL(); | 297 urlString = element->imageSourceURL(); |
298 } else | 298 } else |
299 return KURL(); | 299 return KURL(); |
300 | 300 |
301 return m_innerNonSharedNode->document()->completeURL(stripLeadingAndTrailing
HTMLSpaces(urlString)); | 301 return m_innerNonSharedNode->document().completeURL(stripLeadingAndTrailingH
TMLSpaces(urlString)); |
302 } | 302 } |
303 | 303 |
304 KURL HitTestResult::absoluteMediaURL() const | 304 KURL HitTestResult::absoluteMediaURL() const |
305 { | 305 { |
306 if (HTMLMediaElement* mediaElt = mediaElement()) | 306 if (HTMLMediaElement* mediaElt = mediaElement()) |
307 return mediaElt->currentSrc(); | 307 return mediaElt->currentSrc(); |
308 return KURL(); | 308 return KURL(); |
309 } | 309 } |
310 | 310 |
311 HTMLMediaElement* HitTestResult::mediaElement() const | 311 HTMLMediaElement* HitTestResult::mediaElement() const |
312 { | 312 { |
313 if (!(m_innerNonSharedNode && m_innerNonSharedNode->document())) | 313 if (!m_innerNonSharedNode) |
314 return 0; | 314 return 0; |
315 | 315 |
316 if (!(m_innerNonSharedNode->renderer() && m_innerNonSharedNode->renderer()->
isMedia())) | 316 if (!(m_innerNonSharedNode->renderer() && m_innerNonSharedNode->renderer()->
isMedia())) |
317 return 0; | 317 return 0; |
318 | 318 |
319 if (isHTMLVideoElement(m_innerNonSharedNode.get()) || m_innerNonSharedNode->
hasTagName(HTMLNames::audioTag)) | 319 if (isHTMLVideoElement(m_innerNonSharedNode.get()) || m_innerNonSharedNode->
hasTagName(HTMLNames::audioTag)) |
320 return toHTMLMediaElement(m_innerNonSharedNode.get()); | 320 return toHTMLMediaElement(m_innerNonSharedNode.get()); |
321 return 0; | 321 return 0; |
322 } | 322 } |
323 | 323 |
324 KURL HitTestResult::absoluteLinkURL() const | 324 KURL HitTestResult::absoluteLinkURL() const |
325 { | 325 { |
326 if (!(m_innerURLElement && m_innerURLElement->document())) | 326 if (!m_innerURLElement) |
327 return KURL(); | 327 return KURL(); |
328 | 328 |
329 AtomicString urlString; | 329 AtomicString urlString; |
330 if (isHTMLAnchorElement(m_innerURLElement.get()) || isHTMLAreaElement(m_inne
rURLElement.get()) || m_innerURLElement->hasTagName(linkTag)) | 330 if (isHTMLAnchorElement(m_innerURLElement.get()) || isHTMLAreaElement(m_inne
rURLElement.get()) || m_innerURLElement->hasTagName(linkTag)) |
331 urlString = m_innerURLElement->getAttribute(hrefAttr); | 331 urlString = m_innerURLElement->getAttribute(hrefAttr); |
332 else if (m_innerURLElement->hasTagName(SVGNames::aTag)) | 332 else if (m_innerURLElement->hasTagName(SVGNames::aTag)) |
333 urlString = m_innerURLElement->getAttribute(XLinkNames::hrefAttr); | 333 urlString = m_innerURLElement->getAttribute(XLinkNames::hrefAttr); |
334 else | 334 else |
335 return KURL(); | 335 return KURL(); |
336 | 336 |
337 return m_innerURLElement->document()->completeURL(stripLeadingAndTrailingHTM
LSpaces(urlString)); | 337 return m_innerURLElement->document().completeURL(stripLeadingAndTrailingHTML
Spaces(urlString)); |
338 } | 338 } |
339 | 339 |
340 bool HitTestResult::isLiveLink() const | 340 bool HitTestResult::isLiveLink() const |
341 { | 341 { |
342 if (!(m_innerURLElement && m_innerURLElement->document())) | 342 if (!m_innerURLElement) |
343 return false; | 343 return false; |
344 | 344 |
345 if (isHTMLAnchorElement(m_innerURLElement.get())) | 345 if (isHTMLAnchorElement(m_innerURLElement.get())) |
346 return toHTMLAnchorElement(m_innerURLElement.get())->isLiveLink(); | 346 return toHTMLAnchorElement(m_innerURLElement.get())->isLiveLink(); |
347 | 347 |
348 if (m_innerURLElement->hasTagName(SVGNames::aTag)) | 348 if (m_innerURLElement->hasTagName(SVGNames::aTag)) |
349 return m_innerURLElement->isLink(); | 349 return m_innerURLElement->isLink(); |
350 | 350 |
351 return false; | 351 return false; |
352 } | 352 } |
353 | 353 |
354 bool HitTestResult::isMisspelled() const | 354 bool HitTestResult::isMisspelled() const |
355 { | 355 { |
356 if (!targetNode()) | 356 if (!targetNode()) |
357 return false; | 357 return false; |
358 VisiblePosition pos(targetNode()->renderer()->positionForPoint(localPoint())
); | 358 VisiblePosition pos(targetNode()->renderer()->positionForPoint(localPoint())
); |
359 if (pos.isNull()) | 359 if (pos.isNull()) |
360 return false; | 360 return false; |
361 return m_innerNonSharedNode->document()->markers()->markersInRange( | 361 return m_innerNonSharedNode->document().markers()->markersInRange( |
362 makeRange(pos, pos).get(), DocumentMarker::Spelling | DocumentMarker::Gr
ammar).size() > 0; | 362 makeRange(pos, pos).get(), DocumentMarker::Spelling | DocumentMarker::Gr
ammar).size() > 0; |
363 } | 363 } |
364 | 364 |
365 String HitTestResult::titleDisplayString() const | 365 String HitTestResult::titleDisplayString() const |
366 { | 366 { |
367 if (!m_innerURLElement) | 367 if (!m_innerURLElement) |
368 return String(); | 368 return String(); |
369 | 369 |
370 return displayString(m_innerURLElement->title(), m_innerURLElement.get()); | 370 return displayString(m_innerURLElement->title(), m_innerURLElement.get()); |
371 } | 371 } |
(...skipping 28 matching lines...) Expand all Loading... |
400 // If it is not a rect-based hit test, this method has to be no-op. | 400 // If it is not a rect-based hit test, this method has to be no-op. |
401 // Return false, so the hit test stops. | 401 // Return false, so the hit test stops. |
402 if (!isRectBasedTest()) | 402 if (!isRectBasedTest()) |
403 return false; | 403 return false; |
404 | 404 |
405 // If node is null, return true so the hit test can continue. | 405 // If node is null, return true so the hit test can continue. |
406 if (!node) | 406 if (!node) |
407 return true; | 407 return true; |
408 | 408 |
409 if (request.disallowsShadowContent()) | 409 if (request.disallowsShadowContent()) |
410 node = node->document()->ancestorInThisScope(node); | 410 node = node->document().ancestorInThisScope(node); |
411 | 411 |
412 mutableRectBasedTestResult().add(node); | 412 mutableRectBasedTestResult().add(node); |
413 | 413 |
414 bool regionFilled = rect.contains(locationInContainer.boundingBox()); | 414 bool regionFilled = rect.contains(locationInContainer.boundingBox()); |
415 return !regionFilled; | 415 return !regionFilled; |
416 } | 416 } |
417 | 417 |
418 bool HitTestResult::addNodeToRectBasedTestResult(Node* node, const HitTestReques
t& request, const HitTestLocation& locationInContainer, const FloatRect& rect) | 418 bool HitTestResult::addNodeToRectBasedTestResult(Node* node, const HitTestReques
t& request, const HitTestLocation& locationInContainer, const FloatRect& rect) |
419 { | 419 { |
420 // If it is not a rect-based hit test, this method has to be no-op. | 420 // If it is not a rect-based hit test, this method has to be no-op. |
421 // Return false, so the hit test stops. | 421 // Return false, so the hit test stops. |
422 if (!isRectBasedTest()) | 422 if (!isRectBasedTest()) |
423 return false; | 423 return false; |
424 | 424 |
425 // If node is null, return true so the hit test can continue. | 425 // If node is null, return true so the hit test can continue. |
426 if (!node) | 426 if (!node) |
427 return true; | 427 return true; |
428 | 428 |
429 if (request.disallowsShadowContent()) | 429 if (request.disallowsShadowContent()) |
430 node = node->document()->ancestorInThisScope(node); | 430 node = node->document().ancestorInThisScope(node); |
431 | 431 |
432 mutableRectBasedTestResult().add(node); | 432 mutableRectBasedTestResult().add(node); |
433 | 433 |
434 bool regionFilled = rect.contains(locationInContainer.boundingBox()); | 434 bool regionFilled = rect.contains(locationInContainer.boundingBox()); |
435 return !regionFilled; | 435 return !regionFilled; |
436 } | 436 } |
437 | 437 |
438 void HitTestResult::append(const HitTestResult& other) | 438 void HitTestResult::append(const HitTestResult& other) |
439 { | 439 { |
440 ASSERT(isRectBasedTest() && other.isRectBasedTest()); | 440 ASSERT(isRectBasedTest() && other.isRectBasedTest()); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 Element* HitTestResult::innerElement() const | 488 Element* HitTestResult::innerElement() const |
489 { | 489 { |
490 for (Node* node = m_innerNode.get(); node; node = NodeRenderingTraversal::pa
rent(node)) | 490 for (Node* node = m_innerNode.get(); node; node = NodeRenderingTraversal::pa
rent(node)) |
491 if (node->isElementNode()) | 491 if (node->isElementNode()) |
492 return toElement(node); | 492 return toElement(node); |
493 | 493 |
494 return 0; | 494 return 0; |
495 } | 495 } |
496 | 496 |
497 } // namespace WebCore | 497 } // namespace WebCore |
OLD | NEW |