OLD | NEW |
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 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 // rule (d) above | 368 // rule (d) above |
369 WTF::Unicode::CharDecompositionType decompType = | 369 WTF::Unicode::CharDecompositionType decompType = |
370 WTF::Unicode::decompositionType(c); | 370 WTF::Unicode::decompositionType(c); |
371 if (decompType == WTF::Unicode::DecompositionFont || | 371 if (decompType == WTF::Unicode::DecompositionFont || |
372 decompType == WTF::Unicode::DecompositionCompat) | 372 decompType == WTF::Unicode::DecompositionCompat) |
373 return false; | 373 return false; |
374 | 374 |
375 return true; | 375 return true; |
376 } | 376 } |
377 | 377 |
378 static FrameViewBase* frameViewBaseForElement(const Element& focusedElement) { | |
379 // Return either plugin or frame. | |
380 // TODO(joelhockey): FrameViewBase class will soon be removed. It will be | |
381 // replaced with Focusable ABC that FrameView and PluginView will implement | |
382 // and this method will return Focusable. | |
383 if (isHTMLPlugInElement(focusedElement)) | |
384 return toHTMLPlugInElement(focusedElement).plugin(); | |
385 | |
386 LayoutObject* layoutObject = focusedElement.layoutObject(); | |
387 if (!layoutObject || !layoutObject->isLayoutPart()) | |
388 return 0; | |
389 return toLayoutPart(layoutObject)->frameViewBase(); | |
390 } | |
391 | |
392 static bool acceptsEditingFocus(const Element& element) { | 378 static bool acceptsEditingFocus(const Element& element) { |
393 DCHECK(hasEditableStyle(element)); | 379 DCHECK(hasEditableStyle(element)); |
394 | 380 |
395 return element.document().frame() && rootEditableElement(element); | 381 return element.document().frame() && rootEditableElement(element); |
396 } | 382 } |
397 | 383 |
398 uint64_t Document::s_globalTreeVersion = 0; | 384 uint64_t Document::s_globalTreeVersion = 0; |
399 | 385 |
400 static bool s_threadedParsingEnabledForTesting = true; | 386 static bool s_threadedParsingEnabledForTesting = true; |
401 | 387 |
(...skipping 3644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4046 // Remove focus from the existing focus node (if any) | 4032 // Remove focus from the existing focus node (if any) |
4047 if (oldFocusedElement) { | 4033 if (oldFocusedElement) { |
4048 oldFocusedElement->setFocused(false); | 4034 oldFocusedElement->setFocused(false); |
4049 | 4035 |
4050 // Dispatch the blur event and let the node do any other blur related | 4036 // Dispatch the blur event and let the node do any other blur related |
4051 // activities (important for text fields) | 4037 // activities (important for text fields) |
4052 // If page lost focus, blur event will have already been dispatched | 4038 // If page lost focus, blur event will have already been dispatched |
4053 if (page() && (page()->focusController().isFocused())) { | 4039 if (page() && (page()->focusController().isFocused())) { |
4054 oldFocusedElement->dispatchBlurEvent(newFocusedElement, params.type, | 4040 oldFocusedElement->dispatchBlurEvent(newFocusedElement, params.type, |
4055 params.sourceCapabilities); | 4041 params.sourceCapabilities); |
4056 | |
4057 if (m_focusedElement) { | 4042 if (m_focusedElement) { |
4058 // handler shifted focus | 4043 // handler shifted focus |
4059 focusChangeBlocked = true; | 4044 focusChangeBlocked = true; |
4060 newFocusedElement = nullptr; | 4045 newFocusedElement = nullptr; |
4061 } | 4046 } |
4062 | 4047 |
4063 // 'focusout' is a DOM level 3 name for the bubbling blur event. | 4048 // 'focusout' is a DOM level 3 name for the bubbling blur event. |
4064 oldFocusedElement->dispatchFocusOutEvent(EventTypeNames::focusout, | 4049 oldFocusedElement->dispatchFocusOutEvent(EventTypeNames::focusout, |
4065 newFocusedElement, | 4050 newFocusedElement, |
4066 params.sourceCapabilities); | 4051 params.sourceCapabilities); |
4067 // 'DOMFocusOut' is a DOM level 2 name for compatibility. | 4052 // 'DOMFocusOut' is a DOM level 2 name for compatibility. |
4068 // FIXME: We should remove firing DOMFocusOutEvent event when we are sure | 4053 // FIXME: We should remove firing DOMFocusOutEvent event when we are sure |
4069 // no content depends on it, probably when <rdar://problem/8503958> is | 4054 // no content depends on it, probably when <rdar://problem/8503958> is |
4070 // resolved. | 4055 // resolved. |
4071 oldFocusedElement->dispatchFocusOutEvent(EventTypeNames::DOMFocusOut, | 4056 oldFocusedElement->dispatchFocusOutEvent(EventTypeNames::DOMFocusOut, |
4072 newFocusedElement, | 4057 newFocusedElement, |
4073 params.sourceCapabilities); | 4058 params.sourceCapabilities); |
4074 | 4059 |
4075 if (m_focusedElement) { | 4060 if (m_focusedElement) { |
4076 // handler shifted focus | 4061 // handler shifted focus |
4077 focusChangeBlocked = true; | 4062 focusChangeBlocked = true; |
4078 newFocusedElement = nullptr; | 4063 newFocusedElement = nullptr; |
4079 } | 4064 } |
4080 } | 4065 } |
4081 | 4066 |
4082 if (view()) { | 4067 if (isHTMLPlugInElement(oldFocusedElement)) { |
4083 FrameViewBase* oldFrameViewBase = | 4068 if (PluginView* plugin = toHTMLPlugInElement(oldFocusedElement)->plugin()) |
4084 frameViewBaseForElement(*oldFocusedElement); | 4069 plugin->setFocused(false, params.type); |
4085 if (oldFrameViewBase) | |
4086 oldFrameViewBase->setFocused(false, params.type); | |
4087 else | |
4088 view()->setFocused(false, params.type); | |
4089 } | 4070 } |
4090 } | 4071 } |
4091 | 4072 |
4092 if (newFocusedElement) | 4073 if (newFocusedElement) |
4093 updateStyleAndLayoutTreeForNode(newFocusedElement); | 4074 updateStyleAndLayoutTreeForNode(newFocusedElement); |
4094 if (newFocusedElement && newFocusedElement->isFocusable()) { | 4075 if (newFocusedElement && newFocusedElement->isFocusable()) { |
4095 if (isRootEditableElement(*newFocusedElement) && | 4076 if (isRootEditableElement(*newFocusedElement) && |
4096 !acceptsEditingFocus(*newFocusedElement)) { | 4077 !acceptsEditingFocus(*newFocusedElement)) { |
4097 // delegate blocks focus change | 4078 // delegate blocks focus change |
4098 focusChangeBlocked = true; | 4079 focusChangeBlocked = true; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4145 if (m_focusedElement != newFocusedElement) { | 4126 if (m_focusedElement != newFocusedElement) { |
4146 // handler shifted focus | 4127 // handler shifted focus |
4147 focusChangeBlocked = true; | 4128 focusChangeBlocked = true; |
4148 goto SetFocusedElementDone; | 4129 goto SetFocusedElementDone; |
4149 } | 4130 } |
4150 } | 4131 } |
4151 | 4132 |
4152 if (isRootEditableElement(*m_focusedElement)) | 4133 if (isRootEditableElement(*m_focusedElement)) |
4153 frame()->spellChecker().didBeginEditing(m_focusedElement.get()); | 4134 frame()->spellChecker().didBeginEditing(m_focusedElement.get()); |
4154 | 4135 |
4155 // eww, I suck. set the qt focus correctly | 4136 if (isHTMLPlugInElement(m_focusedElement)) { |
4156 // ### find a better place in the code for this | 4137 if (PluginView* plugin = toHTMLPlugInElement(m_focusedElement)->plugin()) |
4157 if (view()) { | 4138 plugin->setFocused(true, params.type); |
4158 FrameViewBase* focusFrameViewBase = | |
4159 frameViewBaseForElement(*m_focusedElement); | |
4160 if (focusFrameViewBase) { | |
4161 // Make sure a FrameViewBase has the right size before giving it focus. | |
4162 // Otherwise, we are testing edge cases of the FrameViewBase code. | |
4163 // Specifically, in WebCore this does not work well for text fields. | |
4164 updateStyleAndLayout(); | |
4165 // Re-get the FrameViewBase in case updating the layout changed things. | |
4166 focusFrameViewBase = frameViewBaseForElement(*m_focusedElement); | |
4167 } | |
4168 if (focusFrameViewBase) | |
4169 focusFrameViewBase->setFocused(true, params.type); | |
4170 else | |
4171 view()->setFocused(true, params.type); | |
4172 } | 4139 } |
4173 } | 4140 } |
4174 | 4141 |
4175 if (!focusChangeBlocked && m_focusedElement) { | 4142 if (!focusChangeBlocked && m_focusedElement) { |
4176 // Create the AXObject cache in a focus change because Chromium relies on | 4143 // Create the AXObject cache in a focus change because Chromium relies on |
4177 // it. | 4144 // it. |
4178 if (AXObjectCache* cache = axObjectCache()) | 4145 if (AXObjectCache* cache = axObjectCache()) |
4179 cache->handleFocusedUIElementChanged(oldFocusedElement, | 4146 cache->handleFocusedUIElementChanged(oldFocusedElement, |
4180 newFocusedElement); | 4147 newFocusedElement); |
4181 } | 4148 } |
(...skipping 2469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6651 } | 6618 } |
6652 | 6619 |
6653 void showLiveDocumentInstances() { | 6620 void showLiveDocumentInstances() { |
6654 WeakDocumentSet& set = liveDocumentSet(); | 6621 WeakDocumentSet& set = liveDocumentSet(); |
6655 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 6622 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
6656 for (blink::Document* document : set) | 6623 for (blink::Document* document : set) |
6657 fprintf(stderr, "- Document %p URL: %s\n", document, | 6624 fprintf(stderr, "- Document %p URL: %s\n", document, |
6658 document->url().getString().utf8().data()); | 6625 document->url().getString().utf8().data()); |
6659 } | 6626 } |
6660 #endif | 6627 #endif |
OLD | NEW |