Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Side by Side Diff: components/test_runner/web_ax_object_proxy.cc

Issue 2297243002: Don't crash if WebAXObject::characterOffsets doesn't return any bounds. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/test_runner/web_ax_object_proxy.h" 5 #include "components/test_runner/web_ax_object_proxy.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 blink::WebString name = inline_text_box.name(); 350 blink::WebString name = inline_text_box.name();
351 end += name.length(); 351 end += name.length();
352 if (characterIndex < start || characterIndex >= end) 352 if (characterIndex < start || characterIndex >= end)
353 continue; 353 continue;
354 354
355 blink::WebFloatRect inline_text_box_rect = BoundsForObject(inline_text_box); 355 blink::WebFloatRect inline_text_box_rect = BoundsForObject(inline_text_box);
356 356
357 int localIndex = characterIndex - start; 357 int localIndex = characterIndex - start;
358 blink::WebVector<int> character_offsets; 358 blink::WebVector<int> character_offsets;
359 inline_text_box.characterOffsets(character_offsets); 359 inline_text_box.characterOffsets(character_offsets);
360 DCHECK(character_offsets.size() > 0 && 360 if (character_offsets.size() != name.length())
361 character_offsets.size() == name.length()); 361 return blink::WebRect();
362
362 switch (inline_text_box.textDirection()) { 363 switch (inline_text_box.textDirection()) {
363 case blink::WebAXTextDirectionLR: { 364 case blink::WebAXTextDirectionLR: {
364 if (localIndex) { 365 if (localIndex) {
365 int left = inline_text_box_rect.x + character_offsets[localIndex - 1]; 366 int left = inline_text_box_rect.x + character_offsets[localIndex - 1];
366 int width = character_offsets[localIndex] - 367 int width = character_offsets[localIndex] -
367 character_offsets[localIndex - 1]; 368 character_offsets[localIndex - 1];
368 return blink::WebRect(left, inline_text_box_rect.y, 369 return blink::WebRect(left, inline_text_box_rect.y,
369 width, inline_text_box_rect.height); 370 width, inline_text_box_rect.height);
370 } 371 }
371 return blink::WebRect( 372 return blink::WebRect(
(...skipping 1328 matching lines...) Expand 10 before | Expand all | Expand 10 after
1700 v8::Local<v8::Value> value_handle = gin::CreateHandle( 1701 v8::Local<v8::Value> value_handle = gin::CreateHandle(
1701 isolate, new WebAXObjectProxy(object, this)).ToV8(); 1702 isolate, new WebAXObjectProxy(object, this)).ToV8();
1702 if (value_handle.IsEmpty()) 1703 if (value_handle.IsEmpty())
1703 return v8::Local<v8::Object>(); 1704 return v8::Local<v8::Object>();
1704 v8::Local<v8::Object> handle = value_handle->ToObject(isolate); 1705 v8::Local<v8::Object> handle = value_handle->ToObject(isolate);
1705 elements_.Append(handle); 1706 elements_.Append(handle);
1706 return handle; 1707 return handle;
1707 } 1708 }
1708 1709
1709 } // namespace test_runner 1710 } // namespace test_runner
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698