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

Side by Side Diff: third_party/WebKit/Source/core/editing/FrameSelection.h

Issue 1994883002: [Editing][CodeHealth] Extract new FrameCaret class from FrameSelection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update Created 4 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 29 matching lines...) Expand all
40 #include "platform/heap/Handle.h" 40 #include "platform/heap/Handle.h"
41 #include "wtf/Noncopyable.h" 41 #include "wtf/Noncopyable.h"
42 42
43 namespace blink { 43 namespace blink {
44 44
45 class CaretBase; 45 class CaretBase;
46 class CharacterData; 46 class CharacterData;
47 class CullRect; 47 class CullRect;
48 class LayoutBlock; 48 class LayoutBlock;
49 class LocalFrame; 49 class LocalFrame;
50 class FrameCaret;
50 class GranularityStrategy; 51 class GranularityStrategy;
51 class GraphicsContext; 52 class GraphicsContext;
52 class HTMLFormElement; 53 class HTMLFormElement;
53 class SelectionEditor; 54 class SelectionEditor;
54 class PendingSelection; 55 class PendingSelection;
55 class Text; 56 class Text;
56 57
57 enum class CursorAlignOnScroll { IfNeeded, Always }; 58 enum class CursorAlignOnScroll { IfNeeded, Always };
58 59
59 enum EUserTriggered { NotUserTriggered = 0, UserTriggered = 1 }; 60 enum EUserTriggered { NotUserTriggered = 0, UserTriggered = 1 };
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 void nodeWillBeRemoved(Node&); 176 void nodeWillBeRemoved(Node&);
176 void dataWillChange(const CharacterData& node); 177 void dataWillChange(const CharacterData& node);
177 void didUpdateCharacterData(CharacterData*, unsigned offset, unsigned oldLen gth, unsigned newLength); 178 void didUpdateCharacterData(CharacterData*, unsigned offset, unsigned oldLen gth, unsigned newLength);
178 void didMergeTextNodes(const Text& oldNode, unsigned offset); 179 void didMergeTextNodes(const Text& oldNode, unsigned offset);
179 void didSplitTextNode(const Text& oldNode); 180 void didSplitTextNode(const Text& oldNode);
180 181
181 bool isAppearanceDirty() const; 182 bool isAppearanceDirty() const;
182 void commitAppearanceIfNeeded(LayoutView&); 183 void commitAppearanceIfNeeded(LayoutView&);
183 void updateAppearance(); 184 void updateAppearance();
184 void setCaretVisible(bool caretIsVisible); 185 void setCaretVisible(bool caretIsVisible);
185 bool isCaretBoundsDirty() const { return m_caretRectDirty; } 186 bool isCaretBoundsDirty() const;
186 void setCaretRectNeedsUpdate(); 187 void setCaretRectNeedsUpdate();
187 void scheduleVisualUpdate() const; 188 void scheduleVisualUpdate() const;
188 void invalidateCaretRect(); 189 void invalidateCaretRect();
189 void paintCaret(GraphicsContext&, const LayoutPoint&); 190 void paintCaret(GraphicsContext&, const LayoutPoint&);
190 191
191 // Used to suspend caret blinking while the mouse is down. 192 // Used to suspend caret blinking while the mouse is down.
192 void setCaretBlinkingSuspended(bool suspended) { m_isCaretBlinkingSuspended = suspended; } 193 void setCaretBlinkingSuspended(bool);
193 bool isCaretBlinkingSuspended() const { return m_isCaretBlinkingSuspended; } 194 bool isCaretBlinkingSuspended() const;
194 195
195 // Focus 196 // Focus
196 void setFocused(bool); 197 void setFocused(bool);
197 bool isFocused() const { return m_focused; } 198 bool isFocused() const { return m_focused; }
198 bool isFocusedAndActive() const; 199 bool isFocusedAndActive() const;
199 void pageActivationChanged(); 200 void pageActivationChanged();
200 201
201 void updateSecureKeyboardEntryIfActive(); 202 void updateSecureKeyboardEntryIfActive();
202 203
203 // Returns true if a word is selected. 204 // Returns true if a word is selected.
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 void setSelectionAlgorithm(const VisibleSelectionTemplate<Strategy>&, SetSel ectionOptions, CursorAlignOnScroll, TextGranularity); 266 void setSelectionAlgorithm(const VisibleSelectionTemplate<Strategy>&, SetSel ectionOptions, CursorAlignOnScroll, TextGranularity);
266 267
267 void respondToNodeModification(Node&, bool baseRemoved, bool extentRemoved, bool startRemoved, bool endRemoved); 268 void respondToNodeModification(Node&, bool baseRemoved, bool extentRemoved, bool startRemoved, bool endRemoved);
268 269
269 void notifyAccessibilityForSelectionChange(); 270 void notifyAccessibilityForSelectionChange();
270 void notifyCompositorForSelectionChange(); 271 void notifyCompositorForSelectionChange();
271 void notifyEventHandlerForSelectionChange(); 272 void notifyEventHandlerForSelectionChange();
272 273
273 void focusedOrActiveStateChanged(); 274 void focusedOrActiveStateChanged();
274 275
275 void caretBlinkTimerFired(Timer<FrameSelection>*);
276 void stopCaretBlinkTimer();
277
278 void setUseSecureKeyboardEntry(bool); 276 void setUseSecureKeyboardEntry(bool);
279 277
280 void setCaretVisibility(CaretVisibility); 278 void setCaretVisibility(CaretVisibility);
281 bool shouldBlinkCaret() const; 279 bool shouldBlinkCaret() const;
282 280
283 void updateSelectionIfNeeded(const Position& base, const Position& extent, c onst Position& start, const Position& end); 281 void updateSelectionIfNeeded(const Position& base, const Position& extent, c onst Position& start, const Position& end);
284 282
285 template <typename Strategy> 283 template <typename Strategy>
286 VisibleSelectionTemplate<Strategy> validateSelection(const VisibleSelectionT emplate<Strategy>&); 284 VisibleSelectionTemplate<Strategy> validateSelection(const VisibleSelectionT emplate<Strategy>&);
287 285
288 GranularityStrategy* granularityStrategy(); 286 GranularityStrategy* granularityStrategy();
289 287
290 // For unittests 288 // For unittests
291 bool shouldPaintCaretForTesting() const { return m_shouldPaintCaret; } 289 bool shouldPaintCaretForTesting() const;
292 bool isPreviousCaretDirtyForTesting() const { return m_previousCaretNode; } 290 bool isPreviousCaretDirtyForTesting() const;
293 291
294 Member<LocalFrame> m_frame; 292 Member<LocalFrame> m_frame;
295 const Member<PendingSelection> m_pendingSelection; 293 const Member<PendingSelection> m_pendingSelection;
296 const Member<SelectionEditor> m_selectionEditor; 294 const Member<SelectionEditor> m_selectionEditor;
297 295
298 // Used to store base before the adjustment at bidi boundary 296 // Used to store base before the adjustment at bidi boundary
299 VisiblePosition m_originalBase; 297 VisiblePosition m_originalBase;
300 VisiblePositionInFlatTree m_originalBaseInFlatTree; 298 VisiblePositionInFlatTree m_originalBaseInFlatTree;
301 TextGranularity m_granularity; 299 TextGranularity m_granularity;
302 LayoutUnit m_xPosForVerticalArrowNavigation; 300 LayoutUnit m_xPosForVerticalArrowNavigation;
303 301
304 Member<Node> m_previousCaretNode; // The last node which painted the caret. Retained for clearing the old caret when it moves.
305 LayoutRect m_previousCaretRect;
306 CaretVisibility m_previousCaretVisibility;
307
308 Member<EditingStyle> m_typingStyle; 302 Member<EditingStyle> m_typingStyle;
309 303
310 Timer<FrameSelection> m_caretBlinkTimer;
311
312 bool m_caretRectDirty : 1;
313 bool m_shouldPaintCaret : 1;
314 bool m_isCaretBlinkingSuspended : 1;
315 bool m_focused : 1; 304 bool m_focused : 1;
316 bool m_shouldShowBlockCursor : 1; 305 bool m_shouldShowBlockCursor : 1;
317 306
318 // Controls text granularity used to adjust the selection's extent in moveRa ngeSelectionExtent. 307 // Controls text granularity used to adjust the selection's extent in moveRa ngeSelectionExtent.
319 OwnPtr<GranularityStrategy> m_granularityStrategy; 308 OwnPtr<GranularityStrategy> m_granularityStrategy;
320 309
321 OwnPtr<CaretBase> m_caretBase; 310 const Member<FrameCaret> m_frameCaret;
322 }; 311 };
323 312
324 inline EditingStyle* FrameSelection::typingStyle() const 313 inline EditingStyle* FrameSelection::typingStyle() const
325 { 314 {
326 return m_typingStyle.get(); 315 return m_typingStyle.get();
327 } 316 }
328 317
329 inline void FrameSelection::clearTypingStyle() 318 inline void FrameSelection::clearTypingStyle()
330 { 319 {
331 m_typingStyle.clear(); 320 m_typingStyle.clear();
332 } 321 }
333 322
334 inline void FrameSelection::setTypingStyle(EditingStyle* style) 323 inline void FrameSelection::setTypingStyle(EditingStyle* style)
335 { 324 {
336 m_typingStyle = style; 325 m_typingStyle = style;
337 } 326 }
338 } // namespace blink 327 } // namespace blink
339 328
340 #ifndef NDEBUG 329 #ifndef NDEBUG
341 // Outside the WebCore namespace for ease of invocation from gdb. 330 // Outside the WebCore namespace for ease of invocation from gdb.
342 void showTree(const blink::FrameSelection&); 331 void showTree(const blink::FrameSelection&);
343 void showTree(const blink::FrameSelection*); 332 void showTree(const blink::FrameSelection*);
344 #endif 333 #endif
345 334
346 #endif // FrameSelection_h 335 #endif // FrameSelection_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698