OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2011, 2012 Google 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 2709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2720 WebRect caret, unusedEnd; | 2720 WebRect caret, unusedEnd; |
2721 selectionBounds(caret, unusedEnd); | 2721 selectionBounds(caret, unusedEnd); |
2722 IntRect unscaledCaret = caret; | 2722 IntRect unscaledCaret = caret; |
2723 unscaledCaret.scale(1 / pageScaleFactor()); | 2723 unscaledCaret.scale(1 / pageScaleFactor()); |
2724 caret = unscaledCaret; | 2724 caret = unscaledCaret; |
2725 | 2725 |
2726 // Pick a scale which is reasonably readable. This is the scale at which | 2726 // Pick a scale which is reasonably readable. This is the scale at which |
2727 // the caret height will become minReadableCaretHeight (adjusted for dpi | 2727 // the caret height will become minReadableCaretHeight (adjusted for dpi |
2728 // and font scale factor). | 2728 // and font scale factor). |
2729 newScale = clampPageScaleFactorToLimits(legibleScale() * minReadableCaretHei
ght / caret.height); | 2729 newScale = clampPageScaleFactorToLimits(legibleScale() * minReadableCaretHei
ght / caret.height); |
| 2730 newScale = std::max(newScale, pageScaleFactor()); |
2730 const float deltaScale = newScale / pageScaleFactor(); | 2731 const float deltaScale = newScale / pageScaleFactor(); |
2731 | 2732 |
2732 // Convert the rects to absolute space in the new scale. | 2733 // Convert the rects to absolute space in the new scale. |
2733 IntRect textboxRectInDocumentCoordinates = textboxRect; | 2734 IntRect textboxRectInDocumentCoordinates = textboxRect; |
2734 textboxRectInDocumentCoordinates.move(mainFrame()->scrollOffset()); | 2735 textboxRectInDocumentCoordinates.move(mainFrame()->scrollOffset()); |
2735 IntRect caretInDocumentCoordinates = caret; | 2736 IntRect caretInDocumentCoordinates = caret; |
2736 caretInDocumentCoordinates.move(mainFrame()->scrollOffset()); | 2737 caretInDocumentCoordinates.move(mainFrame()->scrollOffset()); |
2737 | 2738 |
2738 int viewWidth = m_size.width / newScale; | 2739 int viewWidth = m_size.width / newScale; |
2739 int viewHeight = m_size.height / newScale; | 2740 int viewHeight = m_size.height / newScale; |
(...skipping 18 matching lines...) Expand all Loading... |
2758 // be offscreen, in which case bottom-align the caret. | 2759 // be offscreen, in which case bottom-align the caret. |
2759 newScroll.setY(std::max<int>(textboxRectInDocumentCoordinates.y(), caret
InDocumentCoordinates.y() + caretInDocumentCoordinates.height() + caretPadding -
viewHeight)); | 2760 newScroll.setY(std::max<int>(textboxRectInDocumentCoordinates.y(), caret
InDocumentCoordinates.y() + caretInDocumentCoordinates.height() + caretPadding -
viewHeight)); |
2760 } | 2761 } |
2761 | 2762 |
2762 needAnimation = false; | 2763 needAnimation = false; |
2763 // If we are at less than the target zoom level, zoom in. | 2764 // If we are at less than the target zoom level, zoom in. |
2764 if (deltaScale > minScaleChangeToTriggerZoom) | 2765 if (deltaScale > minScaleChangeToTriggerZoom) |
2765 needAnimation = true; | 2766 needAnimation = true; |
2766 // If the caret is offscreen, then animate. | 2767 // If the caret is offscreen, then animate. |
2767 IntRect sizeRect(0, 0, viewWidth, viewHeight); | 2768 IntRect sizeRect(0, 0, viewWidth, viewHeight); |
| 2769 sizeRect.scale(newScale / pageScaleFactor()); |
2768 if (!sizeRect.contains(caret)) | 2770 if (!sizeRect.contains(caret)) |
2769 needAnimation = true; | 2771 needAnimation = true; |
2770 // If the box is partially offscreen and it's possible to bring it fully | 2772 // If the box is partially offscreen and it's possible to bring it fully |
2771 // onscreen, then animate. | 2773 // onscreen, then animate. |
2772 if (sizeRect.contains(textboxRectInDocumentCoordinates.width(), textboxRectI
nDocumentCoordinates.height()) && !sizeRect.contains(textboxRect)) | 2774 if (sizeRect.contains(textboxRectInDocumentCoordinates.width(), textboxRectI
nDocumentCoordinates.height()) && !sizeRect.contains(textboxRect)) |
2773 needAnimation = true; | 2775 needAnimation = true; |
2774 } | 2776 } |
2775 | 2777 |
2776 void WebViewImpl::advanceFocus(bool reverse) | 2778 void WebViewImpl::advanceFocus(bool reverse) |
2777 { | 2779 { |
(...skipping 1497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4275 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi
nedConstraints(); | 4277 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi
nedConstraints(); |
4276 | 4278 |
4277 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) | 4279 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) |
4278 return false; | 4280 return false; |
4279 | 4281 |
4280 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width | 4282 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width |
4281 || (constraints.minimumScale == constraints.maximumScale && constraints.
minimumScale != -1); | 4283 || (constraints.minimumScale == constraints.maximumScale && constraints.
minimumScale != -1); |
4282 } | 4284 } |
4283 | 4285 |
4284 } // namespace blink | 4286 } // namespace blink |
OLD | NEW |