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

Side by Side Diff: third_party/WebKit/Source/core/dom/UserActionElementSet.h

Issue 2795143004: [selectors4] Implement :focus-within pseudo-class (Closed)
Patch Set: Rebased patch Created 3 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) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Neither the name of Google Inc. nor the names of its 10 * * Neither the name of Google Inc. nor the names of its
(...skipping 22 matching lines...) Expand all
33 namespace blink { 33 namespace blink {
34 34
35 class Node; 35 class Node;
36 class Element; 36 class Element;
37 37
38 class UserActionElementSet final { 38 class UserActionElementSet final {
39 DISALLOW_NEW(); 39 DISALLOW_NEW();
40 40
41 public: 41 public:
42 bool IsFocused(const Node* node) { return HasFlags(node, kIsFocusedFlag); } 42 bool IsFocused(const Node* node) { return HasFlags(node, kIsFocusedFlag); }
43 bool HasFocusWithin(const Node* node) {
44 return HasFlags(node, kHasFocusWithinFlag);
45 }
43 bool IsActive(const Node* node) { return HasFlags(node, kIsActiveFlag); } 46 bool IsActive(const Node* node) { return HasFlags(node, kIsActiveFlag); }
44 bool IsInActiveChain(const Node* node) { 47 bool IsInActiveChain(const Node* node) {
45 return HasFlags(node, kInActiveChainFlag); 48 return HasFlags(node, kInActiveChainFlag);
46 } 49 }
47 bool IsDragged(const Node* node) { return HasFlags(node, kIsDraggedFlag); } 50 bool IsDragged(const Node* node) { return HasFlags(node, kIsDraggedFlag); }
48 bool IsHovered(const Node* node) { return HasFlags(node, kIsHoveredFlag); } 51 bool IsHovered(const Node* node) { return HasFlags(node, kIsHoveredFlag); }
49 void SetFocused(Node* node, bool enable) { 52 void SetFocused(Node* node, bool enable) {
50 SetFlags(node, enable, kIsFocusedFlag); 53 SetFlags(node, enable, kIsFocusedFlag);
51 } 54 }
55 void SetHasFocusWithin(Node* node, bool enable) {
56 SetFlags(node, enable, kHasFocusWithinFlag);
57 }
52 void SetActive(Node* node, bool enable) { 58 void SetActive(Node* node, bool enable) {
53 SetFlags(node, enable, kIsActiveFlag); 59 SetFlags(node, enable, kIsActiveFlag);
54 } 60 }
55 void SetInActiveChain(Node* node, bool enable) { 61 void SetInActiveChain(Node* node, bool enable) {
56 SetFlags(node, enable, kInActiveChainFlag); 62 SetFlags(node, enable, kInActiveChainFlag);
57 } 63 }
58 void SetDragged(Node* node, bool enable) { 64 void SetDragged(Node* node, bool enable) {
59 SetFlags(node, enable, kIsDraggedFlag); 65 SetFlags(node, enable, kIsDraggedFlag);
60 } 66 }
61 void SetHovered(Node* node, bool enable) { 67 void SetHovered(Node* node, bool enable) {
62 SetFlags(node, enable, kIsHoveredFlag); 68 SetFlags(node, enable, kIsHoveredFlag);
63 } 69 }
64 70
65 UserActionElementSet(); 71 UserActionElementSet();
66 ~UserActionElementSet(); 72 ~UserActionElementSet();
67 73
68 void DidDetach(Element&); 74 void DidDetach(Element&);
69 75
70 DECLARE_TRACE(); 76 DECLARE_TRACE();
71 77
72 private: 78 private:
73 enum ElementFlags { 79 enum ElementFlags {
74 kIsActiveFlag = 1, 80 kIsActiveFlag = 1,
75 kInActiveChainFlag = 1 << 1, 81 kInActiveChainFlag = 1 << 1,
76 kIsHoveredFlag = 1 << 2, 82 kIsHoveredFlag = 1 << 2,
77 kIsFocusedFlag = 1 << 3, 83 kIsFocusedFlag = 1 << 3,
78 kIsDraggedFlag = 1 << 4, 84 kIsDraggedFlag = 1 << 4,
85 kHasFocusWithinFlag = 1 << 5,
79 }; 86 };
80 87
81 void SetFlags(Node* node, bool enable, unsigned flags) { 88 void SetFlags(Node* node, bool enable, unsigned flags) {
82 enable ? SetFlags(node, flags) : ClearFlags(node, flags); 89 enable ? SetFlags(node, flags) : ClearFlags(node, flags);
83 } 90 }
84 void SetFlags(Node*, unsigned); 91 void SetFlags(Node*, unsigned);
85 void ClearFlags(Node*, unsigned); 92 void ClearFlags(Node*, unsigned);
86 bool HasFlags(const Node*, unsigned flags) const; 93 bool HasFlags(const Node*, unsigned flags) const;
87 94
88 void SetFlags(Element*, unsigned); 95 void SetFlags(Element*, unsigned);
89 void ClearFlags(Element*, unsigned); 96 void ClearFlags(Element*, unsigned);
90 bool HasFlags(const Element*, unsigned flags) const; 97 bool HasFlags(const Element*, unsigned flags) const;
91 98
92 typedef HeapHashMap<Member<Element>, unsigned> ElementFlagMap; 99 typedef HeapHashMap<Member<Element>, unsigned> ElementFlagMap;
93 ElementFlagMap elements_; 100 ElementFlagMap elements_;
94 }; 101 };
95 102
96 } // namespace blink 103 } // namespace blink
97 104
98 #endif // UserActionElementSet_h 105 #endif // UserActionElementSet_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/StyleChangeReason.cpp ('k') | third_party/WebKit/Source/core/dom/UserActionElementSet.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698