Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: Source/core/page/FocusController.cpp

Issue 190953009: Use new is*Element() helper functions in page/ code (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/page/EventHandler.cpp ('k') | Source/core/page/PageSerializer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 return; 609 return;
610 610
611 if (Node* mousePressNode = newFocusedFrame->eventHandler().mousePressNode()) { 611 if (Node* mousePressNode = newFocusedFrame->eventHandler().mousePressNode()) {
612 if (mousePressNode->renderer() && !mousePressNode->canStartSelection()) { 612 if (mousePressNode->renderer() && !mousePressNode->canStartSelection()) {
613 // Don't clear the selection for contentEditable elements, but do cl ear it for input and textarea. See bug 38696. 613 // Don't clear the selection for contentEditable elements, but do cl ear it for input and textarea. See bug 38696.
614 Node* root = selection.rootEditableElement(); 614 Node* root = selection.rootEditableElement();
615 if (!root) 615 if (!root)
616 return; 616 return;
617 617
618 if (Node* shadowAncestorNode = root->deprecatedShadowAncestorNode()) { 618 if (Node* shadowAncestorNode = root->deprecatedShadowAncestorNode()) {
619 if (!shadowAncestorNode->hasTagName(inputTag) && !shadowAncestor Node->hasTagName(textareaTag)) 619 if (!isHTMLInputElement(*shadowAncestorNode) && !isHTMLTextAreaE lement(*shadowAncestorNode))
620 return; 620 return;
621 } 621 }
622 } 622 }
623 } 623 }
624 624
625 selection.clear(); 625 selection.clear();
626 } 626 }
627 627
628 bool FocusController::setFocusedElement(Element* element, PassRefPtr<LocalFrame> newFocusedFrame, FocusType type) 628 bool FocusController::setFocusedElement(Element* element, PassRefPtr<LocalFrame> newFocusedFrame, FocusType type)
629 { 629 {
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 884
885 if (container->isDocumentNode()) 885 if (container->isDocumentNode())
886 toDocument(container)->updateLayoutIgnorePendingStylesheets(); 886 toDocument(container)->updateLayoutIgnorePendingStylesheets();
887 887
888 // Figure out the starting rect. 888 // Figure out the starting rect.
889 LayoutRect startingRect; 889 LayoutRect startingRect;
890 if (focusedElement) { 890 if (focusedElement) {
891 if (!hasOffscreenRect(focusedElement)) { 891 if (!hasOffscreenRect(focusedElement)) {
892 container = scrollableEnclosingBoxOrParentFrameForNodeInDirection(ty pe, focusedElement); 892 container = scrollableEnclosingBoxOrParentFrameForNodeInDirection(ty pe, focusedElement);
893 startingRect = nodeRectInAbsoluteCoordinates(focusedElement, true /* ignore border */); 893 startingRect = nodeRectInAbsoluteCoordinates(focusedElement, true /* ignore border */);
894 } else if (focusedElement->hasTagName(areaTag)) { 894 } else if (isHTMLAreaElement(*focusedElement)) {
895 HTMLAreaElement* area = toHTMLAreaElement(focusedElement); 895 HTMLAreaElement& area = toHTMLAreaElement(*focusedElement);
896 container = scrollableEnclosingBoxOrParentFrameForNodeInDirection(ty pe, area->imageElement()); 896 container = scrollableEnclosingBoxOrParentFrameForNodeInDirection(ty pe, area.imageElement());
897 startingRect = virtualRectForAreaElementAndDirection(area, type); 897 startingRect = virtualRectForAreaElementAndDirection(area, type);
898 } 898 }
899 } 899 }
900 900
901 bool consumed = false; 901 bool consumed = false;
902 do { 902 do {
903 consumed = advanceFocusDirectionallyInContainer(container, startingRect, type); 903 consumed = advanceFocusDirectionallyInContainer(container, startingRect, type);
904 startingRect = nodeRectInAbsoluteCoordinates(container, true /* ignore b order */); 904 startingRect = nodeRectInAbsoluteCoordinates(container, true /* ignore b order */);
905 container = scrollableEnclosingBoxOrParentFrameForNodeInDirection(type, container); 905 container = scrollableEnclosingBoxOrParentFrameForNodeInDirection(type, container);
906 if (container && container->isDocumentNode()) 906 if (container && container->isDocumentNode())
907 toDocument(container)->updateLayoutIgnorePendingStylesheets(); 907 toDocument(container)->updateLayoutIgnorePendingStylesheets();
908 } while (!consumed && container); 908 } while (!consumed && container);
909 909
910 return consumed; 910 return consumed;
911 } 911 }
912 912
913 } // namespace WebCore 913 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/page/EventHandler.cpp ('k') | Source/core/page/PageSerializer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698