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 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 | 615 |
616 selection.clear(); | 616 selection.clear(); |
617 } | 617 } |
618 | 618 |
619 bool FocusController::setFocusedElement(Element* element, PassRefPtr<Frame> newF
ocusedFrame, FocusDirection direction) | 619 bool FocusController::setFocusedElement(Element* element, PassRefPtr<Frame> newF
ocusedFrame, FocusDirection direction) |
620 { | 620 { |
621 RefPtr<Frame> oldFocusedFrame = focusedFrame(); | 621 RefPtr<Frame> oldFocusedFrame = focusedFrame(); |
622 RefPtr<Document> oldDocument = oldFocusedFrame ? oldFocusedFrame->document()
: 0; | 622 RefPtr<Document> oldDocument = oldFocusedFrame ? oldFocusedFrame->document()
: 0; |
623 | 623 |
624 Element* oldFocusedElement = oldDocument ? oldDocument->focusedElement() : 0
; | 624 Element* oldFocusedElement = oldDocument ? oldDocument->focusedElement() : 0
; |
625 if (oldFocusedElement == element) | 625 if (element && oldFocusedElement == element) |
626 return true; | 626 return true; |
627 | 627 |
628 // FIXME: Might want to disable this check for caretBrowsing | 628 // FIXME: Might want to disable this check for caretBrowsing |
629 if (oldFocusedElement && oldFocusedElement->isRootEditableElement() && !reli
nquishesEditingFocus(oldFocusedElement)) | 629 if (oldFocusedElement && oldFocusedElement->isRootEditableElement() && !reli
nquishesEditingFocus(oldFocusedElement)) |
630 return false; | 630 return false; |
631 | 631 |
632 m_page->editorClient().willSetInputMethodState(); | 632 m_page->editorClient().willSetInputMethodState(); |
633 | 633 |
634 clearSelectionIfNeeded(oldFocusedFrame.get(), newFocusedFrame.get(), element
); | 634 RefPtr<Document> newDocument; |
635 | 635 if (element) |
636 if (!element) { | 636 newDocument = &element->document(); |
637 if (oldDocument) | 637 else if (newFocusedFrame) |
638 oldDocument->setFocusedElement(0); | 638 newDocument = newFocusedFrame->document(); |
639 return true; | |
640 } | |
641 | |
642 RefPtr<Document> newDocument(element->document()); | |
643 | 639 |
644 if (newDocument && newDocument->focusedElement() == element) | 640 if (newDocument && newDocument->focusedElement() == element) |
645 return true; | 641 return true; |
646 | 642 |
| 643 clearSelectionIfNeeded(oldFocusedFrame.get(), newFocusedFrame.get(), element
); |
| 644 |
647 if (oldDocument && oldDocument != newDocument) | 645 if (oldDocument && oldDocument != newDocument) |
648 oldDocument->setFocusedElement(0); | 646 oldDocument->setFocusedElement(0); |
649 | 647 |
650 if (newFocusedFrame && !newFocusedFrame->page()) { | 648 if (newFocusedFrame && !newFocusedFrame->page()) { |
651 setFocusedFrame(0); | 649 setFocusedFrame(0); |
652 return false; | 650 return false; |
653 } | 651 } |
654 setFocusedFrame(newFocusedFrame); | 652 setFocusedFrame(newFocusedFrame); |
655 | 653 |
656 // Setting the focused node can result in losing our last reft to node when
JS event handlers fire. | 654 // Setting the focused node can result in losing our last reft to node when
JS event handlers fire. |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
900 startingRect = nodeRectInAbsoluteCoordinates(container, true /* ignore b
order */); | 898 startingRect = nodeRectInAbsoluteCoordinates(container, true /* ignore b
order */); |
901 container = scrollableEnclosingBoxOrParentFrameForNodeInDirection(direct
ion, container); | 899 container = scrollableEnclosingBoxOrParentFrameForNodeInDirection(direct
ion, container); |
902 if (container && container->isDocumentNode()) | 900 if (container && container->isDocumentNode()) |
903 toDocument(container)->updateLayoutIgnorePendingStylesheets(); | 901 toDocument(container)->updateLayoutIgnorePendingStylesheets(); |
904 } while (!consumed && container); | 902 } while (!consumed && container); |
905 | 903 |
906 return consumed; | 904 return consumed; |
907 } | 905 } |
908 | 906 |
909 } // namespace WebCore | 907 } // namespace WebCore |
OLD | NEW |