| 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 916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 927 } | 927 } |
| 928 | 928 |
| 929 static bool isBoundary(TextGranularity granularity) | 929 static bool isBoundary(TextGranularity granularity) |
| 930 { | 930 { |
| 931 return granularity == LineBoundary || granularity == ParagraphBoundary || gr
anularity == DocumentBoundary; | 931 return granularity == LineBoundary || granularity == ParagraphBoundary || gr
anularity == DocumentBoundary; |
| 932 } | 932 } |
| 933 | 933 |
| 934 bool FrameSelection::modify(EAlteration alter, SelectionDirection direction, Tex
tGranularity granularity, EUserTriggered userTriggered) | 934 bool FrameSelection::modify(EAlteration alter, SelectionDirection direction, Tex
tGranularity granularity, EUserTriggered userTriggered) |
| 935 { | 935 { |
| 936 if (userTriggered == UserTriggered) { | 936 if (userTriggered == UserTriggered) { |
| 937 FrameSelection trialFrameSelection; | 937 OwnPtrWillBeRawPtr<FrameSelection> trialFrameSelection = FrameSelection:
:create(); |
| 938 trialFrameSelection.setSelection(m_selection); | 938 trialFrameSelection->setSelection(m_selection); |
| 939 trialFrameSelection.modify(alter, direction, granularity, NotUserTrigger
ed); | 939 trialFrameSelection->modify(alter, direction, granularity, NotUserTrigge
red); |
| 940 | 940 |
| 941 if (trialFrameSelection.selection().isRange() && m_selection.isCaret() &
& !dispatchSelectStart()) | 941 if (trialFrameSelection->selection().isRange() && m_selection.isCaret()
&& !dispatchSelectStart()) |
| 942 return false; | 942 return false; |
| 943 } | 943 } |
| 944 | 944 |
| 945 willBeModified(alter, direction); | 945 willBeModified(alter, direction); |
| 946 | 946 |
| 947 bool wasRange = m_selection.isRange(); | 947 bool wasRange = m_selection.isRange(); |
| 948 VisiblePosition originalStartPosition = m_selection.visibleStart(); | 948 VisiblePosition originalStartPosition = m_selection.visibleStart(); |
| 949 VisiblePosition position; | 949 VisiblePosition position; |
| 950 switch (direction) { | 950 switch (direction) { |
| 951 case DirectionRight: | 951 case DirectionRight: |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1041 y = rect.y() + rect.height() / 2; | 1041 y = rect.y() + rect.height() / 2; |
| 1042 return true; | 1042 return true; |
| 1043 } | 1043 } |
| 1044 | 1044 |
| 1045 bool FrameSelection::modify(EAlteration alter, unsigned verticalDistance, Vertic
alDirection direction, EUserTriggered userTriggered, CursorAlignOnScroll align) | 1045 bool FrameSelection::modify(EAlteration alter, unsigned verticalDistance, Vertic
alDirection direction, EUserTriggered userTriggered, CursorAlignOnScroll align) |
| 1046 { | 1046 { |
| 1047 if (!verticalDistance) | 1047 if (!verticalDistance) |
| 1048 return false; | 1048 return false; |
| 1049 | 1049 |
| 1050 if (userTriggered == UserTriggered) { | 1050 if (userTriggered == UserTriggered) { |
| 1051 FrameSelection trialFrameSelection; | 1051 OwnPtrWillBeRawPtr<FrameSelection> trialFrameSelection = FrameSelection:
:create(); |
| 1052 trialFrameSelection.setSelection(m_selection); | 1052 trialFrameSelection->setSelection(m_selection); |
| 1053 trialFrameSelection.modify(alter, verticalDistance, direction, NotUserTr
iggered); | 1053 trialFrameSelection->modify(alter, verticalDistance, direction, NotUserT
riggered); |
| 1054 } | 1054 } |
| 1055 | 1055 |
| 1056 willBeModified(alter, direction == DirectionUp ? DirectionBackward : Directi
onForward); | 1056 willBeModified(alter, direction == DirectionUp ? DirectionBackward : Directi
onForward); |
| 1057 | 1057 |
| 1058 VisiblePosition pos; | 1058 VisiblePosition pos; |
| 1059 LayoutUnit xPos = 0; | 1059 LayoutUnit xPos = 0; |
| 1060 switch (alter) { | 1060 switch (alter) { |
| 1061 case AlterationMove: | 1061 case AlterationMove: |
| 1062 pos = VisiblePosition(direction == DirectionUp ? m_selection.start() : m
_selection.end(), m_selection.affinity()); | 1062 pos = VisiblePosition(direction == DirectionUp ? m_selection.start() : m
_selection.end(), m_selection.affinity()); |
| 1063 xPos = lineDirectionPointForBlockDirectionNavigation(direction == Direct
ionUp ? START : END); | 1063 xPos = lineDirectionPointForBlockDirectionNavigation(direction == Direct
ionUp ? START : END); |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1363 Document* document = m_frame->document(); | 1363 Document* document = m_frame->document(); |
| 1364 | 1364 |
| 1365 if (isHTMLSelectElement(document->focusedElement())) { | 1365 if (isHTMLSelectElement(document->focusedElement())) { |
| 1366 HTMLSelectElement* selectElement = toHTMLSelectElement(document->focused
Element()); | 1366 HTMLSelectElement* selectElement = toHTMLSelectElement(document->focused
Element()); |
| 1367 if (selectElement->canSelectAll()) { | 1367 if (selectElement->canSelectAll()) { |
| 1368 selectElement->selectAll(); | 1368 selectElement->selectAll(); |
| 1369 return; | 1369 return; |
| 1370 } | 1370 } |
| 1371 } | 1371 } |
| 1372 | 1372 |
| 1373 RefPtr<Node> root = nullptr; | 1373 RefPtrWillBeRawPtr<Node> root = nullptr; |
| 1374 Node* selectStartTarget = 0; | 1374 Node* selectStartTarget = 0; |
| 1375 if (isContentEditable()) { | 1375 if (isContentEditable()) { |
| 1376 root = highestEditableRoot(m_selection.start()); | 1376 root = highestEditableRoot(m_selection.start()); |
| 1377 if (Node* shadowRoot = m_selection.nonBoundaryShadowTreeRootNode()) | 1377 if (Node* shadowRoot = m_selection.nonBoundaryShadowTreeRootNode()) |
| 1378 selectStartTarget = shadowRoot->shadowHost(); | 1378 selectStartTarget = shadowRoot->shadowHost(); |
| 1379 else | 1379 else |
| 1380 selectStartTarget = root.get(); | 1380 selectStartTarget = root.get(); |
| 1381 } else { | 1381 } else { |
| 1382 root = m_selection.nonBoundaryShadowTreeRootNode(); | 1382 root = m_selection.nonBoundaryShadowTreeRootNode(); |
| 1383 if (root) | 1383 if (root) |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1441 if (m_selection.start().isNotNull() && m_selection.end().isNotNull()) { | 1441 if (m_selection.start().isNotNull() && m_selection.end().isNotNull()) { |
| 1442 if (AXObjectCache* cache = m_frame->document()->existingAXObjectCache()) | 1442 if (AXObjectCache* cache = m_frame->document()->existingAXObjectCache()) |
| 1443 cache->selectionChanged(m_selection.start().containerNode()); | 1443 cache->selectionChanged(m_selection.start().containerNode()); |
| 1444 } | 1444 } |
| 1445 } | 1445 } |
| 1446 | 1446 |
| 1447 void FrameSelection::focusedOrActiveStateChanged() | 1447 void FrameSelection::focusedOrActiveStateChanged() |
| 1448 { | 1448 { |
| 1449 bool activeAndFocused = isFocusedAndActive(); | 1449 bool activeAndFocused = isFocusedAndActive(); |
| 1450 | 1450 |
| 1451 RefPtr<Document> document = m_frame->document(); | 1451 RefPtrWillBeRawPtr<Document> document = m_frame->document(); |
| 1452 document->updateRenderTreeIfNeeded(); | 1452 document->updateRenderTreeIfNeeded(); |
| 1453 | 1453 |
| 1454 // Because RenderObject::selectionBackgroundColor() and | 1454 // Because RenderObject::selectionBackgroundColor() and |
| 1455 // RenderObject::selectionForegroundColor() check if the frame is active, | 1455 // RenderObject::selectionForegroundColor() check if the frame is active, |
| 1456 // we have to update places those colors were painted. | 1456 // we have to update places those colors were painted. |
| 1457 if (RenderView* view = document->renderView()) | 1457 if (RenderView* view = document->renderView()) |
| 1458 view->repaintSelection(); | 1458 view->repaintSelection(); |
| 1459 | 1459 |
| 1460 // Caret appears in the active frame. | 1460 // Caret appears in the active frame. |
| 1461 if (activeAndFocused) | 1461 if (activeAndFocused) |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1856 m_selection.formatForDebugger(buffer, length); | 1856 m_selection.formatForDebugger(buffer, length); |
| 1857 } | 1857 } |
| 1858 | 1858 |
| 1859 void FrameSelection::showTreeForThis() const | 1859 void FrameSelection::showTreeForThis() const |
| 1860 { | 1860 { |
| 1861 m_selection.showTreeForThis(); | 1861 m_selection.showTreeForThis(); |
| 1862 } | 1862 } |
| 1863 | 1863 |
| 1864 #endif | 1864 #endif |
| 1865 | 1865 |
| 1866 void FrameSelection::trace(Visitor* visitor) |
| 1867 { |
| 1868 visitor->trace(m_logicalRange); |
| 1869 visitor->trace(m_previousCaretNode); |
| 1870 visitor->trace(m_typingStyle); |
| 1871 } |
| 1872 |
| 1866 } | 1873 } |
| 1867 | 1874 |
| 1868 #ifndef NDEBUG | 1875 #ifndef NDEBUG |
| 1869 | 1876 |
| 1870 void showTree(const WebCore::FrameSelection& sel) | 1877 void showTree(const WebCore::FrameSelection& sel) |
| 1871 { | 1878 { |
| 1872 sel.showTreeForThis(); | 1879 sel.showTreeForThis(); |
| 1873 } | 1880 } |
| 1874 | 1881 |
| 1875 void showTree(const WebCore::FrameSelection* sel) | 1882 void showTree(const WebCore::FrameSelection* sel) |
| 1876 { | 1883 { |
| 1877 if (sel) | 1884 if (sel) |
| 1878 sel->showTreeForThis(); | 1885 sel->showTreeForThis(); |
| 1879 } | 1886 } |
| 1880 | 1887 |
| 1881 #endif | 1888 #endif |
| OLD | NEW |