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