| 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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 // complicated set of cases handled below. | 653 // complicated set of cases handled below. |
| 655 switch (event.type) { | 654 switch (event.type) { |
| 656 case WebInputEvent::GestureShowPress: | 655 case WebInputEvent::GestureShowPress: |
| 657 // Queue a highlight animation, then hand off to regular handler. | 656 // Queue a highlight animation, then hand off to regular handler. |
| 658 if (settingsImpl()->gestureTapHighlightEnabled()) | 657 if (settingsImpl()->gestureTapHighlightEnabled()) |
| 659 enableTapHighlightAtPoint(platformEvent); | 658 enableTapHighlightAtPoint(platformEvent); |
| 660 break; | 659 break; |
| 661 case WebInputEvent::GestureTapCancel: | 660 case WebInputEvent::GestureTapCancel: |
| 662 case WebInputEvent::GestureTap: | 661 case WebInputEvent::GestureTap: |
| 663 case WebInputEvent::GestureLongPress: | 662 case WebInputEvent::GestureLongPress: |
| 664 for (size_t i = 0; i < m_linkHighlights.size(); ++i) | 663 for (std::size_t i = 0; i < m_linkHighlights.size(); ++i) |
| 665 m_linkHighlights[i]->startHighlightAnimationIfNeeded(); | 664 m_linkHighlights[i]->startHighlightAnimationIfNeeded(); |
| 666 break; | 665 break; |
| 667 default: | 666 default: |
| 668 break; | 667 break; |
| 669 } | 668 } |
| 670 | 669 |
| 671 switch (event.type) { | 670 switch (event.type) { |
| 672 case WebInputEvent::GestureTap: { | 671 case WebInputEvent::GestureTap: { |
| 673 m_client->cancelScheduledContentIntents(); | 672 m_client->cancelScheduledContentIntents(); |
| 674 if (detectContentOnTouch(platformEvent.position())) { | 673 if (detectContentOnTouch(platformEvent.position())) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 693 scaledEvent.data.tap.height = event.data.tap.height / pageScaleFacto
r(); | 692 scaledEvent.data.tap.height = event.data.tap.height / pageScaleFacto
r(); |
| 694 IntRect boundingBox(scaledEvent.x - scaledEvent.data.tap.width / 2,
scaledEvent.y - scaledEvent.data.tap.height / 2, scaledEvent.data.tap.width, sca
ledEvent.data.tap.height); | 693 IntRect boundingBox(scaledEvent.x - scaledEvent.data.tap.width / 2,
scaledEvent.y - scaledEvent.data.tap.height / 2, scaledEvent.data.tap.width, sca
ledEvent.data.tap.height); |
| 695 Vector<IntRect> goodTargets; | 694 Vector<IntRect> goodTargets; |
| 696 WillBeHeapVector<RawPtrWillBeMember<Node> > highlightNodes; | 695 WillBeHeapVector<RawPtrWillBeMember<Node> > highlightNodes; |
| 697 findGoodTouchTargets(boundingBox, mainFrameImpl()->frame(), goodTarg
ets, highlightNodes); | 696 findGoodTouchTargets(boundingBox, mainFrameImpl()->frame(), goodTarg
ets, highlightNodes); |
| 698 // FIXME: replace touch adjustment code when numberOfGoodTargets ==
1? | 697 // FIXME: replace touch adjustment code when numberOfGoodTargets ==
1? |
| 699 // Single candidate case is currently handled by: https://bugs.webki
t.org/show_bug.cgi?id=85101 | 698 // Single candidate case is currently handled by: https://bugs.webki
t.org/show_bug.cgi?id=85101 |
| 700 if (goodTargets.size() >= 2 && m_client && m_client->didTapMultipleT
argets(scaledEvent, goodTargets)) { | 699 if (goodTargets.size() >= 2 && m_client && m_client->didTapMultipleT
argets(scaledEvent, goodTargets)) { |
| 701 if (settingsImpl()->gestureTapHighlightEnabled()) | 700 if (settingsImpl()->gestureTapHighlightEnabled()) |
| 702 enableTapHighlights(highlightNodes); | 701 enableTapHighlights(highlightNodes); |
| 703 for (size_t i = 0; i < m_linkHighlights.size(); ++i) | 702 for (std::size_t i = 0; i < m_linkHighlights.size(); ++i) |
| 704 m_linkHighlights[i]->startHighlightAnimationIfNeeded(); | 703 m_linkHighlights[i]->startHighlightAnimationIfNeeded(); |
| 705 eventSwallowed = true; | 704 eventSwallowed = true; |
| 706 eventCancelled = true; | 705 eventCancelled = true; |
| 707 break; | 706 break; |
| 708 } | 707 } |
| 709 } | 708 } |
| 710 | 709 |
| 711 eventSwallowed = mainFrameImpl()->frame()->eventHandler().handleGestureE
vent(platformEvent); | 710 eventSwallowed = mainFrameImpl()->frame()->eventHandler().handleGestureE
vent(platformEvent); |
| 712 | 711 |
| 713 if (m_selectPopup && m_selectPopup == selectPopup) { | 712 if (m_selectPopup && m_selectPopup == selectPopup) { |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 Loading... |
| 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 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1214 if (highlightNodes.isEmpty()) | 1213 if (highlightNodes.isEmpty()) |
| 1215 return; | 1214 return; |
| 1216 | 1215 |
| 1217 // Always clear any existing highlight when this is invoked, even if we | 1216 // Always clear any existing highlight when this is invoked, even if we |
| 1218 // don't get a new target to highlight. | 1217 // don't get a new target to highlight. |
| 1219 m_linkHighlights.clear(); | 1218 m_linkHighlights.clear(); |
| 1220 | 1219 |
| 1221 // LinkHighlight reads out layout and compositing state, so we need to make
sure that's all up to date. | 1220 // LinkHighlight reads out layout and compositing state, so we need to make
sure that's all up to date. |
| 1222 layout(); | 1221 layout(); |
| 1223 | 1222 |
| 1224 for (size_t i = 0; i < highlightNodes.size(); ++i) { | 1223 for (std::size_t i = 0; i < highlightNodes.size(); ++i) { |
| 1225 Node* node = highlightNodes[i]; | 1224 Node* node = highlightNodes[i]; |
| 1226 | 1225 |
| 1227 if (!node || !node->renderer()) | 1226 if (!node || !node->renderer()) |
| 1228 continue; | 1227 continue; |
| 1229 | 1228 |
| 1230 Color highlightColor = node->renderer()->style()->tapHighlightColor(); | 1229 Color highlightColor = node->renderer()->style()->tapHighlightColor(); |
| 1231 // Safari documentation for -webkit-tap-highlight-color says if the spec
ified color has 0 alpha, | 1230 // Safari documentation for -webkit-tap-highlight-color says if the spec
ified color has 0 alpha, |
| 1232 // then tap highlighting is disabled. | 1231 // then tap highlighting is disabled. |
| 1233 // http://developer.apple.com/library/safari/#documentation/appleapplica
tions/reference/safaricssref/articles/standardcssproperties.html | 1232 // http://developer.apple.com/library/safari/#documentation/appleapplica
tions/reference/safaricssref/articles/standardcssproperties.html |
| 1234 if (!highlightColor.alpha()) | 1233 if (!highlightColor.alpha()) |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1710 m_client->scheduleAnimation(); | 1709 m_client->scheduleAnimation(); |
| 1711 } | 1710 } |
| 1712 } | 1711 } |
| 1713 | 1712 |
| 1714 void WebViewImpl::layout() | 1713 void WebViewImpl::layout() |
| 1715 { | 1714 { |
| 1716 TRACE_EVENT0("webkit", "WebViewImpl::layout"); | 1715 TRACE_EVENT0("webkit", "WebViewImpl::layout"); |
| 1717 PageWidgetDelegate::layout(m_page.get()); | 1716 PageWidgetDelegate::layout(m_page.get()); |
| 1718 updateLayerTreeBackgroundColor(); | 1717 updateLayerTreeBackgroundColor(); |
| 1719 | 1718 |
| 1720 for (size_t i = 0; i < m_linkHighlights.size(); ++i) | 1719 for (std::size_t i = 0; i < m_linkHighlights.size(); ++i) |
| 1721 m_linkHighlights[i]->updateGeometry(); | 1720 m_linkHighlights[i]->updateGeometry(); |
| 1722 } | 1721 } |
| 1723 | 1722 |
| 1724 void WebViewImpl::paint(WebCanvas* canvas, const WebRect& rect) | 1723 void WebViewImpl::paint(WebCanvas* canvas, const WebRect& rect) |
| 1725 { | 1724 { |
| 1726 // This should only be used when compositing is not being used for this | 1725 // This should only be used when compositing is not being used for this |
| 1727 // WebView, and it is painting into the recording of its parent. | 1726 // WebView, and it is painting into the recording of its parent. |
| 1728 ASSERT(!isAcceleratedCompositingActive()); | 1727 ASSERT(!isAcceleratedCompositingActive()); |
| 1729 | 1728 |
| 1730 double paintStart = currentTime(); | 1729 double paintStart = currentTime(); |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2059 LocalFrame* focused = toLocalFrame(focusedWebCoreFrame()); | 2058 LocalFrame* focused = toLocalFrame(focusedWebCoreFrame()); |
| 2060 if (!focused || !m_imeAcceptEvents) | 2059 if (!focused || !m_imeAcceptEvents) |
| 2061 return false; | 2060 return false; |
| 2062 | 2061 |
| 2063 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused)) | 2062 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported(focused)) |
| 2064 return plugin->confirmComposition(text, selectionBehavior); | 2063 return plugin->confirmComposition(text, selectionBehavior); |
| 2065 | 2064 |
| 2066 return focused->inputMethodController().confirmCompositionOrInsertText(text,
selectionBehavior == KeepSelection ? InputMethodController::KeepSelection : Inp
utMethodController::DoNotKeepSelection); | 2065 return focused->inputMethodController().confirmCompositionOrInsertText(text,
selectionBehavior == KeepSelection ? InputMethodController::KeepSelection : Inp
utMethodController::DoNotKeepSelection); |
| 2067 } | 2066 } |
| 2068 | 2067 |
| 2069 bool WebViewImpl::compositionRange(size_t* location, size_t* length) | 2068 bool WebViewImpl::compositionRange(std::size_t* location, std::size_t* length) |
| 2070 { | 2069 { |
| 2071 LocalFrame* focused = toLocalFrame(focusedWebCoreFrame()); | 2070 LocalFrame* focused = toLocalFrame(focusedWebCoreFrame()); |
| 2072 if (!focused || !m_imeAcceptEvents) | 2071 if (!focused || !m_imeAcceptEvents) |
| 2073 return false; | 2072 return false; |
| 2074 | 2073 |
| 2075 RefPtrWillBeRawPtr<Range> range = focused->inputMethodController().compositi
onRange(); | 2074 RefPtrWillBeRawPtr<Range> range = focused->inputMethodController().compositi
onRange(); |
| 2076 if (!range) | 2075 if (!range) |
| 2077 return false; | 2076 return false; |
| 2078 | 2077 |
| 2079 Element* editable = focused->selection().rootEditableElementOrDocumentElemen
t(); | 2078 Element* editable = focused->selection().rootEditableElementOrDocumentElemen
t(); |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2328 return false; | 2327 return false; |
| 2329 } | 2328 } |
| 2330 | 2329 |
| 2331 WebVector<WebCompositionUnderline> WebViewImpl::compositionUnderlines() const | 2330 WebVector<WebCompositionUnderline> WebViewImpl::compositionUnderlines() const |
| 2332 { | 2331 { |
| 2333 const LocalFrame* focused = toLocalFrame(focusedWebCoreFrame()); | 2332 const LocalFrame* focused = toLocalFrame(focusedWebCoreFrame()); |
| 2334 if (!focused) | 2333 if (!focused) |
| 2335 return WebVector<WebCompositionUnderline>(); | 2334 return WebVector<WebCompositionUnderline>(); |
| 2336 const Vector<CompositionUnderline>& underlines = focused->inputMethodControl
ler().customCompositionUnderlines(); | 2335 const Vector<CompositionUnderline>& underlines = focused->inputMethodControl
ler().customCompositionUnderlines(); |
| 2337 WebVector<WebCompositionUnderline> results(underlines.size()); | 2336 WebVector<WebCompositionUnderline> results(underlines.size()); |
| 2338 for (size_t index = 0; index < underlines.size(); ++index) { | 2337 for (std::size_t index = 0; index < underlines.size(); ++index) { |
| 2339 CompositionUnderline underline = underlines[index]; | 2338 CompositionUnderline underline = underlines[index]; |
| 2340 results[index] = WebCompositionUnderline(underline.startOffset, underlin
e.endOffset, static_cast<WebColor>(underline.color.rgb()), underline.thick); | 2339 results[index] = WebCompositionUnderline(underline.startOffset, underlin
e.endOffset, static_cast<WebColor>(underline.color.rgb()), underline.thick); |
| 2341 } | 2340 } |
| 2342 return results; | 2341 return results; |
| 2343 } | 2342 } |
| 2344 | 2343 |
| 2345 WebColor WebViewImpl::backgroundColor() const | 2344 WebColor WebViewImpl::backgroundColor() const |
| 2346 { | 2345 { |
| 2347 if (isTransparent()) | 2346 if (isTransparent()) |
| 2348 return Color::transparent; | 2347 return Color::transparent; |
| 2349 if (!m_page) | 2348 if (!m_page) |
| 2350 return m_baseBackgroundColor; | 2349 return m_baseBackgroundColor; |
| 2351 if (!m_page->mainFrame()) | 2350 if (!m_page->mainFrame()) |
| 2352 return m_baseBackgroundColor; | 2351 return m_baseBackgroundColor; |
| 2353 FrameView* view = m_page->mainFrame()->view(); | 2352 FrameView* view = m_page->mainFrame()->view(); |
| 2354 return view->documentBackgroundColor().rgb(); | 2353 return view->documentBackgroundColor().rgb(); |
| 2355 } | 2354 } |
| 2356 | 2355 |
| 2357 bool WebViewImpl::caretOrSelectionRange(size_t* location, size_t* length) | 2356 bool WebViewImpl::caretOrSelectionRange(std::size_t* location, std::size_t* leng
th) |
| 2358 { | 2357 { |
| 2359 const LocalFrame* focused = toLocalFrame(focusedWebCoreFrame()); | 2358 const LocalFrame* focused = toLocalFrame(focusedWebCoreFrame()); |
| 2360 if (!focused) | 2359 if (!focused) |
| 2361 return false; | 2360 return false; |
| 2362 | 2361 |
| 2363 PlainTextRange selectionOffsets = focused->inputMethodController().getSelect
ionOffsets(); | 2362 PlainTextRange selectionOffsets = focused->inputMethodController().getSelect
ionOffsets(); |
| 2364 if (selectionOffsets.isNull()) | 2363 if (selectionOffsets.isNull()) |
| 2365 return false; | 2364 return false; |
| 2366 | 2365 |
| 2367 *location = selectionOffsets.start(); | 2366 *location = selectionOffsets.start(); |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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(max<int>(textboxRectInDocumentCoordinates.x(), caretInDoc
umentCoordinates.x() + caretInDocumentCoordinates.width() + caretPadding - viewW
idth)); |
| 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 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3273 UserGestureIndicator gesture(DefinitelyProcessingNewUserGesture); | 3272 UserGestureIndicator gesture(DefinitelyProcessingNewUserGesture); |
| 3274 m_page->dragController().performDrag(&dragData); | 3273 m_page->dragController().performDrag(&dragData); |
| 3275 | 3274 |
| 3276 m_dragOperation = WebDragOperationNone; | 3275 m_dragOperation = WebDragOperationNone; |
| 3277 m_currentDragData = nullptr; | 3276 m_currentDragData = nullptr; |
| 3278 } | 3277 } |
| 3279 | 3278 |
| 3280 void WebViewImpl::spellingMarkers(WebVector<uint32_t>* markers) | 3279 void WebViewImpl::spellingMarkers(WebVector<uint32_t>* markers) |
| 3281 { | 3280 { |
| 3282 Vector<uint32_t> result; | 3281 Vector<uint32_t> result; |
| 3283 for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree().traver
seNext()) { | 3282 for (LocalFrame* frame = m_page->mainFrame(); frame; frame = frame->tree().t
raverseNext()) { |
| 3284 if (!frame->isLocalFrame()) | 3283 const WillBeHeapVector<DocumentMarker*>& documentMarkers = frame->docume
nt()->markers().markers(); |
| 3285 continue; | 3284 for (std::size_t i = 0; i < documentMarkers.size(); ++i) |
| 3286 const WillBeHeapVector<DocumentMarker*>& documentMarkers = toLocalFrame(
frame)->document()->markers().markers(); | |
| 3287 for (size_t i = 0; i < documentMarkers.size(); ++i) | |
| 3288 result.append(documentMarkers[i]->hash()); | 3285 result.append(documentMarkers[i]->hash()); |
| 3289 } | 3286 } |
| 3290 markers->assign(result); | 3287 markers->assign(result); |
| 3291 } | 3288 } |
| 3292 | 3289 |
| 3293 WebDragOperation WebViewImpl::dragTargetDragEnterOrOver(const WebPoint& clientPo
int, const WebPoint& screenPoint, DragAction dragAction, int keyModifiers) | 3290 WebDragOperation WebViewImpl::dragTargetDragEnterOrOver(const WebPoint& clientPo
int, const WebPoint& screenPoint, DragAction dragAction, int keyModifiers) |
| 3294 { | 3291 { |
| 3295 ASSERT(m_currentDragData); | 3292 ASSERT(m_currentDragData); |
| 3296 | 3293 |
| 3297 m_currentDragData->setModifierKeyState(webInputEventKeyStateToPlatformEventK
eyState(keyModifiers)); | 3294 m_currentDragData->setModifierKeyState(webInputEventKeyStateToPlatformEventK
eyState(keyModifiers)); |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3544 unsigned inactiveForegroundColor) { | 3541 unsigned inactiveForegroundColor) { |
| 3545 #if USE(DEFAULT_RENDER_THEME) | 3542 #if USE(DEFAULT_RENDER_THEME) |
| 3546 RenderThemeChromiumDefault::setSelectionColors(activeBackgroundColor, active
ForegroundColor, inactiveBackgroundColor, inactiveForegroundColor); | 3543 RenderThemeChromiumDefault::setSelectionColors(activeBackgroundColor, active
ForegroundColor, inactiveBackgroundColor, inactiveForegroundColor); |
| 3547 RenderTheme::theme().platformColorsDidChange(); | 3544 RenderTheme::theme().platformColorsDidChange(); |
| 3548 #endif | 3545 #endif |
| 3549 } | 3546 } |
| 3550 | 3547 |
| 3551 void WebView::injectStyleSheet(const WebString& sourceCode, const WebVector<WebS
tring>& patternsIn, WebView::StyleInjectionTarget injectIn) | 3548 void WebView::injectStyleSheet(const WebString& sourceCode, const WebVector<WebS
tring>& patternsIn, WebView::StyleInjectionTarget injectIn) |
| 3552 { | 3549 { |
| 3553 Vector<String> patterns; | 3550 Vector<String> patterns; |
| 3554 for (size_t i = 0; i < patternsIn.size(); ++i) | 3551 for (std::size_t i = 0; i < patternsIn.size(); ++i) |
| 3555 patterns.append(patternsIn[i]); | 3552 patterns.append(patternsIn[i]); |
| 3556 | 3553 |
| 3557 InjectedStyleSheets::instance().add(sourceCode, patterns, static_cast<WebCor
e::StyleInjectionTarget>(injectIn)); | 3554 InjectedStyleSheets::instance().add(sourceCode, patterns, static_cast<WebCor
e::StyleInjectionTarget>(injectIn)); |
| 3558 } | 3555 } |
| 3559 | 3556 |
| 3560 void WebView::removeInjectedStyleSheets() | 3557 void WebView::removeInjectedStyleSheets() |
| 3561 { | 3558 { |
| 3562 InjectedStyleSheets::instance().removeAll(); | 3559 InjectedStyleSheets::instance().removeAll(); |
| 3563 } | 3560 } |
| 3564 | 3561 |
| (...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4104 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi
nedConstraints(); | 4101 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi
nedConstraints(); |
| 4105 | 4102 |
| 4106 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) | 4103 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) |
| 4107 return false; | 4104 return false; |
| 4108 | 4105 |
| 4109 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width | 4106 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width |
| 4110 || (constraints.minimumScale == constraints.maximumScale && constraints.
minimumScale != -1); | 4107 || (constraints.minimumScale == constraints.maximumScale && constraints.
minimumScale != -1); |
| 4111 } | 4108 } |
| 4112 | 4109 |
| 4113 } // namespace blink | 4110 } // namespace blink |
| OLD | NEW |