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

Side by Side Diff: Source/core/xml/XPathFunctions.cpp

Issue 26763004: Vector stores Expression object as OwnPtr instead of raw pointer in XPath. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Change XPathGrammar.y also 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
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 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 283
284 if (m_min == Inf) 284 if (m_min == Inf)
285 return value <= m_max; 285 return value <= m_max;
286 286
287 if (m_max == Inf) 287 if (m_max == Inf)
288 return value >= m_min; 288 return value >= m_min;
289 289
290 return value >= m_min && value <= m_max; 290 return value >= m_min && value <= m_max;
291 } 291 }
292 292
293 void Function::setArguments(const Vector<Expression*>& args) 293 void Function::setArguments(Vector<OwnPtr<Expression> >& args)
294 { 294 {
295 ASSERT(!subExprCount()); 295 ASSERT(!subExprCount());
296 296
297 // Some functions use context node as implicit argument, so when explicit ar guments are added, they may no longer be context node sensitive. 297 // Some functions use context node as implicit argument, so when explicit ar guments are added, they may no longer be context node sensitive.
298 if (m_name != "lang" && !args.isEmpty()) 298 if (m_name != "lang" && !args.isEmpty())
299 setIsContextNodeSensitive(false); 299 setIsContextNodeSensitive(false);
300 300
301 Vector<Expression*>::const_iterator end = args.end(); 301 Vector<OwnPtr<Expression> >::iterator end = args.end();
302 for (Vector<Expression*>::const_iterator it = args.begin(); it != end; it++) 302 for (Vector<OwnPtr<Expression> >::iterator it = args.begin(); it != end; it+ +)
303 addSubExpression(*it); 303 addSubExpression(it->release());
304 } 304 }
305 305
306 Value FunLast::evaluate() const 306 Value FunLast::evaluate() const
307 { 307 {
308 return Expression::evaluationContext().size; 308 return Expression::evaluationContext().size;
309 } 309 }
310 310
311 Value FunPosition::evaluate() const 311 Value FunPosition::evaluate() const
312 { 312 {
313 return Expression::evaluationContext().position; 313 return Expression::evaluationContext().position;
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 { "sum", { &createFunSum, 1 } }, 705 { "sum", { &createFunSum, 1 } },
706 { "translate", { &createFunTranslate, 3 } }, 706 { "translate", { &createFunTranslate, 3 } },
707 { "true", { &createFunTrue, 0 } }, 707 { "true", { &createFunTrue, 0 } },
708 }; 708 };
709 709
710 functionMap = new HashMap<String, FunctionRec>; 710 functionMap = new HashMap<String, FunctionRec>;
711 for (size_t i = 0; i < WTF_ARRAY_LENGTH(functions); ++i) 711 for (size_t i = 0; i < WTF_ARRAY_LENGTH(functions); ++i)
712 functionMap->set(functions[i].name, functions[i].function); 712 functionMap->set(functions[i].name, functions[i].function);
713 } 713 }
714 714
715 Function* createFunction(const String& name, const Vector<Expression*>& args) 715
716 Function* createFunction(const String& name)
717 {
718 Vector<OwnPtr<Expression> > args;
719 return createFunction(name, args);
720 }
721
722 Function* createFunction(const String& name, Vector<OwnPtr<Expression> >& args)
716 { 723 {
717 if (!functionMap) 724 if (!functionMap)
718 createFunctionMap(); 725 createFunctionMap();
719 726
720 HashMap<String, FunctionRec>::iterator functionMapIter = functionMap->find(n ame); 727 HashMap<String, FunctionRec>::iterator functionMapIter = functionMap->find(n ame);
721 FunctionRec* functionRec = 0; 728 FunctionRec* functionRec = 0;
722 729
723 if (functionMapIter == functionMap->end() || !(functionRec = &functionMapIte r->value)->args.contains(args.size())) 730 if (functionMapIter == functionMap->end() || !(functionRec = &functionMapIte r->value)->args.contains(args.size()))
724 return 0; 731 return 0;
725 732
726 Function* function = functionRec->factoryFn(); 733 Function* function = functionRec->factoryFn();
727 function->setArguments(args); 734 function->setArguments(args);
728 function->setName(name); 735 function->setName(name);
729 return function; 736 return function;
730 } 737 }
731 738
732 } 739 }
733 } 740 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698