Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(390)

Side by Side Diff: Source/core/layout/HitTestResult.h

Issue 1032823003: Refactor HitTestResult to store the HitTestRequest (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Updated as per review comments Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/inspector/InspectorDOMAgent.cpp ('k') | Source/core/layout/HitTestResult.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006 Apple Computer, Inc. 2 * Copyright (C) 2006 Apple Computer, Inc.
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 class LayoutObject; 46 class LayoutObject;
47 class PositionWithAffinity; 47 class PositionWithAffinity;
48 class Scrollbar; 48 class Scrollbar;
49 49
50 class CORE_EXPORT HitTestResult { 50 class CORE_EXPORT HitTestResult {
51 DISALLOW_ALLOCATION(); 51 DISALLOW_ALLOCATION();
52 public: 52 public:
53 typedef WillBeHeapListHashSet<RefPtrWillBeMember<Node>> NodeSet; 53 typedef WillBeHeapListHashSet<RefPtrWillBeMember<Node>> NodeSet;
54 54
55 HitTestResult(); 55 HitTestResult();
56 HitTestResult(const LayoutPoint&); 56 HitTestResult(const HitTestRequest&, const LayoutPoint&);
57 // Pass positive padding values to perform a rect-based hit test. 57 // Pass positive padding values to perform a rect-based hit test.
58 HitTestResult(const LayoutPoint& centerPoint, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding); 58 HitTestResult(const HitTestRequest&, const LayoutPoint& centerPoint, unsigne d topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPaddin g);
59 HitTestResult(const HitTestLocation&); 59 HitTestResult(const HitTestRequest&, const HitTestLocation&);
60 HitTestResult(const HitTestResult&); 60 HitTestResult(const HitTestResult&);
61 ~HitTestResult(); 61 ~HitTestResult();
62 HitTestResult& operator=(const HitTestResult&); 62 HitTestResult& operator=(const HitTestResult&);
63 DECLARE_TRACE(); 63 DECLARE_TRACE();
64 64
65 // For point-based hit tests, these accessors provide information about the node 65 // For point-based hit tests, these accessors provide information about the node
66 // under the point. For rect-based hit tests they are meaningless (reflect t he 66 // under the point. For rect-based hit tests they are meaningless (reflect t he
67 // last candidate node observed in the rect). 67 // last candidate node observed in the rect).
68 // FIXME: Make these less error-prone for rect-based hit tests (center point or fail). 68 // FIXME: Make these less error-prone for rect-based hit tests (center point or fail).
69 Node* innerNode() const { return m_innerNode.get(); } 69 Node* innerNode() const { return m_innerNode.get(); }
(...skipping 19 matching lines...) Expand all
89 // The hit-tested point in the coordinates of the inner node. 89 // The hit-tested point in the coordinates of the inner node.
90 const LayoutPoint& localPoint() const { return m_localPoint; } 90 const LayoutPoint& localPoint() const { return m_localPoint; }
91 void setLocalPoint(const LayoutPoint& p) { m_localPoint = p; } 91 void setLocalPoint(const LayoutPoint& p) { m_localPoint = p; }
92 92
93 PositionWithAffinity position() const; 93 PositionWithAffinity position() const;
94 LayoutObject* layoutObject() const; 94 LayoutObject* layoutObject() const;
95 95
96 void setToShadowHostIfInClosedShadowRoot(); 96 void setToShadowHostIfInClosedShadowRoot();
97 97
98 const HitTestLocation& hitTestLocation() const { return m_hitTestLocation; } 98 const HitTestLocation& hitTestLocation() const { return m_hitTestLocation; }
99 const HitTestRequest& hitTestRequest() const { return m_hitTestRequest; }
99 100
100 void setInnerNode(Node*); 101 void setInnerNode(Node*);
101 void setInnerNonSharedNode(Node*); 102 void setInnerNonSharedNode(Node*);
102 void setURLElement(Element*); 103 void setURLElement(Element*);
103 void setScrollbar(Scrollbar*); 104 void setScrollbar(Scrollbar*);
104 void setIsOverWidget(bool b) { m_isOverWidget = b; } 105 void setIsOverWidget(bool b) { m_isOverWidget = b; }
105 106
106 bool isSelected() const; 107 bool isSelected() const;
107 String spellingToolTip(TextDirection&) const; 108 String spellingToolTip(TextDirection&) const;
108 String title(TextDirection&) const; 109 String title(TextDirection&) const;
109 const AtomicString& altDisplayString() const; 110 const AtomicString& altDisplayString() const;
110 Image* image() const; 111 Image* image() const;
111 IntRect imageRect() const; 112 IntRect imageRect() const;
112 KURL absoluteImageURL() const; 113 KURL absoluteImageURL() const;
113 KURL absoluteMediaURL() const; 114 KURL absoluteMediaURL() const;
114 KURL absoluteLinkURL() const; 115 KURL absoluteLinkURL() const;
115 String textContent() const; 116 String textContent() const;
116 bool isLiveLink() const; 117 bool isLiveLink() const;
117 bool isMisspelled() const; 118 bool isMisspelled() const;
118 bool isContentEditable() const; 119 bool isContentEditable() const;
119 120
120 bool isOverLink() const; 121 bool isOverLink() const;
121 122
122 // Return true if the test is a list-based test and we should continue testi ng. 123 // Return true if the test is a list-based test and we should continue testi ng.
123 bool addNodeToListBasedTestResult(Node*, const HitTestRequest&, const HitTes tLocation& pointInContainer, const LayoutRect& = LayoutRect()); 124 bool addNodeToListBasedTestResult(Node*, const HitTestLocation& pointInConta iner, const LayoutRect& = LayoutRect());
124 bool addNodeToListBasedTestResult(Node*, const HitTestRequest&, const HitTes tLocation& pointInContainer, const FloatRect&); 125 bool addNodeToListBasedTestResult(Node*, const HitTestLocation& pointInConta iner, const FloatRect&);
125 void append(const HitTestResult&, const HitTestRequest&); 126 void append(const HitTestResult&);
126 127
127 // If m_listBasedTestResult is 0 then set it to a new NodeSet. Return *m_lis tBasedTestResult. Lazy allocation makes 128 // If m_listBasedTestResult is 0 then set it to a new NodeSet. Return *m_lis tBasedTestResult. Lazy allocation makes
128 // sense because the NodeSet is seldom necessary, and it's somewhat expensiv e to allocate and initialize. This method does 129 // sense because the NodeSet is seldom necessary, and it's somewhat expensiv e to allocate and initialize. This method does
129 // the same thing as mutableListBasedTestResult(), but here the return value is const. 130 // the same thing as mutableListBasedTestResult(), but here the return value is const.
130 const NodeSet& listBasedTestResult() const; 131 const NodeSet& listBasedTestResult() const;
131 132
132 // Collapse the rect-based test result into a single target at the specified location. 133 // Collapse the rect-based test result into a single target at the specified location.
133 void resolveRectBasedTest(Node* resolvedInnerNode, const LayoutPoint& resolv edPointInMainFrame); 134 void resolveRectBasedTest(Node* resolvedInnerNode, const LayoutPoint& resolv edPointInMainFrame);
134 135
135 private: 136 private:
136 NodeSet& mutableListBasedTestResult(); // See above. 137 NodeSet& mutableListBasedTestResult(); // See above.
137 HTMLMediaElement* mediaElement() const; 138 HTMLMediaElement* mediaElement() const;
138 139
139 HitTestLocation m_hitTestLocation; 140 HitTestLocation m_hitTestLocation;
141 HitTestRequest m_hitTestRequest;
140 142
141 RefPtrWillBeMember<Node> m_innerNode; 143 RefPtrWillBeMember<Node> m_innerNode;
142 RefPtrWillBeMember<Node> m_innerPossiblyPseudoNode; 144 RefPtrWillBeMember<Node> m_innerPossiblyPseudoNode;
143 RefPtrWillBeMember<Node> m_innerNonSharedNode; 145 RefPtrWillBeMember<Node> m_innerNonSharedNode;
144 // FIXME: Nothing changes this to a value different from m_hitTestLocation! 146 // FIXME: Nothing changes this to a value different from m_hitTestLocation!
145 LayoutPoint m_pointInInnerNodeFrame; // The hit-tested point in innerNode fr ame coordinates. 147 LayoutPoint m_pointInInnerNodeFrame; // The hit-tested point in innerNode fr ame coordinates.
146 LayoutPoint m_localPoint; // A point in the local coordinate space of m_inne rNonSharedNode's renderer. Allows us to efficiently 148 LayoutPoint m_localPoint; // A point in the local coordinate space of m_inne rNonSharedNode's renderer. Allows us to efficiently
147 // determine where inside the renderer we hit on subsequent operations. 149 // determine where inside the renderer we hit on subsequent operations.
148 RefPtrWillBeMember<Element> m_innerURLElement; 150 RefPtrWillBeMember<Element> m_innerURLElement;
149 RefPtrWillBeMember<Scrollbar> m_scrollbar; 151 RefPtrWillBeMember<Scrollbar> m_scrollbar;
150 bool m_isOverWidget; // Returns true if we are over a widget (and not in the border/padding area of a LayoutPart for example). 152 bool m_isOverWidget; // Returns true if we are over a widget (and not in the border/padding area of a LayoutPart for example).
151 153
152 mutable OwnPtrWillBeMember<NodeSet> m_listBasedTestResult; 154 mutable OwnPtrWillBeMember<NodeSet> m_listBasedTestResult;
153 }; 155 };
154 156
155 } // namespace blink 157 } // namespace blink
156 158
157 #endif // HitTestResult_h 159 #endif // HitTestResult_h
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorDOMAgent.cpp ('k') | Source/core/layout/HitTestResult.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698