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

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

Issue 18297002: Optimize (slightly) Document::updateHoverActiveState. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: NeedsRebaseline. Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « LayoutTests/TestExpectations ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 5070 matching lines...) Expand 10 before | Expand all | Expand 10 after
5081 // Now set the hover state for our new object up to the root. 5081 // Now set the hover state for our new object up to the root.
5082 for (RenderObject* curr = newHoverObj; curr; curr = curr->hoverAncestor()) { 5082 for (RenderObject* curr = newHoverObj; curr; curr = curr->hoverAncestor()) {
5083 if (curr->node() && !curr->isText() && (!mustBeInActiveChain || curr->no de()->inActiveChain())) 5083 if (curr->node() && !curr->isText() && (!mustBeInActiveChain || curr->no de()->inActiveChain()))
5084 nodesToAddToChain.append(curr->node()); 5084 nodesToAddToChain.append(curr->node());
5085 } 5085 }
5086 5086
5087 size_t removeCount = nodesToRemoveFromChain.size(); 5087 size_t removeCount = nodesToRemoveFromChain.size();
5088 for (size_t i = 0; i < removeCount; ++i) 5088 for (size_t i = 0; i < removeCount; ++i)
5089 nodesToRemoveFromChain[i]->setHovered(false); 5089 nodesToRemoveFromChain[i]->setHovered(false);
5090 5090
5091 bool sawCommonAncestor = false;
5091 size_t addCount = nodesToAddToChain.size(); 5092 size_t addCount = nodesToAddToChain.size();
5092 for (size_t i = 0; i < addCount; ++i) { 5093 for (size_t i = 0; i < addCount; ++i) {
5094 // Elements past the common ancestor do not change hover state, but migh t change active state.
5095 if (ancestor && nodesToAddToChain[i] == ancestor->node())
5096 sawCommonAncestor = true;
5093 if (allowActiveChanges) 5097 if (allowActiveChanges)
5094 nodesToAddToChain[i]->setActive(true); 5098 nodesToAddToChain[i]->setActive(true);
5095 nodesToAddToChain[i]->setHovered(true); 5099 if (!sawCommonAncestor)
5100 nodesToAddToChain[i]->setHovered(true);
5096 } 5101 }
5097 5102
5098 updateStyleIfNeeded(); 5103 updateStyleIfNeeded();
5099 } 5104 }
5100 5105
5101 void Document::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const 5106 void Document::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
5102 { 5107 {
5103 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM); 5108 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM);
5104 ContainerNode::reportMemoryUsage(memoryObjectInfo); 5109 ContainerNode::reportMemoryUsage(memoryObjectInfo);
5105 TreeScope::reportMemoryUsage(memoryObjectInfo); 5110 TreeScope::reportMemoryUsage(memoryObjectInfo);
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
5244 { 5249 {
5245 return DocumentLifecycleNotifier::create(this); 5250 return DocumentLifecycleNotifier::create(this);
5246 } 5251 }
5247 5252
5248 DocumentLifecycleNotifier* Document::lifecycleNotifier() 5253 DocumentLifecycleNotifier* Document::lifecycleNotifier()
5249 { 5254 {
5250 return static_cast<DocumentLifecycleNotifier*>(ScriptExecutionContext::lifec ycleNotifier()); 5255 return static_cast<DocumentLifecycleNotifier*>(ScriptExecutionContext::lifec ycleNotifier());
5251 } 5256 }
5252 5257
5253 } // namespace WebCore 5258 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/TestExpectations ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698