1 /* 2 * Copyright (C) 2006 Apple Computer, Inc. 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Library General Public 6 * License as published by the Free Software Foundation; either 7 * version 2 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Library General Public License for more details. 13 * 14 * You should have received a copy of the GNU Library General Public License 15 * along with this library; see the file COPYING.LIB. If not, write to 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * Boston, MA 02110-1301, USA. 18 * 19 */ 20 #ifndef HitTestResult_h 21 #define HitTestResult_h 22 23 #include "IntPoint.h" 24 #include "TextDirection.h" 25 #include <wtf/RefPtr.h> 26 27 namespace WebCore { 28 29 class Element; 30 class Frame; 31 class Image; 32 class IntRect; 33 class KURL; 34 class Node; 35 class Scrollbar; 36 class String; 37 38 class HitTestResult { 39 public: 40 HitTestResult(const IntPoint&); 41 HitTestResult(const HitTestResult&); 42 ~HitTestResult(); 43 HitTestResult& operator=(const HitTestResult&); 44 45 Node* innerNode() const { return m_innerNode.get(); } 46 Node* innerNonSharedNode() const { return m_innerNonSharedNode.get(); } 47 IntPoint point() const { return m_point; } 48 IntPoint localPoint() const { return m_localPoint; } 49 Element* URLElement() const { return m_innerURLElement.get(); } 50 Scrollbar* scrollbar() const { return m_scrollbar.get(); } 51 bool isOverWidget() const { return m_isOverWidget; } 52 53 void setToNonShadowAncestor(); 54 55 void setInnerNode(Node*); 56 void setInnerNonSharedNode(Node*); 57 void setPoint(const IntPoint& p) { m_point = p; } 58 void setLocalPoint(const IntPoint& p) { m_localPoint = p; } 59 void setURLElement(Element*); 60 void setScrollbar(Scrollbar*); 61 void setIsOverWidget(bool b) { m_isOverWidget = b; } 62 63 Frame* targetFrame() const; 64 bool isSelected() const; 65 String spellingToolTip(TextDirection&) const; 66 String replacedString() const; 67 String title(TextDirection&) const; 68 String altDisplayString() const; 69 String titleDisplayString() const; 70 Image* image() const; 71 IntRect imageRect() const; 72 KURL absoluteImageURL() const; 73 KURL absoluteMediaURL() const; 74 KURL absoluteLinkURL() const; 75 String textContent() const; 76 bool isLiveLink() const; 77 bool isContentEditable() const; 78 79 private: 80 RefPtr<Node> m_innerNode; 81 RefPtr<Node> m_innerNonSharedNode; 82 IntPoint m_point; 83 IntPoint m_localPoint; // A point in the local coordinate space of m_innerNonSharedNode's renderer. Allows us to efficiently 84 // determine where inside the renderer we hit on subsequent operations. 85 RefPtr<Element> m_innerURLElement; 86 RefPtr<Scrollbar> m_scrollbar; 87 bool m_isOverWidget; // Returns true if we are over a widget (and not in the border/padding area of a RenderWidget for example). 88 }; 89 90 String displayString(const String&, const Node*); 91 92 } // namespace WebCore 93 94 #endif // HitTestResult_h 95