| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. | 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. |
| 5 * | 5 * |
| 6 * Other contributors: | 6 * Other contributors: |
| 7 * Robert O'Callahan <roc+@cs.cmu.edu> | 7 * Robert O'Callahan <roc+@cs.cmu.edu> |
| 8 * David Baron <dbaron@fas.harvard.edu> | 8 * David Baron <dbaron@fas.harvard.edu> |
| 9 * Christian Biesinger <cbiesinger@web.de> | 9 * Christian Biesinger <cbiesinger@web.de> |
| 10 * Randall Jesup <rjesup@wgate.com> | 10 * Randall Jesup <rjesup@wgate.com> |
| 11 * Roland Mainz <roland.mainz@informatik.med.uni-giessen.de> | 11 * Roland Mainz <roland.mainz@informatik.med.uni-giessen.de> |
| 12 * Josh Soref <timeless@mac.com> | 12 * Josh Soref <timeless@mac.com> |
| 13 * Boris Zbarsky <bzbarsky@mit.edu> | 13 * Boris Zbarsky <bzbarsky@mit.edu> |
| 14 * | 14 * |
| 15 * This library is free software; you can redistribute it and/or | 15 * This library is free software; you can redistribute it and/or |
| 16 * modify it under the terms of the GNU Lesser General Public | 16 * modify it under the terms of the GNU Lesser General Public |
| 17 * License as published by the Free Software Foundation; either | 17 * License as published by the Free Software Foundation; either |
| 18 * version 2.1 of the License, or (at your option) any later version. | 18 * version 2.1 of the License, or (at your option) any later version. |
| 19 * | 19 * |
| 20 * This library is distributed in the hope that it will be useful, | 20 * This library is distributed in the hope that it will be useful, |
| 21 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 21 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 23 * Lesser General Public License for more details. | 23 * Lesser General Public License for more details. |
| 24 * | 24 * |
| 25 * You should have received a copy of the GNU Lesser General Public | 25 * You should have received a copy of the GNU Lesser General Public |
| 26 * License along with this library; if not, write to the Free Software | 26 * License along with this library; if not, write to the Free Software |
| 27 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 US
A | 27 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
| 28 * | 28 * |
| 29 * Alternatively, the contents of this file may be used under the terms | 29 * Alternatively, the contents of this file may be used under the terms |
| 30 * of either the Mozilla Public License Version 1.1, found at | 30 * of either the Mozilla Public License Version 1.1, found at |
| 31 * http://www.mozilla.org/MPL/ (the "MPL") or the GNU General Public | 31 * http://www.mozilla.org/MPL/ (the "MPL") or the GNU General Public |
| 32 * License Version 2.0, found at http://www.fsf.org/copyleft/gpl.html | 32 * License Version 2.0, found at http://www.fsf.org/copyleft/gpl.html |
| 33 * (the "GPL"), in which case the provisions of the MPL or the GPL are | 33 * (the "GPL"), in which case the provisions of the MPL or the GPL are |
| 34 * applicable instead of those above. If you wish to allow use of your | 34 * applicable instead of those above. If you wish to allow use of your |
| 35 * version of this file only under the terms of one of those two | 35 * version of this file only under the terms of one of those two |
| 36 * licenses (the MPL or the GPL) and not to allow others to use your | 36 * licenses (the MPL or the GPL) and not to allow others to use your |
| 37 * version of this file under the LGPL, indicate your decision by | 37 * version of this file under the LGPL, indicate your decision by |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 exposeRect.width(), nonZeroVisibleRect.height()); | 80 exposeRect.width(), nonZeroVisibleRect.height()); |
| 81 LayoutUnit intersectWidth = | 81 LayoutUnit intersectWidth = |
| 82 intersection(nonZeroVisibleRect, exposeRectX).width(); | 82 intersection(nonZeroVisibleRect, exposeRectX).width(); |
| 83 if (intersectWidth == exposeRect.width() || | 83 if (intersectWidth == exposeRect.width() || |
| 84 intersectWidth >= MIN_INTERSECT_FOR_REVEAL) { | 84 intersectWidth >= MIN_INTERSECT_FOR_REVEAL) { |
| 85 // If the rectangle is fully visible, use the specified visible behavior. | 85 // If the rectangle is fully visible, use the specified visible behavior. |
| 86 // If the rectangle is partially visible, but over a certain threshold, | 86 // If the rectangle is partially visible, but over a certain threshold, |
| 87 // then treat it as fully visible to avoid unnecessary horizontal scrolling | 87 // then treat it as fully visible to avoid unnecessary horizontal scrolling |
| 88 scrollX = getVisibleBehavior(alignX); | 88 scrollX = getVisibleBehavior(alignX); |
| 89 } else if (intersectWidth == nonZeroVisibleRect.width()) { | 89 } else if (intersectWidth == nonZeroVisibleRect.width()) { |
| 90 // If the rect is bigger than the visible area, don't bother trying to cente
r. Other alignments will work. | 90 // If the rect is bigger than the visible area, don't bother trying to |
| 91 // center. Other alignments will work. |
| 91 scrollX = getVisibleBehavior(alignX); | 92 scrollX = getVisibleBehavior(alignX); |
| 92 if (scrollX == ScrollAlignmentCenter) | 93 if (scrollX == ScrollAlignmentCenter) |
| 93 scrollX = ScrollAlignmentNoScroll; | 94 scrollX = ScrollAlignmentNoScroll; |
| 94 } else if (intersectWidth > 0) { | 95 } else if (intersectWidth > 0) { |
| 95 // If the rectangle is partially visible, but not above the minimum threshol
d, use the specified partial behavior | 96 // If the rectangle is partially visible, but not above the minimum |
| 97 // threshold, use the specified partial behavior |
| 96 scrollX = getPartialBehavior(alignX); | 98 scrollX = getPartialBehavior(alignX); |
| 97 } else { | 99 } else { |
| 98 scrollX = getHiddenBehavior(alignX); | 100 scrollX = getHiddenBehavior(alignX); |
| 99 } | 101 } |
| 100 | 102 |
| 101 if (scrollX == ScrollAlignmentClosestEdge) { | 103 if (scrollX == ScrollAlignmentClosestEdge) { |
| 102 // Closest edge is the right in two cases: | 104 // Closest edge is the right in two cases: |
| 103 // (1) exposeRect to the right of and smaller than nonZeroVisibleRect | 105 // (1) exposeRect to the right of and smaller than nonZeroVisibleRect |
| 104 // (2) exposeRect to the left of and larger than nonZeroVisibleRect | 106 // (2) exposeRect to the left of and larger than nonZeroVisibleRect |
| 105 if ((exposeRect.maxX() > nonZeroVisibleRect.maxX() && | 107 if ((exposeRect.maxX() > nonZeroVisibleRect.maxX() && |
| (...skipping 18 matching lines...) Expand all Loading... |
| 124 // Determine the appropriate Y behavior. | 126 // Determine the appropriate Y behavior. |
| 125 ScrollAlignmentBehavior scrollY; | 127 ScrollAlignmentBehavior scrollY; |
| 126 LayoutRect exposeRectY(nonZeroVisibleRect.x(), exposeRect.y(), | 128 LayoutRect exposeRectY(nonZeroVisibleRect.x(), exposeRect.y(), |
| 127 nonZeroVisibleRect.width(), exposeRect.height()); | 129 nonZeroVisibleRect.width(), exposeRect.height()); |
| 128 LayoutUnit intersectHeight = | 130 LayoutUnit intersectHeight = |
| 129 intersection(nonZeroVisibleRect, exposeRectY).height(); | 131 intersection(nonZeroVisibleRect, exposeRectY).height(); |
| 130 if (intersectHeight == exposeRect.height()) { | 132 if (intersectHeight == exposeRect.height()) { |
| 131 // If the rectangle is fully visible, use the specified visible behavior. | 133 // If the rectangle is fully visible, use the specified visible behavior. |
| 132 scrollY = getVisibleBehavior(alignY); | 134 scrollY = getVisibleBehavior(alignY); |
| 133 } else if (intersectHeight == nonZeroVisibleRect.height()) { | 135 } else if (intersectHeight == nonZeroVisibleRect.height()) { |
| 134 // If the rect is bigger than the visible area, don't bother trying to cente
r. Other alignments will work. | 136 // If the rect is bigger than the visible area, don't bother trying to |
| 137 // center. Other alignments will work. |
| 135 scrollY = getVisibleBehavior(alignY); | 138 scrollY = getVisibleBehavior(alignY); |
| 136 if (scrollY == ScrollAlignmentCenter) | 139 if (scrollY == ScrollAlignmentCenter) |
| 137 scrollY = ScrollAlignmentNoScroll; | 140 scrollY = ScrollAlignmentNoScroll; |
| 138 } else if (intersectHeight > 0) { | 141 } else if (intersectHeight > 0) { |
| 139 // If the rectangle is partially visible, use the specified partial behavior | 142 // If the rectangle is partially visible, use the specified partial behavior |
| 140 scrollY = getPartialBehavior(alignY); | 143 scrollY = getPartialBehavior(alignY); |
| 141 } else { | 144 } else { |
| 142 scrollY = getHiddenBehavior(alignY); | 145 scrollY = getHiddenBehavior(alignY); |
| 143 } | 146 } |
| 144 | 147 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 163 else if (scrollY == ScrollAlignmentCenter) | 166 else if (scrollY == ScrollAlignmentCenter) |
| 164 y = exposeRect.y() + | 167 y = exposeRect.y() + |
| 165 (exposeRect.height() - nonZeroVisibleRect.height()) / 2; | 168 (exposeRect.height() - nonZeroVisibleRect.height()) / 2; |
| 166 else | 169 else |
| 167 y = exposeRect.y(); | 170 y = exposeRect.y(); |
| 168 | 171 |
| 169 return LayoutRect(LayoutPoint(x, y), nonZeroVisibleRect.size()); | 172 return LayoutRect(LayoutPoint(x, y), nonZeroVisibleRect.size()); |
| 170 } | 173 } |
| 171 | 174 |
| 172 } // namespace blink | 175 } // namespace blink |
| OLD | NEW |