| 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 { | 101 { |
| 102 m_hitTestLocation = other.m_hitTestLocation; | 102 m_hitTestLocation = other.m_hitTestLocation; |
| 103 m_hitTestRequest = other.m_hitTestRequest; | 103 m_hitTestRequest = other.m_hitTestRequest; |
| 104 m_innerNode = other.innerNode(); | 104 m_innerNode = other.innerNode(); |
| 105 m_innerPossiblyPseudoNode = other.innerPossiblyPseudoNode(); | 105 m_innerPossiblyPseudoNode = other.innerPossiblyPseudoNode(); |
| 106 m_pointInInnerNodeFrame = other.m_pointInInnerNodeFrame; | 106 m_pointInInnerNodeFrame = other.m_pointInInnerNodeFrame; |
| 107 m_localPoint = other.localPoint(); | 107 m_localPoint = other.localPoint(); |
| 108 m_innerURLElement = other.URLElement(); | 108 m_innerURLElement = other.URLElement(); |
| 109 m_scrollbar = other.scrollbar(); | 109 m_scrollbar = other.scrollbar(); |
| 110 m_isOverWidget = other.isOverWidget(); | 110 m_isOverWidget = other.isOverWidget(); |
| 111 m_validityRect = other.m_validityRect; |
| 111 | 112 |
| 112 // Only copy the NodeSet in case of list hit test. | 113 // Only copy the NodeSet in case of list hit test. |
| 113 m_listBasedTestResult = adoptPtrWillBeNoop(other.m_listBasedTestResult ? new
NodeSet(*other.m_listBasedTestResult) : 0); | 114 m_listBasedTestResult = adoptPtrWillBeNoop(other.m_listBasedTestResult ? new
NodeSet(*other.m_listBasedTestResult) : 0); |
| 114 | 115 |
| 115 return *this; | 116 return *this; |
| 116 } | 117 } |
| 117 | 118 |
| 119 bool HitTestResult::equalForCacheability(const HitTestResult& other) const |
| 120 { |
| 121 bool res = m_hitTestRequest.equalForCacheability(other.m_hitTestRequest) |
| 122 && m_innerNode == other.innerNode() |
| 123 && m_innerPossiblyPseudoNode == other.innerPossiblyPseudoNode() |
| 124 // && m_pointInInnerNodeFrame == other.m_pointInInnerNodeFrame |
| 125 // && m_localPoint == other.localPoint() |
| 126 && m_innerURLElement == other.URLElement() |
| 127 && m_scrollbar == other.scrollbar() |
| 128 && m_isOverWidget == other.isOverWidget(); |
| 129 // && m_listBasedTestResult == other.m_listBasedTestResult; |
| 130 |
| 131 if (!res) { |
| 132 WTF_LOG_ERROR("%d %d %d %d %d %d %d %d", m_hitTestRequest.equalForCachea
bility(other.m_hitTestRequest), |
| 133 m_innerNode == other.m_innerNode, |
| 134 m_innerPossiblyPseudoNode == other.m_innerPossiblyPseudoNode, |
| 135 m_pointInInnerNodeFrame == other.m_pointInInnerNodeFrame, |
| 136 m_localPoint == other.m_localPoint, |
| 137 m_innerURLElement == other.m_innerURLElement, |
| 138 m_scrollbar == other.m_scrollbar, |
| 139 m_isOverWidget == other.m_isOverWidget); |
| 140 } |
| 141 return res; |
| 142 } |
| 143 |
| 118 DEFINE_TRACE(HitTestResult) | 144 DEFINE_TRACE(HitTestResult) |
| 119 { | 145 { |
| 120 visitor->trace(m_innerNode); | 146 visitor->trace(m_innerNode); |
| 147 |
| 121 visitor->trace(m_innerPossiblyPseudoNode); | 148 visitor->trace(m_innerPossiblyPseudoNode); |
| 122 visitor->trace(m_innerURLElement); | 149 visitor->trace(m_innerURLElement); |
| 123 visitor->trace(m_scrollbar); | 150 visitor->trace(m_scrollbar); |
| 124 #if ENABLE(OILPAN) | 151 #if ENABLE(OILPAN) |
| 125 visitor->trace(m_listBasedTestResult); | 152 visitor->trace(m_listBasedTestResult); |
| 126 #endif | 153 #endif |
| 127 } | 154 } |
| 128 | 155 |
| 129 PositionWithAffinity HitTestResult::position() const | 156 PositionWithAffinity HitTestResult::position() const |
| 130 { | 157 { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 bool HitTestResult::isSelected() const | 239 bool HitTestResult::isSelected() const |
| 213 { | 240 { |
| 214 if (!m_innerNode) | 241 if (!m_innerNode) |
| 215 return false; | 242 return false; |
| 216 | 243 |
| 217 if (LocalFrame* frame = m_innerNode->document().frame()) | 244 if (LocalFrame* frame = m_innerNode->document().frame()) |
| 218 return frame->selection().contains(m_hitTestLocation.point()); | 245 return frame->selection().contains(m_hitTestLocation.point()); |
| 219 return false; | 246 return false; |
| 220 } | 247 } |
| 221 | 248 |
| 249 void HitTestResult::setValidityRect(const LayoutRect& rect) |
| 250 { |
| 251 ASSERT(!rect.isEmpty()); |
| 252 if (!rect.isEmpty()) |
| 253 m_validityRect = rect; |
| 254 } |
| 255 |
| 256 void HitTestResult::shrinkValidityRect(const LayoutRect& rect) |
| 257 { |
| 258 LayoutRect tempValidityRect = m_validityRect; |
| 259 if (rect.maxY() <= m_hitTestLocation.point().y() && rect.maxY() > tempValidi
tyRect.y()) { |
| 260 tempValidityRect.shiftYEdgeTo(rect.maxY()); |
| 261 } |
| 262 if (rect.y() > m_hitTestLocation.point().y() && rect.y() < tempValidityRect.
maxY()) { |
| 263 tempValidityRect.shiftMaxYEdgeTo(rect.y()); |
| 264 } |
| 265 if (rect.maxX() <= m_hitTestLocation.point().x() && rect.maxX() > tempValidi
tyRect.x()) { |
| 266 tempValidityRect.shiftXEdgeTo(rect.maxX()); |
| 267 } |
| 268 if (rect.x() > m_hitTestLocation.point().x() && rect.x() < tempValidityRect.
maxX()) { |
| 269 tempValidityRect.shiftMaxXEdgeTo(rect.x()); |
| 270 } |
| 271 |
| 272 if (!tempValidityRect.contains(m_hitTestLocation.point())) { |
| 273 tempValidityRect.show(false); |
| 274 rect.show(false); |
| 275 WTF_LOG_ERROR("Layout point %lf %lf", m_hitTestLocation.point().x().toDo
uble(), m_hitTestLocation.point().y().toDouble()); |
| 276 |
| 277 // ASSERT(false); |
| 278 return; |
| 279 } |
| 280 m_validityRect = tempValidityRect; |
| 281 } |
| 282 |
| 283 void HitTestResult::intersectValidityRect(const LayoutRect& rect) |
| 284 { |
| 285 LayoutRect tempValidityRect = m_validityRect; |
| 286 tempValidityRect.intersect(rect); |
| 287 if (!tempValidityRect.contains(m_hitTestLocation.point())) { |
| 288 tempValidityRect.show(false); |
| 289 m_validityRect.show(false); |
| 290 WTF_LOG_ERROR("Layout point %lf %lf", m_hitTestLocation.point().x().toDo
uble(), m_hitTestLocation.point().y().toDouble()); |
| 291 |
| 292 // ASSERT(false); |
| 293 return; |
| 294 } |
| 295 m_validityRect = tempValidityRect; |
| 296 } |
| 297 |
| 222 String HitTestResult::spellingToolTip(TextDirection& dir) const | 298 String HitTestResult::spellingToolTip(TextDirection& dir) const |
| 223 { | 299 { |
| 224 dir = LTR; | 300 dir = LTR; |
| 225 // Return the tool tip string associated with this point, if any. Only marke
rs associated with bad grammar | 301 // Return the tool tip string associated with this point, if any. Only marke
rs associated with bad grammar |
| 226 // currently supply strings, but maybe someday markers associated with missp
elled words will also. | 302 // currently supply strings, but maybe someday markers associated with missp
elled words will also. |
| 227 if (!m_innerNode) | 303 if (!m_innerNode) |
| 228 return String(); | 304 return String(); |
| 229 | 305 |
| 230 DocumentMarker* marker = m_innerNode->document().markers().markerContainingP
oint(m_hitTestLocation.point(), DocumentMarker::Grammar); | 306 DocumentMarker* marker = m_innerNode->document().markers().markerContainingP
oint(m_hitTestLocation.point(), DocumentMarker::Grammar); |
| 231 if (!marker) | 307 if (!marker) |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 ASSERT(m_hitTestLocation.containsPoint(FloatPoint(resolvedPointInMainFrame))
); | 553 ASSERT(m_hitTestLocation.containsPoint(FloatPoint(resolvedPointInMainFrame))
); |
| 478 m_hitTestLocation = HitTestLocation(resolvedPointInMainFrame); | 554 m_hitTestLocation = HitTestLocation(resolvedPointInMainFrame); |
| 479 m_pointInInnerNodeFrame = resolvedPointInMainFrame; | 555 m_pointInInnerNodeFrame = resolvedPointInMainFrame; |
| 480 m_innerNode = nullptr; | 556 m_innerNode = nullptr; |
| 481 m_innerPossiblyPseudoNode = nullptr; | 557 m_innerPossiblyPseudoNode = nullptr; |
| 482 m_listBasedTestResult = nullptr; | 558 m_listBasedTestResult = nullptr; |
| 483 | 559 |
| 484 // Update the HitTestResult as if the supplied node had been hit in normal p
oint-based hit-test. | 560 // Update the HitTestResult as if the supplied node had been hit in normal p
oint-based hit-test. |
| 485 // Note that we don't know the local point after a rect-based hit-test, but
we never use | 561 // Note that we don't know the local point after a rect-based hit-test, but
we never use |
| 486 // it so shouldn't bother with the cost of computing it. | 562 // it so shouldn't bother with the cost of computing it. |
| 487 resolvedInnerNode->layoutObject()->updateHitTestResult(*this, LayoutPoint())
; | 563 resolvedInnerNode->layoutObject()->updateHitTestResult(*this, LayoutPoint(),
m_validityRect); |
| 488 ASSERT(!isRectBasedTest()); | 564 ASSERT(!isRectBasedTest()); |
| 489 } | 565 } |
| 490 | 566 |
| 491 Element* HitTestResult::innerElement() const | 567 Element* HitTestResult::innerElement() const |
| 492 { | 568 { |
| 493 for (Node* node = m_innerNode.get(); node; node = ComposedTreeTraversal::par
ent(*node)) { | 569 for (Node* node = m_innerNode.get(); node; node = ComposedTreeTraversal::par
ent(*node)) { |
| 494 if (node->isElementNode()) | 570 if (node->isElementNode()) |
| 495 return toElement(node); | 571 return toElement(node); |
| 496 } | 572 } |
| 497 | 573 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 509 else if (isHTMLMapElement(m_innerNode)) | 585 else if (isHTMLMapElement(m_innerNode)) |
| 510 imageMapImageElement = toHTMLMapElement(m_innerNode)->imageElement(); | 586 imageMapImageElement = toHTMLMapElement(m_innerNode)->imageElement(); |
| 511 | 587 |
| 512 if (!imageMapImageElement) | 588 if (!imageMapImageElement) |
| 513 return m_innerNode.get(); | 589 return m_innerNode.get(); |
| 514 | 590 |
| 515 return imageMapImageElement; | 591 return imageMapImageElement; |
| 516 } | 592 } |
| 517 | 593 |
| 518 } // namespace blink | 594 } // namespace blink |
| OLD | NEW |