Merge m-c to inbound.

This commit is contained in:
Ryan VanderMeulen 2013-05-21 13:45:22 -04:00
commit 5465c5b995

View File

@ -682,17 +682,20 @@ nsNativeTheme::IsRangeHorizontal(nsIFrame* aFrame)
bool
nsNativeTheme::IsDarkBackground(nsIFrame* aFrame)
{
nsIScrollableFrame* scrollFrame = aFrame->GetScrollTargetFrame();
nsIScrollableFrame* scrollFrame = nullptr;
while (!scrollFrame && aFrame) {
aFrame = aFrame->GetParent();
scrollFrame = aFrame->GetScrollTargetFrame();
aFrame = aFrame->GetParent();
}
if (!scrollFrame)
return false;
nsIFrame* frame = scrollFrame->GetScrolledFrame();
nsStyleContext* bgSC;
if (nsCSSRendering::FindBackground(frame, &bgSC)) {
nscolor bgColor = bgSC->StyleBackground()->mBackgroundColor;
// Consider the background color dark if the sum of the r, g and b values is
// less than 384 in a semi-transparent docement. This heuristic matches what
// less than 384 in a semi-transparent document. This heuristic matches what
// WebKit does, and we can improve it later if needed.
return NS_GET_A(bgColor) > 127 &&
NS_GET_R(bgColor) + NS_GET_G(bgColor) + NS_GET_B(bgColor) < 384;