OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> | 2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> |
3 * 1999 Lars Knoll <knoll@kde.org> | 3 * 1999 Lars Knoll <knoll@kde.org> |
4 * 1999 Antti Koivisto <koivisto@kde.org> | 4 * 1999 Antti Koivisto <koivisto@kde.org> |
5 * 2000 Dirk Mueller <mueller@kde.org> | 5 * 2000 Dirk Mueller <mueller@kde.org> |
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. |
7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com) | 7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com) |
8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) | 8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) |
9 * Copyright (C) 2009 Google Inc. All rights reserved. | 9 * Copyright (C) 2009 Google Inc. All rights reserved. |
10 * | 10 * |
(...skipping 2184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2195 // Align to the top and to the closest side (this matches other browsers). | 2195 // Align to the top and to the closest side (this matches other browsers). |
2196 anchorNode->renderer()->scrollRectToVisible(rect, ScrollAlignment::alignToEd
geIfNeeded, ScrollAlignment::alignTopAlways); | 2196 anchorNode->renderer()->scrollRectToVisible(rect, ScrollAlignment::alignToEd
geIfNeeded, ScrollAlignment::alignTopAlways); |
2197 | 2197 |
2198 if (AXObjectCache* cache = m_frame->document()->existingAXObjectCache()) | 2198 if (AXObjectCache* cache = m_frame->document()->existingAXObjectCache()) |
2199 cache->handleScrolledToAnchor(anchorNode.get()); | 2199 cache->handleScrolledToAnchor(anchorNode.get()); |
2200 | 2200 |
2201 // scrollRectToVisible can call into setScrollPosition(), which resets m_mai
ntainScrollPositionAnchor. | 2201 // scrollRectToVisible can call into setScrollPosition(), which resets m_mai
ntainScrollPositionAnchor. |
2202 m_maintainScrollPositionAnchor = anchorNode; | 2202 m_maintainScrollPositionAnchor = anchorNode; |
2203 } | 2203 } |
2204 | 2204 |
2205 void FrameView::updateWidget(RenderObject* object) | 2205 bool FrameView::updateWidget(RenderObject* object) |
2206 { | 2206 { |
2207 ASSERT(!object->node() || object->node()->isElementNode()); | 2207 ASSERT(!object->node() || object->node()->isElementNode()); |
2208 Element* ownerElement = toElement(object->node()); | 2208 RefPtr<Element> ownerElement = toElement(object->node()); |
2209 // The object may have already been destroyed (thus node cleared), | 2209 // The object may have already been destroyed (thus node cleared), |
2210 // but FrameView holds a manual ref, so it won't have been deleted. | 2210 // but FrameView holds a manual ref, so it won't have been deleted. |
2211 ASSERT(m_widgetUpdateSet->contains(object)); | 2211 ASSERT(m_widgetUpdateSet->contains(object)); |
2212 if (!ownerElement) | 2212 if (!ownerElement) |
2213 return; | 2213 return true; |
2214 | 2214 |
2215 if (object->isEmbeddedObject()) { | 2215 if (object->isEmbeddedObject()) { |
2216 RenderEmbeddedObject* embeddedObject = static_cast<RenderEmbeddedObject*
>(object); | 2216 RenderEmbeddedObject* embeddedObject = static_cast<RenderEmbeddedObject*
>(object); |
2217 // No need to update if it's already crashed or known to be missing. | 2217 // No need to update if it's already crashed or known to be missing. |
2218 if (embeddedObject->showsUnavailablePluginIndicator()) | 2218 if (embeddedObject->showsUnavailablePluginIndicator()) |
2219 return; | 2219 return true; |
2220 | 2220 |
2221 // FIXME: This could turn into a real virtual dispatch if we defined | 2221 // FIXME: This could turn into a real virtual dispatch if we defined |
2222 // updateWidget(PluginCreationOption) on HTMLElement. | 2222 // updateWidget(PluginCreationOption) on HTMLElement. |
2223 if (ownerElement->hasTagName(objectTag) || ownerElement->hasTagName(embe
dTag) || ownerElement->hasTagName(appletTag)) { | 2223 if (ownerElement->hasTagName(objectTag) || ownerElement->hasTagName(embe
dTag) || ownerElement->hasTagName(appletTag)) { |
2224 HTMLPlugInImageElement* pluginElement = toHTMLPlugInImageElement(own
erElement); | 2224 HTMLPlugInImageElement* pluginElement = toHTMLPlugInImageElement(own
erElement.get()); |
2225 if (pluginElement->needsWidgetUpdate()) | 2225 if (pluginElement->needsWidgetUpdate()) |
2226 pluginElement->updateWidget(CreateAnyWidgetType); | 2226 pluginElement->updateWidget(CreateAnyWidgetType); |
2227 } else | 2227 } else |
2228 ASSERT_NOT_REACHED(); | 2228 ASSERT_NOT_REACHED(); |
2229 | 2229 |
2230 // Caution: it's possible the object was destroyed again, since loading
a | 2230 // Caution: it's possible the object was destroyed again, since loading
a |
2231 // plugin may run any arbitrary JavaScript. | 2231 // plugin may run any arbitrary JavaScript. |
| 2232 if (ownerElement->renderer() != embeddedObject) { |
| 2233 m_widgetUpdateSet->clear(); |
| 2234 return false; |
| 2235 } |
2232 embeddedObject->updateWidgetPosition(); | 2236 embeddedObject->updateWidgetPosition(); |
2233 } | 2237 } |
| 2238 |
| 2239 return true; |
2234 } | 2240 } |
2235 | 2241 |
2236 bool FrameView::updateWidgets() | 2242 bool FrameView::updateWidgets() |
2237 { | 2243 { |
2238 if (m_nestedLayoutCount > 1 || !m_widgetUpdateSet || m_widgetUpdateSet->isEm
pty()) | 2244 if (m_nestedLayoutCount > 1 || !m_widgetUpdateSet || m_widgetUpdateSet->isEm
pty()) |
2239 return true; | 2245 return true; |
2240 | 2246 |
2241 size_t size = m_widgetUpdateSet->size(); | 2247 size_t size = m_widgetUpdateSet->size(); |
2242 | 2248 |
2243 Vector<RenderObject*> objects; | 2249 Vector<RenderObject*> objects; |
2244 objects.reserveInitialCapacity(size); | 2250 objects.reserveInitialCapacity(size); |
2245 | 2251 |
2246 RenderObjectSet::const_iterator end = m_widgetUpdateSet->end(); | 2252 RenderObjectSet::const_iterator end = m_widgetUpdateSet->end(); |
2247 for (RenderObjectSet::const_iterator it = m_widgetUpdateSet->begin(); it !=
end; ++it) { | 2253 for (RenderObjectSet::const_iterator it = m_widgetUpdateSet->begin(); it !=
end; ++it) { |
2248 RenderObject* object = *it; | 2254 RenderObject* object = *it; |
2249 objects.uncheckedAppend(object); | 2255 objects.uncheckedAppend(object); |
2250 if (object->isEmbeddedObject()) { | 2256 if (object->isEmbeddedObject()) { |
2251 RenderEmbeddedObject* embeddedObject = static_cast<RenderEmbeddedObj
ect*>(object); | 2257 RenderEmbeddedObject* embeddedObject = static_cast<RenderEmbeddedObj
ect*>(object); |
2252 embeddedObject->ref(); | 2258 embeddedObject->ref(); |
2253 } | 2259 } |
2254 } | 2260 } |
2255 | 2261 |
2256 for (size_t i = 0; i < size; ++i) { | 2262 for (size_t i = 0; i < size; ++i) { |
2257 RenderObject* object = objects[i]; | 2263 RenderObject* object = objects[i]; |
2258 updateWidget(object); | 2264 if (!updateWidget(object)) |
| 2265 return false; |
2259 m_widgetUpdateSet->remove(object); | 2266 m_widgetUpdateSet->remove(object); |
2260 } | 2267 } |
2261 | 2268 |
2262 RenderArena* arena = m_frame->document()->renderArena(); | 2269 RenderArena* arena = m_frame->document()->renderArena(); |
2263 for (size_t i = 0; i < size; ++i) { | 2270 for (size_t i = 0; i < size; ++i) { |
2264 RenderObject* object = objects[i]; | 2271 RenderObject* object = objects[i]; |
2265 if (object->isEmbeddedObject()) { | 2272 if (object->isEmbeddedObject()) { |
2266 RenderEmbeddedObject* embeddedObject = static_cast<RenderEmbeddedObj
ect*>(object); | 2273 RenderEmbeddedObject* embeddedObject = static_cast<RenderEmbeddedObj
ect*>(object); |
2267 embeddedObject->deref(arena); | 2274 embeddedObject->deref(arena); |
2268 } | 2275 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2331 | 2338 |
2332 if (page) { | 2339 if (page) { |
2333 if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoordina
tor()) | 2340 if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoordina
tor()) |
2334 scrollingCoordinator->frameViewLayoutUpdated(this); | 2341 scrollingCoordinator->frameViewLayoutUpdated(this); |
2335 } | 2342 } |
2336 | 2343 |
2337 scrollToAnchor(); | 2344 scrollToAnchor(); |
2338 | 2345 |
2339 m_actionScheduler->resume(); | 2346 m_actionScheduler->resume(); |
2340 | 2347 |
| 2348 // Refetch render view since it can be destroyed by updateWidget() |
| 2349 // call above. |
| 2350 renderView = this->renderView(); |
2341 if (renderView && !renderView->printing()) { | 2351 if (renderView && !renderView->printing()) { |
2342 IntSize currentSize; | 2352 IntSize currentSize; |
2343 currentSize = visibleContentRect(IncludeScrollbars).size(); | 2353 currentSize = visibleContentRect(IncludeScrollbars).size(); |
2344 float currentZoomFactor = renderView->style()->zoom(); | 2354 float currentZoomFactor = renderView->style()->zoom(); |
2345 bool resized = !m_firstLayout && (currentSize != m_lastViewportSize || c
urrentZoomFactor != m_lastZoomFactor); | 2355 bool resized = !m_firstLayout && (currentSize != m_lastViewportSize || c
urrentZoomFactor != m_lastZoomFactor); |
2346 m_lastViewportSize = currentSize; | 2356 m_lastViewportSize = currentSize; |
2347 m_lastZoomFactor = currentZoomFactor; | 2357 m_lastZoomFactor = currentZoomFactor; |
2348 if (resized) { | 2358 if (resized) { |
2349 m_frame->eventHandler()->sendResizeEvent(); | 2359 m_frame->eventHandler()->sendResizeEvent(); |
2350 | 2360 |
(...skipping 1188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3539 } | 3549 } |
3540 | 3550 |
3541 AXObjectCache* FrameView::axObjectCache() const | 3551 AXObjectCache* FrameView::axObjectCache() const |
3542 { | 3552 { |
3543 if (frame() && frame()->document()) | 3553 if (frame() && frame()->document()) |
3544 return frame()->document()->existingAXObjectCache(); | 3554 return frame()->document()->existingAXObjectCache(); |
3545 return 0; | 3555 return 0; |
3546 } | 3556 } |
3547 | 3557 |
3548 } // namespace WebCore | 3558 } // namespace WebCore |
OLD | NEW |