Diff
Modified: trunk/Source/WebCore/ChangeLog (150721 => 150722)
--- trunk/Source/WebCore/ChangeLog 2013-05-26 18:44:36 UTC (rev 150721)
+++ trunk/Source/WebCore/ChangeLog 2013-05-26 22:23:18 UTC (rev 150722)
@@ -1,3 +1,39 @@
+2013-05-26 Andreas Kling <[email protected]>
+
+ Move :active chain participation state from Node to Element.
+ <http://webkit.org/b/116786>
+
+ Reviewed by Antti Koivisto.
+
+ Only Elements can be in the :active chain so move the logic there from Node.
+
+ * dom/Document.cpp:
+ (WebCore::Document::updateHoverActiveState):
+
+ Add isElementNode() type checks when updating the :active chain.
+
+ * dom/Node.h:
+ * dom/Node.cpp:
+ (WebCore::Node::detach):
+ * dom/Element.cpp:
+ (WebCore::Element::detach):
+
+ Move the remaining logic for detaching from the UserActionElementSet to Element.
+
+ (WebCore::Element::isUserActionElementInActiveChain):
+ * dom/Element.h:
+ (WebCore::Element::inActiveChain):
+
+ Move all the :active chain stuff from Node to Element.
+
+ * dom/UserActionElementSet.cpp:
+ (WebCore::UserActionElementSet::didDetach):
+ * dom/UserActionElementSet.h:
+ (WebCore::UserActionElementSet::isInActiveChain):
+ (WebCore::UserActionElementSet::setInActiveChain):
+
+ UserActionElementSet now only takes Element* in its API.
+
2013-05-26 Antti Koivisto <[email protected]>
Remove FontFamily.h/.cpp
Modified: trunk/Source/WebCore/dom/Document.cpp (150721 => 150722)
--- trunk/Source/WebCore/dom/Document.cpp 2013-05-26 18:44:36 UTC (rev 150721)
+++ trunk/Source/WebCore/dom/Document.cpp 2013-05-26 22:23:18 UTC (rev 150722)
@@ -3,7 +3,7 @@
* (C) 1999 Antti Koivisto ([email protected])
* (C) 2001 Dirk Mueller ([email protected])
* (C) 2006 Alexey Proskuryakov ([email protected])
- * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012, 2013 Apple Inc. All rights reserved.
* Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
* Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
@@ -5870,12 +5870,11 @@
if (oldActiveElement && !request.active()) {
// We are clearing the :active chain because the mouse has been released.
for (RenderObject* curr = oldActiveElement->renderer(); curr; curr = curr->parent()) {
- if (curr->node()) {
- ASSERT(!curr->node()->isTextNode());
- if (curr->node()->isElementNode())
- toElement(curr->node())->setActive(false);
- m_userActionElements.setInActiveChain(curr->node(), false);
- }
+ if (!curr->node() || !curr->node()->isElementNode())
+ continue;
+ Element* element = toElement(curr->node());
+ element->setActive(false);
+ m_userActionElements.setInActiveChain(element, false);
}
setActiveElement(0);
} else {
@@ -5884,8 +5883,9 @@
// We are setting the :active chain and freezing it. If future moves happen, they
// will need to reference this chain.
for (RenderObject* curr = newActiveElement->renderer(); curr; curr = curr->parent()) {
- if (curr->node() && !curr->isText())
- m_userActionElements.setInActiveChain(curr->node(), true);
+ if (!curr->node() || !curr->node()->isElementNode() || curr->isText())
+ continue;
+ m_userActionElements.setInActiveChain(toElement(curr->node()), true);
}
setActiveElement(newActiveElement);
@@ -5949,7 +5949,9 @@
if (oldHoverObj != newHoverObj) {
// The old hover path only needs to be cleared up to (and not including) the common ancestor;
for (RenderObject* curr = oldHoverObj; curr && curr != ancestor; curr = curr->hoverAncestor()) {
- if (curr->node() && !curr->isText() && (!mustBeInActiveChain || curr->node()->inActiveChain()))
+ if (!curr->node() || curr->isText())
+ continue;
+ if (!mustBeInActiveChain || (curr->node()->isElementNode() && toElement(curr->node())->inActiveChain()))
nodesToRemoveFromChain.append(curr->node());
}
// Unset hovered nodes in sub frame documents if the old hovered node was a frame owner.
@@ -5961,7 +5963,9 @@
// Now set the hover state for our new object up to the root.
for (RenderObject* curr = newHoverObj; curr; curr = curr->hoverAncestor()) {
- if (curr->node() && !curr->isText() && (!mustBeInActiveChain || curr->node()->inActiveChain()))
+ if (!curr->node() || curr->isText())
+ continue;
+ if (!mustBeInActiveChain || (curr->node()->isElementNode() && toElement(curr->node())->inActiveChain()))
nodesToAddToChain.append(curr->node());
}
Modified: trunk/Source/WebCore/dom/Element.cpp (150721 => 150722)
--- trunk/Source/WebCore/dom/Element.cpp 2013-05-26 18:44:36 UTC (rev 150721)
+++ trunk/Source/WebCore/dom/Element.cpp 2013-05-26 22:23:18 UTC (rev 150722)
@@ -457,6 +457,12 @@
return true;
}
+bool Element::isUserActionElementInActiveChain() const
+{
+ ASSERT(isUserActionElement());
+ return document()->userActionElements().isInActiveChain(this);
+}
+
bool Element::isUserActionElementActive() const
{
ASSERT(isUserActionElement());
@@ -1469,8 +1475,13 @@
shadow->detach();
}
- if (hovered())
- document()->hoveredNodeDetached(this);
+ if (isUserActionElement()) {
+ if (hovered())
+ document()->hoveredNodeDetached(this);
+ if (inActiveChain())
+ document()->activeChainNodeDetached(this);
+ document()->userActionElements().didDetach(this);
+ }
ContainerNode::detach();
}
Modified: trunk/Source/WebCore/dom/Element.h (150721 => 150722)
--- trunk/Source/WebCore/dom/Element.h 2013-05-26 18:44:36 UTC (rev 150721)
+++ trunk/Source/WebCore/dom/Element.h 2013-05-26 22:23:18 UTC (rev 150722)
@@ -426,6 +426,7 @@
virtual const AtomicString& shadowPseudoId() const;
+ bool inActiveChain() const { return isUserActionElement() && isUserActionElementInActiveChain(); }
bool active() const { return isUserActionElement() && isUserActionElementActive(); }
bool hovered() const { return isUserActionElement() && isUserActionElementHovered(); }
bool focused() const { return isUserActionElement() && isUserActionElementFocused(); }
@@ -664,6 +665,7 @@
void classAttributeChanged(const AtomicString& newClassString);
private:
+ bool isUserActionElementInActiveChain() const;
bool isUserActionElementActive() const;
bool isUserActionElementFocused() const;
bool isUserActionElementHovered() const;
Modified: trunk/Source/WebCore/dom/Node.cpp (150721 => 150722)
--- trunk/Source/WebCore/dom/Node.cpp 2013-05-26 18:44:36 UTC (rev 150721)
+++ trunk/Source/WebCore/dom/Node.cpp 2013-05-26 22:23:18 UTC (rev 150722)
@@ -106,7 +106,6 @@
#include "TreeScopeAdopter.h"
#include "UIEvent.h"
#include "UIEventWithKeyState.h"
-#include "UserActionElementSet.h"
#include "WheelEvent.h"
#include "WindowEventContext.h"
#include "XMLNames.h"
@@ -1050,13 +1049,6 @@
renderer()->destroyAndCleanupAnonymousWrappers();
setRenderer(0);
- Document* doc = document();
- if (isUserActionElement()) {
- if (inActiveChain())
- doc->activeChainNodeDetached(this);
- doc->userActionElements().didDetach(this);
- }
-
clearFlag(IsAttachedFlag);
#ifndef NDEBUG
@@ -2677,12 +2669,6 @@
return count;
}
-bool Node::isUserActionElementInActiveChain() const
-{
- ASSERT(isUserActionElement());
- return document()->userActionElements().isInActiveChain(this);
-}
-
} // namespace WebCore
#ifndef NDEBUG
Modified: trunk/Source/WebCore/dom/Node.h (150721 => 150722)
--- trunk/Source/WebCore/dom/Node.h 2013-05-26 18:44:36 UTC (rev 150721)
+++ trunk/Source/WebCore/dom/Node.h 2013-05-26 22:23:18 UTC (rev 150722)
@@ -358,8 +358,6 @@
bool isUserActionElement() const { return getFlag(IsUserActionElement); }
void setUserActionElement(bool flag) { setFlag(flag, IsUserActionElement); }
- bool inActiveChain() const { return isUserActionElement() && isUserActionElementInActiveChain(); }
-
bool attached() const { return getFlag(IsAttachedFlag); }
void setAttached() { setFlag(IsAttachedFlag); }
bool needsStyleRecalc() const { return styleChangeType() != NoStyleChange; }
@@ -770,8 +768,6 @@
bool rendererIsEditable(EditableLevel, UserSelectAllTreatment = UserSelectAllIsAlwaysNonEditable) const;
bool isEditableToAccessibility(EditableLevel) const;
- bool isUserActionElementInActiveChain() const;
-
void setStyleChange(StyleChangeType);
// Used to share code between lazyAttach and setNeedsStyleRecalc.
Modified: trunk/Source/WebCore/dom/UserActionElementSet.cpp (150721 => 150722)
--- trunk/Source/WebCore/dom/UserActionElementSet.cpp 2013-05-26 18:44:36 UTC (rev 150721)
+++ trunk/Source/WebCore/dom/UserActionElementSet.cpp 2013-05-26 22:23:18 UTC (rev 150722)
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2012 Google Inc. All rights reserved.
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -29,7 +30,6 @@
#include "Document.h"
#include "Element.h"
-#include "Node.h"
namespace WebCore {
@@ -41,10 +41,10 @@
{
}
-void UserActionElementSet::didDetach(Node* node)
+void UserActionElementSet::didDetach(Element* element)
{
- ASSERT(node->isUserActionElement());
- clearFlags(toElement(node), IsActiveFlag | InActiveChainFlag | IsHoveredFlag);
+ ASSERT(element->isUserActionElement());
+ clearFlags(element, IsActiveFlag | InActiveChainFlag | IsHoveredFlag);
}
void UserActionElementSet::documentDidRemoveLastRef()
@@ -52,26 +52,6 @@
m_elements.clear();
}
-bool UserActionElementSet::hasFlags(const Node* node, unsigned flags) const
-{
- ASSERT(node->isUserActionElement() && node->isElementNode());
- return hasFlags(toElement(node), flags);
-}
-
-void UserActionElementSet::setFlags(Node* node, unsigned flags)
-{
- if (!node->isElementNode())
- return;
- return setFlags(toElement(node), flags);
-}
-
-void UserActionElementSet::clearFlags(Node* node, unsigned flags)
-{
- if (!node->isElementNode())
- return;
- return clearFlags(toElement(node), flags);
-}
-
bool UserActionElementSet::hasFlags(const Element* element, unsigned flags) const
{
ASSERT(element->isUserActionElement());
Modified: trunk/Source/WebCore/dom/UserActionElementSet.h (150721 => 150722)
--- trunk/Source/WebCore/dom/UserActionElementSet.h 2013-05-26 18:44:36 UTC (rev 150721)
+++ trunk/Source/WebCore/dom/UserActionElementSet.h 2013-05-26 22:23:18 UTC (rev 150722)
@@ -36,7 +36,6 @@
namespace WebCore {
-class Node;
class Element;
class UserActionElementSet {
@@ -45,17 +44,17 @@
bool isFocused(const Element* element) { return hasFlags(element, IsFocusedFlag); }
bool isActive(const Element* element) { return hasFlags(element, IsActiveFlag); }
- bool isInActiveChain(const Node* node) { return hasFlags(node, InActiveChainFlag); }
+ bool isInActiveChain(const Element* element) { return hasFlags(element, InActiveChainFlag); }
bool isHovered(const Element* element) { return hasFlags(element, IsHoveredFlag); }
void setFocused(Element* element, bool enable) { setFlags(element, enable, IsFocusedFlag); }
void setActive(Element* element, bool enable) { setFlags(element, enable, IsActiveFlag); }
- void setInActiveChain(Node* node, bool enable) { setFlags(node, enable, InActiveChainFlag); }
+ void setInActiveChain(Element* element, bool enable) { setFlags(element, enable, InActiveChainFlag); }
void setHovered(Element* element, bool enable) { setFlags(element, enable, IsHoveredFlag); }
UserActionElementSet();
~UserActionElementSet();
- void didDetach(Node*);
+ void didDetach(Element*);
void documentDidRemoveLastRef();
private:
@@ -66,11 +65,6 @@
IsFocusedFlag = 1 << 3
};
- void setFlags(Node* node, bool enable, unsigned flags) { enable ? setFlags(node, flags) : clearFlags(node, flags); }
- void setFlags(Node*, unsigned);
- void clearFlags(Node*, unsigned);
- bool hasFlags(const Node*, unsigned flags) const;
-
void setFlags(Element* element, bool enable, unsigned flags) { enable ? setFlags(element, flags) : clearFlags(element, flags); }
void setFlags(Element*, unsigned);
void clearFlags(Element*, unsigned);