Lines 2127-2143
void Document::setDashboardRegions(const
Link Here
|
2127 |
} |
2127 |
} |
2128 |
|
2128 |
|
2129 |
bool Document::setFocusedNode(PassRefPtr<Node> newFocusedNode) |
2129 |
bool Document::setFocusedNode(PassRefPtr<Node> newFocusedNode) |
2130 |
{ |
2130 |
{ |
2131 |
// Make sure newFocusedNode is actually in this document |
2131 |
ASSERT(!m_inPageCache); |
2132 |
if (newFocusedNode && (newFocusedNode->document() != this)) |
2132 |
|
|
|
2133 |
// If newFocusedNode is not in this document, just return true without doing anything. |
2134 |
if (newFocusedNode && newFocusedNode->document() != this) |
2133 |
return true; |
2135 |
return true; |
2134 |
|
2136 |
|
2135 |
if (m_focusedNode == newFocusedNode) |
2137 |
if (m_focusedNode == newFocusedNode) |
2136 |
return true; |
2138 |
return true; |
2137 |
|
2139 |
|
2138 |
bool focusChangeBlocked = false; |
2140 |
bool focusChangeBlocked = false; |
2139 |
RefPtr<Node> oldFocusedNode = m_focusedNode; |
2141 |
RefPtr<Node> oldFocusedNode = m_focusedNode.release(); |
2140 |
m_focusedNode = 0; |
|
|
2141 |
|
2142 |
|
2142 |
// Remove focus from the existing focus node (if any) |
2143 |
// Remove focus from the existing focus node (if any) |
2143 |
if (oldFocusedNode && !oldFocusedNode->m_inDetach) { |
2144 |
if (oldFocusedNode && !oldFocusedNode->m_inDetach) { |
Lines 2147-2156
bool Document::setFocusedNode(PassRefPtr
Link Here
|
2147 |
oldFocusedNode->setFocus(false); |
2148 |
oldFocusedNode->setFocus(false); |
2148 |
|
2149 |
|
2149 |
// Dispatch a change event for text fields or textareas that have been edited |
2150 |
// Dispatch a change event for text fields or textareas that have been edited |
2150 |
RenderObject *r = static_cast<RenderObject*>(oldFocusedNode.get()->renderer()); |
2151 |
RenderObject* r = static_cast<RenderObject*>(oldFocusedNode->renderer()); |
2151 |
if (r && (r->isTextArea() || r->isTextField()) && r->isEdited()) { |
2152 |
if (r && (r->isTextArea() || r->isTextField()) && r->isEdited()) { |
2152 |
EventTargetNodeCast(oldFocusedNode.get())->dispatchHTMLEvent(changeEvent, true, false); |
2153 |
EventTargetNodeCast(oldFocusedNode.get())->dispatchHTMLEvent(changeEvent, true, false); |
2153 |
if ((r = static_cast<RenderObject*>(oldFocusedNode.get()->renderer()))) |
2154 |
if ((r = static_cast<RenderObject*>(oldFocusedNode->renderer()))) |
2154 |
r->setEdited(false); |
2155 |
r->setEdited(false); |
2155 |
} |
2156 |
} |
2156 |
|
2157 |
|
Lines 2168-2177
bool Document::setFocusedNode(PassRefPtr
Link Here
|
2168 |
focusChangeBlocked = true; |
2169 |
focusChangeBlocked = true; |
2169 |
newFocusedNode = 0; |
2170 |
newFocusedNode = 0; |
2170 |
} |
2171 |
} |
2171 |
if ((oldFocusedNode.get() == this) && oldFocusedNode->hasOneRef()) |
2172 |
if (oldFocusedNode == this && oldFocusedNode->hasOneRef()) |
2172 |
return true; |
2173 |
return true; |
2173 |
|
2174 |
|
2174 |
if (oldFocusedNode.get() == oldFocusedNode->rootEditableElement()) |
2175 |
if (oldFocusedNode == oldFocusedNode->rootEditableElement()) |
2175 |
frame()->editor()->didEndEditing(); |
2176 |
frame()->editor()->didEndEditing(); |
2176 |
} |
2177 |
} |
2177 |
|
2178 |
|
Lines 2181-2186
bool Document::setFocusedNode(PassRefPtr
Link Here
|
2181 |
focusChangeBlocked = true; |
2182 |
focusChangeBlocked = true; |
2182 |
goto SetFocusedNodeDone; |
2183 |
goto SetFocusedNodeDone; |
2183 |
} |
2184 |
} |
|
|
2185 |
|
2184 |
// Set focus on the new node |
2186 |
// Set focus on the new node |
2185 |
m_focusedNode = newFocusedNode.get(); |
2187 |
m_focusedNode = newFocusedNode.get(); |
2186 |
|
2188 |
|
Lines 2192-2210
bool Document::setFocusedNode(PassRefPtr
Link Here
|
2192 |
focusChangeBlocked = true; |
2194 |
focusChangeBlocked = true; |
2193 |
goto SetFocusedNodeDone; |
2195 |
goto SetFocusedNodeDone; |
2194 |
} |
2196 |
} |
|
|
2197 |
|
2195 |
EventTargetNodeCast(m_focusedNode.get())->dispatchUIEvent(DOMFocusInEvent); |
2198 |
EventTargetNodeCast(m_focusedNode.get())->dispatchUIEvent(DOMFocusInEvent); |
|
|
2199 |
|
2196 |
if (m_focusedNode != newFocusedNode) { |
2200 |
if (m_focusedNode != newFocusedNode) { |
2197 |
// handler shifted focus |
2201 |
// handler shifted focus |
2198 |
focusChangeBlocked = true; |
2202 |
focusChangeBlocked = true; |
2199 |
goto SetFocusedNodeDone; |
2203 |
goto SetFocusedNodeDone; |
2200 |
} |
2204 |
} |
|
|
2205 |
|
2201 |
m_focusedNode->setFocus(); |
2206 |
m_focusedNode->setFocus(); |
2202 |
|
2207 |
|
2203 |
if (m_focusedNode.get() == m_focusedNode->rootEditableElement()) |
2208 |
if (m_focusedNode == m_focusedNode->rootEditableElement()) |
2204 |
frame()->editor()->didBeginEditing(); |
2209 |
frame()->editor()->didBeginEditing(); |
2205 |
|
2210 |
|
2206 |
// eww, I suck. set the qt focus correctly |
|
|
2207 |
// ### find a better place in the code for this |
2208 |
if (view()) { |
2211 |
if (view()) { |
2209 |
Widget *focusWidget = widgetForNode(m_focusedNode.get()); |
2212 |
Widget *focusWidget = widgetForNode(m_focusedNode.get()); |
2210 |
if (focusWidget) { |
2213 |
if (focusWidget) { |
Lines 2230-2236
bool Document::setFocusedNode(PassRefPtr
Link Here
|
2230 |
SetFocusedNodeDone: |
2233 |
SetFocusedNodeDone: |
2231 |
updateRendering(); |
2234 |
updateRendering(); |
2232 |
return !focusChangeBlocked; |
2235 |
return !focusChangeBlocked; |
2233 |
} |
2236 |
} |
2234 |
|
2237 |
|
2235 |
void Document::setCSSTarget(Node* n) |
2238 |
void Document::setCSSTarget(Node* n) |
2236 |
{ |
2239 |
{ |