Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 49 #include "DocumentLoader.h" | 49 #include "DocumentLoader.h" |
| 50 #include "DragController.h" | 50 #include "DragController.h" |
| 51 #include "DragData.h" | 51 #include "DragData.h" |
| 52 #include "DragScrollTimer.h" | 52 #include "DragScrollTimer.h" |
| 53 #include "DragSession.h" | 53 #include "DragSession.h" |
| 54 #include "Editor.h" | 54 #include "Editor.h" |
| 55 #include "EventHandler.h" | 55 #include "EventHandler.h" |
| 56 #include "Extensions3D.h" | 56 #include "Extensions3D.h" |
| 57 #include "FocusController.h" | 57 #include "FocusController.h" |
| 58 #include "FontDescription.h" | 58 #include "FontDescription.h" |
| 59 #include "Frame.h" | |
| 59 #include "FrameLoader.h" | 60 #include "FrameLoader.h" |
| 60 #include "FrameSelection.h" | 61 #include "FrameSelection.h" |
| 61 #include "FrameTree.h" | 62 #include "FrameTree.h" |
| 62 #include "FrameView.h" | 63 #include "FrameView.h" |
| 63 #include "GeolocationClientProxy.h" | 64 #include "GeolocationClientProxy.h" |
| 64 #include "GraphicsContext.h" | 65 #include "GraphicsContext.h" |
| 65 #include "GraphicsContext3D.h" | 66 #include "GraphicsContext3D.h" |
| 66 #include "GraphicsContext3DPrivate.h" | 67 #include "GraphicsContext3DPrivate.h" |
| 67 #include "HTMLInputElement.h" | 68 #include "HTMLInputElement.h" |
| 68 #include "HTMLMediaElement.h" | 69 #include "HTMLMediaElement.h" |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 327 WebViewImpl::WebViewImpl(WebViewClient* client) | 328 WebViewImpl::WebViewImpl(WebViewClient* client) |
| 328 : m_client(client) | 329 : m_client(client) |
| 329 , m_autofillClient(0) | 330 , m_autofillClient(0) |
| 330 , m_permissionClient(0) | 331 , m_permissionClient(0) |
| 331 , m_spellCheckClient(0) | 332 , m_spellCheckClient(0) |
| 332 , m_chromeClientImpl(this) | 333 , m_chromeClientImpl(this) |
| 333 , m_contextMenuClientImpl(this) | 334 , m_contextMenuClientImpl(this) |
| 334 , m_dragClientImpl(this) | 335 , m_dragClientImpl(this) |
| 335 , m_editorClientImpl(this) | 336 , m_editorClientImpl(this) |
| 336 , m_inspectorClientImpl(this) | 337 , m_inspectorClientImpl(this) |
| 338 , m_shouldAutoSize(false) | |
| 337 , m_observedNewNavigation(false) | 339 , m_observedNewNavigation(false) |
| 338 #ifndef NDEBUG | 340 #ifndef NDEBUG |
| 339 , m_newNavigationLoader(0) | 341 , m_newNavigationLoader(0) |
| 340 #endif | 342 #endif |
| 341 , m_zoomLevel(0) | 343 , m_zoomLevel(0) |
| 342 , m_minimumZoomLevel(zoomFactorToZoomLevel(minTextSizeMultiplier)) | 344 , m_minimumZoomLevel(zoomFactorToZoomLevel(minTextSizeMultiplier)) |
| 343 , m_maximumZoomLevel(zoomFactorToZoomLevel(maxTextSizeMultiplier)) | 345 , m_maximumZoomLevel(zoomFactorToZoomLevel(maxTextSizeMultiplier)) |
| 344 , m_minimumPageScaleFactor(minPageScaleFactor) | 346 , m_minimumPageScaleFactor(minPageScaleFactor) |
| 345 , m_maximumPageScaleFactor(maxPageScaleFactor) | 347 , m_maximumPageScaleFactor(maxPageScaleFactor) |
| 346 , m_contextMenuAllowed(false) | 348 , m_contextMenuAllowed(false) |
| (...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1034 mainFrameImpl()->frameView()->willStartLiveResize(); | 1036 mainFrameImpl()->frameView()->willStartLiveResize(); |
| 1035 | 1037 |
| 1036 Frame* frame = mainFrameImpl()->frame(); | 1038 Frame* frame = mainFrameImpl()->frame(); |
| 1037 WebPluginContainerImpl* pluginContainer = WebFrameImpl::pluginContainerFromF rame(frame); | 1039 WebPluginContainerImpl* pluginContainer = WebFrameImpl::pluginContainerFromF rame(frame); |
| 1038 if (pluginContainer) | 1040 if (pluginContainer) |
| 1039 pluginContainer->willStartLiveResize(); | 1041 pluginContainer->willStartLiveResize(); |
| 1040 } | 1042 } |
| 1041 | 1043 |
| 1042 void WebViewImpl::resize(const WebSize& newSize) | 1044 void WebViewImpl::resize(const WebSize& newSize) |
| 1043 { | 1045 { |
| 1046 ASSERT(!m_shouldAutoSize); | |
| 1044 if (m_size == newSize) | 1047 if (m_size == newSize) |
| 1045 return; | 1048 return; |
| 1046 m_size = newSize; | 1049 m_size = newSize; |
| 1047 | 1050 |
| 1048 if (mainFrameImpl()->frameView()) { | 1051 if (mainFrameImpl()->frameView()) { |
| 1049 mainFrameImpl()->frameView()->resize(m_size.width, m_size.height); | 1052 mainFrameImpl()->frameView()->resize(m_size.width, m_size.height); |
| 1050 mainFrameImpl()->frame()->eventHandler()->sendResizeEvent(); | 1053 mainFrameImpl()->frame()->eventHandler()->sendResizeEvent(); |
| 1051 } | 1054 } |
| 1052 | 1055 |
| 1053 if (m_client) { | 1056 if (m_client) { |
| (...skipping 989 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2043 | 2046 |
| 2044 #if USE(ACCELERATED_COMPOSITING) | 2047 #if USE(ACCELERATED_COMPOSITING) |
| 2045 // Also notify the base layer, which RenderLayerCompositor does not see. | 2048 // Also notify the base layer, which RenderLayerCompositor does not see. |
| 2046 if (m_nonCompositedContentHost) { | 2049 if (m_nonCompositedContentHost) { |
| 2047 m_nonCompositedContentHost->topLevelRootLayer()->deviceOrPageScaleFactor Changed(); | 2050 m_nonCompositedContentHost->topLevelRootLayer()->deviceOrPageScaleFactor Changed(); |
| 2048 updateLayerTreeViewport(); | 2051 updateLayerTreeViewport(); |
| 2049 } | 2052 } |
| 2050 #endif | 2053 #endif |
| 2051 } | 2054 } |
| 2052 | 2055 |
| 2056 void WebViewImpl::enableAutoSizeMode(bool enable, const WebSize& minSize, const WebSize& maxSize) | |
| 2057 { | |
| 2058 m_shouldAutoSize = enable; | |
| 2059 m_minAutoSize = minSize; | |
| 2060 m_maxAutoSize = maxSize; | |
| 2061 if (!mainFrameImpl() || !mainFrameImpl()->frame() || !mainFrameImpl()->frame ()->view()) | |
| 2062 return; | |
| 2063 | |
| 2064 mainFrameImpl()->frame()->view()->enableAutoSizeMode(m_shouldAutoSize, m_min AutoSize, m_maxAutoSize); | |
| 2065 } | |
| 2066 | |
| 2053 void WebViewImpl::setPageScaleFactorLimits(float minPageScale, float maxPageScal e) | 2067 void WebViewImpl::setPageScaleFactorLimits(float minPageScale, float maxPageScal e) |
| 2054 { | 2068 { |
| 2055 m_minimumPageScaleFactor = min(max(minPageScale, minPageScaleFactor), maxPag eScaleFactor) * deviceScaleFactor(); | 2069 m_minimumPageScaleFactor = min(max(minPageScale, minPageScaleFactor), maxPag eScaleFactor) * deviceScaleFactor(); |
| 2056 m_maximumPageScaleFactor = max(min(maxPageScale, maxPageScaleFactor), minPag eScaleFactor) * deviceScaleFactor(); | 2070 m_maximumPageScaleFactor = max(min(maxPageScale, maxPageScaleFactor), minPag eScaleFactor) * deviceScaleFactor(); |
| 2057 | 2071 |
| 2058 if (m_size.width && mainFrame() && mainFrame()->contentsSize().width) { | 2072 if (m_size.width && mainFrame() && mainFrame()->contentsSize().width) { |
| 2059 // Limit page scaling down to the document width. | 2073 // Limit page scaling down to the document width. |
| 2060 int viewWidth = m_size.width; | 2074 int viewWidth = m_size.width; |
| 2061 int unscaledContentWidth = mainFrame()->contentsSize().width / pageScale Factor(); | 2075 int unscaledContentWidth = mainFrame()->contentsSize().width / pageScale Factor(); |
| 2062 m_minimumPageScaleFactor = max(m_minimumPageScaleFactor, static_cast<flo at>(viewWidth) / unscaledContentWidth); | 2076 m_minimumPageScaleFactor = max(m_minimumPageScaleFactor, static_cast<flo at>(viewWidth) / unscaledContentWidth); |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2541 m_newNavigationLoader = 0; | 2555 m_newNavigationLoader = 0; |
| 2542 #endif | 2556 #endif |
| 2543 m_observedNewNavigation = false; | 2557 m_observedNewNavigation = false; |
| 2544 } | 2558 } |
| 2545 | 2559 |
| 2546 void WebViewImpl::layoutUpdated(WebFrameImpl* webframe) | 2560 void WebViewImpl::layoutUpdated(WebFrameImpl* webframe) |
| 2547 { | 2561 { |
| 2548 if (!m_client || webframe != mainFrameImpl()) | 2562 if (!m_client || webframe != mainFrameImpl()) |
| 2549 return; | 2563 return; |
| 2550 | 2564 |
| 2565 if (m_shouldAutoSize && mainFrameImpl()->frame() && mainFrameImpl()->frame() ->view()) { | |
| 2566 WebSize frameSize = mainFrameImpl()->frame()->view()->frameRect().size() ; | |
| 2567 if (frameSize != m_size) { | |
| 2568 m_size = frameSize; | |
| 2569 m_client->setSize(m_size); | |
| 2570 // TODO: move to higher level?? this is sync in after the layout cod e?? | |
|
darin (slow to review)
2011/11/30 23:29:05
making this async could also introduce problems as
levin
2011/12/01 20:23:45
After looking at this code further, I realized tha
| |
| 2571 // TODO: Before checking in make this async (to avoid unexpected rec ursion in js code) | |
|
levin
2011/11/30 12:03:47
This needs to be fixed up still and possibly conso
| |
| 2572 // and don't allow this resize event to trigger another resize event . | |
| 2573 mainFrameImpl()->frame()->eventHandler()->sendResizeEvent(); | |
| 2574 | |
| 2575 // Should this just call void WebViewImpl::resize(const WebSize& new Size)? | |
|
darin (slow to review)
2011/11/30 23:29:05
probably should factor out some common code into a
levin
2011/12/01 20:23:45
Done.
| |
| 2576 if (isAcceleratedCompositingActive()) { | |
| 2577 #if USE(ACCELERATED_COMPOSITING) | |
| 2578 updateLayerTreeViewport(); | |
| 2579 #endif | |
| 2580 } else { | |
| 2581 WebRect damagedRect(0, 0, m_size.width, m_size.height); | |
| 2582 m_client->didInvalidateRect(damagedRect); | |
| 2583 } | |
| 2584 } | |
| 2585 } | |
| 2586 | |
| 2551 m_client->didUpdateLayout(); | 2587 m_client->didUpdateLayout(); |
| 2552 } | 2588 } |
| 2553 | 2589 |
| 2554 bool WebViewImpl::useExternalPopupMenus() | 2590 bool WebViewImpl::useExternalPopupMenus() |
| 2555 { | 2591 { |
| 2556 return shouldUseExternalPopupMenus; | 2592 return shouldUseExternalPopupMenus; |
| 2557 } | 2593 } |
| 2558 | 2594 |
| 2559 bool WebViewImpl::navigationPolicyFromMouseEvent(unsigned short button, | 2595 bool WebViewImpl::navigationPolicyFromMouseEvent(unsigned short button, |
| 2560 bool ctrl, bool shift, | 2596 bool ctrl, bool shift, |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3024 } | 3060 } |
| 3025 | 3061 |
| 3026 #if ENABLE(GESTURE_RECOGNIZER) | 3062 #if ENABLE(GESTURE_RECOGNIZER) |
| 3027 void WebViewImpl::resetGestureRecognizer() | 3063 void WebViewImpl::resetGestureRecognizer() |
| 3028 { | 3064 { |
| 3029 m_gestureRecognizer->reset(); | 3065 m_gestureRecognizer->reset(); |
| 3030 } | 3066 } |
| 3031 #endif | 3067 #endif |
| 3032 | 3068 |
| 3033 } // namespace WebKit | 3069 } // namespace WebKit |
| OLD | NEW |