Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(770)

Side by Side Diff: Source/core/page/FrameView.cpp

Issue 23581008: Revert r154797: "Move isValid/isCurrentColor from Color to StyleColor" (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> 2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
3 * 1999 Lars Knoll <knoll@kde.org> 3 * 1999 Lars Knoll <knoll@kde.org>
4 * 1999 Antti Koivisto <koivisto@kde.org> 4 * 1999 Antti Koivisto <koivisto@kde.org>
5 * 2000 Dirk Mueller <mueller@kde.org> 5 * 2000 Dirk Mueller <mueller@kde.org>
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com) 7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com)
8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
9 * Copyright (C) 2009 Google Inc. All rights reserved. 9 * Copyright (C) 2009 Google Inc. All rights reserved.
10 * 10 *
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 m_scrollCorner->destroy(); 350 m_scrollCorner->destroy();
351 m_scrollCorner = 0; 351 m_scrollCorner = 0;
352 } 352 }
353 } 353 }
354 354
355 void FrameView::recalculateScrollbarOverlayStyle() 355 void FrameView::recalculateScrollbarOverlayStyle()
356 { 356 {
357 ScrollbarOverlayStyle oldOverlayStyle = scrollbarOverlayStyle(); 357 ScrollbarOverlayStyle oldOverlayStyle = scrollbarOverlayStyle();
358 ScrollbarOverlayStyle overlayStyle = ScrollbarOverlayStyleDefault; 358 ScrollbarOverlayStyle overlayStyle = ScrollbarOverlayStyleDefault;
359 359
360 StyleColor backgroundColor = documentBackgroundColor(); 360 Color backgroundColor = documentBackgroundColor();
361 if (backgroundColor.isValid()) { 361 if (backgroundColor.isValid()) {
362 // Reduce the background color from RGB to a lightness value 362 // Reduce the background color from RGB to a lightness value
363 // and determine which scrollbar style to use based on a lightness 363 // and determine which scrollbar style to use based on a lightness
364 // heuristic. 364 // heuristic.
365 double hue, saturation, lightness; 365 double hue, saturation, lightness;
366 backgroundColor.color().getHSL(hue, saturation, lightness); 366 backgroundColor.getHSL(hue, saturation, lightness);
367 if (lightness <= .5) 367 if (lightness <= .5)
368 overlayStyle = ScrollbarOverlayStyleLight; 368 overlayStyle = ScrollbarOverlayStyleLight;
369 } 369 }
370 370
371 if (oldOverlayStyle != overlayStyle) 371 if (oldOverlayStyle != overlayStyle)
372 setScrollbarOverlayStyle(overlayStyle); 372 setScrollbarOverlayStyle(overlayStyle);
373 } 373 }
374 374
375 void FrameView::clear() 375 void FrameView::clear()
376 { 376 {
(...skipping 1612 matching lines...) Expand 10 before | Expand all | Expand 10 after
1989 bool FrameView::hasOpaqueBackground() const 1989 bool FrameView::hasOpaqueBackground() const
1990 { 1990 {
1991 return !m_isTransparent && !m_baseBackgroundColor.hasAlpha(); 1991 return !m_isTransparent && !m_baseBackgroundColor.hasAlpha();
1992 } 1992 }
1993 1993
1994 Color FrameView::baseBackgroundColor() const 1994 Color FrameView::baseBackgroundColor() const
1995 { 1995 {
1996 return m_baseBackgroundColor; 1996 return m_baseBackgroundColor;
1997 } 1997 }
1998 1998
1999 void FrameView::setBaseBackgroundColor(const StyleColor& backgroundColor) 1999 void FrameView::setBaseBackgroundColor(const Color& backgroundColor)
2000 { 2000 {
2001 if (!backgroundColor.isValid()) 2001 if (!backgroundColor.isValid())
2002 m_baseBackgroundColor = Color::white; 2002 m_baseBackgroundColor = Color::white;
2003 else 2003 else
2004 m_baseBackgroundColor = backgroundColor.color(); 2004 m_baseBackgroundColor = backgroundColor;
2005 2005
2006 if (RenderLayerBacking* backing = renderView() ? renderView()->layer()->back ing() : 0) { 2006 if (RenderLayerBacking* backing = renderView() ? renderView()->layer()->back ing() : 0) {
2007 backing->updateContentsOpaque(); 2007 backing->updateContentsOpaque();
2008 if (backing->graphicsLayer()) 2008 if (backing->graphicsLayer())
2009 backing->graphicsLayer()->setNeedsDisplay(); 2009 backing->graphicsLayer()->setNeedsDisplay();
2010 } 2010 }
2011 recalculateScrollbarOverlayStyle(); 2011 recalculateScrollbarOverlayStyle();
2012 } 2012 }
2013 2013
2014 void FrameView::updateBackgroundRecursively(const StyleColor& backgroundColor, b ool transparent) 2014 void FrameView::updateBackgroundRecursively(const Color& backgroundColor, bool t ransparent)
2015 { 2015 {
2016 for (Frame* frame = m_frame.get(); frame; frame = frame->tree()->traverseNex t(m_frame.get())) { 2016 for (Frame* frame = m_frame.get(); frame; frame = frame->tree()->traverseNex t(m_frame.get())) {
2017 if (FrameView* view = frame->view()) { 2017 if (FrameView* view = frame->view()) {
2018 view->setTransparent(transparent); 2018 view->setTransparent(transparent);
2019 view->setBaseBackgroundColor(backgroundColor); 2019 view->setBaseBackgroundColor(backgroundColor);
2020 } 2020 }
2021 } 2021 }
2022 } 2022 }
2023 2023
2024 bool FrameView::shouldUpdateWhileOffscreen() const 2024 bool FrameView::shouldUpdateWhileOffscreen() const
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
2693 bool needsBackgorund = bar->isCustomScrollbar() && (m_frame->page() && m_fra me->page()->mainFrame() == m_frame); 2693 bool needsBackgorund = bar->isCustomScrollbar() && (m_frame->page() && m_fra me->page()->mainFrame() == m_frame);
2694 if (needsBackgorund) { 2694 if (needsBackgorund) {
2695 IntRect toFill = bar->frameRect(); 2695 IntRect toFill = bar->frameRect();
2696 toFill.intersect(rect); 2696 toFill.intersect(rect);
2697 context->fillRect(toFill, baseBackgroundColor()); 2697 context->fillRect(toFill, baseBackgroundColor());
2698 } 2698 }
2699 2699
2700 ScrollView::paintScrollbar(context, bar, rect); 2700 ScrollView::paintScrollbar(context, bar, rect);
2701 } 2701 }
2702 2702
2703 StyleColor FrameView::documentBackgroundColor() const 2703 Color FrameView::documentBackgroundColor() const
2704 { 2704 {
2705 // <https://bugs.webkit.org/show_bug.cgi?id=59540> We blend the background c olor of 2705 // <https://bugs.webkit.org/show_bug.cgi?id=59540> We blend the background c olor of
2706 // the document and the body against the base background color of the frame view. 2706 // the document and the body against the base background color of the frame view.
2707 // Background images are unfortunately impractical to include. 2707 // Background images are unfortunately impractical to include.
2708 2708
2709 // Return invalid Color objects whenever there is insufficient information. 2709 // Return invalid Color objects whenever there is insufficient information.
2710 if (!frame().document()) 2710 if (!frame().document())
2711 return Color(); 2711 return Color();
2712 2712
2713 Element* htmlElement = frame().document()->documentElement(); 2713 Element* htmlElement = frame().document()->documentElement();
2714 Element* bodyElement = frame().document()->body(); 2714 Element* bodyElement = frame().document()->body();
2715 2715
2716 // Start with invalid colors. 2716 // Start with invalid colors.
2717 StyleColor htmlBackgroundColor; 2717 Color htmlBackgroundColor;
2718 StyleColor bodyBackgroundColor; 2718 Color bodyBackgroundColor;
2719 if (htmlElement && htmlElement->renderer()) 2719 if (htmlElement && htmlElement->renderer())
2720 htmlBackgroundColor = htmlElement->renderer()->resolveStyleColor(CSSProp ertyBackgroundColor); 2720 htmlBackgroundColor = htmlElement->renderer()->style()->visitedDependent Color(CSSPropertyBackgroundColor);
2721 if (bodyElement && bodyElement->renderer()) 2721 if (bodyElement && bodyElement->renderer())
2722 bodyBackgroundColor = bodyElement->renderer()->resolveStyleColor(CSSProp ertyBackgroundColor); 2722 bodyBackgroundColor = bodyElement->renderer()->style()->visitedDependent Color(CSSPropertyBackgroundColor);
2723 2723
2724 if (!bodyBackgroundColor.isValid()) { 2724 if (!bodyBackgroundColor.isValid()) {
2725 if (!htmlBackgroundColor.isValid()) 2725 if (!htmlBackgroundColor.isValid())
2726 return StyleColor(); 2726 return Color();
2727 return baseBackgroundColor().blend(htmlBackgroundColor.color()); 2727 return baseBackgroundColor().blend(htmlBackgroundColor);
2728 } 2728 }
2729 2729
2730 if (!htmlBackgroundColor.isValid()) 2730 if (!htmlBackgroundColor.isValid())
2731 return baseBackgroundColor().blend(bodyBackgroundColor.color()); 2731 return baseBackgroundColor().blend(bodyBackgroundColor);
2732 2732
2733 // We take the aggregate of the base background color 2733 // We take the aggregate of the base background color
2734 // the <html> background color, and the <body> 2734 // the <html> background color, and the <body>
2735 // background color to find the document color. The 2735 // background color to find the document color. The
2736 // addition of the base background color is not 2736 // addition of the base background color is not
2737 // technically part of the document background, but it 2737 // technically part of the document background, but it
2738 // otherwise poses problems when the aggregate is not 2738 // otherwise poses problems when the aggregate is not
2739 // fully opaque. 2739 // fully opaque.
2740 return baseBackgroundColor().blend(htmlBackgroundColor.color()).blend(bodyBa ckgroundColor.color()); 2740 return baseBackgroundColor().blend(htmlBackgroundColor).blend(bodyBackground Color);
2741 } 2741 }
2742 2742
2743 bool FrameView::hasCustomScrollbars() const 2743 bool FrameView::hasCustomScrollbars() const
2744 { 2744 {
2745 const HashSet<RefPtr<Widget> >* viewChildren = children(); 2745 const HashSet<RefPtr<Widget> >* viewChildren = children();
2746 HashSet<RefPtr<Widget> >::const_iterator end = viewChildren->end(); 2746 HashSet<RefPtr<Widget> >::const_iterator end = viewChildren->end();
2747 for (HashSet<RefPtr<Widget> >::const_iterator current = viewChildren->begin( ); current != end; ++current) { 2747 for (HashSet<RefPtr<Widget> >::const_iterator current = viewChildren->begin( ); current != end; ++current) {
2748 Widget* widget = current->get(); 2748 Widget* widget = current->get();
2749 if (widget->isFrameView()) { 2749 if (widget->isFrameView()) {
2750 if (toFrameView(widget)->hasCustomScrollbars()) 2750 if (toFrameView(widget)->hasCustomScrollbars())
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
3338 } 3338 }
3339 3339
3340 AXObjectCache* FrameView::axObjectCache() const 3340 AXObjectCache* FrameView::axObjectCache() const
3341 { 3341 {
3342 if (frame().document()) 3342 if (frame().document())
3343 return frame().document()->existingAXObjectCache(); 3343 return frame().document()->existingAXObjectCache();
3344 return 0; 3344 return 0;
3345 } 3345 }
3346 3346
3347 } // namespace WebCore 3347 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698