OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights |
3 * reserved. | 3 * reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 | 186 |
187 Position base() const { return selection().base(); } | 187 Position base() const { return selection().base(); } |
188 Position extent() const { return selection().extent(); } | 188 Position extent() const { return selection().extent(); } |
189 Position start() const { return selection().start(); } | 189 Position start() const { return selection().start(); } |
190 Position end() const { return selection().end(); } | 190 Position end() const { return selection().end(); } |
191 | 191 |
192 // Returns true if specified layout block has caret. This function is | 192 // Returns true if specified layout block has caret. This function is |
193 // called during InRecalStyle and InPaint. | 193 // called during InRecalStyle and InPaint. |
194 bool hasCaretIn(const LayoutBlock&) const; | 194 bool hasCaretIn(const LayoutBlock&) const; |
195 | 195 |
| 196 // Return the caret rect in local coordinate space of |caretLayoutBlock|. |
| 197 LayoutRect caretLocalRect() const; |
| 198 LayoutBlock* caretLayoutBlock() const; |
| 199 |
| 200 void setCaretVisualRect(const LayoutRect&); |
| 201 const DisplayItemClient& getCaretDisplayItemClient() const; |
| 202 |
196 // Bounds of (possibly transformed) caret in absolute coords | 203 // Bounds of (possibly transformed) caret in absolute coords |
197 IntRect absoluteCaretBounds(); | 204 IntRect absoluteCaretBounds(); |
198 | 205 |
199 void didChangeFocus(); | 206 void didChangeFocus(); |
200 | 207 |
201 bool isNone() const { return selection().isNone(); } | 208 bool isNone() const { return selection().isNone(); } |
202 bool isCaret() const { return selection().isCaret(); } | 209 bool isCaret() const { return selection().isCaret(); } |
203 bool isRange() const { return selection().isRange(); } | 210 bool isRange() const { return selection().isRange(); } |
204 bool isInPasswordField() const; | 211 bool isInPasswordField() const; |
205 bool isDirectional() const { return selection().isDirectional(); } | 212 bool isDirectional() const { return selection().isDirectional(); } |
206 | 213 |
207 // If this FrameSelection has a logical range which is still valid, this | 214 // If this FrameSelection has a logical range which is still valid, this |
208 // function return its clone. Otherwise, the return value from underlying | 215 // function return its clone. Otherwise, the return value from underlying |
209 // VisibleSelection's firstRange() is returned. | 216 // VisibleSelection's firstRange() is returned. |
210 Range* firstRange() const; | 217 Range* firstRange() const; |
211 | 218 |
212 void documentAttached(Document*); | 219 void documentAttached(Document*); |
213 void dataWillChange(const CharacterData& node); | |
214 | 220 |
215 void didLayout(); | 221 void didLayout(); |
216 bool isAppearanceDirty() const; | 222 bool isAppearanceDirty() const; |
217 void commitAppearanceIfNeeded(LayoutView&); | 223 void commitAppearanceIfNeeded(LayoutView&); |
218 void setCaretVisible(bool caretIsVisible); | 224 void setCaretVisible(bool caretIsVisible); |
219 void setCaretRectNeedsUpdate(); | |
220 void scheduleVisualUpdate() const; | 225 void scheduleVisualUpdate() const; |
221 void invalidateCaretRect(bool forceInvalidation = false); | 226 |
222 void paintCaret(GraphicsContext&, const LayoutPoint&); | 227 void paintCaret(GraphicsContext&, const LayoutPoint&); |
223 | 228 |
| 229 void setCaretMayNeedPaintInvalidation(); |
| 230 void setCaretNeedsPaintInvalidation(); |
| 231 |
224 // Used to suspend caret blinking while the mouse is down. | 232 // Used to suspend caret blinking while the mouse is down. |
225 void setCaretBlinkingSuspended(bool); | 233 void setCaretBlinkingSuspended(bool); |
226 bool isCaretBlinkingSuspended() const; | 234 bool isCaretBlinkingSuspended() const; |
227 | 235 |
228 // Focus | 236 // Focus |
229 void setFocused(bool); | 237 void setFocused(bool); |
230 bool isFocused() const { return m_focused; } | 238 bool isFocused() const { return m_focused; } |
231 bool isFocusedAndActive() const; | 239 bool isFocusedAndActive() const; |
232 void pageActivationChanged(); | 240 void pageActivationChanged(); |
233 | 241 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 | 281 |
274 // TODO(yosin): We should check DOM tree version and style version in | 282 // TODO(yosin): We should check DOM tree version and style version in |
275 // |FrameSelection::selection()| to make sure we use updated selection, | 283 // |FrameSelection::selection()| to make sure we use updated selection, |
276 // rather than having |updateIfNeeded()|. Once, we update all layout tests | 284 // rather than having |updateIfNeeded()|. Once, we update all layout tests |
277 // to use updated selection, we should make |updateIfNeeded()| private. | 285 // to use updated selection, we should make |updateIfNeeded()| private. |
278 void updateIfNeeded(); | 286 void updateIfNeeded(); |
279 | 287 |
280 DECLARE_TRACE(); | 288 DECLARE_TRACE(); |
281 | 289 |
282 private: | 290 private: |
| 291 friend class BlockPaintInvalidatorTest; |
283 friend class FrameSelectionTest; | 292 friend class FrameSelectionTest; |
284 friend class PaintControllerPaintTestForSlimmingPaintV1AndV2; | 293 friend class PaintControllerPaintTestForSlimmingPaintV1AndV2; |
285 friend class SelectionControllerTest; | 294 friend class SelectionControllerTest; |
286 FRIEND_TEST_ALL_PREFIXES(PaintControllerPaintTestForSlimmingPaintV1AndV2, | 295 FRIEND_TEST_ALL_PREFIXES(PaintControllerPaintTestForSlimmingPaintV1AndV2, |
287 FullDocumentPaintingWithCaret); | 296 FullDocumentPaintingWithCaret); |
288 | 297 |
289 explicit FrameSelection(LocalFrame&); | 298 explicit FrameSelection(LocalFrame&); |
290 | 299 |
291 // For |PaintControllerPaintTestForSlimmingPaintV1AndV2|. | |
292 const DisplayItemClient& caretDisplayItemClientForTesting() const; | |
293 | |
294 // Note: We have |selectionInFlatTree()| for unit tests, we should | 300 // Note: We have |selectionInFlatTree()| for unit tests, we should |
295 // use |visibleSelection<EditingInFlatTreeStrategy>()|. | 301 // use |visibleSelection<EditingInFlatTreeStrategy>()|. |
296 const VisibleSelectionInFlatTree& selectionInFlatTree() const; | 302 const VisibleSelectionInFlatTree& selectionInFlatTree() const; |
297 | 303 |
298 template <typename Strategy> | 304 template <typename Strategy> |
299 void setSelectionAlgorithm(const VisibleSelectionTemplate<Strategy>&, | 305 void setSelectionAlgorithm(const VisibleSelectionTemplate<Strategy>&, |
300 SetSelectionOptions, | 306 SetSelectionOptions, |
301 CursorAlignOnScroll, | 307 CursorAlignOnScroll, |
302 TextGranularity); | 308 TextGranularity); |
303 | 309 |
(...skipping 26 matching lines...) Expand all Loading... |
330 unsigned offset, | 336 unsigned offset, |
331 unsigned oldLength, | 337 unsigned oldLength, |
332 unsigned newLength) final; | 338 unsigned newLength) final; |
333 void didMergeTextNodes(const Text& mergedNode, | 339 void didMergeTextNodes(const Text& mergedNode, |
334 const NodeWithIndex& nodeToBeRemovedWithIndex, | 340 const NodeWithIndex& nodeToBeRemovedWithIndex, |
335 unsigned oldLength) final; | 341 unsigned oldLength) final; |
336 void didSplitTextNode(const Text& oldNode) final; | 342 void didSplitTextNode(const Text& oldNode) final; |
337 | 343 |
338 // For unittests | 344 // For unittests |
339 bool shouldPaintCaretForTesting() const; | 345 bool shouldPaintCaretForTesting() const; |
340 bool isPreviousCaretDirtyForTesting() const; | |
341 | 346 |
342 Member<LocalFrame> m_frame; | 347 Member<LocalFrame> m_frame; |
343 const Member<PendingSelection> m_pendingSelection; | 348 const Member<PendingSelection> m_pendingSelection; |
344 const Member<SelectionEditor> m_selectionEditor; | 349 const Member<SelectionEditor> m_selectionEditor; |
345 | 350 |
346 TextGranularity m_granularity; | 351 TextGranularity m_granularity; |
347 LayoutUnit m_xPosForVerticalArrowNavigation; | 352 LayoutUnit m_xPosForVerticalArrowNavigation; |
348 | 353 |
349 bool m_focused : 1; | 354 bool m_focused : 1; |
350 | 355 |
351 HandleVisibility m_handleVisibility = HandleVisibility::NotVisible; | 356 HandleVisibility m_handleVisibility = HandleVisibility::NotVisible; |
352 | 357 |
353 // Controls text granularity used to adjust the selection's extent in | 358 // Controls text granularity used to adjust the selection's extent in |
354 // moveRangeSelectionExtent. | 359 // moveRangeSelectionExtent. |
355 std::unique_ptr<GranularityStrategy> m_granularityStrategy; | 360 std::unique_ptr<GranularityStrategy> m_granularityStrategy; |
356 | 361 |
357 const Member<FrameCaret> m_frameCaret; | 362 const Member<FrameCaret> m_frameCaret; |
358 bool m_useSecureKeyboardEntryWhenActive = false; | 363 bool m_useSecureKeyboardEntryWhenActive = false; |
359 }; | 364 }; |
360 | 365 |
361 } // namespace blink | 366 } // namespace blink |
362 | 367 |
363 #ifndef NDEBUG | 368 #ifndef NDEBUG |
364 // Outside the WebCore namespace for ease of invocation from gdb. | 369 // Outside the WebCore namespace for ease of invocation from gdb. |
365 void showTree(const blink::FrameSelection&); | 370 void showTree(const blink::FrameSelection&); |
366 void showTree(const blink::FrameSelection*); | 371 void showTree(const blink::FrameSelection*); |
367 #endif | 372 #endif |
368 | 373 |
369 #endif // FrameSelection_h | 374 #endif // FrameSelection_h |
OLD | NEW |