2006-05-15 Anders Carlsson <acarlsson@apple.com>
authorandersca <andersca@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 15 May 2006 18:17:37 +0000 (18:17 +0000)
committerandersca <andersca@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 15 May 2006 18:17:37 +0000 (18:17 +0000)
        Reviewed by Eric.

        Remove the XPath log calls. They were causing leaks and were never
        really useful.

        * bridge/mac/WebCorePageBridge.mm:
        (initializeLoggingChannelsIfNecessary):
        * platform/Logging.cpp:
        * platform/Logging.h:
        * xpath/XPathResult.cpp:
        (WebCore::XPathResult::convertTo):
        * xpath/impl/XPathFunctions.cpp:
        (round):
        (WebCore::XPath::FunCount::doEvaluate):
        (WebCore::XPath::FunSum::doEvaluate):
        (WebCore::XPath::FunctionLibrary::createFunction):
        * xpath/impl/XPathPath.cpp:
        (WebCore::XPath::Filter::doEvaluate):
        (WebCore::XPath::LocationPath::doEvaluate):
        * xpath/impl/XPathPredicate.cpp:
        (WebCore::XPath::Negative::doEvaluate):
        (WebCore::XPath::NumericOp::doEvaluate):
        (WebCore::XPath::Union::doEvaluate):
        * xpath/impl/XPathStep.cpp:
        (WebCore::XPath::Step::evaluate):
        (WebCore::XPath::Step::nodesInAxis):
        (WebCore::XPath::Step::nodeTestMatches):
        * xpath/impl/XPathValue.cpp:
        (WebCore::XPath::Value::toNodeVector):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@14378 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/bridge/mac/WebCorePageBridge.mm
WebCore/platform/Logging.cpp
WebCore/platform/Logging.h
WebCore/xpath/XPathResult.cpp
WebCore/xpath/impl/XPathFunctions.cpp
WebCore/xpath/impl/XPathPath.cpp
WebCore/xpath/impl/XPathPredicate.cpp
WebCore/xpath/impl/XPathStep.cpp
WebCore/xpath/impl/XPathValue.cpp

index 8d8d073..bf429d1 100644 (file)
@@ -1,3 +1,35 @@
+2006-05-15  Anders Carlsson  <acarlsson@apple.com>
+
+        Reviewed by Eric.
+
+        Remove the XPath log calls. They were causing leaks and were never
+        really useful.
+        
+        * bridge/mac/WebCorePageBridge.mm:
+        (initializeLoggingChannelsIfNecessary):
+        * platform/Logging.cpp:
+        * platform/Logging.h:
+        * xpath/XPathResult.cpp:
+        (WebCore::XPathResult::convertTo):
+        * xpath/impl/XPathFunctions.cpp:
+        (round):
+        (WebCore::XPath::FunCount::doEvaluate):
+        (WebCore::XPath::FunSum::doEvaluate):
+        (WebCore::XPath::FunctionLibrary::createFunction):
+        * xpath/impl/XPathPath.cpp:
+        (WebCore::XPath::Filter::doEvaluate):
+        (WebCore::XPath::LocationPath::doEvaluate):
+        * xpath/impl/XPathPredicate.cpp:
+        (WebCore::XPath::Negative::doEvaluate):
+        (WebCore::XPath::NumericOp::doEvaluate):
+        (WebCore::XPath::Union::doEvaluate):
+        * xpath/impl/XPathStep.cpp:
+        (WebCore::XPath::Step::evaluate):
+        (WebCore::XPath::Step::nodesInAxis):
+        (WebCore::XPath::Step::nodeTestMatches):
+        * xpath/impl/XPathValue.cpp:
+        (WebCore::XPath::Value::toNodeVector):
+
 2006-05-15  Eric Seidel  <eseidel@apple.com>
 
         Fix linux build.
