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 2917 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2928 // If the box is partially offscreen and it's possible to bring it fully | 2928 // If the box is partially offscreen and it's possible to bring it fully |
2929 // onscreen, then animate. | 2929 // onscreen, then animate. |
2930 if (visualViewport.visibleRect().width() >= textboxRectInDocument.width() | 2930 if (visualViewport.visibleRect().width() >= textboxRectInDocument.width() |
2931 && visualViewport.visibleRect().height() >= textboxRectInDocument.height
() | 2931 && visualViewport.visibleRect().height() >= textboxRectInDocument.height
() |
2932 && !visualViewport.visibleRectInDocument().contains(textboxRectInDocumen
t)) | 2932 && !visualViewport.visibleRectInDocument().contains(textboxRectInDocumen
t)) |
2933 needAnimation = true; | 2933 needAnimation = true; |
2934 | 2934 |
2935 if (!needAnimation) | 2935 if (!needAnimation) |
2936 return; | 2936 return; |
2937 | 2937 |
2938 FloatSize targetViewportSize = visualViewport.size(); | 2938 FloatSize targetViewportSize(visualViewport.size()); |
2939 targetViewportSize.scale(1 / newScale); | 2939 targetViewportSize.scale(1 / newScale); |
2940 | 2940 |
2941 if (textboxRectInDocument.width() <= targetViewportSize.width()) { | 2941 if (textboxRectInDocument.width() <= targetViewportSize.width()) { |
2942 // Field is narrower than screen. Try to leave padding on left so field'
s | 2942 // Field is narrower than screen. Try to leave padding on left so field'
s |
2943 // label is visible, but it's more important to ensure entire field is | 2943 // label is visible, but it's more important to ensure entire field is |
2944 // onscreen. | 2944 // onscreen. |
2945 int idealLeftPadding = targetViewportSize.width() * leftBoxRatio; | 2945 int idealLeftPadding = targetViewportSize.width() * leftBoxRatio; |
2946 int maxLeftPaddingKeepingBoxOnscreen = targetViewportSize.width() - text
boxRectInDocument.width(); | 2946 int maxLeftPaddingKeepingBoxOnscreen = targetViewportSize.width() - text
boxRectInDocument.width(); |
2947 newScroll.setX(textboxRectInDocument.x() - std::min<int>(idealLeftPaddin
g, maxLeftPaddingKeepingBoxOnscreen)); | 2947 newScroll.setX(textboxRectInDocument.x() - std::min<int>(idealLeftPaddin
g, maxLeftPaddingKeepingBoxOnscreen)); |
2948 } else { | 2948 } else { |
(...skipping 1517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4466 if (m_pageColorOverlay) | 4466 if (m_pageColorOverlay) |
4467 m_pageColorOverlay->update(); | 4467 m_pageColorOverlay->update(); |
4468 if (InspectorOverlay* overlay = inspectorOverlay()) { | 4468 if (InspectorOverlay* overlay = inspectorOverlay()) { |
4469 PageOverlay* inspectorPageOverlay = overlay->pageOverlay(); | 4469 PageOverlay* inspectorPageOverlay = overlay->pageOverlay(); |
4470 if (inspectorPageOverlay) | 4470 if (inspectorPageOverlay) |
4471 inspectorPageOverlay->update(); | 4471 inspectorPageOverlay->update(); |
4472 } | 4472 } |
4473 } | 4473 } |
4474 | 4474 |
4475 } // namespace blink | 4475 } // namespace blink |
OLD | NEW |