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

Side by Side Diff: third_party/WebKit/Source/modules/accessibility/AXObjectImpl.h

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 /* 2 /*
3 * Copyright (C) 2008, 2009, 2011 Apple Inc. All rights reserved. 3 * Copyright (C) 2008, 2009, 2011 Apple Inc. All rights reserved.
4 * Copyright (C) 2008 Nuanti Ltd. 4 * Copyright (C) 2008 Nuanti Ltd.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 18 matching lines...) Expand all
29 */ 29 */
30 30
31 #ifndef AXObjectImpl_h 31 #ifndef AXObjectImpl_h
32 #define AXObjectImpl_h 32 #define AXObjectImpl_h
33 33
34 #include "core/dom/AXObject.h" 34 #include "core/dom/AXObject.h"
35 #include "core/editing/VisiblePosition.h" 35 #include "core/editing/VisiblePosition.h"
36 #include "core/editing/markers/DocumentMarker.h" 36 #include "core/editing/markers/DocumentMarker.h"
37 #include "core/inspector/protocol/Accessibility.h" 37 #include "core/inspector/protocol/Accessibility.h"
38 #include "modules/ModulesExport.h" 38 #include "modules/ModulesExport.h"
39 #include "modules/accessibility/AXRange.h"
39 #include "platform/geometry/FloatQuad.h" 40 #include "platform/geometry/FloatQuad.h"
40 #include "platform/geometry/LayoutRect.h" 41 #include "platform/geometry/LayoutRect.h"
41 #include "platform/graphics/Color.h" 42 #include "platform/graphics/Color.h"
42 #include "platform/wtf/Forward.h" 43 #include "platform/wtf/Forward.h"
43 #include "platform/wtf/Vector.h" 44 #include "platform/wtf/Vector.h"
44 45
45 class SkMatrix44; 46 class SkMatrix44;
46 47
47 namespace blink { 48 namespace blink {
48 49
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 namespace blink { 247 namespace blink {
247 248
248 class MODULES_EXPORT AXObjectImpl 249 class MODULES_EXPORT AXObjectImpl
249 : public GarbageCollectedFinalized<AXObjectImpl>, 250 : public GarbageCollectedFinalized<AXObjectImpl>,
250 public AXObject { 251 public AXObject {
251 WTF_MAKE_NONCOPYABLE(AXObjectImpl); 252 WTF_MAKE_NONCOPYABLE(AXObjectImpl);
252 253
253 public: 254 public:
254 typedef HeapVector<Member<AXObjectImpl>> AXObjectVector; 255 typedef HeapVector<Member<AXObjectImpl>> AXObjectVector;
255 256
256 struct AXRange {
257 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
258 // The deepest descendant in which the range starts.
259 // (nullptr means the current object.)
260 Persistent<AXObjectImpl> anchor_object;
261 // The number of characters and child objects in the anchor object
262 // before the range starts.
263 int anchor_offset;
264 // When the same character offset could correspond to two possible
265 // cursor positions, upstream means it's on the previous line rather
266 // than the next line.
267 TextAffinity anchor_affinity;
268
269 // The deepest descendant in which the range ends.
270 // (nullptr means the current object.)
271 Persistent<AXObjectImpl> focus_object;
272 // The number of characters and child objects in the focus object
273 // before the range ends.
274 int focus_offset;
275 // When the same character offset could correspond to two possible
276 // cursor positions, upstream means it's on the previous line rather
277 // than the next line.
278 TextAffinity focus_affinity;
279
280 AXRange()
281 : anchor_object(nullptr),
282 anchor_offset(-1),
283 anchor_affinity(TextAffinity::kUpstream),
284 focus_object(nullptr),
285 focus_offset(-1),
286 focus_affinity(TextAffinity::kDownstream) {}
287
288 AXRange(int start_offset, int end_offset)
289 : anchor_object(nullptr),
290 anchor_offset(start_offset),
291 anchor_affinity(TextAffinity::kUpstream),
292 focus_object(nullptr),
293 focus_offset(end_offset),
294 focus_affinity(TextAffinity::kDownstream) {}
295
296 AXRange(AXObjectImpl* anchor_object,
297 int anchor_offset,
298 TextAffinity anchor_affinity,
299 AXObjectImpl* focus_object,
300 int focus_offset,
301 TextAffinity focus_affinity)
302 : anchor_object(anchor_object),
303 anchor_offset(anchor_offset),
304 anchor_affinity(anchor_affinity),
305 focus_object(focus_object),
306 focus_offset(focus_offset),
307 focus_affinity(focus_affinity) {}
308
309 bool IsValid() const {
310 return ((anchor_object && focus_object) ||
311 (!anchor_object && !focus_object)) &&
312 anchor_offset >= 0 && focus_offset >= 0;
313 }
314
315 // Determines if the range only refers to text offsets under the current
316 // object.
317 bool IsSimple() const {
318 return anchor_object == focus_object || !anchor_object || !focus_object;
319 }
320 };
321
322 protected: 257 protected:
323 AXObjectImpl(AXObjectCacheImpl&); 258 AXObjectImpl(AXObjectCacheImpl&);
324 259
325 public: 260 public:
326 virtual ~AXObjectImpl(); 261 virtual ~AXObjectImpl();
327 DECLARE_VIRTUAL_TRACE(); 262 DECLARE_VIRTUAL_TRACE();
328 263
329 static unsigned NumberOfLiveAXObjects() { return number_of_live_ax_objects_; } 264 static unsigned NumberOfLiveAXObjects() { return number_of_live_ax_objects_; }
330 265
331 // After constructing an AXObjectImpl, it must be given a 266 // After constructing an AXObjectImpl, it must be given a
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 virtual Element* GetElement() const; // Same as GetNode, if it's an Element. 675 virtual Element* GetElement() const; // Same as GetNode, if it's an Element.
741 virtual LayoutObject* GetLayoutObject() const { return nullptr; } 676 virtual LayoutObject* GetLayoutObject() const { return nullptr; }
742 virtual Document* GetDocument() const; 677 virtual Document* GetDocument() const;
743 virtual LocalFrameView* DocumentFrameView() const; 678 virtual LocalFrameView* DocumentFrameView() const;
744 virtual Element* AnchorElement() const { return nullptr; } 679 virtual Element* AnchorElement() const { return nullptr; }
745 virtual Element* ActionElement() const { return nullptr; } 680 virtual Element* ActionElement() const { return nullptr; }
746 String Language() const; 681 String Language() const;
747 bool HasAttribute(const QualifiedName&) const; 682 bool HasAttribute(const QualifiedName&) const;
748 const AtomicString& GetAttribute(const QualifiedName&) const; 683 const AtomicString& GetAttribute(const QualifiedName&) const;
749 684
750 // Methods that retrieve or manipulate the current selection. 685 // Selection.
751 686 virtual AXRange Selection() const;
752 // Get the current selection from anywhere in the accessibility tree.
753 virtual AXRange Selection() const { return AXRange(); }
754 // Gets only the start and end offsets of the selection computed using the
755 // current object as the starting point. Returns a null selection if there is
756 // no selection in the subtree rooted at this object.
757 virtual AXRange SelectionUnderObject() const { return AXRange(); }
758 virtual void SetSelection(const AXRange&) {}
759 687
760 // Scrollable containers. 688 // Scrollable containers.
761 bool IsScrollableContainer() const; 689 bool IsScrollableContainer() const;
762 IntPoint GetScrollOffset() const; 690 IntPoint GetScrollOffset() const;
763 IntPoint MinimumScrollOffset() const; 691 IntPoint MinimumScrollOffset() const;
764 IntPoint MaximumScrollOffset() const; 692 IntPoint MaximumScrollOffset() const;
765 void SetScrollOffset(const IntPoint&) const; 693 void SetScrollOffset(const IntPoint&) const;
766 694
767 // If this object itself scrolls, return its ScrollableArea. 695 // If this object itself scrolls, return its ScrollableArea.
768 virtual ScrollableArea* GetScrollableAreaIfScrollable() const { return 0; } 696 virtual ScrollableArea* GetScrollableAreaIfScrollable() const { return 0; }
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 Member<AXObjectCacheImpl> ax_object_cache_; 807 Member<AXObjectCacheImpl> ax_object_cache_;
880 808
881 // Updates the cached attribute values. This may be recursive, so to prevent 809 // Updates the cached attribute values. This may be recursive, so to prevent
882 // deadlocks, 810 // deadlocks,
883 // functions called here may only search up the tree (ancestors), not down. 811 // functions called here may only search up the tree (ancestors), not down.
884 void UpdateCachedAttributeValuesIfNeeded() const; 812 void UpdateCachedAttributeValuesIfNeeded() const;
885 813
886 private: 814 private:
887 bool IsCheckable() const; 815 bool IsCheckable() const;
888 static bool IsNativeInputInMixedState(const Node*); 816 static bool IsNativeInputInMixedState(const Node*);
817 void ComputeAXObjectAndOffset(const VisiblePositionInFlatTree& position,
818 AXObject** ax_object,
819 int* offset) const;
889 static bool IncludesARIAWidgetRole(const String&); 820 static bool IncludesARIAWidgetRole(const String&);
890 static bool HasInteractiveARIAAttribute(const Element&); 821 static bool HasInteractiveARIAAttribute(const Element&);
891 822
892 static unsigned number_of_live_ax_objects_; 823 static unsigned number_of_live_ax_objects_;
893 }; 824 };
894 825
895 DEFINE_TYPE_CASTS(AXObjectImpl, AXObject, obj, true, true); 826 DEFINE_TYPE_CASTS(AXObjectImpl, AXObject, obj, true, true);
896 827
897 #define DEFINE_AX_OBJECT_TYPE_CASTS(thisType, predicate) \ 828 #define DEFINE_AX_OBJECT_TYPE_CASTS(thisType, predicate) \
898 DEFINE_TYPE_CASTS(thisType, AXObjectImpl, object, object->predicate, \ 829 DEFINE_TYPE_CASTS(thisType, AXObjectImpl, object, object->predicate, \
899 object.predicate) 830 object.predicate)
900 831
901 } // namespace blink 832 } // namespace blink
902 833
903 #endif // AXObjectImpl_h 834 #endif // AXObjectImpl_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698