index 1a2a88d..444d7dc 100644 (file)
@@ -62,7 +62,6 @@ static void initializeLoggingChannelsIfNecessary()
     initializeLogChannel(LogEvents);
     initializeLogChannel(LogEditing);
     initializeLogChannel(LogTextConversion);
-    initializeLogChannel(LogXPath);
 }
 
 - (id)init
index 77ff95f..c816324 100644 (file)
@@ -36,4 +36,3 @@ WTFLogChannel LogPopupBlocking =     { 0x00000040, "WebCoreLogLevel", WTFLogChan
 WTFLogChannel LogEvents =            { 0x00000080, "WebCoreLogLevel", WTFLogChannelOff };
 WTFLogChannel LogEditing =           { 0x00000100, "WebCoreLogLevel", WTFLogChannelOff };
 WTFLogChannel LogTextConversion =    { 0x00000200, "WebCoreLogLevel", WTFLogChannelOff };
-WTFLogChannel LogXPath =             { 0x00000400, "WebCoreLogLevel", WTFLogChannelOff };
index d3cb4a6..4fec22a 100644 (file)
@@ -40,6 +40,5 @@ extern WTFLogChannel LogPopupBlocking;
 extern WTFLogChannel LogEvents;
 extern WTFLogChannel LogEditing;
 extern WTFLogChannel LogTextConversion;
-extern WTFLogChannel LogXPath;
 
 #endif
index 3417874..ce06193 100644 (file)
@@ -111,8 +111,6 @@ void XPathResult::convertTo(unsigned short type, ExceptionCode& ec)
                 return;
             }
             m_resultType = type;
-        default:
-            LOG(XPath, "Cannot convert XPathResult to unknown type '%u'!", type);
     }
 }
 
index 912730c..73b1538 100644 (file)
 #include "XPathFunctions.h"
 
 #include "DeprecatedString.h"
-#include "Logging.h"
 #include "NamedAttrMap.h"
 #include "Node.h"
 #include "XPathValue.h"
 #include <math.h>
 
 #ifdef _MSC_VER // No round() in standard C library for Visual Studio
