| 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 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 } | 573 } |
| 574 | 574 |
| 575 void Document::dispose() | 575 void Document::dispose() |
| 576 { | 576 { |
| 577 ASSERT_WITH_SECURITY_IMPLICATION(!m_deletionHasBegun); | 577 ASSERT_WITH_SECURITY_IMPLICATION(!m_deletionHasBegun); |
| 578 // We must make sure not to be retaining any of our children through | 578 // We must make sure not to be retaining any of our children through |
| 579 // these extra pointers or we will create a reference cycle. | 579 // these extra pointers or we will create a reference cycle. |
| 580 m_docType = 0; | 580 m_docType = 0; |
| 581 m_focusedElement = 0; | 581 m_focusedElement = 0; |
| 582 m_hoverNode = 0; | 582 m_hoverNode = 0; |
| 583 m_activeElement = 0; | 583 m_activeHoverElement = 0; |
| 584 m_titleElement = 0; | 584 m_titleElement = 0; |
| 585 m_documentElement = 0; | 585 m_documentElement = 0; |
| 586 m_contextFeatures = ContextFeatures::defaultSwitch(); | 586 m_contextFeatures = ContextFeatures::defaultSwitch(); |
| 587 m_userActionElements.documentDidRemoveLastRef(); | 587 m_userActionElements.documentDidRemoveLastRef(); |
| 588 m_associatedFormControls.clear(); | 588 m_associatedFormControls.clear(); |
| 589 | 589 |
| 590 detachParser(); | 590 detachParser(); |
| 591 | 591 |
| 592 m_registrationContext.clear(); | 592 m_registrationContext.clear(); |
| 593 | 593 |
| (...skipping 1450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2044 view->detachCustomScrollbars(); | 2044 view->detachCustomScrollbars(); |
| 2045 } | 2045 } |
| 2046 | 2046 |
| 2047 // Indicate destruction mode by setting the renderer to null. | 2047 // Indicate destruction mode by setting the renderer to null. |
| 2048 // FIXME: Don't do this and use m_lifecycle.state() == Stopping instead. | 2048 // FIXME: Don't do this and use m_lifecycle.state() == Stopping instead. |
| 2049 setRenderer(0); | 2049 setRenderer(0); |
| 2050 m_renderView = 0; | 2050 m_renderView = 0; |
| 2051 | 2051 |
| 2052 m_hoverNode = 0; | 2052 m_hoverNode = 0; |
| 2053 m_focusedElement = 0; | 2053 m_focusedElement = 0; |
| 2054 m_activeElement = 0; | 2054 m_activeHoverElement = 0; |
| 2055 m_autofocusElement = 0; | 2055 m_autofocusElement = 0; |
| 2056 | 2056 |
| 2057 ContainerNode::detach(context); | 2057 ContainerNode::detach(context); |
| 2058 | 2058 |
| 2059 unscheduleStyleRecalc(); | 2059 unscheduleStyleRecalc(); |
| 2060 | 2060 |
| 2061 m_styleEngine->didDetach(); | 2061 m_styleEngine->didDetach(); |
| 2062 | 2062 |
| 2063 if (renderView) | 2063 if (renderView) |
| 2064 renderView->destroy(); | 2064 renderView->destroy(); |
| (...skipping 1198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3263 childDocument->seamlessParentUpdatedStylesheets(); | 3263 childDocument->seamlessParentUpdatedStylesheets(); |
| 3264 } | 3264 } |
| 3265 } | 3265 } |
| 3266 } | 3266 } |
| 3267 | 3267 |
| 3268 void Document::setHoverNode(PassRefPtr<Node> newHoverNode) | 3268 void Document::setHoverNode(PassRefPtr<Node> newHoverNode) |
| 3269 { | 3269 { |
| 3270 m_hoverNode = newHoverNode; | 3270 m_hoverNode = newHoverNode; |
| 3271 } | 3271 } |
| 3272 | 3272 |
| 3273 void Document::setActiveElement(PassRefPtr<Element> newActiveElement) | 3273 void Document::setActiveHoverElement(PassRefPtr<Element> newActiveElement) |
| 3274 { | 3274 { |
| 3275 if (!newActiveElement) { | 3275 if (!newActiveElement) { |
| 3276 m_activeElement.clear(); | 3276 m_activeHoverElement.clear(); |
| 3277 return; | 3277 return; |
| 3278 } | 3278 } |
| 3279 | 3279 |
| 3280 m_activeElement = newActiveElement; | 3280 m_activeHoverElement = newActiveElement; |
| 3281 } | 3281 } |
| 3282 | 3282 |
| 3283 void Document::removeFocusedElementOfSubtree(Node* node, bool amongChildrenOnly) | 3283 void Document::removeFocusedElementOfSubtree(Node* node, bool amongChildrenOnly) |
| 3284 { | 3284 { |
| 3285 if (!m_focusedElement) | 3285 if (!m_focusedElement) |
| 3286 return; | 3286 return; |
| 3287 | 3287 |
| 3288 // We can't be focused if we're not in the document. | 3288 // We can't be focused if we're not in the document. |
| 3289 if (!node->inDocument()) | 3289 if (!node->inDocument()) |
| 3290 return; | 3290 return; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 3310 // new hover effects on any other element. | 3310 // new hover effects on any other element. |
| 3311 if (!page()->isCursorVisible()) | 3311 if (!page()->isCursorVisible()) |
| 3312 return; | 3312 return; |
| 3313 | 3313 |
| 3314 if (frame()) | 3314 if (frame()) |
| 3315 frame()->eventHandler().scheduleHoverStateUpdate(); | 3315 frame()->eventHandler().scheduleHoverStateUpdate(); |
| 3316 } | 3316 } |
| 3317 | 3317 |
| 3318 void Document::activeChainNodeDetached(Node* node) | 3318 void Document::activeChainNodeDetached(Node* node) |
| 3319 { | 3319 { |
| 3320 if (!m_activeElement) | 3320 if (!m_activeHoverElement) |
| 3321 return; | 3321 return; |
| 3322 | 3322 |
| 3323 if (node != m_activeElement && (!m_activeElement->isTextNode() || node != No
deRenderingTraversal::parent(m_activeElement.get()))) | 3323 if (node != m_activeHoverElement && (!m_activeHoverElement->isTextNode() ||
node != NodeRenderingTraversal::parent(m_activeHoverElement.get()))) |
| 3324 return; | 3324 return; |
| 3325 | 3325 |
| 3326 Node* activeNode = NodeRenderingTraversal::parent(node); | 3326 Node* activeNode = NodeRenderingTraversal::parent(node); |
| 3327 while (activeNode && activeNode->isElementNode() && !activeNode->renderer()) | 3327 while (activeNode && activeNode->isElementNode() && !activeNode->renderer()) |
| 3328 activeNode = NodeRenderingTraversal::parent(activeNode); | 3328 activeNode = NodeRenderingTraversal::parent(activeNode); |
| 3329 | 3329 |
| 3330 m_activeElement = activeNode && activeNode->isElementNode() ? toElement(acti
veNode) : 0; | 3330 m_activeHoverElement = activeNode && activeNode->isElementNode() ? toElement
(activeNode) : 0; |
| 3331 } | 3331 } |
| 3332 | 3332 |
| 3333 const Vector<AnnotatedRegionValue>& Document::annotatedRegions() const | 3333 const Vector<AnnotatedRegionValue>& Document::annotatedRegions() const |
| 3334 { | 3334 { |
| 3335 return m_annotatedRegions; | 3335 return m_annotatedRegions; |
| 3336 } | 3336 } |
| 3337 | 3337 |
| 3338 void Document::setAnnotatedRegions(const Vector<AnnotatedRegionValue>& regions) | 3338 void Document::setAnnotatedRegions(const Vector<AnnotatedRegionValue>& regions) |
| 3339 { | 3339 { |
| 3340 m_annotatedRegions = regions; | 3340 m_annotatedRegions = regions; |
| (...skipping 1725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5066 | 5066 |
| 5067 if (request.active() && m_frame) | 5067 if (request.active() && m_frame) |
| 5068 m_frame->eventHandler().notifyElementActivated(); | 5068 m_frame->eventHandler().notifyElementActivated(); |
| 5069 | 5069 |
| 5070 Element* innerElementInDocument = innerElement; | 5070 Element* innerElementInDocument = innerElement; |
| 5071 while (innerElementInDocument && innerElementInDocument->document() != this)
{ | 5071 while (innerElementInDocument && innerElementInDocument->document() != this)
{ |
| 5072 innerElementInDocument->document().updateHoverActiveState(request, inner
ElementInDocument, event); | 5072 innerElementInDocument->document().updateHoverActiveState(request, inner
ElementInDocument, event); |
| 5073 innerElementInDocument = innerElementInDocument->document().ownerElement
(); | 5073 innerElementInDocument = innerElementInDocument->document().ownerElement
(); |
| 5074 } | 5074 } |
| 5075 | 5075 |
| 5076 Element* oldActiveElement = activeElement(); | 5076 Element* oldActiveElement = activeHoverElement(); |
| 5077 if (oldActiveElement && !request.active()) { | 5077 if (oldActiveElement && !request.active()) { |
| 5078 // We are clearing the :active chain because the mouse has been released
. | 5078 // We are clearing the :active chain because the mouse has been released
. |
| 5079 for (RenderObject* curr = oldActiveElement->renderer(); curr; curr = cur
r->parent()) { | 5079 for (RenderObject* curr = oldActiveElement->renderer(); curr; curr = cur
r->parent()) { |
| 5080 if (curr->node()) { | 5080 if (curr->node()) { |
| 5081 ASSERT(!curr->node()->isTextNode()); | 5081 ASSERT(!curr->node()->isTextNode()); |
| 5082 curr->node()->setActive(false); | 5082 curr->node()->setActive(false); |
| 5083 m_userActionElements.setInActiveChain(curr->node(), false); | 5083 m_userActionElements.setInActiveChain(curr->node(), false); |
| 5084 } | 5084 } |
| 5085 } | 5085 } |
| 5086 setActiveElement(0); | 5086 setActiveHoverElement(0); |
| 5087 } else { | 5087 } else { |
| 5088 Element* newActiveElement = innerElementInDocument; | 5088 Element* newActiveElement = innerElementInDocument; |
| 5089 if (!oldActiveElement && newActiveElement && request.active() && !reques
t.touchMove()) { | 5089 if (!oldActiveElement && newActiveElement && request.active() && !reques
t.touchMove()) { |
| 5090 // We are setting the :active chain and freezing it. If future moves
happen, they | 5090 // We are setting the :active chain and freezing it. If future moves
happen, they |
| 5091 // will need to reference this chain. | 5091 // will need to reference this chain. |
| 5092 for (RenderObject* curr = newActiveElement->renderer(); curr; curr =
curr->parent()) { | 5092 for (RenderObject* curr = newActiveElement->renderer(); curr; curr =
curr->parent()) { |
| 5093 if (curr->node() && !curr->isText()) | 5093 if (curr->node() && !curr->isText()) |
| 5094 m_userActionElements.setInActiveChain(curr->node(), true); | 5094 m_userActionElements.setInActiveChain(curr->node(), true); |
| 5095 } | 5095 } |
| 5096 | 5096 |
| 5097 setActiveElement(newActiveElement); | 5097 setActiveHoverElement(newActiveElement); |
| 5098 } | 5098 } |
| 5099 } | 5099 } |
| 5100 // If the mouse has just been pressed, set :active on the chain. Those (and
only those) | 5100 // If the mouse has just been pressed, set :active on the chain. Those (and
only those) |
| 5101 // nodes should remain :active until the mouse is released. | 5101 // nodes should remain :active until the mouse is released. |
| 5102 bool allowActiveChanges = !oldActiveElement && activeElement(); | 5102 bool allowActiveChanges = !oldActiveElement && activeHoverElement(); |
| 5103 | 5103 |
| 5104 // If the mouse is down and if this is a mouse move event, we want to restri
ct changes in | 5104 // If the mouse is down and if this is a mouse move event, we want to restri
ct changes in |
| 5105 // :hover/:active to only apply to elements that are in the :active chain th
at we froze | 5105 // :hover/:active to only apply to elements that are in the :active chain th
at we froze |
| 5106 // at the time the mouse went down. | 5106 // at the time the mouse went down. |
| 5107 bool mustBeInActiveChain = request.active() && request.move(); | 5107 bool mustBeInActiveChain = request.active() && request.move(); |
| 5108 | 5108 |
| 5109 RefPtr<Node> oldHoverNode = hoverNode(); | 5109 RefPtr<Node> oldHoverNode = hoverNode(); |
| 5110 | 5110 |
| 5111 // Check to see if the hovered node has changed. | 5111 // Check to see if the hovered node has changed. |
| 5112 // If it hasn't, we do not need to do anything. | 5112 // If it hasn't, we do not need to do anything. |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5315 return; | 5315 return; |
| 5316 } | 5316 } |
| 5317 if (m_hasAutofocused) | 5317 if (m_hasAutofocused) |
| 5318 return; | 5318 return; |
| 5319 m_hasAutofocused = true; | 5319 m_hasAutofocused = true; |
| 5320 ASSERT(!m_autofocusElement); | 5320 ASSERT(!m_autofocusElement); |
| 5321 m_autofocusElement = element; | 5321 m_autofocusElement = element; |
| 5322 m_taskRunner->postTask(AutofocusTask::create()); | 5322 m_taskRunner->postTask(AutofocusTask::create()); |
| 5323 } | 5323 } |
| 5324 | 5324 |
| 5325 Element* Document::activeElement() const |
| 5326 { |
| 5327 if (Element* element = treeScope().adjustedFocusedElement()) |
| 5328 return element; |
| 5329 return body(); |
| 5330 } |
| 5331 |
| 5332 bool Document::hasFocus() const |
| 5333 { |
| 5334 Page* page = this->page(); |
| 5335 if (!page) |
| 5336 return false; |
| 5337 if (!page->focusController().isActive() || !page->focusController().isFocuse
d()) |
| 5338 return false; |
| 5339 if (Frame* focusedFrame = page->focusController().focusedFrame()) { |
| 5340 if (focusedFrame->tree().isDescendantOf(frame())) |
| 5341 return true; |
| 5342 } |
| 5343 return false; |
| 5344 } |
| 5345 |
| 5325 } // namespace WebCore | 5346 } // namespace WebCore |
| OLD | NEW |