Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / editing / Caret.h
index 3d9f9eb..674adf0 100644 (file)
 #include "platform/geometry/LayoutRect.h"
 #include "wtf/Noncopyable.h"
 
-namespace WebCore {
+namespace blink {
 
 class LocalFrame;
 class GraphicsContext;
-class RenderObject;
+class PositionWithAffinity;
+class RenderBlock;
 class RenderView;
 
 class CaretBase {
     WTF_MAKE_NONCOPYABLE(CaretBase);
-    WTF_MAKE_FAST_ALLOCATED;
+    WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED;
 protected:
     enum CaretVisibility { Visible, Hidden };
     explicit CaretBase(CaretVisibility = Hidden);
 
     void invalidateCaretRect(Node*, bool caretRectChanged = false);
     void clearCaretRect();
+    // Creating VisiblePosition causes synchronous layout so we should use the
+    // PositionWithAffinity version if possible.
+    // A position in HTMLTextFromControlElement is a typical example.
+    bool updateCaretRect(Document*, const PositionWithAffinity& caretPosition);
     bool updateCaretRect(Document*, const VisiblePosition& caretPosition);
     IntRect absoluteBoundsForLocalRect(Node*, const LayoutRect&) const;
     bool shouldRepaintCaret(const RenderView*, bool isContentEditable) const;
@@ -62,7 +67,7 @@ protected:
     CaretVisibility caretVisibility() const { return m_caretVisibility; }
 
 protected:
-    static RenderObject* caretRenderer(Node*);
+    static RenderBlock* caretRenderer(Node*);
     static void repaintCaretForLocalRect(Node*, const LayoutRect&);
 
 private:
@@ -71,13 +76,13 @@ private:
     CaretVisibility m_caretVisibility;
 };
 
-class DragCaretController : private CaretBase {
+class DragCaretController FINAL : public NoBaseWillBeGarbageCollected<DragCaretController>, private CaretBase {
     WTF_MAKE_NONCOPYABLE(DragCaretController);
-    WTF_MAKE_FAST_ALLOCATED;
+    WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED;
 public:
-    static PassOwnPtr<DragCaretController> create();
+    static PassOwnPtrWillBeRawPtr<DragCaretController> create();
 
-    RenderObject* caretRenderer() const;
+    RenderBlock* caretRenderer() const;
     void paintDragCaret(LocalFrame*, GraphicsContext*, const LayoutPoint&, const LayoutRect& clipRect) const;
 
     bool isContentEditable() const { return m_position.rootEditableElement(); }
@@ -90,13 +95,15 @@ public:
 
     void nodeWillBeRemoved(Node&);
 
+    void trace(Visitor*);
+
 private:
     DragCaretController();
 
     VisiblePosition m_position;
 };
 
-} // namespace WebCore
+} // namespace blink
 
 
 #endif // Caret_h