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

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..a8c1970b5332ad978ca20647f89ae1e5f2cd23d1
--- /dev/null
+++ b/Source/core/editing/SelectionController.h
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2006, 2007, 2009, 2010, 2011 Apple Inc. All rights reserved.
esprehn 2015/05/25 21:28:12 Missing Google here
Miyoung Shin(g) 2015/05/31 14:01:13 Done.
+ *
+ * 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;
+
+class CORE_EXPORT SelectionController final : public NoBaseWillBeGarbageCollected<SelectionController> {
esprehn 2015/05/25 21:28:12 Does this actually need to be exported? I don't th
Miyoung Shin(g) 2015/05/31 14:01:13 Done.
+ WTF_MAKE_NONCOPYABLE(SelectionController);
+public:
+ 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 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 singleClickInSelection() const;
+
+private:
+ explicit SelectionController(LocalFrame*);
esprehn 2015/05/25 21:28:12 reference
Miyoung Shin(g) 2015/05/31 14:01:13 Done.
+
+ enum class AppendTrailingWhitespace { ShouldAppend, DontAppend };
esprehn 2015/05/25 21:28:12 In the future it's preferred if you don't both mov
Miyoung Shin(g) 2015/05/31 14:01:13 It conflicts with the comment suggested by @yosin
+ void selectClosestWordFromHitTestResult(const HitTestResult&, AppendTrailingWhitespace);
+ void selectClosestMisspellingFromHitTestResult(const HitTestResult&, AppendTrailingWhitespace);
+ void selectClosestWordFromMouseEvent(const MouseEventWithHitTestResults&);
+ void selectClosestMisspellingFromMouseEvent(const MouseEventWithHitTestResults&);
+ void selectClosestWordOrLinkFromMouseEvent(const MouseEventWithHitTestResults&);
+
+ FrameSelection& selection() const;
+
+ RawPtrWillBeMember<LocalFrame> const m_frame;
+ bool m_mouseDownMayStartSelect;
+ bool m_singleClickInSelection;
+ enum class SelectionState { HaveNotStartedSelection, PlacedCaret, ExtendedSelection };
esprehn 2015/05/25 21:28:13 ditto
+ SelectionState m_selectionState;
+};
+
+}
+#endif // SelectionController_h

Powered by Google App Engine
This is Rietveld 408576698