| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2000 Harri Porten (porten@kde.org) | 2 * Copyright (C) 2000 Harri Porten (porten@kde.org) |
| 3 * Copyright (C) 2001 Peter Kelly (pmk@post.com) | 3 * Copyright (C) 2001 Peter Kelly (pmk@post.com) |
| 4 * Copyright (C) 2004-2006 Apple Computer, Inc. | 4 * Copyright (C) 2004-2006 Apple Computer, Inc. |
| 5 * Copyright (C) 2006 James G. Speth (speth@end.com) | 5 * Copyright (C) 2006 James G. Speth (speth@end.com) |
| 6 * Copyright (C) 2006 Samuel Weinig (sam@webkit.org) | 6 * Copyright (C) 2006 Samuel Weinig (sam@webkit.org) |
| 7 * Copyright 2007, 2008 Google Inc. All Rights Reserved. | 7 * Copyright 2007, 2008 Google Inc. All Rights Reserved. |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Lesser General Public | 10 * modify it under the terms of the GNU Lesser General Public |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 } | 251 } |
| 252 | 252 |
| 253 if (Document* doc = frame->document()) | 253 if (Document* doc = frame->document()) |
| 254 doc->updateRendering(); | 254 doc->updateRendering(); |
| 255 | 255 |
| 256 proxy->setTimerCallback(false); | 256 proxy->setTimerCallback(false); |
| 257 } | 257 } |
| 258 | 258 |
| 259 | 259 |
| 260 CALLBACK_FUNC_DECL(DOMParserConstructor) { | 260 CALLBACK_FUNC_DECL(DOMParserConstructor) { |
| 261 INC_STATS(L"DOM.DOMParser.Contructor"); | 261 INC_STATS("DOM.DOMParser.Contructor"); |
| 262 return V8Proxy::ConstructDOMObject<V8ClassIndex::DOMPARSER, | 262 return V8Proxy::ConstructDOMObject<V8ClassIndex::DOMPARSER, |
| 263 DOMParser>(args); | 263 DOMParser>(args); |
| 264 } | 264 } |
| 265 | 265 |
| 266 CALLBACK_FUNC_DECL(MessageChannelConstructor) { | 266 CALLBACK_FUNC_DECL(MessageChannelConstructor) { |
| 267 INC_STATS(L"DOM.MessageChannel.Constructor"); | 267 INC_STATS("DOM.MessageChannel.Constructor"); |
| 268 if (!args.IsConstructCall()) { | 268 if (!args.IsConstructCall()) { |
| 269 V8Proxy::ThrowError(V8Proxy::TYPE_ERROR, | 269 V8Proxy::ThrowError(V8Proxy::TYPE_ERROR, |
| 270 "DOM object constructor cannot be called as a function."); | 270 "DOM object constructor cannot be called as a function."); |
| 271 return v8::Undefined(); | 271 return v8::Undefined(); |
| 272 } | 272 } |
| 273 | 273 |
| 274 // Get the document. | 274 // Get the document. |
| 275 Frame* frame = V8Proxy::retrieveFrame(); | 275 Frame* frame = V8Proxy::retrieveFrame(); |
| 276 if (!frame) | 276 if (!frame) |
| 277 return v8::Undefined(); | 277 return v8::Undefined(); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 303 wrapper_object->SetInternalField(kMessageChannelPort1Index, port1_wrapper); | 303 wrapper_object->SetInternalField(kMessageChannelPort1Index, port1_wrapper); |
| 304 wrapper_object->SetInternalField(kMessageChannelPort2Index, port2_wrapper); | 304 wrapper_object->SetInternalField(kMessageChannelPort2Index, port2_wrapper); |
| 305 | 305 |
| 306 // Return the wrapper object which will be the result of the call to | 306 // Return the wrapper object which will be the result of the call to |
| 307 // new. | 307 // new. |
| 308 return wrapper_object; | 308 return wrapper_object; |
| 309 } | 309 } |
| 310 | 310 |
| 311 | 311 |
| 312 CALLBACK_FUNC_DECL(XMLSerializerConstructor) { | 312 CALLBACK_FUNC_DECL(XMLSerializerConstructor) { |
| 313 INC_STATS(L"DOM.XMLSerializer.Constructor"); | 313 INC_STATS("DOM.XMLSerializer.Constructor"); |
| 314 return V8Proxy::ConstructDOMObject<V8ClassIndex::XMLSERIALIZER, | 314 return V8Proxy::ConstructDOMObject<V8ClassIndex::XMLSERIALIZER, |
| 315 XMLSerializer>(args); | 315 XMLSerializer>(args); |
| 316 } | 316 } |
| 317 | 317 |
| 318 | 318 |
| 319 CALLBACK_FUNC_DECL(XPathEvaluatorConstructor) { | 319 CALLBACK_FUNC_DECL(XPathEvaluatorConstructor) { |
| 320 INC_STATS(L"DOM.XPathEvaluator.Constructor"); | 320 INC_STATS("DOM.XPathEvaluator.Constructor"); |
| 321 return V8Proxy::ConstructDOMObject<V8ClassIndex::XPATHEVALUATOR, | 321 return V8Proxy::ConstructDOMObject<V8ClassIndex::XPATHEVALUATOR, |
| 322 XPathEvaluator>(args); | 322 XPathEvaluator>(args); |
| 323 } | 323 } |
| 324 | 324 |
| 325 | 325 |
| 326 CALLBACK_FUNC_DECL(XSLTProcessorConstructor) { | 326 CALLBACK_FUNC_DECL(XSLTProcessorConstructor) { |
| 327 INC_STATS(L"DOM.XSLTProcessor.Constructor"); | 327 INC_STATS("DOM.XSLTProcessor.Constructor"); |
| 328 return V8Proxy::ConstructDOMObject<V8ClassIndex::XSLTPROCESSOR, | 328 return V8Proxy::ConstructDOMObject<V8ClassIndex::XSLTPROCESSOR, |
| 329 XSLTProcessor>(args); | 329 XSLTProcessor>(args); |
| 330 } | 330 } |
| 331 | 331 |
| 332 | 332 |
| 333 CALLBACK_FUNC_DECL(XSLTProcessorImportStylesheet) { | 333 CALLBACK_FUNC_DECL(XSLTProcessorImportStylesheet) { |
| 334 INC_STATS(L"DOM.XSLTProcessor.importStylesheet"); | 334 INC_STATS("DOM.XSLTProcessor.importStylesheet"); |
| 335 // Return undefined if argument does not have the correct type. | 335 // Return undefined if argument does not have the correct type. |
| 336 if (!V8Node::HasInstance(args[0])) | 336 if (!V8Node::HasInstance(args[0])) |
| 337 return v8::Undefined(); | 337 return v8::Undefined(); |
| 338 | 338 |
| 339 XSLTProcessor* imp = V8Proxy::ToNativeObject<XSLTProcessor>( | 339 XSLTProcessor* imp = V8Proxy::ToNativeObject<XSLTProcessor>( |
| 340 V8ClassIndex::XSLTPROCESSOR, args.Holder()); | 340 V8ClassIndex::XSLTPROCESSOR, args.Holder()); |
| 341 | 341 |
| 342 Node* node = V8Proxy::DOMWrapperToNode<Node>(args[0]); | 342 Node* node = V8Proxy::DOMWrapperToNode<Node>(args[0]); |
| 343 imp->importStylesheet(node); | 343 imp->importStylesheet(node); |
| 344 return v8::Undefined(); | 344 return v8::Undefined(); |
| 345 } | 345 } |
| 346 | 346 |
| 347 | 347 |
| 348 CALLBACK_FUNC_DECL(XSLTProcessorTransformToFragment) { | 348 CALLBACK_FUNC_DECL(XSLTProcessorTransformToFragment) { |
| 349 INC_STATS(L"DOM.XSLTProcessor.transformToFragment"); | 349 INC_STATS("DOM.XSLTProcessor.transformToFragment"); |
| 350 // Return undefined if arguments do not have correct types. | 350 // Return undefined if arguments do not have correct types. |
| 351 if (!V8Node::HasInstance(args[0]) || !V8Document::HasInstance(args[1])) | 351 if (!V8Node::HasInstance(args[0]) || !V8Document::HasInstance(args[1])) |
| 352 return v8::Undefined(); | 352 return v8::Undefined(); |
| 353 | 353 |
| 354 XSLTProcessor* imp = V8Proxy::ToNativeObject<XSLTProcessor>( | 354 XSLTProcessor* imp = V8Proxy::ToNativeObject<XSLTProcessor>( |
| 355 V8ClassIndex::XSLTPROCESSOR, args.Holder()); | 355 V8ClassIndex::XSLTPROCESSOR, args.Holder()); |
| 356 | 356 |
| 357 Node* source = V8Proxy::DOMWrapperToNode<Node>(args[0]); | 357 Node* source = V8Proxy::DOMWrapperToNode<Node>(args[0]); |
| 358 Document* owner = | 358 Document* owner = |
| 359 V8Proxy::DOMWrapperToNode<Document>(args[1]); | 359 V8Proxy::DOMWrapperToNode<Document>(args[1]); |
| 360 RefPtr<DocumentFragment> result = imp->transformToFragment(source, owner); | 360 RefPtr<DocumentFragment> result = imp->transformToFragment(source, owner); |
| 361 return V8Proxy::NodeToV8Object(result.get()); | 361 return V8Proxy::NodeToV8Object(result.get()); |
| 362 } | 362 } |
| 363 | 363 |
| 364 | 364 |
| 365 CALLBACK_FUNC_DECL(XSLTProcessorTransformToDocument) { | 365 CALLBACK_FUNC_DECL(XSLTProcessorTransformToDocument) { |
| 366 INC_STATS(L"DOM.XSLTProcessor.transformToDocument"); | 366 INC_STATS("DOM.XSLTProcessor.transformToDocument"); |
| 367 // Return undefined if argument does not have the correct type. | 367 // Return undefined if argument does not have the correct type. |
| 368 if (!V8Node::HasInstance(args[0])) | 368 if (!V8Node::HasInstance(args[0])) |
| 369 return v8::Undefined(); | 369 return v8::Undefined(); |
| 370 | 370 |
| 371 XSLTProcessor* imp = V8Proxy::ToNativeObject<XSLTProcessor>( | 371 XSLTProcessor* imp = V8Proxy::ToNativeObject<XSLTProcessor>( |
| 372 V8ClassIndex::XSLTPROCESSOR, args.Holder()); | 372 V8ClassIndex::XSLTPROCESSOR, args.Holder()); |
| 373 | 373 |
| 374 Node* source = V8Proxy::DOMWrapperToNode<Node>(args[0]); | 374 Node* source = V8Proxy::DOMWrapperToNode<Node>(args[0]); |
| 375 if (!source) | 375 if (!source) |
| 376 return v8::Undefined(); | 376 return v8::Undefined(); |
| 377 RefPtr<Document> result = imp->transformToDocument(source); | 377 RefPtr<Document> result = imp->transformToDocument(source); |
| 378 // Return undefined if no result was found. | 378 // Return undefined if no result was found. |
| 379 if (!result) | 379 if (!result) |
| 380 return v8::Undefined(); | 380 return v8::Undefined(); |
| 381 return V8Proxy::NodeToV8Object(result.get()); | 381 return V8Proxy::NodeToV8Object(result.get()); |
| 382 } | 382 } |
| 383 | 383 |
| 384 | 384 |
| 385 CALLBACK_FUNC_DECL(XSLTProcessorSetParameter) { | 385 CALLBACK_FUNC_DECL(XSLTProcessorSetParameter) { |
| 386 INC_STATS(L"DOM.XSLTProcessor.setParameter"); | 386 INC_STATS("DOM.XSLTProcessor.setParameter"); |
| 387 // Bail out if localName or value is null or undefined. | 387 // Bail out if localName or value is null or undefined. |
| 388 if (args[1]->IsNull() || args[1]->IsUndefined() || | 388 if (args[1]->IsNull() || args[1]->IsUndefined() || |
| 389 args[2]->IsNull() || args[2]->IsUndefined()) { | 389 args[2]->IsNull() || args[2]->IsUndefined()) { |
| 390 return v8::Undefined(); | 390 return v8::Undefined(); |
| 391 } | 391 } |
| 392 | 392 |
| 393 XSLTProcessor* imp = V8Proxy::ToNativeObject<XSLTProcessor>( | 393 XSLTProcessor* imp = V8Proxy::ToNativeObject<XSLTProcessor>( |
| 394 V8ClassIndex::XSLTPROCESSOR, args.Holder()); | 394 V8ClassIndex::XSLTPROCESSOR, args.Holder()); |
| 395 | 395 |
| 396 String namespaceURI = ToWebCoreString(args[0]); | 396 String namespaceURI = ToWebCoreString(args[0]); |
| 397 String localName = ToWebCoreString(args[1]); | 397 String localName = ToWebCoreString(args[1]); |
| 398 String value = ToWebCoreString(args[2]); | 398 String value = ToWebCoreString(args[2]); |
| 399 imp->setParameter(namespaceURI, localName, value); | 399 imp->setParameter(namespaceURI, localName, value); |
| 400 return v8::Undefined(); | 400 return v8::Undefined(); |
| 401 } | 401 } |
| 402 | 402 |
| 403 | 403 |
| 404 CALLBACK_FUNC_DECL(XSLTProcessorGetParameter) { | 404 CALLBACK_FUNC_DECL(XSLTProcessorGetParameter) { |
| 405 INC_STATS(L"DOM.XSLTProcessor.getParameter"); | 405 INC_STATS("DOM.XSLTProcessor.getParameter"); |
| 406 // Bail out if localName is null or undefined. | 406 // Bail out if localName is null or undefined. |
| 407 if (args[1]->IsNull() || args[1]->IsUndefined()) { | 407 if (args[1]->IsNull() || args[1]->IsUndefined()) { |
| 408 return v8::Undefined(); | 408 return v8::Undefined(); |
| 409 } | 409 } |
| 410 | 410 |
| 411 XSLTProcessor* imp = V8Proxy::ToNativeObject<XSLTProcessor>( | 411 XSLTProcessor* imp = V8Proxy::ToNativeObject<XSLTProcessor>( |
| 412 V8ClassIndex::XSLTPROCESSOR, args.Holder()); | 412 V8ClassIndex::XSLTPROCESSOR, args.Holder()); |
| 413 | 413 |
| 414 String namespaceURI = ToWebCoreString(args[0]); | 414 String namespaceURI = ToWebCoreString(args[0]); |
| 415 String localName = ToWebCoreString(args[1]); | 415 String localName = ToWebCoreString(args[1]); |
| 416 String result = imp->getParameter(namespaceURI, localName); | 416 String result = imp->getParameter(namespaceURI, localName); |
| 417 // Return undefined if the string is null. | 417 // Return undefined if the string is null. |
| 418 if (result.isNull()) return v8::Undefined(); | 418 if (result.isNull()) return v8::Undefined(); |
| 419 return v8String(result); | 419 return v8String(result); |
| 420 } | 420 } |
| 421 | 421 |
| 422 | 422 |
| 423 CALLBACK_FUNC_DECL(XSLTProcessorRemoveParameter) { | 423 CALLBACK_FUNC_DECL(XSLTProcessorRemoveParameter) { |
| 424 INC_STATS(L"DOM.XSLTProcessor.removeParameter"); | 424 INC_STATS("DOM.XSLTProcessor.removeParameter"); |
| 425 // Bail out if localName is null or undefined. | 425 // Bail out if localName is null or undefined. |
| 426 if (args[1]->IsNull() || args[1]->IsUndefined()) | 426 if (args[1]->IsNull() || args[1]->IsUndefined()) |
| 427 return v8::Undefined(); | 427 return v8::Undefined(); |
| 428 | 428 |
| 429 XSLTProcessor* imp = V8Proxy::ToNativeObject<XSLTProcessor>( | 429 XSLTProcessor* imp = V8Proxy::ToNativeObject<XSLTProcessor>( |
| 430 V8ClassIndex::XSLTPROCESSOR, args.Holder()); | 430 V8ClassIndex::XSLTPROCESSOR, args.Holder()); |
| 431 | 431 |
| 432 String namespaceURI = ToWebCoreString(args[0]); | 432 String namespaceURI = ToWebCoreString(args[0]); |
| 433 String localName = ToWebCoreString(args[1]); | 433 String localName = ToWebCoreString(args[1]); |
| 434 imp->removeParameter(namespaceURI, localName); | 434 imp->removeParameter(namespaceURI, localName); |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 else | 658 else |
| 659 return result; | 659 return result; |
| 660 } | 660 } |
| 661 unsigned i = index->Uint32Value(); | 661 unsigned i = index->Uint32Value(); |
| 662 RefPtr<Node> result = collection->item(i); | 662 RefPtr<Node> result = collection->item(i); |
| 663 return V8Proxy::NodeToV8Object(result.get()); | 663 return V8Proxy::NodeToV8Object(result.get()); |
| 664 } | 664 } |
| 665 | 665 |
| 666 | 666 |
| 667 NAMED_PROPERTY_GETTER(HTMLCollection) { | 667 NAMED_PROPERTY_GETTER(HTMLCollection) { |
| 668 INC_STATS(L"DOM.HTMLCollection.NamedPropertyGetter"); | 668 INC_STATS("DOM.HTMLCollection.NamedPropertyGetter"); |
| 669 // Search the prototype chain first. | 669 // Search the prototype chain first. |
| 670 v8::Handle<v8::Value> value = | 670 v8::Handle<v8::Value> value = |
| 671 info.Holder()->GetRealNamedPropertyInPrototypeChain(name); | 671 info.Holder()->GetRealNamedPropertyInPrototypeChain(name); |
| 672 | 672 |
| 673 if (!value.IsEmpty()) { | 673 if (!value.IsEmpty()) { |
| 674 return value; | 674 return value; |
| 675 } | 675 } |
| 676 | 676 |
| 677 // Search local callback properties next to find IDL defined | 677 // Search local callback properties next to find IDL defined |
| 678 // properties. | 678 // properties. |
| 679 if (info.Holder()->HasRealNamedCallbackProperty(name)) { | 679 if (info.Holder()->HasRealNamedCallbackProperty(name)) { |
| 680 return v8::Handle<v8::Value>(); | 680 return v8::Handle<v8::Value>(); |
| 681 } | 681 } |
| 682 | 682 |
| 683 // Finally, search the DOM structure. | 683 // Finally, search the DOM structure. |
| 684 HTMLCollection* imp = V8Proxy::ToNativeObject<HTMLCollection>( | 684 HTMLCollection* imp = V8Proxy::ToNativeObject<HTMLCollection>( |
| 685 V8ClassIndex::HTMLCOLLECTION, info.Holder()); | 685 V8ClassIndex::HTMLCOLLECTION, info.Holder()); |
| 686 String key = ToWebCoreString(name); | 686 String key = ToWebCoreString(name); |
| 687 return HTMLCollectionGetNamedItems(imp, key); | 687 return HTMLCollectionGetNamedItems(imp, key); |
| 688 } | 688 } |
| 689 | 689 |
| 690 INDEXED_PROPERTY_GETTER(CanvasPixelArray) { | 690 INDEXED_PROPERTY_GETTER(CanvasPixelArray) { |
| 691 INC_STATS(L"DOM.CanvasPixelArray.IndexedPropertyGetter"); | 691 INC_STATS("DOM.CanvasPixelArray.IndexedPropertyGetter"); |
| 692 CanvasPixelArray* pixelArray = | 692 CanvasPixelArray* pixelArray = |
| 693 V8Proxy::ToNativeObject<CanvasPixelArray>(V8ClassIndex::CANVASPIXELARRAY, | 693 V8Proxy::ToNativeObject<CanvasPixelArray>(V8ClassIndex::CANVASPIXELARRAY, |
| 694 info.Holder()); | 694 info.Holder()); |
| 695 | 695 |
| 696 // TODO(eroman): This performance will not be good when looping through | 696 // TODO(eroman): This performance will not be good when looping through |
| 697 // many pixels. See: http://code.google.com/p/chromium/issues/detail?id=3473 | 697 // many pixels. See: http://code.google.com/p/chromium/issues/detail?id=3473 |
| 698 | 698 |
| 699 unsigned char result; | 699 unsigned char result; |
| 700 if (!pixelArray->get(index, result)) | 700 if (!pixelArray->get(index, result)) |
| 701 return v8::Undefined(); | 701 return v8::Undefined(); |
| 702 return v8::Number::New(result); | 702 return v8::Number::New(result); |
| 703 } | 703 } |
| 704 | 704 |
| 705 INDEXED_PROPERTY_SETTER(CanvasPixelArray) { | 705 INDEXED_PROPERTY_SETTER(CanvasPixelArray) { |
| 706 INC_STATS(L"DOM.CanvasPixelArray.IndexedPropertySetter"); | 706 INC_STATS("DOM.CanvasPixelArray.IndexedPropertySetter"); |
| 707 CanvasPixelArray* pixelArray = | 707 CanvasPixelArray* pixelArray = |
| 708 V8Proxy::ToNativeObject<CanvasPixelArray>(V8ClassIndex::CANVASPIXELARRAY, | 708 V8Proxy::ToNativeObject<CanvasPixelArray>(V8ClassIndex::CANVASPIXELARRAY, |
| 709 info.Holder()); | 709 info.Holder()); |
| 710 | 710 |
| 711 double pixelValue = value->NumberValue(); | 711 double pixelValue = value->NumberValue(); |
| 712 pixelArray->set(index, pixelValue); | 712 pixelArray->set(index, pixelValue); |
| 713 | 713 |
| 714 // TODO(eroman): what to return? | 714 // TODO(eroman): what to return? |
| 715 return v8::Undefined(); | 715 return v8::Undefined(); |
| 716 } | 716 } |
| 717 | 717 |
| 718 CALLBACK_FUNC_DECL(HTMLCollectionItem) { | 718 CALLBACK_FUNC_DECL(HTMLCollectionItem) { |
| 719 INC_STATS(L"DOM.HTMLCollection.item()"); | 719 INC_STATS("DOM.HTMLCollection.item()"); |
| 720 HTMLCollection* imp = V8Proxy::ToNativeObject<HTMLCollection>( | 720 HTMLCollection* imp = V8Proxy::ToNativeObject<HTMLCollection>( |
| 721 V8ClassIndex::HTMLCOLLECTION, args.Holder()); | 721 V8ClassIndex::HTMLCOLLECTION, args.Holder()); |
| 722 return HTMLCollectionGetItem(imp, args[0]); | 722 return HTMLCollectionGetItem(imp, args[0]); |
| 723 } | 723 } |
| 724 | 724 |
| 725 | 725 |
| 726 CALLBACK_FUNC_DECL(HTMLCollectionNamedItem) { | 726 CALLBACK_FUNC_DECL(HTMLCollectionNamedItem) { |
| 727 INC_STATS(L"DOM.HTMLCollection.namedItem()"); | 727 INC_STATS("DOM.HTMLCollection.namedItem()"); |
| 728 HTMLCollection* imp = V8Proxy::ToNativeObject<HTMLCollection>( | 728 HTMLCollection* imp = V8Proxy::ToNativeObject<HTMLCollection>( |
| 729 V8ClassIndex::HTMLCOLLECTION, args.Holder()); | 729 V8ClassIndex::HTMLCOLLECTION, args.Holder()); |
| 730 String name = ToWebCoreString(args[0]); | 730 String name = ToWebCoreString(args[0]); |
| 731 v8::Handle<v8::Value> result = | 731 v8::Handle<v8::Value> result = |
| 732 HTMLCollectionGetNamedItems(imp, name); | 732 HTMLCollectionGetNamedItems(imp, name); |
| 733 if (result.IsEmpty()) | 733 if (result.IsEmpty()) |
| 734 return v8::Undefined(); | 734 return v8::Undefined(); |
| 735 else | 735 else |
| 736 return result; | 736 return result; |
| 737 } | 737 } |
| 738 | 738 |
| 739 | 739 |
| 740 CALLBACK_FUNC_DECL(HTMLCollectionCallAsFunction) { | 740 CALLBACK_FUNC_DECL(HTMLCollectionCallAsFunction) { |
| 741 INC_STATS(L"DOM.HTMLCollection.callAsFunction()"); | 741 INC_STATS("DOM.HTMLCollection.callAsFunction()"); |
| 742 if (args.Length() < 1) return v8::Undefined(); | 742 if (args.Length() < 1) return v8::Undefined(); |
| 743 | 743 |
| 744 HTMLCollection* imp = V8Proxy::ToNativeObject<HTMLCollection>( | 744 HTMLCollection* imp = V8Proxy::ToNativeObject<HTMLCollection>( |
| 745 V8ClassIndex::HTMLCOLLECTION, args.Holder()); | 745 V8ClassIndex::HTMLCOLLECTION, args.Holder()); |
| 746 | 746 |
| 747 if (args.Length() == 1) { | 747 if (args.Length() == 1) { |
| 748 return HTMLCollectionGetItem(imp, args[0]); | 748 return HTMLCollectionGetItem(imp, args[0]); |
| 749 } | 749 } |
| 750 | 750 |
| 751 // If there is a second argument it is the index of the item we | 751 // If there is a second argument it is the index of the item we |
| (...skipping 20 matching lines...) Expand all Loading... |
| 772 V8Proxy::DOMWrapperToNode<HTMLOptionElement>(args[0]); | 772 V8Proxy::DOMWrapperToNode<HTMLOptionElement>(args[0]); |
| 773 imp->remove(element->index()); | 773 imp->remove(element->index()); |
| 774 return v8::Undefined(); | 774 return v8::Undefined(); |
| 775 } | 775 } |
| 776 | 776 |
| 777 imp->remove(ToInt32(args[0])); | 777 imp->remove(ToInt32(args[0])); |
| 778 return v8::Undefined(); | 778 return v8::Undefined(); |
| 779 } | 779 } |
| 780 | 780 |
| 781 CALLBACK_FUNC_DECL(HTMLSelectElementRemove) { | 781 CALLBACK_FUNC_DECL(HTMLSelectElementRemove) { |
| 782 INC_STATS(L"DOM.HTMLSelectElement.remove"); | 782 INC_STATS("DOM.HTMLSelectElement.remove"); |
| 783 HTMLSelectElement* imp = | 783 HTMLSelectElement* imp = |
| 784 V8Proxy::DOMWrapperToNode<HTMLSelectElement>(args.Holder()); | 784 V8Proxy::DOMWrapperToNode<HTMLSelectElement>(args.Holder()); |
| 785 return V8HTMLSelectElementRemoveHelper(imp, args); | 785 return V8HTMLSelectElementRemoveHelper(imp, args); |
| 786 } | 786 } |
| 787 | 787 |
| 788 CALLBACK_FUNC_DECL(HTMLOptionsCollectionRemove) { | 788 CALLBACK_FUNC_DECL(HTMLOptionsCollectionRemove) { |
| 789 INC_STATS(L"DOM.HTMLOptionsCollection.remove()"); | 789 INC_STATS("DOM.HTMLOptionsCollection.remove()"); |
| 790 HTMLOptionsCollection* imp = | 790 HTMLOptionsCollection* imp = |
| 791 V8Proxy::ToNativeObject<HTMLOptionsCollection>( | 791 V8Proxy::ToNativeObject<HTMLOptionsCollection>( |
| 792 V8ClassIndex::HTMLOPTIONSCOLLECTION, args.Holder()); | 792 V8ClassIndex::HTMLOPTIONSCOLLECTION, args.Holder()); |
| 793 HTMLSelectElement* base = static_cast<HTMLSelectElement*>(imp->base()); | 793 HTMLSelectElement* base = static_cast<HTMLSelectElement*>(imp->base()); |
| 794 return V8HTMLSelectElementRemoveHelper(base, args); | 794 return V8HTMLSelectElementRemoveHelper(base, args); |
| 795 } | 795 } |
| 796 | 796 |
| 797 | 797 |
| 798 CALLBACK_FUNC_DECL(HTMLOptionsCollectionAdd) { | 798 CALLBACK_FUNC_DECL(HTMLOptionsCollectionAdd) { |
| 799 INC_STATS(L"DOM.HTMLOptionsCollection.add()"); | 799 INC_STATS("DOM.HTMLOptionsCollection.add()"); |
| 800 if (!V8HTMLOptionElement::HasInstance(args[0])) { | 800 if (!V8HTMLOptionElement::HasInstance(args[0])) { |
| 801 V8Proxy::SetDOMException(TYPE_MISMATCH_ERR); | 801 V8Proxy::SetDOMException(TYPE_MISMATCH_ERR); |
| 802 return v8::Undefined(); | 802 return v8::Undefined(); |
| 803 } | 803 } |
| 804 HTMLOptionsCollection* imp = | 804 HTMLOptionsCollection* imp = |
| 805 V8Proxy::ToNativeObject<HTMLOptionsCollection>( | 805 V8Proxy::ToNativeObject<HTMLOptionsCollection>( |
| 806 V8ClassIndex::HTMLOPTIONSCOLLECTION, args.Holder()); | 806 V8ClassIndex::HTMLOPTIONSCOLLECTION, args.Holder()); |
| 807 HTMLOptionElement* option = | 807 HTMLOptionElement* option = |
| 808 V8Proxy::DOMWrapperToNode<HTMLOptionElement>(args[0]); | 808 V8Proxy::DOMWrapperToNode<HTMLOptionElement>(args[0]); |
| 809 | 809 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 824 } | 824 } |
| 825 } | 825 } |
| 826 if (ec != 0) { | 826 if (ec != 0) { |
| 827 V8Proxy::SetDOMException(ec); | 827 V8Proxy::SetDOMException(ec); |
| 828 } | 828 } |
| 829 return v8::Undefined(); | 829 return v8::Undefined(); |
| 830 } | 830 } |
| 831 | 831 |
| 832 | 832 |
| 833 CALLBACK_FUNC_DECL(DOMWindowAddEventListener) { | 833 CALLBACK_FUNC_DECL(DOMWindowAddEventListener) { |
| 834 INC_STATS(L"DOM.DOMWindow.addEventListener()"); | 834 INC_STATS("DOM.DOMWindow.addEventListener()"); |
| 835 DOMWindow* imp = V8Proxy::ToNativeObject<DOMWindow>( | 835 DOMWindow* imp = V8Proxy::ToNativeObject<DOMWindow>( |
| 836 V8ClassIndex::DOMWINDOW, args.Holder()); | 836 V8ClassIndex::DOMWINDOW, args.Holder()); |
| 837 | 837 |
| 838 if (!V8Proxy::CanAccessFrame(imp->frame(), true)) | 838 if (!V8Proxy::CanAccessFrame(imp->frame(), true)) |
| 839 return v8::Undefined(); | 839 return v8::Undefined(); |
| 840 | 840 |
| 841 if (!imp->frame()) | 841 if (!imp->frame()) |
| 842 return v8::Undefined(); // DOMWindow could be disconnected from the frame | 842 return v8::Undefined(); // DOMWindow could be disconnected from the frame |
| 843 | 843 |
| 844 Document* doc = imp->frame()->document(); | 844 Document* doc = imp->frame()->document(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 857 String event_type = ToWebCoreString(args[0]); | 857 String event_type = ToWebCoreString(args[0]); |
| 858 bool useCapture = args[2]->BooleanValue(); | 858 bool useCapture = args[2]->BooleanValue(); |
| 859 doc->addWindowEventListener(event_type, listener, useCapture); | 859 doc->addWindowEventListener(event_type, listener, useCapture); |
| 860 } | 860 } |
| 861 | 861 |
| 862 return v8::Undefined(); | 862 return v8::Undefined(); |
| 863 } | 863 } |
| 864 | 864 |
| 865 | 865 |
| 866 CALLBACK_FUNC_DECL(DOMWindowRemoveEventListener) { | 866 CALLBACK_FUNC_DECL(DOMWindowRemoveEventListener) { |
| 867 INC_STATS(L"DOM.DOMWindow.removeEventListener()"); | 867 INC_STATS("DOM.DOMWindow.removeEventListener()"); |
| 868 DOMWindow* imp = V8Proxy::ToNativeObject<DOMWindow>( | 868 DOMWindow* imp = V8Proxy::ToNativeObject<DOMWindow>( |
| 869 V8ClassIndex::DOMWINDOW, args.Holder()); | 869 V8ClassIndex::DOMWINDOW, args.Holder()); |
| 870 | 870 |
| 871 if (!V8Proxy::CanAccessFrame(imp->frame(), true)) | 871 if (!V8Proxy::CanAccessFrame(imp->frame(), true)) |
| 872 return v8::Undefined(); | 872 return v8::Undefined(); |
| 873 | 873 |
| 874 if (!imp->frame()) | 874 if (!imp->frame()) |
| 875 return v8::Undefined(); | 875 return v8::Undefined(); |
| 876 | 876 |
| 877 Document* doc = imp->frame()->document(); | 877 Document* doc = imp->frame()->document(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 888 if (listener) { | 888 if (listener) { |
| 889 String event_type = ToWebCoreString(args[0]); | 889 String event_type = ToWebCoreString(args[0]); |
| 890 bool useCapture = args[2]->BooleanValue(); | 890 bool useCapture = args[2]->BooleanValue(); |
| 891 doc->removeWindowEventListener(event_type, listener.get(), useCapture); | 891 doc->removeWindowEventListener(event_type, listener.get(), useCapture); |
| 892 } | 892 } |
| 893 | 893 |
| 894 return v8::Undefined(); | 894 return v8::Undefined(); |
| 895 } | 895 } |
| 896 | 896 |
| 897 CALLBACK_FUNC_DECL(DOMWindowPostMessage) { | 897 CALLBACK_FUNC_DECL(DOMWindowPostMessage) { |
| 898 INC_STATS(L"DOM.DOMWindow.postMessage()"); | 898 INC_STATS("DOM.DOMWindow.postMessage()"); |
| 899 DOMWindow* window = V8Proxy::ToNativeObject<DOMWindow>( | 899 DOMWindow* window = V8Proxy::ToNativeObject<DOMWindow>( |
| 900 V8ClassIndex::DOMWINDOW, args.Holder()); | 900 V8ClassIndex::DOMWINDOW, args.Holder()); |
| 901 | 901 |
| 902 DOMWindow* source = V8Proxy::retrieveActiveFrame()->domWindow(); | 902 DOMWindow* source = V8Proxy::retrieveActiveFrame()->domWindow(); |
| 903 ASSERT(source->frame()); | 903 ASSERT(source->frame()); |
| 904 | 904 |
| 905 String uri = source->frame()->loader()->url().string(); | 905 String uri = source->frame()->loader()->url().string(); |
| 906 | 906 |
| 907 v8::TryCatch try_catch; | 907 v8::TryCatch try_catch; |
| 908 | 908 |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1044 false, | 1044 false, |
| 1045 user_gesture); | 1045 user_gesture); |
| 1046 } | 1046 } |
| 1047 } | 1047 } |
| 1048 | 1048 |
| 1049 return new_frame; | 1049 return new_frame; |
| 1050 } | 1050 } |
| 1051 | 1051 |
| 1052 | 1052 |
| 1053 CALLBACK_FUNC_DECL(DOMWindowShowModalDialog) { | 1053 CALLBACK_FUNC_DECL(DOMWindowShowModalDialog) { |
| 1054 INC_STATS(L"DOM.DOMWindow.showModalDialog()"); | 1054 INC_STATS("DOM.DOMWindow.showModalDialog()"); |
| 1055 DOMWindow* window = V8Proxy::ToNativeObject<DOMWindow>( | 1055 DOMWindow* window = V8Proxy::ToNativeObject<DOMWindow>( |
| 1056 V8ClassIndex::DOMWINDOW, args.Holder()); | 1056 V8ClassIndex::DOMWINDOW, args.Holder()); |
| 1057 Frame* frame = window->frame(); | 1057 Frame* frame = window->frame(); |
| 1058 | 1058 |
| 1059 if (!frame || !V8Proxy::CanAccessFrame(frame, true)) | 1059 if (!frame || !V8Proxy::CanAccessFrame(frame, true)) |
| 1060 return v8::Undefined(); | 1060 return v8::Undefined(); |
| 1061 | 1061 |
| 1062 if (!canShowModalDialogNow(frame) || !allowPopUp()) | 1062 if (!canShowModalDialogNow(frame) || !allowPopUp()) |
| 1063 return v8::Undefined(); | 1063 return v8::Undefined(); |
| 1064 | 1064 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1134 | 1134 |
| 1135 if (!return_value.IsEmpty()) { | 1135 if (!return_value.IsEmpty()) { |
| 1136 return return_value; | 1136 return return_value; |
| 1137 } | 1137 } |
| 1138 | 1138 |
| 1139 return v8::Undefined(); | 1139 return v8::Undefined(); |
| 1140 } | 1140 } |
| 1141 | 1141 |
| 1142 | 1142 |
| 1143 CALLBACK_FUNC_DECL(DOMWindowOpen) { | 1143 CALLBACK_FUNC_DECL(DOMWindowOpen) { |
| 1144 INC_STATS(L"DOM.DOMWindow.open()"); | 1144 INC_STATS("DOM.DOMWindow.open()"); |
| 1145 DOMWindow* parent = V8Proxy::ToNativeObject<DOMWindow>( | 1145 DOMWindow* parent = V8Proxy::ToNativeObject<DOMWindow>( |
| 1146 V8ClassIndex::DOMWINDOW, args.Holder()); | 1146 V8ClassIndex::DOMWINDOW, args.Holder()); |
| 1147 Frame* frame = parent->frame(); | 1147 Frame* frame = parent->frame(); |
| 1148 | 1148 |
| 1149 if (!V8Proxy::CanAccessFrame(frame, true)) | 1149 if (!V8Proxy::CanAccessFrame(frame, true)) |
| 1150 return v8::Undefined(); | 1150 return v8::Undefined(); |
| 1151 | 1151 |
| 1152 Frame* active_frame = V8Proxy::retrieveActiveFrame(); | 1152 Frame* active_frame = V8Proxy::retrieveActiveFrame(); |
| 1153 if (!active_frame) | 1153 if (!active_frame) |
| 1154 return v8::Undefined(); | 1154 return v8::Undefined(); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1262 frame = createWindow(frame, url_string, frame_name, | 1262 frame = createWindow(frame, url_string, frame_name, |
| 1263 window_features, v8::Local<v8::Value>()); | 1263 window_features, v8::Local<v8::Value>()); |
| 1264 | 1264 |
| 1265 if (!frame) return v8::Undefined(); | 1265 if (!frame) return v8::Undefined(); |
| 1266 | 1266 |
| 1267 return V8Proxy::ToV8Object(V8ClassIndex::DOMWINDOW, frame->domWindow()); | 1267 return V8Proxy::ToV8Object(V8ClassIndex::DOMWINDOW, frame->domWindow()); |
| 1268 } | 1268 } |
| 1269 | 1269 |
| 1270 | 1270 |
| 1271 INDEXED_PROPERTY_GETTER(DOMWindow) { | 1271 INDEXED_PROPERTY_GETTER(DOMWindow) { |
| 1272 INC_STATS(L"DOM.DOMWindow.IndexedPropertyGetter"); | 1272 INC_STATS("DOM.DOMWindow.IndexedPropertyGetter"); |
| 1273 v8::Handle<v8::Object> holder = V8Proxy::LookupDOMWrapper( | 1273 v8::Handle<v8::Object> holder = V8Proxy::LookupDOMWrapper( |
| 1274 V8ClassIndex::DOMWINDOW, info.This()); | 1274 V8ClassIndex::DOMWINDOW, info.This()); |
| 1275 if (holder.IsEmpty()) | 1275 if (holder.IsEmpty()) |
| 1276 return v8::Handle<v8::Value>(); | 1276 return v8::Handle<v8::Value>(); |
| 1277 | 1277 |
| 1278 DOMWindow* window = V8Proxy::ToNativeObject<DOMWindow>( | 1278 DOMWindow* window = V8Proxy::ToNativeObject<DOMWindow>( |
| 1279 V8ClassIndex::DOMWINDOW, holder); | 1279 V8ClassIndex::DOMWINDOW, holder); |
| 1280 if (!window) | 1280 if (!window) |
| 1281 return v8::Handle<v8::Value>(); | 1281 return v8::Handle<v8::Value>(); |
| 1282 | 1282 |
| 1283 Frame* frame = window->frame(); | 1283 Frame* frame = window->frame(); |
| 1284 if (!frame) | 1284 if (!frame) |
| 1285 return v8::Handle<v8::Value>(); | 1285 return v8::Handle<v8::Value>(); |
| 1286 | 1286 |
| 1287 Frame* child = frame->tree()->child(index); | 1287 Frame* child = frame->tree()->child(index); |
| 1288 if (child) { | 1288 if (child) { |
| 1289 return V8Proxy::ToV8Object(V8ClassIndex::DOMWINDOW, child->domWindow()); | 1289 return V8Proxy::ToV8Object(V8ClassIndex::DOMWINDOW, child->domWindow()); |
| 1290 } | 1290 } |
| 1291 | 1291 |
| 1292 return v8::Handle<v8::Value>(); | 1292 return v8::Handle<v8::Value>(); |
| 1293 } | 1293 } |
| 1294 | 1294 |
| 1295 | 1295 |
| 1296 NAMED_PROPERTY_GETTER(DOMWindow) { | 1296 NAMED_PROPERTY_GETTER(DOMWindow) { |
| 1297 INC_STATS(L"DOM.DOMWindow.NamedPropertyGetter"); | 1297 INC_STATS("DOM.DOMWindow.NamedPropertyGetter"); |
| 1298 // The key must be a string. | 1298 // The key must be a string. |
| 1299 if (!name->IsString()) | 1299 if (!name->IsString()) |
| 1300 return v8::Handle<v8::Value>(); | 1300 return v8::Handle<v8::Value>(); |
| 1301 | 1301 |
| 1302 v8::Handle<v8::Object> holder = V8Proxy::LookupDOMWrapper( | 1302 v8::Handle<v8::Object> holder = V8Proxy::LookupDOMWrapper( |
| 1303 V8ClassIndex::DOMWINDOW, info.This()); | 1303 V8ClassIndex::DOMWINDOW, info.This()); |
| 1304 if (holder.IsEmpty()) | 1304 if (holder.IsEmpty()) |
| 1305 return v8::Handle<v8::Value>(); | 1305 return v8::Handle<v8::Value>(); |
| 1306 | 1306 |
| 1307 DOMWindow* window = V8Proxy::ToNativeObject<DOMWindow>( | 1307 DOMWindow* window = V8Proxy::ToNativeObject<DOMWindow>( |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1417 info.Holder()->GetInternalField(kHTMLDocumentMarkerIndex); | 1417 info.Holder()->GetInternalField(kHTMLDocumentMarkerIndex); |
| 1418 info.Holder()->SetInternalField(kHTMLDocumentShadowIndex, marker); | 1418 info.Holder()->SetInternalField(kHTMLDocumentShadowIndex, marker); |
| 1419 return v8::True(); | 1419 return v8::True(); |
| 1420 } | 1420 } |
| 1421 return v8::Handle<v8::Boolean>(); | 1421 return v8::Handle<v8::Boolean>(); |
| 1422 } | 1422 } |
| 1423 | 1423 |
| 1424 | 1424 |
| 1425 NAMED_PROPERTY_SETTER(HTMLDocument) | 1425 NAMED_PROPERTY_SETTER(HTMLDocument) |
| 1426 { | 1426 { |
| 1427 INC_STATS(L"DOM.HTMLDocument.NamedPropertySetter"); | 1427 INC_STATS("DOM.HTMLDocument.NamedPropertySetter"); |
| 1428 // Only handle document.all. We insert the value into the shadow | 1428 // Only handle document.all. We insert the value into the shadow |
| 1429 // internal field from which the getter will retrieve it. | 1429 // internal field from which the getter will retrieve it. |
| 1430 String key = ToWebCoreString(name); | 1430 String key = ToWebCoreString(name); |
| 1431 if (key == "all") { | 1431 if (key == "all") { |
| 1432 ASSERT(info.Holder()->InternalFieldCount() == | 1432 ASSERT(info.Holder()->InternalFieldCount() == |
| 1433 kHTMLDocumentInternalFieldCount); | 1433 kHTMLDocumentInternalFieldCount); |
| 1434 info.Holder()->SetInternalField(kHTMLDocumentShadowIndex, value); | 1434 info.Holder()->SetInternalField(kHTMLDocumentShadowIndex, value); |
| 1435 } | 1435 } |
| 1436 return v8::Handle<v8::Value>(); | 1436 return v8::Handle<v8::Value>(); |
| 1437 } | 1437 } |
| 1438 | 1438 |
| 1439 | 1439 |
| 1440 NAMED_PROPERTY_GETTER(HTMLDocument) | 1440 NAMED_PROPERTY_GETTER(HTMLDocument) |
| 1441 { | 1441 { |
| 1442 INC_STATS(L"DOM.HTMLDocument.NamedPropertyGetter"); | 1442 INC_STATS("DOM.HTMLDocument.NamedPropertyGetter"); |
| 1443 AtomicString key = ToWebCoreString(name); | 1443 AtomicString key = ToWebCoreString(name); |
| 1444 | 1444 |
| 1445 // Special case for document.all. If the value in the shadow | 1445 // Special case for document.all. If the value in the shadow |
| 1446 // internal field is not the marker object, then document.all has | 1446 // internal field is not the marker object, then document.all has |
| 1447 // been temporarily shadowed and we return the value. | 1447 // been temporarily shadowed and we return the value. |
| 1448 if (key == "all") { | 1448 if (key == "all") { |
| 1449 ASSERT(info.Holder()->InternalFieldCount() == kHTMLDocumentInternalField
Count); | 1449 ASSERT(info.Holder()->InternalFieldCount() == kHTMLDocumentInternalField
Count); |
| 1450 v8::Local<v8::Value> marker = info.Holder()->GetInternalField(kHTMLDocum
entMarkerIndex); | 1450 v8::Local<v8::Value> marker = info.Holder()->GetInternalField(kHTMLDocum
entMarkerIndex); |
| 1451 v8::Local<v8::Value> value = info.Holder()->GetInternalField(kHTMLDocume
ntShadowIndex); | 1451 v8::Local<v8::Value> value = info.Holder()->GetInternalField(kHTMLDocume
ntShadowIndex); |
| 1452 if (marker != value) | 1452 if (marker != value) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1469 return V8Proxy::ToV8Object(V8ClassIndex::DOMWINDOW, frame->domWindow
()); | 1469 return V8Proxy::ToV8Object(V8ClassIndex::DOMWINDOW, frame->domWindow
()); |
| 1470 return V8Proxy::NodeToV8Object(node); | 1470 return V8Proxy::NodeToV8Object(node); |
| 1471 } | 1471 } |
| 1472 return V8Proxy::ToV8Object(V8ClassIndex::HTMLCOLLECTION, | 1472 return V8Proxy::ToV8Object(V8ClassIndex::HTMLCOLLECTION, |
| 1473 static_cast<Peerable*>(items.get())); | 1473 static_cast<Peerable*>(items.get())); |
| 1474 } | 1474 } |
| 1475 | 1475 |
| 1476 | 1476 |
| 1477 NAMED_PROPERTY_GETTER(HTMLFrameSetElement) | 1477 NAMED_PROPERTY_GETTER(HTMLFrameSetElement) |
| 1478 { | 1478 { |
| 1479 INC_STATS(L"DOM.HTMLFrameSetElement.NamedPropertyGetter"); | 1479 INC_STATS("DOM.HTMLFrameSetElement.NamedPropertyGetter"); |
| 1480 HTMLFrameSetElement* imp = | 1480 HTMLFrameSetElement* imp = |
| 1481 V8Proxy::DOMWrapperToNode<HTMLFrameSetElement>(info.Holder()); | 1481 V8Proxy::DOMWrapperToNode<HTMLFrameSetElement>(info.Holder()); |
| 1482 String key = ToWebCoreString(name); | 1482 String key = ToWebCoreString(name); |
| 1483 Node* frame = imp->children()->namedItem(key); | 1483 Node* frame = imp->children()->namedItem(key); |
| 1484 if (frame && frame->hasTagName(HTMLNames::frameTag)) { | 1484 if (frame && frame->hasTagName(HTMLNames::frameTag)) { |
| 1485 Document* doc = static_cast<HTMLFrameElement*>(frame)->contentDocument(); | 1485 Document* doc = static_cast<HTMLFrameElement*>(frame)->contentDocument(); |
| 1486 if (doc) { | 1486 if (doc) { |
| 1487 Frame* content_frame = doc->frame(); | 1487 Frame* content_frame = doc->frame(); |
| 1488 if (content_frame) | 1488 if (content_frame) |
| 1489 return V8Proxy::ToV8Object(V8ClassIndex::DOMWINDOW, content_frame->domWi
ndow()); | 1489 return V8Proxy::ToV8Object(V8ClassIndex::DOMWINDOW, content_frame->domWi
ndow()); |
| 1490 } | 1490 } |
| 1491 return v8::Undefined(); | 1491 return v8::Undefined(); |
| 1492 } | 1492 } |
| 1493 return v8::Handle<v8::Value>(); | 1493 return v8::Handle<v8::Value>(); |
| 1494 } | 1494 } |
| 1495 | 1495 |
| 1496 | 1496 |
| 1497 NAMED_PROPERTY_GETTER(HTMLFormElement) { | 1497 NAMED_PROPERTY_GETTER(HTMLFormElement) { |
| 1498 INC_STATS(L"DOM.HTMLFormElement.NamedPropertyGetter"); | 1498 INC_STATS("DOM.HTMLFormElement.NamedPropertyGetter"); |
| 1499 HTMLFormElement* imp = | 1499 HTMLFormElement* imp = |
| 1500 V8Proxy::DOMWrapperToNode<HTMLFormElement>(info.Holder()); | 1500 V8Proxy::DOMWrapperToNode<HTMLFormElement>(info.Holder()); |
| 1501 String v = ToWebCoreString(name); | 1501 String v = ToWebCoreString(name); |
| 1502 | 1502 |
| 1503 // Call getNamedElements twice, first time check if it has a value | 1503 // Call getNamedElements twice, first time check if it has a value |
| 1504 // and let HTMLFormElement update its cache. | 1504 // and let HTMLFormElement update its cache. |
| 1505 // See issue: 867404 | 1505 // See issue: 867404 |
| 1506 { | 1506 { |
| 1507 Vector<RefPtr<Node> > elements; | 1507 Vector<RefPtr<Node> > elements; |
| 1508 imp->getNamedElements(v, elements); | 1508 imp->getNamedElements(v, elements); |
| 1509 if (elements.size() == 0) | 1509 if (elements.size() == 0) |
| 1510 return v8::Handle<v8::Value>(); | 1510 return v8::Handle<v8::Value>(); |
| 1511 } | 1511 } |
| 1512 // Second call may return different results from the first call, | 1512 // Second call may return different results from the first call, |
| 1513 // but if the first the size cannot be zero. | 1513 // but if the first the size cannot be zero. |
| 1514 Vector<RefPtr<Node> > elements; | 1514 Vector<RefPtr<Node> > elements; |
| 1515 imp->getNamedElements(v, elements); | 1515 imp->getNamedElements(v, elements); |
| 1516 ASSERT(elements.size() != 0); | 1516 ASSERT(elements.size() != 0); |
| 1517 if (elements.size() == 1) { | 1517 if (elements.size() == 1) { |
| 1518 return V8Proxy::NodeToV8Object(elements.at(0).get()); | 1518 return V8Proxy::NodeToV8Object(elements.at(0).get()); |
| 1519 } else { | 1519 } else { |
| 1520 NodeList* collection = new V8VectorNodeList(elements); | 1520 NodeList* collection = new V8VectorNodeList(elements); |
| 1521 return V8Proxy::ToV8Object(V8ClassIndex::NODELIST, | 1521 return V8Proxy::ToV8Object(V8ClassIndex::NODELIST, |
| 1522 static_cast<Peerable*>(collection)); | 1522 static_cast<Peerable*>(collection)); |
| 1523 } | 1523 } |
| 1524 } | 1524 } |
| 1525 | 1525 |
| 1526 | 1526 |
| 1527 INDEXED_PROPERTY_GETTER(NamedNodeMap) { | 1527 INDEXED_PROPERTY_GETTER(NamedNodeMap) { |
| 1528 INC_STATS(L"DOM.NamedNodeMap.IndexedPropertyGetter"); | 1528 INC_STATS("DOM.NamedNodeMap.IndexedPropertyGetter"); |
| 1529 NamedNodeMap* imp = V8Proxy::ToNativeObject<NamedNodeMap>( | 1529 NamedNodeMap* imp = V8Proxy::ToNativeObject<NamedNodeMap>( |
| 1530 V8ClassIndex::NAMEDNODEMAP, info.Holder()); | 1530 V8ClassIndex::NAMEDNODEMAP, info.Holder()); |
| 1531 RefPtr<Node> result = imp->item(index); | 1531 RefPtr<Node> result = imp->item(index); |
| 1532 if (!result) return v8::Handle<v8::Value>(); | 1532 if (!result) return v8::Handle<v8::Value>(); |
| 1533 | 1533 |
| 1534 return V8Proxy::NodeToV8Object(result.get()); | 1534 return V8Proxy::NodeToV8Object(result.get()); |
| 1535 } | 1535 } |
| 1536 | 1536 |
| 1537 NAMED_PROPERTY_GETTER(NamedNodeMap) { | 1537 NAMED_PROPERTY_GETTER(NamedNodeMap) { |
| 1538 INC_STATS(L"DOM.NamedNodeMap.NamedPropertyGetter"); | 1538 INC_STATS("DOM.NamedNodeMap.NamedPropertyGetter"); |
| 1539 // Search the prototype chain first. | 1539 // Search the prototype chain first. |
| 1540 v8::Handle<v8::Value> value = | 1540 v8::Handle<v8::Value> value = |
| 1541 info.Holder()->GetRealNamedPropertyInPrototypeChain(name); | 1541 info.Holder()->GetRealNamedPropertyInPrototypeChain(name); |
| 1542 if (!value.IsEmpty()) | 1542 if (!value.IsEmpty()) |
| 1543 return value; | 1543 return value; |
| 1544 | 1544 |
| 1545 // Then look for IDL defined properties on the object itself. | 1545 // Then look for IDL defined properties on the object itself. |
| 1546 if (info.Holder()->HasRealNamedCallbackProperty(name)) | 1546 if (info.Holder()->HasRealNamedCallbackProperty(name)) |
| 1547 return v8::Handle<v8::Value>(); | 1547 return v8::Handle<v8::Value>(); |
| 1548 | 1548 |
| 1549 // Finally, search the DOM. | 1549 // Finally, search the DOM. |
| 1550 NamedNodeMap* imp = V8Proxy::ToNativeObject<NamedNodeMap>( | 1550 NamedNodeMap* imp = V8Proxy::ToNativeObject<NamedNodeMap>( |
| 1551 V8ClassIndex::NAMEDNODEMAP, info.Holder()); | 1551 V8ClassIndex::NAMEDNODEMAP, info.Holder()); |
| 1552 String prop_name = ToWebCoreString(name); | 1552 String prop_name = ToWebCoreString(name); |
| 1553 RefPtr<Node> result = imp->getNamedItem(prop_name); | 1553 RefPtr<Node> result = imp->getNamedItem(prop_name); |
| 1554 if (!result) return v8::Handle<v8::Value>(); | 1554 if (!result) return v8::Handle<v8::Value>(); |
| 1555 | 1555 |
| 1556 return V8Proxy::NodeToV8Object(result.get()); | 1556 return V8Proxy::NodeToV8Object(result.get()); |
| 1557 } | 1557 } |
| 1558 | 1558 |
| 1559 | 1559 |
| 1560 NAMED_PROPERTY_GETTER(NodeList) { | 1560 NAMED_PROPERTY_GETTER(NodeList) { |
| 1561 INC_STATS(L"DOM.NodeList.NamedPropertyGetter"); | 1561 INC_STATS("DOM.NodeList.NamedPropertyGetter"); |
| 1562 NodeList* list = V8Proxy::ToNativeObject<NodeList>( | 1562 NodeList* list = V8Proxy::ToNativeObject<NodeList>( |
| 1563 V8ClassIndex::NODELIST, info.Holder()); | 1563 V8ClassIndex::NODELIST, info.Holder()); |
| 1564 String prop_name = ToWebCoreString(name); | 1564 String prop_name = ToWebCoreString(name); |
| 1565 | 1565 |
| 1566 // Length property cannot be overridden. | 1566 // Length property cannot be overridden. |
| 1567 if (prop_name == "length") | 1567 if (prop_name == "length") |
| 1568 return v8::Number::New(list->length()); | 1568 return v8::Number::New(list->length()); |
| 1569 | 1569 |
| 1570 RefPtr<Node> result = list->itemWithName(prop_name); | 1570 RefPtr<Node> result = list->itemWithName(prop_name); |
| 1571 if (result) | 1571 if (result) |
| 1572 return V8Proxy::NodeToV8Object(result.get()); | 1572 return V8Proxy::NodeToV8Object(result.get()); |
| 1573 | 1573 |
| 1574 return v8::Handle<v8::Value>(); | 1574 return v8::Handle<v8::Value>(); |
| 1575 } | 1575 } |
| 1576 | 1576 |
| 1577 | 1577 |
| 1578 INDEXED_PROPERTY_GETTER(HTMLFormElement) { | 1578 INDEXED_PROPERTY_GETTER(HTMLFormElement) { |
| 1579 INC_STATS(L"DOM.HTMLFormElement.IndexedPropertyGetter"); | 1579 INC_STATS("DOM.HTMLFormElement.IndexedPropertyGetter"); |
| 1580 HTMLFormElement* form = | 1580 HTMLFormElement* form = |
| 1581 V8Proxy::DOMWrapperToNode<HTMLFormElement>(info.Holder()); | 1581 V8Proxy::DOMWrapperToNode<HTMLFormElement>(info.Holder()); |
| 1582 | 1582 |
| 1583 RefPtr<Node> result = form->elements()->item(index); | 1583 RefPtr<Node> result = form->elements()->item(index); |
| 1584 if (!result) return v8::Handle<v8::Value>(); | 1584 if (!result) return v8::Handle<v8::Value>(); |
| 1585 return V8Proxy::NodeToV8Object(result.get()); | 1585 return V8Proxy::NodeToV8Object(result.get()); |
| 1586 } | 1586 } |
| 1587 | 1587 |
| 1588 | 1588 |
| 1589 INDEXED_PROPERTY_GETTER(HTMLOptionsCollection) { | 1589 INDEXED_PROPERTY_GETTER(HTMLOptionsCollection) { |
| 1590 INC_STATS(L"DOM.HTMLOptionsCollection.IndexedPropertyGetter"); | 1590 INC_STATS("DOM.HTMLOptionsCollection.IndexedPropertyGetter"); |
| 1591 HTMLOptionsCollection* collection = | 1591 HTMLOptionsCollection* collection = |
| 1592 V8Proxy::ToNativeObject<HTMLOptionsCollection>( | 1592 V8Proxy::ToNativeObject<HTMLOptionsCollection>( |
| 1593 V8ClassIndex::HTMLOPTIONSCOLLECTION, info.Holder()); | 1593 V8ClassIndex::HTMLOPTIONSCOLLECTION, info.Holder()); |
| 1594 | 1594 |
| 1595 RefPtr<Node> result = collection->item(index); | 1595 RefPtr<Node> result = collection->item(index); |
| 1596 if (!result) return v8::Handle<v8::Value>(); | 1596 if (!result) return v8::Handle<v8::Value>(); |
| 1597 | 1597 |
| 1598 return V8Proxy::NodeToV8Object(result.get()); | 1598 return V8Proxy::NodeToV8Object(result.get()); |
| 1599 } | 1599 } |
| 1600 | 1600 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1618 V8Proxy::DOMWrapperToNode<HTMLOptionElement>( | 1618 V8Proxy::DOMWrapperToNode<HTMLOptionElement>( |
| 1619 v8::Handle<v8::Object>::Cast(value)); | 1619 v8::Handle<v8::Object>::Cast(value)); |
| 1620 base->setOption(index, element, ec); | 1620 base->setOption(index, element, ec); |
| 1621 | 1621 |
| 1622 V8Proxy::SetDOMException(ec); | 1622 V8Proxy::SetDOMException(ec); |
| 1623 return value; | 1623 return value; |
| 1624 } | 1624 } |
| 1625 | 1625 |
| 1626 | 1626 |
| 1627 INDEXED_PROPERTY_SETTER(HTMLOptionsCollection) { | 1627 INDEXED_PROPERTY_SETTER(HTMLOptionsCollection) { |
| 1628 INC_STATS(L"DOM.HTMLOptionsCollection.IndexedPropertySetter"); | 1628 INC_STATS("DOM.HTMLOptionsCollection.IndexedPropertySetter"); |
| 1629 HTMLOptionsCollection* collection = | 1629 HTMLOptionsCollection* collection = |
| 1630 V8Proxy::ToNativeObject<HTMLOptionsCollection>( | 1630 V8Proxy::ToNativeObject<HTMLOptionsCollection>( |
| 1631 V8ClassIndex::HTMLOPTIONSCOLLECTION, info.Holder()); | 1631 V8ClassIndex::HTMLOPTIONSCOLLECTION, info.Holder()); |
| 1632 HTMLSelectElement* base = static_cast<HTMLSelectElement*>(collection->base()); | 1632 HTMLSelectElement* base = static_cast<HTMLSelectElement*>(collection->base()); |
| 1633 return OptionsCollectionSetter(index, value, base); | 1633 return OptionsCollectionSetter(index, value, base); |
| 1634 } | 1634 } |
| 1635 | 1635 |
| 1636 | 1636 |
| 1637 INDEXED_PROPERTY_SETTER(HTMLSelectElementCollection) { | 1637 INDEXED_PROPERTY_SETTER(HTMLSelectElementCollection) { |
| 1638 INC_STATS(L"DOM.HTMLSelectElementCollection.IndexedPropertySetter"); | 1638 INC_STATS("DOM.HTMLSelectElementCollection.IndexedPropertySetter"); |
| 1639 HTMLSelectElement* select = | 1639 HTMLSelectElement* select = |
| 1640 V8Proxy::DOMWrapperToNode<HTMLSelectElement>(info.Holder()); | 1640 V8Proxy::DOMWrapperToNode<HTMLSelectElement>(info.Holder()); |
| 1641 return OptionsCollectionSetter(index, value, select); | 1641 return OptionsCollectionSetter(index, value, select); |
| 1642 } | 1642 } |
| 1643 | 1643 |
| 1644 // Check for a CSS prefix. | 1644 // Check for a CSS prefix. |
| 1645 // Passed prefix is all lowercase. | 1645 // Passed prefix is all lowercase. |
| 1646 // First character of the prefix within the property name may be upper or lowerc
ase. | 1646 // First character of the prefix within the property name may be upper or lowerc
ase. |
| 1647 // Other characters in the prefix within the property name must be lowercase. | 1647 // Other characters in the prefix within the property name must be lowercase. |
| 1648 // The prefix within the property name must be followed by a capital letter. | 1648 // The prefix within the property name must be followed by a capital letter. |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1721 else { | 1721 else { |
| 1722 name.append('-'); | 1722 name.append('-'); |
| 1723 name.append(WTF::toASCIILower(c)); | 1723 name.append(WTF::toASCIILower(c)); |
| 1724 } | 1724 } |
| 1725 } | 1725 } |
| 1726 | 1726 |
| 1727 return String::adopt(name); | 1727 return String::adopt(name); |
| 1728 } | 1728 } |
| 1729 | 1729 |
| 1730 NAMED_PROPERTY_GETTER(CSSStyleDeclaration) { | 1730 NAMED_PROPERTY_GETTER(CSSStyleDeclaration) { |
| 1731 INC_STATS(L"DOM.CSSStyleDeclaration.NamedPropertyGetter"); | 1731 INC_STATS("DOM.CSSStyleDeclaration.NamedPropertyGetter"); |
| 1732 // First look for API defined attributes on the style declaration | 1732 // First look for API defined attributes on the style declaration |
| 1733 // object. | 1733 // object. |
| 1734 if (info.Holder()->HasRealNamedCallbackProperty(name)) | 1734 if (info.Holder()->HasRealNamedCallbackProperty(name)) |
| 1735 return v8::Handle<v8::Value>(); | 1735 return v8::Handle<v8::Value>(); |
| 1736 | 1736 |
| 1737 // Search the style declaration. | 1737 // Search the style declaration. |
| 1738 CSSStyleDeclaration* imp = V8Proxy::ToNativeObject<CSSStyleDeclaration>( | 1738 CSSStyleDeclaration* imp = V8Proxy::ToNativeObject<CSSStyleDeclaration>( |
| 1739 V8ClassIndex::CSSSTYLEDECLARATION, info.Holder()); | 1739 V8ClassIndex::CSSSTYLEDECLARATION, info.Holder()); |
| 1740 | 1740 |
| 1741 bool pixel_or_pos; | 1741 bool pixel_or_pos; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1765 // The 'filter' attribute is made undetectable in KJS/WebKit | 1765 // The 'filter' attribute is made undetectable in KJS/WebKit |
| 1766 // to avoid confusion with IE's filter extension. | 1766 // to avoid confusion with IE's filter extension. |
| 1767 if (prop == "filter") { | 1767 if (prop == "filter") { |
| 1768 return v8UndetectableString(result); | 1768 return v8UndetectableString(result); |
| 1769 } | 1769 } |
| 1770 return v8String(result); | 1770 return v8String(result); |
| 1771 } | 1771 } |
| 1772 | 1772 |
| 1773 | 1773 |
| 1774 NAMED_PROPERTY_SETTER(CSSStyleDeclaration) { | 1774 NAMED_PROPERTY_SETTER(CSSStyleDeclaration) { |
| 1775 INC_STATS(L"DOM.CSSStyleDeclaration.NamedPropertySetter"); | 1775 INC_STATS("DOM.CSSStyleDeclaration.NamedPropertySetter"); |
| 1776 CSSStyleDeclaration* imp = V8Proxy::ToNativeObject<CSSStyleDeclaration>( | 1776 CSSStyleDeclaration* imp = V8Proxy::ToNativeObject<CSSStyleDeclaration>( |
| 1777 V8ClassIndex::CSSSTYLEDECLARATION, info.Holder()); | 1777 V8ClassIndex::CSSSTYLEDECLARATION, info.Holder()); |
| 1778 String property_name = ToWebCoreString(name); | 1778 String property_name = ToWebCoreString(name); |
| 1779 int ec = 0; | 1779 int ec = 0; |
| 1780 | 1780 |
| 1781 bool pixel_or_pos; | 1781 bool pixel_or_pos; |
| 1782 String prop = cssPropertyName(property_name, &pixel_or_pos); | 1782 String prop = cssPropertyName(property_name, &pixel_or_pos); |
| 1783 if (!CSSStyleDeclaration::isPropertyName(prop)) { | 1783 if (!CSSStyleDeclaration::isPropertyName(prop)) { |
| 1784 return v8::Handle<v8::Value>(); // do not block the call | 1784 return v8::Handle<v8::Value>(); // do not block the call |
| 1785 } | 1785 } |
| 1786 | 1786 |
| 1787 String prop_value = valueToStringWithNullCheck(value); | 1787 String prop_value = valueToStringWithNullCheck(value); |
| 1788 if (pixel_or_pos) prop_value += "px"; | 1788 if (pixel_or_pos) prop_value += "px"; |
| 1789 imp->setProperty(prop, prop_value, ec); | 1789 imp->setProperty(prop, prop_value, ec); |
| 1790 | 1790 |
| 1791 V8Proxy::SetDOMException(ec); | 1791 V8Proxy::SetDOMException(ec); |
| 1792 return value; | 1792 return value; |
| 1793 } | 1793 } |
| 1794 | 1794 |
| 1795 | 1795 |
| 1796 NAMED_PROPERTY_GETTER(HTMLPlugInElement) { | 1796 NAMED_PROPERTY_GETTER(HTMLPlugInElement) { |
| 1797 INC_STATS(L"DOM.HTMLPlugInElement.NamedPropertyGetter"); | 1797 INC_STATS("DOM.HTMLPlugInElement.NamedPropertyGetter"); |
| 1798 HTMLPlugInElement* imp = | 1798 HTMLPlugInElement* imp = |
| 1799 V8Proxy::DOMWrapperToNode<HTMLPlugInElement>(info.Holder()); | 1799 V8Proxy::DOMWrapperToNode<HTMLPlugInElement>(info.Holder()); |
| 1800 v8::Local<v8::Object> instance = | 1800 v8::Local<v8::Object> instance = |
| 1801 v8::Local<v8::Object>::New(imp->getInstance()); | 1801 v8::Local<v8::Object>::New(imp->getInstance()); |
| 1802 if (instance.IsEmpty()) return v8::Handle<v8::Object>(); | 1802 if (instance.IsEmpty()) return v8::Handle<v8::Object>(); |
| 1803 return NPObjectGetNamedProperty(instance, name); | 1803 return NPObjectGetNamedProperty(instance, name); |
| 1804 } | 1804 } |
| 1805 | 1805 |
| 1806 | 1806 |
| 1807 NAMED_PROPERTY_SETTER(HTMLPlugInElement) { | 1807 NAMED_PROPERTY_SETTER(HTMLPlugInElement) { |
| 1808 INC_STATS(L"DOM.HTMLPlugInElement.NamedPropertySetter"); | 1808 INC_STATS("DOM.HTMLPlugInElement.NamedPropertySetter"); |
| 1809 HTMLPlugInElement* imp = | 1809 HTMLPlugInElement* imp = |
| 1810 V8Proxy::DOMWrapperToNode<HTMLPlugInElement>(info.Holder()); | 1810 V8Proxy::DOMWrapperToNode<HTMLPlugInElement>(info.Holder()); |
| 1811 v8::Local<v8::Object> instance = | 1811 v8::Local<v8::Object> instance = |
| 1812 v8::Local<v8::Object>::New(imp->getInstance()); | 1812 v8::Local<v8::Object>::New(imp->getInstance()); |
| 1813 if (instance.IsEmpty()) { | 1813 if (instance.IsEmpty()) { |
| 1814 return v8::Handle<v8::Value>(); // do not block the call | 1814 return v8::Handle<v8::Value>(); // do not block the call |
| 1815 } | 1815 } |
| 1816 | 1816 |
| 1817 return NPObjectSetNamedProperty(instance, name, value); | 1817 return NPObjectSetNamedProperty(instance, name, value); |
| 1818 } | 1818 } |
| 1819 | 1819 |
| 1820 | 1820 |
| 1821 CALLBACK_FUNC_DECL(HTMLPlugInElement) { | 1821 CALLBACK_FUNC_DECL(HTMLPlugInElement) { |
| 1822 INC_STATS(L"DOM.HTMLPluginElement()"); | 1822 INC_STATS("DOM.HTMLPluginElement()"); |
| 1823 return NPObjectInvokeDefaultHandler(args); | 1823 return NPObjectInvokeDefaultHandler(args); |
| 1824 } | 1824 } |
| 1825 | 1825 |
| 1826 | 1826 |
| 1827 INDEXED_PROPERTY_GETTER(HTMLPlugInElement) { | 1827 INDEXED_PROPERTY_GETTER(HTMLPlugInElement) { |
| 1828 INC_STATS(L"DOM.HTMLPlugInElement.IndexedPropertyGetter"); | 1828 INC_STATS("DOM.HTMLPlugInElement.IndexedPropertyGetter"); |
| 1829 HTMLPlugInElement* imp = | 1829 HTMLPlugInElement* imp = |
| 1830 V8Proxy::DOMWrapperToNode<HTMLPlugInElement>(info.Holder()); | 1830 V8Proxy::DOMWrapperToNode<HTMLPlugInElement>(info.Holder()); |
| 1831 v8::Local<v8::Object> instance = | 1831 v8::Local<v8::Object> instance = |
| 1832 v8::Local<v8::Object>::New(imp->getInstance()); | 1832 v8::Local<v8::Object>::New(imp->getInstance()); |
| 1833 if (instance.IsEmpty()) return v8::Handle<v8::Object>(); | 1833 if (instance.IsEmpty()) return v8::Handle<v8::Object>(); |
| 1834 return NPObjectGetIndexedProperty(instance, index); | 1834 return NPObjectGetIndexedProperty(instance, index); |
| 1835 } | 1835 } |
| 1836 | 1836 |
| 1837 | 1837 |
| 1838 INDEXED_PROPERTY_SETTER(HTMLPlugInElement) { | 1838 INDEXED_PROPERTY_SETTER(HTMLPlugInElement) { |
| 1839 INC_STATS(L"DOM.HTMLPlugInElement.IndexedPropertySetter"); | 1839 INC_STATS("DOM.HTMLPlugInElement.IndexedPropertySetter"); |
| 1840 HTMLPlugInElement* imp = | 1840 HTMLPlugInElement* imp = |
| 1841 V8Proxy::DOMWrapperToNode<HTMLPlugInElement>(info.Holder()); | 1841 V8Proxy::DOMWrapperToNode<HTMLPlugInElement>(info.Holder()); |
| 1842 v8::Local<v8::Object> instance = | 1842 v8::Local<v8::Object> instance = |
| 1843 v8::Local<v8::Object>::New(imp->getInstance()); | 1843 v8::Local<v8::Object>::New(imp->getInstance()); |
| 1844 if (instance.IsEmpty()) { | 1844 if (instance.IsEmpty()) { |
| 1845 return v8::Handle<v8::Value>(); // do not block the call | 1845 return v8::Handle<v8::Value>(); // do not block the call |
| 1846 } | 1846 } |
| 1847 | 1847 |
| 1848 return NPObjectSetIndexedProperty(instance, index, value); | 1848 return NPObjectSetIndexedProperty(instance, index, value); |
| 1849 } | 1849 } |
| 1850 | 1850 |
| 1851 NAMED_PROPERTY_GETTER(StyleSheetList) { | 1851 NAMED_PROPERTY_GETTER(StyleSheetList) { |
| 1852 INC_STATS(L"DOM.StyleSheetList.NamedPropertyGetter"); | 1852 INC_STATS("DOM.StyleSheetList.NamedPropertyGetter"); |
| 1853 // Look for local properties first. | 1853 // Look for local properties first. |
| 1854 if (info.Holder()->HasRealNamedProperty(name)) { | 1854 if (info.Holder()->HasRealNamedProperty(name)) { |
| 1855 return v8::Handle<v8::Value>(); | 1855 return v8::Handle<v8::Value>(); |
| 1856 } | 1856 } |
| 1857 | 1857 |
| 1858 // Search style sheet. | 1858 // Search style sheet. |
| 1859 StyleSheetList* imp = V8Proxy::ToNativeObject<StyleSheetList>( | 1859 StyleSheetList* imp = V8Proxy::ToNativeObject<StyleSheetList>( |
| 1860 V8ClassIndex::STYLESHEETLIST, info.Holder()); | 1860 V8ClassIndex::STYLESHEETLIST, info.Holder()); |
| 1861 String key = ToWebCoreString(name); | 1861 String key = ToWebCoreString(name); |
| 1862 HTMLStyleElement* item = imp->getNamedItem(key); | 1862 HTMLStyleElement* item = imp->getNamedItem(key); |
| 1863 if (item) { | 1863 if (item) { |
| 1864 return V8Proxy::ToV8Object(V8ClassIndex::HTMLSTYLEELEMENT, item); | 1864 return V8Proxy::ToV8Object(V8ClassIndex::HTMLSTYLEELEMENT, item); |
| 1865 } | 1865 } |
| 1866 return v8::Handle<v8::Value>(); | 1866 return v8::Handle<v8::Value>(); |
| 1867 } | 1867 } |
| 1868 | 1868 |
| 1869 | 1869 |
| 1870 // CanvasRenderingContext2D ---------------------------------------------------- | 1870 // CanvasRenderingContext2D ---------------------------------------------------- |
| 1871 | 1871 |
| 1872 // Helper macro for converting v8 values into floats (expected by many of the | 1872 // Helper macro for converting v8 values into floats (expected by many of the |
| 1873 // canvas functions). | 1873 // canvas functions). |
| 1874 #define TO_FLOAT(a) static_cast<float>((a)->NumberValue()) | 1874 #define TO_FLOAT(a) static_cast<float>((a)->NumberValue()) |
| 1875 | 1875 |
| 1876 // TODO: SetStrokeColor and SetFillColor are similar except function names, | 1876 // TODO: SetStrokeColor and SetFillColor are similar except function names, |
| 1877 // consolidate them into one. | 1877 // consolidate them into one. |
| 1878 CALLBACK_FUNC_DECL(CanvasRenderingContext2DSetStrokeColor) { | 1878 CALLBACK_FUNC_DECL(CanvasRenderingContext2DSetStrokeColor) { |
| 1879 INC_STATS(L"DOM.CanvasRenderingContext2D.setStrokeColor()"); | 1879 INC_STATS("DOM.CanvasRenderingContext2D.setStrokeColor()"); |
| 1880 CanvasRenderingContext2D* context = | 1880 CanvasRenderingContext2D* context = |
| 1881 V8Proxy::ToNativeObject<CanvasRenderingContext2D>( | 1881 V8Proxy::ToNativeObject<CanvasRenderingContext2D>( |
| 1882 V8ClassIndex::CANVASRENDERINGCONTEXT2D, args.Holder()); | 1882 V8ClassIndex::CANVASRENDERINGCONTEXT2D, args.Holder()); |
| 1883 switch (args.Length()) { | 1883 switch (args.Length()) { |
| 1884 case 1: | 1884 case 1: |
| 1885 if (args[0]->IsString()) { | 1885 if (args[0]->IsString()) { |
| 1886 context->setStrokeColor(ToWebCoreString(args[0])); | 1886 context->setStrokeColor(ToWebCoreString(args[0])); |
| 1887 } else { | 1887 } else { |
| 1888 context->setStrokeColor(TO_FLOAT(args[0])); | 1888 context->setStrokeColor(TO_FLOAT(args[0])); |
| 1889 } | 1889 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1912 break; | 1912 break; |
| 1913 default: | 1913 default: |
| 1914 V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, | 1914 V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, |
| 1915 "setStrokeColor: Invalid number of arguments"); | 1915 "setStrokeColor: Invalid number of arguments"); |
| 1916 break; | 1916 break; |
| 1917 } | 1917 } |
| 1918 return v8::Undefined(); | 1918 return v8::Undefined(); |
| 1919 } | 1919 } |
| 1920 | 1920 |
| 1921 CALLBACK_FUNC_DECL(CanvasRenderingContext2DSetFillColor) { | 1921 CALLBACK_FUNC_DECL(CanvasRenderingContext2DSetFillColor) { |
| 1922 INC_STATS(L"DOM.CanvasRenderingContext2D.steFillColor()"); | 1922 INC_STATS("DOM.CanvasRenderingContext2D.steFillColor()"); |
| 1923 CanvasRenderingContext2D* context = | 1923 CanvasRenderingContext2D* context = |
| 1924 V8Proxy::ToNativeObject<CanvasRenderingContext2D>( | 1924 V8Proxy::ToNativeObject<CanvasRenderingContext2D>( |
| 1925 V8ClassIndex::CANVASRENDERINGCONTEXT2D, args.Holder()); | 1925 V8ClassIndex::CANVASRENDERINGCONTEXT2D, args.Holder()); |
| 1926 switch (args.Length()) { | 1926 switch (args.Length()) { |
| 1927 case 1: | 1927 case 1: |
| 1928 if (args[0]->IsString()) { | 1928 if (args[0]->IsString()) { |
| 1929 context->setFillColor(ToWebCoreString(args[0])); | 1929 context->setFillColor(ToWebCoreString(args[0])); |
| 1930 } else { | 1930 } else { |
| 1931 context->setFillColor(TO_FLOAT(args[0])); | 1931 context->setFillColor(TO_FLOAT(args[0])); |
| 1932 } | 1932 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1953 break; | 1953 break; |
| 1954 default: | 1954 default: |
| 1955 V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, | 1955 V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, |
| 1956 "setFillColor: Invalid number of arguments"); | 1956 "setFillColor: Invalid number of arguments"); |
| 1957 break; | 1957 break; |
| 1958 } | 1958 } |
| 1959 return v8::Undefined(); | 1959 return v8::Undefined(); |
| 1960 } | 1960 } |
| 1961 | 1961 |
| 1962 CALLBACK_FUNC_DECL(CanvasRenderingContext2DStrokeRect) { | 1962 CALLBACK_FUNC_DECL(CanvasRenderingContext2DStrokeRect) { |
| 1963 INC_STATS(L"DOM.CanvasRenderingContext2D.strokeRect()"); | 1963 INC_STATS("DOM.CanvasRenderingContext2D.strokeRect()"); |
| 1964 CanvasRenderingContext2D* context = | 1964 CanvasRenderingContext2D* context = |
| 1965 V8Proxy::ToNativeObject<CanvasRenderingContext2D>( | 1965 V8Proxy::ToNativeObject<CanvasRenderingContext2D>( |
| 1966 V8ClassIndex::CANVASRENDERINGCONTEXT2D, args.Holder()); | 1966 V8ClassIndex::CANVASRENDERINGCONTEXT2D, args.Holder()); |
| 1967 if (args.Length() == 5) { | 1967 if (args.Length() == 5) { |
| 1968 context->strokeRect(TO_FLOAT(args[0]), | 1968 context->strokeRect(TO_FLOAT(args[0]), |
| 1969 TO_FLOAT(args[1]), | 1969 TO_FLOAT(args[1]), |
| 1970 TO_FLOAT(args[2]), | 1970 TO_FLOAT(args[2]), |
| 1971 TO_FLOAT(args[3]), | 1971 TO_FLOAT(args[3]), |
| 1972 TO_FLOAT(args[4])); | 1972 TO_FLOAT(args[4])); |
| 1973 } else if (args.Length() == 4) { | 1973 } else if (args.Length() == 4) { |
| 1974 context->strokeRect(TO_FLOAT(args[0]), | 1974 context->strokeRect(TO_FLOAT(args[0]), |
| 1975 TO_FLOAT(args[1]), | 1975 TO_FLOAT(args[1]), |
| 1976 TO_FLOAT(args[2]), | 1976 TO_FLOAT(args[2]), |
| 1977 TO_FLOAT(args[3])); | 1977 TO_FLOAT(args[3])); |
| 1978 } else { | 1978 } else { |
| 1979 V8Proxy::SetDOMException(INDEX_SIZE_ERR); | 1979 V8Proxy::SetDOMException(INDEX_SIZE_ERR); |
| 1980 return v8::Handle<v8::Value>(); | 1980 return v8::Handle<v8::Value>(); |
| 1981 } | 1981 } |
| 1982 | 1982 |
| 1983 return v8::Undefined(); | 1983 return v8::Undefined(); |
| 1984 } | 1984 } |
| 1985 | 1985 |
| 1986 CALLBACK_FUNC_DECL(CanvasRenderingContext2DSetShadow) { | 1986 CALLBACK_FUNC_DECL(CanvasRenderingContext2DSetShadow) { |
| 1987 INC_STATS(L"DOM.CanvasRenderingContext2D.setShadow()"); | 1987 INC_STATS("DOM.CanvasRenderingContext2D.setShadow()"); |
| 1988 CanvasRenderingContext2D* context = | 1988 CanvasRenderingContext2D* context = |
| 1989 V8Proxy::ToNativeObject<CanvasRenderingContext2D>( | 1989 V8Proxy::ToNativeObject<CanvasRenderingContext2D>( |
| 1990 V8ClassIndex::CANVASRENDERINGCONTEXT2D, args.Holder()); | 1990 V8ClassIndex::CANVASRENDERINGCONTEXT2D, args.Holder()); |
| 1991 | 1991 |
| 1992 switch (args.Length()) { | 1992 switch (args.Length()) { |
| 1993 case 3: | 1993 case 3: |
| 1994 context->setShadow(TO_FLOAT(args[0]), TO_FLOAT(args[1]), | 1994 context->setShadow(TO_FLOAT(args[0]), TO_FLOAT(args[1]), |
| 1995 TO_FLOAT(args[2])); | 1995 TO_FLOAT(args[2])); |
| 1996 break; | 1996 break; |
| 1997 case 4: | 1997 case 4: |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2027 default: | 2027 default: |
| 2028 V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, | 2028 V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, |
| 2029 "setShadow: Invalid number of arguments"); | 2029 "setShadow: Invalid number of arguments"); |
| 2030 break; | 2030 break; |
| 2031 } | 2031 } |
| 2032 | 2032 |
| 2033 return v8::Undefined(); | 2033 return v8::Undefined(); |
| 2034 } | 2034 } |
| 2035 | 2035 |
| 2036 CALLBACK_FUNC_DECL(CanvasRenderingContext2DDrawImage) { | 2036 CALLBACK_FUNC_DECL(CanvasRenderingContext2DDrawImage) { |
| 2037 INC_STATS(L"DOM.CanvasRenderingContext2D.drawImage()"); | 2037 INC_STATS("DOM.CanvasRenderingContext2D.drawImage()"); |
| 2038 CanvasRenderingContext2D* context = | 2038 CanvasRenderingContext2D* context = |
| 2039 V8Proxy::ToNativeObject<CanvasRenderingContext2D>( | 2039 V8Proxy::ToNativeObject<CanvasRenderingContext2D>( |
| 2040 V8ClassIndex::CANVASRENDERINGCONTEXT2D, args.Holder()); | 2040 V8ClassIndex::CANVASRENDERINGCONTEXT2D, args.Holder()); |
| 2041 | 2041 |
| 2042 v8::Handle<v8::Value> arg = args[0]; | 2042 v8::Handle<v8::Value> arg = args[0]; |
| 2043 | 2043 |
| 2044 if (V8HTMLImageElement::HasInstance(arg)) { | 2044 if (V8HTMLImageElement::HasInstance(arg)) { |
| 2045 ExceptionCode ec = 0; | 2045 ExceptionCode ec = 0; |
| 2046 HTMLImageElement* image_element = | 2046 HTMLImageElement* image_element = |
| 2047 V8Proxy::DOMWrapperToNode<HTMLImageElement>(arg); | 2047 V8Proxy::DOMWrapperToNode<HTMLImageElement>(arg); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2112 return v8::Undefined(); | 2112 return v8::Undefined(); |
| 2113 } | 2113 } |
| 2114 return v8::Undefined(); | 2114 return v8::Undefined(); |
| 2115 } | 2115 } |
| 2116 | 2116 |
| 2117 V8Proxy::SetDOMException(TYPE_MISMATCH_ERR); | 2117 V8Proxy::SetDOMException(TYPE_MISMATCH_ERR); |
| 2118 return v8::Handle<v8::Value>(); | 2118 return v8::Handle<v8::Value>(); |
| 2119 } | 2119 } |
| 2120 | 2120 |
| 2121 CALLBACK_FUNC_DECL(CanvasRenderingContext2DDrawImageFromRect) { | 2121 CALLBACK_FUNC_DECL(CanvasRenderingContext2DDrawImageFromRect) { |
| 2122 INC_STATS(L"DOM.CanvasRenderingContext2D.drawImageFromRect()"); | 2122 INC_STATS("DOM.CanvasRenderingContext2D.drawImageFromRect()"); |
| 2123 CanvasRenderingContext2D* context = | 2123 CanvasRenderingContext2D* context = |
| 2124 V8Proxy::ToNativeObject<CanvasRenderingContext2D>( | 2124 V8Proxy::ToNativeObject<CanvasRenderingContext2D>( |
| 2125 V8ClassIndex::CANVASRENDERINGCONTEXT2D, args.Holder()); | 2125 V8ClassIndex::CANVASRENDERINGCONTEXT2D, args.Holder()); |
| 2126 | 2126 |
| 2127 v8::Handle<v8::Value> arg = args[0]; | 2127 v8::Handle<v8::Value> arg = args[0]; |
| 2128 | 2128 |
| 2129 if (V8HTMLImageElement::HasInstance(arg)) { | 2129 if (V8HTMLImageElement::HasInstance(arg)) { |
| 2130 HTMLImageElement* image_element = | 2130 HTMLImageElement* image_element = |
| 2131 V8Proxy::DOMWrapperToNode<HTMLImageElement>(arg); | 2131 V8Proxy::DOMWrapperToNode<HTMLImageElement>(arg); |
| 2132 context->drawImageFromRect(image_element, | 2132 context->drawImageFromRect(image_element, |
| 2133 TO_FLOAT(args[1]), TO_FLOAT(args[2]), | 2133 TO_FLOAT(args[1]), TO_FLOAT(args[2]), |
| 2134 TO_FLOAT(args[3]), TO_FLOAT(args[4]), | 2134 TO_FLOAT(args[3]), TO_FLOAT(args[4]), |
| 2135 TO_FLOAT(args[5]), TO_FLOAT(args[6]), | 2135 TO_FLOAT(args[5]), TO_FLOAT(args[6]), |
| 2136 TO_FLOAT(args[7]), TO_FLOAT(args[8]), | 2136 TO_FLOAT(args[7]), TO_FLOAT(args[8]), |
| 2137 ToWebCoreString(args[9])); | 2137 ToWebCoreString(args[9])); |
| 2138 } else { | 2138 } else { |
| 2139 V8Proxy::ThrowError(V8Proxy::TYPE_ERROR, | 2139 V8Proxy::ThrowError(V8Proxy::TYPE_ERROR, |
| 2140 "drawImageFromRect: Invalid type of arguments"); | 2140 "drawImageFromRect: Invalid type of arguments"); |
| 2141 } | 2141 } |
| 2142 | 2142 |
| 2143 return v8::Undefined(); | 2143 return v8::Undefined(); |
| 2144 } | 2144 } |
| 2145 | 2145 |
| 2146 CALLBACK_FUNC_DECL(CanvasRenderingContext2DCreatePattern) { | 2146 CALLBACK_FUNC_DECL(CanvasRenderingContext2DCreatePattern) { |
| 2147 INC_STATS(L"DOM.CanvasRenderingContext2D.createPattern()"); | 2147 INC_STATS("DOM.CanvasRenderingContext2D.createPattern()"); |
| 2148 CanvasRenderingContext2D* context = | 2148 CanvasRenderingContext2D* context = |
| 2149 V8Proxy::ToNativeObject<CanvasRenderingContext2D>( | 2149 V8Proxy::ToNativeObject<CanvasRenderingContext2D>( |
| 2150 V8ClassIndex::CANVASRENDERINGCONTEXT2D, args.Holder()); | 2150 V8ClassIndex::CANVASRENDERINGCONTEXT2D, args.Holder()); |
| 2151 | 2151 |
| 2152 v8::Handle<v8::Value> arg = args[0]; | 2152 v8::Handle<v8::Value> arg = args[0]; |
| 2153 | 2153 |
| 2154 if (V8HTMLImageElement::HasInstance(arg)) { | 2154 if (V8HTMLImageElement::HasInstance(arg)) { |
| 2155 HTMLImageElement* image_element = | 2155 HTMLImageElement* image_element = |
| 2156 V8Proxy::DOMWrapperToNode<HTMLImageElement>(arg); | 2156 V8Proxy::DOMWrapperToNode<HTMLImageElement>(arg); |
| 2157 ExceptionCode ec = 0; | 2157 ExceptionCode ec = 0; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2177 } | 2177 } |
| 2178 return V8Proxy::ToV8Object(V8ClassIndex::CANVASPATTERN, | 2178 return V8Proxy::ToV8Object(V8ClassIndex::CANVASPATTERN, |
| 2179 static_cast<Peerable*>(pattern.get())); | 2179 static_cast<Peerable*>(pattern.get())); |
| 2180 } | 2180 } |
| 2181 | 2181 |
| 2182 V8Proxy::SetDOMException(TYPE_MISMATCH_ERR); | 2182 V8Proxy::SetDOMException(TYPE_MISMATCH_ERR); |
| 2183 return v8::Handle<v8::Value>(); | 2183 return v8::Handle<v8::Value>(); |
| 2184 } | 2184 } |
| 2185 | 2185 |
| 2186 CALLBACK_FUNC_DECL(CanvasRenderingContext2DFillText) { | 2186 CALLBACK_FUNC_DECL(CanvasRenderingContext2DFillText) { |
| 2187 INC_STATS(L"DOM.CanvasRenderingContext2D.fillText()"); | 2187 INC_STATS("DOM.CanvasRenderingContext2D.fillText()"); |
| 2188 | 2188 |
| 2189 CanvasRenderingContext2D* context = | 2189 CanvasRenderingContext2D* context = |
| 2190 V8Proxy::ToNativeObject<CanvasRenderingContext2D>( | 2190 V8Proxy::ToNativeObject<CanvasRenderingContext2D>( |
| 2191 V8ClassIndex::CANVASRENDERINGCONTEXT2D, args.Holder()); | 2191 V8ClassIndex::CANVASRENDERINGCONTEXT2D, args.Holder()); |
| 2192 | 2192 |
| 2193 // Two forms: | 2193 // Two forms: |
| 2194 // * fillText(text, x, y) | 2194 // * fillText(text, x, y) |
| 2195 // * fillText(text, x, y, maxWidth) | 2195 // * fillText(text, x, y, maxWidth) |
| 2196 if (args.Length() < 3 || args.Length() > 4) { | 2196 if (args.Length() < 3 || args.Length() > 4) { |
| 2197 V8Proxy::SetDOMException(SYNTAX_ERR); | 2197 V8Proxy::SetDOMException(SYNTAX_ERR); |
| 2198 return v8::Handle<v8::Value>(); | 2198 return v8::Handle<v8::Value>(); |
| 2199 } | 2199 } |
| 2200 | 2200 |
| 2201 String text = ToWebCoreString(args[0]); | 2201 String text = ToWebCoreString(args[0]); |
| 2202 float x = TO_FLOAT(args[1]); | 2202 float x = TO_FLOAT(args[1]); |
| 2203 float y = TO_FLOAT(args[2]); | 2203 float y = TO_FLOAT(args[2]); |
| 2204 | 2204 |
| 2205 if (args.Length() == 4) { | 2205 if (args.Length() == 4) { |
| 2206 float maxWidth = TO_FLOAT(args[3]); | 2206 float maxWidth = TO_FLOAT(args[3]); |
| 2207 context->fillText(text, x, y, maxWidth); | 2207 context->fillText(text, x, y, maxWidth); |
| 2208 } else { | 2208 } else { |
| 2209 context->fillText(text, x, y); | 2209 context->fillText(text, x, y); |
| 2210 } | 2210 } |
| 2211 | 2211 |
| 2212 return v8::Undefined(); | 2212 return v8::Undefined(); |
| 2213 } | 2213 } |
| 2214 | 2214 |
| 2215 CALLBACK_FUNC_DECL(CanvasRenderingContext2DStrokeText) { | 2215 CALLBACK_FUNC_DECL(CanvasRenderingContext2DStrokeText) { |
| 2216 INC_STATS(L"DOM.CanvasRenderingContext2D.strokeText()"); | 2216 INC_STATS("DOM.CanvasRenderingContext2D.strokeText()"); |
| 2217 | 2217 |
| 2218 CanvasRenderingContext2D* context = | 2218 CanvasRenderingContext2D* context = |
| 2219 V8Proxy::ToNativeObject<CanvasRenderingContext2D>( | 2219 V8Proxy::ToNativeObject<CanvasRenderingContext2D>( |
| 2220 V8ClassIndex::CANVASRENDERINGCONTEXT2D, args.Holder()); | 2220 V8ClassIndex::CANVASRENDERINGCONTEXT2D, args.Holder()); |
| 2221 | 2221 |
| 2222 // Two forms: | 2222 // Two forms: |
| 2223 // * strokeText(text, x, y) | 2223 // * strokeText(text, x, y) |
| 2224 // * strokeText(text, x, y, maxWidth) | 2224 // * strokeText(text, x, y, maxWidth) |
| 2225 if (args.Length() < 3 || args.Length() > 4) { | 2225 if (args.Length() < 3 || args.Length() > 4) { |
| 2226 V8Proxy::SetDOMException(SYNTAX_ERR); | 2226 V8Proxy::SetDOMException(SYNTAX_ERR); |
| 2227 return v8::Handle<v8::Value>(); | 2227 return v8::Handle<v8::Value>(); |
| 2228 } | 2228 } |
| 2229 | 2229 |
| 2230 String text = ToWebCoreString(args[0]); | 2230 String text = ToWebCoreString(args[0]); |
| 2231 float x = TO_FLOAT(args[1]); | 2231 float x = TO_FLOAT(args[1]); |
| 2232 float y = TO_FLOAT(args[2]); | 2232 float y = TO_FLOAT(args[2]); |
| 2233 | 2233 |
| 2234 if (args.Length() == 4) { | 2234 if (args.Length() == 4) { |
| 2235 float maxWidth = TO_FLOAT(args[3]); | 2235 float maxWidth = TO_FLOAT(args[3]); |
| 2236 context->strokeText(text, x, y, maxWidth); | 2236 context->strokeText(text, x, y, maxWidth); |
| 2237 } else { | 2237 } else { |
| 2238 context->strokeText(text, x, y); | 2238 context->strokeText(text, x, y); |
| 2239 } | 2239 } |
| 2240 | 2240 |
| 2241 return v8::Undefined(); | 2241 return v8::Undefined(); |
| 2242 } | 2242 } |
| 2243 | 2243 |
| 2244 CALLBACK_FUNC_DECL(CanvasRenderingContext2DPutImageData) { | 2244 CALLBACK_FUNC_DECL(CanvasRenderingContext2DPutImageData) { |
| 2245 INC_STATS(L"DOM.CanvasRenderingContext2D.putImageData()"); | 2245 INC_STATS("DOM.CanvasRenderingContext2D.putImageData()"); |
| 2246 | 2246 |
| 2247 // Two froms: | 2247 // Two froms: |
| 2248 // * putImageData(ImageData, x, y) | 2248 // * putImageData(ImageData, x, y) |
| 2249 // * putImageData(ImageData, x, y, dirtyX, dirtyY, dirtyWidth, dirtyHeight) | 2249 // * putImageData(ImageData, x, y, dirtyX, dirtyY, dirtyWidth, dirtyHeight) |
| 2250 if (args.Length() != 3 && args.Length() != 7) { | 2250 if (args.Length() != 3 && args.Length() != 7) { |
| 2251 V8Proxy::SetDOMException(SYNTAX_ERR); | 2251 V8Proxy::SetDOMException(SYNTAX_ERR); |
| 2252 return v8::Handle<v8::Value>(); | 2252 return v8::Handle<v8::Value>(); |
| 2253 } | 2253 } |
| 2254 | 2254 |
| 2255 CanvasRenderingContext2D* context = | 2255 CanvasRenderingContext2D* context = |
| (...skipping 26 matching lines...) Expand all Loading... |
| 2282 return v8::Handle<v8::Value>(); | 2282 return v8::Handle<v8::Value>(); |
| 2283 } | 2283 } |
| 2284 | 2284 |
| 2285 return v8::Undefined(); | 2285 return v8::Undefined(); |
| 2286 } | 2286 } |
| 2287 | 2287 |
| 2288 | 2288 |
| 2289 // Console --------------------------------------------------------------------- | 2289 // Console --------------------------------------------------------------------- |
| 2290 | 2290 |
| 2291 CALLBACK_FUNC_DECL(ConsoleAssert) { | 2291 CALLBACK_FUNC_DECL(ConsoleAssert) { |
| 2292 INC_STATS(L"DOM.Console.assert()"); | 2292 INC_STATS("DOM.Console.assert()"); |
| 2293 V8Proxy::SetDOMException(NOT_SUPPORTED_ERR); | 2293 V8Proxy::SetDOMException(NOT_SUPPORTED_ERR); |
| 2294 return v8::Undefined(); | 2294 return v8::Undefined(); |
| 2295 } | 2295 } |
| 2296 | 2296 |
| 2297 CALLBACK_FUNC_DECL(ConsoleCount) { | 2297 CALLBACK_FUNC_DECL(ConsoleCount) { |
| 2298 INC_STATS(L"DOM.Console.count()"); | 2298 INC_STATS("DOM.Console.count()"); |
| 2299 V8Proxy::SetDOMException(NOT_SUPPORTED_ERR); | 2299 V8Proxy::SetDOMException(NOT_SUPPORTED_ERR); |
| 2300 return v8::Undefined(); | 2300 return v8::Undefined(); |
| 2301 } | 2301 } |
| 2302 | 2302 |
| 2303 CALLBACK_FUNC_DECL(ConsoleDebug) { | 2303 CALLBACK_FUNC_DECL(ConsoleDebug) { |
| 2304 INC_STATS(L"DOM.Console.debug()"); | 2304 INC_STATS("DOM.Console.debug()"); |
| 2305 V8Proxy::SetDOMException(NOT_SUPPORTED_ERR); | 2305 V8Proxy::SetDOMException(NOT_SUPPORTED_ERR); |
| 2306 return v8::Undefined(); | 2306 return v8::Undefined(); |
| 2307 } | 2307 } |
| 2308 | 2308 |
| 2309 CALLBACK_FUNC_DECL(ConsoleDir) { | 2309 CALLBACK_FUNC_DECL(ConsoleDir) { |
| 2310 INC_STATS(L"DOM.Console.dir()"); | 2310 INC_STATS("DOM.Console.dir()"); |
| 2311 V8Proxy::SetDOMException(NOT_SUPPORTED_ERR); | 2311 V8Proxy::SetDOMException(NOT_SUPPORTED_ERR); |
| 2312 return v8::Undefined(); | 2312 return v8::Undefined(); |
| 2313 } | 2313 } |
| 2314 | 2314 |
| 2315 CALLBACK_FUNC_DECL(ConsoleError) { | 2315 CALLBACK_FUNC_DECL(ConsoleError) { |
| 2316 INC_STATS(L"DOM.Console.error()"); | 2316 INC_STATS("DOM.Console.error()"); |
| 2317 v8::Handle<v8::Value> holder = args.Holder(); | 2317 v8::Handle<v8::Value> holder = args.Holder(); |
| 2318 Console* imp = V8Proxy::ToNativeObject<Console>(V8ClassIndex::CONSOLE, holder)
; | 2318 Console* imp = V8Proxy::ToNativeObject<Console>(V8ClassIndex::CONSOLE, holder)
; |
| 2319 ScriptCallContext context(args); | 2319 ScriptCallContext context(args); |
| 2320 imp->error(&context); | 2320 imp->error(&context); |
| 2321 return v8::Undefined(); | 2321 return v8::Undefined(); |
| 2322 } | 2322 } |
| 2323 | 2323 |
| 2324 CALLBACK_FUNC_DECL(ConsoleGroup) { | 2324 CALLBACK_FUNC_DECL(ConsoleGroup) { |
| 2325 INC_STATS(L"DOM.Console.group()"); | 2325 INC_STATS("DOM.Console.group()"); |
| 2326 v8::Handle<v8::Value> holder = args.Holder(); | 2326 v8::Handle<v8::Value> holder = args.Holder(); |
| 2327 Console* imp = V8Proxy::ToNativeObject<Console>(V8ClassIndex::CONSOLE, holder)
; | 2327 Console* imp = V8Proxy::ToNativeObject<Console>(V8ClassIndex::CONSOLE, holder)
; |
| 2328 ScriptCallContext context(args); | 2328 ScriptCallContext context(args); |
| 2329 imp->group(&context); | 2329 imp->group(&context); |
| 2330 return v8::Undefined(); | 2330 return v8::Undefined(); |
| 2331 } | 2331 } |
| 2332 | 2332 |
| 2333 CALLBACK_FUNC_DECL(ConsoleInfo) { | 2333 CALLBACK_FUNC_DECL(ConsoleInfo) { |
| 2334 INC_STATS(L"DOM.Console.info()"); | 2334 INC_STATS("DOM.Console.info()"); |
| 2335 v8::Handle<v8::Value> holder = args.Holder(); | 2335 v8::Handle<v8::Value> holder = args.Holder(); |
| 2336 Console* imp = V8Proxy::ToNativeObject<Console>(V8ClassIndex::CONSOLE, holder)
; | 2336 Console* imp = V8Proxy::ToNativeObject<Console>(V8ClassIndex::CONSOLE, holder)
; |
| 2337 ScriptCallContext context(args); | 2337 ScriptCallContext context(args); |
| 2338 imp->info(&context); | 2338 imp->info(&context); |
| 2339 return v8::Undefined(); | 2339 return v8::Undefined(); |
| 2340 } | 2340 } |
| 2341 | 2341 |
| 2342 CALLBACK_FUNC_DECL(ConsoleLog) { | 2342 CALLBACK_FUNC_DECL(ConsoleLog) { |
| 2343 INC_STATS(L"DOM.Console.log()"); | 2343 INC_STATS("DOM.Console.log()"); |
| 2344 v8::Handle<v8::Value> holder = args.Holder(); | 2344 v8::Handle<v8::Value> holder = args.Holder(); |
| 2345 Console* imp = V8Proxy::ToNativeObject<Console>(V8ClassIndex::CONSOLE, holder)
; | 2345 Console* imp = V8Proxy::ToNativeObject<Console>(V8ClassIndex::CONSOLE, holder)
; |
| 2346 ScriptCallContext context(args); | 2346 ScriptCallContext context(args); |
| 2347 imp->log(&context); | 2347 imp->log(&context); |
| 2348 return v8::Undefined(); | 2348 return v8::Undefined(); |
| 2349 } | 2349 } |
| 2350 | 2350 |
| 2351 CALLBACK_FUNC_DECL(ConsoleProfile) { | 2351 CALLBACK_FUNC_DECL(ConsoleProfile) { |
| 2352 INC_STATS(L"DOM.Console.profile()"); | 2352 INC_STATS("DOM.Console.profile()"); |
| 2353 V8Proxy::SetDOMException(NOT_SUPPORTED_ERR); | 2353 V8Proxy::SetDOMException(NOT_SUPPORTED_ERR); |
| 2354 return v8::Undefined(); | 2354 return v8::Undefined(); |
| 2355 } | 2355 } |
| 2356 | 2356 |
| 2357 CALLBACK_FUNC_DECL(ConsoleProfileEnd) { | 2357 CALLBACK_FUNC_DECL(ConsoleProfileEnd) { |
| 2358 INC_STATS(L"DOM.Console.profileEnd()"); | 2358 INC_STATS("DOM.Console.profileEnd()"); |
| 2359 V8Proxy::SetDOMException(NOT_SUPPORTED_ERR); | 2359 V8Proxy::SetDOMException(NOT_SUPPORTED_ERR); |
| 2360 return v8::Undefined(); | 2360 return v8::Undefined(); |
| 2361 } | 2361 } |
| 2362 | 2362 |
| 2363 CALLBACK_FUNC_DECL(ConsoleTimeEnd) { | 2363 CALLBACK_FUNC_DECL(ConsoleTimeEnd) { |
| 2364 INC_STATS(L"DOM.Console.timeEnd()"); | 2364 INC_STATS("DOM.Console.timeEnd()"); |
| 2365 V8Proxy::SetDOMException(NOT_SUPPORTED_ERR); | 2365 V8Proxy::SetDOMException(NOT_SUPPORTED_ERR); |
| 2366 return v8::Undefined(); | 2366 return v8::Undefined(); |
| 2367 } | 2367 } |
| 2368 | 2368 |
| 2369 CALLBACK_FUNC_DECL(ConsoleWarn) { | 2369 CALLBACK_FUNC_DECL(ConsoleWarn) { |
| 2370 INC_STATS(L"DOM.Console.warn()"); | 2370 INC_STATS("DOM.Console.warn()"); |
| 2371 v8::Handle<v8::Value> holder = args.Holder(); | 2371 v8::Handle<v8::Value> holder = args.Holder(); |
| 2372 Console* imp = V8Proxy::ToNativeObject<Console>(V8ClassIndex::CONSOLE, holder)
; | 2372 Console* imp = V8Proxy::ToNativeObject<Console>(V8ClassIndex::CONSOLE, holder)
; |
| 2373 ScriptCallContext context(args); | 2373 ScriptCallContext context(args); |
| 2374 imp->warn(&context); | 2374 imp->warn(&context); |
| 2375 return v8::Undefined(); | 2375 return v8::Undefined(); |
| 2376 } | 2376 } |
| 2377 | 2377 |
| 2378 CALLBACK_FUNC_DECL(ConsoleDirxml) { | 2378 CALLBACK_FUNC_DECL(ConsoleDirxml) { |
| 2379 INC_STATS(L"DOM.Console.dirxml()"); | 2379 INC_STATS("DOM.Console.dirxml()"); |
| 2380 V8Proxy::SetDOMException(NOT_SUPPORTED_ERR); | 2380 V8Proxy::SetDOMException(NOT_SUPPORTED_ERR); |
| 2381 return v8::Undefined(); | 2381 return v8::Undefined(); |
| 2382 } | 2382 } |
| 2383 | 2383 |
| 2384 CALLBACK_FUNC_DECL(ConsoleTrace) { | 2384 CALLBACK_FUNC_DECL(ConsoleTrace) { |
| 2385 INC_STATS(L"DOM.Console.trace()"); | 2385 INC_STATS("DOM.Console.trace()"); |
| 2386 V8Proxy::SetDOMException(NOT_SUPPORTED_ERR); | 2386 V8Proxy::SetDOMException(NOT_SUPPORTED_ERR); |
| 2387 return v8::Undefined(); | 2387 return v8::Undefined(); |
| 2388 } | 2388 } |
| 2389 | 2389 |
| 2390 | 2390 |
| 2391 // Clipboard ------------------------------------------------------------------- | 2391 // Clipboard ------------------------------------------------------------------- |
| 2392 | 2392 |
| 2393 | 2393 |
| 2394 ACCESSOR_GETTER(ClipboardTypes) { | 2394 ACCESSOR_GETTER(ClipboardTypes) { |
| 2395 INC_STATS(L"DOM.Clipboard.types()"); | 2395 INC_STATS("DOM.Clipboard.types()"); |
| 2396 Clipboard* imp = | 2396 Clipboard* imp = |
| 2397 V8Proxy::ToNativeObject<Clipboard>(V8ClassIndex::CLIPBOARD, | 2397 V8Proxy::ToNativeObject<Clipboard>(V8ClassIndex::CLIPBOARD, |
| 2398 info.Holder()); | 2398 info.Holder()); |
| 2399 | 2399 |
| 2400 HashSet<String> types = imp->types(); | 2400 HashSet<String> types = imp->types(); |
| 2401 if (types.isEmpty()) | 2401 if (types.isEmpty()) |
| 2402 return v8::Null(); | 2402 return v8::Null(); |
| 2403 | 2403 |
| 2404 v8::Local<v8::Array> result = v8::Array::New(types.size()); | 2404 v8::Local<v8::Array> result = v8::Array::New(types.size()); |
| 2405 HashSet<String>::const_iterator end = types.end(); | 2405 HashSet<String>::const_iterator end = types.end(); |
| 2406 int index = 0; | 2406 int index = 0; |
| 2407 for (HashSet<String>::const_iterator it = types.begin(); | 2407 for (HashSet<String>::const_iterator it = types.begin(); |
| 2408 it != end; | 2408 it != end; |
| 2409 ++it, ++index) { | 2409 ++it, ++index) { |
| 2410 result->Set(v8::Integer::New(index), v8String(*it)); | 2410 result->Set(v8::Integer::New(index), v8String(*it)); |
| 2411 } | 2411 } |
| 2412 return result; | 2412 return result; |
| 2413 } | 2413 } |
| 2414 | 2414 |
| 2415 | 2415 |
| 2416 CALLBACK_FUNC_DECL(ClipboardClearData) { | 2416 CALLBACK_FUNC_DECL(ClipboardClearData) { |
| 2417 INC_STATS(L"DOM.Clipboard.clearData()"); | 2417 INC_STATS("DOM.Clipboard.clearData()"); |
| 2418 Clipboard* imp = V8Proxy::ToNativeObject<Clipboard>( | 2418 Clipboard* imp = V8Proxy::ToNativeObject<Clipboard>( |
| 2419 V8ClassIndex::CLIPBOARD, args.Holder()); | 2419 V8ClassIndex::CLIPBOARD, args.Holder()); |
| 2420 | 2420 |
| 2421 if (args.Length() == 0) { | 2421 if (args.Length() == 0) { |
| 2422 imp->clearAllData(); | 2422 imp->clearAllData(); |
| 2423 return v8::Undefined(); | 2423 return v8::Undefined(); |
| 2424 } | 2424 } |
| 2425 | 2425 |
| 2426 if (args.Length() == 1) { | 2426 if (args.Length() == 1) { |
| 2427 String v = ToWebCoreString(args[0]); | 2427 String v = ToWebCoreString(args[0]); |
| 2428 imp->clearData(v); | 2428 imp->clearData(v); |
| 2429 return v8::Undefined(); | 2429 return v8::Undefined(); |
| 2430 } | 2430 } |
| 2431 | 2431 |
| 2432 V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, | 2432 V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, |
| 2433 "clearData: Invalid number of arguments"); | 2433 "clearData: Invalid number of arguments"); |
| 2434 return v8::Undefined(); | 2434 return v8::Undefined(); |
| 2435 } | 2435 } |
| 2436 | 2436 |
| 2437 | 2437 |
| 2438 CALLBACK_FUNC_DECL(ClipboardGetData) { | 2438 CALLBACK_FUNC_DECL(ClipboardGetData) { |
| 2439 INC_STATS(L"DOM.Clipboard.getData()"); | 2439 INC_STATS("DOM.Clipboard.getData()"); |
| 2440 Clipboard* imp = V8Proxy::ToNativeObject<Clipboard>( | 2440 Clipboard* imp = V8Proxy::ToNativeObject<Clipboard>( |
| 2441 V8ClassIndex::CLIPBOARD, args.Holder()); | 2441 V8ClassIndex::CLIPBOARD, args.Holder()); |
| 2442 | 2442 |
| 2443 if (args.Length() != 1) { | 2443 if (args.Length() != 1) { |
| 2444 V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, | 2444 V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, |
| 2445 "getData: Invalid number of arguments"); | 2445 "getData: Invalid number of arguments"); |
| 2446 return v8::Undefined(); | 2446 return v8::Undefined(); |
| 2447 } | 2447 } |
| 2448 | 2448 |
| 2449 bool success; | 2449 bool success; |
| 2450 String v = ToWebCoreString(args[0]); | 2450 String v = ToWebCoreString(args[0]); |
| 2451 String result = imp->getData(v, success); | 2451 String result = imp->getData(v, success); |
| 2452 if (success) return v8String(result); | 2452 if (success) return v8String(result); |
| 2453 return v8::Undefined(); | 2453 return v8::Undefined(); |
| 2454 } | 2454 } |
| 2455 | 2455 |
| 2456 CALLBACK_FUNC_DECL(ClipboardSetData) { | 2456 CALLBACK_FUNC_DECL(ClipboardSetData) { |
| 2457 INC_STATS(L"DOM.Clipboard.setData()"); | 2457 INC_STATS("DOM.Clipboard.setData()"); |
| 2458 Clipboard* imp = V8Proxy::ToNativeObject<Clipboard>( | 2458 Clipboard* imp = V8Proxy::ToNativeObject<Clipboard>( |
| 2459 V8ClassIndex::CLIPBOARD, args.Holder()); | 2459 V8ClassIndex::CLIPBOARD, args.Holder()); |
| 2460 | 2460 |
| 2461 if (args.Length() != 2) { | 2461 if (args.Length() != 2) { |
| 2462 V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, | 2462 V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, |
| 2463 "setData: Invalid number of arguments"); | 2463 "setData: Invalid number of arguments"); |
| 2464 return v8::Undefined(); | 2464 return v8::Undefined(); |
| 2465 } | 2465 } |
| 2466 | 2466 |
| 2467 String type = ToWebCoreString(args[0]); | 2467 String type = ToWebCoreString(args[0]); |
| 2468 String data = ToWebCoreString(args[1]); | 2468 String data = ToWebCoreString(args[1]); |
| 2469 bool result = imp->setData(type, data); | 2469 bool result = imp->setData(type, data); |
| 2470 return result ? v8::True() : v8::False(); | 2470 return result ? v8::True() : v8::False(); |
| 2471 } | 2471 } |
| 2472 | 2472 |
| 2473 | 2473 |
| 2474 CALLBACK_FUNC_DECL(ClipboardSetDragImage) { | 2474 CALLBACK_FUNC_DECL(ClipboardSetDragImage) { |
| 2475 INC_STATS(L"DOM.Clipboard.setDragImage()"); | 2475 INC_STATS("DOM.Clipboard.setDragImage()"); |
| 2476 Clipboard* imp = V8Proxy::ToNativeObject<Clipboard>( | 2476 Clipboard* imp = V8Proxy::ToNativeObject<Clipboard>( |
| 2477 V8ClassIndex::CLIPBOARD, args.Holder()); | 2477 V8ClassIndex::CLIPBOARD, args.Holder()); |
| 2478 | 2478 |
| 2479 if (!imp->isForDragging()) | 2479 if (!imp->isForDragging()) |
| 2480 return v8::Undefined(); | 2480 return v8::Undefined(); |
| 2481 | 2481 |
| 2482 if (args.Length() != 3) { | 2482 if (args.Length() != 3) { |
| 2483 V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, | 2483 V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, |
| 2484 "setDragImage: Invalid number of arguments"); | 2484 "setDragImage: Invalid number of arguments"); |
| 2485 return v8::Undefined(); | 2485 return v8::Undefined(); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2545 if (contentDoc && !V8Proxy::CheckNodeSecurity(contentDoc)) | 2545 if (contentDoc && !V8Proxy::CheckNodeSecurity(contentDoc)) |
| 2546 return false; | 2546 return false; |
| 2547 } | 2547 } |
| 2548 return true; | 2548 return true; |
| 2549 } | 2549 } |
| 2550 | 2550 |
| 2551 | 2551 |
| 2552 // Element --------------------------------------------------------------------- | 2552 // Element --------------------------------------------------------------------- |
| 2553 | 2553 |
| 2554 CALLBACK_FUNC_DECL(ElementSetAttribute) { | 2554 CALLBACK_FUNC_DECL(ElementSetAttribute) { |
| 2555 INC_STATS(L"DOM.Element.setAttribute()"); | 2555 INC_STATS("DOM.Element.setAttribute()"); |
| 2556 Element* imp = V8Proxy::DOMWrapperToNode<Element>(args.Holder()); | 2556 Element* imp = V8Proxy::DOMWrapperToNode<Element>(args.Holder()); |
| 2557 ExceptionCode ec = 0; | 2557 ExceptionCode ec = 0; |
| 2558 String name = ToWebCoreString(args[0]); | 2558 String name = ToWebCoreString(args[0]); |
| 2559 String value = ToWebCoreString(args[1]); | 2559 String value = ToWebCoreString(args[1]); |
| 2560 | 2560 |
| 2561 if (!AllowSettingSrcToJavascriptURL(imp, name, value)) { | 2561 if (!AllowSettingSrcToJavascriptURL(imp, name, value)) { |
| 2562 return v8::Undefined(); | 2562 return v8::Undefined(); |
| 2563 } | 2563 } |
| 2564 | 2564 |
| 2565 imp->setAttribute(name, value, ec); | 2565 imp->setAttribute(name, value, ec); |
| 2566 if (ec != 0) { | 2566 if (ec != 0) { |
| 2567 V8Proxy::SetDOMException(ec); | 2567 V8Proxy::SetDOMException(ec); |
| 2568 return v8::Handle<v8::Value>(); | 2568 return v8::Handle<v8::Value>(); |
| 2569 } | 2569 } |
| 2570 return v8::Undefined(); | 2570 return v8::Undefined(); |
| 2571 } | 2571 } |
| 2572 | 2572 |
| 2573 CALLBACK_FUNC_DECL(ElementSetAttributeNode) { | 2573 CALLBACK_FUNC_DECL(ElementSetAttributeNode) { |
| 2574 INC_STATS(L"DOM.Element.setAttributeNode()"); | 2574 INC_STATS("DOM.Element.setAttributeNode()"); |
| 2575 if (!V8Attr::HasInstance(args[0])) { | 2575 if (!V8Attr::HasInstance(args[0])) { |
| 2576 V8Proxy::SetDOMException(TYPE_MISMATCH_ERR); | 2576 V8Proxy::SetDOMException(TYPE_MISMATCH_ERR); |
| 2577 return v8::Handle<v8::Value>(); | 2577 return v8::Handle<v8::Value>(); |
| 2578 } | 2578 } |
| 2579 | 2579 |
| 2580 Attr* newAttr = V8Proxy::DOMWrapperToNode<Attr>(args[0]); | 2580 Attr* newAttr = V8Proxy::DOMWrapperToNode<Attr>(args[0]); |
| 2581 Element* imp = V8Proxy::DOMWrapperToNode<Element>(args.Holder()); | 2581 Element* imp = V8Proxy::DOMWrapperToNode<Element>(args.Holder()); |
| 2582 ExceptionCode ec = 0; | 2582 ExceptionCode ec = 0; |
| 2583 | 2583 |
| 2584 if (!AllowSettingSrcToJavascriptURL(imp, newAttr->name(), newAttr->value())) { | 2584 if (!AllowSettingSrcToJavascriptURL(imp, newAttr->name(), newAttr->value())) { |
| 2585 return v8::Undefined(); | 2585 return v8::Undefined(); |
| 2586 } | 2586 } |
| 2587 | 2587 |
| 2588 RefPtr<Attr> result = imp->setAttributeNode(newAttr, ec); | 2588 RefPtr<Attr> result = imp->setAttributeNode(newAttr, ec); |
| 2589 if (ec != 0) { | 2589 if (ec != 0) { |
| 2590 V8Proxy::SetDOMException(ec); | 2590 V8Proxy::SetDOMException(ec); |
| 2591 return v8::Handle<v8::Value>(); | 2591 return v8::Handle<v8::Value>(); |
| 2592 } | 2592 } |
| 2593 return V8Proxy::NodeToV8Object(result.get()); | 2593 return V8Proxy::NodeToV8Object(result.get()); |
| 2594 } | 2594 } |
| 2595 | 2595 |
| 2596 CALLBACK_FUNC_DECL(ElementSetAttributeNS) { | 2596 CALLBACK_FUNC_DECL(ElementSetAttributeNS) { |
| 2597 INC_STATS(L"DOM.Element.setAttributeNS()"); | 2597 INC_STATS("DOM.Element.setAttributeNS()"); |
| 2598 Element* imp = V8Proxy::DOMWrapperToNode<Element>(args.Holder()); | 2598 Element* imp = V8Proxy::DOMWrapperToNode<Element>(args.Holder()); |
| 2599 ExceptionCode ec = 0; | 2599 ExceptionCode ec = 0; |
| 2600 String namespaceURI = valueToStringWithNullCheck(args[0]); | 2600 String namespaceURI = valueToStringWithNullCheck(args[0]); |
| 2601 String qualifiedName = ToWebCoreString(args[1]); | 2601 String qualifiedName = ToWebCoreString(args[1]); |
| 2602 String value = ToWebCoreString(args[2]); | 2602 String value = ToWebCoreString(args[2]); |
| 2603 | 2603 |
| 2604 if (!AllowSettingSrcToJavascriptURL(imp, qualifiedName, value)) { | 2604 if (!AllowSettingSrcToJavascriptURL(imp, qualifiedName, value)) { |
| 2605 return v8::Undefined(); | 2605 return v8::Undefined(); |
| 2606 } | 2606 } |
| 2607 | 2607 |
| 2608 imp->setAttributeNS(namespaceURI, qualifiedName, value, ec); | 2608 imp->setAttributeNS(namespaceURI, qualifiedName, value, ec); |
| 2609 if (ec != 0) { | 2609 if (ec != 0) { |
| 2610 V8Proxy::SetDOMException(ec); | 2610 V8Proxy::SetDOMException(ec); |
| 2611 return v8::Handle<v8::Value>(); | 2611 return v8::Handle<v8::Value>(); |
| 2612 } | 2612 } |
| 2613 return v8::Undefined(); | 2613 return v8::Undefined(); |
| 2614 } | 2614 } |
| 2615 | 2615 |
| 2616 CALLBACK_FUNC_DECL(ElementSetAttributeNodeNS) { | 2616 CALLBACK_FUNC_DECL(ElementSetAttributeNodeNS) { |
| 2617 INC_STATS(L"DOM.Element.setAttributeNodeNS()"); | 2617 INC_STATS("DOM.Element.setAttributeNodeNS()"); |
| 2618 if (!V8Attr::HasInstance(args[0])) { | 2618 if (!V8Attr::HasInstance(args[0])) { |
| 2619 V8Proxy::SetDOMException(TYPE_MISMATCH_ERR); | 2619 V8Proxy::SetDOMException(TYPE_MISMATCH_ERR); |
| 2620 return v8::Handle<v8::Value>(); | 2620 return v8::Handle<v8::Value>(); |
| 2621 } | 2621 } |
| 2622 | 2622 |
| 2623 Attr* newAttr = V8Proxy::DOMWrapperToNode<Attr>(args[0]); | 2623 Attr* newAttr = V8Proxy::DOMWrapperToNode<Attr>(args[0]); |
| 2624 Element* imp = V8Proxy::DOMWrapperToNode<Element>(args.Holder()); | 2624 Element* imp = V8Proxy::DOMWrapperToNode<Element>(args.Holder()); |
| 2625 ExceptionCode ec = 0; | 2625 ExceptionCode ec = 0; |
| 2626 | 2626 |
| 2627 if (!AllowSettingSrcToJavascriptURL(imp, newAttr->name(), newAttr->value())) { | 2627 if (!AllowSettingSrcToJavascriptURL(imp, newAttr->name(), newAttr->value())) { |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2747 id = imp->installTimeout(action, timeout, single_shot); | 2747 id = imp->installTimeout(action, timeout, single_shot); |
| 2748 } else { | 2748 } else { |
| 2749 // TODO(fqian): what's the right return value if failed. | 2749 // TODO(fqian): what's the right return value if failed. |
| 2750 return v8::Undefined(); | 2750 return v8::Undefined(); |
| 2751 } | 2751 } |
| 2752 return v8::Integer::New(id); | 2752 return v8::Integer::New(id); |
| 2753 } | 2753 } |
| 2754 | 2754 |
| 2755 | 2755 |
| 2756 CALLBACK_FUNC_DECL(DOMWindowSetTimeout) { | 2756 CALLBACK_FUNC_DECL(DOMWindowSetTimeout) { |
| 2757 INC_STATS(L"DOM.DOMWindow.setTimeout()"); | 2757 INC_STATS("DOM.DOMWindow.setTimeout()"); |
| 2758 return WindowSetTimeoutImpl(args, true); | 2758 return WindowSetTimeoutImpl(args, true); |
| 2759 } | 2759 } |
| 2760 | 2760 |
| 2761 | 2761 |
| 2762 CALLBACK_FUNC_DECL(DOMWindowSetInterval) { | 2762 CALLBACK_FUNC_DECL(DOMWindowSetInterval) { |
| 2763 INC_STATS(L"DOM.DOMWindow.setInterval()"); | 2763 INC_STATS("DOM.DOMWindow.setInterval()"); |
| 2764 return WindowSetTimeoutImpl(args, false); | 2764 return WindowSetTimeoutImpl(args, false); |
| 2765 } | 2765 } |
| 2766 | 2766 |
| 2767 | 2767 |
| 2768 // HTMLDocument ---------------------------------------------------------------- | 2768 // HTMLDocument ---------------------------------------------------------------- |
| 2769 | 2769 |
| 2770 // Concatenates "args" to a string. If args is empty, returns empty string. | 2770 // Concatenates "args" to a string. If args is empty, returns empty string. |
| 2771 // Firefox/Safari/IE support non-standard arguments to document.write, ex: | 2771 // Firefox/Safari/IE support non-standard arguments to document.write, ex: |
| 2772 // document.write("a", "b", "c") --> document.write("abc") | 2772 // document.write("a", "b", "c") --> document.write("abc") |
| 2773 // document.write() --> document.write("") | 2773 // document.write() --> document.write("") |
| 2774 static String WriteHelper_GetString(const v8::Arguments& args) { | 2774 static String WriteHelper_GetString(const v8::Arguments& args) { |
| 2775 String str = ""; | 2775 String str = ""; |
| 2776 for (int i = 0; i < args.Length(); ++i) { | 2776 for (int i = 0; i < args.Length(); ++i) { |
| 2777 str += ToWebCoreString(args[i]); | 2777 str += ToWebCoreString(args[i]); |
| 2778 } | 2778 } |
| 2779 return str; | 2779 return str; |
| 2780 } | 2780 } |
| 2781 | 2781 |
| 2782 CALLBACK_FUNC_DECL(HTMLDocumentWrite) { | 2782 CALLBACK_FUNC_DECL(HTMLDocumentWrite) { |
| 2783 INC_STATS(L"DOM.HTMLDocument.write()"); | 2783 INC_STATS("DOM.HTMLDocument.write()"); |
| 2784 HTMLDocument* imp = V8Proxy::DOMWrapperToNode<HTMLDocument>(args.Holder()); | 2784 HTMLDocument* imp = V8Proxy::DOMWrapperToNode<HTMLDocument>(args.Holder()); |
| 2785 Frame* frame = V8Proxy::retrieveActiveFrame(); | 2785 Frame* frame = V8Proxy::retrieveActiveFrame(); |
| 2786 ASSERT(frame); | 2786 ASSERT(frame); |
| 2787 imp->write(WriteHelper_GetString(args), frame->document()); | 2787 imp->write(WriteHelper_GetString(args), frame->document()); |
| 2788 return v8::Undefined(); | 2788 return v8::Undefined(); |
| 2789 } | 2789 } |
| 2790 | 2790 |
| 2791 CALLBACK_FUNC_DECL(HTMLDocumentWriteln) { | 2791 CALLBACK_FUNC_DECL(HTMLDocumentWriteln) { |
| 2792 INC_STATS(L"DOM.HTMLDocument.writeln()"); | 2792 INC_STATS("DOM.HTMLDocument.writeln()"); |
| 2793 HTMLDocument* imp = V8Proxy::DOMWrapperToNode<HTMLDocument>(args.Holder()); | 2793 HTMLDocument* imp = V8Proxy::DOMWrapperToNode<HTMLDocument>(args.Holder()); |
| 2794 Frame* frame = V8Proxy::retrieveActiveFrame(); | 2794 Frame* frame = V8Proxy::retrieveActiveFrame(); |
| 2795 ASSERT(frame); | 2795 ASSERT(frame); |
| 2796 imp->writeln(WriteHelper_GetString(args), frame->document()); | 2796 imp->writeln(WriteHelper_GetString(args), frame->document()); |
| 2797 return v8::Undefined(); | 2797 return v8::Undefined(); |
| 2798 } | 2798 } |
| 2799 | 2799 |
| 2800 CALLBACK_FUNC_DECL(HTMLDocumentOpen) { | 2800 CALLBACK_FUNC_DECL(HTMLDocumentOpen) { |
| 2801 INC_STATS(L"DOM.HTMLDocument.open()"); | 2801 INC_STATS("DOM.HTMLDocument.open()"); |
| 2802 HTMLDocument* imp = V8Proxy::DOMWrapperToNode<HTMLDocument>(args.Holder()); | 2802 HTMLDocument* imp = V8Proxy::DOMWrapperToNode<HTMLDocument>(args.Holder()); |
| 2803 | 2803 |
| 2804 if (args.Length() > 2) { | 2804 if (args.Length() > 2) { |
| 2805 if (Frame* frame = imp->frame()) { | 2805 if (Frame* frame = imp->frame()) { |
| 2806 // Fetch the global object for the frame. | 2806 // Fetch the global object for the frame. |
| 2807 v8::Local<v8::Context> context = V8Proxy::GetContext(frame); | 2807 v8::Local<v8::Context> context = V8Proxy::GetContext(frame); |
| 2808 // Bail out if we cannot get the context. | 2808 // Bail out if we cannot get the context. |
| 2809 if (context.IsEmpty()) return v8::Undefined(); | 2809 if (context.IsEmpty()) return v8::Undefined(); |
| 2810 v8::Local<v8::Object> global = context->Global(); | 2810 v8::Local<v8::Object> global = context->Global(); |
| 2811 // Get the open property of the global object. | 2811 // Get the open property of the global object. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2833 } | 2833 } |
| 2834 | 2834 |
| 2835 Frame* frame = V8Proxy::retrieveActiveFrame(); | 2835 Frame* frame = V8Proxy::retrieveActiveFrame(); |
| 2836 imp->open(frame->document()); | 2836 imp->open(frame->document()); |
| 2837 return v8::Undefined(); | 2837 return v8::Undefined(); |
| 2838 } | 2838 } |
| 2839 | 2839 |
| 2840 // Document -------------------------------------------------------------------- | 2840 // Document -------------------------------------------------------------------- |
| 2841 | 2841 |
| 2842 CALLBACK_FUNC_DECL(DocumentEvaluate) { | 2842 CALLBACK_FUNC_DECL(DocumentEvaluate) { |
| 2843 INC_STATS(L"DOM.Document.evaluate()"); | 2843 INC_STATS("DOM.Document.evaluate()"); |
| 2844 | 2844 |
| 2845 Document* imp = V8Proxy::DOMWrapperToNode<Document>(args.Holder()); | 2845 Document* imp = V8Proxy::DOMWrapperToNode<Document>(args.Holder()); |
| 2846 ExceptionCode ec = 0; | 2846 ExceptionCode ec = 0; |
| 2847 String expression = ToWebCoreString(args[0]); | 2847 String expression = ToWebCoreString(args[0]); |
| 2848 Node* contextNode = NULL; | 2848 Node* contextNode = NULL; |
| 2849 if (V8Node::HasInstance(args[1])) { | 2849 if (V8Node::HasInstance(args[1])) { |
| 2850 contextNode = V8Proxy::DOMWrapperToNode<Node>(args[1]); | 2850 contextNode = V8Proxy::DOMWrapperToNode<Node>(args[1]); |
| 2851 } | 2851 } |
| 2852 // Find the XPath | 2852 // Find the XPath |
| 2853 XPathNSResolver* resolver = NULL; | 2853 XPathNSResolver* resolver = NULL; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2908 if (!base64Decode(in, out)) { | 2908 if (!base64Decode(in, out)) { |
| 2909 V8Proxy::ThrowError(V8Proxy::GENERAL_ERROR, "Cannot decode base64"); | 2909 V8Proxy::ThrowError(V8Proxy::GENERAL_ERROR, "Cannot decode base64"); |
| 2910 return v8::Undefined(); | 2910 return v8::Undefined(); |
| 2911 } | 2911 } |
| 2912 } | 2912 } |
| 2913 | 2913 |
| 2914 return v8String(String(out.data(), out.size())); | 2914 return v8String(String(out.data(), out.size())); |
| 2915 } | 2915 } |
| 2916 | 2916 |
| 2917 CALLBACK_FUNC_DECL(DOMWindowAtob) { | 2917 CALLBACK_FUNC_DECL(DOMWindowAtob) { |
| 2918 INC_STATS(L"DOM.DOMWindow.atob()"); | 2918 INC_STATS("DOM.DOMWindow.atob()"); |
| 2919 DOMWindow* imp = V8Proxy::ToNativeObject<DOMWindow>( | 2919 DOMWindow* imp = V8Proxy::ToNativeObject<DOMWindow>( |
| 2920 V8ClassIndex::DOMWINDOW, args.Holder()); | 2920 V8ClassIndex::DOMWINDOW, args.Holder()); |
| 2921 | 2921 |
| 2922 if (!V8Proxy::CanAccessFrame(imp->frame(), true)) | 2922 if (!V8Proxy::CanAccessFrame(imp->frame(), true)) |
| 2923 return v8::Undefined(); | 2923 return v8::Undefined(); |
| 2924 | 2924 |
| 2925 if (args.Length() < 1) { | 2925 if (args.Length() < 1) { |
| 2926 V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, "Not enough arguments"); | 2926 V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, "Not enough arguments"); |
| 2927 return v8::Undefined(); | 2927 return v8::Undefined(); |
| 2928 } | 2928 } |
| 2929 | 2929 |
| 2930 if (args[0]->IsNull()) return v8String(""); | 2930 if (args[0]->IsNull()) return v8String(""); |
| 2931 | 2931 |
| 2932 String str = ToWebCoreString(args[0]); | 2932 String str = ToWebCoreString(args[0]); |
| 2933 return Base64Convert(str, false); | 2933 return Base64Convert(str, false); |
| 2934 } | 2934 } |
| 2935 | 2935 |
| 2936 CALLBACK_FUNC_DECL(DOMWindowBtoa) { | 2936 CALLBACK_FUNC_DECL(DOMWindowBtoa) { |
| 2937 INC_STATS(L"DOM.DOMWindow.btoa()"); | 2937 INC_STATS("DOM.DOMWindow.btoa()"); |
| 2938 DOMWindow* imp = V8Proxy::ToNativeObject<DOMWindow>( | 2938 DOMWindow* imp = V8Proxy::ToNativeObject<DOMWindow>( |
| 2939 V8ClassIndex::DOMWINDOW, args.Holder()); | 2939 V8ClassIndex::DOMWINDOW, args.Holder()); |
| 2940 | 2940 |
| 2941 if (!V8Proxy::CanAccessFrame(imp->frame(), true)) | 2941 if (!V8Proxy::CanAccessFrame(imp->frame(), true)) |
| 2942 return v8::Undefined(); | 2942 return v8::Undefined(); |
| 2943 | 2943 |
| 2944 if (args.Length() < 1) { | 2944 if (args.Length() < 1) { |
| 2945 V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, "Not enough arguments"); | 2945 V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, "Not enough arguments"); |
| 2946 return v8::Undefined(); | 2946 return v8::Undefined(); |
| 2947 } | 2947 } |
| 2948 | 2948 |
| 2949 if (args[0]->IsNull()) return v8String(""); | 2949 if (args[0]->IsNull()) return v8String(""); |
| 2950 | 2950 |
| 2951 String str = ToWebCoreString(args[0]); | 2951 String str = ToWebCoreString(args[0]); |
| 2952 return Base64Convert(str, true); | 2952 return Base64Convert(str, true); |
| 2953 } | 2953 } |
| 2954 | 2954 |
| 2955 // TODO(fqian): returning string is cheating, and we should | 2955 // TODO(fqian): returning string is cheating, and we should |
| 2956 // fix this by calling toString function on the receiver. | 2956 // fix this by calling toString function on the receiver. |
| 2957 // However, V8 implements toString in JavaScript, which requires | 2957 // However, V8 implements toString in JavaScript, which requires |
| 2958 // switching context of receiver. I consider it is dangerous. | 2958 // switching context of receiver. I consider it is dangerous. |
| 2959 CALLBACK_FUNC_DECL(DOMWindowToString) | 2959 CALLBACK_FUNC_DECL(DOMWindowToString) |
| 2960 { | 2960 { |
| 2961 INC_STATS(L"DOM.DOMWindow.toString()"); | 2961 INC_STATS("DOM.DOMWindow.toString()"); |
| 2962 return args.This()->ObjectProtoToString(); | 2962 return args.This()->ObjectProtoToString(); |
| 2963 } | 2963 } |
| 2964 | 2964 |
| 2965 CALLBACK_FUNC_DECL(DOMWindowNOP) | 2965 CALLBACK_FUNC_DECL(DOMWindowNOP) |
| 2966 { | 2966 { |
| 2967 INC_STATS(L"DOM.DOMWindow.nop()"); | 2967 INC_STATS("DOM.DOMWindow.nop()"); |
| 2968 return v8::Undefined(); | 2968 return v8::Undefined(); |
| 2969 } | 2969 } |
| 2970 | 2970 |
| 2971 | 2971 |
| 2972 // EventTargetNode ------------------------------------------------------------- | 2972 // EventTargetNode ------------------------------------------------------------- |
| 2973 | 2973 |
| 2974 CALLBACK_FUNC_DECL(EventTargetNodeAddEventListener) { | 2974 CALLBACK_FUNC_DECL(EventTargetNodeAddEventListener) { |
| 2975 INC_STATS(L"DOM.EventTargetNode.addEventListener()"); | 2975 INC_STATS("DOM.EventTargetNode.addEventListener()"); |
| 2976 EventTargetNode* node = | 2976 EventTargetNode* node = |
| 2977 V8Proxy::DOMWrapperToNode<EventTargetNode>(args.Holder()); | 2977 V8Proxy::DOMWrapperToNode<EventTargetNode>(args.Holder()); |
| 2978 | 2978 |
| 2979 V8Proxy* proxy = V8Proxy::retrieve(node->document()->frame()); | 2979 V8Proxy* proxy = V8Proxy::retrieve(node->document()->frame()); |
| 2980 if (!proxy) | 2980 if (!proxy) |
| 2981 return v8::Undefined(); | 2981 return v8::Undefined(); |
| 2982 | 2982 |
| 2983 RefPtr<EventListener> listener = | 2983 RefPtr<EventListener> listener = |
| 2984 proxy->FindOrCreateV8EventListener(args[1], false); | 2984 proxy->FindOrCreateV8EventListener(args[1], false); |
| 2985 if (listener) { | 2985 if (listener) { |
| 2986 String type = ToWebCoreString(args[0]); | 2986 String type = ToWebCoreString(args[0]); |
| 2987 bool useCapture = args[2]->BooleanValue(); | 2987 bool useCapture = args[2]->BooleanValue(); |
| 2988 node->addEventListener(type, listener, useCapture); | 2988 node->addEventListener(type, listener, useCapture); |
| 2989 } | 2989 } |
| 2990 return v8::Undefined(); | 2990 return v8::Undefined(); |
| 2991 } | 2991 } |
| 2992 | 2992 |
| 2993 CALLBACK_FUNC_DECL(EventTargetNodeRemoveEventListener) { | 2993 CALLBACK_FUNC_DECL(EventTargetNodeRemoveEventListener) { |
| 2994 INC_STATS(L"DOM.EventTargetNode.removeEventListener()"); | 2994 INC_STATS("DOM.EventTargetNode.removeEventListener()"); |
| 2995 EventTargetNode* node = | 2995 EventTargetNode* node = |
| 2996 V8Proxy::DOMWrapperToNode<EventTargetNode>(args.Holder()); | 2996 V8Proxy::DOMWrapperToNode<EventTargetNode>(args.Holder()); |
| 2997 | 2997 |
| 2998 V8Proxy* proxy = V8Proxy::retrieve(node->document()->frame()); | 2998 V8Proxy* proxy = V8Proxy::retrieve(node->document()->frame()); |
| 2999 // It is possbile that the owner document of the node is detached | 2999 // It is possbile that the owner document of the node is detached |
| 3000 // from the frame, return immediately in this case. | 3000 // from the frame, return immediately in this case. |
| 3001 // See issue 878909 | 3001 // See issue 878909 |
| 3002 if (!proxy) | 3002 if (!proxy) |
| 3003 return v8::Undefined(); | 3003 return v8::Undefined(); |
| 3004 | 3004 |
| 3005 RefPtr<EventListener> listener = | 3005 RefPtr<EventListener> listener = |
| 3006 proxy->FindV8EventListener(args[1], false); | 3006 proxy->FindV8EventListener(args[1], false); |
| 3007 if (listener) { | 3007 if (listener) { |
| 3008 String type = ToWebCoreString(args[0]); | 3008 String type = ToWebCoreString(args[0]); |
| 3009 bool useCapture = args[2]->BooleanValue(); | 3009 bool useCapture = args[2]->BooleanValue(); |
| 3010 node->removeEventListener(type, listener.get(), useCapture); | 3010 node->removeEventListener(type, listener.get(), useCapture); |
| 3011 } | 3011 } |
| 3012 | 3012 |
| 3013 return v8::Undefined(); | 3013 return v8::Undefined(); |
| 3014 } | 3014 } |
| 3015 | 3015 |
| 3016 | 3016 |
| 3017 // Navigator ------------------------------------------------------------------ | 3017 // Navigator ------------------------------------------------------------------ |
| 3018 ACCESSOR_GETTER(NavigatorAppVersion) { | 3018 ACCESSOR_GETTER(NavigatorAppVersion) { |
| 3019 INC_STATS(L"DOM.Navigator.appVersion"); | 3019 INC_STATS("DOM.Navigator.appVersion"); |
| 3020 v8::Handle<v8::Object> holder = info.Holder(); | 3020 v8::Handle<v8::Object> holder = info.Holder(); |
| 3021 Navigator* imp = V8Proxy::ToNativeObject<Navigator>(V8ClassIndex::NAVIGATOR, | 3021 Navigator* imp = V8Proxy::ToNativeObject<Navigator>(V8ClassIndex::NAVIGATOR, |
| 3022 holder); | 3022 holder); |
| 3023 String v = ToString(imp->appVersion()); | 3023 String v = ToString(imp->appVersion()); |
| 3024 return v8StringOrUndefined(v); | 3024 return v8StringOrUndefined(v); |
| 3025 } | 3025 } |
| 3026 | 3026 |
| 3027 | 3027 |
| 3028 // TreeWalker ------------------------------------------------------------------ | 3028 // TreeWalker ------------------------------------------------------------------ |
| 3029 | 3029 |
| 3030 CALLBACK_FUNC_DECL(TreeWalkerParentNode) { | 3030 CALLBACK_FUNC_DECL(TreeWalkerParentNode) { |
| 3031 INC_STATS(L"DOM.TreeWalker.parentNode()"); | 3031 INC_STATS("DOM.TreeWalker.parentNode()"); |
| 3032 TreeWalker* treeWalker = V8Proxy::ToNativeObject<TreeWalker>( | 3032 TreeWalker* treeWalker = V8Proxy::ToNativeObject<TreeWalker>( |
| 3033 V8ClassIndex::TREEWALKER, args.Holder()); | 3033 V8ClassIndex::TREEWALKER, args.Holder()); |
| 3034 | 3034 |
| 3035 JSC::ExecState exec; | 3035 JSC::ExecState exec; |
| 3036 RefPtr<Node> result = treeWalker->parentNode(&exec); | 3036 RefPtr<Node> result = treeWalker->parentNode(&exec); |
| 3037 if (exec.hadException()) { | 3037 if (exec.hadException()) { |
| 3038 v8::ThrowException(exec.exception()); | 3038 v8::ThrowException(exec.exception()); |
| 3039 return v8::Undefined(); | 3039 return v8::Undefined(); |
| 3040 } | 3040 } |
| 3041 if (!result) return v8::Null(); | 3041 if (!result) return v8::Null(); |
| 3042 return V8Proxy::NodeToV8Object(result.get()); | 3042 return V8Proxy::NodeToV8Object(result.get()); |
| 3043 } | 3043 } |
| 3044 | 3044 |
| 3045 CALLBACK_FUNC_DECL(TreeWalkerFirstChild) { | 3045 CALLBACK_FUNC_DECL(TreeWalkerFirstChild) { |
| 3046 INC_STATS(L"DOM.TreeWalker.firstChild()"); | 3046 INC_STATS("DOM.TreeWalker.firstChild()"); |
| 3047 TreeWalker* treeWalker = V8Proxy::ToNativeObject<TreeWalker>( | 3047 TreeWalker* treeWalker = V8Proxy::ToNativeObject<TreeWalker>( |
| 3048 V8ClassIndex::TREEWALKER, args.Holder()); | 3048 V8ClassIndex::TREEWALKER, args.Holder()); |
| 3049 | 3049 |
| 3050 JSC::ExecState exec; | 3050 JSC::ExecState exec; |
| 3051 RefPtr<Node> result = treeWalker->firstChild(&exec); | 3051 RefPtr<Node> result = treeWalker->firstChild(&exec); |
| 3052 if (exec.hadException()) { | 3052 if (exec.hadException()) { |
| 3053 v8::ThrowException(exec.exception()); | 3053 v8::ThrowException(exec.exception()); |
| 3054 return v8::Undefined(); | 3054 return v8::Undefined(); |
| 3055 } | 3055 } |
| 3056 if (!result) return v8::Null(); | 3056 if (!result) return v8::Null(); |
| 3057 return V8Proxy::NodeToV8Object(result.get()); | 3057 return V8Proxy::NodeToV8Object(result.get()); |
| 3058 } | 3058 } |
| 3059 | 3059 |
| 3060 CALLBACK_FUNC_DECL(TreeWalkerLastChild) { | 3060 CALLBACK_FUNC_DECL(TreeWalkerLastChild) { |
| 3061 INC_STATS(L"DOM.TreeWalker.lastChild()"); | 3061 INC_STATS("DOM.TreeWalker.lastChild()"); |
| 3062 TreeWalker* treeWalker = V8Proxy::ToNativeObject<TreeWalker>( | 3062 TreeWalker* treeWalker = V8Proxy::ToNativeObject<TreeWalker>( |
| 3063 V8ClassIndex::TREEWALKER, args.Holder()); | 3063 V8ClassIndex::TREEWALKER, args.Holder()); |
| 3064 | 3064 |
| 3065 JSC::ExecState exec; | 3065 JSC::ExecState exec; |
| 3066 RefPtr<Node> result = treeWalker->lastChild(&exec); | 3066 RefPtr<Node> result = treeWalker->lastChild(&exec); |
| 3067 if (exec.hadException()) { | 3067 if (exec.hadException()) { |
| 3068 v8::ThrowException(exec.exception()); | 3068 v8::ThrowException(exec.exception()); |
| 3069 return v8::Undefined(); | 3069 return v8::Undefined(); |
| 3070 } | 3070 } |
| 3071 if (!result) return v8::Null(); | 3071 if (!result) return v8::Null(); |
| 3072 return V8Proxy::NodeToV8Object(result.get()); | 3072 return V8Proxy::NodeToV8Object(result.get()); |
| 3073 } | 3073 } |
| 3074 | 3074 |
| 3075 CALLBACK_FUNC_DECL(TreeWalkerNextNode) { | 3075 CALLBACK_FUNC_DECL(TreeWalkerNextNode) { |
| 3076 INC_STATS(L"DOM.TreeWalker.nextNode()"); | 3076 INC_STATS("DOM.TreeWalker.nextNode()"); |
| 3077 TreeWalker* treeWalker = V8Proxy::ToNativeObject<TreeWalker>( | 3077 TreeWalker* treeWalker = V8Proxy::ToNativeObject<TreeWalker>( |
| 3078 V8ClassIndex::TREEWALKER, args.Holder()); | 3078 V8ClassIndex::TREEWALKER, args.Holder()); |
| 3079 | 3079 |
| 3080 JSC::ExecState exec; | 3080 JSC::ExecState exec; |
| 3081 RefPtr<Node> result = treeWalker->nextNode(&exec); | 3081 RefPtr<Node> result = treeWalker->nextNode(&exec); |
| 3082 if (exec.hadException()) { | 3082 if (exec.hadException()) { |
| 3083 v8::ThrowException(exec.exception()); | 3083 v8::ThrowException(exec.exception()); |
| 3084 return v8::Undefined(); | 3084 return v8::Undefined(); |
| 3085 } | 3085 } |
| 3086 if (!result) return v8::Null(); | 3086 if (!result) return v8::Null(); |
| 3087 return V8Proxy::NodeToV8Object(result.get()); | 3087 return V8Proxy::NodeToV8Object(result.get()); |
| 3088 } | 3088 } |
| 3089 | 3089 |
| 3090 CALLBACK_FUNC_DECL(TreeWalkerPreviousNode) { | 3090 CALLBACK_FUNC_DECL(TreeWalkerPreviousNode) { |
| 3091 INC_STATS(L"DOM.TreeWalker.previousNode()"); | 3091 INC_STATS("DOM.TreeWalker.previousNode()"); |
| 3092 TreeWalker* treeWalker = V8Proxy::ToNativeObject<TreeWalker>( | 3092 TreeWalker* treeWalker = V8Proxy::ToNativeObject<TreeWalker>( |
| 3093 V8ClassIndex::TREEWALKER, args.Holder()); | 3093 V8ClassIndex::TREEWALKER, args.Holder()); |
| 3094 | 3094 |
| 3095 JSC::ExecState exec; | 3095 JSC::ExecState exec; |
| 3096 RefPtr<Node> result = treeWalker->previousNode(&exec); | 3096 RefPtr<Node> result = treeWalker->previousNode(&exec); |
| 3097 if (exec.hadException()) { | 3097 if (exec.hadException()) { |
| 3098 v8::ThrowException(exec.exception()); | 3098 v8::ThrowException(exec.exception()); |
| 3099 return v8::Undefined(); | 3099 return v8::Undefined(); |
| 3100 } | 3100 } |
| 3101 if (!result) return v8::Null(); | 3101 if (!result) return v8::Null(); |
| 3102 return V8Proxy::NodeToV8Object(result.get()); | 3102 return V8Proxy::NodeToV8Object(result.get()); |
| 3103 } | 3103 } |
| 3104 | 3104 |
| 3105 CALLBACK_FUNC_DECL(TreeWalkerNextSibling) { | 3105 CALLBACK_FUNC_DECL(TreeWalkerNextSibling) { |
| 3106 INC_STATS(L"DOM.TreeWalker.nextSibling()"); | 3106 INC_STATS("DOM.TreeWalker.nextSibling()"); |
| 3107 TreeWalker* treeWalker = V8Proxy::ToNativeObject<TreeWalker>( | 3107 TreeWalker* treeWalker = V8Proxy::ToNativeObject<TreeWalker>( |
| 3108 V8ClassIndex::TREEWALKER, args.Holder()); | 3108 V8ClassIndex::TREEWALKER, args.Holder()); |
| 3109 | 3109 |
| 3110 JSC::ExecState exec; | 3110 JSC::ExecState exec; |
| 3111 RefPtr<Node> result = treeWalker->nextSibling(&exec); | 3111 RefPtr<Node> result = treeWalker->nextSibling(&exec); |
| 3112 if (exec.hadException()) { | 3112 if (exec.hadException()) { |
| 3113 v8::ThrowException(exec.exception()); | 3113 v8::ThrowException(exec.exception()); |
| 3114 return v8::Undefined(); | 3114 return v8::Undefined(); |
| 3115 } | 3115 } |
| 3116 if (!result) return v8::Null(); | 3116 if (!result) return v8::Null(); |
| 3117 return V8Proxy::NodeToV8Object(result.get()); | 3117 return V8Proxy::NodeToV8Object(result.get()); |
| 3118 } | 3118 } |
| 3119 | 3119 |
| 3120 CALLBACK_FUNC_DECL(TreeWalkerPreviousSibling) { | 3120 CALLBACK_FUNC_DECL(TreeWalkerPreviousSibling) { |
| 3121 INC_STATS(L"DOM.TreeWalker.previousSibling()"); | 3121 INC_STATS("DOM.TreeWalker.previousSibling()"); |
| 3122 TreeWalker* treeWalker = V8Proxy::ToNativeObject<TreeWalker>( | 3122 TreeWalker* treeWalker = V8Proxy::ToNativeObject<TreeWalker>( |
| 3123 V8ClassIndex::TREEWALKER, args.Holder()); | 3123 V8ClassIndex::TREEWALKER, args.Holder()); |
| 3124 | 3124 |
| 3125 JSC::ExecState exec; | 3125 JSC::ExecState exec; |
| 3126 RefPtr<Node> result = treeWalker->previousSibling(&exec); | 3126 RefPtr<Node> result = treeWalker->previousSibling(&exec); |
| 3127 if (exec.hadException()) { | 3127 if (exec.hadException()) { |
| 3128 v8::ThrowException(exec.exception()); | 3128 v8::ThrowException(exec.exception()); |
| 3129 return v8::Undefined(); | 3129 return v8::Undefined(); |
| 3130 } | 3130 } |
| 3131 if (!result) return v8::Null(); | 3131 if (!result) return v8::Null(); |
| 3132 return V8Proxy::NodeToV8Object(result.get()); | 3132 return V8Proxy::NodeToV8Object(result.get()); |
| 3133 } | 3133 } |
| 3134 | 3134 |
| 3135 CALLBACK_FUNC_DECL(NodeIteratorNextNode) { | 3135 CALLBACK_FUNC_DECL(NodeIteratorNextNode) { |
| 3136 INC_STATS(L"DOM.NodeIterator.nextNode()"); | 3136 INC_STATS("DOM.NodeIterator.nextNode()"); |
| 3137 NodeIterator* nodeIterator = V8Proxy::ToNativeObject<NodeIterator>( | 3137 NodeIterator* nodeIterator = V8Proxy::ToNativeObject<NodeIterator>( |
| 3138 V8ClassIndex::NODEITERATOR, args.Holder()); | 3138 V8ClassIndex::NODEITERATOR, args.Holder()); |
| 3139 | 3139 |
| 3140 ExceptionCode ec = 0; | 3140 ExceptionCode ec = 0; |
| 3141 JSC::ExecState exec; | 3141 JSC::ExecState exec; |
| 3142 RefPtr<Node> result = nodeIterator->nextNode(&exec, ec); | 3142 RefPtr<Node> result = nodeIterator->nextNode(&exec, ec); |
| 3143 if (ec != 0) { | 3143 if (ec != 0) { |
| 3144 V8Proxy::SetDOMException(ec); | 3144 V8Proxy::SetDOMException(ec); |
| 3145 return v8::Null(); | 3145 return v8::Null(); |
| 3146 } | 3146 } |
| 3147 if (exec.hadException()) { | 3147 if (exec.hadException()) { |
| 3148 v8::ThrowException(exec.exception()); | 3148 v8::ThrowException(exec.exception()); |
| 3149 return v8::Undefined(); | 3149 return v8::Undefined(); |
| 3150 } | 3150 } |
| 3151 if (!result) return v8::Null(); | 3151 if (!result) return v8::Null(); |
| 3152 return V8Proxy::NodeToV8Object(result.get()); | 3152 return V8Proxy::NodeToV8Object(result.get()); |
| 3153 } | 3153 } |
| 3154 | 3154 |
| 3155 CALLBACK_FUNC_DECL(NodeIteratorPreviousNode) { | 3155 CALLBACK_FUNC_DECL(NodeIteratorPreviousNode) { |
| 3156 INC_STATS(L"DOM.NodeIterator.previousNode()"); | 3156 INC_STATS("DOM.NodeIterator.previousNode()"); |
| 3157 NodeIterator* nodeIterator = V8Proxy::ToNativeObject<NodeIterator>( | 3157 NodeIterator* nodeIterator = V8Proxy::ToNativeObject<NodeIterator>( |
| 3158 V8ClassIndex::NODEITERATOR, args.Holder()); | 3158 V8ClassIndex::NODEITERATOR, args.Holder()); |
| 3159 | 3159 |
| 3160 ExceptionCode ec = 0; | 3160 ExceptionCode ec = 0; |
| 3161 JSC::ExecState exec; | 3161 JSC::ExecState exec; |
| 3162 RefPtr<Node> result = nodeIterator->previousNode(&exec, ec); | 3162 RefPtr<Node> result = nodeIterator->previousNode(&exec, ec); |
| 3163 if (ec != 0) { | 3163 if (ec != 0) { |
| 3164 V8Proxy::SetDOMException(ec); | 3164 V8Proxy::SetDOMException(ec); |
| 3165 return v8::Null(); | 3165 return v8::Null(); |
| 3166 } | 3166 } |
| 3167 if (exec.hadException()) { | 3167 if (exec.hadException()) { |
| 3168 v8::ThrowException(exec.exception()); | 3168 v8::ThrowException(exec.exception()); |
| 3169 return v8::Undefined(); | 3169 return v8::Undefined(); |
| 3170 } | 3170 } |
| 3171 if (!result) return v8::Null(); | 3171 if (!result) return v8::Null(); |
| 3172 return V8Proxy::NodeToV8Object(result.get()); | 3172 return V8Proxy::NodeToV8Object(result.get()); |
| 3173 } | 3173 } |
| 3174 | 3174 |
| 3175 CALLBACK_FUNC_DECL(NodeFilterAcceptNode) { | 3175 CALLBACK_FUNC_DECL(NodeFilterAcceptNode) { |
| 3176 INC_STATS(L"DOM.NodeFilter.acceptNode()"); | 3176 INC_STATS("DOM.NodeFilter.acceptNode()"); |
| 3177 V8Proxy::SetDOMException(NOT_SUPPORTED_ERR); | 3177 V8Proxy::SetDOMException(NOT_SUPPORTED_ERR); |
| 3178 return v8::Undefined(); | 3178 return v8::Undefined(); |
| 3179 } | 3179 } |
| 3180 | 3180 |
| 3181 static String EventNameFromAttributeName(const String& name) { | 3181 static String EventNameFromAttributeName(const String& name) { |
| 3182 ASSERT(name.startsWith("on")); | 3182 ASSERT(name.startsWith("on")); |
| 3183 String event_type = name.substring(2); | 3183 String event_type = name.substring(2); |
| 3184 | 3184 |
| 3185 if (event_type.startsWith("w")) { | 3185 if (event_type.startsWith("w")) { |
| 3186 switch(event_type[event_type.length() - 1]) { | 3186 switch(event_type[event_type.length() - 1]) { |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3321 newLength = UINT_MAX; | 3321 newLength = UINT_MAX; |
| 3322 } else { | 3322 } else { |
| 3323 newLength = static_cast<unsigned>(v); | 3323 newLength = static_cast<unsigned>(v); |
| 3324 } | 3324 } |
| 3325 } | 3325 } |
| 3326 if (!ec) imp->setLength(value->Uint32Value(), ec); | 3326 if (!ec) imp->setLength(value->Uint32Value(), ec); |
| 3327 V8Proxy::SetDOMException(ec); | 3327 V8Proxy::SetDOMException(ec); |
| 3328 } | 3328 } |
| 3329 | 3329 |
| 3330 ACCESSOR_GETTER(HTMLInputElementSelectionStart) { | 3330 ACCESSOR_GETTER(HTMLInputElementSelectionStart) { |
| 3331 INC_STATS(L"DOM.HTMLInputElement.selectionStart._get"); | 3331 INC_STATS("DOM.HTMLInputElement.selectionStart._get"); |
| 3332 v8::Handle<v8::Object> holder = info.Holder(); | 3332 v8::Handle<v8::Object> holder = info.Holder(); |
| 3333 HTMLInputElement* imp = V8Proxy::DOMWrapperToNode<HTMLInputElement>(holder); | 3333 HTMLInputElement* imp = V8Proxy::DOMWrapperToNode<HTMLInputElement>(holder); |
| 3334 | 3334 |
| 3335 if (!imp->canHaveSelection()) | 3335 if (!imp->canHaveSelection()) |
| 3336 return v8::Undefined(); | 3336 return v8::Undefined(); |
| 3337 | 3337 |
| 3338 int v = imp->selectionStart(); | 3338 int v = imp->selectionStart(); |
| 3339 return v8::Integer::New(v); | 3339 return v8::Integer::New(v); |
| 3340 } | 3340 } |
| 3341 | 3341 |
| 3342 ACCESSOR_GETTER(HTMLInputElementSelectionEnd) { | 3342 ACCESSOR_GETTER(HTMLInputElementSelectionEnd) { |
| 3343 INC_STATS(L"DOM.HTMLInputElement.selectionEnd._get"); | 3343 INC_STATS("DOM.HTMLInputElement.selectionEnd._get"); |
| 3344 v8::Handle<v8::Object> holder = info.Holder(); | 3344 v8::Handle<v8::Object> holder = info.Holder(); |
| 3345 HTMLInputElement* imp = V8Proxy::DOMWrapperToNode<HTMLInputElement>(holder); | 3345 HTMLInputElement* imp = V8Proxy::DOMWrapperToNode<HTMLInputElement>(holder); |
| 3346 | 3346 |
| 3347 if (!imp->canHaveSelection()) | 3347 if (!imp->canHaveSelection()) |
| 3348 return v8::Undefined(); | 3348 return v8::Undefined(); |
| 3349 | 3349 |
| 3350 int v = imp->selectionEnd(); | 3350 int v = imp->selectionEnd(); |
| 3351 return v8::Integer::New(v); | 3351 return v8::Integer::New(v); |
| 3352 } | 3352 } |
| 3353 | 3353 |
| 3354 #if ENABLE(SVG) | 3354 #if ENABLE(SVG) |
| 3355 | 3355 |
| 3356 ACCESSOR_GETTER(SVGLengthValue) { | 3356 ACCESSOR_GETTER(SVGLengthValue) { |
| 3357 INC_STATS(L"DOM.SVGLength.value"); | 3357 INC_STATS("DOM.SVGLength.value"); |
| 3358 V8SVGPODTypeWrapper<SVGLength>* wrapper = V8Proxy::ToNativeObject<V8SVGPODType
Wrapper<SVGLength> >(V8ClassIndex::SVGLENGTH, info.Holder()); | 3358 V8SVGPODTypeWrapper<SVGLength>* wrapper = V8Proxy::ToNativeObject<V8SVGPODType
Wrapper<SVGLength> >(V8ClassIndex::SVGLENGTH, info.Holder()); |
| 3359 SVGLength imp = *wrapper; | 3359 SVGLength imp = *wrapper; |
| 3360 return v8::Number::New(imp.value(V8Proxy::GetSVGContext(wrapper))); | 3360 return v8::Number::New(imp.value(V8Proxy::GetSVGContext(wrapper))); |
| 3361 } | 3361 } |
| 3362 | 3362 |
| 3363 CALLBACK_FUNC_DECL(SVGLengthConvertToSpecifiedUnits) { | 3363 CALLBACK_FUNC_DECL(SVGLengthConvertToSpecifiedUnits) { |
| 3364 INC_STATS(L"DOM.SVGLength.convertToSpecifiedUnits"); | 3364 INC_STATS("DOM.SVGLength.convertToSpecifiedUnits"); |
| 3365 V8SVGPODTypeWrapper<SVGLength>* wrapper = V8Proxy::ToNativeObject<V8SVGPODType
Wrapper<SVGLength> >(V8ClassIndex::SVGLENGTH, args.Holder()); | 3365 V8SVGPODTypeWrapper<SVGLength>* wrapper = V8Proxy::ToNativeObject<V8SVGPODType
Wrapper<SVGLength> >(V8ClassIndex::SVGLENGTH, args.Holder()); |
| 3366 SVGLength imp = *wrapper; | 3366 SVGLength imp = *wrapper; |
| 3367 SVGElement* context = V8Proxy::GetSVGContext(wrapper); | 3367 SVGElement* context = V8Proxy::GetSVGContext(wrapper); |
| 3368 imp.convertToSpecifiedUnits(ToInt32(args[0]), context); | 3368 imp.convertToSpecifiedUnits(ToInt32(args[0]), context); |
| 3369 wrapper->commitChange(imp, context); | 3369 wrapper->commitChange(imp, context); |
| 3370 return v8::Undefined(); | 3370 return v8::Undefined(); |
| 3371 } | 3371 } |
| 3372 | 3372 |
| 3373 CALLBACK_FUNC_DECL(SVGMatrixInverse) { | 3373 CALLBACK_FUNC_DECL(SVGMatrixInverse) { |
| 3374 INC_STATS(L"DOM.SVGMatrix.inverse()"); | 3374 INC_STATS("DOM.SVGMatrix.inverse()"); |
| 3375 AffineTransform imp = | 3375 AffineTransform imp = |
| 3376 *V8Proxy::ToNativeObject<V8SVGPODTypeWrapper<AffineTransform> >( | 3376 *V8Proxy::ToNativeObject<V8SVGPODTypeWrapper<AffineTransform> >( |
| 3377 V8ClassIndex::SVGMATRIX, args.Holder()); | 3377 V8ClassIndex::SVGMATRIX, args.Holder()); |
| 3378 ExceptionCode ec = 0; | 3378 ExceptionCode ec = 0; |
| 3379 AffineTransform result = imp.inverse(); | 3379 AffineTransform result = imp.inverse(); |
| 3380 if (!imp.isInvertible()) { | 3380 if (!imp.isInvertible()) { |
| 3381 ec = SVGException::SVG_MATRIX_NOT_INVERTABLE; | 3381 ec = SVGException::SVG_MATRIX_NOT_INVERTABLE; |
| 3382 } | 3382 } |
| 3383 if (ec != 0) { | 3383 if (ec != 0) { |
| 3384 V8Proxy::SetDOMException(ec); | 3384 V8Proxy::SetDOMException(ec); |
| 3385 return v8::Handle<v8::Value>(); | 3385 return v8::Handle<v8::Value>(); |
| 3386 } | 3386 } |
| 3387 | 3387 |
| 3388 Peerable* peer = static_cast<Peerable*>( | 3388 Peerable* peer = static_cast<Peerable*>( |
| 3389 new V8SVGStaticPODTypeWrapper<AffineTransform>(result)); | 3389 new V8SVGStaticPODTypeWrapper<AffineTransform>(result)); |
| 3390 return V8Proxy::ToV8Object(V8ClassIndex::SVGMATRIX, peer); | 3390 return V8Proxy::ToV8Object(V8ClassIndex::SVGMATRIX, peer); |
| 3391 } | 3391 } |
| 3392 | 3392 |
| 3393 CALLBACK_FUNC_DECL(SVGMatrixRotateFromVector) { | 3393 CALLBACK_FUNC_DECL(SVGMatrixRotateFromVector) { |
| 3394 INC_STATS(L"DOM.SVGMatrix.rotateFromVector()"); | 3394 INC_STATS("DOM.SVGMatrix.rotateFromVector()"); |
| 3395 AffineTransform imp = | 3395 AffineTransform imp = |
| 3396 *V8Proxy::ToNativeObject<V8SVGPODTypeWrapper<AffineTransform> >( | 3396 *V8Proxy::ToNativeObject<V8SVGPODTypeWrapper<AffineTransform> >( |
| 3397 V8ClassIndex::SVGMATRIX, args.Holder()); | 3397 V8ClassIndex::SVGMATRIX, args.Holder()); |
| 3398 ExceptionCode ec = 0; | 3398 ExceptionCode ec = 0; |
| 3399 float x = TO_FLOAT(args[0]); | 3399 float x = TO_FLOAT(args[0]); |
| 3400 float y = TO_FLOAT(args[1]); | 3400 float y = TO_FLOAT(args[1]); |
| 3401 AffineTransform result = imp; | 3401 AffineTransform result = imp; |
| 3402 result.rotateFromVector(x, y); | 3402 result.rotateFromVector(x, y); |
| 3403 if (x == 0.0 || y == 0.0) { | 3403 if (x == 0.0 || y == 0.0) { |
| 3404 ec = SVGException::SVG_INVALID_VALUE_ERR; | 3404 ec = SVGException::SVG_INVALID_VALUE_ERR; |
| 3405 } | 3405 } |
| 3406 if (ec != 0) { | 3406 if (ec != 0) { |
| 3407 V8Proxy::SetDOMException(ec); | 3407 V8Proxy::SetDOMException(ec); |
| 3408 return v8::Handle<v8::Value>(); | 3408 return v8::Handle<v8::Value>(); |
| 3409 } | 3409 } |
| 3410 | 3410 |
| 3411 Peerable* peer = static_cast<Peerable*>( | 3411 Peerable* peer = static_cast<Peerable*>( |
| 3412 new V8SVGStaticPODTypeWrapper<AffineTransform>(result)); | 3412 new V8SVGStaticPODTypeWrapper<AffineTransform>(result)); |
| 3413 return V8Proxy::ToV8Object(V8ClassIndex::SVGMATRIX, peer); | 3413 return V8Proxy::ToV8Object(V8ClassIndex::SVGMATRIX, peer); |
| 3414 } | 3414 } |
| 3415 | 3415 |
| 3416 CALLBACK_FUNC_DECL(SVGElementInstanceAddEventListener) { | 3416 CALLBACK_FUNC_DECL(SVGElementInstanceAddEventListener) { |
| 3417 INC_STATS(L"DOM.SVGElementInstance.AddEventListener()"); | 3417 INC_STATS("DOM.SVGElementInstance.AddEventListener()"); |
| 3418 SVGElementInstance* instance = | 3418 SVGElementInstance* instance = |
| 3419 V8Proxy::DOMWrapperToNative<SVGElementInstance>(args.Holder()); | 3419 V8Proxy::DOMWrapperToNative<SVGElementInstance>(args.Holder()); |
| 3420 | 3420 |
| 3421 V8Proxy* proxy = V8Proxy::retrieve(instance->scriptExecutionContext()); | 3421 V8Proxy* proxy = V8Proxy::retrieve(instance->scriptExecutionContext()); |
| 3422 if (!proxy) | 3422 if (!proxy) |
| 3423 return v8::Undefined(); | 3423 return v8::Undefined(); |
| 3424 | 3424 |
| 3425 RefPtr<EventListener> listener = | 3425 RefPtr<EventListener> listener = |
| 3426 proxy->FindOrCreateV8EventListener(args[1], false); | 3426 proxy->FindOrCreateV8EventListener(args[1], false); |
| 3427 if (listener) { | 3427 if (listener) { |
| 3428 String type = ToWebCoreString(args[0]); | 3428 String type = ToWebCoreString(args[0]); |
| 3429 bool useCapture = args[2]->BooleanValue(); | 3429 bool useCapture = args[2]->BooleanValue(); |
| 3430 instance->addEventListener(type, listener, useCapture); | 3430 instance->addEventListener(type, listener, useCapture); |
| 3431 } | 3431 } |
| 3432 return v8::Undefined(); | 3432 return v8::Undefined(); |
| 3433 } | 3433 } |
| 3434 | 3434 |
| 3435 CALLBACK_FUNC_DECL(SVGElementInstanceRemoveEventListener) { | 3435 CALLBACK_FUNC_DECL(SVGElementInstanceRemoveEventListener) { |
| 3436 INC_STATS(L"DOM.SVGElementInstance.RemoveEventListener()"); | 3436 INC_STATS("DOM.SVGElementInstance.RemoveEventListener()"); |
| 3437 SVGElementInstance* instance = | 3437 SVGElementInstance* instance = |
| 3438 V8Proxy::DOMWrapperToNative<SVGElementInstance>(args.Holder()); | 3438 V8Proxy::DOMWrapperToNative<SVGElementInstance>(args.Holder()); |
| 3439 | 3439 |
| 3440 V8Proxy* proxy = V8Proxy::retrieve(instance->scriptExecutionContext()); | 3440 V8Proxy* proxy = V8Proxy::retrieve(instance->scriptExecutionContext()); |
| 3441 // It is possbile that the owner document of the node is detached | 3441 // It is possbile that the owner document of the node is detached |
| 3442 // from the frame, return immediately in this case. | 3442 // from the frame, return immediately in this case. |
| 3443 // See issue 878909 | 3443 // See issue 878909 |
| 3444 if (!proxy) | 3444 if (!proxy) |
| 3445 return v8::Undefined(); | 3445 return v8::Undefined(); |
| 3446 | 3446 |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3627 #undef MAKE_CASE | 3627 #undef MAKE_CASE |
| 3628 | 3628 |
| 3629 default: | 3629 default: |
| 3630 return V8ClassIndex::INVALID_CLASS_INDEX; | 3630 return V8ClassIndex::INVALID_CLASS_INDEX; |
| 3631 } | 3631 } |
| 3632 } | 3632 } |
| 3633 | 3633 |
| 3634 #endif // ENABLE(SVG) | 3634 #endif // ENABLE(SVG) |
| 3635 | 3635 |
| 3636 } // namespace WebCore | 3636 } // namespace WebCore |
| OLD | NEW |