| 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 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 m_maximumLegibleScale(1), | 354 m_maximumLegibleScale(1), |
| 355 m_doubleTapZoomPageScaleFactor(0), | 355 m_doubleTapZoomPageScaleFactor(0), |
| 356 m_doubleTapZoomPending(false), | 356 m_doubleTapZoomPending(false), |
| 357 m_enableFakePageScaleAnimationForTesting(false), | 357 m_enableFakePageScaleAnimationForTesting(false), |
| 358 m_fakePageScaleAnimationPageScaleFactor(0), | 358 m_fakePageScaleAnimationPageScaleFactor(0), |
| 359 m_fakePageScaleAnimationUseAnchor(false), | 359 m_fakePageScaleAnimationUseAnchor(false), |
| 360 m_compositorDeviceScaleFactorOverride(0), | 360 m_compositorDeviceScaleFactorOverride(0), |
| 361 m_suppressNextKeypressEvent(false), | 361 m_suppressNextKeypressEvent(false), |
| 362 m_imeAcceptEvents(true), | 362 m_imeAcceptEvents(true), |
| 363 m_devToolsEmulator(nullptr), | 363 m_devToolsEmulator(nullptr), |
| 364 m_isTransparent(false), | |
| 365 m_tabsToLinks(false), | 364 m_tabsToLinks(false), |
| 366 m_layerTreeView(nullptr), | 365 m_layerTreeView(nullptr), |
| 367 m_rootLayer(nullptr), | 366 m_rootLayer(nullptr), |
| 368 m_rootGraphicsLayer(nullptr), | 367 m_rootGraphicsLayer(nullptr), |
| 369 m_visualViewportContainerLayer(nullptr), | 368 m_visualViewportContainerLayer(nullptr), |
| 370 m_matchesHeuristicsForGpuRasterization(false), | 369 m_matchesHeuristicsForGpuRasterization(false), |
| 371 m_flingModifier(0), | 370 m_flingModifier(0), |
| 372 m_flingSourceDevice(WebGestureDeviceUninitialized), | 371 m_flingSourceDevice(WebGestureDeviceUninitialized), |
| 373 m_fullscreenController(FullscreenController::create(this)), | 372 m_fullscreenController(FullscreenController::create(this)), |
| 374 m_baseBackgroundColor(Color::white), | 373 m_baseBackgroundColor(Color::white), |
| 375 m_baseBackgroundColorOverrideEnabled(false), | 374 m_baseBackgroundColorOverrideEnabled(false), |
| 376 m_baseBackgroundColorOverride(Color::transparent), | 375 m_baseBackgroundColorOverride(Color::transparent), |
| 376 m_backgroundColorOverrideEnabled(false), |
| 377 m_backgroundColorOverride(Color::transparent), | 377 m_backgroundColorOverride(Color::transparent), |
| 378 m_zoomFactorOverride(0), | 378 m_zoomFactorOverride(0), |
| 379 m_userGestureObserved(false), | 379 m_userGestureObserved(false), |
| 380 m_shouldDispatchFirstVisuallyNonEmptyLayout(false), | 380 m_shouldDispatchFirstVisuallyNonEmptyLayout(false), |
| 381 m_shouldDispatchFirstLayoutAfterFinishedParsing(false), | 381 m_shouldDispatchFirstLayoutAfterFinishedParsing(false), |
| 382 m_shouldDispatchFirstLayoutAfterFinishedLoading(false), | 382 m_shouldDispatchFirstLayoutAfterFinishedLoading(false), |
| 383 m_displayMode(WebDisplayModeBrowser), | 383 m_displayMode(WebDisplayModeBrowser), |
| 384 m_elasticOverscroll(FloatSize()), | 384 m_elasticOverscroll(FloatSize()), |
| 385 m_mutator(nullptr), | 385 m_mutator(nullptr), |
| 386 m_scheduler(WTF::wrapUnique(Platform::current() | 386 m_scheduler(WTF::wrapUnique(Platform::current() |
| (...skipping 2052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2439 | 2439 |
| 2440 FrameSelection& selection = frame->selection(); | 2440 FrameSelection& selection = frame->selection(); |
| 2441 if (!selection.isAvailable()) { | 2441 if (!selection.isAvailable()) { |
| 2442 // plugins/mouse-capture-inside-shadow.html reaches here. | 2442 // plugins/mouse-capture-inside-shadow.html reaches here. |
| 2443 return false; | 2443 return false; |
| 2444 } | 2444 } |
| 2445 return selection.computeVisibleSelectionInDOMTreeDeprecated().isBaseFirst(); | 2445 return selection.computeVisibleSelectionInDOMTreeDeprecated().isBaseFirst(); |
| 2446 } | 2446 } |
| 2447 | 2447 |
| 2448 WebColor WebViewImpl::backgroundColor() const { | 2448 WebColor WebViewImpl::backgroundColor() const { |
| 2449 if (isTransparent()) | 2449 if (m_backgroundColorOverrideEnabled) |
| 2450 return Color::transparent; | 2450 return m_backgroundColorOverride; |
| 2451 if (!m_page) | 2451 if (!m_page) |
| 2452 return baseBackgroundColor().rgb(); | 2452 return baseBackgroundColor().rgb(); |
| 2453 if (!m_page->mainFrame()) | 2453 if (!m_page->mainFrame()) |
| 2454 return baseBackgroundColor().rgb(); | 2454 return baseBackgroundColor().rgb(); |
| 2455 if (!m_page->mainFrame()->isLocalFrame()) | 2455 if (!m_page->mainFrame()->isLocalFrame()) |
| 2456 return baseBackgroundColor().rgb(); | 2456 return baseBackgroundColor().rgb(); |
| 2457 FrameView* view = m_page->deprecatedLocalMainFrame()->view(); | 2457 FrameView* view = m_page->deprecatedLocalMainFrame()->view(); |
| 2458 if (!view) |
| 2459 return baseBackgroundColor().rgb(); |
| 2458 return view->documentBackgroundColor().rgb(); | 2460 return view->documentBackgroundColor().rgb(); |
| 2459 } | 2461 } |
| 2460 | 2462 |
| 2461 WebPagePopup* WebViewImpl::pagePopup() const { | 2463 WebPagePopup* WebViewImpl::pagePopup() const { |
| 2462 return m_pagePopup.get(); | 2464 return m_pagePopup.get(); |
| 2463 } | 2465 } |
| 2464 | 2466 |
| 2465 // TODO(ekaramad):This method is almost duplicated in WebFrameWidgetImpl as | 2467 // TODO(ekaramad):This method is almost duplicated in WebFrameWidgetImpl as |
| 2466 // well. This code needs to be refactored (http://crbug.com/629721). | 2468 // well. This code needs to be refactored (http://crbug.com/629721). |
| 2467 WebRange WebViewImpl::caretOrSelectionRange() { | 2469 WebRange WebViewImpl::caretOrSelectionRange() { |
| (...skipping 1042 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3510 void WebViewImpl::didCloseContextMenu() { | 3512 void WebViewImpl::didCloseContextMenu() { |
| 3511 LocalFrame* frame = m_page->focusController().focusedFrame(); | 3513 LocalFrame* frame = m_page->focusController().focusedFrame(); |
| 3512 if (frame) | 3514 if (frame) |
| 3513 frame->selection().setCaretBlinkingSuspended(false); | 3515 frame->selection().setCaretBlinkingSuspended(false); |
| 3514 } | 3516 } |
| 3515 | 3517 |
| 3516 void WebViewImpl::hidePopups() { | 3518 void WebViewImpl::hidePopups() { |
| 3517 cancelPagePopup(); | 3519 cancelPagePopup(); |
| 3518 } | 3520 } |
| 3519 | 3521 |
| 3520 void WebViewImpl::setIsTransparent(bool isTransparent) { | |
| 3521 // Set any existing frames to be transparent. | |
| 3522 Frame* frame = m_page->mainFrame(); | |
| 3523 while (frame) { | |
| 3524 if (frame->isLocalFrame()) | |
| 3525 toLocalFrame(frame)->view()->setTransparent(isTransparent); | |
| 3526 frame = frame->tree().traverseNext(); | |
| 3527 } | |
| 3528 | |
| 3529 // Future frames check this to know whether to be transparent. | |
| 3530 m_isTransparent = isTransparent; | |
| 3531 | |
| 3532 if (m_layerTreeView) | |
| 3533 m_layerTreeView->setHasTransparentBackground(this->isTransparent()); | |
| 3534 } | |
| 3535 | |
| 3536 bool WebViewImpl::isTransparent() const { | |
| 3537 return m_isTransparent; | |
| 3538 } | |
| 3539 | |
| 3540 WebInputMethodControllerImpl* WebViewImpl::getActiveWebInputMethodController() | 3522 WebInputMethodControllerImpl* WebViewImpl::getActiveWebInputMethodController() |
| 3541 const { | 3523 const { |
| 3542 return WebInputMethodControllerImpl::fromFrame(focusedLocalFrameInWidget()); | 3524 return WebInputMethodControllerImpl::fromFrame(focusedLocalFrameInWidget()); |
| 3543 } | 3525 } |
| 3544 | 3526 |
| 3545 Color WebViewImpl::baseBackgroundColor() const { | 3527 Color WebViewImpl::baseBackgroundColor() const { |
| 3546 return m_baseBackgroundColorOverrideEnabled ? m_baseBackgroundColorOverride | 3528 return m_baseBackgroundColorOverrideEnabled ? m_baseBackgroundColorOverride |
| 3547 : m_baseBackgroundColor; | 3529 : m_baseBackgroundColor; |
| 3548 } | 3530 } |
| 3549 | 3531 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 3577 mainFrameImpl() | 3559 mainFrameImpl() |
| 3578 ->frame() | 3560 ->frame() |
| 3579 ->view() | 3561 ->view() |
| 3580 ->updateLifecycleToCompositingCleanPlusScrolling(); | 3562 ->updateLifecycleToCompositingCleanPlusScrolling(); |
| 3581 } | 3563 } |
| 3582 updateBaseBackgroundColor(); | 3564 updateBaseBackgroundColor(); |
| 3583 } | 3565 } |
| 3584 | 3566 |
| 3585 void WebViewImpl::updateBaseBackgroundColor() { | 3567 void WebViewImpl::updateBaseBackgroundColor() { |
| 3586 Color color = baseBackgroundColor(); | 3568 Color color = baseBackgroundColor(); |
| 3587 if (m_page->mainFrame() && m_page->mainFrame()->isLocalFrame()) | 3569 if (m_page->mainFrame() && m_page->mainFrame()->isLocalFrame()) { |
| 3588 m_page->deprecatedLocalMainFrame()->view()->setBaseBackgroundColor(color); | 3570 FrameView* view = m_page->deprecatedLocalMainFrame()->view(); |
| 3571 view->setBaseBackgroundColor(color); |
| 3572 view->updateBaseBackgroundColorRecursively(color); |
| 3573 } |
| 3589 } | 3574 } |
| 3590 | 3575 |
| 3591 void WebViewImpl::setIsActive(bool active) { | 3576 void WebViewImpl::setIsActive(bool active) { |
| 3592 if (page()) | 3577 if (page()) |
| 3593 page()->focusController().setActive(active); | 3578 page()->focusController().setActive(active); |
| 3594 } | 3579 } |
| 3595 | 3580 |
| 3596 bool WebViewImpl::isActive() const { | 3581 bool WebViewImpl::isActive() const { |
| 3597 return page() ? page()->focusController().isActive() : false; | 3582 return page() ? page()->focusController().isActive() : false; |
| 3598 } | 3583 } |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3704 | 3689 |
| 3705 void WebViewImpl::mainFrameScrollOffsetChanged() { | 3690 void WebViewImpl::mainFrameScrollOffsetChanged() { |
| 3706 m_devToolsEmulator->mainFrameScrollOrScaleChanged(); | 3691 m_devToolsEmulator->mainFrameScrollOrScaleChanged(); |
| 3707 } | 3692 } |
| 3708 | 3693 |
| 3709 bool WebViewImpl::useExternalPopupMenus() { | 3694 bool WebViewImpl::useExternalPopupMenus() { |
| 3710 return shouldUseExternalPopupMenus; | 3695 return shouldUseExternalPopupMenus; |
| 3711 } | 3696 } |
| 3712 | 3697 |
| 3713 void WebViewImpl::setBackgroundColorOverride(WebColor color) { | 3698 void WebViewImpl::setBackgroundColorOverride(WebColor color) { |
| 3699 m_backgroundColorOverrideEnabled = true; |
| 3714 m_backgroundColorOverride = color; | 3700 m_backgroundColorOverride = color; |
| 3715 updateLayerTreeBackgroundColor(); | 3701 updateLayerTreeBackgroundColor(); |
| 3716 } | 3702 } |
| 3717 | 3703 |
| 3704 void WebViewImpl::clearBackgroundColorOverride() { |
| 3705 m_backgroundColorOverrideEnabled = false; |
| 3706 updateLayerTreeBackgroundColor(); |
| 3707 } |
| 3708 |
| 3718 void WebViewImpl::setZoomFactorOverride(float zoomFactor) { | 3709 void WebViewImpl::setZoomFactorOverride(float zoomFactor) { |
| 3719 m_zoomFactorOverride = zoomFactor; | 3710 m_zoomFactorOverride = zoomFactor; |
| 3720 setZoomLevel(zoomLevel()); | 3711 setZoomLevel(zoomLevel()); |
| 3721 } | 3712 } |
| 3722 | 3713 |
| 3723 void WebViewImpl::setPageOverlayColor(WebColor color) { | 3714 void WebViewImpl::setPageOverlayColor(WebColor color) { |
| 3724 if (m_pageColorOverlay) | 3715 if (m_pageColorOverlay) |
| 3725 m_pageColorOverlay.reset(); | 3716 m_pageColorOverlay.reset(); |
| 3726 | 3717 |
| 3727 if (color == Color::transparent) | 3718 if (color == Color::transparent) |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4017 if (!page() || !m_layerTreeView) | 4008 if (!page() || !m_layerTreeView) |
| 4018 return; | 4009 return; |
| 4019 | 4010 |
| 4020 m_layerTreeView->setPageScaleFactorAndLimits( | 4011 m_layerTreeView->setPageScaleFactorAndLimits( |
| 4021 pageScaleFactor(), minimumPageScaleFactor(), maximumPageScaleFactor()); | 4012 pageScaleFactor(), minimumPageScaleFactor(), maximumPageScaleFactor()); |
| 4022 } | 4013 } |
| 4023 | 4014 |
| 4024 void WebViewImpl::updateLayerTreeBackgroundColor() { | 4015 void WebViewImpl::updateLayerTreeBackgroundColor() { |
| 4025 if (!m_layerTreeView) | 4016 if (!m_layerTreeView) |
| 4026 return; | 4017 return; |
| 4027 | 4018 m_layerTreeView->setBackgroundColor(backgroundColor()); |
| 4028 m_layerTreeView->setBackgroundColor(alphaChannel(m_backgroundColorOverride) | |
| 4029 ? m_backgroundColorOverride | |
| 4030 : backgroundColor()); | |
| 4031 } | 4019 } |
| 4032 | 4020 |
| 4033 void WebViewImpl::updateLayerTreeDeviceScaleFactor() { | 4021 void WebViewImpl::updateLayerTreeDeviceScaleFactor() { |
| 4034 DCHECK(page()); | 4022 DCHECK(page()); |
| 4035 DCHECK(m_layerTreeView); | 4023 DCHECK(m_layerTreeView); |
| 4036 | 4024 |
| 4037 float deviceScaleFactor = m_compositorDeviceScaleFactorOverride | 4025 float deviceScaleFactor = m_compositorDeviceScaleFactorOverride |
| 4038 ? m_compositorDeviceScaleFactorOverride | 4026 ? m_compositorDeviceScaleFactorOverride |
| 4039 : page()->deviceScaleFactorDeprecated(); | 4027 : page()->deviceScaleFactorDeprecated(); |
| 4040 m_layerTreeView->setDeviceScaleFactor(deviceScaleFactor); | 4028 m_layerTreeView->setDeviceScaleFactor(deviceScaleFactor); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4174 if (focusedFrame->localFrameRoot() != mainFrameImpl()->frame()) | 4162 if (focusedFrame->localFrameRoot() != mainFrameImpl()->frame()) |
| 4175 return nullptr; | 4163 return nullptr; |
| 4176 return focusedFrame; | 4164 return focusedFrame; |
| 4177 } | 4165 } |
| 4178 | 4166 |
| 4179 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const { | 4167 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const { |
| 4180 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr; | 4168 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr; |
| 4181 } | 4169 } |
| 4182 | 4170 |
| 4183 } // namespace blink | 4171 } // namespace blink |
| OLD | NEW |