Reviewed by Hyatt.
Allow changing the background color WebCore draws under transparent page backgrounds.
No automated way to test. All tests pass, no performance regression.
* bridge/mac/WebCoreFrameBridge.h:
* bridge/mac/WebCoreFrameBridge.mm:
(-[WebCoreFrameBridge setBaseBackgroundColor:]):
* page/FrameView.cpp:
(WebCore::FrameViewPrivate::FrameViewPrivate):
(WebCore::FrameView::baseBackgroundColor):
(WebCore::FrameView::setBaseBackgroundColor):
* page/FrameView.h:
* rendering/RenderBox.cpp:
(WebCore::RenderBox::paintBackgroundExtended):
* rendering/RenderView.cpp:
(WebCore::RenderView::paintBoxDecorations):
WebKit:
Reviewed by Hyatt.
WebView API to allow changing the background color that draws under transparent page backgrounds.
* WebView/WebFrame.m:
(-[WebFrame _makeDocumentView]):
(-[WebFrame _updateBackground]):
* WebView/WebFrameInternal.h:
* WebView/WebFrameView.m:
(-[WebFrameView drawRect:]):
* WebView/WebView.m:
(-[WebView setBackgroundColor:]):
(-[WebView backgroundColor]):
(-[WebView _commonInitializationWithFrameName:groupName:]):
(-[WebView setDrawsBackground:]):
* WebView/WebViewPrivate.h:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@16027
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2006-08-24 Timothy Hatcher <timothy@apple.com>
+
+ Reviewed by Hyatt.
+
+ Allow changing the background color WebCore draws under transparent page backgrounds.
+ No automated way to test. All tests pass, no performance regression.
+
+ * bridge/mac/WebCoreFrameBridge.h:
+ * bridge/mac/WebCoreFrameBridge.mm:
+ (-[WebCoreFrameBridge setBaseBackgroundColor:]):
+ * page/FrameView.cpp:
+ (WebCore::FrameViewPrivate::FrameViewPrivate):
+ (WebCore::FrameView::baseBackgroundColor):
+ (WebCore::FrameView::setBaseBackgroundColor):
+ * page/FrameView.h:
+ * rendering/RenderBox.cpp:
+ (WebCore::RenderBox::paintBackgroundExtended):
+ * rendering/RenderView.cpp:
+ (WebCore::RenderView::paintBoxDecorations):
+
2006-08-24 Darin Adler <darin@apple.com>
Reviewed by Justin.
- (BOOL)doneProcessingData;
- (BOOL)shouldClose;
+- (void)setBaseBackgroundColor:(NSColor *)backgroundColor;
- (void)setDrawsBackground:(BOOL)drawsBackround;
- (NSColor *)bodyBackgroundColor;
return m_frame->document()->axObjectCache()->get(root);
}
+- (void)setBaseBackgroundColor:(NSColor *)backgroundColor
+{
+ if (m_frame && m_frame->view()) {
+ NSColor *deviceColor = [backgroundColor colorUsingColorSpaceName:NSDeviceRGBColorSpace];
+ Color color = Color(makeRGBA((int)(255 * [deviceColor redComponent]),
+ (int)(255 * [deviceColor blueComponent]),
+ (int)(255 * [deviceColor greenComponent]),
+ (int)(255 * [deviceColor alphaComponent])));
+ m_frame->view()->setBaseBackgroundColor(color);
+ }
+}
+
- (void)setDrawsBackground:(BOOL)drawsBackground
{
if (m_frame && m_frame->view())
{
repaintRects = 0;
isTransparent = false;
+ baseBackgroundColor = Color::white;
vmode = hmode = ScrollBarAuto;
needToInitScrollBars = true;
reset();
bool needToInitScrollBars;
bool mousePressed;
bool isTransparent;
-
+ Color baseBackgroundColor;
+
Timer<FrameView> hoverTimer;
RenderLayer* m_resizeLayer;
d->isTransparent = isTransparent;
}
+Color FrameView::baseBackgroundColor() const
+{
+ return d->baseBackgroundColor;
+}
+
+void FrameView::setBaseBackgroundColor(Color bc)
+{
+ if (!bc.isValid())
+ bc = Color::white;
+ d->baseBackgroundColor = bc;
+}
+
void FrameView::scheduleHoverStateUpdate()
{
if (!d->hoverTimer.isActive())
namespace WebCore {
class AtomicString;
+class Color;
class CSSProperty;
class CSSStyleSelector;
class Clipboard;
bool isTransparent() const;
void setTransparent(bool isTransparent);
-
+
+ Color baseBackgroundColor() const;
+ void setBaseBackgroundColor(Color);
+
void scheduleRelayout();
void scheduleRelayoutOfSubtree(Node*);
void unscheduleRelayout();
if (isTransparent)
view()->frameView()->setUseSlowRepaints(); // The parent must show behind the child.
- else
- bgColor = Color::white;
}
// Paint the color first underneath all images.
- if (!bgLayer->next() && bgColor.isValid() && bgColor.alpha() > 0) {
+ if (!bgLayer->next()) {
IntRect rect(_tx, clipy, w, cliph);
- // If we have an alpha and we are painting the root element, go ahead and blend with white.
- if (bgColor.alpha() < 0xFF && isRoot() && !view()->frameView()->isTransparent())
- p->fillRect(rect, Color(Color::white));
- p->fillRect(rect, bgColor);
+ // If we have an alpha and we are painting the root element, go ahead and blend with the base background color.
+ if (isRoot() && (!bgColor.isValid() || bgColor.alpha() < 0xFF) && !view()->frameView()->isTransparent()) {
+ Color baseColor = view()->frameView()->baseBackgroundColor();
+ if (baseColor.alpha() > 0) {
+ p->save();
+ p->setCompositeOperation(CompositeCopy);
+ p->fillRect(rect, baseColor);
+ p->restore();
+ } else
+ p->clearRect(rect);
+ }
+
+ if (bgColor.isValid() && bgColor.alpha() > 0)
+ p->fillRect(rect, bgColor);
}
// no progressive loading of the background image
// no background in the child document should show the parent's background.
if (elt || view()->isTransparent())
frameView()->setUseSlowRepaints(); // The parent must show behind the child.
- else
- i.p->fillRect(i.r, Color(Color::white));
+ else {
+ Color baseColor = frameView()->baseBackgroundColor();
+ if (baseColor.alpha() > 0) {
+ i.p->save();
+ i.p->setCompositeOperation(CompositeCopy);
+ i.p->fillRect(i.r, baseColor);
+ i.p->restore();
+ } else
+ i.p->clearRect(i.r);
+ }
}
void RenderView::repaintViewRectangle(const IntRect& ur, bool immediate)
+2006-08-24 Timothy Hatcher <timothy@apple.com>
+
+ Reviewed by Hyatt.
+
+ WebView API to allow changing the background color that draws under transparent page backgrounds.
+
+ * WebView/WebFrame.m:
+ (-[WebFrame _makeDocumentView]):
+ (-[WebFrame _updateBackground]):
+ * WebView/WebFrameInternal.h:
+ * WebView/WebFrameView.m:
+ (-[WebFrameView drawRect:]):
+ * WebView/WebView.m:
+ (-[WebView setBackgroundColor:]):
+ (-[WebView backgroundColor]):
+ (-[WebView _commonInitializationWithFrameName:groupName:]):
+ (-[WebView setDrawsBackground:]):
+ * WebView/WebViewPrivate.h:
+
2006-08-24 Timothy Hatcher <timothy@apple.com>
Reviewed by Darin.
// FIXME: We could save work and not do this for a top-level view that is not a WebHTMLView.
WebFrameView *v = _private->webFrameView;
[_private->bridge createFrameViewWithNSView:documentView marginWidth:[v _marginWidth] marginHeight:[v _marginHeight]];
- [self _updateDrawsBackground];
+ [self _updateBackground];
[_private->bridge installInFrame:[v _scrollView]];
// Call setDataSource on the document view after it has been placed in the view hierarchy.
return result;
}
-- (void)_updateDrawsBackground
+- (void)_updateBackground
{
BOOL drawsBackground = [[self webView] drawsBackground];
+ NSColor *backgroundColor = [[self webView] backgroundColor];
for (WebFrame *frame = self; frame; frame = [frame _traverseNextFrameStayWithin:self]) {
- // FIXME: why not the other way for scroll view?
+ // Never call setDrawsBackground:YES on the scroll view or the background color will
+ // flash between pages loads, very noticeable during the PLT.
if (!drawsBackground)
[[[frame frameView] _scrollView] setDrawsBackground:NO];
+ [[[frame frameView] _scrollView] setBackgroundColor:backgroundColor];
id documentView = [[frame frameView] documentView];
if ([documentView respondsToSelector:@selector(setDrawsBackground:)])
[documentView setDrawsBackground:drawsBackground];
+ if ([documentView respondsToSelector:@selector(setBackgroundColor:)])
+ [documentView setBackgroundColor:backgroundColor];
[[frame _bridge] setDrawsBackground:drawsBackground];
+ [[frame _bridge] setBaseBackgroundColor:backgroundColor];
}
}
@interface WebFrame (WebInternal)
-- (void)_updateDrawsBackground;
+- (void)_updateBackground;
- (void)_setInternalLoadDelegate:(id)internalLoadDelegate;
- (id)_internalLoadDelegate;
- (void)_unmarkAllMisspellings;
if ([self documentView] == nil) {
// Need to paint ourselves if there's no documentView to do it instead.
if ([[self _webView] drawsBackground]) {
- [[NSColor whiteColor] set];
+ [[[self _webView] backgroundColor] set];
NSRectFill(rect);
}
} else {
BOOL tabKeyCyclesThroughElements;
BOOL tabKeyCyclesThroughElementsChanged;
+ NSColor *backgroundColor;
+
NSString *mediaStyle;
NSView <WebDocumentDragging> *draggingDocumentView;
} while (frame);
}
+- (void)setBackgroundColor:(NSColor *)backgroundColor
+{
+ if ([_private->backgroundColor isEqual:backgroundColor])
+ return;
+
+ id old = _private->backgroundColor;
+ _private->backgroundColor = [backgroundColor retain];
+ [old release];
+
+ [[self mainFrame] _updateBackground];
+}
+
+- (NSColor *)backgroundColor
+{
+ return _private->backgroundColor;
+}
+
@end
_private->mainFrameDocumentReady = NO;
_private->drawsBackground = YES;
_private->smartInsertDeleteEnabled = YES;
+ _private->backgroundColor = [[NSColor whiteColor] retain];
NSRect f = [self frame];
WebFrameView *frameView = [[WebFrameView alloc] initWithFrame: NSMakeRect(0,0,f.size.width,f.size.height)];
if (_private->drawsBackground == drawsBackground)
return;
_private->drawsBackground = drawsBackground;
- [[self mainFrame] _updateDrawsBackground];
+ [[self mainFrame] _updateBackground];
}
- (BOOL)drawsBackground
+ (BOOL)_developerExtrasEnabled;
+ (BOOL)_scriptDebuggerEnabled;
+/*!
+ @method setBackgroundColor:
+ @param backgroundColor Color to use as the default background.
+ @abstract Sets what color the receiver draws under transparent page background colors and images.
+ This color is also used when no page is loaded. A color with alpha should only be used when the receiver is
+ in a non-opaque window, since the color is drawn using NSCompositeCopy.
+*/
+- (void)setBackgroundColor:(NSColor *)backgroundColor;
+
+/*!
+ @method backgroundColor
+ @result Returns the background color drawn under transparent page background colors and images.
+ This color is also used when no page is loaded. A color with alpha should only be used when the receiver is
+ in a non-opaque window, since the color is drawn using NSCompositeCopy.
+*/
+- (NSColor *)backgroundColor;
+
/*!
Could be worth adding to the API.
@method loadItemsFromOtherView: