| 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 6127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6138 !m_snapCoordinator) | 6138 !m_snapCoordinator) |
| 6139 m_snapCoordinator = SnapCoordinator::create(); | 6139 m_snapCoordinator = SnapCoordinator::create(); |
| 6140 | 6140 |
| 6141 return m_snapCoordinator.get(); | 6141 return m_snapCoordinator.get(); |
| 6142 } | 6142 } |
| 6143 | 6143 |
| 6144 void Document::setContextFeatures(ContextFeatures& features) { | 6144 void Document::setContextFeatures(ContextFeatures& features) { |
| 6145 m_contextFeatures = &features; | 6145 m_contextFeatures = &features; |
| 6146 } | 6146 } |
| 6147 | 6147 |
| 6148 static LayoutObject* nearestCommonHoverAncestor(LayoutObject* obj1, | |
| 6149 LayoutObject* obj2) { | |
| 6150 if (!obj1 || !obj2) | |
| 6151 return 0; | |
| 6152 | |
| 6153 for (LayoutObject* currObj1 = obj1; currObj1; | |
| 6154 currObj1 = currObj1->hoverAncestor()) { | |
| 6155 for (LayoutObject* currObj2 = obj2; currObj2; | |
| 6156 currObj2 = currObj2->hoverAncestor()) { | |
| 6157 if (currObj1 == currObj2) | |
| 6158 return currObj1; | |
| 6159 } | |
| 6160 } | |
| 6161 | |
| 6162 return 0; | |
| 6163 } | |
| 6164 | |
| 6165 // TODO(mustaq) |request| parameter maybe a misuse of HitTestRequest in | 6148 // TODO(mustaq) |request| parameter maybe a misuse of HitTestRequest in |
| 6166 // updateHoverActiveState() since the function doesn't bother with hit-testing. | 6149 // updateHoverActiveState() since the function doesn't bother with hit-testing. |
| 6167 void Document::updateHoverActiveState(const HitTestRequest& request, | 6150 void Document::updateHoverActiveState(const HitTestRequest& request, |
| 6168 Element* innerElement, | 6151 Element* innerElement, |
| 6169 Scrollbar* hitScrollbar) { | 6152 Scrollbar* hitScrollbar) { |
| 6170 DCHECK(!request.readOnly()); | 6153 DCHECK(!request.readOnly()); |
| 6171 | 6154 |
| 6172 if (request.active() && m_frame) | 6155 if (request.active() && m_frame) |
| 6173 m_frame->eventHandler().notifyElementActivated(); | 6156 m_frame->eventHandler().notifyElementActivated(); |
| 6174 | 6157 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6232 | 6215 |
| 6233 // Check to see if the hovered node has changed. | 6216 // Check to see if the hovered node has changed. |
| 6234 // If it hasn't, we do not need to do anything. | 6217 // If it hasn't, we do not need to do anything. |
| 6235 Node* newHoverNode = innerElementInDocument; | 6218 Node* newHoverNode = innerElementInDocument; |
| 6236 while (newHoverNode && !newHoverNode->layoutObject()) | 6219 while (newHoverNode && !newHoverNode->layoutObject()) |
| 6237 newHoverNode = newHoverNode->parentOrShadowHostNode(); | 6220 newHoverNode = newHoverNode->parentOrShadowHostNode(); |
| 6238 | 6221 |
| 6239 // Update our current hover node. | 6222 // Update our current hover node. |
| 6240 setHoverNode(newHoverNode); | 6223 setHoverNode(newHoverNode); |
| 6241 | 6224 |
| 6242 // We have two different objects. Fetch their layoutObjects. | 6225 Node* ancestor = |
| 6243 LayoutObject* oldHoverObj = | 6226 (oldHoverNode && oldHoverNode->isConnected() && newHoverNode) |
| 6244 oldHoverNode ? oldHoverNode->layoutObject() : nullptr; | 6227 ? FlatTreeTraversal::commonAncestor(*oldHoverNode, *newHoverNode) |
| 6245 LayoutObject* newHoverObj = | 6228 : nullptr; |
| 6246 newHoverNode ? newHoverNode->layoutObject() : nullptr; | |
| 6247 | |
| 6248 // Locate the common ancestor layout object for the two layoutObjects. | |
| 6249 LayoutObject* ancestor = nearestCommonHoverAncestor(oldHoverObj, newHoverObj); | |
| 6250 Node* ancestorNode(ancestor ? ancestor->node() : nullptr); | |
| 6251 | 6229 |
| 6252 HeapVector<Member<Node>, 32> nodesToRemoveFromChain; | 6230 HeapVector<Member<Node>, 32> nodesToRemoveFromChain; |
| 6253 HeapVector<Member<Node>, 32> nodesToAddToChain; | 6231 HeapVector<Member<Node>, 32> nodesToAddToChain; |
| 6254 | 6232 |
| 6255 if (oldHoverObj != newHoverObj) { | 6233 if (oldHoverNode != newHoverNode) { |
| 6256 // If the old hovered node is not nil but it's layoutObject is, it was | 6234 // The old hover path only needs to be cleared up to (and not including) the |
| 6257 // probably detached as part of the :hover style (for instance by setting | 6235 // common ancestor; |
| 6258 // display:none in the :hover pseudo-class). In this case, the old hovered | 6236 // |
| 6259 // element (and its ancestors) must be updated, to ensure it's normal style | 6237 // FIXME(ecobos@igalia.com): oldHoverNode may be disconnected from the tree |
| 6260 // is re-applied. | 6238 // already. This is due to our handling of m_hoverNode in |
| 6261 if (oldHoverNode && !oldHoverObj) { | 6239 // hoveredNodeDetached (which assumes all the parents are hovered) and |
| 6262 for (Node& node : NodeTraversal::inclusiveAncestorsOf(*oldHoverNode)) { | 6240 // mustBeInActiveChain (which makes this not hold). |
| 6263 if (!mustBeInActiveChain || | 6241 // |
| 6264 (node.isElementNode() && toElement(node).inActiveChain())) | 6242 // In that case, none of the nodes in the chain have the flags, so there's |
| 6265 nodesToRemoveFromChain.push_back(node); | 6243 // no problem in skipping this step. |
| 6244 if (oldHoverNode && oldHoverNode->isConnected()) { |
| 6245 for (Node* curr = oldHoverNode; curr && curr != ancestor; |
| 6246 curr = FlatTreeTraversal::parent(*curr)) { |
| 6247 if (!curr->isTextNode() && |
| 6248 (!mustBeInActiveChain || curr->inActiveChain())) |
| 6249 nodesToRemoveFromChain.push_back(curr); |
| 6266 } | 6250 } |
| 6267 } | 6251 } |
| 6268 | |
| 6269 // The old hover path only needs to be cleared up to (and not including) the | |
| 6270 // common ancestor; | |
| 6271 for (LayoutObject* curr = oldHoverObj; curr && curr != ancestor; | |
| 6272 curr = curr->hoverAncestor()) { | |
| 6273 if (curr->node() && !curr->isText() && | |
| 6274 (!mustBeInActiveChain || curr->node()->inActiveChain())) | |
| 6275 nodesToRemoveFromChain.push_back(curr->node()); | |
| 6276 } | |
| 6277 | |
| 6278 // TODO(mustaq): The two loops above may push a single node twice into | |
| 6279 // nodesToRemoveFromChain. There must be a better way. | |
| 6280 } | 6252 } |
| 6281 | 6253 |
| 6282 // Now set the hover state for our new object up to the root. | 6254 // Now set the hover state for our new object up to the root. |
| 6283 for (LayoutObject* curr = newHoverObj; curr; curr = curr->hoverAncestor()) { | 6255 for (Node* curr = newHoverNode; curr; |
| 6284 if (curr->node() && !curr->isText() && | 6256 curr = FlatTreeTraversal::parent(*curr)) { |
| 6285 (!mustBeInActiveChain || curr->node()->inActiveChain())) | 6257 if (!curr->isTextNode() && (!mustBeInActiveChain || curr->inActiveChain())) |
| 6286 nodesToAddToChain.push_back(curr->node()); | 6258 nodesToAddToChain.push_back(curr); |
| 6287 } | 6259 } |
| 6288 | 6260 |
| 6289 size_t removeCount = nodesToRemoveFromChain.size(); | 6261 for (Node* node : nodesToRemoveFromChain) |
| 6290 for (size_t i = 0; i < removeCount; ++i) { | 6262 node->setHovered(false); |
| 6291 nodesToRemoveFromChain[i]->setHovered(false); | |
| 6292 } | |
| 6293 | 6263 |
| 6294 bool sawCommonAncestor = false; | 6264 bool sawCommonAncestor = false; |
| 6295 size_t addCount = nodesToAddToChain.size(); | 6265 for (Node* node : nodesToAddToChain) { |
| 6296 for (size_t i = 0; i < addCount; ++i) { | |
| 6297 // Elements past the common ancestor do not change hover state, but might | 6266 // Elements past the common ancestor do not change hover state, but might |
| 6298 // change active state. | 6267 // change active state. |
| 6299 if (ancestorNode && nodesToAddToChain[i] == ancestorNode) | 6268 if (node == ancestor) |
| 6300 sawCommonAncestor = true; | 6269 sawCommonAncestor = true; |
| 6301 if (allowActiveChanges) | 6270 if (allowActiveChanges) |
| 6302 nodesToAddToChain[i]->setActive(true); | 6271 node->setActive(true); |
| 6303 if (!sawCommonAncestor || nodesToAddToChain[i] == m_hoverNode) { | 6272 if (!sawCommonAncestor || node == m_hoverNode) |
| 6304 nodesToAddToChain[i]->setHovered(true); | 6273 node->setHovered(true); |
| 6305 } | |
| 6306 } | 6274 } |
| 6307 } | 6275 } |
| 6308 | 6276 |
| 6309 bool Document::haveScriptBlockingStylesheetsLoaded() const { | 6277 bool Document::haveScriptBlockingStylesheetsLoaded() const { |
| 6310 return m_styleEngine->haveScriptBlockingStylesheetsLoaded(); | 6278 return m_styleEngine->haveScriptBlockingStylesheetsLoaded(); |
| 6311 } | 6279 } |
| 6312 | 6280 |
| 6313 bool Document::haveRenderBlockingStylesheetsLoaded() const { | 6281 bool Document::haveRenderBlockingStylesheetsLoaded() const { |
| 6314 if (RuntimeEnabledFeatures::cssInBodyDoesNotBlockPaintEnabled()) | 6282 if (RuntimeEnabledFeatures::cssInBodyDoesNotBlockPaintEnabled()) |
| 6315 return m_styleEngine->haveRenderBlockingStylesheetsLoaded(); | 6283 return m_styleEngine->haveRenderBlockingStylesheetsLoaded(); |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6663 } | 6631 } |
| 6664 | 6632 |
| 6665 void showLiveDocumentInstances() { | 6633 void showLiveDocumentInstances() { |
| 6666 WeakDocumentSet& set = liveDocumentSet(); | 6634 WeakDocumentSet& set = liveDocumentSet(); |
| 6667 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 6635 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
| 6668 for (blink::Document* document : set) | 6636 for (blink::Document* document : set) |
| 6669 fprintf(stderr, "- Document %p URL: %s\n", document, | 6637 fprintf(stderr, "- Document %p URL: %s\n", document, |
| 6670 document->url().getString().utf8().data()); | 6638 document->url().getString().utf8().data()); |
| 6671 } | 6639 } |
| 6672 #endif | 6640 #endif |
| OLD | NEW |