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

Side by Side Diff: Source/web/WebViewImpl.cpp

Issue 329183002: Removing "using" declarations that import names in the C++ Standard library. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed Trybot Errors Created 6 years, 6 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 | « Source/web/WebPluginScrollbarImpl.cpp ('k') | Source/web/tests/ScrollAnimatorNoneTest.cpp » ('j') | 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) 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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 154
155 #if USE(DEFAULT_RENDER_THEME) 155 #if USE(DEFAULT_RENDER_THEME)
156 #include "core/rendering/RenderThemeChromiumDefault.h" 156 #include "core/rendering/RenderThemeChromiumDefault.h"
157 #endif 157 #endif
158 158
159 // Get rid of WTF's pow define so we can use std::pow. 159 // Get rid of WTF's pow define so we can use std::pow.
160 #undef pow 160 #undef pow
161 #include <cmath> // for std::pow 161 #include <cmath> // for std::pow
162 162
163 using namespace WebCore; 163 using namespace WebCore;
164 using namespace std;
165 164
166 // The following constants control parameters for automated scaling of webpages 165 // The following constants control parameters for automated scaling of webpages
167 // (such as due to a double tap gesture or find in page etc.). These are 166 // (such as due to a double tap gesture or find in page etc.). These are
168 // experimentally determined. 167 // experimentally determined.
169 static const int touchPointPadding = 32; 168 static const int touchPointPadding = 32;
170 static const int nonUserInitiatedPointPadding = 11; 169 static const int nonUserInitiatedPointPadding = 11;
171 static const float minScaleDifference = 0.01f; 170 static const float minScaleDifference = 0.01f;
172 static const float doubleTapZoomContentDefaultMargin = 5; 171 static const float doubleTapZoomContentDefaultMargin = 5;
173 static const float doubleTapZoomContentMinimumMargin = 2; 172 static const float doubleTapZoomContentMinimumMargin = 2;
174 static const double doubleTapZoomAnimationDurationInSeconds = 0.25; 173 static const double doubleTapZoomAnimationDurationInSeconds = 0.25;
(...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after
1058 maxSize = mainFrame()->contentsSize(); 1057 maxSize = mainFrame()->contentsSize();
1059 IntSize scrollOffset; 1058 IntSize scrollOffset;
1060 if (mainFrame()) 1059 if (mainFrame())
1061 scrollOffset = mainFrame()->scrollOffset(); 1060 scrollOffset = mainFrame()->scrollOffset();
1062 int leftMargin = targetMargin; 1061 int leftMargin = targetMargin;
1063 int rightMargin = targetMargin; 1062 int rightMargin = targetMargin;
1064 1063
1065 const int absoluteSourceX = source.x + scrollOffset.width(); 1064 const int absoluteSourceX = source.x + scrollOffset.width();
1066 if (leftMargin > absoluteSourceX) { 1065 if (leftMargin > absoluteSourceX) {
1067 leftMargin = absoluteSourceX; 1066 leftMargin = absoluteSourceX;
1068 rightMargin = max(leftMargin, minimumMargin); 1067 rightMargin = std::max(leftMargin, minimumMargin);
1069 } 1068 }
1070 1069
1071 const int maximumRightMargin = maxSize.width - (source.width + absoluteSourc eX); 1070 const int maximumRightMargin = maxSize.width - (source.width + absoluteSourc eX);
1072 if (rightMargin > maximumRightMargin) { 1071 if (rightMargin > maximumRightMargin) {
1073 rightMargin = maximumRightMargin; 1072 rightMargin = maximumRightMargin;
1074 leftMargin = min(leftMargin, max(rightMargin, minimumMargin)); 1073 leftMargin = std::min(leftMargin, std::max(rightMargin, minimumMargin));
1075 } 1074 }
1076 1075
1077 const int newWidth = source.width + leftMargin + rightMargin; 1076 const int newWidth = source.width + leftMargin + rightMargin;
1078 const int newX = source.x - leftMargin; 1077 const int newX = source.x - leftMargin;
1079 1078
1080 ASSERT(newWidth >= 0); 1079 ASSERT(newWidth >= 0);
1081 ASSERT(scrollOffset.width() + newX + newWidth <= maxSize.width); 1080 ASSERT(scrollOffset.width() + newX + newWidth <= maxSize.width);
1082 1081
1083 return WebRect(newX, source.y, newWidth, source.height); 1082 return WebRect(newX, source.y, newWidth, source.height);
1084 } 1083 }
(...skipping 24 matching lines...) Expand all
1109 // need to express them in post-scale size. To do that we'd need to know 1108 // need to express them in post-scale size. To do that we'd need to know
1110 // the scale we're scaling to, but that depends on the margins. Instead 1109 // the scale we're scaling to, but that depends on the margins. Instead
1111 // we express them as a fraction of the target rectangle: this will be 1110 // we express them as a fraction of the target rectangle: this will be
1112 // correct if we end up fully zooming to it, and won't matter if we 1111 // correct if we end up fully zooming to it, and won't matter if we
1113 // don't. 1112 // don't.
1114 rect = widenRectWithinPageBounds(rect, 1113 rect = widenRectWithinPageBounds(rect,
1115 static_cast<int>(defaultMargin * rect.width / m_size.width), 1114 static_cast<int>(defaultMargin * rect.width / m_size.width),
1116 static_cast<int>(minimumMargin * rect.width / m_size.width)); 1115 static_cast<int>(minimumMargin * rect.width / m_size.width));
1117 // Fit block to screen, respecting limits. 1116 // Fit block to screen, respecting limits.
1118 scale = static_cast<float>(m_size.width) / rect.width; 1117 scale = static_cast<float>(m_size.width) / rect.width;
1119 scale = min(scale, legibleScale()); 1118 scale = std::min(scale, legibleScale());
1120 if (pageScaleFactor() < defaultScaleWhenAlreadyLegible) 1119 if (pageScaleFactor() < defaultScaleWhenAlreadyLegible)
1121 scale = max(scale, defaultScaleWhenAlreadyLegible); 1120 scale = std::max(scale, defaultScaleWhenAlreadyLegible);
1122 scale = clampPageScaleFactorToLimits(scale); 1121 scale = clampPageScaleFactorToLimits(scale);
1123 } 1122 }
1124 1123
1125 // FIXME: If this is being called for auto zoom during find in page, 1124 // FIXME: If this is being called for auto zoom during find in page,
1126 // then if the user manually zooms in it'd be nice to preserve the 1125 // then if the user manually zooms in it'd be nice to preserve the
1127 // relative increase in zoom they caused (if they zoom out then it's ok 1126 // relative increase in zoom they caused (if they zoom out then it's ok
1128 // to zoom them back in again). This isn't compatible with our current 1127 // to zoom them back in again). This isn't compatible with our current
1129 // double-tap zoom strategy (fitting the containing block to the screen) 1128 // double-tap zoom strategy (fitting the containing block to the screen)
1130 // though. 1129 // though.
1131 1130
1132 float screenWidth = m_size.width / scale; 1131 float screenWidth = m_size.width / scale;
1133 float screenHeight = m_size.height / scale; 1132 float screenHeight = m_size.height / scale;
1134 1133
1135 // Scroll to vertically align the block. 1134 // Scroll to vertically align the block.
1136 if (rect.height < screenHeight) { 1135 if (rect.height < screenHeight) {
1137 // Vertically center short blocks. 1136 // Vertically center short blocks.
1138 rect.y -= 0.5 * (screenHeight - rect.height); 1137 rect.y -= 0.5 * (screenHeight - rect.height);
1139 } else { 1138 } else {
1140 // Ensure position we're zooming to (+ padding) isn't off the bottom of 1139 // Ensure position we're zooming to (+ padding) isn't off the bottom of
1141 // the screen. 1140 // the screen.
1142 rect.y = max<float>(rect.y, hitPoint.y + padding - screenHeight); 1141 rect.y = std::max<float>(rect.y, hitPoint.y + padding - screenHeight);
1143 } // Otherwise top align the block. 1142 } // Otherwise top align the block.
1144 1143
1145 // Do the same thing for horizontal alignment. 1144 // Do the same thing for horizontal alignment.
1146 if (rect.width < screenWidth) 1145 if (rect.width < screenWidth)
1147 rect.x -= 0.5 * (screenWidth - rect.width); 1146 rect.x -= 0.5 * (screenWidth - rect.width);
1148 else 1147 else
1149 rect.x = max<float>(rect.x, hitPoint.x + padding - screenWidth); 1148 rect.x = std::max<float>(rect.x, hitPoint.x + padding - screenWidth);
1150 scroll.x = rect.x; 1149 scroll.x = rect.x;
1151 scroll.y = rect.y; 1150 scroll.y = rect.y;
1152 1151
1153 scale = clampPageScaleFactorToLimits(scale); 1152 scale = clampPageScaleFactorToLimits(scale);
1154 scroll = mainFrameImpl()->frameView()->windowToContents(scroll); 1153 scroll = mainFrameImpl()->frameView()->windowToContents(scroll);
1155 scroll = clampOffsetAtScale(scroll, scale); 1154 scroll = clampOffsetAtScale(scroll, scale);
1156 } 1155 }
1157 1156
1158 static bool invokesHandCursor(Node* node, LocalFrame* frame) 1157 static bool invokesHandCursor(Node* node, LocalFrame* frame)
1159 { 1158 {
(...skipping 1439 matching lines...) Expand 10 before | Expand all | Expand 10 after
2599 2598
2600 int viewWidth = m_size.width / newScale; 2599 int viewWidth = m_size.width / newScale;
2601 int viewHeight = m_size.height / newScale; 2600 int viewHeight = m_size.height / newScale;
2602 2601
2603 if (textboxRectInDocumentCoordinates.width() <= viewWidth) { 2602 if (textboxRectInDocumentCoordinates.width() <= viewWidth) {
2604 // Field is narrower than screen. Try to leave padding on left so field' s 2603 // Field is narrower than screen. Try to leave padding on left so field' s
2605 // label is visible, but it's more important to ensure entire field is 2604 // label is visible, but it's more important to ensure entire field is
2606 // onscreen. 2605 // onscreen.
2607 int idealLeftPadding = viewWidth * leftBoxRatio; 2606 int idealLeftPadding = viewWidth * leftBoxRatio;
2608 int maxLeftPaddingKeepingBoxOnscreen = viewWidth - textboxRectInDocument Coordinates.width(); 2607 int maxLeftPaddingKeepingBoxOnscreen = viewWidth - textboxRectInDocument Coordinates.width();
2609 newScroll.setX(textboxRectInDocumentCoordinates.x() - min<int>(idealLeft Padding, maxLeftPaddingKeepingBoxOnscreen)); 2608 newScroll.setX(textboxRectInDocumentCoordinates.x() - std::min<int>(idea lLeftPadding, maxLeftPaddingKeepingBoxOnscreen));
2610 } else { 2609 } else {
2611 // Field is wider than screen. Try to left-align field, unless caret wou ld 2610 // Field is wider than screen. Try to left-align field, unless caret wou ld
2612 // be offscreen, in which case right-align the caret. 2611 // be offscreen, in which case right-align the caret.
2613 newScroll.setX(max<int>(textboxRectInDocumentCoordinates.x(), caretInDoc umentCoordinates.x() + caretInDocumentCoordinates.width() + caretPadding - viewW idth)); 2612 newScroll.setX(std::max<int>(textboxRectInDocumentCoordinates.x(), caret InDocumentCoordinates.x() + caretInDocumentCoordinates.width() + caretPadding - viewWidth));
2614 } 2613 }
2615 if (textboxRectInDocumentCoordinates.height() <= viewHeight) { 2614 if (textboxRectInDocumentCoordinates.height() <= viewHeight) {
2616 // Field is shorter than screen. Vertically center it. 2615 // Field is shorter than screen. Vertically center it.
2617 newScroll.setY(textboxRectInDocumentCoordinates.y() - (viewHeight - text boxRectInDocumentCoordinates.height()) / 2); 2616 newScroll.setY(textboxRectInDocumentCoordinates.y() - (viewHeight - text boxRectInDocumentCoordinates.height()) / 2);
2618 } else { 2617 } else {
2619 // Field is taller than screen. Try to top align field, unless caret wou ld 2618 // Field is taller than screen. Try to top align field, unless caret wou ld
2620 // be offscreen, in which case bottom-align the caret. 2619 // be offscreen, in which case bottom-align the caret.
2621 newScroll.setY(max<int>(textboxRectInDocumentCoordinates.y(), caretInDoc umentCoordinates.y() + caretInDocumentCoordinates.height() + caretPadding - view Height)); 2620 newScroll.setY(std::max<int>(textboxRectInDocumentCoordinates.y(), caret InDocumentCoordinates.y() + caretInDocumentCoordinates.height() + caretPadding - viewHeight));
2622 } 2621 }
2623 2622
2624 needAnimation = false; 2623 needAnimation = false;
2625 // If we are at less than the target zoom level, zoom in. 2624 // If we are at less than the target zoom level, zoom in.
2626 if (deltaScale > minScaleChangeToTriggerZoom) 2625 if (deltaScale > minScaleChangeToTriggerZoom)
2627 needAnimation = true; 2626 needAnimation = true;
2628 // If the caret is offscreen, then animate. 2627 // If the caret is offscreen, then animate.
2629 IntRect sizeRect(0, 0, viewWidth, viewHeight); 2628 IntRect sizeRect(0, 0, viewWidth, viewHeight);
2630 if (!sizeRect.contains(caret)) 2629 if (!sizeRect.contains(caret))
2631 needAnimation = true; 2630 needAnimation = true;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
2688 frame->setTextZoomFactor(textZoomFactor); 2687 frame->setTextZoomFactor(textZoomFactor);
2689 2688
2690 return textZoomFactor; 2689 return textZoomFactor;
2691 } 2690 }
2692 2691
2693 void WebViewImpl::fullFramePluginZoomLevelChanged(double zoomLevel) 2692 void WebViewImpl::fullFramePluginZoomLevelChanged(double zoomLevel)
2694 { 2693 {
2695 if (zoomLevel == m_zoomLevel) 2694 if (zoomLevel == m_zoomLevel)
2696 return; 2695 return;
2697 2696
2698 m_zoomLevel = max(min(zoomLevel, m_maximumZoomLevel), m_minimumZoomLevel); 2697 m_zoomLevel = std::max(std::min(zoomLevel, m_maximumZoomLevel), m_minimumZoo mLevel);
2699 m_client->zoomLevelChanged(); 2698 m_client->zoomLevelChanged();
2700 } 2699 }
2701 2700
2702 double WebView::zoomLevelToZoomFactor(double zoomLevel) 2701 double WebView::zoomLevelToZoomFactor(double zoomLevel)
2703 { 2702 {
2704 return pow(textSizeMultiplierRatio, zoomLevel); 2703 return pow(textSizeMultiplierRatio, zoomLevel);
2705 } 2704 }
2706 2705
2707 double WebView::zoomFactorToZoomLevel(double factor) 2706 double WebView::zoomFactorToZoomLevel(double factor)
2708 { 2707 {
(...skipping 1395 matching lines...) Expand 10 before | Expand all | Expand 10 after
4104 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints(); 4103 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints();
4105 4104
4106 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) 4105 if (!mainFrameImpl() || !mainFrameImpl()->frameView())
4107 return false; 4106 return false;
4108 4107
4109 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width 4108 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width
4110 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); 4109 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1);
4111 } 4110 }
4112 4111
4113 } // namespace blink 4112 } // namespace blink
OLDNEW
« no previous file with comments | « Source/web/WebPluginScrollbarImpl.cpp ('k') | Source/web/tests/ScrollAnimatorNoneTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698