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

Side by Side Diff: third_party/WebKit/Source/modules/accessibility/AXNodeObject.cpp

Issue 2745713002: WIP: Modified AXPosition to work with objects with both embedded object characters and text. (Closed)
Patch Set: Simplified and cleaned up selection code in Blink > Accessibility. Created 3 years, 6 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012, Google Inc. All rights reserved. 2 * Copyright (C) 2012, 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 1400 matching lines...) Expand 10 before | Expand all | Expand 10 after
1411 DocumentMarkerController& marker_controller = GetDocument()->Markers(); 1411 DocumentMarkerController& marker_controller = GetDocument()->Markers();
1412 DocumentMarkerVector markers = marker_controller.MarkersFor(GetNode()); 1412 DocumentMarkerVector markers = marker_controller.MarkersFor(GetNode());
1413 for (size_t i = 0; i < markers.size(); ++i) { 1413 for (size_t i = 0; i < markers.size(); ++i) {
1414 DocumentMarker* marker = markers[i]; 1414 DocumentMarker* marker = markers[i];
1415 switch (marker->GetType()) { 1415 switch (marker->GetType()) {
1416 case DocumentMarker::kSpelling: 1416 case DocumentMarker::kSpelling:
1417 case DocumentMarker::kGrammar: 1417 case DocumentMarker::kGrammar:
1418 case DocumentMarker::kTextMatch: 1418 case DocumentMarker::kTextMatch:
1419 case DocumentMarker::kActiveSuggestion: 1419 case DocumentMarker::kActiveSuggestion:
1420 marker_types.push_back(marker->GetType()); 1420 marker_types.push_back(marker->GetType());
1421 marker_ranges.push_back( 1421 marker_ranges.emplace_back(
1422 AXRange(marker->StartOffset(), marker->EndOffset())); 1422 const_cast<AXNodeObject*>(this), marker->StartOffset(),
1423 const_cast<AXNodeObject*>(this), marker->EndOffset());
1423 break; 1424 break;
1424 case DocumentMarker::kComposition: 1425 case DocumentMarker::kComposition:
1425 // No need for accessibility to know about these marker types. 1426 // No need for accessibility to know about these marker types.
1426 break; 1427 break;
1427 } 1428 }
1428 } 1429 }
1429 } 1430 }
1430 1431
1431 AXObjectImpl* AXNodeObject::InPageLinkTarget() const { 1432 AXObjectImpl* AXNodeObject::InPageLinkTarget() const {
1432 if (!node_ || !isHTMLAnchorElement(node_) || !GetDocument()) 1433 if (!node_ || !isHTMLAnchorElement(node_) || !GetDocument())
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
2011 html_element = ToHTMLElement(GetNode()); 2012 html_element = ToHTMLElement(GetNode());
2012 if (html_element && IsLabelableElement(html_element)) { 2013 if (html_element && IsLabelableElement(html_element)) {
2013 if (ToLabelableElement(html_element)->labels() && 2014 if (ToLabelableElement(html_element)->labels() &&
2014 ToLabelableElement(html_element)->labels()->length() > 0) 2015 ToLabelableElement(html_element)->labels()->length() > 0)
2015 return true; 2016 return true;
2016 } 2017 }
2017 2018
2018 return false; 2019 return false;
2019 } 2020 }
2020 2021
2022 bool AXNodeObject::NameFromContents() const {
2023 Node* node = GetNode();
2024 if (!node || !node->IsElementNode())
2025 return AXObject::NameFromContents();
2026 // AXObject::nameFromContents determines whether an element should take its
2027 // name from its descendant contents based on role. However, <select> is a
2028 // special case, as unlike a typical pop-up button it contains its own pop-up
2029 // menu's contents, which should not be used as the name.
2030 if (isHTMLSelectElement(node))
2031 return false;
2032 return AXObject::NameFromContents();
2033 }
2034
2035 AXRange AXNodeObject::Selection() const {
2036 if (!GetNode())
2037 return AXObject::Selection();
2038 if (IsTextControlElement(GetNode())) {
2039 TextControlElement* text_control = ToTextControlElement(GetNode());
2040 return AXRange(const_cast<AXNodeObject*>(this),
2041 text_control->selectionStart(),
2042 const_cast<AXNodeObject*>(this),
2043 text_control->selectionEnd(), TextAffinity::kDownstream);
2044 }
2045 return AXObject::Selection();
2046 }
2047
2021 void AXNodeObject::GetRelativeBounds( 2048 void AXNodeObject::GetRelativeBounds(
2022 AXObjectImpl** out_container, 2049 AXObjectImpl** out_container,
2023 FloatRect& out_bounds_in_container, 2050 FloatRect& out_bounds_in_container,
2024 SkMatrix44& out_container_transform) const { 2051 SkMatrix44& out_container_transform) const {
2025 if (LayoutObjectForRelativeBounds()) { 2052 if (LayoutObjectForRelativeBounds()) {
2026 AXObjectImpl::GetRelativeBounds(out_container, out_bounds_in_container, 2053 AXObjectImpl::GetRelativeBounds(out_container, out_bounds_in_container,
2027 out_container_transform); 2054 out_container_transform);
2028 return; 2055 return;
2029 } 2056 }
2030 2057
(...skipping 1184 matching lines...) Expand 10 before | Expand all | Expand 10 after
3215 return String(); 3242 return String();
3216 return ToTextControlElement(node)->StrippedPlaceholder(); 3243 return ToTextControlElement(node)->StrippedPlaceholder();
3217 } 3244 }
3218 3245
3219 DEFINE_TRACE(AXNodeObject) { 3246 DEFINE_TRACE(AXNodeObject) {
3220 visitor->Trace(node_); 3247 visitor->Trace(node_);
3221 AXObjectImpl::Trace(visitor); 3248 AXObjectImpl::Trace(visitor);
3222 } 3249 }
3223 3250
3224 } // namespace blink 3251 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698