| 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 r
ights reserved. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r
ights reserved. |
| 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) |
| 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. | 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. |
| 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) |
| 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. | 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 #include "core/loader/ImageLoader.h" | 126 #include "core/loader/ImageLoader.h" |
| 127 #include "core/page/Chrome.h" | 127 #include "core/page/Chrome.h" |
| 128 #include "core/page/ChromeClient.h" | 128 #include "core/page/ChromeClient.h" |
| 129 #include "core/page/EventHandler.h" | 129 #include "core/page/EventHandler.h" |
| 130 #include "core/page/EventWithHitTestResults.h" | 130 #include "core/page/EventWithHitTestResults.h" |
| 131 #include "core/page/FocusController.h" | 131 #include "core/page/FocusController.h" |
| 132 #include "core/page/Page.h" | 132 #include "core/page/Page.h" |
| 133 #include "core/page/scrolling/ScrollingCoordinator.h" | 133 #include "core/page/scrolling/ScrollingCoordinator.h" |
| 134 #include "core/rendering/HitTestResult.h" | 134 #include "core/rendering/HitTestResult.h" |
| 135 #include "core/rendering/RenderView.h" | 135 #include "core/rendering/RenderView.h" |
| 136 #include "core/rendering/RenderWidget.h" | |
| 137 #include "core/rendering/compositing/RenderLayerCompositor.h" | 136 #include "core/rendering/compositing/RenderLayerCompositor.h" |
| 138 #include "platform/DateComponents.h" | 137 #include "platform/DateComponents.h" |
| 139 #include "platform/EventDispatchForbiddenScope.h" | 138 #include "platform/EventDispatchForbiddenScope.h" |
| 140 #include "platform/Language.h" | 139 #include "platform/Language.h" |
| 141 #include "platform/Logging.h" | 140 #include "platform/Logging.h" |
| 142 #include "platform/RuntimeEnabledFeatures.h" | 141 #include "platform/RuntimeEnabledFeatures.h" |
| 143 #include "platform/ScriptForbiddenScope.h" | 142 #include "platform/ScriptForbiddenScope.h" |
| 144 #include "platform/TraceEvent.h" | 143 #include "platform/TraceEvent.h" |
| 145 #include "platform/network/HTTPParsers.h" | 144 #include "platform/network/HTTPParsers.h" |
| 146 #include "platform/scroll/Scrollbar.h" | 145 #include "platform/scroll/Scrollbar.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 return false; | 226 return false; |
| 228 | 227 |
| 229 // rule (d) above | 228 // rule (d) above |
| 230 DecompositionType decompType = decompositionType(c); | 229 DecompositionType decompType = decompositionType(c); |
| 231 if (decompType == DecompositionFont || decompType == DecompositionCompat) | 230 if (decompType == DecompositionFont || decompType == DecompositionCompat) |
| 232 return false; | 231 return false; |
| 233 | 232 |
| 234 return true; | 233 return true; |
| 235 } | 234 } |
| 236 | 235 |
| 237 static Widget* widgetForElement(const Element& focusedElement) | |
| 238 { | |
| 239 RenderObject* renderer = focusedElement.renderer(); | |
| 240 if (!renderer || !renderer->isWidget()) | |
| 241 return 0; | |
| 242 return toRenderWidget(renderer)->widget(); | |
| 243 } | |
| 244 | |
| 245 static bool acceptsEditingFocus(const Element& element) | 236 static bool acceptsEditingFocus(const Element& element) |
| 246 { | 237 { |
| 247 ASSERT(element.hasEditableStyle()); | 238 ASSERT(element.hasEditableStyle()); |
| 248 | 239 |
| 249 return element.document().frame() && element.rootEditableElement(); | 240 return element.document().frame() && element.rootEditableElement(); |
| 250 } | 241 } |
| 251 | 242 |
| 252 #ifndef NDEBUG | 243 #ifndef NDEBUG |
| 253 typedef HashSet<RawPtr<Document> > WeakDocumentSet; | 244 typedef HashSet<RawPtr<Document> > WeakDocumentSet; |
| 254 static WeakDocumentSet& liveDocumentSet() | 245 static WeakDocumentSet& liveDocumentSet() |
| (...skipping 1823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2078 // on it, probably when <rdar://problem/8503958> is resolved. | 2069 // on it, probably when <rdar://problem/8503958> is resolved. |
| 2079 oldFocusedElement->dispatchFocusOutEvent(EventTypeNames::DOMFocusOut
, newFocusedElement.get()); // DOM level 2 name for compatibility. | 2070 oldFocusedElement->dispatchFocusOutEvent(EventTypeNames::DOMFocusOut
, newFocusedElement.get()); // DOM level 2 name for compatibility. |
| 2080 | 2071 |
| 2081 if (m_focusedElement) { | 2072 if (m_focusedElement) { |
| 2082 // handler shifted focus | 2073 // handler shifted focus |
| 2083 focusChangeBlocked = true; | 2074 focusChangeBlocked = true; |
| 2084 newFocusedElement = nullptr; | 2075 newFocusedElement = nullptr; |
| 2085 } | 2076 } |
| 2086 } | 2077 } |
| 2087 | 2078 |
| 2088 if (view()) { | 2079 if (view()) |
| 2089 Widget* oldWidget = widgetForElement(*oldFocusedElement); | 2080 view()->setFocus(false); |
| 2090 if (oldWidget) | |
| 2091 oldWidget->setFocus(false); | |
| 2092 else | |
| 2093 view()->setFocus(false); | |
| 2094 } | |
| 2095 } | 2081 } |
| 2096 | 2082 |
| 2097 if (newFocusedElement && newFocusedElement->isFocusable()) { | 2083 if (newFocusedElement && newFocusedElement->isFocusable()) { |
| 2098 if (newFocusedElement->isRootEditableElement() && !acceptsEditingFocus(*
newFocusedElement)) { | 2084 if (newFocusedElement->isRootEditableElement() && !acceptsEditingFocus(*
newFocusedElement)) { |
| 2099 // delegate blocks focus change | 2085 // delegate blocks focus change |
| 2100 focusChangeBlocked = true; | 2086 focusChangeBlocked = true; |
| 2101 goto SetFocusedElementDone; | 2087 goto SetFocusedElementDone; |
| 2102 } | 2088 } |
| 2103 // Set focus on the new node | 2089 // Set focus on the new node |
| 2104 m_focusedElement = newFocusedElement; | 2090 m_focusedElement = newFocusedElement; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 2132 focusChangeBlocked = true; | 2118 focusChangeBlocked = true; |
| 2133 goto SetFocusedElementDone; | 2119 goto SetFocusedElementDone; |
| 2134 } | 2120 } |
| 2135 } | 2121 } |
| 2136 | 2122 |
| 2137 m_focusedElement->setFocus(true); | 2123 m_focusedElement->setFocus(true); |
| 2138 | 2124 |
| 2139 if (m_focusedElement->isRootEditableElement()) | 2125 if (m_focusedElement->isRootEditableElement()) |
| 2140 frame()->spellChecker().didBeginEditing(m_focusedElement.get()); | 2126 frame()->spellChecker().didBeginEditing(m_focusedElement.get()); |
| 2141 | 2127 |
| 2142 // eww, I suck. set the qt focus correctly | 2128 if (view()) |
| 2143 // ### find a better place in the code for this | 2129 view()->setFocus(true); |
| 2144 if (view()) { | |
| 2145 Widget* focusWidget = widgetForElement(*m_focusedElement); | |
| 2146 if (focusWidget) { | |
| 2147 // Make sure a widget has the right size before giving it focus. | |
| 2148 // Otherwise, we are testing edge cases of the Widget code. | |
| 2149 // Specifically, in WebCore this does not work well for text fie
lds. | |
| 2150 updateLayout(); | |
| 2151 // Re-get the widget in case updating the layout changed things. | |
| 2152 focusWidget = widgetForElement(*m_focusedElement); | |
| 2153 } | |
| 2154 if (focusWidget) | |
| 2155 focusWidget->setFocus(true); | |
| 2156 else | |
| 2157 view()->setFocus(true); | |
| 2158 } | |
| 2159 } | 2130 } |
| 2160 | 2131 |
| 2161 if (!focusChangeBlocked && frameHost()) | 2132 if (!focusChangeBlocked && frameHost()) |
| 2162 frameHost()->chrome().focusedNodeChanged(m_focusedElement.get()); | 2133 frameHost()->chrome().focusedNodeChanged(m_focusedElement.get()); |
| 2163 | 2134 |
| 2164 SetFocusedElementDone: | 2135 SetFocusedElementDone: |
| 2165 updateRenderTreeIfNeeded(); | 2136 updateRenderTreeIfNeeded(); |
| 2166 if (LocalFrame* frame = this->frame()) | 2137 if (LocalFrame* frame = this->frame()) |
| 2167 frame->selection().didChangeFocus(); | 2138 frame->selection().didChangeFocus(); |
| 2168 return !focusChangeBlocked; | 2139 return !focusChangeBlocked; |
| (...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3174 using namespace blink; | 3145 using namespace blink; |
| 3175 void showLiveDocumentInstances() | 3146 void showLiveDocumentInstances() |
| 3176 { | 3147 { |
| 3177 WeakDocumentSet& set = liveDocumentSet(); | 3148 WeakDocumentSet& set = liveDocumentSet(); |
| 3178 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 3149 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
| 3179 for (WeakDocumentSet::const_iterator it = set.begin(); it != set.end(); ++it
) { | 3150 for (WeakDocumentSet::const_iterator it = set.begin(); it != set.end(); ++it
) { |
| 3180 fprintf(stderr, "- Document %p URL: %s\n", *it, (*it)->url().string().ut
f8().data()); | 3151 fprintf(stderr, "- Document %p URL: %s\n", *it, (*it)->url().string().ut
f8().data()); |
| 3181 } | 3152 } |
| 3182 } | 3153 } |
| 3183 #endif | 3154 #endif |
| OLD | NEW |