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

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

Issue 2821303005: [selectors4] Use common ancestor strategy for :focus-within (Closed)
Patch Set: New approach using Document::SetFocusedElement() Created 3 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 | « third_party/WebKit/Source/core/dom/Document.cpp ('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 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 // https://bugs.webkit.org/show_bug.cgi?id=33962 365 // https://bugs.webkit.org/show_bug.cgi?id=33962
366 if (Page* page = document->GetPage()) { 366 if (Page* page = document->GetPage()) {
367 if (page->Suspended()) 367 if (page->Suspended())
368 return; 368 return;
369 } 369 }
370 370
371 if (!focused && document->FocusedElement()) { 371 if (!focused && document->FocusedElement()) {
372 Element* focused_element = document->FocusedElement(); 372 Element* focused_element = document->FocusedElement();
373 // Use focus_type kWebFocusTypePage, same as used in DispatchBlurEvent. 373 // Use focus_type kWebFocusTypePage, same as used in DispatchBlurEvent.
374 focused_element->SetFocused(false, kWebFocusTypePage); 374 focused_element->SetFocused(false, kWebFocusTypePage);
375 focused_element->SetHasFocusWithinUpToAncestor(false);
rune 2017/04/21 08:08:35 I'm generally not so fond of default arguments and
Manuel Rego 2017/04/24 15:24:46 Ok, I've made it mandatory.
375 DispatchBlurEvent(*document, *focused_element); 376 DispatchBlurEvent(*document, *focused_element);
376 } 377 }
377 378
378 if (LocalDOMWindow* window = document->domWindow()) 379 if (LocalDOMWindow* window = document->domWindow())
379 window->DispatchEvent( 380 window->DispatchEvent(
380 Event::Create(focused ? EventTypeNames::focus : EventTypeNames::blur)); 381 Event::Create(focused ? EventTypeNames::focus : EventTypeNames::blur));
381 if (focused && document->FocusedElement()) { 382 if (focused && document->FocusedElement()) {
382 Element* focused_element(document->FocusedElement()); 383 Element* focused_element(document->FocusedElement());
383 // Use focus_type kWebFocusTypePage, same as used in DispatchFocusEvent. 384 // Use focus_type kWebFocusTypePage, same as used in DispatchFocusEvent.
384 focused_element->SetFocused(true, kWebFocusTypePage); 385 focused_element->SetFocused(true, kWebFocusTypePage);
386 focused_element->SetHasFocusWithinUpToAncestor(true);
385 DispatchFocusEvent(*document, *focused_element); 387 DispatchFocusEvent(*document, *focused_element);
386 } 388 }
387 } 389 }
388 390
389 inline bool HasCustomFocusLogic(const Element& element) { 391 inline bool HasCustomFocusLogic(const Element& element) {
390 return element.IsHTMLElement() && 392 return element.IsHTMLElement() &&
391 ToHTMLElement(element).HasCustomFocusLogic(); 393 ToHTMLElement(element).HasCustomFocusLogic();
392 } 394 }
393 395
394 inline bool IsShadowHostWithoutCustomFocusLogic(const Element& element) { 396 inline bool IsShadowHostWithoutCustomFocusLogic(const Element& element) {
(...skipping 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after
1396 it->FocusedFrameChanged(); 1398 it->FocusedFrameChanged();
1397 } 1399 }
1398 1400
1399 DEFINE_TRACE(FocusController) { 1401 DEFINE_TRACE(FocusController) {
1400 visitor->Trace(page_); 1402 visitor->Trace(page_);
1401 visitor->Trace(focused_frame_); 1403 visitor->Trace(focused_frame_);
1402 visitor->Trace(focus_changed_observers_); 1404 visitor->Trace(focus_changed_observers_);
1403 } 1405 }
1404 1406
1405 } // namespace blink 1407 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698