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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 216 | 216 |
| 217 if (extent.atRightBoundaryOfBidiRun() && | 217 if (extent.atRightBoundaryOfBidiRun() && |
| 218 extent.isEquivalent( | 218 extent.isEquivalent( |
| 219 base.rightBoundaryOfBidiRun(extent.bidiLevelOnLeft()))) { | 219 base.rightBoundaryOfBidiRun(extent.bidiLevelOnLeft()))) { |
| 220 visibleExtent = createVisiblePosition(fromPositionInDOMTree<Strategy>( | 220 visibleExtent = createVisiblePosition(fromPositionInDOMTree<Strategy>( |
| 221 extent.positionAtRightBoundaryOfBiDiRun())); | 221 extent.positionAtRightBoundaryOfBiDiRun())); |
| 222 return; | 222 return; |
| 223 } | 223 } |
| 224 } | 224 } |
| 225 | 225 |
| 226 void FrameSelection::setNonDirectionalSelectionIfNeeded( | 226 // TODO(yosin): We should move |setNonDirectionalSelectionIfNeeded()| to |
| 227 // "SelectionController.cpp" | |
| 228 void SelectionController::setNonDirectionalSelectionIfNeeded( | |
| 227 const VisibleSelectionInFlatTree& passedNewSelection, | 229 const VisibleSelectionInFlatTree& passedNewSelection, |
| 228 TextGranularity granularity, | 230 TextGranularity granularity, |
| 229 EndPointsAdjustmentMode endpointsAdjustmentMode) { | 231 EndPointsAdjustmentMode endpointsAdjustmentMode) { |
| 230 VisibleSelectionInFlatTree newSelection = passedNewSelection; | 232 VisibleSelectionInFlatTree newSelection = passedNewSelection; |
| 231 bool isDirectional = shouldAlwaysUseDirectionalSelection(m_frame) || | 233 bool isDirectional = shouldAlwaysUseDirectionalSelection(m_frame) || |
| 232 newSelection.isDirectional(); | 234 newSelection.isDirectional(); |
| 233 | 235 |
| 234 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets | 236 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets |
| 235 // needs to be audited. See http://crbug.com/590369 for more details. | 237 // needs to be audited. See http://crbug.com/590369 for more details. |
| 236 document().updateStyleAndLayoutIgnorePendingStylesheets(); | 238 document().updateStyleAndLayoutIgnorePendingStylesheets(); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 249 VisiblePositionInFlatTree newExtent = extent; | 251 VisiblePositionInFlatTree newExtent = extent; |
| 250 if (endpointsAdjustmentMode == AdjustEndpointsAtBidiBoundary) | 252 if (endpointsAdjustmentMode == AdjustEndpointsAtBidiBoundary) |
| 251 adjustEndpointsAtBidiBoundary(newBase, newExtent); | 253 adjustEndpointsAtBidiBoundary(newBase, newExtent); |
| 252 | 254 |
| 253 if (newBase.deepEquivalent() != base.deepEquivalent() || | 255 if (newBase.deepEquivalent() != base.deepEquivalent() || |
| 254 newExtent.deepEquivalent() != extent.deepEquivalent()) { | 256 newExtent.deepEquivalent() != extent.deepEquivalent()) { |
| 255 m_originalBaseInFlatTree = base; | 257 m_originalBaseInFlatTree = base; |
| 256 newSelection.setBase(newBase); | 258 newSelection.setBase(newBase); |
| 257 newSelection.setExtent(newExtent); | 259 newSelection.setExtent(newExtent); |
| 258 } else if (originalBase.isNotNull()) { | 260 } else if (originalBase.isNotNull()) { |
| 259 if (visibleSelection<EditingInFlatTreeStrategy>().base() == | 261 if (selection().visibleSelection<EditingInFlatTreeStrategy>().base() == |
| 260 newSelection.base()) | 262 newSelection.base()) |
| 261 newSelection.setBase(originalBase); | 263 newSelection.setBase(originalBase); |
| 262 m_originalBaseInFlatTree = VisiblePositionInFlatTree(); | 264 m_originalBaseInFlatTree = VisiblePositionInFlatTree(); |
| 263 } | 265 } |
| 264 | 266 |
| 265 // Adjusting base and extent will make newSelection always directional | 267 // Adjusting base and extent will make newSelection always directional |
| 266 newSelection.setIsDirectional(isDirectional); | 268 newSelection.setIsDirectional(isDirectional); |
| 267 if (visibleSelection<EditingInFlatTreeStrategy>() == newSelection) | 269 if (selection().visibleSelection<EditingInFlatTreeStrategy>() == newSelection) |
| 268 return; | 270 return; |
| 269 | 271 |
| 270 const SetSelectionOptions options = CloseTyping | ClearTypingStyle; | 272 const FrameSelection::SetSelectionOptions options = |
| 271 setSelection(newSelection, options, CursorAlignOnScroll::IfNeeded, | 273 FrameSelection::CloseTyping | FrameSelection::ClearTypingStyle; |
| 272 granularity); | 274 selection().setSelection(newSelection, options, CursorAlignOnScroll::IfNeeded, |
| 275 granularity); | |
| 273 } | 276 } |
| 274 | 277 |
| 275 template <typename Strategy> | 278 template <typename Strategy> |
| 276 void FrameSelection::setSelectionAlgorithm( | 279 void FrameSelection::setSelectionAlgorithm( |
| 277 const VisibleSelectionTemplate<Strategy>& newSelection, | 280 const VisibleSelectionTemplate<Strategy>& newSelection, |
| 278 SetSelectionOptions options, | 281 SetSelectionOptions options, |
| 279 CursorAlignOnScroll align, | 282 CursorAlignOnScroll align, |
| 280 TextGranularity granularity) { | 283 TextGranularity granularity) { |
| 281 DCHECK(isAvailable()); | 284 DCHECK(isAvailable()); |
| 282 DCHECK(newSelection.isValidFor(document())); | 285 DCHECK(newSelection.isValidFor(document())); |
| (...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 806 void FrameSelection::documentAttached(Document* document) { | 809 void FrameSelection::documentAttached(Document* document) { |
| 807 DCHECK(document); | 810 DCHECK(document); |
| 808 DCHECK(!m_document) << "FrameSelection is already attached to " << m_document; | 811 DCHECK(!m_document) << "FrameSelection is already attached to " << m_document; |
| 809 m_document = document; | 812 m_document = document; |
| 810 m_selectionEditor->documentAttached(document); | 813 m_selectionEditor->documentAttached(document); |
| 811 } | 814 } |
| 812 | 815 |
| 813 void FrameSelection::documentDetached(const Document& document) { | 816 void FrameSelection::documentDetached(const Document& document) { |
| 814 DCHECK_EQ(m_document, document); | 817 DCHECK_EQ(m_document, document); |
| 815 m_document = nullptr; | 818 m_document = nullptr; |
| 816 m_originalBaseInFlatTree = VisiblePositionInFlatTree(); | |
| 817 m_granularity = CharacterGranularity; | 819 m_granularity = CharacterGranularity; |
| 818 | 820 |
| 819 LayoutViewItem view = m_frame->contentLayoutItem(); | 821 LayoutViewItem view = m_frame->contentLayoutItem(); |
| 820 if (!view.isNull()) | 822 if (!view.isNull()) |
| 821 view.clearSelection(); | 823 view.clearSelection(); |
| 822 | 824 |
| 823 clearTypingStyle(); | 825 clearTypingStyle(); |
| 824 m_selectionEditor->documentDetached(document); | 826 m_selectionEditor->documentDetached(document); |
| 825 m_frameCaret->documentDetached(); | 827 m_frameCaret->documentDetached(); |
| 828 m_frame->eventHandler().selectionController().documentDetached(); | |
|
Xiaocheng
2016/10/24 03:53:11
SelectionController::DocumentDetached doesn't seem
yosin_UTC9
2016/10/24 07:12:12
Done.
| |
| 826 } | 829 } |
| 827 | 830 |
| 828 LayoutBlock* FrameSelection::caretLayoutObject() const { | 831 LayoutBlock* FrameSelection::caretLayoutObject() const { |
| 829 DCHECK(selection().isValidFor(document())); | 832 DCHECK(selection().isValidFor(document())); |
| 830 if (!isCaret()) | 833 if (!isCaret()) |
| 831 return nullptr; | 834 return nullptr; |
| 832 return CaretBase::caretLayoutObject(selection().start().anchorNode()); | 835 return CaretBase::caretLayoutObject(selection().start().anchorNode()); |
| 833 } | 836 } |
| 834 | 837 |
| 835 IntRect FrameSelection::absoluteCaretBounds() { | 838 IntRect FrameSelection::absoluteCaretBounds() { |
| (...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1361 selection().showTreeForThis(); | 1364 selection().showTreeForThis(); |
| 1362 } | 1365 } |
| 1363 | 1366 |
| 1364 #endif | 1367 #endif |
| 1365 | 1368 |
| 1366 DEFINE_TRACE(FrameSelection) { | 1369 DEFINE_TRACE(FrameSelection) { |
| 1367 visitor->trace(m_document); | 1370 visitor->trace(m_document); |
| 1368 visitor->trace(m_frame); | 1371 visitor->trace(m_frame); |
| 1369 visitor->trace(m_pendingSelection); | 1372 visitor->trace(m_pendingSelection); |
| 1370 visitor->trace(m_selectionEditor); | 1373 visitor->trace(m_selectionEditor); |
| 1371 visitor->trace(m_originalBaseInFlatTree); | |
| 1372 visitor->trace(m_typingStyle); | 1374 visitor->trace(m_typingStyle); |
| 1373 visitor->trace(m_frameCaret); | 1375 visitor->trace(m_frameCaret); |
| 1374 } | 1376 } |
| 1375 | 1377 |
| 1376 void FrameSelection::scheduleVisualUpdate() const { | 1378 void FrameSelection::scheduleVisualUpdate() const { |
| 1377 if (Page* page = m_frame->page()) | 1379 if (Page* page = m_frame->page()) |
| 1378 page->animator().scheduleVisualUpdate(m_frame->localFrameRoot()); | 1380 page->animator().scheduleVisualUpdate(m_frame->localFrameRoot()); |
| 1379 } | 1381 } |
| 1380 | 1382 |
| 1381 bool FrameSelection::selectWordAroundPosition(const VisiblePosition& position) { | 1383 bool FrameSelection::selectWordAroundPosition(const VisiblePosition& position) { |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1485 } | 1487 } |
| 1486 | 1488 |
| 1487 void showTree(const blink::FrameSelection* sel) { | 1489 void showTree(const blink::FrameSelection* sel) { |
| 1488 if (sel) | 1490 if (sel) |
| 1489 sel->showTreeForThis(); | 1491 sel->showTreeForThis(); |
| 1490 else | 1492 else |
| 1491 LOG(INFO) << "Cannot showTree for <null> FrameSelection."; | 1493 LOG(INFO) << "Cannot showTree for <null> FrameSelection."; |
| 1492 } | 1494 } |
| 1493 | 1495 |
| 1494 #endif | 1496 #endif |
| OLD | NEW |