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

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

Issue 2797943002: Set plugin focus via element dispatch (Closed)
Patch Set: Remove testing var. 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
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 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All
7 * rights reserved. 7 * rights reserved.
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
9 * (http://www.torchmobile.com/) 9 * (http://www.torchmobile.com/)
10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 return false; 359 return false;
360 360
361 // rule (d) above 361 // rule (d) above
362 CharDecompositionType decompType = decompositionType(c); 362 CharDecompositionType decompType = decompositionType(c);
363 if (decompType == DecompositionFont || decompType == DecompositionCompat) 363 if (decompType == DecompositionFont || decompType == DecompositionCompat)
364 return false; 364 return false;
365 365
366 return true; 366 return true;
367 } 367 }
368 368
369 static FrameViewBase* frameViewBaseForElement(const Element& focusedElement) {
370 LayoutObject* layoutObject = focusedElement.layoutObject();
371 if (!layoutObject || !layoutObject->isLayoutPart())
372 return 0;
373 return toLayoutPart(layoutObject)->frameViewBase();
374 }
375
376 static bool acceptsEditingFocus(const Element& element) { 369 static bool acceptsEditingFocus(const Element& element) {
377 DCHECK(hasEditableStyle(element)); 370 DCHECK(hasEditableStyle(element));
378 371
379 return element.document().frame() && rootEditableElement(element); 372 return element.document().frame() && rootEditableElement(element);
380 } 373 }
381 374
382 uint64_t Document::s_globalTreeVersion = 0; 375 uint64_t Document::s_globalTreeVersion = 0;
383 376
384 static bool s_threadedParsingEnabledForTesting = true; 377 static bool s_threadedParsingEnabledForTesting = true;
385 378
(...skipping 3637 matching lines...) Expand 10 before | Expand all | Expand 10 after
4023 // Remove focus from the existing focus node (if any) 4016 // Remove focus from the existing focus node (if any)
4024 if (oldFocusedElement) { 4017 if (oldFocusedElement) {
4025 oldFocusedElement->setFocused(false); 4018 oldFocusedElement->setFocused(false);
4026 4019
4027 // Dispatch the blur event and let the node do any other blur related 4020 // Dispatch the blur event and let the node do any other blur related
4028 // activities (important for text fields) 4021 // activities (important for text fields)
4029 // If page lost focus, blur event will have already been dispatched 4022 // If page lost focus, blur event will have already been dispatched
4030 if (page() && (page()->focusController().isFocused())) { 4023 if (page() && (page()->focusController().isFocused())) {
4031 oldFocusedElement->dispatchBlurEvent(newFocusedElement, params.type, 4024 oldFocusedElement->dispatchBlurEvent(newFocusedElement, params.type,
4032 params.sourceCapabilities); 4025 params.sourceCapabilities);
4033
4034 if (m_focusedElement) { 4026 if (m_focusedElement) {
4035 // handler shifted focus 4027 // handler shifted focus
4036 focusChangeBlocked = true; 4028 focusChangeBlocked = true;
4037 newFocusedElement = nullptr; 4029 newFocusedElement = nullptr;
4038 } 4030 }
4039 4031
4040 // 'focusout' is a DOM level 3 name for the bubbling blur event. 4032 // 'focusout' is a DOM level 3 name for the bubbling blur event.
4041 oldFocusedElement->dispatchFocusOutEvent(EventTypeNames::focusout, 4033 oldFocusedElement->dispatchFocusOutEvent(EventTypeNames::focusout,
4042 newFocusedElement, 4034 newFocusedElement,
4043 params.sourceCapabilities); 4035 params.sourceCapabilities);
4044 // 'DOMFocusOut' is a DOM level 2 name for compatibility. 4036 // 'DOMFocusOut' is a DOM level 2 name for compatibility.
4045 // FIXME: We should remove firing DOMFocusOutEvent event when we are sure 4037 // FIXME: We should remove firing DOMFocusOutEvent event when we are sure
4046 // no content depends on it, probably when <rdar://problem/8503958> is 4038 // no content depends on it, probably when <rdar://problem/8503958> is
4047 // resolved. 4039 // resolved.
4048 oldFocusedElement->dispatchFocusOutEvent(EventTypeNames::DOMFocusOut, 4040 oldFocusedElement->dispatchFocusOutEvent(EventTypeNames::DOMFocusOut,
4049 newFocusedElement, 4041 newFocusedElement,
4050 params.sourceCapabilities); 4042 params.sourceCapabilities);
4051 4043
4052 if (m_focusedElement) { 4044 if (m_focusedElement) {
4053 // handler shifted focus 4045 // handler shifted focus
4054 focusChangeBlocked = true; 4046 focusChangeBlocked = true;
4055 newFocusedElement = nullptr; 4047 newFocusedElement = nullptr;
4056 } 4048 }
4057 } 4049 }
4058
4059 if (view()) {
4060 FrameViewBase* oldFrameViewBase =
4061 frameViewBaseForElement(*oldFocusedElement);
4062 if (oldFrameViewBase)
4063 oldFrameViewBase->setFocused(false, params.type);
4064 else
4065 view()->setFocused(false, params.type);
4066 }
4067 } 4050 }
4068 4051
4069 if (newFocusedElement) 4052 if (newFocusedElement)
4070 updateStyleAndLayoutTreeForNode(newFocusedElement); 4053 updateStyleAndLayoutTreeForNode(newFocusedElement);
4071 if (newFocusedElement && newFocusedElement->isFocusable()) { 4054 if (newFocusedElement && newFocusedElement->isFocusable()) {
4072 if (isRootEditableElement(*newFocusedElement) && 4055 if (isRootEditableElement(*newFocusedElement) &&
4073 !acceptsEditingFocus(*newFocusedElement)) { 4056 !acceptsEditingFocus(*newFocusedElement)) {
4074 // delegate blocks focus change 4057 // delegate blocks focus change
4075 focusChangeBlocked = true; 4058 focusChangeBlocked = true;
4076 goto SetFocusedElementDone; 4059 goto SetFocusedElementDone;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
4121 4104
4122 if (m_focusedElement != newFocusedElement) { 4105 if (m_focusedElement != newFocusedElement) {
4123 // handler shifted focus 4106 // handler shifted focus
4124 focusChangeBlocked = true; 4107 focusChangeBlocked = true;
4125 goto SetFocusedElementDone; 4108 goto SetFocusedElementDone;
4126 } 4109 }
4127 } 4110 }
4128 4111
4129 if (isRootEditableElement(*m_focusedElement)) 4112 if (isRootEditableElement(*m_focusedElement))
4130 frame()->spellChecker().didBeginEditing(m_focusedElement.get()); 4113 frame()->spellChecker().didBeginEditing(m_focusedElement.get());
4131
4132 // eww, I suck. set the qt focus correctly
4133 // ### find a better place in the code for this
4134 if (view()) {
4135 FrameViewBase* focusFrameViewBase =
4136 frameViewBaseForElement(*m_focusedElement);
4137 if (focusFrameViewBase) {
4138 // Make sure a FrameViewBase has the right size before giving it focus.
4139 // Otherwise, we are testing edge cases of the FrameViewBase code.
4140 // Specifically, in WebCore this does not work well for text fields.
4141 updateStyleAndLayout();
haraken 2017/04/05 11:59:00 Is it okay to remove updateStyleAndLayout()?
joelhockey 2017/04/05 23:59:11 I don't really know, but I can say that all the te
4142 // Re-get the FrameViewBase in case updating the layout changed things.
4143 focusFrameViewBase = frameViewBaseForElement(*m_focusedElement);
4144 }
4145 if (focusFrameViewBase)
4146 focusFrameViewBase->setFocused(true, params.type);
4147 else
4148 view()->setFocused(true, params.type);
dcheng 2017/04/05 07:48:08 I think we can delete setFocused() off FrameViewBa
joelhockey 2017/04/05 23:59:11 Yes, done
4149 }
4150 } 4114 }
4151 4115
4152 if (!focusChangeBlocked && m_focusedElement) { 4116 if (!focusChangeBlocked && m_focusedElement) {
4153 // Create the AXObject cache in a focus change because Chromium relies on 4117 // Create the AXObject cache in a focus change because Chromium relies on
4154 // it. 4118 // it.
4155 if (AXObjectCache* cache = axObjectCache()) 4119 if (AXObjectCache* cache = axObjectCache())
4156 cache->handleFocusedUIElementChanged(oldFocusedElement, 4120 cache->handleFocusedUIElementChanged(oldFocusedElement,
4157 newFocusedElement); 4121 newFocusedElement);
4158 } 4122 }
4159 4123
(...skipping 2468 matching lines...) Expand 10 before | Expand all | Expand 10 after
6628 } 6592 }
6629 6593
6630 void showLiveDocumentInstances() { 6594 void showLiveDocumentInstances() {
6631 WeakDocumentSet& set = liveDocumentSet(); 6595 WeakDocumentSet& set = liveDocumentSet();
6632 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 6596 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
6633 for (blink::Document* document : set) 6597 for (blink::Document* document : set)
6634 fprintf(stderr, "- Document %p URL: %s\n", document, 6598 fprintf(stderr, "- Document %p URL: %s\n", document,
6635 document->url().getString().utf8().data()); 6599 document->url().getString().utf8().data());
6636 } 6600 }
6637 #endif 6601 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698