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 931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 942 FrameView* view = frame_->View(); | 942 FrameView* view = frame_->View(); |
| 943 LayoutViewItem layout_view = frame_->ContentLayoutItem(); | 943 LayoutViewItem layout_view = frame_->ContentLayoutItem(); |
| 944 | 944 |
| 945 if (!view || layout_view.IsNull()) | 945 if (!view || layout_view.IsNull()) |
| 946 return LayoutRect(); | 946 return LayoutRect(); |
| 947 | 947 |
| 948 view->UpdateLifecycleToLayoutClean(); | 948 view->UpdateLifecycleToLayoutClean(); |
| 949 return LayoutRect(layout_selection_->SelectionBounds()); | 949 return LayoutRect(layout_selection_->SelectionBounds()); |
| 950 } | 950 } |
| 951 | 951 |
| 952 static IntRect AbsoluteSelectionBoundsOf( | |
| 953 const VisibleSelectionInFlatTree& visible_selection) { | |
| 954 const SelectionInFlatTree& selection = visible_selection.AsSelection(); | |
| 955 return ComputeTextRect( | |
| 956 EphemeralRangeInFlatTree(selection.Base(), selection.Extent())); | |
|
yosin_UTC9
2017/05/22 08:11:43
I think we should use VSInFlatTree.Start() and End
yoichio
2017/05/22 08:42:21
Done.
| |
| 957 } | |
| 958 | |
| 959 // TODO(editing-dev): This should be done in FlatTree world. | |
| 952 void FrameSelection::RevealSelection(const ScrollAlignment& alignment, | 960 void FrameSelection::RevealSelection(const ScrollAlignment& alignment, |
| 953 RevealExtentOption reveal_extent_option) { | 961 RevealExtentOption reveal_extent_option) { |
| 954 DCHECK(IsAvailable()); | 962 DCHECK(IsAvailable()); |
| 955 | 963 |
| 956 // TODO(editing-dev): The use of updateStyleAndLayoutIgnorePendingStylesheets | 964 // TODO(editing-dev): The use of updateStyleAndLayoutIgnorePendingStylesheets |
| 957 // needs to be audited. See http://crbug.com/590369 for more details. | 965 // needs to be audited. See http://crbug.com/590369 for more details. |
| 958 // Calculation of absolute caret bounds requires clean layout. | 966 // Calculation of absolute caret bounds requires clean layout. |
| 959 GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheets(); | 967 GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheets(); |
| 960 | 968 |
| 961 LayoutRect rect; | 969 LayoutRect rect; |
| 962 | 970 |
| 963 switch (ComputeVisibleSelectionInDOMTree().GetSelectionType()) { | 971 switch (ComputeVisibleSelectionInDOMTree().GetSelectionType()) { |
| 964 case kNoSelection: | 972 case kNoSelection: |
| 965 return; | 973 return; |
| 966 case kCaretSelection: | 974 case kCaretSelection: |
| 967 rect = LayoutRect(AbsoluteCaretBounds()); | 975 rect = LayoutRect(AbsoluteCaretBounds()); |
| 968 break; | 976 break; |
| 969 case kRangeSelection: | 977 case kRangeSelection: |
| 970 rect = LayoutRect(reveal_extent_option == kRevealExtent | 978 rect = LayoutRect( |
| 971 ? AbsoluteCaretBoundsOf(CreateVisiblePosition( | 979 reveal_extent_option == kRevealExtent |
| 972 ComputeVisibleSelectionInDOMTree().Extent())) | 980 ? AbsoluteCaretBoundsOf(CreateVisiblePosition( |
| 973 : EnclosingIntRect(UnclippedBounds())); | 981 ComputeVisibleSelectionInDOMTree().Extent())) |
| 982 : AbsoluteSelectionBoundsOf(ComputeVisibleSelectionInFlatTree())); | |
| 974 break; | 983 break; |
| 975 } | 984 } |
| 976 | 985 |
| 977 Position start = ComputeVisibleSelectionInDOMTree().Start(); | 986 Position start = ComputeVisibleSelectionInDOMTree().Start(); |
| 978 DCHECK(start.AnchorNode()); | 987 DCHECK(start.AnchorNode()); |
| 979 if (start.AnchorNode() && start.AnchorNode()->GetLayoutObject()) { | 988 if (start.AnchorNode() && start.AnchorNode()->GetLayoutObject()) { |
| 980 // FIXME: This code only handles scrolling the startContainer's layer, but | 989 // FIXME: This code only handles scrolling the startContainer's layer, but |
| 981 // the selection rect could intersect more than just that. | 990 // the selection rect could intersect more than just that. |
| 982 if (DocumentLoader* document_loader = frame_->Loader().GetDocumentLoader()) | 991 if (DocumentLoader* document_loader = frame_->Loader().GetDocumentLoader()) |
| 983 document_loader->GetInitialScrollState().was_scrolled_by_user = true; | 992 document_loader->GetInitialScrollState().was_scrolled_by_user = true; |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1175 } | 1184 } |
| 1176 | 1185 |
| 1177 void showTree(const blink::FrameSelection* sel) { | 1186 void showTree(const blink::FrameSelection* sel) { |
| 1178 if (sel) | 1187 if (sel) |
| 1179 sel->ShowTreeForThis(); | 1188 sel->ShowTreeForThis(); |
| 1180 else | 1189 else |
| 1181 LOG(INFO) << "Cannot showTree for <null> FrameSelection."; | 1190 LOG(INFO) << "Cannot showTree for <null> FrameSelection."; |
| 1182 } | 1191 } |
| 1183 | 1192 |
| 1184 #endif | 1193 #endif |
| OLD | NEW |