mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 12:25:53 +00:00
Bug 486933 - image-rendering does not work on body or root CSS background images. r+sr=roc
This commit is contained in:
parent
bff20cf17a
commit
2fbd5745fc
@ -904,6 +904,59 @@ nsCSSRendering::FindNonTransparentBackground(nsStyleContext* aContext,
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Returns true if aFrame is a canvas frame.
|
||||
// We need to treat the viewport as canvas because, even though
|
||||
// it does not actually paint a background, we need to get the right
|
||||
// background style so we correctly detect transparent documents.
|
||||
PRBool
|
||||
nsCSSRendering::IsCanvasFrame(nsIFrame *aFrame)
|
||||
{
|
||||
nsIAtom* frameType = aFrame->GetType();
|
||||
return frameType == nsGkAtoms::canvasFrame ||
|
||||
frameType == nsGkAtoms::rootFrame ||
|
||||
frameType == nsGkAtoms::pageFrame ||
|
||||
frameType == nsGkAtoms::pageContentFrame ||
|
||||
frameType == nsGkAtoms::viewportFrame;
|
||||
}
|
||||
|
||||
nsIFrame*
|
||||
nsCSSRendering::FindRootFrame(nsIFrame *aForFrame)
|
||||
{
|
||||
const nsStyleBackground* result = aForFrame->GetStyleBackground();
|
||||
|
||||
// Check if we need to do propagation from BODY rather than HTML.
|
||||
if (result->IsTransparent()) {
|
||||
nsIContent* content = aForFrame->GetContent();
|
||||
// The root element content can't be null. We wouldn't know what
|
||||
// frame to create for aFrame.
|
||||
// Use |GetOwnerDoc| so it works during destruction.
|
||||
nsIDocument* document = content->GetOwnerDoc();
|
||||
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(document);
|
||||
if (htmlDoc) {
|
||||
nsIContent* bodyContent = htmlDoc->GetBodyContentExternal();
|
||||
// We need to null check the body node (bug 118829) since
|
||||
// there are cases, thanks to the fix for bug 5569, where we
|
||||
// will reflow a document with no body. In particular, if a
|
||||
// SCRIPT element in the head blocks the parser and then has a
|
||||
// SCRIPT that does "document.location.href = 'foo'", then
|
||||
// nsParser::Terminate will call |DidBuildModel| methods
|
||||
// through to the content sink, which will call |StartLayout|
|
||||
// and thus |InitialReflow| on the pres shell. See bug 119351
|
||||
// for the ugly details.
|
||||
if (bodyContent) {
|
||||
nsIFrame *bodyFrame = aForFrame->PresContext()->GetPresShell()->
|
||||
GetPrimaryFrameFor(bodyContent);
|
||||
if (bodyFrame) {
|
||||
return bodyFrame;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return aForFrame;
|
||||
}
|
||||
|
||||
/**
|
||||
* |FindBackground| finds the correct style data to use to paint the
|
||||
* background. It is responsible for handling the following two
|
||||
@ -933,56 +986,10 @@ nsCSSRendering::FindNonTransparentBackground(nsStyleContext* aContext,
|
||||
* whether the frame is the canvas frame, because PaintBackground must
|
||||
* propagate that frame's background color to the view manager.
|
||||
*/
|
||||
|
||||
// Returns true if aFrame is a canvas frame.
|
||||
// We need to treat the viewport as canvas because, even though
|
||||
// it does not actually paint a background, we need to get the right
|
||||
// background style so we correctly detect transparent documents.
|
||||
PRBool
|
||||
nsCSSRendering::IsCanvasFrame(nsIFrame *aFrame)
|
||||
{
|
||||
nsIAtom* frameType = aFrame->GetType();
|
||||
return frameType == nsGkAtoms::canvasFrame ||
|
||||
frameType == nsGkAtoms::rootFrame ||
|
||||
frameType == nsGkAtoms::pageFrame ||
|
||||
frameType == nsGkAtoms::pageContentFrame ||
|
||||
frameType == nsGkAtoms::viewportFrame;
|
||||
}
|
||||
|
||||
const nsStyleBackground*
|
||||
nsCSSRendering::FindRootFrameBackground(nsIFrame* aForFrame)
|
||||
{
|
||||
const nsStyleBackground* result = aForFrame->GetStyleBackground();
|
||||
|
||||
// Check if we need to do propagation from BODY rather than HTML.
|
||||
if (result->IsTransparent()) {
|
||||
nsIContent* content = aForFrame->GetContent();
|
||||
// The root element content can't be null. We wouldn't know what
|
||||
// frame to create for aForFrame.
|
||||
// Use |GetOwnerDoc| so it works during destruction.
|
||||
nsIDocument* document = content->GetOwnerDoc();
|
||||
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(document);
|
||||
if (htmlDoc) {
|
||||
nsIContent* bodyContent = htmlDoc->GetBodyContentExternal();
|
||||
// We need to null check the body node (bug 118829) since
|
||||
// there are cases, thanks to the fix for bug 5569, where we
|
||||
// will reflow a document with no body. In particular, if a
|
||||
// SCRIPT element in the head blocks the parser and then has a
|
||||
// SCRIPT that does "document.location.href = 'foo'", then
|
||||
// nsParser::Terminate will call |DidBuildModel| methods
|
||||
// through to the content sink, which will call |StartLayout|
|
||||
// and thus |InitialReflow| on the pres shell. See bug 119351
|
||||
// for the ugly details.
|
||||
if (bodyContent) {
|
||||
nsIFrame *bodyFrame = aForFrame->PresContext()->GetPresShell()->
|
||||
GetPrimaryFrameFor(bodyContent);
|
||||
if (bodyFrame)
|
||||
result = bodyFrame->GetStyleBackground();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
return FindRootFrame(aForFrame)->GetStyleBackground();
|
||||
}
|
||||
|
||||
inline void
|
||||
|
@ -119,7 +119,12 @@ struct nsCSSRendering {
|
||||
nscolor aColor);
|
||||
|
||||
/**
|
||||
* @return PR_TRUE if |aForFrame| is a canvas frame, in the CSS sense.
|
||||
* Gets the root frame for the frame
|
||||
*/
|
||||
static nsIFrame* FindRootFrame(nsIFrame* aForFrame);
|
||||
|
||||
/**
|
||||
* @return PR_TRUE if |aFrame| is a canvas frame, in the CSS sense.
|
||||
*/
|
||||
static PRBool IsCanvasFrame(nsIFrame* aFrame);
|
||||
|
||||
|
@ -2669,10 +2669,13 @@ nsLayoutUtils::GetClosestLayer(nsIFrame* aFrame)
|
||||
}
|
||||
|
||||
gfxPattern::GraphicsFilter
|
||||
nsLayoutUtils::GetGraphicsFilterForFrame(nsIFrame* aFrame)
|
||||
nsLayoutUtils::GetGraphicsFilterForFrame(nsIFrame* aForFrame)
|
||||
{
|
||||
#ifdef MOZ_SVG
|
||||
switch (aFrame->GetStyleSVG()->mImageRendering) {
|
||||
nsIFrame *frame = nsCSSRendering::IsCanvasFrame(aForFrame) ?
|
||||
nsCSSRendering::FindRootFrame(aForFrame) : aForFrame;
|
||||
|
||||
switch (frame->GetStyleSVG()->mImageRendering) {
|
||||
case NS_STYLE_IMAGE_RENDERING_OPTIMIZESPEED:
|
||||
return gfxPattern::FILTER_FAST;
|
||||
case NS_STYLE_IMAGE_RENDERING_OPTIMIZEQUALITY:
|
||||
|
21
layout/reftests/image/background-image-zoom-1-ref.html
Normal file
21
layout/reftests/image/background-image-zoom-1-ref.html
Normal file
@ -0,0 +1,21 @@
|
||||
<!DOCTYPE HTML>
|
||||
<!--
|
||||
Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/licenses/publicdomain/
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<title>reference background-image-rendering: -moz-crisp-edges</title>
|
||||
<style>
|
||||
html
|
||||
{
|
||||
background-image: url('big.png');
|
||||
background-attachment:fixed;
|
||||
background-position: 20px 20px;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
22
layout/reftests/image/background-image-zoom-1.html
Normal file
22
layout/reftests/image/background-image-zoom-1.html
Normal file
@ -0,0 +1,22 @@
|
||||
<!DOCTYPE HTML>
|
||||
<!--
|
||||
Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/licenses/publicdomain/
|
||||
-->
|
||||
<html reftest-zoom="5">
|
||||
<head>
|
||||
<title>test background-image-rendering: -moz-crisp-edges</title>
|
||||
<style>
|
||||
html
|
||||
{
|
||||
background-image: url('small.png');
|
||||
image-rendering: -moz-crisp-edges;
|
||||
background-attachment:fixed;
|
||||
background-position: 4px 4px;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
@ -1 +1,2 @@
|
||||
== image-zoom-1.html image-zoom-1-ref.html
|
||||
== background-image-zoom-1.html background-image-zoom-1-ref.html
|
||||
== image-zoom-1.html image-zoom-1-ref.html
|
||||
|
Loading…
Reference in New Issue
Block a user