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

Unified Diff: Source/core/editing/SelectionController.h

Issue 1113323002: [Reland] Refactor the selection code in EventHandler (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: Source/core/editing/SelectionController.h
diff --git a/Source/core/page/AutoscrollController.h b/Source/core/editing/SelectionController.h
similarity index 35%
copy from Source/core/page/AutoscrollController.h
copy to Source/core/editing/SelectionController.h
index b2c765ae5af92e083e178b52a1963edd948cd529..f15ad0b4ba55ccbfbfd371c025dc9a34eec8ea8e 100644
--- a/Source/core/page/AutoscrollController.h
+++ b/Source/core/editing/SelectionController.h
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2006, 2007, 2009, 2010, 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2015 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -23,71 +24,64 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef AutoscrollController_h
-#define AutoscrollController_h
+#ifndef SelectionController_h
+#define SelectionController_h
#include "core/CoreExport.h"
-#include "platform/geometry/IntPoint.h"
-#include "wtf/PassOwnPtr.h"
+#include "core/editing/TextGranularity.h"
+#include "core/page/EventWithHitTestResults.h"
+#include "platform/heap/Handle.h"
namespace blink {
+class FrameSelection;
+class HitTestResult;
class LocalFrame;
-class FrameView;
-class Node;
-class Page;
-class PlatformMouseEvent;
-class LayoutBox;
-class LayoutObject;
+class VisibleSelection;
-enum AutoscrollType {
- NoAutoscroll,
- AutoscrollForDragAndDrop,
- AutoscrollForSelection,
-#if OS(WIN)
- AutoscrollForPanCanStop,
- AutoscrollForPan,
-#endif
-};
-
-// AutscrollController handels autoscroll and pan scroll for EventHandler.
-class CORE_EXPORT AutoscrollController {
+class SelectionController final : public NoBaseWillBeGarbageCollected<SelectionController> {
+ WTF_MAKE_NONCOPYABLE(SelectionController);
public:
- static PassOwnPtr<AutoscrollController> create(Page&);
+ static PassOwnPtrWillBeRawPtr<SelectionController> create(LocalFrame&);
+ DECLARE_TRACE();
+
+ bool updateSelectionForMouseDownDispatchingSelectStart(Node*, const VisibleSelection&, TextGranularity);
+ void handleMousePressEvent(const MouseEventWithHitTestResults&);
+ bool handleMousePressEventSingleClick(const MouseEventWithHitTestResults&);
+ bool handleMousePressEventDoubleClick(const MouseEventWithHitTestResults&);
+ bool handleMousePressEventTripleClick(const MouseEventWithHitTestResults&);
+ void handleMouseDraggedEvent(const MouseEventWithHitTestResults&, const IntPoint&, const LayoutPoint&, Node*, const IntPoint&);
+ bool handleMouseReleaseEvent(const MouseEventWithHitTestResults&, const LayoutPoint&);
+ bool handlePasteGlobalSelection(const PlatformMouseEvent&);
+ bool handleGestureLongPress(const PlatformGestureEvent&, const HitTestResult&);
- void animate(double monotonicFrameBeginTime);
- bool autoscrollInProgress() const;
- bool autoscrollInProgress(const LayoutBox*) const;
- bool panScrollInProgress() const;
- void startAutoscrollForSelection(LayoutObject*);
- void stopAutoscroll();
- void stopAutoscrollIfNeeded(LayoutObject*);
- void updateAutoscrollLayoutObject();
- void updateDragAndDrop(Node* targetNode, const IntPoint& eventPosition, double eventTime);
-#if OS(WIN)
- void handleMouseReleaseForPanScrolling(LocalFrame*, const PlatformMouseEvent&);
- void startPanScrolling(LayoutBox*, const IntPoint&);
-#endif
+ void updateSelectionForMouseDrag(Node*, const LayoutPoint&, const IntPoint&);
+ void updateSelectionForMouseDrag(const HitTestResult&, Node*, const LayoutPoint&, const IntPoint&);
+ void prepareForContextMenu(const MouseEventWithHitTestResults&, const LayoutPoint&);
+ void preparePassMousePressEventToSubframe(MouseEventWithHitTestResults&);
+
+ void initializeSelectionState();
+ void setMouseDownMayStartSelect(bool);
+ bool mouseDownMayStartSelect() const;
+ bool mouseDownWasSingleClickInSelection() const;
private:
- explicit AutoscrollController(Page&);
+ explicit SelectionController(LocalFrame&);
- void startAutoscroll();
+ enum AppendTrailingWhitespace { ShouldAppendTrailingWhitespace, DontAppendTrailingWhitespace };
+ void selectClosestWordFromHitTestResult(const HitTestResult&, AppendTrailingWhitespace);
+ void selectClosestMisspellingFromHitTestResult(const HitTestResult&, AppendTrailingWhitespace);
+ void selectClosestWordFromMouseEvent(const MouseEventWithHitTestResults&);
+ void selectClosestMisspellingFromMouseEvent(const MouseEventWithHitTestResults&);
+ void selectClosestWordOrLinkFromMouseEvent(const MouseEventWithHitTestResults&);
-#if OS(WIN)
- void updatePanScrollState(FrameView*, const IntPoint& lastKnownMousePosition);
-#endif
- Page& m_page;
- LayoutBox* m_autoscrollLayoutObject;
- AutoscrollType m_autoscrollType;
- IntPoint m_dragAndDropAutoscrollReferencePosition;
- double m_dragAndDropAutoscrollStartTime;
-#if OS(WIN)
- IntPoint m_panScrollStartPos;
-#endif
+ RawPtrWillBeMember<LocalFrame> const m_frame;
+ bool m_mouseDownMayStartSelect;
+ bool m_mouseDownWasSingleClickInSelection;
+ enum SelectionInitiationState { HaveNotStartedSelection, PlacedCaret, ExtendedSelection };
+ SelectionInitiationState m_selectionInitiationState;
};
} // namespace blink
-
-#endif // AutoscrollController_h
+#endif // SelectionController_h

Powered by Google App Engine
This is Rietveld 408576698