OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. |
6 * Copyright (C) 2007 Trolltech ASA | 6 * Copyright (C) 2007 Trolltech ASA |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "CSSStyleSelector.h" | 32 #include "CSSStyleSelector.h" |
33 #include "CSSStyleSheet.h" | 33 #include "CSSStyleSheet.h" |
34 #include "CString.h" | 34 #include "CString.h" |
35 #include "ChildNodeList.h" | 35 #include "ChildNodeList.h" |
36 #include "ClassNodeList.h" | 36 #include "ClassNodeList.h" |
37 #include "DOMImplementation.h" | 37 #include "DOMImplementation.h" |
38 #include "Document.h" | 38 #include "Document.h" |
39 #include "DynamicNodeList.h" | 39 #include "DynamicNodeList.h" |
40 #include "Element.h" | 40 #include "Element.h" |
41 #include "ExceptionCode.h" | 41 #include "ExceptionCode.h" |
| 42 #include "ExceptionContext.h" |
42 #include "Frame.h" | 43 #include "Frame.h" |
43 #include "HTMLNames.h" | 44 #include "HTMLNames.h" |
44 #include "Logging.h" | 45 #include "Logging.h" |
45 #include "NSResolver.h" | 46 #include "NSResolver.h" |
46 #include "NameNodeList.h" | 47 #include "NameNodeList.h" |
47 #include "NamedAttrMap.h" | 48 #include "NamedAttrMap.h" |
48 #include "ProcessingInstruction.h" | 49 #include "ProcessingInstruction.h" |
49 #include "RenderObject.h" | 50 #include "RenderObject.h" |
50 #include "ScriptController.h" | 51 #include "ScriptController.h" |
51 #include "SelectorNodeList.h" | 52 #include "SelectorNodeList.h" |
52 #include "StringBuilder.h" | 53 #include "StringBuilder.h" |
53 #include "TagNodeList.h" | 54 #include "TagNodeList.h" |
54 #include "Text.h" | 55 #include "Text.h" |
55 #include "XMLNames.h" | 56 #include "XMLNames.h" |
56 #include "htmlediting.h" | 57 #include "htmlediting.h" |
57 #include <wtf/RefCountedLeakCounter.h> | 58 #include <wtf/RefCountedLeakCounter.h> |
58 | 59 |
59 #if USE(JSC) | 60 #if USE(JSC) |
60 #include "JSDOMBinding.h" | |
61 #include <kjs/ExecState.h> | |
62 #include <kjs/JSLock.h> | 61 #include <kjs/JSLock.h> |
63 #endif | 62 #endif |
64 | 63 |
65 namespace WebCore { | 64 namespace WebCore { |
66 | 65 |
67 using namespace HTMLNames; | 66 using namespace HTMLNames; |
68 | 67 |
69 struct NodeListsNodeData { | 68 struct NodeListsNodeData { |
70 typedef HashSet<DynamicNodeList*> NodeListSet; | 69 typedef HashSet<DynamicNodeList*> NodeListSet; |
71 NodeListSet m_listsWithCaches; | 70 NodeListSet m_listsWithCaches; |
(...skipping 1192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1264 bool operator()(CSSSelector* selector) | 1263 bool operator()(CSSSelector* selector) |
1265 { | 1264 { |
1266 if (selector->hasTag() && selector->m_tag.prefix() != nullAtom && select
or->m_tag.prefix() != starAtom) | 1265 if (selector->hasTag() && selector->m_tag.prefix() != nullAtom && select
or->m_tag.prefix() != starAtom) |
1267 return true; | 1266 return true; |
1268 if (selector->hasAttribute() && selector->m_attr.prefix() != nullAtom &&
selector->m_attr.prefix() != starAtom) | 1267 if (selector->hasAttribute() && selector->m_attr.prefix() != nullAtom &&
selector->m_attr.prefix() != starAtom) |
1269 return true; | 1268 return true; |
1270 return false; | 1269 return false; |
1271 } | 1270 } |
1272 }; | 1271 }; |
1273 | 1272 |
1274 #if USE(JSC) | |
1275 class ResolveNamespaceFunctor { | 1273 class ResolveNamespaceFunctor { |
1276 public: | 1274 public: |
1277 ResolveNamespaceFunctor(NSResolver* resolver, ExceptionCode& ec, KJS::ExecSt
ate* exec) | 1275 ResolveNamespaceFunctor(NSResolver* resolver, ExceptionCode& ec, ExceptionCo
ntext* exec) |
1278 : m_resolver(resolver) | 1276 : m_resolver(resolver) |
1279 , m_exceptionCode(ec) | 1277 , m_exceptionCode(ec) |
1280 , m_exec(exec) | 1278 , m_exec(exec) |
1281 { | 1279 { |
1282 } | 1280 } |
1283 | 1281 |
1284 bool operator()(CSSSelector* selector) | 1282 bool operator()(CSSSelector* selector) |
1285 { | 1283 { |
1286 if (selector->hasTag() && selector->m_tag.prefix() != nullAtom && select
or->m_tag.prefix() != starAtom) { | 1284 if (selector->hasTag() && selector->m_tag.prefix() != nullAtom && select
or->m_tag.prefix() != starAtom) { |
1287 String resolvedNamespaceURI = m_resolver->lookupNamespaceURI(m_exec,
selector->m_tag.prefix()); | 1285 String resolvedNamespaceURI = m_resolver->lookupNamespaceURI(m_exec,
selector->m_tag.prefix()); |
(...skipping 17 matching lines...) Expand all Loading... |
1305 QualifiedName newQualifiedName(selector->m_attr.prefix(), selector->
m_attr.localName(), resolvedNamespaceURI); | 1303 QualifiedName newQualifiedName(selector->m_attr.prefix(), selector->
m_attr.localName(), resolvedNamespaceURI); |
1306 selector->m_attr = newQualifiedName; | 1304 selector->m_attr = newQualifiedName; |
1307 } | 1305 } |
1308 | 1306 |
1309 return false; | 1307 return false; |
1310 } | 1308 } |
1311 | 1309 |
1312 private: | 1310 private: |
1313 NSResolver* m_resolver; | 1311 NSResolver* m_resolver; |
1314 ExceptionCode& m_exceptionCode; | 1312 ExceptionCode& m_exceptionCode; |
1315 KJS::ExecState* m_exec; | 1313 ExceptionContext* m_exec; |
1316 }; | 1314 }; |
1317 | 1315 |
1318 static bool selectorNeedsNamespaceResolution(CSSSelector* currentSelector) | 1316 static bool selectorNeedsNamespaceResolution(CSSSelector* currentSelector) |
1319 { | 1317 { |
1320 SelectorNeedsNamespaceResolutionFunctor functor; | 1318 SelectorNeedsNamespaceResolutionFunctor functor; |
1321 return forEachSelector(functor, currentSelector); | 1319 return forEachSelector(functor, currentSelector); |
1322 } | 1320 } |
1323 | 1321 |
1324 static bool resolveNamespacesForSelector(CSSSelector* currentSelector, NSResolve
r* resolver, ExceptionCode& ec, KJS::ExecState* exec) | 1322 static bool resolveNamespacesForSelector(CSSSelector* currentSelector, NSResolve
r* resolver, ExceptionCode& ec, ExceptionContext* exec) |
1325 { | 1323 { |
1326 ResolveNamespaceFunctor functor(resolver, ec, exec); | 1324 ResolveNamespaceFunctor functor(resolver, ec, exec); |
1327 return forEachSelector(functor, currentSelector); | 1325 return forEachSelector(functor, currentSelector); |
1328 } | 1326 } |
1329 | 1327 |
1330 PassRefPtr<Element> Node::querySelector(const String& selectors, ExceptionCode&
ec) | 1328 PassRefPtr<Element> Node::querySelector(const String& selectors, ExceptionCode&
ec) |
1331 { | 1329 { |
1332 return querySelector(selectors, 0, ec, execStateFromNode(this)); | 1330 return querySelector(selectors, 0, ec, ExceptionContext::createFromNode(this
)); |
1333 } | 1331 } |
1334 | 1332 |
1335 PassRefPtr<NodeList> Node::querySelectorAll(const String& selectors, ExceptionCo
de& ec) | 1333 PassRefPtr<NodeList> Node::querySelectorAll(const String& selectors, ExceptionCo
de& ec) |
1336 { | 1334 { |
1337 return querySelectorAll(selectors, 0, ec, execStateFromNode(this)); | 1335 return querySelectorAll(selectors, 0, ec, ExceptionContext::createFromNode(t
his)); |
1338 } | 1336 } |
1339 | 1337 |
1340 PassRefPtr<Element> Node::querySelector(const String& selectors, NSResolver* res
olver, ExceptionCode& ec, KJS::ExecState* exec) | 1338 PassRefPtr<Element> Node::querySelector(const String& selectors, NSResolver* res
olver, ExceptionCode& ec, ExceptionContext* exec) |
1341 { | 1339 { |
1342 if (selectors.isEmpty()) { | 1340 if (selectors.isEmpty()) { |
1343 ec = SYNTAX_ERR; | 1341 ec = SYNTAX_ERR; |
1344 return 0; | 1342 return 0; |
1345 } | 1343 } |
1346 bool strictParsing = !document()->inCompatMode(); | 1344 bool strictParsing = !document()->inCompatMode(); |
1347 CSSParser p(strictParsing); | 1345 CSSParser p(strictParsing); |
1348 if (resolver) { | 1346 if (resolver) { |
1349 String defaultNamespace = resolver->lookupNamespaceURI(exec, String()); | 1347 String defaultNamespace = resolver->lookupNamespaceURI(exec, String()); |
1350 if (exec && exec->hadException()) | 1348 if (exec && exec->hadException()) |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1390 for (CSSSelector* selector = querySelector.get(); selector; selector
= selector->next()) { | 1388 for (CSSSelector* selector = querySelector.get(); selector; selector
= selector->next()) { |
1391 if (selectorChecker.checkSelector(selector, element)) | 1389 if (selectorChecker.checkSelector(selector, element)) |
1392 return element; | 1390 return element; |
1393 } | 1391 } |
1394 } | 1392 } |
1395 } | 1393 } |
1396 | 1394 |
1397 return 0; | 1395 return 0; |
1398 } | 1396 } |
1399 | 1397 |
1400 PassRefPtr<NodeList> Node::querySelectorAll(const String& selectors, NSResolver*
resolver, ExceptionCode& ec, KJS::ExecState* exec) | 1398 PassRefPtr<NodeList> Node::querySelectorAll(const String& selectors, NSResolver*
resolver, ExceptionCode& ec, ExceptionContext* exec) |
1401 { | 1399 { |
1402 if (selectors.isEmpty()) { | 1400 if (selectors.isEmpty()) { |
1403 ec = SYNTAX_ERR; | 1401 ec = SYNTAX_ERR; |
1404 return 0; | 1402 return 0; |
1405 } | 1403 } |
1406 bool strictParsing = !document()->inCompatMode(); | 1404 bool strictParsing = !document()->inCompatMode(); |
1407 CSSParser p(strictParsing); | 1405 CSSParser p(strictParsing); |
1408 if (resolver) { | 1406 if (resolver) { |
1409 String defaultNamespace = resolver->lookupNamespaceURI(exec, String()); | 1407 String defaultNamespace = resolver->lookupNamespaceURI(exec, String()); |
1410 if (exec && exec->hadException()) | 1408 if (exec && exec->hadException()) |
(...skipping 16 matching lines...) Expand all Loading... |
1427 // No NSResolver was passed, so throw a NAMESPACE_ERR if the selector in
cludes any | 1425 // No NSResolver was passed, so throw a NAMESPACE_ERR if the selector in
cludes any |
1428 // namespace prefixes. | 1426 // namespace prefixes. |
1429 if (selectorNeedsNamespaceResolution(querySelector.get())) { | 1427 if (selectorNeedsNamespaceResolution(querySelector.get())) { |
1430 ec = NAMESPACE_ERR; | 1428 ec = NAMESPACE_ERR; |
1431 return 0; | 1429 return 0; |
1432 } | 1430 } |
1433 } | 1431 } |
1434 | 1432 |
1435 return createSelectorNodeList(this, querySelector.get()); | 1433 return createSelectorNodeList(this, querySelector.get()); |
1436 } | 1434 } |
1437 #endif // USE(JSC) | |
1438 | 1435 |
1439 Document *Node::ownerDocument() const | 1436 Document *Node::ownerDocument() const |
1440 { | 1437 { |
1441 Document *doc = document(); | 1438 Document *doc = document(); |
1442 return doc == this ? 0 : doc; | 1439 return doc == this ? 0 : doc; |
1443 } | 1440 } |
1444 | 1441 |
1445 bool Node::hasAttributes() const | 1442 bool Node::hasAttributes() const |
1446 { | 1443 { |
1447 return false; | 1444 return false; |
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2004 | 2001 |
2005 #ifndef NDEBUG | 2002 #ifndef NDEBUG |
2006 | 2003 |
2007 void showTree(const WebCore::Node* node) | 2004 void showTree(const WebCore::Node* node) |
2008 { | 2005 { |
2009 if (node) | 2006 if (node) |
2010 node->showTreeForThis(); | 2007 node->showTreeForThis(); |
2011 } | 2008 } |
2012 | 2009 |
2013 #endif | 2010 #endif |
OLD | NEW |