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

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, 7 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/editing/SelectionController.h b/Source/core/editing/SelectionController.h
new file mode 100644
index 0000000000000000000000000000000000000000..39970e9e6a31980fbc9af6e485fc42261b6ede36
--- /dev/null
+++ b/Source/core/editing/SelectionController.h
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2006, 2007, 2009, 2010, 2011 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SelectionController_h
+#define SelectionController_h
+
+#include "core/CoreExport.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 VisibleSelection;
+
+enum AppendTrailingWhitespace { ShouldAppendTrailingWhitespace, DontAppendTrailingWhitespace };
yosin_UTC9 2015/05/19 09:41:19 It seems |AppendTrailingWhitespace| used only in |
Miyoung Shin(g) 2015/05/19 16:12:50 Done.
+
+class CORE_EXPORT SelectionController final {
+ WTF_MAKE_NONCOPYABLE(SelectionController);
+public:
+ static PassOwnPtr<SelectionController> create(LocalFrame*, FrameSelection*);
+ ~SelectionController();
+
+ void clear();
+ bool updateSelectionForMouseDownDispatchingSelectStart(Node*, const VisibleSelection&, TextGranularity);
+ void selectClosestWordFromHitTestResult(const HitTestResult&, AppendTrailingWhitespace);
yosin_UTC9 2015/05/19 09:41:19 Do we need to expose |selectClosestWordXXX| as pub
Miyoung Shin(g) 2015/05/19 16:12:51 Done.
+ void selectClosestMisspellingFromHitTestResult(const HitTestResult&, AppendTrailingWhitespace);
+ void selectClosestWordFromMouseEvent(const MouseEventWithHitTestResults&);
+ void selectClosestMisspellingFromMouseEvent(const MouseEventWithHitTestResults&);
+ void selectClosestWordOrLinkFromMouseEvent(const MouseEventWithHitTestResults&);
+
+ void handleMousePressEvent(const MouseEventWithHitTestResults&);
+ bool handleMousePressEventSingleClick(const MouseEventWithHitTestResults&);
+ bool handleMousePressEventDoubleClick(const MouseEventWithHitTestResults&);
+ bool handleMousePressEventTripleClick(const MouseEventWithHitTestResults&);
+ void handleMouseDraggedEvent(const MouseEventWithHitTestResults&, const IntPoint&, const LayoutPoint&, const RefPtr<Node>, const IntPoint&);
+ bool handleMouseReleaseEvent(const MouseEventWithHitTestResults&, const LayoutPoint&);
+ bool handlePasteGlobalSelection(const PlatformMouseEvent&);
+
+ void updateSelectionForMouseDrag(const RefPtr<Node>, const LayoutPoint&, const IntPoint&);
+ void updateSelectionForMouseDrag(const HitTestResult&, const RefPtr<Node>, const LayoutPoint&, const IntPoint&);
+ void prepareForContextMenu(const MouseEventWithHitTestResults&, const LayoutPoint&);
+ void preparePassMousePressEventToSubframe(MouseEventWithHitTestResults&);
+
+ void initializeSelectionState();
+ void setMouseDownMayStartSelect(bool);
+ bool mouseDownMayStartSelect() const;
+ bool singleClickInSelection() const;
+ FrameSelection& selection() const;
+
+private:
+ explicit SelectionController(LocalFrame*, FrameSelection*);
+
+ LocalFrame* const m_frame;
+ FrameSelection* const m_selection;
+
+ bool m_mouseDownMayStartSelect;
+ bool m_singleClickInSelection;
+ enum class SelectionState { HaveNotStartedSelection, PlacedCaret, ExtendedSelection };
+ SelectionState m_selectionState;
+};
+
+}
+#endif // SelectionController_h

Powered by Google App Engine
This is Rietveld 408576698