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

Side by Side Diff: third_party/WebKit/Source/core/dom/Element.cpp

Issue 1420693006: Introduce a struct to store arguments of Element::focus(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Peter Kelly (pmk@post.com) 4 * (C) 2001 Peter Kelly (pmk@post.com)
5 * (C) 2001 Dirk Mueller (mueller@kde.org) 5 * (C) 2001 Dirk Mueller (mueller@kde.org)
6 * (C) 2007 David Smith (catfish.man@gmail.com) 6 * (C) 2007 David Smith (catfish.man@gmail.com)
7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved. 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved.
8 * (C) 2007 Eric Seidel (eric@webkit.org) 8 * (C) 2007 Eric Seidel (eric@webkit.org)
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 2330 matching lines...) Expand 10 before | Expand all | Expand 10 after
2341 2341
2342 bool Element::hasAttributeNS(const AtomicString& namespaceURI, const AtomicStrin g& localName) const 2342 bool Element::hasAttributeNS(const AtomicString& namespaceURI, const AtomicStrin g& localName) const
2343 { 2343 {
2344 if (!elementData()) 2344 if (!elementData())
2345 return false; 2345 return false;
2346 QualifiedName qName(nullAtom, localName, namespaceURI); 2346 QualifiedName qName(nullAtom, localName, namespaceURI);
2347 synchronizeAttribute(qName); 2347 synchronizeAttribute(qName);
2348 return elementData()->attributes().find(qName); 2348 return elementData()->attributes().find(qName);
2349 } 2349 }
2350 2350
2351 void Element::focus(bool restorePreviousSelection, WebFocusType type, InputDevic eCapabilities* sourceCapabilities) 2351 void Element::focus(const FocusParams& params)
2352 { 2352 {
2353 if (!inDocument()) 2353 if (!inDocument())
2354 return; 2354 return;
2355 2355
2356 if (document().focusedElement() == this) 2356 if (document().focusedElement() == this)
2357 return; 2357 return;
2358 2358
2359 if (!document().isActive()) 2359 if (!document().isActive())
2360 return; 2360 return;
2361 2361
2362 document().updateLayoutIgnorePendingStylesheets(); 2362 document().updateLayoutIgnorePendingStylesheets();
2363 if (!isFocusable()) 2363 if (!isFocusable())
2364 return; 2364 return;
2365 2365
2366 if (authorShadowRoot() && authorShadowRoot()->delegatesFocus()) { 2366 if (authorShadowRoot() && authorShadowRoot()->delegatesFocus()) {
2367 if (containsIncludingShadowDOM(document().focusedElement())) 2367 if (containsIncludingShadowDOM(document().focusedElement()))
2368 return; 2368 return;
2369 2369
2370 // Slide the focus to its inner node. 2370 // Slide the focus to its inner node.
2371 Element* next = document().page()->focusController().findFocusableElemen t(WebFocusTypeForward, *this); 2371 Element* next = document().page()->focusController().findFocusableElemen t(WebFocusTypeForward, *this);
2372 if (next && containsIncludingShadowDOM(next)) { 2372 if (next && containsIncludingShadowDOM(next)) {
2373 next->focus(false, WebFocusTypeForward); 2373 next->focus(FocusParams(SelectionBehaviorOnFocus::Reset, WebFocusTyp eForward, nullptr));
2374 return; 2374 return;
2375 } 2375 }
2376 } 2376 }
2377 2377
2378 RefPtrWillBeRawPtr<Node> protect(this); 2378 RefPtrWillBeRawPtr<Node> protect(this);
2379 if (!document().page()->focusController().setFocusedElement(this, document() .frame(), type, sourceCapabilities)) 2379 if (!document().page()->focusController().setFocusedElement(this, document() .frame(), params.type, params.sourceCapabilities))
2380 return; 2380 return;
2381 2381
2382 // Setting the focused node above might have invalidated the layout due to s cripts. 2382 // Setting the focused node above might have invalidated the layout due to s cripts.
2383 document().updateLayoutIgnorePendingStylesheets(); 2383 document().updateLayoutIgnorePendingStylesheets();
2384 if (!isFocusable()) 2384 if (!isFocusable())
2385 return; 2385 return;
2386 2386
2387 cancelFocusAppearanceUpdate(); 2387 cancelFocusAppearanceUpdate();
2388 updateFocusAppearance(restorePreviousSelection); 2388 updateFocusAppearance(params.selectionBehavior);
2389 2389
2390 if (UserGestureIndicator::processedUserGestureSinceLoad()) { 2390 if (UserGestureIndicator::processedUserGestureSinceLoad()) {
2391 // Bring up the keyboard in the context of anything triggered by a user 2391 // Bring up the keyboard in the context of anything triggered by a user
2392 // gesture. Since tracking that across arbitrary boundaries (eg. 2392 // gesture. Since tracking that across arbitrary boundaries (eg.
2393 // animations) is difficult, for now we match IE's heuristic and bring 2393 // animations) is difficult, for now we match IE's heuristic and bring
2394 // up the keyboard if there's been any gesture since load. 2394 // up the keyboard if there's been any gesture since load.
2395 document().page()->chromeClient().showImeIfNeeded(); 2395 document().page()->chromeClient().showImeIfNeeded();
2396 } 2396 }
2397 } 2397 }
2398 2398
2399 void Element::updateFocusAppearance(bool /*restorePreviousSelection*/) 2399 void Element::updateFocusAppearance(SelectionBehaviorOnFocus)
2400 { 2400 {
2401 if (isRootEditableElement()) { 2401 if (isRootEditableElement()) {
2402 // Taking the ownership since setSelection() may release the last refere nce to |frame|. 2402 // Taking the ownership since setSelection() may release the last refere nce to |frame|.
2403 RefPtrWillBeRawPtr<LocalFrame> frame(document().frame()); 2403 RefPtrWillBeRawPtr<LocalFrame> frame(document().frame());
2404 if (!frame) 2404 if (!frame)
2405 return; 2405 return;
2406 2406
2407 // When focusing an editable element in an iframe, don't reset the selec tion if it already contains a selection. 2407 // When focusing an editable element in an iframe, don't reset the selec tion if it already contains a selection.
2408 if (this == frame->selection().rootEditableElement()) 2408 if (this == frame->selection().rootEditableElement())
2409 return; 2409 return;
(...skipping 1163 matching lines...) Expand 10 before | Expand all | Expand 10 after
3573 { 3573 {
3574 #if ENABLE(OILPAN) 3574 #if ENABLE(OILPAN)
3575 if (hasRareData()) 3575 if (hasRareData())
3576 visitor->trace(elementRareData()); 3576 visitor->trace(elementRareData());
3577 visitor->trace(m_elementData); 3577 visitor->trace(m_elementData);
3578 #endif 3578 #endif
3579 ContainerNode::trace(visitor); 3579 ContainerNode::trace(visitor);
3580 } 3580 }
3581 3581
3582 } // namespace blink 3582 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Element.h ('k') | third_party/WebKit/Source/core/html/HTMLAreaElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698