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

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

Issue 1942953003: Accessible setSelection function should use VisiblePositions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add test for selecting whole element Created 4 years, 7 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/core/editing/EditingUtilities.h ('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) 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2008 Apple 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 1922 matching lines...) Expand 10 before | Expand all | Expand 10 after
1933 focusObject = focusObject->parentObject(); 1933 focusObject = focusObject->parentObject();
1934 } 1934 }
1935 1935
1936 if (!anchorNode || !focusNode) 1936 if (!anchorNode || !focusNode)
1937 return; 1937 return;
1938 1938
1939 LocalFrame* frame = getLayoutObject()->frame(); 1939 LocalFrame* frame = getLayoutObject()->frame();
1940 if (!frame) 1940 if (!frame)
1941 return; 1941 return;
1942 1942
1943 frame->selection().setSelection(VisibleSelection( 1943 // Set the selection based on visible positions, because the offsets in acce ssibility nodes
1944 Position(anchorNode, selection.anchorOffset), 1944 // are based on visible indexes, which often skips redundant whitespace, for example.
1945 Position(focusNode, selection.focusOffset))); 1945 VisiblePosition anchorVisiblePosition = anchorNode->isTextNode()
1946 ? blink::visiblePositionForIndex(selection.anchorOffset, anchorNode->par entNode())
1947 : createVisiblePosition(Position(anchorNode, selection.anchorOffset));
1948 VisiblePosition focusVisiblePosition = focusNode->isTextNode()
1949 ? blink::visiblePositionForIndex(selection.focusOffset, focusNode->paren tNode())
1950 : createVisiblePosition(Position(focusNode, selection.focusOffset));
1951 frame->selection().setSelection(VisibleSelection(anchorVisiblePosition, focu sVisiblePosition));
1946 } 1952 }
1947 1953
1948 bool AXLayoutObject::isValidSelectionBound(const AXObject* boundObject) const 1954 bool AXLayoutObject::isValidSelectionBound(const AXObject* boundObject) const
1949 { 1955 {
1950 return getLayoutObject() && boundObject && !boundObject->isDetached() 1956 return getLayoutObject() && boundObject && !boundObject->isDetached()
1951 && boundObject->isAXLayoutObject() && boundObject->getLayoutObject() 1957 && boundObject->isAXLayoutObject() && boundObject->getLayoutObject()
1952 && boundObject->getLayoutObject()->frame() == getLayoutObject()->frame() 1958 && boundObject->getLayoutObject()->frame() == getLayoutObject()->frame()
1953 && &boundObject->axObjectCache() == &axObjectCache(); 1959 && &boundObject->axObjectCache() == &axObjectCache();
1954 } 1960 }
1955 1961
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
2471 if (label && label->layoutObject()) { 2477 if (label && label->layoutObject()) {
2472 LayoutRect labelRect = axObjectCache().getOrCreate(label)->elementRe ct(); 2478 LayoutRect labelRect = axObjectCache().getOrCreate(label)->elementRe ct();
2473 result.unite(labelRect); 2479 result.unite(labelRect);
2474 } 2480 }
2475 } 2481 }
2476 2482
2477 return result; 2483 return result;
2478 } 2484 }
2479 2485
2480 } // namespace blink 2486 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/EditingUtilities.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698