Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / rendering / HitTestResult.h
index a6cadad..e0a8daf 100644 (file)
 #include "platform/geometry/FloatQuad.h"
 #include "platform/geometry/FloatRect.h"
 #include "platform/geometry/LayoutRect.h"
+#include "platform/heap/Handle.h"
 #include "platform/text/TextDirection.h"
 #include "wtf/Forward.h"
 #include "wtf/ListHashSet.h"
 #include "wtf/OwnPtr.h"
 #include "wtf/RefPtr.h"
 
-namespace WebCore {
+namespace blink {
 
 class Element;
-class Frame;
+class LocalFrame;
 class HTMLMediaElement;
 class Image;
 class KURL;
 class Node;
 class RenderObject;
-class RenderRegion;
+class PositionWithAffinity;
 class Scrollbar;
 
 class HitTestResult {
+    DISALLOW_ALLOCATION();
 public:
-    typedef ListHashSet<RefPtr<Node> > NodeSet;
+    typedef WillBeHeapListHashSet<RefPtrWillBeMember<Node> > NodeSet;
 
     HitTestResult();
     HitTestResult(const LayoutPoint&);
@@ -57,7 +59,12 @@ public:
     HitTestResult(const HitTestResult&);
     ~HitTestResult();
     HitTestResult& operator=(const HitTestResult&);
+    void trace(Visitor*);
 
+    // For point-based hit tests, these accessors provide information about the node
+    // under the point. For rect-based hit tests they are meaningless (reflect the
+    // last candidate node observed in the rect).
+    // FIXME: Make these less error-prone for rect-based hit tests (center point or fail).
     Node* innerNode() const { return m_innerNode.get(); }
     Node* innerPossiblyPseudoNode() const { return m_innerPossiblyPseudoNode.get(); }
     Element* innerElement() const;
@@ -76,15 +83,15 @@ public:
     // The hit-tested point in the coordinates of the innerNode frame, the frame containing innerNode.
     const LayoutPoint& pointInInnerNodeFrame() const { return m_pointInInnerNodeFrame; }
     IntPoint roundedPointInInnerNodeFrame() const { return roundedIntPoint(pointInInnerNodeFrame()); }
-    Frame* innerNodeFrame() const;
+    LocalFrame* innerNodeFrame() const;
 
     // The hit-tested point in the coordinates of the inner node.
     const LayoutPoint& localPoint() const { return m_localPoint; }
     void setLocalPoint(const LayoutPoint& p) { m_localPoint = p; }
 
+    PositionWithAffinity position() const;
     RenderObject* renderer() const;
 
-    void setToNodesInDocumentTreeScope();
     void setToShadowHostIfInUserAgentShadowRoot();
 
     const HitTestLocation& hitTestLocation() const { return m_hitTestLocation; }
@@ -96,15 +103,16 @@ public:
     void setIsFirstLetter(bool b) { m_isFirstLetter = b; }
     void setIsOverWidget(bool b) { m_isOverWidget = b; }
 
-    Frame* targetFrame() const;
     bool isSelected() const;
     String spellingToolTip(TextDirection&) const;
     String title(TextDirection&) const;
-    String altDisplayString() const;
-    String titleDisplayString() const;
+    const AtomicString& altDisplayString() const;
     Image* image() const;
     IntRect imageRect() const;
     KURL absoluteImageURL() const;
+    // This variant of absoluteImageURL will also convert <canvas> elements
+    // to huge image data URLs (very expensive).
+    KURL absoluteImageURLIncludingCanvasDataURL() const;
     KURL absoluteMediaURL() const;
     KURL absoluteLinkURL() const;
     String textContent() const;
@@ -124,28 +132,34 @@ public:
     // the same thing as mutableRectBasedTestResult(), but here the return value is const.
     const NodeSet& rectBasedTestResult() const;
 
-    Node* targetNode() const;
+    // Collapse the rect-based test result into a single target at the specified location.
+    void resolveRectBasedTest(Node* resolvedInnerNode, const LayoutPoint& resolvedPointInMainFrame);
+
+    // FIXME: Remove this.
+    Node* targetNode() const { return innerNode(); }
 
 private:
+    KURL absoluteImageURLInternal(bool allowCanvas) const;
     NodeSet& mutableRectBasedTestResult(); // See above.
     HTMLMediaElement* mediaElement() const;
 
     HitTestLocation m_hitTestLocation;
 
-    RefPtr<Node> m_innerNode;
-    RefPtr<Node> m_innerPossiblyPseudoNode;
-    RefPtr<Node> m_innerNonSharedNode;
+    RefPtrWillBeMember<Node> m_innerNode;
+    RefPtrWillBeMember<Node> m_innerPossiblyPseudoNode;
+    RefPtrWillBeMember<Node> m_innerNonSharedNode;
+    // FIXME: Nothing changes this to a value different from m_hitTestLocation!
     LayoutPoint m_pointInInnerNodeFrame; // The hit-tested point in innerNode frame coordinates.
     LayoutPoint m_localPoint; // A point in the local coordinate space of m_innerNonSharedNode's renderer. Allows us to efficiently
                               // determine where inside the renderer we hit on subsequent operations.
-    RefPtr<Element> m_innerURLElement;
+    RefPtrWillBeMember<Element> m_innerURLElement;
     RefPtr<Scrollbar> m_scrollbar;
     bool m_isOverWidget; // Returns true if we are over a widget (and not in the border/padding area of a RenderWidget for example).
     bool m_isFirstLetter;
 
-    mutable OwnPtr<NodeSet> m_rectBasedTestResult;
+    mutable OwnPtrWillBeMember<NodeSet> m_rectBasedTestResult;
 };
 
-} // namespace WebCore
+} // namespace blink
 
 #endif // HitTestResult_h