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