| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2008, 2009, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 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 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 void SelectionEditor::updateCachedVisibleSelectionIfNeeded() const { | 363 void SelectionEditor::updateCachedVisibleSelectionIfNeeded() const { |
| 364 // Note: Since we |FrameCaret::updateApperance()| is called from | 364 // Note: Since we |FrameCaret::updateApperance()| is called from |
| 365 // |FrameView::performPostLayoutTasks()|, we check lifecycle against | 365 // |FrameView::performPostLayoutTasks()|, we check lifecycle against |
| 366 // |AfterPerformLayout| instead of |LayoutClean|. | 366 // |AfterPerformLayout| instead of |LayoutClean|. |
| 367 DCHECK_GE(document().lifecycle().state(), | 367 DCHECK_GE(document().lifecycle().state(), |
| 368 DocumentLifecycle::AfterPerformLayout); | 368 DocumentLifecycle::AfterPerformLayout); |
| 369 assertSelectionValid(); | 369 assertSelectionValid(); |
| 370 if (!needsUpdateVisibleSelection()) | 370 if (!needsUpdateVisibleSelection()) |
| 371 return; | 371 return; |
| 372 | 372 |
| 373 m_styleVersion = document().styleVersion(); |
| 374 m_cacheIsDirty = false; |
| 373 m_cachedVisibleSelectionInDOMTree = createVisibleSelection(m_selection); | 375 m_cachedVisibleSelectionInDOMTree = createVisibleSelection(m_selection); |
| 376 if (m_cachedVisibleSelectionInDOMTree.isNone()) { |
| 377 m_cachedVisibleSelectionInFlatTree = VisibleSelectionInFlatTree(); |
| 378 return; |
| 379 } |
| 374 m_cachedVisibleSelectionInFlatTree = createVisibleSelection( | 380 m_cachedVisibleSelectionInFlatTree = createVisibleSelection( |
| 375 SelectionInFlatTree::Builder() | 381 SelectionInFlatTree::Builder() |
| 376 .setBaseAndExtent(toPositionInFlatTree(m_selection.base()), | 382 .setBaseAndExtent(toPositionInFlatTree(m_selection.base()), |
| 377 toPositionInFlatTree(m_selection.extent())) | 383 toPositionInFlatTree(m_selection.extent())) |
| 378 .setAffinity(m_selection.affinity()) | 384 .setAffinity(m_selection.affinity()) |
| 379 .setHasTrailingWhitespace(m_selection.hasTrailingWhitespace()) | 385 .setHasTrailingWhitespace(m_selection.hasTrailingWhitespace()) |
| 380 .setGranularity(m_selection.granularity()) | 386 .setGranularity(m_selection.granularity()) |
| 381 .setIsDirectional(m_selection.isDirectional()) | 387 .setIsDirectional(m_selection.isDirectional()) |
| 382 .build()); | 388 .build()); |
| 383 m_styleVersion = document().styleVersion(); | |
| 384 m_cacheIsDirty = false; | |
| 385 } | 389 } |
| 386 | 390 |
| 387 void SelectionEditor::cacheRangeOfDocument(Range* range) { | 391 void SelectionEditor::cacheRangeOfDocument(Range* range) { |
| 388 m_cachedRange = range; | 392 m_cachedRange = range; |
| 389 } | 393 } |
| 390 | 394 |
| 391 Range* SelectionEditor::documentCachedRange() const { | 395 Range* SelectionEditor::documentCachedRange() const { |
| 392 return m_cachedRange; | 396 return m_cachedRange; |
| 393 } | 397 } |
| 394 | 398 |
| 395 void SelectionEditor::clearDocumentCachedRange() { | 399 void SelectionEditor::clearDocumentCachedRange() { |
| 396 m_cachedRange = nullptr; | 400 m_cachedRange = nullptr; |
| 397 } | 401 } |
| 398 | 402 |
| 399 DEFINE_TRACE(SelectionEditor) { | 403 DEFINE_TRACE(SelectionEditor) { |
| 400 visitor->trace(m_frame); | 404 visitor->trace(m_frame); |
| 401 visitor->trace(m_selection); | 405 visitor->trace(m_selection); |
| 402 visitor->trace(m_cachedVisibleSelectionInDOMTree); | 406 visitor->trace(m_cachedVisibleSelectionInDOMTree); |
| 403 visitor->trace(m_cachedVisibleSelectionInFlatTree); | 407 visitor->trace(m_cachedVisibleSelectionInFlatTree); |
| 404 visitor->trace(m_cachedRange); | 408 visitor->trace(m_cachedRange); |
| 405 SynchronousMutationObserver::trace(visitor); | 409 SynchronousMutationObserver::trace(visitor); |
| 406 } | 410 } |
| 407 | 411 |
| 408 } // namespace blink | 412 } // namespace blink |
| OLD | NEW |