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