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

Side by Side Diff: Source/core/rendering/RenderScrollbar.cpp

Issue 603193005: Move the Widget hierarchy to the Oilpan heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Switch LocalFrame::m_pluginElements rep to HashSet<HTMLPlugInElement*> Created 6 years, 2 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
OLDNEW
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
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 { 48 {
49 ASSERT(ownerNode || owningFrame); 49 ASSERT(ownerNode || owningFrame);
50 50
51 // FIXME: We need to do this because RenderScrollbar::styleChanged is called as soon as the scrollbar is created. 51 // FIXME: We need to do this because RenderScrollbar::styleChanged is called as soon as the scrollbar is created.
52 52
53 // Update the scrollbar size. 53 // Update the scrollbar size.
54 int width = 0; 54 int width = 0;
55 int height = 0; 55 int height = 0;
56 updateScrollbarPart(ScrollbarBGPart); 56 updateScrollbarPart(ScrollbarBGPart);
57 if (RenderScrollbarPart* part = m_parts.get(ScrollbarBGPart)) { 57 if (RenderScrollbarPart* part = m_parts.get(ScrollbarBGPart)) {
58 part->layout(); 58 part->layout();
59 width = part->width(); 59 width = part->width();
60 height = part->height(); 60 height = part->height();
61 } else if (this->orientation() == HorizontalScrollbar) 61 } else if (this->orientation() == HorizontalScrollbar)
62 width = this->width(); 62 width = this->width();
63 else 63 else
64 height = this->height(); 64 height = this->height();
65 65
66 setFrameRect(IntRect(0, 0, width, height)); 66 setFrameRect(IntRect(0, 0, width, height));
67
68 #if ENABLE(OILPAN)
69 ThreadState::current()->registerPreFinalizer(*this);
70 #endif
67 } 71 }
68 72
69 RenderScrollbar::~RenderScrollbar() 73 RenderScrollbar::~RenderScrollbar()
70 { 74 {
71 if (!m_parts.isEmpty()) { 75 // 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 76 // also on the heap, a pre-destruction finalizer is used.
73 // ready to be destroyed, its destruction can be delayed because of RefP tr 77 #if !ENABLE(OILPAN)
74 // maintained in other classes such as EventHandler (m_lastScrollbarUnde rMouse). 78 destroyParts();
75 // Meanwhile, we can have a call to updateScrollbarPart which recreates the 79 #endif
76 // scrollbar part. So, we need to destroy these parts since we don't wan t them 80 }
77 // to call on a destroyed scrollbar. See webkit bug 68009. 81
78 updateScrollbarParts(true); 82 void RenderScrollbar::destroyParts()
79 } 83 {
84 if (m_parts.isEmpty())
85 return;
86
87 // When a scrollbar is detached from its parent (causing all parts removal) and
88 // ready to be destroyed, its destruction can be delayed because of RefPtr
89 // maintained in other classes such as EventHandler (m_lastScrollbarUnderMou se).
90 // Meanwhile, we can have a call to updateScrollbarPart which recreates the
91 // scrollbar part. So, we need to destroy these parts since we don't want th em
92 // to call on a destroyed scrollbar. See webkit bug 68009.
93 updateScrollbarParts(true);
94 }
95
96 void RenderScrollbar::trace(Visitor* visitor)
97 {
98 #if ENABLE(OILPAN)
99 visitor->trace(m_owner);
100 visitor->trace(m_owningFrame);
101 visitor->trace(m_parts);
102 #endif
103 Scrollbar::trace(visitor);
80 } 104 }
81 105
82 RenderBox* RenderScrollbar::owningRenderer() const 106 RenderBox* RenderScrollbar::owningRenderer() const
83 { 107 {
84 if (m_owningFrame) { 108 if (m_owningFrame) {
85 RenderBox* currentRenderer = m_owningFrame->ownerRenderer(); 109 RenderBox* currentRenderer = m_owningFrame->ownerRenderer();
86 return currentRenderer; 110 return currentRenderer;
87 } 111 }
88 return m_owner && m_owner->renderer() ? m_owner->renderer()->enclosingBox() : 0; 112 return m_owner && m_owner->renderer() ? m_owner->renderer()->enclosingBox() : 0;
89 } 113 }
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 int RenderScrollbar::minimumThumbLength() 358 int RenderScrollbar::minimumThumbLength()
335 { 359 {
336 RenderScrollbarPart* partRenderer = m_parts.get(ThumbPart); 360 RenderScrollbarPart* partRenderer = m_parts.get(ThumbPart);
337 if (!partRenderer) 361 if (!partRenderer)
338 return 0; 362 return 0;
339 partRenderer->layout(); 363 partRenderer->layout();
340 return orientation() == HorizontalScrollbar ? partRenderer->width() : partRe nderer->height(); 364 return orientation() == HorizontalScrollbar ? partRenderer->width() : partRe nderer->height();
341 } 365 }
342 366
343 } 367 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698