| 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 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 } | 283 } |
| 284 | 284 |
| 285 // <http://bugs.webkit.org/show_bug.cgi?id=23464>: Infinite recursion at | 285 // <http://bugs.webkit.org/show_bug.cgi?id=23464>: Infinite recursion at |
| 286 // |FrameSelection::setSelection| | 286 // |FrameSelection::setSelection| |
| 287 // if |document->frame()| == |m_frame| we can get into an infinite loop | 287 // if |document->frame()| == |m_frame| we can get into an infinite loop |
| 288 if (s.base().anchorNode()) { | 288 if (s.base().anchorNode()) { |
| 289 Document& document = *s.base().document(); | 289 Document& document = *s.base().document(); |
| 290 // TODO(hajimehoshi): validateSelection already checks if the selection | 290 // TODO(hajimehoshi): validateSelection already checks if the selection |
| 291 // is valid, thus we don't need this 'if' clause any more. | 291 // is valid, thus we don't need this 'if' clause any more. |
| 292 if (document.frame() && document.frame() != m_frame && document != m_fra
me->document()) { | 292 if (document.frame() && document.frame() != m_frame && document != m_fra
me->document()) { |
| 293 RefPtrWillBeRawPtr<LocalFrame> guard(document.frame()); | 293 RawPtr<LocalFrame> guard(document.frame()); |
| 294 document.frame()->selection().setSelection(s, options, align, granul
arity); | 294 document.frame()->selection().setSelection(s, options, align, granul
arity); |
| 295 // It's possible that during the above set selection, this | 295 // It's possible that during the above set selection, this |
| 296 // |FrameSelection| has been modified by | 296 // |FrameSelection| has been modified by |
| 297 // |selectFrameElementInParentIfFullySelected|, but that the | 297 // |selectFrameElementInParentIfFullySelected|, but that the |
| 298 // selection is no longer valid since the frame is about to be | 298 // selection is no longer valid since the frame is about to be |
| 299 // destroyed. If this is the case, clear our selection. | 299 // destroyed. If this is the case, clear our selection. |
| 300 if (!guard->host() && !selection().isNonOrphanedCaretOrRange()) | 300 if (!guard->host() && !selection().isNonOrphanedCaretOrRange()) |
| 301 clear(); | 301 clear(); |
| 302 return; | 302 return; |
| 303 } | 303 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 333 if (!(options & DoNotUpdateAppearance)) { | 333 if (!(options & DoNotUpdateAppearance)) { |
| 334 // Hits in compositing/overflow/do-not-paint-outline-into-composited-scr
olling-contents.html | 334 // Hits in compositing/overflow/do-not-paint-outline-into-composited-scr
olling-contents.html |
| 335 DisableCompositingQueryAsserts disabler; | 335 DisableCompositingQueryAsserts disabler; |
| 336 stopCaretBlinkTimer(); | 336 stopCaretBlinkTimer(); |
| 337 updateAppearance(); | 337 updateAppearance(); |
| 338 } | 338 } |
| 339 | 339 |
| 340 // Always clear the x position used for vertical arrow navigation. | 340 // Always clear the x position used for vertical arrow navigation. |
| 341 // It will be restored by the vertical arrow navigation code if necessary. | 341 // It will be restored by the vertical arrow navigation code if necessary. |
| 342 m_selectionEditor->resetXPosForVerticalArrowNavigation(); | 342 m_selectionEditor->resetXPosForVerticalArrowNavigation(); |
| 343 RefPtrWillBeRawPtr<LocalFrame> protector(m_frame.get()); | 343 RawPtr<LocalFrame> protector(m_frame.get()); |
| 344 // This may dispatch a synchronous focus-related events. | 344 // This may dispatch a synchronous focus-related events. |
| 345 selectFrameElementInParentIfFullySelected(); | 345 selectFrameElementInParentIfFullySelected(); |
| 346 notifyLayoutObjectOfSelectionChange(userTriggered); | 346 notifyLayoutObjectOfSelectionChange(userTriggered); |
| 347 // If the selections are same in the DOM tree but not in the flat tree, | 347 // If the selections are same in the DOM tree but not in the flat tree, |
| 348 // don't fire events. For example, if the selection crosses shadow tree | 348 // don't fire events. For example, if the selection crosses shadow tree |
| 349 // boundary, selection for the DOM tree is shrunk while that for the | 349 // boundary, selection for the DOM tree is shrunk while that for the |
| 350 // flat tree is not. Additionally, this case occurs in some edge cases. | 350 // flat tree is not. Additionally, this case occurs in some edge cases. |
| 351 // See also: editing/pasteboard/4076267-3.html | 351 // See also: editing/pasteboard/4076267-3.html |
| 352 if (oldSelection == m_selectionEditor->visibleSelection<Strategy>()) { | 352 if (oldSelection == m_selectionEditor->visibleSelection<Strategy>()) { |
| 353 m_frame->inputMethodController().cancelCompositionIfSelectionIsInvalid()
; | 353 m_frame->inputMethodController().cancelCompositionIfSelectionIsInvalid()
; |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 830 Document* document = m_frame->document(); | 830 Document* document = m_frame->document(); |
| 831 | 831 |
| 832 if (isHTMLSelectElement(document->focusedElement())) { | 832 if (isHTMLSelectElement(document->focusedElement())) { |
| 833 HTMLSelectElement* selectElement = toHTMLSelectElement(document->focused
Element()); | 833 HTMLSelectElement* selectElement = toHTMLSelectElement(document->focused
Element()); |
| 834 if (selectElement->canSelectAll()) { | 834 if (selectElement->canSelectAll()) { |
| 835 selectElement->selectAll(); | 835 selectElement->selectAll(); |
| 836 return; | 836 return; |
| 837 } | 837 } |
| 838 } | 838 } |
| 839 | 839 |
| 840 RefPtrWillBeRawPtr<Node> root = nullptr; | 840 RawPtr<Node> root = nullptr; |
| 841 Node* selectStartTarget = nullptr; | 841 Node* selectStartTarget = nullptr; |
| 842 if (isContentEditable()) { | 842 if (isContentEditable()) { |
| 843 root = highestEditableRoot(selection().start()); | 843 root = highestEditableRoot(selection().start()); |
| 844 if (Node* shadowRoot = selection().nonBoundaryShadowTreeRootNode()) | 844 if (Node* shadowRoot = selection().nonBoundaryShadowTreeRootNode()) |
| 845 selectStartTarget = shadowRoot->shadowHost(); | 845 selectStartTarget = shadowRoot->shadowHost(); |
| 846 else | 846 else |
| 847 selectStartTarget = root.get(); | 847 selectStartTarget = root.get(); |
| 848 } else { | 848 } else { |
| 849 root = selection().nonBoundaryShadowTreeRootNode(); | 849 root = selection().nonBoundaryShadowTreeRootNode(); |
| 850 if (root) { | 850 if (root) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 872 return false; | 872 return false; |
| 873 ASSERT(range->startContainer()->document() == range->endContainer()->documen
t()); | 873 ASSERT(range->startContainer()->document() == range->endContainer()->documen
t()); |
| 874 return setSelectedRange(EphemeralRange(range), affinity, directional, option
s); | 874 return setSelectedRange(EphemeralRange(range), affinity, directional, option
s); |
| 875 } | 875 } |
| 876 | 876 |
| 877 bool FrameSelection::setSelectedRange(const EphemeralRange& range, TextAffinity
affinity, SelectionDirectionalMode directional, SetSelectionOptions options) | 877 bool FrameSelection::setSelectedRange(const EphemeralRange& range, TextAffinity
affinity, SelectionDirectionalMode directional, SetSelectionOptions options) |
| 878 { | 878 { |
| 879 return m_selectionEditor->setSelectedRange(range, affinity, directional, opt
ions); | 879 return m_selectionEditor->setSelectedRange(range, affinity, directional, opt
ions); |
| 880 } | 880 } |
| 881 | 881 |
| 882 PassRefPtrWillBeRawPtr<Range> FrameSelection::firstRange() const | 882 RawPtr<Range> FrameSelection::firstRange() const |
| 883 { | 883 { |
| 884 return m_selectionEditor->firstRange(); | 884 return m_selectionEditor->firstRange(); |
| 885 } | 885 } |
| 886 | 886 |
| 887 bool FrameSelection::isInPasswordField() const | 887 bool FrameSelection::isInPasswordField() const |
| 888 { | 888 { |
| 889 HTMLTextFormControlElement* textControl = enclosingTextFormControl(start()); | 889 HTMLTextFormControlElement* textControl = enclosingTextFormControl(start()); |
| 890 return isHTMLInputElement(textControl) && toHTMLInputElement(textControl)->t
ype() == InputTypeNames::password; | 890 return isHTMLInputElement(textControl) && toHTMLInputElement(textControl)->t
ype() == InputTypeNames::password; |
| 891 } | 891 } |
| 892 | 892 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 907 } | 907 } |
| 908 | 908 |
| 909 void FrameSelection::notifyEventHandlerForSelectionChange() | 909 void FrameSelection::notifyEventHandlerForSelectionChange() |
| 910 { | 910 { |
| 911 m_frame->eventHandler().selectionController().notifySelectionChanged(); | 911 m_frame->eventHandler().selectionController().notifySelectionChanged(); |
| 912 } | 912 } |
| 913 | 913 |
| 914 void FrameSelection::focusedOrActiveStateChanged() | 914 void FrameSelection::focusedOrActiveStateChanged() |
| 915 { | 915 { |
| 916 bool activeAndFocused = isFocusedAndActive(); | 916 bool activeAndFocused = isFocusedAndActive(); |
| 917 RefPtrWillBeRawPtr<Document> document = m_frame->document(); | 917 RawPtr<Document> document = m_frame->document(); |
| 918 | 918 |
| 919 // Trigger style invalidation from the focused element. Even though | 919 // Trigger style invalidation from the focused element. Even though |
| 920 // the focused element hasn't changed, the evaluation of focus pseudo | 920 // the focused element hasn't changed, the evaluation of focus pseudo |
| 921 // selectors are dependent on whether the frame is focused and active. | 921 // selectors are dependent on whether the frame is focused and active. |
| 922 if (Element* element = document->focusedElement()) | 922 if (Element* element = document->focusedElement()) |
| 923 element->focusStateChanged(); | 923 element->focusStateChanged(); |
| 924 | 924 |
| 925 document->updateLayoutTreeIfNeeded(); | 925 document->updateLayoutTreeIfNeeded(); |
| 926 | 926 |
| 927 // Because LayoutObject::selectionBackgroundColor() and | 927 // Because LayoutObject::selectionBackgroundColor() and |
| (...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1425 | 1425 |
| 1426 void showTree(const blink::FrameSelection* sel) | 1426 void showTree(const blink::FrameSelection* sel) |
| 1427 { | 1427 { |
| 1428 if (sel) | 1428 if (sel) |
| 1429 sel->showTreeForThis(); | 1429 sel->showTreeForThis(); |
| 1430 else | 1430 else |
| 1431 fprintf(stderr, "Cannot showTree for (nil) FrameSelection.\n"); | 1431 fprintf(stderr, "Cannot showTree for (nil) FrameSelection.\n"); |
| 1432 } | 1432 } |
| 1433 | 1433 |
| 1434 #endif | 1434 #endif |
| OLD | NEW |