OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
488 | 488 |
489 float toFloat(v8::Handle<v8::Value> value, ExceptionState& exceptionState) | 489 float toFloat(v8::Handle<v8::Value> value, ExceptionState& exceptionState) |
490 { | 490 { |
491 TONATIVE_DEFAULT_EXCEPTIONSTATE(v8::Local<v8::Number>, numberObject, value-> ToNumber(), exceptionState, 0); | 491 TONATIVE_DEFAULT_EXCEPTIONSTATE(v8::Local<v8::Number>, numberObject, value-> ToNumber(), exceptionState, 0); |
492 return numberObject->NumberValue(); | 492 return numberObject->NumberValue(); |
493 } | 493 } |
494 | 494 |
495 String toByteString(v8::Handle<v8::Value> value, ExceptionState& exceptionState) | 495 String toByteString(v8::Handle<v8::Value> value, ExceptionState& exceptionState) |
496 { | 496 { |
497 // From the Web IDL spec: http://heycam.github.io/webidl/#es-ByteString | 497 // From the Web IDL spec: http://heycam.github.io/webidl/#es-ByteString |
498 if (value.IsEmpty()) | |
499 return String(); | |
498 | 500 |
499 // 1. Let x be ToString(v) | 501 // 1. Let x be ToString(v) |
500 TONATIVE_DEFAULT_EXCEPTIONSTATE(v8::Local<v8::String>, stringObject, value-> ToString(), exceptionState, String()); | 502 TONATIVE_DEFAULT_EXCEPTIONSTATE(v8::Local<v8::String>, stringObject, value-> ToString(), exceptionState, String()); |
501 String x = toCoreString(stringObject); | 503 String x = toCoreString(stringObject); |
502 | 504 |
503 // 2. If the value of any element of x is greater than 255, then throw a Typ eError. | 505 // 2. If the value of any element of x is greater than 255, then throw a Typ eError. |
504 if (!x.containsOnlyLatin1()) { | 506 if (!x.containsOnlyLatin1()) { |
505 exceptionState.throwTypeError("Value is not a valid ByteString."); | 507 exceptionState.throwTypeError("Value is not a valid ByteString."); |
506 return String(); | 508 return String(); |
507 } | 509 } |
508 | 510 |
509 // 3. Return an IDL ByteString value whose length is the length of x, and wh ere the | 511 // 3. Return an IDL ByteString value whose length is the length of x, and wh ere the |
510 // value of each element is the value of the corresponding element of x. | 512 // value of each element is the value of the corresponding element of x. |
511 // Blink: A ByteString is simply a String with a range constrained per the a bove, so | 513 // Blink: A ByteString is simply a String with a range constrained per the a bove, so |
512 // this is the identity operation. | 514 // this is the identity operation. |
513 return x; | 515 return x; |
514 } | 516 } |
515 | 517 |
518 String toScalarValueString(v8::Handle<v8::Value> value, ExceptionState& exceptio nState) | |
519 { | |
520 // From the Encoding standard (with a TODO to move to Web IDL): | |
521 // http://encoding.spec.whatwg.org/#type-scalarvaluestring | |
522 if (value.IsEmpty()) | |
523 return String(); | |
524 TONATIVE_DEFAULT_EXCEPTIONSTATE(v8::Local<v8::String>, stringObject, value-> ToString(), exceptionState, String()); | |
haraken
2014/06/11 04:21:12
Probably you can (or should?) use TOSTRING_DEFAULT
jsbell
2014/06/12 17:45:55
As discussed in the ByteString bug, I think we wan
haraken
2014/06/12 17:49:02
Yes!
| |
525 | |
526 // ScalarValueString is identical to DOMString except that "convert a | |
527 // DOMString to a sequence of Unicode characters" is used subsequently | |
528 // when converting to an IDL value | |
529 String x = toCoreString(stringObject); | |
530 return x.toScalarValueString(); | |
531 } | |
532 | |
516 PassRefPtrWillBeRawPtr<XPathNSResolver> toXPathNSResolver(v8::Handle<v8::Value> value, v8::Isolate* isolate) | 533 PassRefPtrWillBeRawPtr<XPathNSResolver> toXPathNSResolver(v8::Handle<v8::Value> value, v8::Isolate* isolate) |
517 { | 534 { |
518 RefPtrWillBeRawPtr<XPathNSResolver> resolver = nullptr; | 535 RefPtrWillBeRawPtr<XPathNSResolver> resolver = nullptr; |
519 if (V8XPathNSResolver::hasInstance(value, isolate)) | 536 if (V8XPathNSResolver::hasInstance(value, isolate)) |
520 resolver = V8XPathNSResolver::toNative(v8::Handle<v8::Object>::Cast(valu e)); | 537 resolver = V8XPathNSResolver::toNative(v8::Handle<v8::Object>::Cast(valu e)); |
521 else if (value->IsObject()) | 538 else if (value->IsObject()) |
522 resolver = V8CustomXPathNSResolver::create(value->ToObject(), isolate); | 539 resolver = V8CustomXPathNSResolver::create(value->ToObject(), isolate); |
523 return resolver; | 540 return resolver; |
524 } | 541 } |
525 | 542 |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
806 PassRefPtr<TraceEvent::ConvertableToTraceFormat> devToolsTraceEventData(Executio nContext* context, v8::Handle<v8::Function> function, v8::Isolate* isolate) | 823 PassRefPtr<TraceEvent::ConvertableToTraceFormat> devToolsTraceEventData(Executio nContext* context, v8::Handle<v8::Function> function, v8::Isolate* isolate) |
807 { | 824 { |
808 int scriptId = 0; | 825 int scriptId = 0; |
809 String resourceName; | 826 String resourceName; |
810 int lineNumber = 1; | 827 int lineNumber = 1; |
811 GetDevToolsFunctionInfo(function, isolate, scriptId, resourceName, lineNumbe r); | 828 GetDevToolsFunctionInfo(function, isolate, scriptId, resourceName, lineNumbe r); |
812 return InspectorFunctionCallEvent::data(context, scriptId, resourceName, lin eNumber); | 829 return InspectorFunctionCallEvent::data(context, scriptId, resourceName, lin eNumber); |
813 } | 830 } |
814 | 831 |
815 } // namespace WebCore | 832 } // namespace WebCore |
OLD | NEW |