Commit b92d8776 authored by timothy@apple.com's avatar timothy@apple.com

WebCore: Export Color::white and Color::transparent.

Reviewed by Anders Carlsson.

* WebCore.exp.in:

WebKit2: Add support for transparent WebKit2 WKViews.

https://webkit.org/b/50785

Reviewed by Anders Carlsson.

* Shared/WebPageCreationParameters.cpp:
(WebKit::WebPageCreationParameters::encode): Encode drawsBackground and drawsTransparentBackground.
(WebKit::WebPageCreationParameters::decode): Decode drawsBackground and drawsTransparentBackground.
* Shared/WebPageCreationParameters.h:
* UIProcess/API/mac/WKView.h:
* UIProcess/API/mac/WKView.mm:
(-[WKView setDrawsBackground:]): Added.
(-[WKView drawsBackground]): Added.
(-[WKView setDrawsTransparentBackground:]): Added.
(-[WKView drawsTransparentBackground]): Added.
(-[WKView drawRect:]): Only fill the background if the WebProcess isn't valid and drawsBackground.
Use white or clear based on setDrawsTransparentBackground.
(-[WKView isOpaque]): Return drawsBackground.
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::WebPageProxy): Initialize m_drawsBackground and m_drawsTransparentBackground.
(WebKit::WebPageProxy::setDrawsBackground): Added. Send a SetDrawsBackground message.
(WebKit::WebPageProxy::setDrawsTransparentBackground): Added. Send a SetDrawsTransparentBackground message.
(WebKit::WebPageProxy::creationParameters): Set drawsBackground and drawsTransparentBackground.
* UIProcess/WebPageProxy.h:
(WebKit::WebPageProxy::drawsBackground): Added. Return m_drawsBackground.
(WebKit::WebPageProxy::drawsTransparentBackground): Added. Return m_drawsTransparentBackground.
* UIProcess/mac/ChunkedUpdateDrawingAreaProxyMac.mm:
(WebKit::ChunkedUpdateDrawingAreaProxy::platformPaint): Use the copy blend mode when drawing a background.
(WebKit::ChunkedUpdateDrawingAreaProxy::drawUpdateChunkIntoBackingStore): Use the copy blend mode to replace existing content.
* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::transitionToCommittedForNewPage): Setup the new view's background color and transparent flag.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::WebPage): Initialize m_drawsBackground and m_drawsTransparentBackground.
(WebKit::WebPage::setDrawsBackground): Added. Propagate the flag to the FrameViews.
(WebKit::WebPage::setDrawsTransparentBackground): Added. Propagate the background color to the FrameViews.
* WebProcess/WebPage/WebPage.h:
(WebKit::WebPage::drawsBackground): Added. Return m_drawsBackground.
(WebKit::WebPage::drawsTransparentBackground): Added. Return m_drawsTransparentBackground.
* WebProcess/WebPage/WebPage.messages.in: Added SetDrawsBackground and SetDrawsTransparentBackground.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@73666 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 7682f297
2010-12-09 Timothy Hatcher <timothy@apple.com>
Export Color::white and Color::transparent.
Reviewed by Anders Carlsson.
* WebCore.exp.in:
2010-12-09 Sam Weinig <sam@webkit.org>
Fix failing Mac tests.
......
......@@ -648,6 +648,8 @@ __ZN7WebCore4coreEP20NSURLProtectionSpace
__ZN7WebCore4toJSEPN3JSC9ExecStateEPNS_17JSDOMGlobalObjectEPNS_19CSSStyleDeclarationE
__ZN7WebCore4toJSEPN3JSC9ExecStateEPNS_17JSDOMGlobalObjectEPNS_5RangeE
__ZN7WebCore4toJSEPN3JSC9ExecStateEPNS_17JSDOMGlobalObjectEPNS_8NodeListE
__ZN7WebCore5Color11transparentE
__ZN7WebCore5Color5whiteE
__ZN7WebCore5Frame10createViewERKNS_7IntSizeERKNS_5ColorEbS3_bNS_13ScrollbarModeEbS7_b
__ZN7WebCore5Frame14frameForWidgetEPKNS_6WidgetE
__ZN7WebCore5Frame17setPageZoomFactorEf
......
2010-12-09 Timothy Hatcher <timothy@apple.com>
Add support for transparent WebKit2 WKViews.
https://webkit.org/b/50785
Reviewed by Anders Carlsson.
* Shared/WebPageCreationParameters.cpp:
(WebKit::WebPageCreationParameters::encode): Encode drawsBackground and drawsTransparentBackground.
(WebKit::WebPageCreationParameters::decode): Decode drawsBackground and drawsTransparentBackground.
* Shared/WebPageCreationParameters.h:
* UIProcess/API/mac/WKView.h:
* UIProcess/API/mac/WKView.mm:
(-[WKView setDrawsBackground:]): Added.
(-[WKView drawsBackground]): Added.
(-[WKView setDrawsTransparentBackground:]): Added.
(-[WKView drawsTransparentBackground]): Added.
(-[WKView drawRect:]): Only fill the background if the WebProcess isn't valid and drawsBackground.
Use white or clear based on setDrawsTransparentBackground.
(-[WKView isOpaque]): Return drawsBackground.
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::WebPageProxy): Initialize m_drawsBackground and m_drawsTransparentBackground.
(WebKit::WebPageProxy::setDrawsBackground): Added. Send a SetDrawsBackground message.
(WebKit::WebPageProxy::setDrawsTransparentBackground): Added. Send a SetDrawsTransparentBackground message.
(WebKit::WebPageProxy::creationParameters): Set drawsBackground and drawsTransparentBackground.
* UIProcess/WebPageProxy.h:
(WebKit::WebPageProxy::drawsBackground): Added. Return m_drawsBackground.
(WebKit::WebPageProxy::drawsTransparentBackground): Added. Return m_drawsTransparentBackground.
* UIProcess/mac/ChunkedUpdateDrawingAreaProxyMac.mm:
(WebKit::ChunkedUpdateDrawingAreaProxy::platformPaint): Use the copy blend mode when drawing a background.
(WebKit::ChunkedUpdateDrawingAreaProxy::drawUpdateChunkIntoBackingStore): Use the copy blend mode to replace existing content.
* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::transitionToCommittedForNewPage): Setup the new view's background color and transparent flag.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::WebPage): Initialize m_drawsBackground and m_drawsTransparentBackground.
(WebKit::WebPage::setDrawsBackground): Added. Propagate the flag to the FrameViews.
(WebKit::WebPage::setDrawsTransparentBackground): Added. Propagate the background color to the FrameViews.
* WebProcess/WebPage/WebPage.h:
(WebKit::WebPage::drawsBackground): Added. Return m_drawsBackground.
(WebKit::WebPage::drawsTransparentBackground): Added. Return m_drawsTransparentBackground.
* WebProcess/WebPage/WebPage.messages.in: Added SetDrawsBackground and SetDrawsTransparentBackground.
2010-12-09 Anders Carlsson <andersca@apple.com>
Reviewed by Sam Weinig.
......@@ -35,6 +35,8 @@ void WebPageCreationParameters::encode(CoreIPC::ArgumentEncoder* encoder) const
encoder->encode(store);
encoder->encode(drawingAreaInfo);
encoder->encode(pageGroupData);
encoder->encode(drawsBackground);
encoder->encode(drawsTransparentBackground);
#if PLATFORM(WIN)
encoder->encode(reinterpret_cast<uint64_t>(nativeWindow));
......@@ -51,6 +53,10 @@ bool WebPageCreationParameters::decode(CoreIPC::ArgumentDecoder* decoder, WebPag
return false;
if (!decoder->decode(parameters.pageGroupData))
return false;
if (!decoder->decode(parameters.drawsBackground))
return false;
if (!decoder->decode(parameters.drawsTransparentBackground))
return false;
#if PLATFORM(WIN)
uint64_t nativeWindow;
......
......@@ -47,6 +47,9 @@ struct WebPageCreationParameters {
DrawingAreaInfo drawingAreaInfo;
WebPageGroupData pageGroupData;
bool drawsBackground;
bool drawsTransparentBackground;
#if PLATFORM(WIN)
HWND nativeWindow;
#endif
......
......@@ -38,4 +38,10 @@ WK_EXPORT
- (WKPageRef)pageRef;
- (void)setDrawsBackground:(BOOL)flag;
- (BOOL)drawsBackground;
- (void)setDrawsTransparentBackground:(BOOL)flag;
- (BOOL)drawsTransparentBackground;
@end
......@@ -176,6 +176,26 @@ struct EditCommandState {
return toAPI(_data->_page.get());
}
- (void)setDrawsBackground:(BOOL)drawsBackground
{
_data->_page->setDrawsBackground(drawsBackground);
}
- (BOOL)drawsBackground
{
return _data->_page->drawsBackground();
}
- (void)setDrawsTransparentBackground:(BOOL)drawsTransparentBackground
{
_data->_page->setDrawsTransparentBackground(drawsTransparentBackground);
}
- (BOOL)drawsTransparentBackground
{
return _data->_page->drawsTransparentBackground();
}
- (BOOL)acceptsFirstResponder
{
return YES;
......@@ -673,21 +693,20 @@ static bool isViewVisible(NSView *view)
}
- (void)drawRect:(NSRect)rect
{
[[NSColor whiteColor] set];
NSRectFill(rect);
{
if (_data->_page->isValid() && _data->_page->drawingArea()) {
CGContextRef context = static_cast<CGContextRef>([[NSGraphicsContext currentContext] graphicsPort]);
_data->_page->drawingArea()->paint(IntRect(rect), context);
_data->_page->didDraw();
} else if (_data->_page->drawsBackground()) {
[_data->_page->drawsTransparentBackground() ? [NSColor clearColor] : [NSColor whiteColor] set];
NSRectFill(rect);
}
}
- (BOOL)isOpaque
- (BOOL)isOpaque
{
// FIXME: Return NO if we have a transparent background.
return YES;
return _data->_page->drawsBackground();
}
- (void)viewDidHide
......
......@@ -104,6 +104,8 @@ WebPageProxy::WebPageProxy(WebPageNamespace* pageNamespace, WebPageGroup* pageGr
, m_textZoomFactor(1)
, m_pageZoomFactor(1)
, m_viewScaleFactor(1)
, m_drawsBackground(true)
, m_drawsTransparentBackground(false)
, m_isValid(true)
, m_isClosed(false)
, m_inDecidePolicyForMIMEType(false)
......@@ -400,6 +402,28 @@ bool WebPageProxy::canShowMIMEType(const String& mimeType) const
return false;
}
void WebPageProxy::setDrawsBackground(bool drawsBackground)
{
if (m_drawsBackground == drawsBackground)
return;
m_drawsBackground = drawsBackground;
if (isValid())
process()->send(Messages::WebPage::SetDrawsBackground(drawsBackground), m_pageID);
}
void WebPageProxy::setDrawsTransparentBackground(bool drawsTransparentBackground)
{
if (m_drawsTransparentBackground == drawsTransparentBackground)
return;
m_drawsTransparentBackground = drawsTransparentBackground;
if (isValid())
process()->send(Messages::WebPage::SetDrawsTransparentBackground(drawsTransparentBackground), m_pageID);
}
void WebPageProxy::setFocused(bool isFocused)
{
if (!isValid())
......@@ -1526,6 +1550,8 @@ WebPageCreationParameters WebPageProxy::creationParameters(const IntSize& size)
parameters.drawingAreaInfo = m_drawingArea->info();
parameters.store = m_pageGroup->preferences()->store();
parameters.pageGroupData = m_pageGroup->data();
parameters.drawsBackground = m_drawsBackground;
parameters.drawsTransparentBackground = m_drawsTransparentBackground;
#if PLATFORM(WIN)
parameters.nativeWindow = m_pageClient->nativeWindow();
......
......@@ -158,9 +158,15 @@ public:
bool canShowMIMEType(const String& mimeType) const;
void setFocused(bool isFocused);
void setActive(bool active);
void setIsInWindow(bool isInWindow);
bool drawsBackground() const { return m_drawsBackground; }
void setDrawsBackground(bool);
bool drawsTransparentBackground() const { return m_drawsTransparentBackground; }
void setDrawsTransparentBackground(bool);
void setFocused(bool);
void setActive(bool);
void setIsInWindow(bool);
void setWindowResizerSize(const WebCore::IntSize&);
void executeEditCommand(const String& commandName);
......@@ -435,7 +441,8 @@ private:
double m_pageZoomFactor;
double m_viewScaleFactor;
bool m_visibleToInjectedBundle;
bool m_drawsBackground;
bool m_drawsTransparentBackground;
// If the process backing the web page is alive and kicking.
bool m_isValid;
......
......@@ -67,6 +67,10 @@ void ChunkedUpdateDrawingAreaProxy::platformPaint(const IntRect& rect, CGContext
CGContextSaveGState(context);
// Use the copy blend mode when drawing a background.
if (page()->drawsBackground())
CGContextSetBlendMode(context, kCGBlendModeCopy);
// Flip the destination.
CGContextScaleCTM(context, 1, -1);
CGContextTranslateCTM(context, 0, -m_size.height());
......@@ -84,12 +88,17 @@ void ChunkedUpdateDrawingAreaProxy::drawUpdateChunkIntoBackingStore(UpdateChunk*
RetainPtr<CGImageRef> image(updateChunk->createImage());
IntRect updateChunkRect = updateChunk->rect();
// Flip the destination.
CGContextSaveGState(m_bitmapContext.get());
// Use the copy blend mode to replace existing content.
CGContextSetBlendMode(m_bitmapContext.get(), kCGBlendModeCopy);
// Flip the destination.
CGContextScaleCTM(m_bitmapContext.get(), 1, -1);
CGContextTranslateCTM(m_bitmapContext.get(), 0, -(updateChunkRect.y() + updateChunkRect.bottom()));
CGContextDrawImage(m_bitmapContext.get(), updateChunkRect, image.get());
CGContextRestoreGState(m_bitmapContext.get());
[m_webView setNeedsDisplayInRect:NSRectFromCGRect(updateChunkRect)];
......
......@@ -1030,12 +1030,13 @@ void WebFrameLoaderClient::transitionToCommittedFromCachedFrame(CachedFrame*)
void WebFrameLoaderClient::transitionToCommittedForNewPage()
{
WebPage* webPage = m_frame->page();
Color backgroundColor = webPage->drawsTransparentBackground() ? Color::transparent : Color::white;
bool isMainFrame = webPage->mainFrame() == m_frame;
#if ENABLE(TILED_BACKING_STORE)
IntSize currentVisibleContentSize = m_frame->coreFrame()->view() ? m_frame->coreFrame()->view()->actualVisibleContentRect().size() : IntSize();
m_frame->coreFrame()->createView(m_frame->page()->size(), Color::white, false, webPage->resizesToContentsLayoutSize(), isMainFrame && webPage->resizesToContentsEnabled());
m_frame->coreFrame()->createView(webPage->size(), backgroundColor, false, webPage->resizesToContentsLayoutSize(), isMainFrame && webPage->resizesToContentsEnabled());
if (isMainFrame && webPage->resizesToContentsEnabled()) {
m_frame->coreFrame()->view()->setDelegatesScrolling(true);
......@@ -1048,8 +1049,10 @@ void WebFrameLoaderClient::transitionToCommittedForNewPage()
const String& mimeType = m_frame->coreFrame()->loader()->documentLoader()->response().mimeType();
m_frameHasCustomRepresentation = isMainFrame && WebProcess::shared().shouldUseCustomRepresentationForMIMEType(mimeType);
m_frame->coreFrame()->createView(m_frame->page()->size(), Color::white, false, IntSize(), false);
m_frame->coreFrame()->createView(webPage->size(), backgroundColor, false, IntSize(), false);
#endif
m_frame->coreFrame()->view()->setTransparent(!webPage->drawsBackground());
}
void WebFrameLoaderClient::dispatchDidBecomeFrameset(bool value)
......
......@@ -111,6 +111,8 @@ PassRefPtr<WebPage> WebPage::create(uint64_t pageID, const WebPageCreationParame
WebPage::WebPage(uint64_t pageID, const WebPageCreationParameters& parameters)
: m_viewSize(parameters.viewSize)
, m_drawsBackground(true)
, m_drawsTransparentBackground(false)
, m_isInRedo(false)
, m_isClosed(false)
, m_tabToLinks(false)
......@@ -154,6 +156,9 @@ WebPage::WebPage(uint64_t pageID, const WebPageCreationParameters& parameters)
m_drawingArea = DrawingArea::create(parameters.drawingAreaInfo.type, parameters.drawingAreaInfo.identifier, this);
m_mainFrame = WebFrame::createMainFrame(this);
setDrawsBackground(parameters.drawsBackground);
setDrawsTransparentBackground(parameters.drawsTransparentBackground);
#ifndef NDEBUG
webPageCounter.increment();
#endif
......@@ -763,6 +768,37 @@ void WebPage::setActive(bool isActive)
#endif
}
void WebPage::setDrawsBackground(bool drawsBackground)
{
if (m_drawsBackground == drawsBackground)
return;
m_drawsBackground = drawsBackground;
for (Frame* coreFrame = m_mainFrame->coreFrame(); coreFrame; coreFrame = coreFrame->tree()->traverseNext()) {
if (FrameView* view = coreFrame->view())
view->setTransparent(!drawsBackground);
}
m_drawingArea->setNeedsDisplay(IntRect(IntPoint(0, 0), m_viewSize));
}
void WebPage::setDrawsTransparentBackground(bool drawsTransparentBackground)
{
if (m_drawsTransparentBackground == drawsTransparentBackground)
return;
m_drawsTransparentBackground = drawsTransparentBackground;
Color backgroundColor = drawsTransparentBackground ? Color::transparent : Color::white;
for (Frame* coreFrame = m_mainFrame->coreFrame(); coreFrame; coreFrame = coreFrame->tree()->traverseNext()) {
if (FrameView* view = coreFrame->view())
view->setBaseBackgroundColor(backgroundColor);
}
m_drawingArea->setNeedsDisplay(IntRect(IntPoint(0, 0), m_viewSize));
}
void WebPage::setFocused(bool isFocused)
{
m_page->focusController()->setFocused(isFocused);
......
......@@ -173,6 +173,9 @@ public:
void scaleWebView(double scale, const WebCore::IntPoint& origin);
double viewScaleFactor() const;
bool drawsBackground() const { return m_drawsBackground; }
bool drawsTransparentBackground() const { return m_drawsTransparentBackground; }
void stopLoading();
#if USE(ACCELERATED_COMPOSITING)
......@@ -276,6 +279,9 @@ private:
void touchEvent(const WebTouchEvent&);
#endif
void setDrawsBackground(bool);
void setDrawsTransparentBackground(bool);
void getContentsAsString(uint64_t callbackID);
void getRenderTreeExternalRepresentation(uint64_t callbackID);
void getSourceForFrame(uint64_t frameID, uint64_t callbackID);
......@@ -322,6 +328,9 @@ private:
WebCore::IntSize m_viewSize;
RefPtr<DrawingArea> m_drawingArea;
bool m_drawsBackground;
bool m_drawsTransparentBackground;
bool m_isInRedo;
bool m_isClosed;
......
......@@ -25,6 +25,9 @@ messages -> WebPage {
SetFocused(bool focused)
SetIsInWindow(bool isInWindow)
SetDrawsBackground(bool drawsBackground)
SetDrawsTransparentBackground(bool drawsTransparentBackground)
KeyEvent(WebKit::WebKeyboardEvent event)
MouseEvent(WebKit::WebMouseEvent event)
WheelEvent(WebKit::WebWheelEvent event)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment