| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 LocalFrame* owningFrame) | 54 LocalFrame* owningFrame) |
| 55 : Scrollbar(scrollableArea, | 55 : Scrollbar(scrollableArea, |
| 56 orientation, | 56 orientation, |
| 57 RegularScrollbar, | 57 RegularScrollbar, |
| 58 nullptr, | 58 nullptr, |
| 59 LayoutScrollbarTheme::layoutScrollbarTheme()), | 59 LayoutScrollbarTheme::layoutScrollbarTheme()), |
| 60 m_owner(ownerNode), | 60 m_owner(ownerNode), |
| 61 m_owningFrame(owningFrame) { | 61 m_owningFrame(owningFrame) { |
| 62 ASSERT(ownerNode || owningFrame); | 62 ASSERT(ownerNode || owningFrame); |
| 63 | 63 |
| 64 // FIXME: We need to do this because LayoutScrollbar::styleChanged is called a
s soon as the scrollbar is created. | 64 // FIXME: We need to do this because LayoutScrollbar::styleChanged is called |
| 65 // as soon as the scrollbar is created. |
| 65 | 66 |
| 66 // Update the scrollbar size. | 67 // Update the scrollbar size. |
| 67 IntRect rect(0, 0, 0, 0); | 68 IntRect rect(0, 0, 0, 0); |
| 68 updateScrollbarPart(ScrollbarBGPart); | 69 updateScrollbarPart(ScrollbarBGPart); |
| 69 if (LayoutScrollbarPart* part = m_parts.get(ScrollbarBGPart)) { | 70 if (LayoutScrollbarPart* part = m_parts.get(ScrollbarBGPart)) { |
| 70 part->layout(); | 71 part->layout(); |
| 71 rect.setSize(flooredIntSize(part->size())); | 72 rect.setSize(flooredIntSize(part->size())); |
| 72 } else if (this->orientation() == HorizontalScrollbar) { | 73 } else if (this->orientation() == HorizontalScrollbar) { |
| 73 rect.setWidth(this->width()); | 74 rect.setWidth(this->width()); |
| 74 } else { | 75 } else { |
| 75 rect.setHeight(this->height()); | 76 rect.setHeight(this->height()); |
| 76 } | 77 } |
| 77 | 78 |
| 78 setFrameRect(rect); | 79 setFrameRect(rect); |
| 79 } | 80 } |
| 80 | 81 |
| 81 LayoutScrollbar::~LayoutScrollbar() { | 82 LayoutScrollbar::~LayoutScrollbar() { |
| 82 if (m_parts.isEmpty()) | 83 if (m_parts.isEmpty()) |
| 83 return; | 84 return; |
| 84 | 85 |
| 85 // When a scrollbar is detached from its parent (causing all parts removal) an
d | 86 // When a scrollbar is detached from its parent (causing all parts removal) |
| 86 // ready to be destroyed, its destruction can be delayed because of RefPtr | 87 // and ready to be destroyed, its destruction can be delayed because of |
| 87 // maintained in other classes such as EventHandler (m_lastScrollbarUnderMouse
). | 88 // RefPtr maintained in other classes such as EventHandler |
| 89 // (m_lastScrollbarUnderMouse). |
| 88 // Meanwhile, we can have a call to updateScrollbarPart which recreates the | 90 // Meanwhile, we can have a call to updateScrollbarPart which recreates the |
| 89 // scrollbar part. So, we need to destroy these parts since we don't want them | 91 // scrollbar part. So, we need to destroy these parts since we don't want them |
| 90 // to call on a destroyed scrollbar. See webkit bug 68009. | 92 // to call on a destroyed scrollbar. See webkit bug 68009. |
| 91 updateScrollbarParts(true); | 93 updateScrollbarParts(true); |
| 92 } | 94 } |
| 93 | 95 |
| 94 DEFINE_TRACE(LayoutScrollbar) { | 96 DEFINE_TRACE(LayoutScrollbar) { |
| 95 visitor->trace(m_owner); | 97 visitor->trace(m_owner); |
| 96 visitor->trace(m_owningFrame); | 98 visitor->trace(m_owningFrame); |
| 97 Scrollbar::trace(visitor); | 99 Scrollbar::trace(visitor); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 ScrollbarPart partType, | 162 ScrollbarPart partType, |
| 161 PseudoId pseudoId) { | 163 PseudoId pseudoId) { |
| 162 if (!owningLayoutObject()) | 164 if (!owningLayoutObject()) |
| 163 return nullptr; | 165 return nullptr; |
| 164 | 166 |
| 165 RefPtr<ComputedStyle> result = owningLayoutObject()->getUncachedPseudoStyle( | 167 RefPtr<ComputedStyle> result = owningLayoutObject()->getUncachedPseudoStyle( |
| 166 PseudoStyleRequest(pseudoId, this, partType), | 168 PseudoStyleRequest(pseudoId, this, partType), |
| 167 owningLayoutObject()->style()); | 169 owningLayoutObject()->style()); |
| 168 // Scrollbars for root frames should always have background color | 170 // Scrollbars for root frames should always have background color |
| 169 // unless explicitly specified as transparent. So we force it. | 171 // unless explicitly specified as transparent. So we force it. |
| 170 // This is because WebKit assumes scrollbar to be always painted and missing b
ackground | 172 // This is because WebKit assumes scrollbar to be always painted and missing |
| 171 // causes visual artifact like non-paint invalidated dirty region. | 173 // background causes visual artifact like non-paint invalidated dirty region. |
| 172 if (result && m_owningFrame && m_owningFrame->view() && | 174 if (result && m_owningFrame && m_owningFrame->view() && |
| 173 !m_owningFrame->view()->isTransparent() && !result->hasBackground()) | 175 !m_owningFrame->view()->isTransparent() && !result->hasBackground()) |
| 174 result->setBackgroundColor(StyleColor(Color::white)); | 176 result->setBackgroundColor(StyleColor(Color::white)); |
| 175 | 177 |
| 176 return result; | 178 return result; |
| 177 } | 179 } |
| 178 | 180 |
| 179 void LayoutScrollbar::updateScrollbarParts(bool destroy) { | 181 void LayoutScrollbar::updateScrollbarParts(bool destroy) { |
| 180 updateScrollbarPart(ScrollbarBGPart, destroy); | 182 updateScrollbarPart(ScrollbarBGPart, destroy); |
| 181 updateScrollbarPart(BackButtonStartPart, destroy); | 183 updateScrollbarPart(BackButtonStartPart, destroy); |
| 182 updateScrollbarPart(ForwardButtonStartPart, destroy); | 184 updateScrollbarPart(ForwardButtonStartPart, destroy); |
| 183 updateScrollbarPart(BackTrackPart, destroy); | 185 updateScrollbarPart(BackTrackPart, destroy); |
| 184 updateScrollbarPart(ThumbPart, destroy); | 186 updateScrollbarPart(ThumbPart, destroy); |
| 185 updateScrollbarPart(ForwardTrackPart, destroy); | 187 updateScrollbarPart(ForwardTrackPart, destroy); |
| 186 updateScrollbarPart(BackButtonEndPart, destroy); | 188 updateScrollbarPart(BackButtonEndPart, destroy); |
| 187 updateScrollbarPart(ForwardButtonEndPart, destroy); | 189 updateScrollbarPart(ForwardButtonEndPart, destroy); |
| 188 updateScrollbarPart(TrackBGPart, destroy); | 190 updateScrollbarPart(TrackBGPart, destroy); |
| 189 | 191 |
| 190 if (destroy) | 192 if (destroy) |
| 191 return; | 193 return; |
| 192 | 194 |
| 193 // See if the scrollbar's thickness changed. If so, we need to mark our ownin
g object as needing a layout. | 195 // See if the scrollbar's thickness changed. If so, we need to mark our |
| 196 // owning object as needing a layout. |
| 194 bool isHorizontal = orientation() == HorizontalScrollbar; | 197 bool isHorizontal = orientation() == HorizontalScrollbar; |
| 195 int oldThickness = isHorizontal ? height() : width(); | 198 int oldThickness = isHorizontal ? height() : width(); |
| 196 int newThickness = 0; | 199 int newThickness = 0; |
| 197 LayoutScrollbarPart* part = m_parts.get(ScrollbarBGPart); | 200 LayoutScrollbarPart* part = m_parts.get(ScrollbarBGPart); |
| 198 if (part) { | 201 if (part) { |
| 199 part->layout(); | 202 part->layout(); |
| 200 newThickness = | 203 newThickness = |
| 201 (isHorizontal ? part->size().height() : part->size().width()).toInt(); | 204 (isHorizontal ? part->size().height() : part->size().width()).toInt(); |
| 202 } | 205 } |
| 203 | 206 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 | 249 |
| 247 RefPtr<ComputedStyle> partStyle = | 250 RefPtr<ComputedStyle> partStyle = |
| 248 !destroy | 251 !destroy |
| 249 ? getScrollbarPseudoStyle(partType, pseudoForScrollbarPart(partType)) | 252 ? getScrollbarPseudoStyle(partType, pseudoForScrollbarPart(partType)) |
| 250 : PassRefPtr<ComputedStyle>(nullptr); | 253 : PassRefPtr<ComputedStyle>(nullptr); |
| 251 | 254 |
| 252 bool needLayoutObject = | 255 bool needLayoutObject = |
| 253 !destroy && partStyle && partStyle->display() != EDisplay::None; | 256 !destroy && partStyle && partStyle->display() != EDisplay::None; |
| 254 | 257 |
| 255 if (needLayoutObject && partStyle->display() != EDisplay::Block) { | 258 if (needLayoutObject && partStyle->display() != EDisplay::Block) { |
| 256 // See if we are a button that should not be visible according to OS setting
s. | 259 // See if we are a button that should not be visible according to OS |
| 260 // settings. |
| 257 WebScrollbarButtonsPlacement buttonsPlacement = theme().buttonsPlacement(); | 261 WebScrollbarButtonsPlacement buttonsPlacement = theme().buttonsPlacement(); |
| 258 switch (partType) { | 262 switch (partType) { |
| 259 case BackButtonStartPart: | 263 case BackButtonStartPart: |
| 260 needLayoutObject = | 264 needLayoutObject = |
| 261 (buttonsPlacement == WebScrollbarButtonsPlacementSingle || | 265 (buttonsPlacement == WebScrollbarButtonsPlacementSingle || |
| 262 buttonsPlacement == WebScrollbarButtonsPlacementDoubleStart || | 266 buttonsPlacement == WebScrollbarButtonsPlacementDoubleStart || |
| 263 buttonsPlacement == WebScrollbarButtonsPlacementDoubleBoth); | 267 buttonsPlacement == WebScrollbarButtonsPlacementDoubleBoth); |
| 264 break; | 268 break; |
| 265 case ForwardButtonStartPart: | 269 case ForwardButtonStartPart: |
| 266 needLayoutObject = | 270 needLayoutObject = |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 } | 403 } |
| 400 | 404 |
| 401 void LayoutScrollbar::invalidateDisplayItemClientsOfScrollbarParts() { | 405 void LayoutScrollbar::invalidateDisplayItemClientsOfScrollbarParts() { |
| 402 for (auto& part : m_parts) | 406 for (auto& part : m_parts) |
| 403 ObjectPaintInvalidator(*part.value) | 407 ObjectPaintInvalidator(*part.value) |
| 404 .invalidateDisplayItemClientsIncludingNonCompositingDescendants( | 408 .invalidateDisplayItemClientsIncludingNonCompositingDescendants( |
| 405 PaintInvalidationScroll); | 409 PaintInvalidationScroll); |
| 406 } | 410 } |
| 407 | 411 |
| 408 } // namespace blink | 412 } // namespace blink |
| OLD | NEW |