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

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

Issue 1300113006: Fixed AXLayoutObject::getSelection() so that it doesn't return nullptr for anchor and focus objects. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 4 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 /* 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 1847 matching lines...) Expand 10 before | Expand all | Expand 10 after
1858 int focusOffset = selectionRange->endOffset(); 1858 int focusOffset = selectionRange->endOffset();
1859 ASSERT(focusOffset >= 0); 1859 ASSERT(focusOffset >= 0);
1860 1860
1861 Node* anchorNode = selectionRange->startContainer(); 1861 Node* anchorNode = selectionRange->startContainer();
1862 ASSERT(anchorNode); 1862 ASSERT(anchorNode);
1863 1863
1864 RefPtrWillBeRawPtr<AXObject> anchorObject = nullptr; 1864 RefPtrWillBeRawPtr<AXObject> anchorObject = nullptr;
1865 // Find the closest node that has a corresponding AXObject. 1865 // Find the closest node that has a corresponding AXObject.
1866 // This is because some nodes may be aria hidden or might not even have 1866 // This is because some nodes may be aria hidden or might not even have
1867 // a layout object if they are part of the shadow DOM. 1867 // a layout object if they are part of the shadow DOM.
1868 while (anchorNode && !getUnignoredObjectFromNode(*anchorNode)) { 1868 while (anchorNode
1869 && !(anchorObject = getUnignoredObjectFromNode(*anchorNode))) {
1869 if (anchorNode->nextSibling()) 1870 if (anchorNode->nextSibling())
1870 anchorNode = anchorNode->nextSibling(); 1871 anchorNode = anchorNode->nextSibling();
1871 else 1872 else
1872 anchorNode = anchorNode->parentNode(); 1873 anchorNode = anchorNode->parentNode();
1873 } 1874 }
1874 if (anchorNode != selectionRange->startContainer()) 1875 if (anchorNode != selectionRange->startContainer())
1875 anchorOffset = 0; 1876 anchorOffset = 0;
1876 1877
1877 Node* focusNode = selectionRange->endContainer(); 1878 Node* focusNode = selectionRange->endContainer();
1878 ASSERT(focusNode); 1879 ASSERT(focusNode);
1879 1880
1880 RefPtrWillBeRawPtr<AXObject> focusObject = nullptr; 1881 RefPtrWillBeRawPtr<AXObject> focusObject = nullptr;
1881 while (focusNode && !getUnignoredObjectFromNode(*focusNode)) { 1882 while (focusNode
1883 && !(focusObject = getUnignoredObjectFromNode(*focusNode))) {
1882 if (focusNode->previousSibling()) 1884 if (focusNode->previousSibling())
1883 focusNode = focusNode->previousSibling(); 1885 focusNode = focusNode->previousSibling();
1884 else 1886 else
1885 focusNode = focusNode->parentNode(); 1887 focusNode = focusNode->parentNode();
1886 } 1888 }
1887 if (focusNode != selectionRange->endContainer()) 1889 if (focusNode != selectionRange->endContainer())
1888 focusOffset = 0; 1890 focusOffset = 0;
1889 1891
1890 if (!anchorObject || !focusObject) 1892 if (!anchorObject || !focusObject)
1891 return AXRange(); 1893 return AXRange();
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after
2645 if (label && label->layoutObject()) { 2647 if (label && label->layoutObject()) {
2646 LayoutRect labelRect = axObjectCache().getOrCreate(label)->elementRe ct(); 2648 LayoutRect labelRect = axObjectCache().getOrCreate(label)->elementRe ct();
2647 result.unite(labelRect); 2649 result.unite(labelRect);
2648 } 2650 }
2649 } 2651 }
2650 2652
2651 return result; 2653 return result;
2652 } 2654 }
2653 2655
2654 } // namespace blink 2656 } // namespace blink
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