| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * Copyright (C) 2000 Dirk Mueller (mueller@kde.org) | 3 * Copyright (C) 2000 Dirk Mueller (mueller@kde.org) |
| 4 * Copyright (C) 2004, 2006, 2009, 2010 Apple Inc. All rights reserved. | 4 * Copyright (C) 2004, 2006, 2009, 2010 Apple Inc. All rights reserved. |
| 5 * Copyright (C) 2013 Google Inc. All rights reserved. | 5 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 6 * | 6 * |
| 7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
| 11 * | 11 * |
| 12 * This library is distributed in the hope that it will be useful, | 12 * This library is distributed in the hope that it will be useful, |
| 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 * Library General Public License for more details. | 15 * Library General Public License for more details. |
| 16 * | 16 * |
| 17 * You should have received a copy of the GNU Library General Public License | 17 * You should have received a copy of the GNU Library General Public License |
| 18 * along with this library; see the file COPYING.LIB. If not, write to | 18 * along with this library; see the file COPYING.LIB. If not, write to |
| 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 20 * Boston, MA 02110-1301, USA. | 20 * Boston, MA 02110-1301, USA. |
| 21 * | 21 * |
| 22 */ | 22 */ |
| 23 | 23 |
| 24 #include "config.h" | 24 #include "config.h" |
| 25 #include "core/rendering/RenderWidget.h" | 25 #include "core/rendering/RenderWidget.h" |
| 26 | 26 |
| 27 #include "core/accessibility/AXObjectCache.h" | 27 #include "core/accessibility/AXObjectCache.h" |
| 28 #include "core/frame/LocalFrame.h" | 28 #include "core/frame/LocalFrame.h" |
| 29 #include "core/html/HTMLFrameOwnerElement.h" |
| 30 #include "core/html/HTMLPlugInElement.h" |
| 29 #include "core/rendering/GraphicsContextAnnotator.h" | 31 #include "core/rendering/GraphicsContextAnnotator.h" |
| 30 #include "core/rendering/HitTestResult.h" | 32 #include "core/rendering/HitTestResult.h" |
| 31 #include "core/rendering/LayoutRectRecorder.h" | 33 #include "core/rendering/LayoutRectRecorder.h" |
| 32 #include "core/rendering/RenderLayer.h" | 34 #include "core/rendering/RenderLayer.h" |
| 33 #include "core/rendering/RenderView.h" | 35 #include "core/rendering/RenderView.h" |
| 34 #include "core/rendering/compositing/CompositedLayerMapping.h" | 36 #include "core/rendering/compositing/CompositedLayerMapping.h" |
| 37 #include "core/rendering/compositing/RenderLayerCompositor.h" |
| 35 #include "wtf/HashMap.h" | 38 #include "wtf/HashMap.h" |
| 36 | 39 |
| 37 namespace WebCore { | 40 namespace WebCore { |
| 38 | 41 |
| 39 typedef HashMap<RefPtr<Widget>, FrameView*> WidgetToParentMap; | |
| 40 static WidgetToParentMap& widgetNewParentMap() | |
| 41 { | |
| 42 DEFINE_STATIC_LOCAL(WidgetToParentMap, map, ()); | |
| 43 return map; | |
| 44 } | |
| 45 | |
| 46 static unsigned s_updateSuspendCount = 0; | |
| 47 | |
| 48 RenderWidget::UpdateSuspendScope::UpdateSuspendScope() | |
| 49 { | |
| 50 ++s_updateSuspendCount; | |
| 51 } | |
| 52 | |
| 53 RenderWidget::UpdateSuspendScope::~UpdateSuspendScope() | |
| 54 { | |
| 55 ASSERT(s_updateSuspendCount > 0); | |
| 56 if (s_updateSuspendCount == 1) { | |
| 57 WidgetToParentMap map; | |
| 58 widgetNewParentMap().swap(map); | |
| 59 WidgetToParentMap::iterator end = map.end(); | |
| 60 for (WidgetToParentMap::iterator it = map.begin(); it != end; ++it) { | |
| 61 Widget* child = it->key.get(); | |
| 62 ScrollView* currentParent = toScrollView(child->parent()); | |
| 63 FrameView* newParent = it->value; | |
| 64 if (newParent != currentParent) { | |
| 65 if (currentParent) | |
| 66 currentParent->removeChild(child); | |
| 67 if (newParent) | |
| 68 newParent->addChild(child); | |
| 69 } | |
| 70 } | |
| 71 } | |
| 72 --s_updateSuspendCount; | |
| 73 } | |
| 74 | |
| 75 static void moveWidgetToParentSoon(Widget* child, FrameView* parent) | |
| 76 { | |
| 77 if (!s_updateSuspendCount) { | |
| 78 if (parent) | |
| 79 parent->addChild(child); | |
| 80 else | |
| 81 toScrollView(child->parent())->removeChild(child); | |
| 82 return; | |
| 83 } | |
| 84 widgetNewParentMap().set(child, parent); | |
| 85 } | |
| 86 | |
| 87 RenderWidget::RenderWidget(Element* element) | 42 RenderWidget::RenderWidget(Element* element) |
| 88 : RenderReplaced(element) | 43 : RenderReplaced(element) |
| 89 , m_widget(nullptr) | |
| 90 // Reference counting is used to prevent the widget from being | 44 // Reference counting is used to prevent the widget from being |
| 91 // destroyed while inside the Widget code, which might not be | 45 // destroyed while inside the Widget code, which might not be |
| 92 // able to handle that. | 46 // able to handle that. |
| 93 , m_refCount(1) | 47 , m_refCount(1) |
| 94 { | 48 { |
| 95 ASSERT(element); | 49 ASSERT(element); |
| 96 frameView()->addWidget(this); | 50 frameView()->addWidget(this); |
| 97 } | 51 } |
| 98 | 52 |
| 99 void RenderWidget::willBeDestroyed() | 53 void RenderWidget::willBeDestroyed() |
| 100 { | 54 { |
| 101 frameView()->removeWidget(this); | 55 frameView()->removeWidget(this); |
| 102 | 56 |
| 103 if (AXObjectCache* cache = document().existingAXObjectCache()) { | 57 if (AXObjectCache* cache = document().existingAXObjectCache()) { |
| 104 cache->childrenChanged(this->parent()); | 58 cache->childrenChanged(this->parent()); |
| 105 cache->remove(this); | 59 cache->remove(this); |
| 106 } | 60 } |
| 107 | 61 |
| 108 setWidget(nullptr); | 62 Element* element = toElement(node()); |
| 63 if (element && element->isFrameOwnerElement()) |
| 64 toHTMLFrameOwnerElement(element)->setWidget(nullptr); |
| 109 | 65 |
| 110 RenderReplaced::willBeDestroyed(); | 66 RenderReplaced::willBeDestroyed(); |
| 111 } | 67 } |
| 112 | 68 |
| 113 void RenderWidget::destroy() | 69 void RenderWidget::destroy() |
| 114 { | 70 { |
| 115 willBeDestroyed(); | 71 willBeDestroyed(); |
| 116 clearNode(); | 72 clearNode(); |
| 117 deref(); | 73 deref(); |
| 118 } | 74 } |
| 119 | 75 |
| 120 RenderWidget::~RenderWidget() | 76 RenderWidget::~RenderWidget() |
| 121 { | 77 { |
| 122 ASSERT(m_refCount <= 0); | 78 ASSERT(m_refCount <= 0); |
| 123 clearWidget(); | 79 } |
| 80 |
| 81 Widget* RenderWidget::widget() const |
| 82 { |
| 83 // Plugin widgets are stored in their DOM node. This includes HTMLAppletElem
ent. |
| 84 Element* element = toElement(node()); |
| 85 |
| 86 if (element && element->isFrameOwnerElement()) |
| 87 return toHTMLFrameOwnerElement(element)->ownedWidget(); |
| 88 |
| 89 return 0; |
| 124 } | 90 } |
| 125 | 91 |
| 126 // Widgets are always placed on integer boundaries, so rounding the size is actu
ally | 92 // Widgets are always placed on integer boundaries, so rounding the size is actu
ally |
| 127 // the desired behavior. This function is here because it's otherwise seldom wha
t we | 93 // the desired behavior. This function is here because it's otherwise seldom wha
t we |
| 128 // want to do with a LayoutRect. | 94 // want to do with a LayoutRect. |
| 129 static inline IntRect roundedIntRect(const LayoutRect& rect) | 95 static inline IntRect roundedIntRect(const LayoutRect& rect) |
| 130 { | 96 { |
| 131 return IntRect(roundedIntPoint(rect.location()), roundedIntSize(rect.size())
); | 97 return IntRect(roundedIntPoint(rect.location()), roundedIntSize(rect.size())
); |
| 132 } | 98 } |
| 133 | 99 |
| 134 bool RenderWidget::setWidgetGeometry(const LayoutRect& frame) | 100 bool RenderWidget::setWidgetGeometry(const LayoutRect& frame) |
| 135 { | 101 { |
| 136 if (!node()) | 102 if (!node()) |
| 137 return false; | 103 return false; |
| 138 | 104 |
| 105 Widget* widget = this->widget(); |
| 106 ASSERT(widget); |
| 107 |
| 139 IntRect newFrame = roundedIntRect(frame); | 108 IntRect newFrame = roundedIntRect(frame); |
| 140 | 109 |
| 141 if (m_widget->frameRect() == newFrame) | 110 if (widget->frameRect() == newFrame) |
| 142 return false; | 111 return false; |
| 143 | 112 |
| 144 RefPtr<RenderWidget> protector(this); | 113 RefPtr<RenderWidget> protector(this); |
| 145 RefPtr<Node> protectedNode(node()); | 114 RefPtr<Node> protectedNode(node()); |
| 146 m_widget->setFrameRect(newFrame); | 115 widget->setFrameRect(newFrame); |
| 147 | 116 |
| 148 { | 117 { |
| 149 // FIXME: Remove incremental compositing updates after fixing the chicke
n/egg issues | 118 // FIXME: Remove incremental compositing updates after fixing the chicke
n/egg issues |
| 150 // https://code.google.com/p/chromium/issues/detail?id=343756 | 119 // https://code.google.com/p/chromium/issues/detail?id=343756 |
| 151 DisableCompositingQueryAsserts disabler; | 120 DisableCompositingQueryAsserts disabler; |
| 152 if (hasLayer() && layer()->compositingState() == PaintsIntoOwnBacking) | 121 if (hasLayer() && layer()->compositingState() == PaintsIntoOwnBacking) |
| 153 layer()->compositedLayerMapping()->updateAfterWidgetResize(); | 122 layer()->compositedLayerMapping()->updateAfterWidgetResize(); |
| 154 } | 123 } |
| 155 | 124 |
| 156 return m_widget->frameRect().size() != newFrame.size(); | 125 return widget->frameRect().size() != newFrame.size(); |
| 157 } | 126 } |
| 158 | 127 |
| 159 bool RenderWidget::updateWidgetGeometry() | 128 bool RenderWidget::updateWidgetGeometry() |
| 160 { | 129 { |
| 130 Widget* widget = this->widget(); |
| 131 ASSERT(widget); |
| 132 |
| 161 LayoutRect contentBox = contentBoxRect(); | 133 LayoutRect contentBox = contentBoxRect(); |
| 162 LayoutRect absoluteContentBox(localToAbsoluteQuad(FloatQuad(contentBox)).bou
ndingBox()); | 134 LayoutRect absoluteContentBox(localToAbsoluteQuad(FloatQuad(contentBox)).bou
ndingBox()); |
| 163 if (m_widget->isFrameView()) { | 135 if (widget->isFrameView()) { |
| 164 contentBox.setLocation(absoluteContentBox.location()); | 136 contentBox.setLocation(absoluteContentBox.location()); |
| 165 return setWidgetGeometry(contentBox); | 137 return setWidgetGeometry(contentBox); |
| 166 } | 138 } |
| 167 | 139 |
| 168 return setWidgetGeometry(absoluteContentBox); | 140 return setWidgetGeometry(absoluteContentBox); |
| 169 } | 141 } |
| 170 | 142 |
| 171 void RenderWidget::setWidget(PassRefPtr<Widget> widget) | |
| 172 { | |
| 173 if (widget == m_widget) | |
| 174 return; | |
| 175 | |
| 176 if (m_widget) { | |
| 177 moveWidgetToParentSoon(m_widget.get(), 0); | |
| 178 clearWidget(); | |
| 179 } | |
| 180 m_widget = widget; | |
| 181 if (m_widget) { | |
| 182 // If we've already received a layout, apply the calculated space to the | |
| 183 // widget immediately, but we have to have really been fully constructed
(with a non-null | |
| 184 // style pointer). | |
| 185 if (style()) { | |
| 186 if (!needsLayout()) | |
| 187 updateWidgetGeometry(); | |
| 188 | |
| 189 if (style()->visibility() != VISIBLE) | |
| 190 m_widget->hide(); | |
| 191 else { | |
| 192 m_widget->show(); | |
| 193 repaint(); | |
| 194 } | |
| 195 } | |
| 196 moveWidgetToParentSoon(m_widget.get(), frameView()); | |
| 197 } | |
| 198 | |
| 199 if (AXObjectCache* cache = document().existingAXObjectCache()) | |
| 200 cache->childrenChanged(this); | |
| 201 } | |
| 202 | |
| 203 void RenderWidget::layout() | 143 void RenderWidget::layout() |
| 204 { | 144 { |
| 205 ASSERT(needsLayout()); | 145 ASSERT(needsLayout()); |
| 206 | 146 |
| 207 LayoutRectRecorder recorder(*this); | 147 LayoutRectRecorder recorder(*this); |
| 208 clearNeedsLayout(); | 148 clearNeedsLayout(); |
| 209 } | 149 } |
| 210 | 150 |
| 211 void RenderWidget::styleDidChange(StyleDifference diff, const RenderStyle* oldSt
yle) | 151 void RenderWidget::styleDidChange(StyleDifference diff, const RenderStyle* oldSt
yle) |
| 212 { | 152 { |
| 213 RenderReplaced::styleDidChange(diff, oldStyle); | 153 RenderReplaced::styleDidChange(diff, oldStyle); |
| 214 if (m_widget) { | 154 Widget* widget = this->widget(); |
| 215 if (style()->visibility() != VISIBLE) | 155 |
| 216 m_widget->hide(); | 156 if (widget) { |
| 217 else | 157 if (style()->visibility() != VISIBLE) { |
| 218 m_widget->show(); | 158 widget->hide(); |
| 159 } else { |
| 160 widget->show(); |
| 161 } |
| 219 } | 162 } |
| 220 } | 163 } |
| 221 | 164 |
| 222 void RenderWidget::paintContents(PaintInfo& paintInfo, const LayoutPoint& paintO
ffset) | 165 void RenderWidget::paintContents(PaintInfo& paintInfo, const LayoutPoint& paintO
ffset) |
| 223 { | 166 { |
| 224 LayoutPoint adjustedPaintOffset = paintOffset + location(); | 167 LayoutPoint adjustedPaintOffset = paintOffset + location(); |
| 225 | 168 |
| 169 Widget* widget = this->widget(); |
| 170 ASSERT(widget); |
| 171 |
| 226 // Tell the widget to paint now. This is the only time the widget is allowed | 172 // Tell the widget to paint now. This is the only time the widget is allowed |
| 227 // to paint itself. That way it will composite properly with z-indexed layer
s. | 173 // to paint itself. That way it will composite properly with z-indexed layer
s. |
| 228 IntPoint widgetLocation = m_widget->frameRect().location(); | 174 IntPoint widgetLocation = widget->frameRect().location(); |
| 229 IntPoint paintLocation(roundToInt(adjustedPaintOffset.x() + borderLeft() + p
addingLeft()), | 175 IntPoint paintLocation(roundToInt(adjustedPaintOffset.x() + borderLeft() + p
addingLeft()), |
| 230 roundToInt(adjustedPaintOffset.y() + borderTop() + paddingTop())); | 176 roundToInt(adjustedPaintOffset.y() + borderTop() + paddingTop())); |
| 231 IntRect paintRect = paintInfo.rect; | 177 IntRect paintRect = paintInfo.rect; |
| 232 | 178 |
| 233 IntSize widgetPaintOffset = paintLocation - widgetLocation; | 179 IntSize widgetPaintOffset = paintLocation - widgetLocation; |
| 234 // When painting widgets into compositing layers, tx and ty are relative to
the enclosing compositing layer, | 180 // When painting widgets into compositing layers, tx and ty are relative to
the enclosing compositing layer, |
| 235 // not the root. In this case, shift the CTM and adjust the paintRect to be
root-relative to fix plug-in drawing. | 181 // not the root. In this case, shift the CTM and adjust the paintRect to be
root-relative to fix plug-in drawing. |
| 236 if (!widgetPaintOffset.isZero()) { | 182 if (!widgetPaintOffset.isZero()) { |
| 237 paintInfo.context->translate(widgetPaintOffset); | 183 paintInfo.context->translate(widgetPaintOffset); |
| 238 paintRect.move(-widgetPaintOffset); | 184 paintRect.move(-widgetPaintOffset); |
| 239 } | 185 } |
| 240 m_widget->paint(paintInfo.context, paintRect); | 186 widget->paint(paintInfo.context, paintRect); |
| 241 | 187 |
| 242 if (!widgetPaintOffset.isZero()) | 188 if (!widgetPaintOffset.isZero()) |
| 243 paintInfo.context->translate(-widgetPaintOffset); | 189 paintInfo.context->translate(-widgetPaintOffset); |
| 244 | 190 |
| 245 if (m_widget->isFrameView()) { | 191 if (widget->isFrameView()) { |
| 246 FrameView* frameView = toFrameView(m_widget.get()); | 192 FrameView* frameView = toFrameView(widget); |
| 247 bool runOverlapTests = !frameView->useSlowRepaintsIfNotOverlapped() || f
rameView->hasCompositedContent(); | 193 bool runOverlapTests = !frameView->useSlowRepaintsIfNotOverlapped() || f
rameView->hasCompositedContent(); |
| 248 if (paintInfo.overlapTestRequests && runOverlapTests) { | 194 if (paintInfo.overlapTestRequests && runOverlapTests) { |
| 249 ASSERT(!paintInfo.overlapTestRequests->contains(this)); | 195 ASSERT(!paintInfo.overlapTestRequests->contains(this)); |
| 250 paintInfo.overlapTestRequests->set(this, m_widget->frameRect()); | 196 paintInfo.overlapTestRequests->set(this, widget->frameRect()); |
| 251 } | 197 } |
| 252 } | 198 } |
| 253 } | 199 } |
| 254 | 200 |
| 255 void RenderWidget::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset) | 201 void RenderWidget::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset) |
| 256 { | 202 { |
| 257 ANNOTATE_GRAPHICS_CONTEXT(paintInfo, this); | 203 ANNOTATE_GRAPHICS_CONTEXT(paintInfo, this); |
| 258 | 204 |
| 259 if (!shouldPaint(paintInfo, paintOffset)) | 205 if (!shouldPaint(paintInfo, paintOffset)) |
| 260 return; | 206 return; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 281 if (borderRect.isEmpty()) | 227 if (borderRect.isEmpty()) |
| 282 return; | 228 return; |
| 283 | 229 |
| 284 // Push a clip if we have a border radius, since we want to round the fo
reground content that gets painted. | 230 // Push a clip if we have a border radius, since we want to round the fo
reground content that gets painted. |
| 285 paintInfo.context->save(); | 231 paintInfo.context->save(); |
| 286 RoundedRect roundedInnerRect = style()->getRoundedInnerBorderFor(borderR
ect, | 232 RoundedRect roundedInnerRect = style()->getRoundedInnerBorderFor(borderR
ect, |
| 287 paddingTop() + borderTop(), paddingBottom() + borderBottom(), paddin
gLeft() + borderLeft(), paddingRight() + borderRight(), true, true); | 233 paddingTop() + borderTop(), paddingBottom() + borderBottom(), paddin
gLeft() + borderLeft(), paddingRight() + borderRight(), true, true); |
| 288 clipRoundedInnerRect(paintInfo.context, borderRect, roundedInnerRect); | 234 clipRoundedInnerRect(paintInfo.context, borderRect, roundedInnerRect); |
| 289 } | 235 } |
| 290 | 236 |
| 291 if (m_widget) | 237 Widget* widget = this->widget(); |
| 238 if (widget) |
| 292 paintContents(paintInfo, paintOffset); | 239 paintContents(paintInfo, paintOffset); |
| 293 | 240 |
| 294 if (style()->hasBorderRadius()) | 241 if (style()->hasBorderRadius()) |
| 295 paintInfo.context->restore(); | 242 paintInfo.context->restore(); |
| 296 | 243 |
| 297 // Paint a partially transparent wash over selected widgets. | 244 // Paint a partially transparent wash over selected widgets. |
| 298 if (isSelected() && !document().printing()) { | 245 if (isSelected() && !document().printing()) { |
| 299 // FIXME: selectionRect() is in absolute, not painting coordinates. | 246 // FIXME: selectionRect() is in absolute, not painting coordinates. |
| 300 paintInfo.context->fillRect(pixelSnappedIntRect(selectionRect()), select
ionBackgroundColor()); | 247 paintInfo.context->fillRect(pixelSnappedIntRect(selectionRect()), select
ionBackgroundColor()); |
| 301 } | 248 } |
| 302 | 249 |
| 303 if (canResize()) | 250 if (canResize()) |
| 304 layer()->scrollableArea()->paintResizer(paintInfo.context, roundedIntPoi
nt(adjustedPaintOffset), paintInfo.rect); | 251 layer()->scrollableArea()->paintResizer(paintInfo.context, roundedIntPoi
nt(adjustedPaintOffset), paintInfo.rect); |
| 305 } | 252 } |
| 306 | 253 |
| 307 void RenderWidget::setIsOverlapped(bool isOverlapped) | 254 void RenderWidget::setIsOverlapped(bool isOverlapped) |
| 308 { | 255 { |
| 309 ASSERT(m_widget); | 256 Widget* widget = this->widget(); |
| 310 ASSERT(m_widget->isFrameView()); | 257 ASSERT(widget); |
| 311 toFrameView(m_widget.get())->setIsOverlapped(isOverlapped); | 258 ASSERT(widget->isFrameView()); |
| 259 toFrameView(widget)->setIsOverlapped(isOverlapped); |
| 312 } | 260 } |
| 313 | 261 |
| 314 void RenderWidget::deref() | 262 void RenderWidget::deref() |
| 315 { | 263 { |
| 316 if (--m_refCount <= 0) | 264 if (--m_refCount <= 0) |
| 317 postDestroy(); | 265 postDestroy(); |
| 318 } | 266 } |
| 319 | 267 |
| 268 void RenderWidget::updateOnWidgetChange() |
| 269 { |
| 270 Widget* widget = this->widget(); |
| 271 if (!widget) |
| 272 return; |
| 273 |
| 274 if (!style()) |
| 275 return; |
| 276 |
| 277 if (!needsLayout()) |
| 278 updateWidgetGeometry(); |
| 279 |
| 280 if (style()->visibility() != VISIBLE) { |
| 281 widget->hide(); |
| 282 } else { |
| 283 widget->show(); |
| 284 // FIXME: Why do we repaint in this case, but not the other? |
| 285 repaint(); |
| 286 } |
| 287 } |
| 288 |
| 320 void RenderWidget::updateWidgetPosition() | 289 void RenderWidget::updateWidgetPosition() |
| 321 { | 290 { |
| 322 if (!m_widget || !node()) // Check the node in case destroy() has been calle
d. | 291 Widget* widget = this->widget(); |
| 292 if (!widget || !node()) // Check the node in case destroy() has been called. |
| 323 return; | 293 return; |
| 324 | 294 |
| 325 bool boundsChanged = updateWidgetGeometry(); | 295 bool boundsChanged = updateWidgetGeometry(); |
| 326 | 296 |
| 327 // if the frame bounds got changed, or if view needs layout (possibly indica
ting | 297 // if the frame bounds got changed, or if view needs layout (possibly indica
ting |
| 328 // content size is wrong) we have to do a layout to set the right widget siz
e | 298 // content size is wrong) we have to do a layout to set the right widget siz
e |
| 329 if (m_widget && m_widget->isFrameView()) { | 299 if (widget && widget->isFrameView()) { |
| 330 FrameView* frameView = toFrameView(m_widget.get()); | 300 FrameView* frameView = toFrameView(widget); |
| 331 // Check the frame's page to make sure that the frame isn't in the proce
ss of being destroyed. | 301 // Check the frame's page to make sure that the frame isn't in the proce
ss of being destroyed. |
| 332 if ((boundsChanged || frameView->needsLayout()) && frameView->frame().pa
ge()) | 302 if ((boundsChanged || frameView->needsLayout()) && frameView->frame().pa
ge()) |
| 333 frameView->layout(); | 303 frameView->layout(); |
| 334 } | 304 } |
| 335 } | 305 } |
| 336 | 306 |
| 337 void RenderWidget::widgetPositionsUpdated() | 307 void RenderWidget::widgetPositionsUpdated() |
| 338 { | 308 { |
| 339 if (!m_widget) | 309 Widget* widget = this->widget(); |
| 310 if (!widget) |
| 340 return; | 311 return; |
| 341 m_widget->widgetPositionsUpdated(); | 312 widget->widgetPositionsUpdated(); |
| 342 } | |
| 343 | |
| 344 void RenderWidget::clearWidget() | |
| 345 { | |
| 346 m_widget = nullptr; | |
| 347 } | 313 } |
| 348 | 314 |
| 349 bool RenderWidget::nodeAtPoint(const HitTestRequest& request, HitTestResult& res
ult, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedO
ffset, HitTestAction action) | 315 bool RenderWidget::nodeAtPoint(const HitTestRequest& request, HitTestResult& res
ult, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedO
ffset, HitTestAction action) |
| 350 { | 316 { |
| 351 bool hadResult = result.innerNode(); | 317 bool hadResult = result.innerNode(); |
| 352 bool inside = RenderReplaced::nodeAtPoint(request, result, locationInContain
er, accumulatedOffset, action); | 318 bool inside = RenderReplaced::nodeAtPoint(request, result, locationInContain
er, accumulatedOffset, action); |
| 353 | 319 |
| 354 // Check to see if we are really over the widget itself (and not just in the
border/padding area). | 320 // Check to see if we are really over the widget itself (and not just in the
border/padding area). |
| 355 if ((inside || result.isRectBasedTest()) && !hadResult && result.innerNode()
== node()) | 321 if ((inside || result.isRectBasedTest()) && !hadResult && result.innerNode()
== node()) |
| 356 result.setIsOverWidget(contentBoxRect().contains(result.localPoint())); | 322 result.setIsOverWidget(contentBoxRect().contains(result.localPoint())); |
| 357 return inside; | 323 return inside; |
| 358 } | 324 } |
| 359 | 325 |
| 360 CursorDirective RenderWidget::getCursor(const LayoutPoint& point, Cursor& cursor
) const | 326 CursorDirective RenderWidget::getCursor(const LayoutPoint& point, Cursor& cursor
) const |
| 361 { | 327 { |
| 362 if (widget() && widget()->isPluginView()) { | 328 if (widget() && widget()->isPluginView()) { |
| 363 // A plug-in is responsible for setting the cursor when the pointer is o
ver it. | 329 // A plug-in is responsible for setting the cursor when the pointer is o
ver it. |
| 364 return DoNotSetCursor; | 330 return DoNotSetCursor; |
| 365 } | 331 } |
| 366 return RenderReplaced::getCursor(point, cursor); | 332 return RenderReplaced::getCursor(point, cursor); |
| 367 } | 333 } |
| 368 | 334 |
| 369 } // namespace WebCore | 335 } // namespace WebCore |
| OLD | NEW |