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

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

Issue 205033004: Dispatch change and blur event for input type=text when window focus is changed (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Removed toHTML conversion and added setFocus(true) for focus Created 6 years, 8 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
« no previous file with comments | « LayoutTests/fast/forms/text/text-window-lost-focus-change-event-expected.txt ('k') | no next file » | 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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 // https://bugs.webkit.org/show_bug.cgi?id=27105 137 // https://bugs.webkit.org/show_bug.cgi?id=27105
138 138
139 // Do not fire events while modal dialogs are up. See https://bugs.webkit.o rg/show_bug.cgi?id=33962 139 // Do not fire events while modal dialogs are up. See https://bugs.webkit.o rg/show_bug.cgi?id=33962
140 if (Page* page = document->page()) { 140 if (Page* page = document->page()) {
141 if (page->defersLoading()) 141 if (page->defersLoading())
142 return; 142 return;
143 } 143 }
144 144
145 if (!focused && document->focusedElement()) { 145 if (!focused && document->focusedElement()) {
146 RefPtr<Element> focusedElement(document->focusedElement()); 146 RefPtr<Element> focusedElement(document->focusedElement());
147 focusedElement->setFocus(false);
147 focusedElement->dispatchBlurEvent(0); 148 focusedElement->dispatchBlurEvent(0);
148 if (focusedElement == document->focusedElement()) { 149 if (focusedElement == document->focusedElement()) {
149 focusedElement->dispatchFocusOutEvent(EventTypeNames::focusout, 0); 150 focusedElement->dispatchFocusOutEvent(EventTypeNames::focusout, 0);
150 if (focusedElement == document->focusedElement()) 151 if (focusedElement == document->focusedElement())
151 focusedElement->dispatchFocusOutEvent(EventTypeNames::DOMFocusOu t, 0); 152 focusedElement->dispatchFocusOutEvent(EventTypeNames::DOMFocusOu t, 0);
152 } 153 }
153 } 154 }
154 155
155 if (DOMWindow* window = document->domWindow()) 156 if (DOMWindow* window = document->domWindow())
156 window->dispatchEvent(Event::create(focused ? EventTypeNames::focus : Ev entTypeNames::blur)); 157 window->dispatchEvent(Event::create(focused ? EventTypeNames::focus : Ev entTypeNames::blur));
157 if (focused && document->focusedElement()) { 158 if (focused && document->focusedElement()) {
158 RefPtr<Element> focusedElement(document->focusedElement()); 159 RefPtr<Element> focusedElement(document->focusedElement());
160 focusedElement->setFocus(true);
159 focusedElement->dispatchFocusEvent(0, FocusTypePage); 161 focusedElement->dispatchFocusEvent(0, FocusTypePage);
160 if (focusedElement == document->focusedElement()) { 162 if (focusedElement == document->focusedElement()) {
161 document->focusedElement()->dispatchFocusInEvent(EventTypeNames::foc usin, 0); 163 document->focusedElement()->dispatchFocusInEvent(EventTypeNames::foc usin, 0);
162 if (focusedElement == document->focusedElement()) 164 if (focusedElement == document->focusedElement())
163 document->focusedElement()->dispatchFocusInEvent(EventTypeNames: :DOMFocusIn, 0); 165 document->focusedElement()->dispatchFocusInEvent(EventTypeNames: :DOMFocusIn, 0);
164 } 166 }
165 } 167 }
166 } 168 }
167 169
168 static inline bool hasCustomFocusLogic(Element* element) 170 static inline bool hasCustomFocusLogic(Element* element)
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after
904 startingRect = nodeRectInAbsoluteCoordinates(container, true /* ignore b order */); 906 startingRect = nodeRectInAbsoluteCoordinates(container, true /* ignore b order */);
905 container = scrollableEnclosingBoxOrParentFrameForNodeInDirection(type, container); 907 container = scrollableEnclosingBoxOrParentFrameForNodeInDirection(type, container);
906 if (container && container->isDocumentNode()) 908 if (container && container->isDocumentNode())
907 toDocument(container)->updateLayoutIgnorePendingStylesheets(); 909 toDocument(container)->updateLayoutIgnorePendingStylesheets();
908 } while (!consumed && container); 910 } while (!consumed && container);
909 911
910 return consumed; 912 return consumed;
911 } 913 }
912 914
913 } // namespace WebCore 915 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/fast/forms/text/text-window-lost-focus-change-event-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698