Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(334)

Side by Side Diff: Source/core/dom/Document.cpp

Issue 1064543002: Set hovered state of current Hovered node even if it is also common ancestor of oldHovered node and (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 5258 matching lines...) Expand 10 before | Expand all | Expand 10 after
5269 5269
5270 // Update our current hover node. 5270 // Update our current hover node.
5271 setHoverNode(newHoverNode); 5271 setHoverNode(newHoverNode);
5272 5272
5273 // We have two different objects. Fetch their renderers. 5273 // We have two different objects. Fetch their renderers.
5274 LayoutObject* oldHoverObj = oldHoverNode ? oldHoverNode->layoutObject() : 0; 5274 LayoutObject* oldHoverObj = oldHoverNode ? oldHoverNode->layoutObject() : 0;
5275 LayoutObject* newHoverObj = newHoverNode ? newHoverNode->layoutObject() : 0; 5275 LayoutObject* newHoverObj = newHoverNode ? newHoverNode->layoutObject() : 0;
5276 5276
5277 // Locate the common ancestor render object for the two renderers. 5277 // Locate the common ancestor render object for the two renderers.
5278 LayoutObject* ancestor = nearestCommonHoverAncestor(oldHoverObj, newHoverObj ); 5278 LayoutObject* ancestor = nearestCommonHoverAncestor(oldHoverObj, newHoverObj );
5279 RefPtrWillBeRawPtr<Node> ancestorNode(ancestor ? ancestor->node() : 0); 5279 RefPtrWillBeRawPtr<Node> ancestorNode(ancestor ? ancestor->node() : 0);
leviw_travelin_and_unemployed 2015/04/07 17:17:42 This is no longer used.
5280 5280
5281 WillBeHeapVector<RefPtrWillBeMember<Node>, 32> nodesToRemoveFromChain; 5281 WillBeHeapVector<RefPtrWillBeMember<Node>, 32> nodesToRemoveFromChain;
5282 WillBeHeapVector<RefPtrWillBeMember<Node>, 32> nodesToAddToChain; 5282 WillBeHeapVector<RefPtrWillBeMember<Node>, 32> nodesToAddToChain;
5283 5283
5284 if (oldHoverObj != newHoverObj) { 5284 if (oldHoverObj != newHoverObj) {
5285 // If the old hovered node is not nil but it's renderer is, it was proba bly detached as part of the :hover style 5285 // If the old hovered node is not nil but it's renderer is, it was proba bly detached as part of the :hover style
5286 // (for instance by setting display:none in the :hover pseudo-class). In this case, the old hovered element (and its ancestors) 5286 // (for instance by setting display:none in the :hover pseudo-class). In this case, the old hovered element (and its ancestors)
5287 // must be updated, to ensure it's normal style is re-applied. 5287 // must be updated, to ensure it's normal style is re-applied.
5288 if (oldHoverNode && !oldHoverObj) { 5288 if (oldHoverNode && !oldHoverObj) {
5289 for (Node* node = oldHoverNode.get(); node; node = node->parentNode( )) { 5289 for (Node* node = oldHoverNode.get(); node; node = node->parentNode( )) {
(...skipping 16 matching lines...) Expand all
5306 for (LayoutObject* curr = newHoverObj; curr; curr = curr->hoverAncestor()) { 5306 for (LayoutObject* curr = newHoverObj; curr; curr = curr->hoverAncestor()) {
5307 if (curr->node() && !curr->isText() && (!mustBeInActiveChain || curr->no de()->inActiveChain())) 5307 if (curr->node() && !curr->isText() && (!mustBeInActiveChain || curr->no de()->inActiveChain()))
5308 nodesToAddToChain.append(curr->node()); 5308 nodesToAddToChain.append(curr->node());
5309 } 5309 }
5310 5310
5311 size_t removeCount = nodesToRemoveFromChain.size(); 5311 size_t removeCount = nodesToRemoveFromChain.size();
5312 for (size_t i = 0; i < removeCount; ++i) { 5312 for (size_t i = 0; i < removeCount; ++i) {
5313 nodesToRemoveFromChain[i]->setHovered(false); 5313 nodesToRemoveFromChain[i]->setHovered(false);
5314 } 5314 }
5315 5315
5316 bool sawCommonAncestor = false;
5317 size_t addCount = nodesToAddToChain.size(); 5316 size_t addCount = nodesToAddToChain.size();
5318 for (size_t i = 0; i < addCount; ++i) { 5317 for (size_t i = 0; i < addCount; ++i) {
5319 // Elements past the common ancestor do not change hover state, but migh t change active state. 5318 // Elements past the common ancestor do not change hover state, but migh t change active state.
5320 if (ancestorNode && nodesToAddToChain[i] == ancestorNode)
5321 sawCommonAncestor = true;
5322 if (allowActiveChanges) 5319 if (allowActiveChanges)
5323 nodesToAddToChain[i]->setActive(true); 5320 nodesToAddToChain[i]->setActive(true);
5324 if (!sawCommonAncestor) { 5321 nodesToAddToChain[i]->setHovered(true);
5325 nodesToAddToChain[i]->setHovered(true);
5326 }
5327 } 5322 }
5328 } 5323 }
5329 5324
5330 bool Document::haveStylesheetsLoaded() const 5325 bool Document::haveStylesheetsLoaded() const
5331 { 5326 {
5332 return m_styleEngine->haveStylesheetsLoaded(); 5327 return m_styleEngine->haveStylesheetsLoaded();
5333 } 5328 }
5334 5329
5335 Locale& Document::getCachedLocale(const AtomicString& locale) 5330 Locale& Document::getCachedLocale(const AtomicString& locale)
5336 { 5331 {
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
5704 #ifndef NDEBUG 5699 #ifndef NDEBUG
5705 using namespace blink; 5700 using namespace blink;
5706 void showLiveDocumentInstances() 5701 void showLiveDocumentInstances()
5707 { 5702 {
5708 WeakDocumentSet& set = liveDocumentSet(); 5703 WeakDocumentSet& set = liveDocumentSet();
5709 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 5704 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
5710 for (Document* document : set) 5705 for (Document* document : set)
5711 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data()); 5706 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data());
5712 } 5707 }
5713 #endif 5708 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698