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

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

Issue 19883002: Expose a way to set a view's base background color. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: +test Created 7 years, 5 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
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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 #include "core/platform/NotImplemented.h" 131 #include "core/platform/NotImplemented.h"
132 #include "core/platform/PlatformGestureEvent.h" 132 #include "core/platform/PlatformGestureEvent.h"
133 #include "core/platform/PlatformKeyboardEvent.h" 133 #include "core/platform/PlatformKeyboardEvent.h"
134 #include "core/platform/PlatformMouseEvent.h" 134 #include "core/platform/PlatformMouseEvent.h"
135 #include "core/platform/PlatformWheelEvent.h" 135 #include "core/platform/PlatformWheelEvent.h"
136 #include "core/platform/PopupMenuClient.h" 136 #include "core/platform/PopupMenuClient.h"
137 #include "core/platform/Timer.h" 137 #include "core/platform/Timer.h"
138 #include "core/platform/chromium/KeyboardCodes.h" 138 #include "core/platform/chromium/KeyboardCodes.h"
139 #include "core/platform/chromium/TraceEvent.h" 139 #include "core/platform/chromium/TraceEvent.h"
140 #include "core/platform/chromium/support/WebActiveGestureAnimation.h" 140 #include "core/platform/chromium/support/WebActiveGestureAnimation.h"
141 #include "core/platform/graphics/Color.h"
142 #include "core/platform/graphics/ColorSpace.h" 141 #include "core/platform/graphics/ColorSpace.h"
143 #include "core/platform/graphics/Extensions3D.h" 142 #include "core/platform/graphics/Extensions3D.h"
144 #include "core/platform/graphics/FontCache.h" 143 #include "core/platform/graphics/FontCache.h"
145 #include "core/platform/graphics/FontDescription.h" 144 #include "core/platform/graphics/FontDescription.h"
146 #include "core/platform/graphics/GraphicsContext.h" 145 #include "core/platform/graphics/GraphicsContext.h"
147 #include "core/platform/graphics/GraphicsContext3D.h" 146 #include "core/platform/graphics/GraphicsContext3D.h"
148 #include "core/platform/graphics/Image.h" 147 #include "core/platform/graphics/Image.h"
149 #include "core/platform/graphics/ImageBuffer.h" 148 #include "core/platform/graphics/ImageBuffer.h"
150 #include "core/platform/graphics/chromium/LayerPainterChromium.h" 149 #include "core/platform/graphics/chromium/LayerPainterChromium.h"
151 #include "core/platform/graphics/gpu/SharedGraphicsContext3D.h" 150 #include "core/platform/graphics/gpu/SharedGraphicsContext3D.h"
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 #if ENABLE(NAVIGATOR_CONTENT_UTILS) 419 #if ENABLE(NAVIGATOR_CONTENT_UTILS)
421 , m_navigatorContentUtilsClient(NavigatorContentUtilsClientImpl::create(this )) 420 , m_navigatorContentUtilsClient(NavigatorContentUtilsClientImpl::create(this ))
422 #endif 421 #endif
423 , m_flingModifier(0) 422 , m_flingModifier(0)
424 , m_flingSourceDevice(false) 423 , m_flingSourceDevice(false)
425 , m_showFPSCounter(false) 424 , m_showFPSCounter(false)
426 , m_showPaintRects(false) 425 , m_showPaintRects(false)
427 , m_showDebugBorders(false) 426 , m_showDebugBorders(false)
428 , m_continuousPaintingEnabled(false) 427 , m_continuousPaintingEnabled(false)
429 , m_showScrollBottleneckRects(false) 428 , m_showScrollBottleneckRects(false)
429 , m_baseBackgroundColor(Color::white)
430 { 430 {
431 Page::PageClients pageClients; 431 Page::PageClients pageClients;
432 pageClients.chromeClient = &m_chromeClientImpl; 432 pageClients.chromeClient = &m_chromeClientImpl;
433 pageClients.contextMenuClient = &m_contextMenuClientImpl; 433 pageClients.contextMenuClient = &m_contextMenuClientImpl;
434 pageClients.editorClient = &m_editorClientImpl; 434 pageClients.editorClient = &m_editorClientImpl;
435 pageClients.dragClient = &m_dragClientImpl; 435 pageClients.dragClient = &m_dragClientImpl;
436 pageClients.inspectorClient = &m_inspectorClientImpl; 436 pageClients.inspectorClient = &m_inspectorClientImpl;
437 pageClients.backForwardClient = &m_backForwardClientImpl; 437 pageClients.backForwardClient = &m_backForwardClientImpl;
438 438
439 m_page = adoptPtr(new Page(pageClients)); 439 m_page = adoptPtr(new Page(pageClients));
(...skipping 2012 matching lines...) Expand 10 before | Expand all | Expand 10 after
2452 if (!frame) 2452 if (!frame)
2453 return false; 2453 return false;
2454 return frame->selection()->isContentEditable(); 2454 return frame->selection()->isContentEditable();
2455 } 2455 }
2456 2456
2457 WebColor WebViewImpl::backgroundColor() const 2457 WebColor WebViewImpl::backgroundColor() const
2458 { 2458 {
2459 if (isTransparent()) 2459 if (isTransparent())
2460 return Color::transparent; 2460 return Color::transparent;
2461 if (!m_page) 2461 if (!m_page)
2462 return Color::white; 2462 return m_baseBackgroundColor.rgb();
2463 FrameView* view = m_page->mainFrame()->view(); 2463 FrameView* view = m_page->mainFrame()->view();
2464 Color backgroundColor = view->documentBackgroundColor(); 2464 Color backgroundColor = view->documentBackgroundColor();
2465 if (!backgroundColor.isValid()) 2465 if (!backgroundColor.isValid())
2466 return Color::white; 2466 return m_baseBackgroundColor.rgb();
2467 return backgroundColor.rgb(); 2467 return backgroundColor.rgb();
2468 } 2468 }
2469 2469
2470 bool WebViewImpl::caretOrSelectionRange(size_t* location, size_t* length) 2470 bool WebViewImpl::caretOrSelectionRange(size_t* location, size_t* length)
2471 { 2471 {
2472 const Frame* focused = focusedWebCoreFrame(); 2472 const Frame* focused = focusedWebCoreFrame();
2473 if (!focused) 2473 if (!focused)
2474 return false; 2474 return false;
2475 2475
2476 FrameSelection* selection = focused->selection(); 2476 FrameSelection* selection = focused->selection();
(...skipping 1087 matching lines...) Expand 10 before | Expand all | Expand 10 after
3564 Frame* frame = m_page->mainFrame(); 3564 Frame* frame = m_page->mainFrame();
3565 while (frame) { 3565 while (frame) {
3566 frame->view()->setTransparent(isTransparent); 3566 frame->view()->setTransparent(isTransparent);
3567 frame = frame->tree()->traverseNext(); 3567 frame = frame->tree()->traverseNext();
3568 } 3568 }
3569 3569
3570 // Future frames check this to know whether to be transparent. 3570 // Future frames check this to know whether to be transparent.
3571 m_isTransparent = isTransparent; 3571 m_isTransparent = isTransparent;
3572 } 3572 }
3573 3573
3574 void WebViewImpl::setBaseBackgroundColor(WebColor color)
3575 {
3576 Color c(static_cast<RGBA32>(color));
3577 if (m_baseBackgroundColor == c)
3578 return;
3579
3580 m_baseBackgroundColor = c;
3581
3582 m_page->mainFrame()->view()->updateBackgroundRecursively(c, m_isTransparent) ;
3583
3584 if (m_layerTreeView)
3585 m_layerTreeView->setBackgroundColor(backgroundColor());
3586 }
3587
3574 bool WebViewImpl::isTransparent() const 3588 bool WebViewImpl::isTransparent() const
3575 { 3589 {
3576 return m_isTransparent; 3590 return m_isTransparent;
3577 } 3591 }
3578 3592
3579 void WebViewImpl::setIsActive(bool active) 3593 void WebViewImpl::setIsActive(bool active)
3580 { 3594 {
3581 if (page() && page()->focusController()) 3595 if (page() && page()->focusController())
3582 page()->focusController()->setActive(active); 3596 page()->focusController()->setActive(active);
3583 } 3597 }
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
4142 } 4156 }
4143 4157
4144 bool WebViewImpl::shouldDisableDesktopWorkarounds() 4158 bool WebViewImpl::shouldDisableDesktopWorkarounds()
4145 { 4159 {
4146 ViewportArguments arguments = mainFrameImpl()->frame()->document()->viewport Arguments(); 4160 ViewportArguments arguments = mainFrameImpl()->frame()->document()->viewport Arguments();
4147 return arguments.width == ViewportArguments::ValueDeviceWidth || !arguments. userZoom 4161 return arguments.width == ViewportArguments::ValueDeviceWidth || !arguments. userZoom
4148 || (arguments.minZoom == arguments.maxZoom && arguments.minZoom != Viewp ortArguments::ValueAuto); 4162 || (arguments.minZoom == arguments.maxZoom && arguments.minZoom != Viewp ortArguments::ValueAuto);
4149 } 4163 }
4150 4164
4151 } // namespace WebKit 4165 } // namespace WebKit
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698