| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2008, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2008, 2009 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2008 Collabora Ltd. | 3 * Copyright (C) 2008 Collabora Ltd. |
| 4 * Copyright (C) 2011 Peter Varga (pvarga@webkit.org), University of Szeged | 4 * Copyright (C) 2011 Peter Varga (pvarga@webkit.org), University of Szeged |
| 5 * Copyright (C) 2013 Google Inc. All rights reserved. | 5 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 6 * | 6 * |
| 7 * Redistribution and use in source and binary forms, with or without | 7 * Redistribution and use in source and binary forms, with or without |
| 8 * modification, are permitted provided that the following conditions | 8 * modification, are permitted provided that the following conditions |
| 9 * are met: | 9 * are met: |
| 10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 .ToLocal(&return_value)) | 99 .ToLocal(&return_value)) |
| 100 return -1; | 100 return -1; |
| 101 | 101 |
| 102 // RegExp#exec returns null if there's no match, otherwise it returns an | 102 // RegExp#exec returns null if there's no match, otherwise it returns an |
| 103 // Array of strings with the first being the whole match string and others | 103 // Array of strings with the first being the whole match string and others |
| 104 // being subgroups. The Array also has some random properties tacked on like | 104 // being subgroups. The Array also has some random properties tacked on like |
| 105 // "index" which is the offset of the match. | 105 // "index" which is the offset of the match. |
| 106 // | 106 // |
| 107 // https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Object
s/RegExp/exec | 107 // https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Object
s/RegExp/exec |
| 108 | 108 |
| 109 ASSERT(!return_value.IsEmpty()); | 109 DCHECK(!return_value.IsEmpty()); |
| 110 if (!return_value->IsArray()) | 110 if (!return_value->IsArray()) |
| 111 return -1; | 111 return -1; |
| 112 | 112 |
| 113 v8::Local<v8::Array> result = return_value.As<v8::Array>(); | 113 v8::Local<v8::Array> result = return_value.As<v8::Array>(); |
| 114 v8::Local<v8::Value> match_offset; | 114 v8::Local<v8::Value> match_offset; |
| 115 if (!result->Get(context, V8AtomicString(isolate, "index")) | 115 if (!result->Get(context, V8AtomicString(isolate, "index")) |
| 116 .ToLocal(&match_offset)) | 116 .ToLocal(&match_offset)) |
| 117 return -1; | 117 return -1; |
| 118 if (match_length) { | 118 if (match_length) { |
| 119 v8::Local<v8::Value> match; | 119 v8::Local<v8::Value> match; |
| 120 if (!result->Get(context, 0).ToLocal(&match)) | 120 if (!result->Get(context, 0).ToLocal(&match)) |
| 121 return -1; | 121 return -1; |
| 122 *match_length = match.As<v8::String>()->Length(); | 122 *match_length = match.As<v8::String>()->Length(); |
| 123 } | 123 } |
| 124 | 124 |
| 125 return match_offset.As<v8::Int32>()->Value() + start_from; | 125 return match_offset.As<v8::Int32>()->Value() + start_from; |
| 126 } | 126 } |
| 127 | 127 |
| 128 } // namespace blink | 128 } // namespace blink |
| OLD | NEW |