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

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

Issue 431983005: FrameSelection::updateApperance for caret should not cause layout. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix test failures Created 6 years, 4 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
« no previous file with comments | « Source/core/editing/Caret.cpp ('k') | Source/core/editing/FrameSelection.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 typedef unsigned SetSelectionOptions; // Union of values in SetSelectionOpti on and EUserTriggered 82 typedef unsigned SetSelectionOptions; // Union of values in SetSelectionOpti on and EUserTriggered
83 static inline EUserTriggered selectionOptionsToUserTriggered(SetSelectionOpt ions options) 83 static inline EUserTriggered selectionOptionsToUserTriggered(SetSelectionOpt ions options)
84 { 84 {
85 return static_cast<EUserTriggered>(options & UserTriggered); 85 return static_cast<EUserTriggered>(options & UserTriggered);
86 } 86 }
87 87
88 enum DirectoinalOption { 88 enum DirectoinalOption {
89 NonDirectional, 89 NonDirectional,
90 Directional 90 Directional
91 }; 91 };
92 enum ResetCaretBlinkOption {
93 None,
94 ResetCaretBlink
95 };
92 96
93 Element* rootEditableElement() const { return m_selection.rootEditableElemen t(); } 97 Element* rootEditableElement() const { return m_selection.rootEditableElemen t(); }
94 Element* rootEditableElementOrDocumentElement() const; 98 Element* rootEditableElementOrDocumentElement() const;
95 ContainerNode* rootEditableElementOrTreeScopeRootNode() const; 99 ContainerNode* rootEditableElementOrTreeScopeRootNode() const;
96 100
97 bool hasEditableStyle() const { return m_selection.hasEditableStyle(); } 101 bool hasEditableStyle() const { return m_selection.hasEditableStyle(); }
98 bool isContentEditable() const { return m_selection.isContentEditable(); } 102 bool isContentEditable() const { return m_selection.isContentEditable(); }
99 bool isContentRichlyEditable() const { return m_selection.isContentRichlyEdi table(); } 103 bool isContentRichlyEditable() const { return m_selection.isContentRichlyEdi table(); }
100 104
101 void moveTo(const VisiblePosition&, EUserTriggered = NotUserTriggered, Curso rAlignOnScroll = AlignCursorOnScrollIfNeeded); 105 void moveTo(const VisiblePosition&, EUserTriggered = NotUserTriggered, Curso rAlignOnScroll = AlignCursorOnScrollIfNeeded);
(...skipping 30 matching lines...) Expand all
132 void setExtent(const VisiblePosition&, EUserTriggered = NotUserTriggered); 136 void setExtent(const VisiblePosition&, EUserTriggered = NotUserTriggered);
133 137
134 Position base() const { return m_selection.base(); } 138 Position base() const { return m_selection.base(); }
135 Position extent() const { return m_selection.extent(); } 139 Position extent() const { return m_selection.extent(); }
136 Position start() const { return m_selection.start(); } 140 Position start() const { return m_selection.start(); }
137 Position end() const { return m_selection.end(); } 141 Position end() const { return m_selection.end(); }
138 142
139 // Return the renderer that is responsible for painting the caret (in the se lection start node) 143 // Return the renderer that is responsible for painting the caret (in the se lection start node)
140 RenderBlock* caretRenderer() const; 144 RenderBlock* caretRenderer() const;
141 145
142 // Caret rect local to the caret's renderer
143 LayoutRect localCaretRect();
144 LayoutRect localCaretRectWithoutUpdateForTesting() const { return CaretBase: :localCaretRectWithoutUpdate(); }
145
146 // Bounds of (possibly transformed) caret in absolute coords 146 // Bounds of (possibly transformed) caret in absolute coords
147 IntRect absoluteCaretBounds(); 147 IntRect absoluteCaretBounds();
148 void setCaretRectNeedsUpdate() { CaretBase::setCaretRectNeedsUpdate(); }
149 148
150 void didChangeFocus(); 149 void didChangeFocus();
151 void willBeModified(EAlteration, SelectionDirection); 150 void willBeModified(EAlteration, SelectionDirection);
152 151
153 bool isNone() const { return m_selection.isNone(); } 152 bool isNone() const { return m_selection.isNone(); }
154 bool isCaret() const { return m_selection.isCaret(); } 153 bool isCaret() const { return m_selection.isCaret(); }
155 bool isRange() const { return m_selection.isRange(); } 154 bool isRange() const { return m_selection.isRange(); }
156 bool isCaretOrRange() const { return m_selection.isCaretOrRange(); } 155 bool isCaretOrRange() const { return m_selection.isCaretOrRange(); }
157 bool isInPasswordField() const; 156 bool isInPasswordField() const;
158 bool isDirectional() const { return m_selection.isDirectional(); } 157 bool isDirectional() const { return m_selection.isDirectional(); }
159 158
160 // If this FrameSelection has a logical range which is still valid, this fun ction return its clone. Otherwise, 159 // If this FrameSelection has a logical range which is still valid, this fun ction return its clone. Otherwise,
161 // the return value from underlying VisibleSelection's firstRange() is retur ned. 160 // the return value from underlying VisibleSelection's firstRange() is retur ned.
162 PassRefPtrWillBeRawPtr<Range> firstRange() const; 161 PassRefPtrWillBeRawPtr<Range> firstRange() const;
163 162
164 PassRefPtrWillBeRawPtr<Range> toNormalizedRange() const { return m_selection .toNormalizedRange(); } 163 PassRefPtrWillBeRawPtr<Range> toNormalizedRange() const { return m_selection .toNormalizedRange(); }
165 164
166 void nodeWillBeRemoved(Node&); 165 void nodeWillBeRemoved(Node&);
167 void didUpdateCharacterData(CharacterData*, unsigned offset, unsigned oldLen gth, unsigned newLength); 166 void didUpdateCharacterData(CharacterData*, unsigned offset, unsigned oldLen gth, unsigned newLength);
168 void didMergeTextNodes(const Text& oldNode, unsigned offset); 167 void didMergeTextNodes(const Text& oldNode, unsigned offset);
169 void didSplitTextNode(const Text& oldNode); 168 void didSplitTextNode(const Text& oldNode);
170 169
170 void updateAppearance(ResetCaretBlinkOption = None);
171 void setCaretVisible(bool caretIsVisible) { setCaretVisibility(caretIsVisibl e ? Visible : Hidden); } 171 void setCaretVisible(bool caretIsVisible) { setCaretVisibility(caretIsVisibl e ? Visible : Hidden); }
172 bool recomputeCaretRect(); 172 bool isCaretBoundsDirty() const { return m_caretRectDirty; }
173 void setCaretRectNeedsUpdate();
174 void scheduleVisualUpdate() const;
173 void invalidateCaretRect(); 175 void invalidateCaretRect();
174 void paintCaret(GraphicsContext*, const LayoutPoint&, const LayoutRect& clip Rect); 176 void paintCaret(GraphicsContext*, const LayoutPoint&, const LayoutRect& clip Rect);
175 177
176 // Used to suspend caret blinking while the mouse is down. 178 // Used to suspend caret blinking while the mouse is down.
177 void setCaretBlinkingSuspended(bool suspended) { m_isCaretBlinkingSuspended = suspended; } 179 void setCaretBlinkingSuspended(bool suspended) { m_isCaretBlinkingSuspended = suspended; }
178 bool isCaretBlinkingSuspended() const { return m_isCaretBlinkingSuspended; } 180 bool isCaretBlinkingSuspended() const { return m_isCaretBlinkingSuspended; }
179 181
180 // Focus 182 // Focus
181 void setFocused(bool); 183 void setFocused(bool);
182 bool isFocused() const { return m_focused; } 184 bool isFocused() const { return m_focused; }
183 bool isFocusedAndActive() const; 185 bool isFocusedAndActive() const;
184 void pageActivationChanged(); 186 void pageActivationChanged();
185 187
186 // Painting.
187 void updateAppearance();
188
189 void updateSecureKeyboardEntryIfActive(); 188 void updateSecureKeyboardEntryIfActive();
190 189
191 #ifndef NDEBUG 190 #ifndef NDEBUG
192 void formatForDebugger(char* buffer, unsigned length) const; 191 void formatForDebugger(char* buffer, unsigned length) const;
193 void showTreeForThis() const; 192 void showTreeForThis() const;
194 #endif 193 #endif
195 194
196 enum EndPointsAdjustmentMode { AdjustEndpointsAtBidiBoundary, DoNotAdjsutEnd points }; 195 enum EndPointsAdjustmentMode { AdjustEndpointsAtBidiBoundary, DoNotAdjsutEnd points };
197 void setNonDirectionalSelectionIfNeeded(const VisibleSelection&, TextGranula rity, EndPointsAdjustmentMode = DoNotAdjsutEndpoints); 196 void setNonDirectionalSelectionIfNeeded(const VisibleSelection&, TextGranula rity, EndPointsAdjustmentMode = DoNotAdjsutEndpoints);
198 void setFocusedNodeIfNeeded(); 197 void setFocusedNodeIfNeeded();
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 bool m_observingVisibleSelection; 272 bool m_observingVisibleSelection;
274 VisiblePosition m_originalBase; // Used to store base before the adjustment at bidi boundary 273 VisiblePosition m_originalBase; // Used to store base before the adjustment at bidi boundary
275 TextGranularity m_granularity; 274 TextGranularity m_granularity;
276 275
277 // The range specified by the user, which may not be visually canonicalized (hence "logical"). 276 // The range specified by the user, which may not be visually canonicalized (hence "logical").
278 // This will be invalidated if the underlying VisibleSelection changes. If t hat happens, this variable will 277 // This will be invalidated if the underlying VisibleSelection changes. If t hat happens, this variable will
279 // become null, in which case logical positions == visible positions. 278 // become null, in which case logical positions == visible positions.
280 RefPtrWillBeMember<Range> m_logicalRange; 279 RefPtrWillBeMember<Range> m_logicalRange;
281 280
282 RefPtrWillBeMember<Node> m_previousCaretNode; // The last node which painted the caret. Retained for clearing the old caret when it moves. 281 RefPtrWillBeMember<Node> m_previousCaretNode; // The last node which painted the caret. Retained for clearing the old caret when it moves.
282 LayoutRect m_previousCaretRect;
283 283
284 RefPtrWillBeMember<EditingStyle> m_typingStyle; 284 RefPtrWillBeMember<EditingStyle> m_typingStyle;
285 285
286 Timer<FrameSelection> m_caretBlinkTimer; 286 Timer<FrameSelection> m_caretBlinkTimer;
287 // The painted bounds of the caret in absolute coordinates 287
288 IntRect m_absCaretBounds; 288 bool m_caretRectDirty : 1;
289 bool m_absCaretBoundsDirty : 1;
290 bool m_caretPaint : 1; 289 bool m_caretPaint : 1;
291 bool m_isCaretBlinkingSuspended : 1; 290 bool m_isCaretBlinkingSuspended : 1;
292 bool m_focused : 1; 291 bool m_focused : 1;
293 bool m_shouldShowBlockCursor : 1; 292 bool m_shouldShowBlockCursor : 1;
294 }; 293 };
295 294
296 inline EditingStyle* FrameSelection::typingStyle() const 295 inline EditingStyle* FrameSelection::typingStyle() const
297 { 296 {
298 return m_typingStyle.get(); 297 return m_typingStyle.get();
299 } 298 }
300 299
301 inline void FrameSelection::clearTypingStyle() 300 inline void FrameSelection::clearTypingStyle()
302 { 301 {
303 m_typingStyle.clear(); 302 m_typingStyle.clear();
304 } 303 }
305 304
306 inline void FrameSelection::setTypingStyle(PassRefPtrWillBeRawPtr<EditingStyle> style) 305 inline void FrameSelection::setTypingStyle(PassRefPtrWillBeRawPtr<EditingStyle> style)
307 { 306 {
308 m_typingStyle = style; 307 m_typingStyle = style;
309 } 308 }
310 } // namespace blink 309 } // namespace blink
311 310
312 #ifndef NDEBUG 311 #ifndef NDEBUG
313 // Outside the WebCore namespace for ease of invocation from gdb. 312 // Outside the WebCore namespace for ease of invocation from gdb.
314 void showTree(const blink::FrameSelection&); 313 void showTree(const blink::FrameSelection&);
315 void showTree(const blink::FrameSelection*); 314 void showTree(const blink::FrameSelection*);
316 #endif 315 #endif
317 316
318 #endif // FrameSelection_h 317 #endif // FrameSelection_h
OLDNEW
« no previous file with comments | « Source/core/editing/Caret.cpp ('k') | Source/core/editing/FrameSelection.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698