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 28 matching lines...) Expand all Loading... |
39 #include "core/rendering/RenderTextFragment.h" | 39 #include "core/rendering/RenderTextFragment.h" |
40 #include "core/svg/SVGElement.h" | 40 #include "core/svg/SVGElement.h" |
41 #include "platform/scroll/Scrollbar.h" | 41 #include "platform/scroll/Scrollbar.h" |
42 | 42 |
43 namespace blink { | 43 namespace blink { |
44 | 44 |
45 using namespace HTMLNames; | 45 using namespace HTMLNames; |
46 | 46 |
47 HitTestResult::HitTestResult() | 47 HitTestResult::HitTestResult() |
48 : m_isOverWidget(false) | 48 : m_isOverWidget(false) |
49 , m_isFirstLetter(false) | |
50 { | 49 { |
51 } | 50 } |
52 | 51 |
53 HitTestResult::HitTestResult(const LayoutPoint& point) | 52 HitTestResult::HitTestResult(const LayoutPoint& point) |
54 : m_hitTestLocation(point) | 53 : m_hitTestLocation(point) |
55 , m_pointInInnerNodeFrame(point) | 54 , m_pointInInnerNodeFrame(point) |
56 , m_isOverWidget(false) | 55 , m_isOverWidget(false) |
57 , m_isFirstLetter(false) | |
58 { | 56 { |
59 } | 57 } |
60 | 58 |
61 HitTestResult::HitTestResult(const LayoutPoint& centerPoint, unsigned topPadding
, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding) | 59 HitTestResult::HitTestResult(const LayoutPoint& centerPoint, unsigned topPadding
, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding) |
62 : m_hitTestLocation(centerPoint, topPadding, rightPadding, bottomPadding, le
ftPadding) | 60 : m_hitTestLocation(centerPoint, topPadding, rightPadding, bottomPadding, le
ftPadding) |
63 , m_pointInInnerNodeFrame(centerPoint) | 61 , m_pointInInnerNodeFrame(centerPoint) |
64 , m_isOverWidget(false) | 62 , m_isOverWidget(false) |
65 , m_isFirstLetter(false) | |
66 { | 63 { |
67 } | 64 } |
68 | 65 |
69 HitTestResult::HitTestResult(const HitTestLocation& other) | 66 HitTestResult::HitTestResult(const HitTestLocation& other) |
70 : m_hitTestLocation(other) | 67 : m_hitTestLocation(other) |
71 , m_pointInInnerNodeFrame(m_hitTestLocation.point()) | 68 , m_pointInInnerNodeFrame(m_hitTestLocation.point()) |
72 , m_isOverWidget(false) | 69 , m_isOverWidget(false) |
73 , m_isFirstLetter(false) | |
74 { | 70 { |
75 } | 71 } |
76 | 72 |
77 HitTestResult::HitTestResult(const HitTestResult& other) | 73 HitTestResult::HitTestResult(const HitTestResult& other) |
78 : m_hitTestLocation(other.m_hitTestLocation) | 74 : m_hitTestLocation(other.m_hitTestLocation) |
79 , m_innerNode(other.innerNode()) | 75 , m_innerNode(other.innerNode()) |
80 , m_innerPossiblyPseudoNode(other.m_innerPossiblyPseudoNode) | 76 , m_innerPossiblyPseudoNode(other.m_innerPossiblyPseudoNode) |
81 , m_innerNonSharedNode(other.innerNonSharedNode()) | 77 , m_innerNonSharedNode(other.innerNonSharedNode()) |
82 , m_pointInInnerNodeFrame(other.m_pointInInnerNodeFrame) | 78 , m_pointInInnerNodeFrame(other.m_pointInInnerNodeFrame) |
83 , m_localPoint(other.localPoint()) | 79 , m_localPoint(other.localPoint()) |
84 , m_innerURLElement(other.URLElement()) | 80 , m_innerURLElement(other.URLElement()) |
85 , m_scrollbar(other.scrollbar()) | 81 , m_scrollbar(other.scrollbar()) |
86 , m_isOverWidget(other.isOverWidget()) | 82 , m_isOverWidget(other.isOverWidget()) |
87 , m_isFirstLetter(other.m_isFirstLetter) | |
88 { | 83 { |
89 // Only copy the NodeSet in case of rect hit test. | 84 // Only copy the NodeSet in case of rect hit test. |
90 m_rectBasedTestResult = adoptPtrWillBeNoop(other.m_rectBasedTestResult ? new
NodeSet(*other.m_rectBasedTestResult) : 0); | 85 m_rectBasedTestResult = adoptPtrWillBeNoop(other.m_rectBasedTestResult ? new
NodeSet(*other.m_rectBasedTestResult) : 0); |
91 } | 86 } |
92 | 87 |
93 HitTestResult::~HitTestResult() | 88 HitTestResult::~HitTestResult() |
94 { | 89 { |
95 } | 90 } |
96 | 91 |
97 HitTestResult& HitTestResult::operator=(const HitTestResult& other) | 92 HitTestResult& HitTestResult::operator=(const HitTestResult& other) |
98 { | 93 { |
99 m_hitTestLocation = other.m_hitTestLocation; | 94 m_hitTestLocation = other.m_hitTestLocation; |
100 m_innerNode = other.innerNode(); | 95 m_innerNode = other.innerNode(); |
101 m_innerPossiblyPseudoNode = other.innerPossiblyPseudoNode(); | 96 m_innerPossiblyPseudoNode = other.innerPossiblyPseudoNode(); |
102 m_innerNonSharedNode = other.innerNonSharedNode(); | 97 m_innerNonSharedNode = other.innerNonSharedNode(); |
103 m_pointInInnerNodeFrame = other.m_pointInInnerNodeFrame; | 98 m_pointInInnerNodeFrame = other.m_pointInInnerNodeFrame; |
104 m_localPoint = other.localPoint(); | 99 m_localPoint = other.localPoint(); |
105 m_innerURLElement = other.URLElement(); | 100 m_innerURLElement = other.URLElement(); |
106 m_scrollbar = other.scrollbar(); | 101 m_scrollbar = other.scrollbar(); |
107 m_isFirstLetter = other.m_isFirstLetter; | |
108 m_isOverWidget = other.isOverWidget(); | 102 m_isOverWidget = other.isOverWidget(); |
109 | 103 |
110 // Only copy the NodeSet in case of rect hit test. | 104 // Only copy the NodeSet in case of rect hit test. |
111 m_rectBasedTestResult = adoptPtrWillBeNoop(other.m_rectBasedTestResult ? new
NodeSet(*other.m_rectBasedTestResult) : 0); | 105 m_rectBasedTestResult = adoptPtrWillBeNoop(other.m_rectBasedTestResult ? new
NodeSet(*other.m_rectBasedTestResult) : 0); |
112 | 106 |
113 return *this; | 107 return *this; |
114 } | 108 } |
115 | 109 |
116 void HitTestResult::trace(Visitor* visitor) | 110 void HitTestResult::trace(Visitor* visitor) |
117 { | 111 { |
(...skipping 13 matching lines...) Expand all Loading... |
131 RenderObject* renderer = this->renderer(); | 125 RenderObject* renderer = this->renderer(); |
132 if (!renderer) | 126 if (!renderer) |
133 return PositionWithAffinity(); | 127 return PositionWithAffinity(); |
134 if (m_innerPossiblyPseudoNode->isPseudoElement() && m_innerPossiblyPseudoNod
e->pseudoId() == BEFORE) | 128 if (m_innerPossiblyPseudoNode->isPseudoElement() && m_innerPossiblyPseudoNod
e->pseudoId() == BEFORE) |
135 return Position(m_innerNode, Position::PositionIsBeforeChildren).downstr
eam(); | 129 return Position(m_innerNode, Position::PositionIsBeforeChildren).downstr
eam(); |
136 return renderer->positionForPoint(localPoint()); | 130 return renderer->positionForPoint(localPoint()); |
137 } | 131 } |
138 | 132 |
139 RenderObject* HitTestResult::renderer() const | 133 RenderObject* HitTestResult::renderer() const |
140 { | 134 { |
141 if (!m_innerNode) | 135 return m_innerNode ? m_innerNode->renderer() : 0; |
142 return 0; | |
143 RenderObject* renderer = m_innerNode->renderer(); | |
144 if (!m_isFirstLetter || !renderer || !renderer->isText() || !toRenderText(re
nderer)->isTextFragment()) | |
145 return renderer; | |
146 return toRenderTextFragment(renderer)->firstRenderTextInFirstLetter(); | |
147 } | 136 } |
148 | 137 |
149 void HitTestResult::setToShadowHostIfInUserAgentShadowRoot() | 138 void HitTestResult::setToShadowHostIfInUserAgentShadowRoot() |
150 { | 139 { |
151 if (Node* node = innerNode()) { | 140 if (Node* node = innerNode()) { |
152 if (ShadowRoot* containingShadowRoot = node->containingShadowRoot()) { | 141 if (ShadowRoot* containingShadowRoot = node->containingShadowRoot()) { |
153 if (containingShadowRoot->type() == ShadowRoot::UserAgentShadowRoot) | 142 if (containingShadowRoot->type() == ShadowRoot::UserAgentShadowRoot) |
154 setInnerNode(node->shadowHost()); | 143 setInnerNode(node->shadowHost()); |
155 } | 144 } |
156 } | 145 } |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 { | 462 { |
474 for (Node* node = m_innerNode.get(); node; node = NodeRenderingTraversal::pa
rent(node)) { | 463 for (Node* node = m_innerNode.get(); node; node = NodeRenderingTraversal::pa
rent(node)) { |
475 if (node->isElementNode()) | 464 if (node->isElementNode()) |
476 return toElement(node); | 465 return toElement(node); |
477 } | 466 } |
478 | 467 |
479 return 0; | 468 return 0; |
480 } | 469 } |
481 | 470 |
482 } // namespace blink | 471 } // namespace blink |
OLD | NEW |