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

Side by Side Diff: Source/core/xml/XPathStep.h

Issue 26709019: Vector stores Predicate object as OwnPtr instead of raw pointer in XPath. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 2 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
« no previous file with comments | « Source/core/xml/XPathPath.cpp ('k') | Source/core/xml/XPathStep.cpp » ('j') | 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) 2005 Frerich Raabe <raabe@kde.org> 2 * Copyright (C) 2005 Frerich Raabe <raabe@kde.org>
3 * Copyright (C) 2006, 2009 Apple Inc. 3 * Copyright (C) 2006, 2009 Apple Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 WTF_MAKE_FAST_ALLOCATED; 54 WTF_MAKE_FAST_ALLOCATED;
55 public: 55 public:
56 enum Kind { 56 enum Kind {
57 TextNodeTest, CommentNodeTest, ProcessingInstructionNodeTest, AnyNod eTest, NameTest 57 TextNodeTest, CommentNodeTest, ProcessingInstructionNodeTest, AnyNod eTest, NameTest
58 }; 58 };
59 59
60 NodeTest(Kind kind) : m_kind(kind) { } 60 NodeTest(Kind kind) : m_kind(kind) { }
61 NodeTest(Kind kind, const String& data) : m_kind(kind), m_data(data) { } 61 NodeTest(Kind kind, const String& data) : m_kind(kind), m_data(data) { }
62 NodeTest(Kind kind, const String& data, const String& namespaceURI) : m_ kind(kind), m_data(data), m_namespaceURI(namespaceURI) { } 62 NodeTest(Kind kind, const String& data, const String& namespaceURI) : m_ kind(kind), m_data(data), m_namespaceURI(namespaceURI) { }
63 63
64 NodeTest(const NodeTest& o)
65 : m_kind(o.m_kind)
66 , m_data(o.m_data)
67 , m_namespaceURI(o.m_namespaceURI)
68 {
69 ASSERT(o.m_mergedPredicates.isEmpty());
70 }
71 NodeTest& operator=(const NodeTest& o)
72 {
73 m_kind = o.m_kind;
74 m_data = o.m_data;
75 m_namespaceURI = o.m_namespaceURI;
76 ASSERT(o.m_mergedPredicates.isEmpty());
77 return *this;
78 }
79
64 Kind kind() const { return m_kind; } 80 Kind kind() const { return m_kind; }
65 const AtomicString& data() const { return m_data; } 81 const AtomicString& data() const { return m_data; }
66 const AtomicString& namespaceURI() const { return m_namespaceURI; } 82 const AtomicString& namespaceURI() const { return m_namespaceURI; }
67 Vector<Predicate*>& mergedPredicates() { return m_mergedPredicates; } 83 Vector<OwnPtr<Predicate> >& mergedPredicates() { return m_mergedPredicat es; }
68 const Vector<Predicate*>& mergedPredicates() const { return m_mergedPred icates; } 84 const Vector<OwnPtr<Predicate> >& mergedPredicates() const { return m_me rgedPredicates; }
69 85
70 private: 86 private:
71 Kind m_kind; 87 Kind m_kind;
72 AtomicString m_data; 88 AtomicString m_data;
73 AtomicString m_namespaceURI; 89 AtomicString m_namespaceURI;
74 90
75 // When possible, we merge some or all predicates with node test for bet ter performance. 91 // When possible, we merge some or all predicates with node test for bet ter performance.
76 Vector<Predicate*> m_mergedPredicates; 92 Vector<OwnPtr<Predicate> > m_mergedPredicates;
77 }; 93 };
78 94
79 Step(Axis, const NodeTest&, const Vector<Predicate*>& predicates = Vector<Pr edicate*>()); 95 Step(Axis, const NodeTest&);
96 Step(Axis, const NodeTest&, Vector<OwnPtr<Predicate> >&);
80 ~Step(); 97 ~Step();
81 98
82 void optimize(); 99 void optimize();
83 100
84 void evaluate(Node* context, NodeSet&) const; 101 void evaluate(Node* context, NodeSet&) const;
85 102
86 Axis axis() const { return m_axis; } 103 Axis axis() const { return m_axis; }
87 const NodeTest& nodeTest() const { return m_nodeTest; } 104 const NodeTest& nodeTest() const { return m_nodeTest; }
88 105
89 private: 106 private:
90 friend void optimizeStepPair(Step*, Step*, bool&); 107 friend void optimizeStepPair(Step*, Step*, bool&);
91 bool predicatesAreContextListInsensitive() const; 108 bool predicatesAreContextListInsensitive() const;
92 109
93 void parseNodeTest(const String&); 110 void parseNodeTest(const String&);
94 void nodesInAxis(Node* context, NodeSet&) const; 111 void nodesInAxis(Node* context, NodeSet&) const;
95 String namespaceFromNodetest(const String& nodeTest) const; 112 String namespaceFromNodetest(const String& nodeTest) const;
96 113
97 Axis m_axis; 114 Axis m_axis;
98 NodeTest m_nodeTest; 115 NodeTest m_nodeTest;
99 Vector<Predicate*> m_predicates; 116 Vector<OwnPtr<Predicate> > m_predicates;
100 }; 117 };
101 118
102 void optimizeStepPair(Step*, Step*, bool& dropSecondStep); 119 void optimizeStepPair(Step*, Step*, bool& dropSecondStep);
103 120
104 } // namespace XPath 121 } // namespace XPath
105 122
106 } // namespace WebCore 123 } // namespace WebCore
107 124
108 #endif // XPathStep_h 125 #endif // XPathStep_h
OLDNEW
« no previous file with comments | « Source/core/xml/XPathPath.cpp ('k') | Source/core/xml/XPathStep.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698