Changeset 85171 in webkit


Ignore:
Timestamp:
Apr 28, 2011 12:48:47 AM (13 years ago)
Author:
commit-queue@webkit.org
Message:

2011-04-28 Jon Lee <jonlee@apple.com>

Reviewed by Simon Fraser.

REGRESSION: white overlay scrollbars on apple.com/startpage
https://bugs.webkit.org/show_bug.cgi?id=59540
<rdar://problem/9338653>

Now we look at the document background in addition to the <body> element,
and blend those colors in with the base background of the frame view to
arrive at our aggregate color. This provides a better result to determine
overlay scrollbar style.

  • page/Frame.cpp: (WebCore::Frame::getDocumentBackgroundColor): look up the colors on the html and body element, and properly composite them.
  • platform/graphics/Color.h: a short comment to note that blend() uses the Porter-Duff source-over equation
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r85169 r85171  
     12011-04-28  Jon Lee  <jonlee@apple.com>
     2
     3        Reviewed by Simon Fraser.
     4
     5        REGRESSION: white overlay scrollbars on apple.com/startpage
     6        https://bugs.webkit.org/show_bug.cgi?id=59540
     7        <rdar://problem/9338653>
     8
     9        Now we look at the document background in addition to the <body> element,
     10        and blend those colors in with the base background of the frame view to
     11        arrive at our aggregate color. This provides a better result to determine
     12        overlay scrollbar style.
     13
     14        * page/Frame.cpp:
     15        (WebCore::Frame::getDocumentBackgroundColor): look up the colors on the html and body element, and properly composite them.
     16        * platform/graphics/Color.h: a short comment to note that blend() uses the Porter-Duff source-over equation
     17
    1182011-04-27  Adam Barth  <abarth@webkit.org>
    219
  • trunk/Source/WebCore/page/Frame.cpp

    r85164 r85171  
    504504Color Frame::getDocumentBackgroundColor() const
    505505{
    506     // FIXME: This is a basic implementation adopted originally from WebFrame,
    507     // but ultimately is wrong. Body painting propagates up to the document (see
    508     // RenderBox::paintRootBoxDecorations()), so code from that method should be
    509     // adopted here to get the style used to paint the root background.
    510 
    511     // Return invalid Color objects if we are not able to obtain the color
    512     // for whatever reason.
     506    // <https://bugs.webkit.org/show_bug.cgi?id=59540> We blend the background color of
     507    // the document and the body against the base background color of the frame view.
     508    // Background images are unfortunately impractical to include.
     509
     510    // Return invalid Color objects whenever there is insufficient information.
    513511    if (!m_doc)
    514512        return Color();
    515    
    516     Element* rootElementToUse = m_doc->body();
    517     if (!rootElementToUse)
    518         rootElementToUse = m_doc->documentElement();
    519     if (!rootElementToUse)
    520         return Color();
    521    
    522     RenderObject* renderer = rootElementToUse->renderer();
    523     if (!renderer)
    524         return Color();
    525    
    526     return renderer->style()->visitedDependentColor(CSSPropertyBackgroundColor);
     513
     514    Element* htmlElement = m_doc->documentElement();
     515    Element* bodyElement = m_doc->body();
     516
     517    // start as invalid colors
     518    Color htmlBackgroundColor;
     519    Color bodyBackgroundColor;
     520    if (htmlElement && htmlElement->renderer())
     521        htmlBackgroundColor = htmlElement->renderer()->style()->visitedDependentColor(CSSPropertyBackgroundColor);
     522    if (bodyElement && bodyElement->renderer())
     523        bodyBackgroundColor = bodyElement->renderer()->style()->visitedDependentColor(CSSPropertyBackgroundColor);
     524   
     525    if (!bodyBackgroundColor.isValid()) {
     526        if (!htmlBackgroundColor.isValid())
     527            return Color();
     528        return view()->baseBackgroundColor().blend(htmlBackgroundColor);
     529    }
     530   
     531    if (!htmlBackgroundColor.isValid())
     532        return view()->baseBackgroundColor().blend(bodyBackgroundColor);
     533   
     534    // We take the aggregate of the base background color
     535    // the <html> background color, and the <body>
     536    // background color to find the document color. The
     537    // addition of the base background color is not
     538    // technically part of the document background, but it
     539    // otherwise poses problems when the aggregate is not
     540    // fully opaque.
     541    return view()->baseBackgroundColor().blend(htmlBackgroundColor).blend(bodyBackgroundColor);
    527542}
    528543
  • trunk/Source/WebCore/platform/graphics/Color.h

    r84101 r85171  
    122122    Color dark() const;
    123123
     124    // This is an implementation of Porter-Duff's "source-over" equation
    124125    Color blend(const Color&) const;
    125126    Color blendWithWhite() const;
Note: See TracChangeset for help on using the changeset viewer.