| 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 20 matching lines...) Expand all Loading... |
| 31 #include "core/dom/Range.h" | 31 #include "core/dom/Range.h" |
| 32 #include "core/dom/SynchronousMutationObserver.h" | 32 #include "core/dom/SynchronousMutationObserver.h" |
| 33 #include "core/editing/EphemeralRange.h" | 33 #include "core/editing/EphemeralRange.h" |
| 34 #include "core/editing/VisiblePosition.h" | 34 #include "core/editing/VisiblePosition.h" |
| 35 #include "core/editing/VisibleSelection.h" | 35 #include "core/editing/VisibleSelection.h" |
| 36 #include "core/editing/iterators/TextIteratorBehavior.h" | 36 #include "core/editing/iterators/TextIteratorBehavior.h" |
| 37 #include "core/layout/ScrollAlignment.h" | 37 #include "core/layout/ScrollAlignment.h" |
| 38 #include "platform/Timer.h" | 38 #include "platform/Timer.h" |
| 39 #include "platform/geometry/IntRect.h" | 39 #include "platform/geometry/IntRect.h" |
| 40 #include "platform/geometry/LayoutRect.h" | 40 #include "platform/geometry/LayoutRect.h" |
| 41 #include "platform/graphics/PaintInvalidationReason.h" |
| 41 #include "platform/heap/Handle.h" | 42 #include "platform/heap/Handle.h" |
| 42 #include "wtf/Noncopyable.h" | 43 #include "wtf/Noncopyable.h" |
| 43 #include <memory> | 44 #include <memory> |
| 44 | 45 |
| 45 namespace blink { | 46 namespace blink { |
| 46 | 47 |
| 47 class CharacterData; | 48 class CharacterData; |
| 48 class DisplayItemClient; | 49 class DisplayItemClient; |
| 49 class LayoutBlock; | 50 class LayoutBlock; |
| 50 class LocalFrame; | 51 class LocalFrame; |
| 51 class FrameCaret; | 52 class FrameCaret; |
| 52 class GranularityStrategy; | 53 class GranularityStrategy; |
| 53 class GraphicsContext; | 54 class GraphicsContext; |
| 54 class HTMLFormElement; | 55 class HTMLFormElement; |
| 55 class SelectionEditor; | 56 class SelectionEditor; |
| 56 class PendingSelection; | 57 class PendingSelection; |
| 57 class Text; | 58 class Text; |
| 58 class TextIteratorBehavior; | 59 class TextIteratorBehavior; |
| 60 struct PaintInvalidatorContext; |
| 59 | 61 |
| 60 enum class CursorAlignOnScroll { IfNeeded, Always }; | 62 enum class CursorAlignOnScroll { IfNeeded, Always }; |
| 61 | 63 |
| 62 enum EUserTriggered { NotUserTriggered = 0, UserTriggered = 1 }; | 64 enum EUserTriggered { NotUserTriggered = 0, UserTriggered = 1 }; |
| 63 | 65 |
| 64 enum RevealExtentOption { RevealExtent, DoNotRevealExtent }; | 66 enum RevealExtentOption { RevealExtent, DoNotRevealExtent }; |
| 65 | 67 |
| 66 enum class SelectionDirectionalMode { NonDirectional, Directional }; | 68 enum class SelectionDirectionalMode { NonDirectional, Directional }; |
| 67 | 69 |
| 68 enum class CaretVisibility; | 70 enum class CaretVisibility; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 const VisiblePosition& extent, | 184 const VisiblePosition& extent, |
| 183 TextGranularity); | 185 TextGranularity); |
| 184 | 186 |
| 185 TextGranularity granularity() const { return m_granularity; } | 187 TextGranularity granularity() const { return m_granularity; } |
| 186 | 188 |
| 187 Position base() const { return selection().base(); } | 189 Position base() const { return selection().base(); } |
| 188 Position extent() const { return selection().extent(); } | 190 Position extent() const { return selection().extent(); } |
| 189 Position start() const { return selection().start(); } | 191 Position start() const { return selection().start(); } |
| 190 Position end() const { return selection().end(); } | 192 Position end() const { return selection().end(); } |
| 191 | 193 |
| 192 // Returns true if specified layout block has caret. This function is | 194 // Returns true if specified layout block should paint caret. This function is |
| 193 // called during InRecalStyle and InPaint. | 195 // called during painting only. |
| 194 bool hasCaretIn(const LayoutBlock&) const; | 196 bool shouldPaintCaret(const LayoutBlock&) const; |
| 195 | 197 |
| 196 // Bounds of (possibly transformed) caret in absolute coords | 198 // Bounds of (possibly transformed) caret in absolute coords |
| 197 IntRect absoluteCaretBounds(); | 199 IntRect absoluteCaretBounds(); |
| 198 | 200 |
| 199 void didChangeFocus(); | 201 void didChangeFocus(); |
| 200 | 202 |
| 201 bool isNone() const { return selection().isNone(); } | 203 bool isNone() const { return selection().isNone(); } |
| 202 bool isCaret() const { return selection().isCaret(); } | 204 bool isCaret() const { return selection().isCaret(); } |
| 203 bool isRange() const { return selection().isRange(); } | 205 bool isRange() const { return selection().isRange(); } |
| 204 bool isInPasswordField() const; | 206 bool isInPasswordField() const; |
| 205 bool isDirectional() const { return selection().isDirectional(); } | 207 bool isDirectional() const { return selection().isDirectional(); } |
| 206 | 208 |
| 207 // If this FrameSelection has a logical range which is still valid, this | 209 // If this FrameSelection has a logical range which is still valid, this |
| 208 // function return its clone. Otherwise, the return value from underlying | 210 // function return its clone. Otherwise, the return value from underlying |
| 209 // VisibleSelection's firstRange() is returned. | 211 // VisibleSelection's firstRange() is returned. |
| 210 Range* firstRange() const; | 212 Range* firstRange() const; |
| 211 | 213 |
| 212 void documentAttached(Document*); | 214 void documentAttached(Document*); |
| 213 void dataWillChange(const CharacterData& node); | |
| 214 | 215 |
| 215 void didLayout(); | 216 void didLayout(); |
| 216 bool isAppearanceDirty() const; | 217 bool isAppearanceDirty() const; |
| 217 void commitAppearanceIfNeeded(LayoutView&); | 218 void commitAppearanceIfNeeded(LayoutView&); |
| 218 void setCaretVisible(bool caretIsVisible); | 219 void setCaretVisible(bool caretIsVisible); |
| 219 void setCaretRectNeedsUpdate(); | |
| 220 void scheduleVisualUpdate() const; | 220 void scheduleVisualUpdate() const; |
| 221 void invalidateCaretRect(bool forceInvalidation = false); | 221 void scheduleVisualUpdateForPaintInvalidationIfNeeded() const; |
| 222 |
| 223 // Paint invalidation methods delegating to FrameCaret. |
| 224 void clearPreviousCaretVisualRect(const LayoutBlock&); |
| 225 void layoutBlockWillBeDestroyed(const LayoutBlock&); |
| 226 void updateForPaintInvalidation(); |
| 227 void invalidatePaintIfNeeded(const LayoutBlock&, |
| 228 const PaintInvalidatorContext&, |
| 229 PaintInvalidationReason); |
| 230 |
| 222 void paintCaret(GraphicsContext&, const LayoutPoint&); | 231 void paintCaret(GraphicsContext&, const LayoutPoint&); |
| 223 | 232 |
| 224 // Used to suspend caret blinking while the mouse is down. | 233 // Used to suspend caret blinking while the mouse is down. |
| 225 void setCaretBlinkingSuspended(bool); | 234 void setCaretBlinkingSuspended(bool); |
| 226 bool isCaretBlinkingSuspended() const; | 235 bool isCaretBlinkingSuspended() const; |
| 227 | 236 |
| 228 // Focus | 237 // Focus |
| 229 void setFocused(bool); | 238 void setFocused(bool); |
| 230 bool isFocused() const { return m_focused; } | 239 bool isFocused() const { return m_focused; } |
| 231 bool isFocusedAndActive() const; | 240 bool isFocusedAndActive() const; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 | 282 |
| 274 // TODO(yosin): We should check DOM tree version and style version in | 283 // TODO(yosin): We should check DOM tree version and style version in |
| 275 // |FrameSelection::selection()| to make sure we use updated selection, | 284 // |FrameSelection::selection()| to make sure we use updated selection, |
| 276 // rather than having |updateIfNeeded()|. Once, we update all layout tests | 285 // rather than having |updateIfNeeded()|. Once, we update all layout tests |
| 277 // to use updated selection, we should make |updateIfNeeded()| private. | 286 // to use updated selection, we should make |updateIfNeeded()| private. |
| 278 void updateIfNeeded(); | 287 void updateIfNeeded(); |
| 279 | 288 |
| 280 DECLARE_TRACE(); | 289 DECLARE_TRACE(); |
| 281 | 290 |
| 282 private: | 291 private: |
| 292 friend class BlockPaintInvalidatorTest; |
| 283 friend class FrameSelectionTest; | 293 friend class FrameSelectionTest; |
| 284 friend class PaintControllerPaintTestForSlimmingPaintV1AndV2; | 294 friend class PaintControllerPaintTestForSlimmingPaintV1AndV2; |
| 285 friend class SelectionControllerTest; | 295 friend class SelectionControllerTest; |
| 286 FRIEND_TEST_ALL_PREFIXES(PaintControllerPaintTestForSlimmingPaintV1AndV2, | 296 FRIEND_TEST_ALL_PREFIXES(PaintControllerPaintTestForSlimmingPaintV1AndV2, |
| 287 FullDocumentPaintingWithCaret); | 297 FullDocumentPaintingWithCaret); |
| 288 | 298 |
| 289 explicit FrameSelection(LocalFrame&); | 299 explicit FrameSelection(LocalFrame&); |
| 290 | 300 |
| 291 // For |PaintControllerPaintTestForSlimmingPaintV1AndV2|. | |
| 292 const DisplayItemClient& caretDisplayItemClientForTesting() const; | 301 const DisplayItemClient& caretDisplayItemClientForTesting() const; |
| 293 | 302 |
| 294 // Note: We have |selectionInFlatTree()| for unit tests, we should | 303 // Note: We have |selectionInFlatTree()| for unit tests, we should |
| 295 // use |visibleSelection<EditingInFlatTreeStrategy>()|. | 304 // use |visibleSelection<EditingInFlatTreeStrategy>()|. |
| 296 const VisibleSelectionInFlatTree& selectionInFlatTree() const; | 305 const VisibleSelectionInFlatTree& selectionInFlatTree() const; |
| 297 | 306 |
| 298 template <typename Strategy> | 307 template <typename Strategy> |
| 299 void setSelectionAlgorithm(const VisibleSelectionTemplate<Strategy>&, | 308 void setSelectionAlgorithm(const VisibleSelectionTemplate<Strategy>&, |
| 300 SetSelectionOptions, | 309 SetSelectionOptions, |
| 301 CursorAlignOnScroll, | 310 CursorAlignOnScroll, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 328 void nodeWillBeRemoved(Node&) final; | 337 void nodeWillBeRemoved(Node&) final; |
| 329 void didUpdateCharacterData(CharacterData*, | 338 void didUpdateCharacterData(CharacterData*, |
| 330 unsigned offset, | 339 unsigned offset, |
| 331 unsigned oldLength, | 340 unsigned oldLength, |
| 332 unsigned newLength) final; | 341 unsigned newLength) final; |
| 333 void didMergeTextNodes(const Text& mergedNode, | 342 void didMergeTextNodes(const Text& mergedNode, |
| 334 const NodeWithIndex& nodeToBeRemovedWithIndex, | 343 const NodeWithIndex& nodeToBeRemovedWithIndex, |
| 335 unsigned oldLength) final; | 344 unsigned oldLength) final; |
| 336 void didSplitTextNode(const Text& oldNode) final; | 345 void didSplitTextNode(const Text& oldNode) final; |
| 337 | 346 |
| 338 // For unittests | |
| 339 bool shouldPaintCaretForTesting() const; | |
| 340 bool isPreviousCaretDirtyForTesting() const; | |
| 341 | |
| 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 |