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

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

Issue 20061003: Move isValid/isCurrentColor from Color to StyleColor (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 5 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 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 m_scrollCorner->destroy(); 366 m_scrollCorner->destroy();
367 m_scrollCorner = 0; 367 m_scrollCorner = 0;
368 } 368 }
369 } 369 }
370 370
371 void FrameView::recalculateScrollbarOverlayStyle() 371 void FrameView::recalculateScrollbarOverlayStyle()
372 { 372 {
373 ScrollbarOverlayStyle oldOverlayStyle = scrollbarOverlayStyle(); 373 ScrollbarOverlayStyle oldOverlayStyle = scrollbarOverlayStyle();
374 ScrollbarOverlayStyle overlayStyle = ScrollbarOverlayStyleDefault; 374 ScrollbarOverlayStyle overlayStyle = ScrollbarOverlayStyleDefault;
375 375
376 Color backgroundColor = documentBackgroundColor(); 376 StyleColor backgroundColor = documentBackgroundColor();
377 if (backgroundColor.isValid()) { 377 if (backgroundColor.isValid()) {
378 // Reduce the background color from RGB to a lightness value 378 // Reduce the background color from RGB to a lightness value
379 // and determine which scrollbar style to use based on a lightness 379 // and determine which scrollbar style to use based on a lightness
380 // heuristic. 380 // heuristic.
381 double hue, saturation, lightness; 381 double hue, saturation, lightness;
382 backgroundColor.getHSL(hue, saturation, lightness); 382 backgroundColor.color().getHSL(hue, saturation, lightness);
383 if (lightness <= .5) 383 if (lightness <= .5)
384 overlayStyle = ScrollbarOverlayStyleLight; 384 overlayStyle = ScrollbarOverlayStyleLight;
385 } 385 }
386 386
387 if (oldOverlayStyle != overlayStyle) 387 if (oldOverlayStyle != overlayStyle)
388 setScrollbarOverlayStyle(overlayStyle); 388 setScrollbarOverlayStyle(overlayStyle);
389 } 389 }
390 390
391 void FrameView::clear() 391 void FrameView::clear()
392 { 392 {
(...skipping 1634 matching lines...) Expand 10 before | Expand all | Expand 10 after
2027 bool FrameView::hasOpaqueBackground() const 2027 bool FrameView::hasOpaqueBackground() const
2028 { 2028 {
2029 return !m_isTransparent && !m_baseBackgroundColor.hasAlpha(); 2029 return !m_isTransparent && !m_baseBackgroundColor.hasAlpha();
2030 } 2030 }
2031 2031
2032 Color FrameView::baseBackgroundColor() const 2032 Color FrameView::baseBackgroundColor() const
2033 { 2033 {
2034 return m_baseBackgroundColor; 2034 return m_baseBackgroundColor;
2035 } 2035 }
2036 2036
2037 void FrameView::setBaseBackgroundColor(const Color& backgroundColor) 2037 void FrameView::setBaseBackgroundColor(const StyleColor& backgroundColor)
2038 { 2038 {
2039 if (!backgroundColor.isValid()) 2039 if (!backgroundColor.isValid())
2040 m_baseBackgroundColor = Color::white; 2040 m_baseBackgroundColor = Color::white;
2041 else 2041 else
2042 m_baseBackgroundColor = backgroundColor; 2042 m_baseBackgroundColor = backgroundColor.color();
2043 2043
2044 if (renderView() && renderView()->layer()->backing()) 2044 if (renderView() && renderView()->layer()->backing())
2045 renderView()->layer()->backing()->updateContentsOpaque(); 2045 renderView()->layer()->backing()->updateContentsOpaque();
2046 recalculateScrollbarOverlayStyle(); 2046 recalculateScrollbarOverlayStyle();
2047 } 2047 }
2048 2048
2049 void FrameView::updateBackgroundRecursively(const Color& backgroundColor, bool t ransparent) 2049 void FrameView::updateBackgroundRecursively(const StyleColor& backgroundColor, b ool transparent)
2050 { 2050 {
2051 for (Frame* frame = m_frame.get(); frame; frame = frame->tree()->traverseNex t(m_frame.get())) { 2051 for (Frame* frame = m_frame.get(); frame; frame = frame->tree()->traverseNex t(m_frame.get())) {
2052 if (FrameView* view = frame->view()) { 2052 if (FrameView* view = frame->view()) {
2053 view->setTransparent(transparent); 2053 view->setTransparent(transparent);
2054 view->setBaseBackgroundColor(backgroundColor); 2054 view->setBaseBackgroundColor(backgroundColor);
2055 } 2055 }
2056 } 2056 }
2057 } 2057 }
2058 2058
2059 bool FrameView::shouldUpdateWhileOffscreen() const 2059 bool FrameView::shouldUpdateWhileOffscreen() const
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after
2727 bool needsBackgorund = bar->isCustomScrollbar() && (m_frame->page() && m_fra me->page()->mainFrame() == m_frame); 2727 bool needsBackgorund = bar->isCustomScrollbar() && (m_frame->page() && m_fra me->page()->mainFrame() == m_frame);
2728 if (needsBackgorund) { 2728 if (needsBackgorund) {
2729 IntRect toFill = bar->frameRect(); 2729 IntRect toFill = bar->frameRect();
2730 toFill.intersect(rect); 2730 toFill.intersect(rect);
2731 context->fillRect(toFill, baseBackgroundColor()); 2731 context->fillRect(toFill, baseBackgroundColor());
2732 } 2732 }
2733 2733
2734 ScrollView::paintScrollbar(context, bar, rect); 2734 ScrollView::paintScrollbar(context, bar, rect);
2735 } 2735 }
2736 2736
2737 Color FrameView::documentBackgroundColor() const 2737 StyleColor FrameView::documentBackgroundColor() const
2738 { 2738 {
2739 // <https://bugs.webkit.org/show_bug.cgi?id=59540> We blend the background c olor of 2739 // <https://bugs.webkit.org/show_bug.cgi?id=59540> We blend the background c olor of
2740 // the document and the body against the base background color of the frame view. 2740 // the document and the body against the base background color of the frame view.
2741 // Background images are unfortunately impractical to include. 2741 // Background images are unfortunately impractical to include.
2742 2742
2743 // Return invalid Color objects whenever there is insufficient information. 2743 // Return invalid Color objects whenever there is insufficient information.
2744 if (!frame()->document()) 2744 if (!frame()->document())
2745 return Color(); 2745 return Color();
2746 2746
2747 Element* htmlElement = frame()->document()->documentElement(); 2747 Element* htmlElement = frame()->document()->documentElement();
2748 Element* bodyElement = frame()->document()->body(); 2748 Element* bodyElement = frame()->document()->body();
2749 2749
2750 // Start with invalid colors. 2750 // Start with invalid colors.
2751 Color htmlBackgroundColor; 2751 StyleColor htmlBackgroundColor;
2752 Color bodyBackgroundColor; 2752 StyleColor bodyBackgroundColor;
2753 if (htmlElement && htmlElement->renderer()) 2753 if (htmlElement && htmlElement->renderer())
2754 htmlBackgroundColor = htmlElement->renderer()->style()->visitedDependent Color(CSSPropertyBackgroundColor); 2754 htmlBackgroundColor = htmlElement->renderer()->resolveStyleColor(CSSProp ertyBackgroundColor);
2755 if (bodyElement && bodyElement->renderer()) 2755 if (bodyElement && bodyElement->renderer())
2756 bodyBackgroundColor = bodyElement->renderer()->style()->visitedDependent Color(CSSPropertyBackgroundColor); 2756 bodyBackgroundColor = bodyElement->renderer()->resolveStyleColor(CSSProp ertyBackgroundColor);
2757 2757
2758 if (!bodyBackgroundColor.isValid()) { 2758 if (!bodyBackgroundColor.isValid()) {
2759 if (!htmlBackgroundColor.isValid()) 2759 if (!htmlBackgroundColor.isValid())
2760 return Color(); 2760 return StyleColor();
2761 return baseBackgroundColor().blend(htmlBackgroundColor); 2761 return baseBackgroundColor().blend(htmlBackgroundColor.color());
2762 } 2762 }
2763 2763
2764 if (!htmlBackgroundColor.isValid()) 2764 if (!htmlBackgroundColor.isValid())
2765 return baseBackgroundColor().blend(bodyBackgroundColor); 2765 return baseBackgroundColor().blend(bodyBackgroundColor.color());
2766 2766
2767 // We take the aggregate of the base background color 2767 // We take the aggregate of the base background color
2768 // the <html> background color, and the <body> 2768 // the <html> background color, and the <body>
2769 // background color to find the document color. The 2769 // background color to find the document color. The
2770 // addition of the base background color is not 2770 // addition of the base background color is not
2771 // technically part of the document background, but it 2771 // technically part of the document background, but it
2772 // otherwise poses problems when the aggregate is not 2772 // otherwise poses problems when the aggregate is not
2773 // fully opaque. 2773 // fully opaque.
2774 return baseBackgroundColor().blend(htmlBackgroundColor).blend(bodyBackground Color); 2774 return baseBackgroundColor().blend(htmlBackgroundColor.color()).blend(bodyBa ckgroundColor.color());
2775 } 2775 }
2776 2776
2777 bool FrameView::hasCustomScrollbars() const 2777 bool FrameView::hasCustomScrollbars() const
2778 { 2778 {
2779 const HashSet<RefPtr<Widget> >* viewChildren = children(); 2779 const HashSet<RefPtr<Widget> >* viewChildren = children();
2780 HashSet<RefPtr<Widget> >::const_iterator end = viewChildren->end(); 2780 HashSet<RefPtr<Widget> >::const_iterator end = viewChildren->end();
2781 for (HashSet<RefPtr<Widget> >::const_iterator current = viewChildren->begin( ); current != end; ++current) { 2781 for (HashSet<RefPtr<Widget> >::const_iterator current = viewChildren->begin( ); current != end; ++current) {
2782 Widget* widget = current->get(); 2782 Widget* widget = current->get();
2783 if (widget->isFrameView()) { 2783 if (widget->isFrameView()) {
2784 if (toFrameView(widget)->hasCustomScrollbars()) 2784 if (toFrameView(widget)->hasCustomScrollbars())
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
3373 } 3373 }
3374 3374
3375 AXObjectCache* FrameView::axObjectCache() const 3375 AXObjectCache* FrameView::axObjectCache() const
3376 { 3376 {
3377 if (frame() && frame()->document()) 3377 if (frame() && frame()->document())
3378 return frame()->document()->existingAXObjectCache(); 3378 return frame()->document()->existingAXObjectCache();
3379 return 0; 3379 return 0;
3380 } 3380 }
3381 3381
3382 } // namespace WebCore 3382 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698