| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008, 2009, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008, 2009, 2011 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 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 // This may be out of range - the calling function should clip this | 702 // This may be out of range - the calling function should clip this |
| 703 // to the available range. | 703 // to the available range. |
| 704 static int computeBestScrollOffset(int currentScrollOffset, int subfocusMin, int
subfocusMax, int objectMin, int objectMax, int viewportMin, int viewportMax) | 704 static int computeBestScrollOffset(int currentScrollOffset, int subfocusMin, int
subfocusMax, int objectMin, int objectMax, int viewportMin, int viewportMax) |
| 705 { | 705 { |
| 706 int viewportSize = viewportMax - viewportMin; | 706 int viewportSize = viewportMax - viewportMin; |
| 707 | 707 |
| 708 // If the object size is larger than the viewport size, consider | 708 // If the object size is larger than the viewport size, consider |
| 709 // only a portion that's as large as the viewport, centering on | 709 // only a portion that's as large as the viewport, centering on |
| 710 // the subfocus as much as possible. | 710 // the subfocus as much as possible. |
| 711 if (objectMax - objectMin > viewportSize) { | 711 if (objectMax - objectMin > viewportSize) { |
| 712 // Subfocus must be within focus: | 712 // Since it's impossible to fit the whole object in the |
| 713 // viewport, exit now if the subfocus is already within the viewport. |
| 714 if (subfocusMin - currentScrollOffset >= viewportMin |
| 715 && subfocusMax - currentScrollOffset <= viewportMax) |
| 716 return currentScrollOffset; |
| 717 |
| 718 // Subfocus must be within focus. |
| 713 subfocusMin = std::max(subfocusMin, objectMin); | 719 subfocusMin = std::max(subfocusMin, objectMin); |
| 714 subfocusMax = std::min(subfocusMax, objectMax); | 720 subfocusMax = std::min(subfocusMax, objectMax); |
| 715 | 721 |
| 716 // Subfocus must be no larger than the viewport size; favor top/left. | 722 // Subfocus must be no larger than the viewport size; favor top/left. |
| 717 if (subfocusMax - subfocusMin > viewportSize) | 723 if (subfocusMax - subfocusMin > viewportSize) |
| 718 subfocusMax = subfocusMin + viewportSize; | 724 subfocusMax = subfocusMin + viewportSize; |
| 719 | 725 |
| 720 // Compute the size of an object centered on the subfocus, the size of t
he viewport. | 726 // Compute the size of an object centered on the subfocus, the size of t
he viewport. |
| 721 int centeredObjectMin = (subfocusMin + subfocusMax - viewportSize) / 2; | 727 int centeredObjectMin = (subfocusMin + subfocusMax - viewportSize) / 2; |
| 722 int centeredObjectMax = centeredObjectMin + viewportSize; | 728 int centeredObjectMax = centeredObjectMin + viewportSize; |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 918 return ToggleButtonRole; | 924 return ToggleButtonRole; |
| 919 if (ariaHasPopup()) | 925 if (ariaHasPopup()) |
| 920 return PopUpButtonRole; | 926 return PopUpButtonRole; |
| 921 // We don't contemplate RadioButtonRole, as it depends on the input | 927 // We don't contemplate RadioButtonRole, as it depends on the input |
| 922 // type. | 928 // type. |
| 923 | 929 |
| 924 return ButtonRole; | 930 return ButtonRole; |
| 925 } | 931 } |
| 926 | 932 |
| 927 } // namespace blink | 933 } // namespace blink |
| OLD | NEW |