Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Side by Side Diff: Source/core/editing/FrameSelection.cpp

Issue 299353004: Oilpan: move editing objects to the heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Make test wrapper class finalized Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/editing/FrameSelection.h ('k') | Source/core/editing/IndentOutdentCommand.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 , m_isCaretBlinkingSuspended(false) 100 , m_isCaretBlinkingSuspended(false)
101 , m_focused(frame && frame->page() && frame->page()->focusController().focus edFrame() == frame) 101 , m_focused(frame && frame->page() && frame->page()->focusController().focus edFrame() == frame)
102 , m_shouldShowBlockCursor(false) 102 , m_shouldShowBlockCursor(false)
103 { 103 {
104 if (shouldAlwaysUseDirectionalSelection(m_frame)) 104 if (shouldAlwaysUseDirectionalSelection(m_frame))
105 m_selection.setIsDirectional(true); 105 m_selection.setIsDirectional(true);
106 } 106 }
107 107
108 FrameSelection::~FrameSelection() 108 FrameSelection::~FrameSelection()
109 { 109 {
110 #if !ENABLE(OILPAN)
111 // Oilpan: No need to clear out VisibleSelection observer;
112 // it is finalized as a part object of FrameSelection.
110 stopObservingVisibleSelectionChangeIfNecessary(); 113 stopObservingVisibleSelectionChangeIfNecessary();
114 #endif
111 } 115 }
112 116
113 Element* FrameSelection::rootEditableElementOrDocumentElement() const 117 Element* FrameSelection::rootEditableElementOrDocumentElement() const
114 { 118 {
115 Element* selectionRoot = m_selection.rootEditableElement(); 119 Element* selectionRoot = m_selection.rootEditableElement();
116 return selectionRoot ? selectionRoot : m_frame->document()->documentElement( ); 120 return selectionRoot ? selectionRoot : m_frame->document()->documentElement( );
117 } 121 }
118 122
119 Node* FrameSelection::rootEditableElementOrTreeScopeRootNode() const 123 Node* FrameSelection::rootEditableElementOrTreeScopeRootNode() const
120 { 124 {
(...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after
927 } 931 }
928 932
929 static bool isBoundary(TextGranularity granularity) 933 static bool isBoundary(TextGranularity granularity)
930 { 934 {
931 return granularity == LineBoundary || granularity == ParagraphBoundary || gr anularity == DocumentBoundary; 935 return granularity == LineBoundary || granularity == ParagraphBoundary || gr anularity == DocumentBoundary;
932 } 936 }
933 937
934 bool FrameSelection::modify(EAlteration alter, SelectionDirection direction, Tex tGranularity granularity, EUserTriggered userTriggered) 938 bool FrameSelection::modify(EAlteration alter, SelectionDirection direction, Tex tGranularity granularity, EUserTriggered userTriggered)
935 { 939 {
936 if (userTriggered == UserTriggered) { 940 if (userTriggered == UserTriggered) {
937 FrameSelection trialFrameSelection; 941 OwnPtrWillBeRawPtr<FrameSelection> trialFrameSelection = FrameSelection: :create();
938 trialFrameSelection.setSelection(m_selection); 942 trialFrameSelection->setSelection(m_selection);
939 trialFrameSelection.modify(alter, direction, granularity, NotUserTrigger ed); 943 trialFrameSelection->modify(alter, direction, granularity, NotUserTrigge red);
940 944
941 if (trialFrameSelection.selection().isRange() && m_selection.isCaret() & & !dispatchSelectStart()) 945 if (trialFrameSelection->selection().isRange() && m_selection.isCaret() && !dispatchSelectStart())
942 return false; 946 return false;
943 } 947 }
944 948
945 willBeModified(alter, direction); 949 willBeModified(alter, direction);
946 950
947 bool wasRange = m_selection.isRange(); 951 bool wasRange = m_selection.isRange();
948 VisiblePosition originalStartPosition = m_selection.visibleStart(); 952 VisiblePosition originalStartPosition = m_selection.visibleStart();
949 VisiblePosition position; 953 VisiblePosition position;
950 switch (direction) { 954 switch (direction) {
951 case DirectionRight: 955 case DirectionRight:
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
1041 y = rect.y() + rect.height() / 2; 1045 y = rect.y() + rect.height() / 2;
1042 return true; 1046 return true;
1043 } 1047 }
1044 1048
1045 bool FrameSelection::modify(EAlteration alter, unsigned verticalDistance, Vertic alDirection direction, EUserTriggered userTriggered, CursorAlignOnScroll align) 1049 bool FrameSelection::modify(EAlteration alter, unsigned verticalDistance, Vertic alDirection direction, EUserTriggered userTriggered, CursorAlignOnScroll align)
1046 { 1050 {
1047 if (!verticalDistance) 1051 if (!verticalDistance)
1048 return false; 1052 return false;
1049 1053
1050 if (userTriggered == UserTriggered) { 1054 if (userTriggered == UserTriggered) {
1051 FrameSelection trialFrameSelection; 1055 OwnPtrWillBeRawPtr<FrameSelection> trialFrameSelection = FrameSelection: :create();
1052 trialFrameSelection.setSelection(m_selection); 1056 trialFrameSelection->setSelection(m_selection);
1053 trialFrameSelection.modify(alter, verticalDistance, direction, NotUserTr iggered); 1057 trialFrameSelection->modify(alter, verticalDistance, direction, NotUserT riggered);
1054 } 1058 }
1055 1059
1056 willBeModified(alter, direction == DirectionUp ? DirectionBackward : Directi onForward); 1060 willBeModified(alter, direction == DirectionUp ? DirectionBackward : Directi onForward);
1057 1061
1058 VisiblePosition pos; 1062 VisiblePosition pos;
1059 LayoutUnit xPos = 0; 1063 LayoutUnit xPos = 0;
1060 switch (alter) { 1064 switch (alter) {
1061 case AlterationMove: 1065 case AlterationMove:
1062 pos = VisiblePosition(direction == DirectionUp ? m_selection.start() : m _selection.end(), m_selection.affinity()); 1066 pos = VisiblePosition(direction == DirectionUp ? m_selection.start() : m _selection.end(), m_selection.affinity());
1063 xPos = lineDirectionPointForBlockDirectionNavigation(direction == Direct ionUp ? START : END); 1067 xPos = lineDirectionPointForBlockDirectionNavigation(direction == Direct ionUp ? START : END);
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
1363 Document* document = m_frame->document(); 1367 Document* document = m_frame->document();
1364 1368
1365 if (isHTMLSelectElement(document->focusedElement())) { 1369 if (isHTMLSelectElement(document->focusedElement())) {
1366 HTMLSelectElement* selectElement = toHTMLSelectElement(document->focused Element()); 1370 HTMLSelectElement* selectElement = toHTMLSelectElement(document->focused Element());
1367 if (selectElement->canSelectAll()) { 1371 if (selectElement->canSelectAll()) {
1368 selectElement->selectAll(); 1372 selectElement->selectAll();
1369 return; 1373 return;
1370 } 1374 }
1371 } 1375 }
1372 1376
1373 RefPtr<Node> root = nullptr; 1377 RefPtrWillBeRawPtr<Node> root = nullptr;
1374 Node* selectStartTarget = 0; 1378 Node* selectStartTarget = 0;
1375 if (isContentEditable()) { 1379 if (isContentEditable()) {
1376 root = highestEditableRoot(m_selection.start()); 1380 root = highestEditableRoot(m_selection.start());
1377 if (Node* shadowRoot = m_selection.nonBoundaryShadowTreeRootNode()) 1381 if (Node* shadowRoot = m_selection.nonBoundaryShadowTreeRootNode())
1378 selectStartTarget = shadowRoot->shadowHost(); 1382 selectStartTarget = shadowRoot->shadowHost();
1379 else 1383 else
1380 selectStartTarget = root.get(); 1384 selectStartTarget = root.get();
1381 } else { 1385 } else {
1382 root = m_selection.nonBoundaryShadowTreeRootNode(); 1386 root = m_selection.nonBoundaryShadowTreeRootNode();
1383 if (root) 1387 if (root)
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1441 if (m_selection.start().isNotNull() && m_selection.end().isNotNull()) { 1445 if (m_selection.start().isNotNull() && m_selection.end().isNotNull()) {
1442 if (AXObjectCache* cache = m_frame->document()->existingAXObjectCache()) 1446 if (AXObjectCache* cache = m_frame->document()->existingAXObjectCache())
1443 cache->selectionChanged(m_selection.start().containerNode()); 1447 cache->selectionChanged(m_selection.start().containerNode());
1444 } 1448 }
1445 } 1449 }
1446 1450
1447 void FrameSelection::focusedOrActiveStateChanged() 1451 void FrameSelection::focusedOrActiveStateChanged()
1448 { 1452 {
1449 bool activeAndFocused = isFocusedAndActive(); 1453 bool activeAndFocused = isFocusedAndActive();
1450 1454
1451 RefPtr<Document> document = m_frame->document(); 1455 RefPtrWillBeRawPtr<Document> document = m_frame->document();
1452 document->updateRenderTreeIfNeeded(); 1456 document->updateRenderTreeIfNeeded();
1453 1457
1454 // Because RenderObject::selectionBackgroundColor() and 1458 // Because RenderObject::selectionBackgroundColor() and
1455 // RenderObject::selectionForegroundColor() check if the frame is active, 1459 // RenderObject::selectionForegroundColor() check if the frame is active,
1456 // we have to update places those colors were painted. 1460 // we have to update places those colors were painted.
1457 if (RenderView* view = document->renderView()) 1461 if (RenderView* view = document->renderView())
1458 view->repaintSelection(); 1462 view->repaintSelection();
1459 1463
1460 // Caret appears in the active frame. 1464 // Caret appears in the active frame.
1461 if (activeAndFocused) 1465 if (activeAndFocused)
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
1856 m_selection.formatForDebugger(buffer, length); 1860 m_selection.formatForDebugger(buffer, length);
1857 } 1861 }
1858 1862
1859 void FrameSelection::showTreeForThis() const 1863 void FrameSelection::showTreeForThis() const
1860 { 1864 {
1861 m_selection.showTreeForThis(); 1865 m_selection.showTreeForThis();
1862 } 1866 }
1863 1867
1864 #endif 1868 #endif
1865 1869
1870 void FrameSelection::trace(Visitor* visitor)
1871 {
1872 visitor->trace(m_selection);
1873 visitor->trace(m_originalBase);
1874 visitor->trace(m_logicalRange);
1875 visitor->trace(m_previousCaretNode);
1876 visitor->trace(m_typingStyle);
1877 VisibleSelection::ChangeObserver::trace(visitor);
1878 }
1879
1866 } 1880 }
1867 1881
1868 #ifndef NDEBUG 1882 #ifndef NDEBUG
1869 1883
1870 void showTree(const WebCore::FrameSelection& sel) 1884 void showTree(const WebCore::FrameSelection& sel)
1871 { 1885 {
1872 sel.showTreeForThis(); 1886 sel.showTreeForThis();
1873 } 1887 }
1874 1888
1875 void showTree(const WebCore::FrameSelection* sel) 1889 void showTree(const WebCore::FrameSelection* sel)
1876 { 1890 {
1877 if (sel) 1891 if (sel)
1878 sel->showTreeForThis(); 1892 sel->showTreeForThis();
1879 } 1893 }
1880 1894
1881 #endif 1895 #endif
OLDNEW
« no previous file with comments | « Source/core/editing/FrameSelection.h ('k') | Source/core/editing/IndentOutdentCommand.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698