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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 visitor->trace(m_scrollbar); | 118 visitor->trace(m_scrollbar); |
119 #if ENABLE(OILPAN) | 119 #if ENABLE(OILPAN) |
120 visitor->trace(m_listBasedTestResult); | 120 visitor->trace(m_listBasedTestResult); |
121 #endif | 121 #endif |
122 } | 122 } |
123 | 123 |
124 PositionWithAffinity HitTestResult::position() const | 124 PositionWithAffinity HitTestResult::position() const |
125 { | 125 { |
126 if (!m_innerPossiblyPseudoNode) | 126 if (!m_innerPossiblyPseudoNode) |
127 return PositionWithAffinity(); | 127 return PositionWithAffinity(); |
128 LayoutObject* renderer = this->renderer(); | 128 LayoutObject* renderer = this->layoutObject(); |
129 if (!renderer) | 129 if (!renderer) |
130 return PositionWithAffinity(); | 130 return PositionWithAffinity(); |
131 if (m_innerPossiblyPseudoNode->isPseudoElement() && m_innerPossiblyPseudoNod
e->pseudoId() == BEFORE) | 131 if (m_innerPossiblyPseudoNode->isPseudoElement() && m_innerPossiblyPseudoNod
e->pseudoId() == BEFORE) |
132 return Position(m_innerNode, Position::PositionIsBeforeChildren).downstr
eam(); | 132 return Position(m_innerNode, Position::PositionIsBeforeChildren).downstr
eam(); |
133 return renderer->positionForPoint(localPoint()); | 133 return renderer->positionForPoint(localPoint()); |
134 } | 134 } |
135 | 135 |
136 LayoutObject* HitTestResult::renderer() const | 136 LayoutObject* HitTestResult::layoutObject() const |
137 { | 137 { |
138 return m_innerNode ? m_innerNode->renderer() : 0; | 138 return m_innerNode ? m_innerNode->layoutObject() : 0; |
139 } | 139 } |
140 | 140 |
141 void HitTestResult::setToShadowHostIfInClosedShadowRoot() | 141 void HitTestResult::setToShadowHostIfInClosedShadowRoot() |
142 { | 142 { |
143 if (Node* node = innerNode()) { | 143 if (Node* node = innerNode()) { |
144 if (ShadowRoot* containingShadowRoot = node->containingShadowRoot()) { | 144 if (ShadowRoot* containingShadowRoot = node->containingShadowRoot()) { |
145 if (containingShadowRoot->type() == ShadowRoot::ClosedShadowRoot) | 145 if (containingShadowRoot->type() == ShadowRoot::ClosedShadowRoot) |
146 setInnerNode(node->shadowHost()); | 146 setInnerNode(node->shadowHost()); |
147 } | 147 } |
148 } | 148 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 dir = LTR; | 204 dir = LTR; |
205 // Return the tool tip string associated with this point, if any. Only marke
rs associated with bad grammar | 205 // Return the tool tip string associated with this point, if any. Only marke
rs associated with bad grammar |
206 // currently supply strings, but maybe someday markers associated with missp
elled words will also. | 206 // currently supply strings, but maybe someday markers associated with missp
elled words will also. |
207 if (!m_innerNonSharedNode) | 207 if (!m_innerNonSharedNode) |
208 return String(); | 208 return String(); |
209 | 209 |
210 DocumentMarker* marker = m_innerNonSharedNode->document().markers().markerCo
ntainingPoint(m_hitTestLocation.point(), DocumentMarker::Grammar); | 210 DocumentMarker* marker = m_innerNonSharedNode->document().markers().markerCo
ntainingPoint(m_hitTestLocation.point(), DocumentMarker::Grammar); |
211 if (!marker) | 211 if (!marker) |
212 return String(); | 212 return String(); |
213 | 213 |
214 if (LayoutObject* renderer = m_innerNonSharedNode->renderer()) | 214 if (LayoutObject* renderer = m_innerNonSharedNode->layoutObject()) |
215 dir = renderer->style()->direction(); | 215 dir = renderer->style()->direction(); |
216 return marker->description(); | 216 return marker->description(); |
217 } | 217 } |
218 | 218 |
219 String HitTestResult::title(TextDirection& dir) const | 219 String HitTestResult::title(TextDirection& dir) const |
220 { | 220 { |
221 dir = LTR; | 221 dir = LTR; |
222 // Find the title in the nearest enclosing DOM node. | 222 // Find the title in the nearest enclosing DOM node. |
223 // For <area> tags in image maps, walk the tree for the <area>, not the <img
> using it. | 223 // For <area> tags in image maps, walk the tree for the <area>, not the <img
> using it. |
224 for (Node* titleNode = m_innerNode.get(); titleNode; titleNode = ComposedTre
eTraversal::parent(*titleNode)) { | 224 for (Node* titleNode = m_innerNode.get(); titleNode; titleNode = ComposedTre
eTraversal::parent(*titleNode)) { |
225 if (titleNode->isElementNode()) { | 225 if (titleNode->isElementNode()) { |
226 String title = toElement(titleNode)->title(); | 226 String title = toElement(titleNode)->title(); |
227 if (!title.isNull()) { | 227 if (!title.isNull()) { |
228 if (LayoutObject* renderer = titleNode->renderer()) | 228 if (LayoutObject* renderer = titleNode->layoutObject()) |
229 dir = renderer->style()->direction(); | 229 dir = renderer->style()->direction(); |
230 return title; | 230 return title; |
231 } | 231 } |
232 } | 232 } |
233 } | 233 } |
234 return String(); | 234 return String(); |
235 } | 235 } |
236 | 236 |
237 const AtomicString& HitTestResult::altDisplayString() const | 237 const AtomicString& HitTestResult::altDisplayString() const |
238 { | 238 { |
(...skipping 11 matching lines...) Expand all Loading... |
250 } | 250 } |
251 | 251 |
252 return nullAtom; | 252 return nullAtom; |
253 } | 253 } |
254 | 254 |
255 Image* HitTestResult::image() const | 255 Image* HitTestResult::image() const |
256 { | 256 { |
257 if (!m_innerNonSharedNode) | 257 if (!m_innerNonSharedNode) |
258 return 0; | 258 return 0; |
259 | 259 |
260 LayoutObject* renderer = m_innerNonSharedNode->renderer(); | 260 LayoutObject* renderer = m_innerNonSharedNode->layoutObject(); |
261 if (renderer && renderer->isImage()) { | 261 if (renderer && renderer->isImage()) { |
262 LayoutImage* image = toLayoutImage(renderer); | 262 LayoutImage* image = toLayoutImage(renderer); |
263 if (image->cachedImage() && !image->cachedImage()->errorOccurred()) | 263 if (image->cachedImage() && !image->cachedImage()->errorOccurred()) |
264 return image->cachedImage()->imageForRenderer(image); | 264 return image->cachedImage()->imageForRenderer(image); |
265 } | 265 } |
266 | 266 |
267 return 0; | 267 return 0; |
268 } | 268 } |
269 | 269 |
270 IntRect HitTestResult::imageRect() const | 270 IntRect HitTestResult::imageRect() const |
271 { | 271 { |
272 if (!image()) | 272 if (!image()) |
273 return IntRect(); | 273 return IntRect(); |
274 return m_innerNonSharedNode->layoutBox()->absoluteContentQuad().enclosingBou
ndingBox(); | 274 return m_innerNonSharedNode->layoutBox()->absoluteContentQuad().enclosingBou
ndingBox(); |
275 } | 275 } |
276 | 276 |
277 KURL HitTestResult::absoluteImageURL() const | 277 KURL HitTestResult::absoluteImageURL() const |
278 { | 278 { |
279 if (!m_innerNonSharedNode) | 279 if (!m_innerNonSharedNode) |
280 return KURL(); | 280 return KURL(); |
281 | 281 |
282 LayoutObject* renderer = m_innerNonSharedNode->renderer(); | 282 LayoutObject* renderer = m_innerNonSharedNode->layoutObject(); |
283 if (!(renderer && renderer->isImage())) | 283 if (!(renderer && renderer->isImage())) |
284 return KURL(); | 284 return KURL(); |
285 | 285 |
286 AtomicString urlString; | 286 AtomicString urlString; |
287 if (isHTMLEmbedElement(*m_innerNonSharedNode) | 287 if (isHTMLEmbedElement(*m_innerNonSharedNode) |
288 || isHTMLImageElement(*m_innerNonSharedNode) | 288 || isHTMLImageElement(*m_innerNonSharedNode) |
289 || isHTMLInputElement(*m_innerNonSharedNode) | 289 || isHTMLInputElement(*m_innerNonSharedNode) |
290 || isHTMLObjectElement(*m_innerNonSharedNode) | 290 || isHTMLObjectElement(*m_innerNonSharedNode) |
291 || isSVGImageElement(*m_innerNonSharedNode)) { | 291 || isSVGImageElement(*m_innerNonSharedNode)) { |
292 urlString = toElement(*m_innerNonSharedNode).imageSourceURL(); | 292 urlString = toElement(*m_innerNonSharedNode).imageSourceURL(); |
293 } else { | 293 } else { |
294 return KURL(); | 294 return KURL(); |
295 } | 295 } |
296 | 296 |
297 return m_innerNonSharedNode->document().completeURL(stripLeadingAndTrailingH
TMLSpaces(urlString)); | 297 return m_innerNonSharedNode->document().completeURL(stripLeadingAndTrailingH
TMLSpaces(urlString)); |
298 } | 298 } |
299 | 299 |
300 KURL HitTestResult::absoluteMediaURL() const | 300 KURL HitTestResult::absoluteMediaURL() const |
301 { | 301 { |
302 if (HTMLMediaElement* mediaElt = mediaElement()) | 302 if (HTMLMediaElement* mediaElt = mediaElement()) |
303 return mediaElt->currentSrc(); | 303 return mediaElt->currentSrc(); |
304 return KURL(); | 304 return KURL(); |
305 } | 305 } |
306 | 306 |
307 HTMLMediaElement* HitTestResult::mediaElement() const | 307 HTMLMediaElement* HitTestResult::mediaElement() const |
308 { | 308 { |
309 if (!m_innerNonSharedNode) | 309 if (!m_innerNonSharedNode) |
310 return 0; | 310 return 0; |
311 | 311 |
312 if (!(m_innerNonSharedNode->renderer() && m_innerNonSharedNode->renderer()->
isMedia())) | 312 if (!(m_innerNonSharedNode->layoutObject() && m_innerNonSharedNode->layoutOb
ject()->isMedia())) |
313 return 0; | 313 return 0; |
314 | 314 |
315 if (isHTMLMediaElement(*m_innerNonSharedNode)) | 315 if (isHTMLMediaElement(*m_innerNonSharedNode)) |
316 return toHTMLMediaElement(m_innerNonSharedNode); | 316 return toHTMLMediaElement(m_innerNonSharedNode); |
317 return 0; | 317 return 0; |
318 } | 318 } |
319 | 319 |
320 KURL HitTestResult::absoluteLinkURL() const | 320 KURL HitTestResult::absoluteLinkURL() const |
321 { | 321 { |
322 if (!m_innerURLElement) | 322 if (!m_innerURLElement) |
323 return KURL(); | 323 return KURL(); |
324 return m_innerURLElement->hrefURL(); | 324 return m_innerURLElement->hrefURL(); |
325 } | 325 } |
326 | 326 |
327 bool HitTestResult::isLiveLink() const | 327 bool HitTestResult::isLiveLink() const |
328 { | 328 { |
329 return m_innerURLElement && m_innerURLElement->isLiveLink(); | 329 return m_innerURLElement && m_innerURLElement->isLiveLink(); |
330 } | 330 } |
331 | 331 |
332 bool HitTestResult::isMisspelled() const | 332 bool HitTestResult::isMisspelled() const |
333 { | 333 { |
334 if (!innerNode() || !innerNode()->renderer()) | 334 if (!innerNode() || !innerNode()->layoutObject()) |
335 return false; | 335 return false; |
336 VisiblePosition pos(innerNode()->renderer()->positionForPoint(localPoint()))
; | 336 VisiblePosition pos(innerNode()->layoutObject()->positionForPoint(localPoint
())); |
337 if (pos.isNull()) | 337 if (pos.isNull()) |
338 return false; | 338 return false; |
339 return m_innerNonSharedNode->document().markers().markersInRange( | 339 return m_innerNonSharedNode->document().markers().markersInRange( |
340 makeRange(pos, pos).get(), DocumentMarker::MisspellingMarkers()).size()
> 0; | 340 makeRange(pos, pos).get(), DocumentMarker::MisspellingMarkers()).size()
> 0; |
341 } | 341 } |
342 | 342 |
343 bool HitTestResult::isOverLink() const | 343 bool HitTestResult::isOverLink() const |
344 { | 344 { |
345 return m_innerURLElement && m_innerURLElement->isLink(); | 345 return m_innerURLElement && m_innerURLElement->isLink(); |
346 } | 346 } |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 m_hitTestLocation = HitTestLocation(resolvedPointInMainFrame); | 460 m_hitTestLocation = HitTestLocation(resolvedPointInMainFrame); |
461 m_pointInInnerNodeFrame = resolvedPointInMainFrame; | 461 m_pointInInnerNodeFrame = resolvedPointInMainFrame; |
462 m_innerNode = nullptr; | 462 m_innerNode = nullptr; |
463 m_innerNonSharedNode = nullptr; | 463 m_innerNonSharedNode = nullptr; |
464 m_innerPossiblyPseudoNode = nullptr; | 464 m_innerPossiblyPseudoNode = nullptr; |
465 m_listBasedTestResult = nullptr; | 465 m_listBasedTestResult = nullptr; |
466 | 466 |
467 // Update the HitTestResult as if the supplied node had been hit in normal p
oint-based hit-test. | 467 // Update the HitTestResult as if the supplied node had been hit in normal p
oint-based hit-test. |
468 // Note that we don't know the local point after a rect-based hit-test, but
we never use | 468 // Note that we don't know the local point after a rect-based hit-test, but
we never use |
469 // it so shouldn't bother with the cost of computing it. | 469 // it so shouldn't bother with the cost of computing it. |
470 resolvedInnerNode->renderer()->updateHitTestResult(*this, LayoutPoint()); | 470 resolvedInnerNode->layoutObject()->updateHitTestResult(*this, LayoutPoint())
; |
471 ASSERT(!isRectBasedTest()); | 471 ASSERT(!isRectBasedTest()); |
472 } | 472 } |
473 | 473 |
474 Element* HitTestResult::innerElement() const | 474 Element* HitTestResult::innerElement() const |
475 { | 475 { |
476 for (Node* node = m_innerNode.get(); node; node = NodeRenderingTraversal::pa
rent(*node)) { | 476 for (Node* node = m_innerNode.get(); node; node = NodeRenderingTraversal::pa
rent(*node)) { |
477 if (node->isElementNode()) | 477 if (node->isElementNode()) |
478 return toElement(node); | 478 return toElement(node); |
479 } | 479 } |
480 | 480 |
481 return 0; | 481 return 0; |
482 } | 482 } |
483 | 483 |
484 } // namespace blink | 484 } // namespace blink |
OLD | NEW |