Changeset 84769 in webkit
- Timestamp:
- Apr 25, 2011 1:26:32 AM (13 years ago)
- Location:
- trunk/Source
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r84768 r84769 1 2011-04-25 Jon Lee <jonlee@apple.com> 2 3 Reviewed by Maciej Stachowiak. 4 5 Overlay scroller hard to see on pages with dark background (59183) 6 https://bugs.webkit.org/show_bug.cgi?id=59183 7 <rdar://problem/8975367> 8 9 Switch the scrollbar's overlay style depending on its frame's background color. 10 This refactors the getDocumentBackgroundColor method needed for gestures. The style 11 is determined and set on every paint() call to the Mac scrollbar theme. 12 13 * WebCore.exp.in: adding method to allow changing style 14 * page/Frame.cpp: 15 (WebCore::Frame::getDocumentBackgroundColor): moving code from WebFrame for reuse by FrameView 16 * page/Frame.h: 17 * page/FrameView.cpp: 18 (WebCore::FrameView::recommendedScrollbarOverlayStyle): overridden to suggest a style based on CSS background color 19 * page/FrameView.h: 20 * platform/ScrollTypes.h: new enum to represent different overlay scrollbar styles 21 * platform/ScrollableArea.h: 22 (WebCore::ScrollableArea::recommendedScrollbarOverlayStyle): new virtual function to return a suggested overlay style 23 * platform/mac/ScrollbarThemeMac.mm: 24 (WebCore::ScrollbarThemeMac::paint): 25 * platform/mac/WebCoreSystemInterface.h: 26 * platform/mac/WebCoreSystemInterface.mm: 27 1 28 2011-04-25 Dan Bernstein <mitz@apple.com> 2 29 -
trunk/Source/WebCore/WebCore.exp.in
r84751 r84769 1012 1012 __ZNK3JSC8Bindings10RootObject12globalObjectEv 1013 1013 __ZNK3WTF6String14createCFStringEv 1014 __ZNK7WebCore5Frame26getDocumentBackgroundColorEv 1014 1015 __ZNK7WebCore10Credential11persistenceEv 1015 1016 __ZNK7WebCore10Credential4userEv … … 1438 1439 _wkScrollbarPainterTrackAlpha 1439 1440 _wkScrollbarPainterUsesOverlayScrollers 1441 _wkSetScrollbarPainterKnobStyle 1440 1442 _wkScrollbarThickness 1441 1443 _wkSetPainterForPainterController -
trunk/Source/WebCore/page/Frame.cpp
r84442 r84769 501 501 return matchLabelsAgainstString(labels, element->getAttribute(idAttr)); 502 502 } 503 504 Color Frame::getDocumentBackgroundColor() const 505 { 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. 513 if (!m_doc) 514 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); 527 } 503 528 504 529 void Frame::setPrinting(bool printing, const FloatSize& pageSize, float maximumShrinkRatio, AdjustViewSizeOrNot shouldAdjustViewSize) -
trunk/Source/WebCore/page/Frame.h
r83081 r84769 191 191 String matchLabelsAgainstElement(const Vector<String>& labels, Element*); 192 192 193 Color getDocumentBackgroundColor() const; 194 193 195 #if PLATFORM(MAC) 194 196 NSString* searchForLabelsBeforeElement(NSArray* labels, Element*, size_t* resultDistance, bool* resultIsInCellAbove); -
trunk/Source/WebCore/page/FrameView.cpp
r84751 r84769 307 307 } 308 308 309 ScrollbarOverlayStyle FrameView::recommendedScrollbarOverlayStyle() const 310 { 311 Color bgColor = m_frame->getDocumentBackgroundColor(); 312 if (!bgColor.isValid()) 313 return ScrollbarOverlayStyleDefault; 314 315 // Reduce the background color from RGB to a lightness value 316 // and determine which scrollbar style to use based on a lightness 317 // heuristic. 318 double hue, saturation, lightness; 319 bgColor.getHSL(hue, saturation, lightness); 320 if (lightness > .5) 321 return ScrollbarOverlayStyleDefault; 322 323 return ScrollbarOverlayStyleLight; 324 } 325 309 326 void FrameView::clear() 310 327 { -
trunk/Source/WebCore/page/FrameView.h
r84751 r84769 134 134 void resetScrollbarsAndClearContentsSize(); 135 135 void detachCustomScrollbars(); 136 virtual ScrollbarOverlayStyle recommendedScrollbarOverlayStyle() const; 136 137 137 138 void clear(); -
trunk/Source/WebCore/platform/ScrollTypes.h
r84751 r84769 151 151 }; 152 152 153 enum ScrollbarOverlayStyle { 154 ScrollbarOverlayStyleDefault, 155 ScrollbarOverlayStyleDark, 156 ScrollbarOverlayStyleLight 157 }; 158 153 159 typedef unsigned ScrollbarControlPartMask; 154 160 -
trunk/Source/WebCore/platform/ScrollableArea.h
r84752 r84769 78 78 79 79 bool hasOverlayScrollbars() const; 80 virtual ScrollbarOverlayStyle recommendedScrollbarOverlayStyle() const { return ScrollbarOverlayStyleDefault; } 80 81 81 82 ScrollAnimator* scrollAnimator() const { return m_scrollAnimator.get(); } -
trunk/Source/WebCore/platform/mac/ScrollbarThemeMac.mm
r84767 r84769 1 1 /* 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.2 * Copyright (C) 2008, 2011 Apple Inc. All Rights Reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 430 430 } 431 431 432 #if USE(WK_SCROLLBAR_PAINTER) 433 static inline wkScrollerKnobStyle toScrollbarPainterKnobStyle(ScrollbarOverlayStyle style) 434 { 435 switch (style) { 436 case ScrollbarOverlayStyleDark: 437 return wkScrollerKnobStyleDark; 438 case ScrollbarOverlayStyleLight: 439 return wkScrollerKnobStyleLight; 440 default: 441 return wkScrollerKnobStyleDefault; 442 } 443 } 444 #endif 445 432 446 bool ScrollbarThemeMac::paint(Scrollbar* scrollbar, GraphicsContext* context, const IntRect& damageRect) 433 447 { … … 452 466 value = 0; 453 467 } 454 468 455 469 ScrollAnimatorMac* scrollAnimator = static_cast<ScrollAnimatorMac*>(scrollbar->scrollableArea()->scrollAnimator()); 456 470 scrollAnimator->setIsDrawingIntoLayer(context->isCALayerContext()); 457 471 472 #if USE(WK_SCROLLBAR_PAINTER) 473 wkSetScrollbarPainterKnobStyle(painterForScrollbar(scrollbar), toScrollbarPainterKnobStyle(scrollbar->scrollableArea()->recommendedScrollbarOverlayStyle())); 474 #endif 475 458 476 GraphicsContextStateSaver stateSaver(*context); 459 477 context->clip(damageRect); -
trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.h
r84751 r84769 229 229 extern void (*wkScrollbarPainterSetOverlayState)(WKScrollbarPainterRef, int overlayScrollerState); 230 230 231 enum { 232 wkScrollerKnobStyleDefault = 0, 233 wkScrollerKnobStyleDark = 1, 234 wkScrollerKnobStyleLight = 2 235 }; 236 typedef uint32 wkScrollerKnobStyle; 237 extern void (*wkSetScrollbarPainterKnobStyle)(WKScrollbarPainterRef, wkScrollerKnobStyle); 238 231 239 extern WKScrollbarPainterControllerRef (*wkMakeScrollbarPainterController)(id painterControllerDelegate); 232 240 extern void (*wkSetPainterForPainterController)(WKScrollbarPainterControllerRef, WKScrollbarPainterRef, bool isHorizontal); -
trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.mm
r84751 r84769 151 151 CGRect (*wkScrollbarPainterKnobRect)(WKScrollbarPainterRef); 152 152 void (*wkScrollbarPainterSetOverlayState)(WKScrollbarPainterRef, int overlayScrollerState); 153 void (*wkSetScrollbarPainterKnobStyle)(WKScrollbarPainterRef, wkScrollerKnobStyle); 153 154 154 155 WKScrollbarPainterControllerRef (*wkMakeScrollbarPainterController)(id painterControllerDelegate); -
trunk/Source/WebKit/mac/ChangeLog
r84751 r84769 1 2011-04-25 Jon Lee <jonlee@apple.com> 2 3 Reviewed by Maciej Stachowiak. 4 5 Overlay scroller hard to see on pages with dark background (59183) 6 https://bugs.webkit.org/show_bug.cgi?id=59183 7 <rdar://problem/8975367> 8 9 * WebCoreSupport/WebSystemInterface.mm: 10 (InitWebCoreSystemInterface): adding method to allow changing style 11 1 12 2011-04-23 Sheriff Bot <webkit.review.bot@gmail.com> 2 13 -
trunk/Source/WebKit/mac/WebCoreSupport/WebSystemInterface.mm
r84751 r84769 147 147 INIT(ScrollbarPainterKnobRect); 148 148 INIT(ScrollbarPainterSetOverlayState); 149 INIT(SetScrollbarPainterKnobStyle); 149 150 INIT(MakeScrollbarPainterController); 150 151 INIT(MakeScrollbarReplacementPainter); -
trunk/Source/WebKit2/ChangeLog
r84757 r84769 1 2011-04-25 Jon Lee <jonlee@apple.com> 2 3 Reviewed by Maciej Stachowiak. 4 5 Overlay scroller hard to see on pages with dark background (59183) 6 https://bugs.webkit.org/show_bug.cgi?id=59183 7 <rdar://problem/8975367> 8 9 * WebProcess/WebCoreSupport/mac/WebSystemInterface.mm: 10 (InitWebCoreSystemInterface): adding method to allow changing style 11 * WebProcess/WebPage/WebFrame.cpp: 12 (WebKit::WebFrame::getDocumentBackgroundColor): refactoring to use common code for retrieving background color 13 1 14 2011-04-24 Dan Bernstein <mitz@apple.com> 2 15 -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm
r84751 r84769 125 125 INIT(ScrollbarPainterKnobRect); 126 126 INIT(ScrollbarPainterSetOverlayState); 127 INIT(SetScrollbarPainterKnobStyle); 127 128 INIT(MakeScrollbarPainterController); 128 129 INIT(MakeScrollbarReplacementPainter); -
trunk/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp
r84058 r84769 541 541 if (!m_coreFrame) 542 542 return false; 543 Document* document = m_coreFrame->document(); 544 if (!document) 545 return false; 546 547 Element* rootElementToUse = document->body(); 548 if (!rootElementToUse) 549 rootElementToUse = document->documentElement(); 550 if (!rootElementToUse) 551 return false; 552 553 RenderObject* renderer = rootElementToUse->renderer(); 554 if (!renderer) 555 return false; 556 Color color = renderer->style()->visitedDependentColor(CSSPropertyBackgroundColor); 557 if (!color.isValid()) 558 return false; 559 560 color.getRGBA(*red, *green, *blue, *alpha); 543 Color bgColor = m_coreFrame->getDocumentBackgroundColor(); 544 if (!bgColor.isValid()) 545 return false; 546 547 bgColor.getRGBA(*red, *green, *blue, *alpha); 561 548 return true; 562 549 }
Note: See TracChangeset
for help on using the changeset viewer.