Chromium Code Reviews| 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 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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_cachedVisibleSelectionInDOMTree = createVisibleSelection(m_selection); | 373 m_cachedVisibleSelectionInDOMTree = createVisibleSelection(m_selection); |
| 374 m_cachedVisibleSelectionInFlatTree = createVisibleSelection( | 374 if (m_cachedVisibleSelectionInDOMTree.isNone()) { |
|
yosin_UTC9
2017/03/16 02:30:05
Good catch!
Please move this shortcut in another
yoichio
2017/03/16 04:10:59
This is core of this CL and needs for performance
| |
| 375 SelectionInFlatTree::Builder() | 375 m_cachedVisibleSelectionInFlatTree = VisibleSelectionInFlatTree(); |
| 376 .setBaseAndExtent(toPositionInFlatTree(m_selection.base()), | 376 } else { |
| 377 toPositionInFlatTree(m_selection.extent())) | 377 m_cachedVisibleSelectionInFlatTree = createVisibleSelection( |
| 378 .setAffinity(m_selection.affinity()) | 378 SelectionInFlatTree::Builder() |
| 379 .setHasTrailingWhitespace(m_selection.hasTrailingWhitespace()) | 379 .setBaseAndExtent(toPositionInFlatTree(m_selection.base()), |
| 380 .setGranularity(m_selection.granularity()) | 380 toPositionInFlatTree(m_selection.extent())) |
| 381 .setIsDirectional(m_selection.isDirectional()) | 381 .setAffinity(m_selection.affinity()) |
| 382 .build()); | 382 .setHasTrailingWhitespace(m_selection.hasTrailingWhitespace()) |
| 383 .setGranularity(m_selection.granularity()) | |
| 384 .setIsDirectional(m_selection.isDirectional()) | |
| 385 .build()); | |
| 386 } | |
| 383 m_styleVersion = document().styleVersion(); | 387 m_styleVersion = document().styleVersion(); |
| 384 m_cacheIsDirty = false; | 388 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 |