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

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: Using HTMLFormControlElement instead of HTMLInputElement to check changes and dispatch change event 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
« 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 28 matching lines...) Expand all
39 #include "core/dom/shadow/ShadowRoot.h" 39 #include "core/dom/shadow/ShadowRoot.h"
40 #include "core/editing/Editor.h" 40 #include "core/editing/Editor.h"
41 #include "core/editing/FrameSelection.h" 41 #include "core/editing/FrameSelection.h"
42 #include "core/editing/htmlediting.h" // For firstPositionInOrBeforeNode 42 #include "core/editing/htmlediting.h" // For firstPositionInOrBeforeNode
43 #include "core/events/Event.h" 43 #include "core/events/Event.h"
44 #include "core/frame/DOMWindow.h" 44 #include "core/frame/DOMWindow.h"
45 #include "core/frame/FrameView.h" 45 #include "core/frame/FrameView.h"
46 #include "core/frame/LocalFrame.h" 46 #include "core/frame/LocalFrame.h"
47 #include "core/html/HTMLAreaElement.h" 47 #include "core/html/HTMLAreaElement.h"
48 #include "core/html/HTMLImageElement.h" 48 #include "core/html/HTMLImageElement.h"
49 #include "core/html/HTMLInputElement.h"
tkent 2014/03/27 00:46:04 I don't think adding dependency to a specific elem
49 #include "core/html/HTMLPlugInElement.h" 50 #include "core/html/HTMLPlugInElement.h"
50 #include "core/html/HTMLShadowElement.h" 51 #include "core/html/HTMLShadowElement.h"
51 #include "core/page/Chrome.h" 52 #include "core/page/Chrome.h"
52 #include "core/page/ChromeClient.h" 53 #include "core/page/ChromeClient.h"
53 #include "core/page/EventHandler.h" 54 #include "core/page/EventHandler.h"
54 #include "core/page/FrameTree.h" 55 #include "core/page/FrameTree.h"
55 #include "core/page/Page.h" 56 #include "core/page/Page.h"
56 #include "core/frame/Settings.h" 57 #include "core/frame/Settings.h"
57 #include "core/page/SpatialNavigation.h" 58 #include "core/page/SpatialNavigation.h"
58 #include "core/rendering/HitTestResult.h" 59 #include "core/rendering/HitTestResult.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 // https://bugs.webkit.org/show_bug.cgi?id=27105 138 // https://bugs.webkit.org/show_bug.cgi?id=27105
138 139
139 // Do not fire events while modal dialogs are up. See https://bugs.webkit.o rg/show_bug.cgi?id=33962 140 // 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()) { 141 if (Page* page = document->page()) {
141 if (page->defersLoading()) 142 if (page->defersLoading())
142 return; 143 return;
143 } 144 }
144 145
145 if (!focused && document->focusedElement()) { 146 if (!focused && document->focusedElement()) {
146 RefPtr<Element> focusedElement(document->focusedElement()); 147 RefPtr<Element> focusedElement(document->focusedElement());
147 focusedElement->dispatchBlurEvent(0); 148 if (focusedElement && focusedElement->isHTMLElement()) {
149 HTMLElement* element = toHTMLElement(focusedElement);
150 if (element && element->isFormControlElement()) {
151 if (toHTMLFormControlElement(element)->wasChangedSinceLastFormCo ntrolChangeEvent())
152 toHTMLFormControlElement(element)->dispatchFormControlChange Event();
153 }
154 }
155 if (focusedElement == document->focusedElement())
156 focusedElement->dispatchBlurEvent(0);
148 if (focusedElement == document->focusedElement()) { 157 if (focusedElement == document->focusedElement()) {
149 focusedElement->dispatchFocusOutEvent(EventTypeNames::focusout, 0); 158 focusedElement->dispatchFocusOutEvent(EventTypeNames::focusout, 0);
150 if (focusedElement == document->focusedElement()) 159 if (focusedElement == document->focusedElement())
151 focusedElement->dispatchFocusOutEvent(EventTypeNames::DOMFocusOu t, 0); 160 focusedElement->dispatchFocusOutEvent(EventTypeNames::DOMFocusOu t, 0);
152 } 161 }
153 } 162 }
154 163
155 if (DOMWindow* window = document->domWindow()) 164 if (DOMWindow* window = document->domWindow())
156 window->dispatchEvent(Event::create(focused ? EventTypeNames::focus : Ev entTypeNames::blur)); 165 window->dispatchEvent(Event::create(focused ? EventTypeNames::focus : Ev entTypeNames::blur));
157 if (focused && document->focusedElement()) { 166 if (focused && document->focusedElement()) {
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after
904 startingRect = nodeRectInAbsoluteCoordinates(container, true /* ignore b order */); 913 startingRect = nodeRectInAbsoluteCoordinates(container, true /* ignore b order */);
905 container = scrollableEnclosingBoxOrParentFrameForNodeInDirection(type, container); 914 container = scrollableEnclosingBoxOrParentFrameForNodeInDirection(type, container);
906 if (container && container->isDocumentNode()) 915 if (container && container->isDocumentNode())
907 toDocument(container)->updateLayoutIgnorePendingStylesheets(); 916 toDocument(container)->updateLayoutIgnorePendingStylesheets();
908 } while (!consumed && container); 917 } while (!consumed && container);
909 918
910 return consumed; 919 return consumed;
911 } 920 }
912 921
913 } // namespace WebCore 922 } // 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