-static double round(double val)\r
-{\r
-    double valFloor = floor(val);\r
-    if (val >= 0)\r
-        return (val - valFloor < 0.5) ? valFloor : (valFloor+1.0);\r
-    else\r
-        return (val - valFloor <= 0.5) ? valFloor : (valFloor+1.0);\r
-}\r
-#endif\r
+static double round(double val)
+{
+    double valFloor = floor(val);
+    if (val >= 0)
+        return (val - valFloor < 0.5) ? valFloor : (valFloor+1.0);
+    else
+        return (val - valFloor <= 0.5) ? valFloor : (valFloor+1.0);
+}
+#endif
 
 namespace WebCore {
 namespace XPath {
@@ -463,11 +462,8 @@ Value FunCount::doEvaluate() const
 {
     Value a = arg(0)->evaluate();
     
-    if (!a.isNodeVector()) {
-        LOG(XPath, "count() expects <nodevector>");
-
+    if (!a.isNodeVector())
         return 0.0;
-    }
     
     return a.toNodeVector().size();
 }
@@ -686,10 +682,8 @@ Value FunNumber::doEvaluate() const
 Value FunSum::doEvaluate() const
 {
     Value a = arg(0)->evaluate();
-    if (!a.isNodeVector()) {
-        LOG(XPath, "sum() expects <nodevector>");
+    if (!a.isNodeVector())
         return 0.0;
-    }
 
     double sum = 0.0;
     NodeVector nodes = a.toNodeVector();
@@ -781,8 +775,6 @@ FunctionLibrary::FunctionLibrary()
 Function *FunctionLibrary::createFunction(const char *name, const Vector<Expression*> &args) const
 {
     if (!m_functionDict.contains(name)) {
-        LOG(XPath, "Function '%s' not supported by this implementation.", name);
-        
         // Return a dummy function instead of 0.
         Function *funcTrue = m_functionDict.get("true").factoryFn();
         funcTrue->setName("true");
@@ -790,10 +782,8 @@ Function *FunctionLibrary::createFunction(const char *name, const Vector<Express
     }
 
     FunctionRec functionRec = m_functionDict.get(name);
-    if (!functionRec.args.contains(args.size())) {
-        LOG(XPath, "Function '%s' requires %d arguments, but %d given.", name, functionRec.args.asString().ascii(), args.size());
+    if (!functionRec.args.contains(args.size()))
         return 0;
-    }
 
     Function *function = functionRec.factoryFn();
     function->setArguments(args);
index 1469077..6d8a9b4 100644 (file)
@@ -31,7 +31,6 @@
 #include "XPathPath.h"
 
 #include "Document.h"
-#include "Logging.h"
 #include "Node.h"
 #include "XPathValue.h"
 
@@ -53,12 +52,8 @@ Value Filter::doEvaluate() const
 {
     Value v = m_expr->evaluate();
     
-    if (!v.isNodeVector()) {
-        if (!m_predicates.isEmpty())
-            LOG(XPath, "Ignoring predicates for filter since expression does not evaluate to a nodevector!");
-
+    if (!v.isNodeVector()) 
         return v;
-    }
 
     NodeVector inNodes = v.toNodeVector(), outNodes;
     for (unsigned i = 0; i < m_predicates.size(); i++) {
@@ -99,12 +94,6 @@ void LocationPath::optimize()
 
 Value LocationPath::doEvaluate() const
 {
-    if (m_absolute) {
-        LOG(XPath, "Evaluating absolute path expression with %i location steps.", m_steps.size());
-    } else {
-        LOG(XPath, "Evaluating relative path expression with %i location steps.", m_steps.size());
-    }
-
     NodeVector inDomNodes, outDomNodes;
 
     /* For absolute location paths, the context node is ignored - the
index 5346dbb..3ff4748 100644 (file)
@@ -30,7 +30,6 @@
 
 #include "XPathPredicate.h"
 
-#include "Logging.h"
 #include "Node.h"
 #include "XPathFunctions.h"
 #include "XPathValue.h"
@@ -76,10 +75,8 @@ Value StringExpression::doEvaluate() const
 Value Negative::doEvaluate() const
 {
     Value p(subExpr(0)->evaluate());
-    if (!p.isNumber()) {
-        LOG(XPath, "Unary minus is undefined for non-numeric types.");
+    if (!p.isNumber())
         return Value();
-    }
     return -p.toNumber();
 }
 
@@ -95,10 +92,8 @@ Value NumericOp::doEvaluate() const
     Value lhs(subExpr(0)->evaluate());
     Value rhs(subExpr(1)->evaluate());
     
-    if (!lhs.isNumber() || !rhs.isNumber()) {
-        LOG(XPath, "Cannot perform operation on non-numeric types.");
+    if (!lhs.isNumber() || !rhs.isNumber())
         return Value();
-    }
 
     double leftVal = lhs.toNumber(), rightVal = rhs.toNumber();
 
@@ -191,10 +186,8 @@ Value Union::doEvaluate() const
 {
     Value lhs = subExpr(0)->evaluate();
     Value rhs = subExpr(1)->evaluate();
-    if (!lhs.isNodeVector() || !rhs.isNodeVector()) {
-        LOG(XPath, "Union operator '|' works only with nodevectors.");
+    if (!lhs.isNodeVector() || !rhs.isNodeVector())
         return NodeVector();
-    }
     
     NodeVector lhsNodes = lhs.toNodeVector();
     NodeVector rhsNodes = rhs.toNodeVector();
index 05c8d15..345dae1 100644 (file)
@@ -29,7 +29,6 @@
 
 #include "XPathStep.h"
 
-#include "Logging.h"
 #include "Document.h"
 #include "NamedAttrMap.h"
 #include "Node.h"
@@ -77,22 +76,8 @@ Step::~Step()
 
 NodeVector Step::evaluate(Node* context) const
 {
-    LOG(XPath, "Evaluating step, axis='%s', nodetest='%s', %u predicates",
-            axisAsString(m_axis).ascii(), m_nodeTest.ascii(), m_predicates.size());
-    if (context->nodeType() == Node::ELEMENT_NODE)
-        LOG(XPath, "Context node is an element called %s", context->nodeName().ascii());
-    else if (context->nodeType() == Node::ATTRIBUTE_NODE)
-        LOG(XPath, "Context node is an attribute called %s with value %s", 
-               context->nodeName().ascii(), 
-               context->nodeValue().ascii());
-    else
-        LOG(XPath, "Context node is of unknown type %d", context->nodeType());
-
     NodeVector inNodes = nodesInAxis(context), outNodes;
-    LOG(XPath, "Axis %s matches %d nodes.", axisAsString(m_axis).ascii(), inNodes.size());
-
     inNodes = nodeTestMatches(inNodes);
-    LOG(XPath, "Nodetest %s trims this number to %d", m_nodeTest.ascii(), inNodes.size());
     
     outNodes = inNodes;
     for (unsigned i = 0; i < m_predicates.size(); i++) {
@@ -113,8 +98,6 @@ NodeVector Step::evaluate(Node* context) const
             ++Expression::evaluationContext().position;
         }
 
-        LOG(XPath, "\tPredicate trims this number to %d", outNodes.size());
-
         inNodes = outNodes;
     }
     return outNodes;
@@ -178,10 +161,8 @@ NodeVector Step::nodesInAxis(Node* context) const
                 return NodeVector();
 
             NamedAttrMap* attrs = context->attributes();
-            if (!attrs) {
-                LOG(XPath, "Node::attributes() returned NULL!");
+            if (!attrs)
                 return nodes;
-            }
 
             for (unsigned long i = 0; i < attrs->length(); ++i) 
                 nodes.append (attrs->item(i));
@@ -194,11 +175,8 @@ NodeVector Step::nodesInAxis(Node* context) const
             bool foundXmlNsNode = false;
             for (Node* node = context; node; node = node->parentNode()) {
                 NamedAttrMap* attrs = node->attributes();
-                if (!attrs) {
-                    LOG(XPath, "Node::attributes() returned NULL!");
-
+                if (!attrs)
                     continue;
-                }
 
                 for (unsigned long i = 0; i < attrs->length(); ++i) {
                     Node* n = attrs->item(i).get();
@@ -313,8 +291,7 @@ NodeVector Step::nodeTestMatches(const NodeVector& nodes) const
 
             return matches;
         } else if (m_axis == NamespaceAxis) {
-            LOG(XPath, "Node test %s on axis %s is not implemented yet.",
-                m_nodeTest.ascii(), axisAsString(m_axis).ascii());
+            // Node test on the namespace axis is not implemented yet
         } else {
             for (unsigned i = 0; i < nodes.size(); i++) {
                 Node* node = nodes[i].get();
@@ -330,9 +307,6 @@ NodeVector Step::nodeTestMatches(const NodeVector& nodes) const
             return matches;
         }
     }
-    
-    LOG(XPath, "Node test %s on axis %s is not implemented yet.",
-        m_nodeTest.ascii(), axisAsString(m_axis).ascii());
 
     return matches;
 }
index 276836b..a584e84 100644 (file)
@@ -31,7 +31,6 @@
 #include "XPathValue.h"
 
 #include "DeprecatedString.h"
-#include "Logging.h"
 
 #ifdef _MSC_VER // math functions missing from Microsoft Visual Studio standard C library
 #include <xmath.h>
@@ -86,8 +85,6 @@ Value::Value(const String& value)
 
 const NodeVector &Value::toNodeVector() const
 {
-    if (m_type != NodeVector_)
-        LOG(XPath, "Cannot convert anything to a nodevector.");    
     return m_nodeVector;    
 }