| 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 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 // Note: Since we |FrameCaret::updateApperance()| is called from | 398 // Note: Since we |FrameCaret::updateApperance()| is called from |
| 399 // |FrameView::performPostLayoutTasks()|, we check lifecycle against | 399 // |FrameView::performPostLayoutTasks()|, we check lifecycle against |
| 400 // |AfterPerformLayout| instead of |LayoutClean|. | 400 // |AfterPerformLayout| instead of |LayoutClean|. |
| 401 DCHECK_GE(GetDocument().Lifecycle().GetState(), | 401 DCHECK_GE(GetDocument().Lifecycle().GetState(), |
| 402 DocumentLifecycle::kAfterPerformLayout); | 402 DocumentLifecycle::kAfterPerformLayout); |
| 403 AssertSelectionValid(); | 403 AssertSelectionValid(); |
| 404 if (!NeedsUpdateVisibleSelectionInFlatTree()) | 404 if (!NeedsUpdateVisibleSelectionInFlatTree()) |
| 405 return; | 405 return; |
| 406 style_version_for_flat_tree_ = GetDocument().StyleVersion(); | 406 style_version_for_flat_tree_ = GetDocument().StyleVersion(); |
| 407 cached_visible_selection_in_flat_tree_is_dirty_ = false; | 407 cached_visible_selection_in_flat_tree_is_dirty_ = false; |
| 408 cached_visible_selection_in_flat_tree_ = CreateVisibleSelection( | 408 SelectionInFlatTree::Builder builder; |
| 409 SelectionInFlatTree::Builder() | 409 const PositionInFlatTree& base = ToPositionInFlatTree(selection_.Base()); |
| 410 .SetBaseAndExtent(ToPositionInFlatTree(selection_.Base()), | 410 const PositionInFlatTree& extent = ToPositionInFlatTree(selection_.Extent()); |
| 411 ToPositionInFlatTree(selection_.Extent())) | 411 if (base.IsNotNull() && extent.IsNotNull()) |
| 412 .SetAffinity(selection_.Affinity()) | 412 builder.SetBaseAndExtent(base, extent); |
| 413 .SetHasTrailingWhitespace(selection_.HasTrailingWhitespace()) | 413 else if (base.IsNotNull()) |
| 414 .SetGranularity(selection_.Granularity()) | 414 builder.Collapse(base); |
| 415 .SetIsDirectional(selection_.IsDirectional()) | 415 else if (extent.IsNotNull()) |
| 416 .Build()); | 416 builder.Collapse(extent); |
| 417 builder.SetAffinity(selection_.Affinity()) |
| 418 .SetHasTrailingWhitespace(selection_.HasTrailingWhitespace()) |
| 419 .SetGranularity(selection_.Granularity()) |
| 420 .SetIsDirectional(selection_.IsDirectional()); |
| 421 cached_visible_selection_in_flat_tree_ = |
| 422 CreateVisibleSelection(builder.Build()); |
| 417 if (!cached_visible_selection_in_flat_tree_.IsNone()) | 423 if (!cached_visible_selection_in_flat_tree_.IsNone()) |
| 418 return; | 424 return; |
| 419 style_version_for_dom_tree_ = GetDocument().StyleVersion(); | 425 style_version_for_dom_tree_ = GetDocument().StyleVersion(); |
| 420 cached_visible_selection_in_dom_tree_is_dirty_ = false; | 426 cached_visible_selection_in_dom_tree_is_dirty_ = false; |
| 421 cached_visible_selection_in_dom_tree_ = VisibleSelection(); | 427 cached_visible_selection_in_dom_tree_ = VisibleSelection(); |
| 422 } | 428 } |
| 423 | 429 |
| 424 void SelectionEditor::CacheRangeOfDocument(Range* range) { | 430 void SelectionEditor::CacheRangeOfDocument(Range* range) { |
| 425 cached_range_ = range; | 431 cached_range_ = range; |
| 426 } | 432 } |
| 427 | 433 |
| 428 Range* SelectionEditor::DocumentCachedRange() const { | 434 Range* SelectionEditor::DocumentCachedRange() const { |
| 429 return cached_range_; | 435 return cached_range_; |
| 430 } | 436 } |
| 431 | 437 |
| 432 void SelectionEditor::ClearDocumentCachedRange() { | 438 void SelectionEditor::ClearDocumentCachedRange() { |
| 433 cached_range_ = nullptr; | 439 cached_range_ = nullptr; |
| 434 } | 440 } |
| 435 | 441 |
| 436 DEFINE_TRACE(SelectionEditor) { | 442 DEFINE_TRACE(SelectionEditor) { |
| 437 visitor->Trace(frame_); | 443 visitor->Trace(frame_); |
| 438 visitor->Trace(selection_); | 444 visitor->Trace(selection_); |
| 439 visitor->Trace(cached_visible_selection_in_dom_tree_); | 445 visitor->Trace(cached_visible_selection_in_dom_tree_); |
| 440 visitor->Trace(cached_visible_selection_in_flat_tree_); | 446 visitor->Trace(cached_visible_selection_in_flat_tree_); |
| 441 visitor->Trace(cached_range_); | 447 visitor->Trace(cached_range_); |
| 442 SynchronousMutationObserver::Trace(visitor); | 448 SynchronousMutationObserver::Trace(visitor); |
| 443 } | 449 } |
| 444 | 450 |
| 445 } // namespace blink | 451 } // namespace blink |
| OLD | NEW |