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

Side by Side Diff: third_party/WebKit/Source/modules/exported/WebAXObject.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
« no previous file with comments | « third_party/WebKit/Source/modules/accessibility/BUILD.gn ('k') | 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 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 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 30 matching lines...) Expand all
41 #include "core/frame/VisualViewport.h" 41 #include "core/frame/VisualViewport.h"
42 #include "core/frame/WebLocalFrameBase.h" 42 #include "core/frame/WebLocalFrameBase.h"
43 #include "core/input/KeyboardEventManager.h" 43 #include "core/input/KeyboardEventManager.h"
44 #include "core/layout/LayoutObject.h" 44 #include "core/layout/LayoutObject.h"
45 #include "core/layout/api/LayoutAPIShim.h" 45 #include "core/layout/api/LayoutAPIShim.h"
46 #include "core/layout/api/LayoutViewItem.h" 46 #include "core/layout/api/LayoutViewItem.h"
47 #include "core/page/Page.h" 47 #include "core/page/Page.h"
48 #include "core/style/ComputedStyle.h" 48 #include "core/style/ComputedStyle.h"
49 #include "modules/accessibility/AXObjectCacheImpl.h" 49 #include "modules/accessibility/AXObjectCacheImpl.h"
50 #include "modules/accessibility/AXObjectImpl.h" 50 #include "modules/accessibility/AXObjectImpl.h"
51 #include "modules/accessibility/AXRange.h"
51 #include "modules/accessibility/AXTable.h" 52 #include "modules/accessibility/AXTable.h"
52 #include "modules/accessibility/AXTableCell.h" 53 #include "modules/accessibility/AXTableCell.h"
53 #include "modules/accessibility/AXTableColumn.h" 54 #include "modules/accessibility/AXTableColumn.h"
54 #include "modules/accessibility/AXTableRow.h" 55 #include "modules/accessibility/AXTableRow.h"
55 #include "platform/wtf/text/StringBuilder.h" 56 #include "platform/wtf/text/StringBuilder.h"
56 #include "public/platform/WebFloatRect.h" 57 #include "public/platform/WebFloatRect.h"
57 #include "public/platform/WebPoint.h" 58 #include "public/platform/WebPoint.h"
58 #include "public/platform/WebRect.h" 59 #include "public/platform/WebRect.h"
59 #include "public/platform/WebString.h" 60 #include "public/platform/WebString.h"
60 #include "public/platform/WebURL.h" 61 #include "public/platform/WebURL.h"
(...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after
800 if (IsDetached()) { 801 if (IsDetached()) {
801 anchor_object = WebAXObject(); 802 anchor_object = WebAXObject();
802 anchor_offset = -1; 803 anchor_offset = -1;
803 anchor_affinity = kWebAXTextAffinityDownstream; 804 anchor_affinity = kWebAXTextAffinityDownstream;
804 focus_object = WebAXObject(); 805 focus_object = WebAXObject();
805 focus_offset = -1; 806 focus_offset = -1;
806 focus_affinity = kWebAXTextAffinityDownstream; 807 focus_affinity = kWebAXTextAffinityDownstream;
807 return; 808 return;
808 } 809 }
809 810
811 <<<<<<< HEAD:third_party/WebKit/Source/modules/exported/WebAXObject.cpp
810 AXObjectImpl::AXRange ax_selection = private_->Selection(); 812 AXObjectImpl::AXRange ax_selection = private_->Selection();
811 anchor_object = WebAXObject(ax_selection.anchor_object); 813 anchor_object = WebAXObject(ax_selection.anchor_object);
812 anchor_offset = ax_selection.anchor_offset; 814 anchor_offset = ax_selection.anchor_offset;
813 anchor_affinity = 815 anchor_affinity =
814 static_cast<WebAXTextAffinity>(ax_selection.anchor_affinity); 816 static_cast<WebAXTextAffinity>(ax_selection.anchor_affinity);
815 focus_object = WebAXObject(ax_selection.focus_object); 817 focus_object = WebAXObject(ax_selection.focus_object);
816 focus_offset = ax_selection.focus_offset; 818 focus_offset = ax_selection.focus_offset;
817 focus_affinity = static_cast<WebAXTextAffinity>(ax_selection.focus_affinity); 819 focus_affinity = static_cast<WebAXTextAffinity>(ax_selection.focus_affinity);
818 return; 820 return;
821 =======
822 AXRange ax_selection = private_->Selection();
823 // If selection is invalid, it will set object and offset endpoints to nullptr
824 // and -1 respectively.
825 anchor_object = WebAXObject(ax_selection.AnchorObject());
826 anchor_offset = ax_selection.AnchorOffset();
827 anchor_affinity = static_cast<WebAXTextAffinity>(ax_selection.Affinity());
828 focus_object = WebAXObject(ax_selection.FocusObject());
829 focus_offset = ax_selection.FocusOffset();
830 focus_affinity = static_cast<WebAXTextAffinity>(ax_selection.Affinity());
831 >>>>>>> Simplified and cleaned up selection code in Blink > Accessibility.:third _party/WebKit/Source/web/WebAXObject.cpp
819 } 832 }
820 833
821 void WebAXObject::SetSelection(const WebAXObject& anchor_object, 834 void WebAXObject::SetSelection(const WebAXObject& anchor_object,
822 int anchor_offset, 835 int anchor_offset,
823 const WebAXObject& focus_object, 836 const WebAXObject& focus_object,
824 int focus_offset) const { 837 int focus_offset) const {
825 if (IsDetached()) 838 if (IsDetached())
826 return; 839 return;
827 840
841 <<<<<<< HEAD:third_party/WebKit/Source/modules/exported/WebAXObject.cpp
828 AXObjectImpl::AXRange ax_selection(anchor_object, anchor_offset, 842 AXObjectImpl::AXRange ax_selection(anchor_object, anchor_offset,
829 TextAffinity::kUpstream, focus_object, 843 TextAffinity::kUpstream, focus_object,
830 focus_offset, TextAffinity::kDownstream); 844 focus_offset, TextAffinity::kDownstream);
831 private_->SetSelection(ax_selection); 845 private_->SetSelection(ax_selection);
846 =======
847 AXRange ax_selection(anchor_object, anchor_offset, focus_object, focus_offset,
848 TextAffinity::kDownstream);
849 ax_selection.Select();
850 >>>>>>> Simplified and cleaned up selection code in Blink > Accessibility.:third _party/WebKit/Source/web/WebAXObject.cpp
832 return; 851 return;
833 } 852 }
834 853
835 unsigned WebAXObject::SelectionEnd() const { 854 unsigned WebAXObject::SelectionEnd() const {
836 if (IsDetached()) 855 if (IsDetached())
837 return 0; 856 return 0;
838 857
858 <<<<<<< HEAD:third_party/WebKit/Source/modules/exported/WebAXObject.cpp
839 AXObjectImpl::AXRange ax_selection = private_->SelectionUnderObject(); 859 AXObjectImpl::AXRange ax_selection = private_->SelectionUnderObject();
840 if (ax_selection.focus_offset < 0) 860 if (ax_selection.focus_offset < 0)
861 =======
862 AXRange ax_selection = private_->Selection();
863 if (ax_selection.FocusOffset() < 0)
864 >>>>>>> Simplified and cleaned up selection code in Blink > Accessibility.:third _party/WebKit/Source/web/WebAXObject.cpp
841 return 0; 865 return 0;
842 866
843 return ax_selection.focus_offset; 867 return ax_selection.FocusOffset();
844 } 868 }
845 869
846 unsigned WebAXObject::SelectionStart() const { 870 unsigned WebAXObject::SelectionStart() const {
847 if (IsDetached()) 871 if (IsDetached())
848 return 0; 872 return 0;
849 873
874 <<<<<<< HEAD:third_party/WebKit/Source/modules/exported/WebAXObject.cpp
850 AXObjectImpl::AXRange ax_selection = private_->SelectionUnderObject(); 875 AXObjectImpl::AXRange ax_selection = private_->SelectionUnderObject();
851 if (ax_selection.anchor_offset < 0) 876 if (ax_selection.anchor_offset < 0)
877 =======
878 AXRange ax_selection = private_->Selection();
879 if (ax_selection.AnchorOffset() < 0)
880 >>>>>>> Simplified and cleaned up selection code in Blink > Accessibility.:third _party/WebKit/Source/web/WebAXObject.cpp
852 return 0; 881 return 0;
853 882
854 return ax_selection.anchor_offset; 883 return ax_selection.AnchorOffset();
855 } 884 }
856 885
857 unsigned WebAXObject::SelectionEndLineNumber() const { 886 unsigned WebAXObject::SelectionEndLineNumber() const {
858 if (IsDetached()) 887 if (IsDetached())
859 return 0; 888 return 0;
860 889
861 VisiblePosition position = private_->VisiblePositionForIndex(SelectionEnd()); 890 VisiblePosition position = private_->VisiblePositionForIndex(SelectionEnd());
862 int line_number = private_->LineForPosition(position); 891 int line_number = private_->LineForPosition(position);
863 if (line_number < 0) 892 if (line_number < 0)
864 return 0; 893 return 0;
(...skipping 17 matching lines...) Expand all
882 void WebAXObject::SetFocused(bool on) const { 911 void WebAXObject::SetFocused(bool on) const {
883 if (!IsDetached()) 912 if (!IsDetached())
884 private_->SetFocused(on); 913 private_->SetFocused(on);
885 } 914 }
886 915
887 void WebAXObject::SetSelectedTextRange(int selection_start, 916 void WebAXObject::SetSelectedTextRange(int selection_start,
888 int selection_end) const { 917 int selection_end) const {
889 if (IsDetached()) 918 if (IsDetached())
890 return; 919 return;
891 920
921 <<<<<<< HEAD:third_party/WebKit/Source/modules/exported/WebAXObject.cpp
892 private_->SetSelection(AXObjectImpl::AXRange(selection_start, selection_end)); 922 private_->SetSelection(AXObjectImpl::AXRange(selection_start, selection_end));
923 =======
924 AXRange ax_selection(private_.Get(), selection_start, private_.Get(),
925 selection_end);
926 if (ax_selection.IsValid())
927 ax_selection.Select();
928 >>>>>>> Simplified and cleaned up selection code in Blink > Accessibility.:third _party/WebKit/Source/web/WebAXObject.cpp
893 } 929 }
894 930
895 void WebAXObject::SetSequentialFocusNavigationStartingPoint() const { 931 void WebAXObject::SetSequentialFocusNavigationStartingPoint() const {
896 if (IsDetached()) 932 if (IsDetached())
897 return; 933 return;
898 934
899 private_->SetSequentialFocusNavigationStartingPoint(); 935 private_->SetSequentialFocusNavigationStartingPoint();
900 } 936 }
901 937
902 void WebAXObject::SetValue(WebString value) const { 938 void WebAXObject::SetValue(WebString value) const {
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
1411 return WebAXObject(private_.Get()->PreviousOnLine()); 1447 return WebAXObject(private_.Get()->PreviousOnLine());
1412 } 1448 }
1413 1449
1414 void WebAXObject::Markers(WebVector<WebAXMarkerType>& types, 1450 void WebAXObject::Markers(WebVector<WebAXMarkerType>& types,
1415 WebVector<int>& starts, 1451 WebVector<int>& starts,
1416 WebVector<int>& ends) const { 1452 WebVector<int>& ends) const {
1417 if (IsDetached()) 1453 if (IsDetached())
1418 return; 1454 return;
1419 1455
1420 Vector<DocumentMarker::MarkerType> marker_types; 1456 Vector<DocumentMarker::MarkerType> marker_types;
1457 <<<<<<< HEAD:third_party/WebKit/Source/modules/exported/WebAXObject.cpp
1421 Vector<AXObjectImpl::AXRange> marker_ranges; 1458 Vector<AXObjectImpl::AXRange> marker_ranges;
1459 =======
1460 Vector<AXRange> marker_ranges;
1461 >>>>>>> Simplified and cleaned up selection code in Blink > Accessibility.:third _party/WebKit/Source/web/WebAXObject.cpp
1422 private_->Markers(marker_types, marker_ranges); 1462 private_->Markers(marker_types, marker_ranges);
1423 DCHECK_EQ(marker_types.size(), marker_ranges.size()); 1463 DCHECK_EQ(marker_types.size(), marker_ranges.size());
1424 1464
1425 WebVector<WebAXMarkerType> web_marker_types(marker_types.size()); 1465 WebVector<WebAXMarkerType> web_marker_types(marker_types.size());
1426 WebVector<int> start_offsets(marker_ranges.size()); 1466 WebVector<int> start_offsets(marker_ranges.size());
1427 WebVector<int> end_offsets(marker_ranges.size()); 1467 WebVector<int> end_offsets(marker_ranges.size());
1428 for (size_t i = 0; i < marker_types.size(); ++i) { 1468 for (size_t i = 0; i < marker_types.size(); ++i) {
1429 web_marker_types[i] = static_cast<WebAXMarkerType>(marker_types[i]); 1469 web_marker_types[i] = static_cast<WebAXMarkerType>(marker_types[i]);
1430 DCHECK(marker_ranges[i].IsSimple()); 1470 DCHECK(marker_ranges[i].IsSimple());
1431 start_offsets[i] = marker_ranges[i].anchor_offset; 1471 start_offsets[i] = marker_ranges[i].AnchorOffset();
1432 end_offsets[i] = marker_ranges[i].focus_offset; 1472 end_offsets[i] = marker_ranges[i].FocusOffset();
1433 } 1473 }
1434 1474
1435 types.Swap(web_marker_types); 1475 types.Swap(web_marker_types);
1436 starts.Swap(start_offsets); 1476 starts.Swap(start_offsets);
1437 ends.Swap(end_offsets); 1477 ends.Swap(end_offsets);
1438 } 1478 }
1439 1479
1440 void WebAXObject::CharacterOffsets(WebVector<int>& offsets) const { 1480 void WebAXObject::CharacterOffsets(WebVector<int>& offsets) const {
1441 if (IsDetached()) 1481 if (IsDetached())
1442 return; 1482 return;
1443 1483
1444 Vector<int> offsets_vector; 1484 Vector<int> offsets_vector;
1445 private_->TextCharacterOffsets(offsets_vector); 1485 private_->TextCharacterOffsets(offsets_vector);
1446 1486
1447 size_t vector_size = offsets_vector.size(); 1487 size_t vector_size = offsets_vector.size();
1448 WebVector<int> offsets_web_vector(vector_size); 1488 WebVector<int> offsets_web_vector(vector_size);
1449 for (size_t i = 0; i < vector_size; i++) 1489 for (size_t i = 0; i < vector_size; i++)
1450 offsets_web_vector[i] = offsets_vector[i]; 1490 offsets_web_vector[i] = offsets_vector[i];
1451 offsets.Swap(offsets_web_vector); 1491 offsets.Swap(offsets_web_vector);
1452 } 1492 }
1453 1493
1454 void WebAXObject::GetWordBoundaries(WebVector<int>& starts, 1494 void WebAXObject::GetWordBoundaries(WebVector<int>& starts,
1455 WebVector<int>& ends) const { 1495 WebVector<int>& ends) const {
1456 if (IsDetached()) 1496 if (IsDetached())
1457 return; 1497 return;
1458 1498
1499 <<<<<<< HEAD:third_party/WebKit/Source/modules/exported/WebAXObject.cpp
1459 Vector<AXObjectImpl::AXRange> word_boundaries; 1500 Vector<AXObjectImpl::AXRange> word_boundaries;
1501 =======
1502 Vector<AXRange> word_boundaries;
1503 >>>>>>> Simplified and cleaned up selection code in Blink > Accessibility.:third _party/WebKit/Source/web/WebAXObject.cpp
1460 private_->GetWordBoundaries(word_boundaries); 1504 private_->GetWordBoundaries(word_boundaries);
1461 1505
1462 WebVector<int> word_start_offsets(word_boundaries.size()); 1506 WebVector<int> word_start_offsets(word_boundaries.size());
1463 WebVector<int> word_end_offsets(word_boundaries.size()); 1507 WebVector<int> word_end_offsets(word_boundaries.size());
1464 for (size_t i = 0; i < word_boundaries.size(); ++i) { 1508 for (size_t i = 0; i < word_boundaries.size(); ++i) {
1465 DCHECK(word_boundaries[i].IsSimple()); 1509 DCHECK(word_boundaries[i].IsSimple());
1466 word_start_offsets[i] = word_boundaries[i].anchor_offset; 1510 word_start_offsets[i] = word_boundaries[i].AnchorOffset();
1467 word_end_offsets[i] = word_boundaries[i].focus_offset; 1511 word_end_offsets[i] = word_boundaries[i].FocusOffset();
1468 } 1512 }
1469 1513
1470 starts.Swap(word_start_offsets); 1514 starts.Swap(word_start_offsets);
1471 ends.Swap(word_end_offsets); 1515 ends.Swap(word_end_offsets);
1472 } 1516 }
1473 1517
1474 bool WebAXObject::IsScrollableContainer() const { 1518 bool WebAXObject::IsScrollableContainer() const {
1475 if (IsDetached()) 1519 if (IsDetached())
1476 return false; 1520 return false;
1477 1521
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1589 1633
1590 // static 1634 // static
1591 WebAXObject WebAXObject::FromWebDocumentFocused( 1635 WebAXObject WebAXObject::FromWebDocumentFocused(
1592 const WebDocument& web_document) { 1636 const WebDocument& web_document) {
1593 const Document* document = web_document.ConstUnwrap<Document>(); 1637 const Document* document = web_document.ConstUnwrap<Document>();
1594 AXObjectCacheImpl* cache = ToAXObjectCacheImpl(document->AxObjectCache()); 1638 AXObjectCacheImpl* cache = ToAXObjectCacheImpl(document->AxObjectCache());
1595 return cache ? WebAXObject(cache->FocusedObject()) : WebAXObject(); 1639 return cache ? WebAXObject(cache->FocusedObject()) : WebAXObject();
1596 } 1640 }
1597 1641
1598 } // namespace blink 1642 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/accessibility/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698