Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008, 2009 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008, 2009 Apple Inc. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 #include "core/css/PseudoStyleRequest.h" | 29 #include "core/css/PseudoStyleRequest.h" |
| 30 #include "core/frame/FrameView.h" | 30 #include "core/frame/FrameView.h" |
| 31 #include "core/frame/LocalFrame.h" | 31 #include "core/frame/LocalFrame.h" |
| 32 #include "core/rendering/RenderPart.h" | 32 #include "core/rendering/RenderPart.h" |
| 33 #include "core/rendering/RenderScrollbarPart.h" | 33 #include "core/rendering/RenderScrollbarPart.h" |
| 34 #include "core/rendering/RenderScrollbarTheme.h" | 34 #include "core/rendering/RenderScrollbarTheme.h" |
| 35 #include "platform/graphics/GraphicsContext.h" | 35 #include "platform/graphics/GraphicsContext.h" |
| 36 | 36 |
| 37 namespace blink { | 37 namespace blink { |
| 38 | 38 |
| 39 PassRefPtr<Scrollbar> RenderScrollbar::createCustomScrollbar(ScrollableArea* scr ollableArea, ScrollbarOrientation orientation, Node* ownerNode, LocalFrame* owni ngFrame) | 39 PassRefPtrWillBeRawPtr<Scrollbar> RenderScrollbar::createCustomScrollbar(Scrolla bleArea* scrollableArea, ScrollbarOrientation orientation, Node* ownerNode, Loca lFrame* owningFrame) |
| 40 { | 40 { |
| 41 return adoptRef(new RenderScrollbar(scrollableArea, orientation, ownerNode, owningFrame)); | 41 return adoptRefWillBeNoop(new RenderScrollbar(scrollableArea, orientation, o wnerNode, owningFrame)); |
| 42 } | 42 } |
| 43 | 43 |
| 44 RenderScrollbar::RenderScrollbar(ScrollableArea* scrollableArea, ScrollbarOrient ation orientation, Node* ownerNode, LocalFrame* owningFrame) | 44 RenderScrollbar::RenderScrollbar(ScrollableArea* scrollableArea, ScrollbarOrient ation orientation, Node* ownerNode, LocalFrame* owningFrame) |
| 45 : Scrollbar(scrollableArea, orientation, RegularScrollbar, RenderScrollbarTh eme::renderScrollbarTheme()) | 45 : Scrollbar(scrollableArea, orientation, RegularScrollbar, RenderScrollbarTh eme::renderScrollbarTheme()) |
| 46 , m_owner(ownerNode) | 46 , m_owner(ownerNode) |
| 47 , m_owningFrame(owningFrame) | 47 , m_owningFrame(owningFrame) |
| 48 #if ENABLE(OILPAN) | |
| 49 , m_updatePartsMap(true) | |
| 50 #endif | |
| 48 { | 51 { |
| 49 ASSERT(ownerNode || owningFrame); | 52 ASSERT(ownerNode || owningFrame); |
| 50 | 53 |
| 51 // FIXME: We need to do this because RenderScrollbar::styleChanged is called as soon as the scrollbar is created. | 54 // FIXME: We need to do this because RenderScrollbar::styleChanged is called as soon as the scrollbar is created. |
| 52 | 55 |
| 53 // Update the scrollbar size. | 56 // Update the scrollbar size. |
| 54 int width = 0; | 57 int width = 0; |
| 55 int height = 0; | 58 int height = 0; |
| 56 updateScrollbarPart(ScrollbarBGPart); | 59 updateScrollbarPart(ScrollbarBGPart); |
| 57 if (RenderScrollbarPart* part = m_parts.get(ScrollbarBGPart)) { | 60 if (RenderScrollbarPart* part = m_parts.get(ScrollbarBGPart)) { |
| 58 part->layout(); | 61 part->layout(); |
| 59 width = part->width(); | 62 width = part->width(); |
| 60 height = part->height(); | 63 height = part->height(); |
| 61 } else if (this->orientation() == HorizontalScrollbar) | 64 } else if (this->orientation() == HorizontalScrollbar) |
| 62 width = this->width(); | 65 width = this->width(); |
| 63 else | 66 else |
| 64 height = this->height(); | 67 height = this->height(); |
| 65 | 68 |
| 66 setFrameRect(IntRect(0, 0, width, height)); | 69 setFrameRect(IntRect(0, 0, width, height)); |
| 70 | |
| 71 #if ENABLE(OILPAN) | |
| 72 ThreadState::current()->registerPreFinalizer(*this); | |
| 73 #endif | |
| 67 } | 74 } |
| 68 | 75 |
| 69 RenderScrollbar::~RenderScrollbar() | 76 RenderScrollbar::~RenderScrollbar() |
| 70 { | 77 { |
| 71 if (!m_parts.isEmpty()) { | 78 // Oilpan: to be able to access the hash map that's |
| 72 // When a scrollbar is detached from its parent (causing all parts remov al) and | 79 // also on the heap, a pre-destruction finalizer is used. |
| 73 // ready to be destroyed, its destruction can be delayed because of RefP tr | 80 #if !ENABLE(OILPAN) |
| 74 // maintained in other classes such as EventHandler (m_lastScrollbarUnde rMouse). | 81 destroyParts(); |
| 75 // Meanwhile, we can have a call to updateScrollbarPart which recreates the | 82 #endif |
| 76 // scrollbar part. So, we need to destroy these parts since we don't wan t them | 83 } |
| 77 // to call on a destroyed scrollbar. See webkit bug 68009. | 84 |
| 78 updateScrollbarParts(true); | 85 void RenderScrollbar::destroyParts() |
| 79 } | 86 { |
| 87 if (m_parts.isEmpty()) | |
| 88 return; | |
| 89 | |
| 90 #if ENABLE(OILPAN) | |
| 91 m_updatePartsMap = false; | |
| 92 #endif | |
| 93 | |
| 94 // When a scrollbar is detached from its parent (causing all parts removal) and | |
| 95 // ready to be destroyed, its destruction can be delayed because of RefPtr | |
| 96 // maintained in other classes such as EventHandler (m_lastScrollbarUnderMou se). | |
| 97 // Meanwhile, we can have a call to updateScrollbarPart which recreates the | |
| 98 // scrollbar part. So, we need to destroy these parts since we don't want th em | |
| 99 // to call on a destroyed scrollbar. See webkit bug 68009. | |
| 100 // | |
| 101 updateScrollbarParts(true); | |
| 102 } | |
| 103 | |
| 104 void RenderScrollbar::trace(Visitor* visitor) | |
| 105 { | |
| 106 #if ENABLE(OILPAN) | |
| 107 visitor->trace(m_owner); | |
| 108 visitor->trace(m_owningFrame); | |
| 109 visitor->trace(m_parts); | |
| 110 #endif | |
| 111 Scrollbar::trace(visitor); | |
| 80 } | 112 } |
| 81 | 113 |
| 82 RenderBox* RenderScrollbar::owningRenderer() const | 114 RenderBox* RenderScrollbar::owningRenderer() const |
| 83 { | 115 { |
| 84 if (m_owningFrame) { | 116 if (m_owningFrame) { |
| 85 RenderBox* currentRenderer = m_owningFrame->ownerRenderer(); | 117 RenderBox* currentRenderer = m_owningFrame->ownerRenderer(); |
| 86 return currentRenderer; | 118 return currentRenderer; |
| 87 } | 119 } |
| 88 return m_owner && m_owner->renderer() ? m_owner->renderer()->enclosingBox() : 0; | 120 return m_owner && m_owner->renderer() ? m_owner->renderer()->enclosingBox() : 0; |
| 89 } | 121 } |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 235 break; | 267 break; |
| 236 case ForwardButtonEndPart: | 268 case ForwardButtonEndPart: |
| 237 needRenderer = (buttonsPlacement == ScrollbarButtonsSingle || bu ttonsPlacement == ScrollbarButtonsDoubleEnd || | 269 needRenderer = (buttonsPlacement == ScrollbarButtonsSingle || bu ttonsPlacement == ScrollbarButtonsDoubleEnd || |
| 238 buttonsPlacement == ScrollbarButtonsDoubleBoth); | 270 buttonsPlacement == ScrollbarButtonsDoubleBoth); |
| 239 break; | 271 break; |
| 240 default: | 272 default: |
| 241 break; | 273 break; |
| 242 } | 274 } |
| 243 } | 275 } |
| 244 | 276 |
| 277 #if ENABLE(OILPAN) | |
| 278 const bool updatePartsMap = m_updatePartsMap; | |
| 279 #else | |
| 280 const bool updatePartsMap = true; | |
| 281 #endif | |
| 245 RenderScrollbarPart* partRenderer = m_parts.get(partType); | 282 RenderScrollbarPart* partRenderer = m_parts.get(partType); |
| 246 if (!partRenderer && needRenderer) { | 283 if (!partRenderer && needRenderer) { |
| 247 partRenderer = RenderScrollbarPart::createAnonymous(&owningRenderer()->d ocument(), this, partType); | 284 partRenderer = RenderScrollbarPart::createAnonymous(&owningRenderer()->d ocument(), this, partType); |
| 248 m_parts.set(partType, partRenderer); | 285 if (updatePartsMap) |
|
haraken
2014/10/10 02:50:32
Why do you need this condition? Given that m_parts
sof
2014/10/10 05:22:19
ok, I simply prefer not to rely on there being no
sof
2014/10/10 08:40:55
To drive things forward, dropped the flag & rely o
| |
| 286 m_parts.set(partType, partRenderer); | |
| 249 } else if (partRenderer && !needRenderer) { | 287 } else if (partRenderer && !needRenderer) { |
| 250 m_parts.remove(partType); | 288 if (updatePartsMap) |
| 289 m_parts.remove(partType); | |
| 251 partRenderer->destroy(); | 290 partRenderer->destroy(); |
| 252 partRenderer = 0; | 291 partRenderer = 0; |
| 253 } | 292 } |
| 254 | 293 |
| 255 if (partRenderer) | 294 if (partRenderer) |
| 256 partRenderer->setStyle(partStyle.release()); | 295 partRenderer->setStyle(partStyle.release()); |
| 257 } | 296 } |
| 258 | 297 |
| 259 IntRect RenderScrollbar::buttonRect(ScrollbarPart partType) | 298 IntRect RenderScrollbar::buttonRect(ScrollbarPart partType) |
| 260 { | 299 { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 334 int RenderScrollbar::minimumThumbLength() | 373 int RenderScrollbar::minimumThumbLength() |
| 335 { | 374 { |
| 336 RenderScrollbarPart* partRenderer = m_parts.get(ThumbPart); | 375 RenderScrollbarPart* partRenderer = m_parts.get(ThumbPart); |
| 337 if (!partRenderer) | 376 if (!partRenderer) |
| 338 return 0; | 377 return 0; |
| 339 partRenderer->layout(); | 378 partRenderer->layout(); |
| 340 return orientation() == HorizontalScrollbar ? partRenderer->width() : partRe nderer->height(); | 379 return orientation() == HorizontalScrollbar ? partRenderer->width() : partRe nderer->height(); |
| 341 } | 380 } |
| 342 | 381 |
| 343 } | 382 } |
| OLD | NEW |