OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. |
3 * Copyright (C) 2008 Nuanti Ltd. | 3 * Copyright (C) 2008 Nuanti Ltd. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 26 matching lines...) Expand all Loading... |
37 #include "core/dom/NodeRenderingTraversal.h" | 37 #include "core/dom/NodeRenderingTraversal.h" |
38 #include "core/dom/NodeTraversal.h" | 38 #include "core/dom/NodeTraversal.h" |
39 #include "core/dom/Range.h" | 39 #include "core/dom/Range.h" |
40 #include "core/dom/shadow/ElementShadow.h" | 40 #include "core/dom/shadow/ElementShadow.h" |
41 #include "core/dom/shadow/ShadowRoot.h" | 41 #include "core/dom/shadow/ShadowRoot.h" |
42 #include "core/editing/Editor.h" | 42 #include "core/editing/Editor.h" |
43 #include "core/editing/FrameSelection.h" | 43 #include "core/editing/FrameSelection.h" |
44 #include "core/editing/htmlediting.h" // For firstPositionInOrBeforeNode | 44 #include "core/editing/htmlediting.h" // For firstPositionInOrBeforeNode |
45 #include "core/html/HTMLAreaElement.h" | 45 #include "core/html/HTMLAreaElement.h" |
46 #include "core/html/HTMLImageElement.h" | 46 #include "core/html/HTMLImageElement.h" |
| 47 #include "core/html/HTMLTextAreaElement.h" |
47 #include "core/page/Chrome.h" | 48 #include "core/page/Chrome.h" |
48 #include "core/page/EditorClient.h" | 49 #include "core/page/EditorClient.h" |
49 #include "core/page/EventHandler.h" | 50 #include "core/page/EventHandler.h" |
50 #include "core/page/Frame.h" | 51 #include "core/page/Frame.h" |
51 #include "core/page/FrameTree.h" | 52 #include "core/page/FrameTree.h" |
52 #include "core/page/FrameView.h" | 53 #include "core/page/FrameView.h" |
53 #include "core/page/Page.h" | 54 #include "core/page/Page.h" |
54 #include "core/page/Settings.h" | 55 #include "core/page/Settings.h" |
55 #include "core/page/SpatialNavigation.h" | 56 #include "core/page/SpatialNavigation.h" |
56 #include "core/rendering/HitTestResult.h" | 57 #include "core/rendering/HitTestResult.h" |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 if (s->isNone()) | 552 if (s->isNone()) |
552 return; | 553 return; |
553 | 554 |
554 bool caretBrowsing = oldFocusedFrame->settings()->caretBrowsingEnabled(); | 555 bool caretBrowsing = oldFocusedFrame->settings()->caretBrowsingEnabled(); |
555 if (caretBrowsing) | 556 if (caretBrowsing) |
556 return; | 557 return; |
557 | 558 |
558 Node* selectionStartNode = s->selection().start().deprecatedNode(); | 559 Node* selectionStartNode = s->selection().start().deprecatedNode(); |
559 if (selectionStartNode == newFocusedNode || selectionStartNode->isDescendant
Of(newFocusedNode) || selectionStartNode->deprecatedShadowAncestorNode() == newF
ocusedNode) | 560 if (selectionStartNode == newFocusedNode || selectionStartNode->isDescendant
Of(newFocusedNode) || selectionStartNode->deprecatedShadowAncestorNode() == newF
ocusedNode) |
560 return; | 561 return; |
561 | 562 |
562 if (Node* mousePressNode = newFocusedFrame->eventHandler()->mousePressNode()
) { | 563 if (Node* mousePressNode = newFocusedFrame->eventHandler()->mousePressNode()
) { |
563 if (mousePressNode->renderer() && !mousePressNode->canStartSelection())
{ | 564 if (mousePressNode->renderer() && !mousePressNode->canStartSelection())
{ |
564 // Don't clear the selection for contentEditable elements, but do cl
ear it for input and textarea. See bug 38696. | 565 // Don't clear the selection for contentEditable elements, but do cl
ear it for input and textarea. See bug 38696. |
565 Node * root = s->rootEditableElement(); | 566 Node * root = s->rootEditableElement(); |
566 if (!root) | 567 if (!root) |
567 return; | 568 return; |
568 | 569 |
569 if (Node* shadowAncestorNode = root->deprecatedShadowAncestorNode())
{ | 570 if (Node* shadowAncestorNode = root->deprecatedShadowAncestorNode())
{ |
570 if (!shadowAncestorNode->hasTagName(inputTag) && !shadowAncestor
Node->hasTagName(textareaTag)) | 571 if (!shadowAncestorNode->hasTagName(inputTag) && !isHTMLTextArea
Element(shadowAncestorNode)) |
571 return; | 572 return; |
572 } | 573 } |
573 } | 574 } |
574 } | 575 } |
575 | 576 |
576 s->clear(); | 577 s->clear(); |
577 } | 578 } |
578 | 579 |
579 bool FocusController::setFocusedElement(Element* element, PassRefPtr<Frame> newF
ocusedFrame, FocusDirection direction) | 580 bool FocusController::setFocusedElement(Element* element, PassRefPtr<Frame> newF
ocusedFrame, FocusDirection direction) |
580 { | 581 { |
581 RefPtr<Frame> oldFocusedFrame = focusedFrame(); | 582 RefPtr<Frame> oldFocusedFrame = focusedFrame(); |
582 RefPtr<Document> oldDocument = oldFocusedFrame ? oldFocusedFrame->document()
: 0; | 583 RefPtr<Document> oldDocument = oldFocusedFrame ? oldFocusedFrame->document()
: 0; |
583 | 584 |
584 Node* oldFocusedNode = oldDocument ? oldDocument->focusedNode() : 0; | 585 Node* oldFocusedNode = oldDocument ? oldDocument->focusedNode() : 0; |
585 if (oldFocusedNode == element) | 586 if (oldFocusedNode == element) |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
863 startingRect = nodeRectInAbsoluteCoordinates(container, true /* ignore b
order */); | 864 startingRect = nodeRectInAbsoluteCoordinates(container, true /* ignore b
order */); |
864 container = scrollableEnclosingBoxOrParentFrameForNodeInDirection(direct
ion, container); | 865 container = scrollableEnclosingBoxOrParentFrameForNodeInDirection(direct
ion, container); |
865 if (container && container->isDocumentNode()) | 866 if (container && container->isDocumentNode()) |
866 toDocument(container)->updateLayoutIgnorePendingStylesheets(); | 867 toDocument(container)->updateLayoutIgnorePendingStylesheets(); |
867 } while (!consumed && container); | 868 } while (!consumed && container); |
868 | 869 |
869 return consumed; | 870 return consumed; |
870 } | 871 } |
871 | 872 |
872 } // namespace WebCore | 873 } // namespace WebCore |
OLD | NEW |