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

Unified Diff: third_party/WebKit/Source/core/editing/LayoutSelection.cpp

Issue 2616623002: Do not send redundant selectionchange-events (decouple focus) (Closed)
Patch Set: Add comment Created 3 years, 8 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: third_party/WebKit/Source/core/editing/LayoutSelection.cpp
diff --git a/third_party/WebKit/Source/core/editing/LayoutSelection.cpp b/third_party/WebKit/Source/core/editing/LayoutSelection.cpp
index 540146afea59317b2f41c95f2de8b3f74415c3f7..e9dea0bc42d0c99dc5b652af954aa0782c765e11 100644
--- a/third_party/WebKit/Source/core/editing/LayoutSelection.cpp
+++ b/third_party/WebKit/Source/core/editing/LayoutSelection.cpp
@@ -34,6 +34,7 @@ namespace blink {
LayoutSelection::LayoutSelection(FrameSelection& frame_selection)
: frame_selection_(&frame_selection),
has_pending_selection_(false),
+ force_hide_(false),
selection_start_(nullptr),
selection_end_(nullptr),
selection_start_pos_(-1),
@@ -111,6 +112,14 @@ SelectionInFlatTree LayoutSelection::CalcVisibleSelection(
return builder.Build();
}
+void LayoutSelection::SetHasPendingSelection(PaintHint hint) {
+ has_pending_selection_ = true;
+ if (hint == PaintHint::kHide)
yosin_UTC9 2017/04/13 09:31:50 How about if (hint == PaintHint::kKeep) return;
hugoh_UTC2 2017/04/14 01:34:47 Acknowledged. Semantically the same so this is a m
yosin_UTC9 2017/04/14 02:29:16 Blink prefers early-return style, though.
+ force_hide_ = true;
+ else if (hint == PaintHint::kPaint)
+ force_hide_ = false;
+}
+
void LayoutSelection::Commit(LayoutView& layout_view) {
if (!HasPendingSelection())
return;
@@ -131,7 +140,7 @@ void LayoutSelection::Commit(LayoutView& layout_view) {
const VisibleSelectionInFlatTree& selection =
CreateVisibleSelection(CalcVisibleSelection(original_selection));
- if (!selection.IsRange()) {
+ if (!selection.IsRange() || force_hide_) {
ClearSelection();
return;
}
@@ -170,6 +179,7 @@ void LayoutSelection::Commit(LayoutView& layout_view) {
void LayoutSelection::OnDocumentShutdown() {
has_pending_selection_ = false;
+ force_hide_ = false;
selection_start_ = nullptr;
selection_end_ = nullptr;
selection_start_pos_ = -1;

Powered by Google App Engine
This is Rietveld 408576698