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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 , m_shouldUpdateWhileOffscreen(true) | 173 , m_shouldUpdateWhileOffscreen(true) |
174 , m_deferSetNeedsLayouts(0) | 174 , m_deferSetNeedsLayouts(0) |
175 , m_setNeedsLayoutWasDeferred(false) | 175 , m_setNeedsLayoutWasDeferred(false) |
176 , m_scrollCorner(0) | 176 , m_scrollCorner(0) |
177 , m_shouldAutoSize(false) | 177 , m_shouldAutoSize(false) |
178 , m_inAutoSize(false) | 178 , m_inAutoSize(false) |
179 , m_didRunAutosize(false) | 179 , m_didRunAutosize(false) |
180 , m_hasSoftwareFilters(false) | 180 , m_hasSoftwareFilters(false) |
181 , m_visibleContentScaleFactor(1) | 181 , m_visibleContentScaleFactor(1) |
182 { | 182 { |
| 183 ASSERT(m_frame); |
183 init(); | 184 init(); |
184 | 185 |
185 // FIXME: Can m_frame ever be null here? | |
186 if (!m_frame) | |
187 return; | |
188 | |
189 Page* page = m_frame->page(); | 186 Page* page = m_frame->page(); |
190 if (!page) | 187 if (!page) |
191 return; | 188 return; |
192 | 189 |
193 if (m_frame == page->mainFrame()) { | 190 if (m_frame == page->mainFrame()) { |
194 ScrollableArea::setVerticalScrollElasticity(ScrollElasticityAllowed); | 191 ScrollableArea::setVerticalScrollElasticity(ScrollElasticityAllowed); |
195 ScrollableArea::setHorizontalScrollElasticity(ScrollElasticityAllowed); | 192 ScrollableArea::setHorizontalScrollElasticity(ScrollElasticityAllowed); |
196 } | 193 } |
197 } | 194 } |
198 | 195 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 m_maintainScrollPositionAnchor = 0; | 277 m_maintainScrollPositionAnchor = 0; |
281 m_disableRepaints = 0; | 278 m_disableRepaints = 0; |
282 } | 279 } |
283 | 280 |
284 void FrameView::removeFromAXObjectCache() | 281 void FrameView::removeFromAXObjectCache() |
285 { | 282 { |
286 if (AXObjectCache* cache = axObjectCache()) | 283 if (AXObjectCache* cache = axObjectCache()) |
287 cache->remove(this); | 284 cache->remove(this); |
288 } | 285 } |
289 | 286 |
290 void FrameView::clearFrame() | |
291 { | |
292 RELEASE_ASSERT(!isInLayout()); | |
293 m_frame = 0; | |
294 } | |
295 | |
296 void FrameView::resetScrollbars() | 287 void FrameView::resetScrollbars() |
297 { | 288 { |
298 // Reset the document's scrollbars back to our defaults before we yield the
floor. | 289 // Reset the document's scrollbars back to our defaults before we yield the
floor. |
299 m_firstLayout = true; | 290 m_firstLayout = true; |
300 setScrollbarsSuppressed(true); | 291 setScrollbarsSuppressed(true); |
301 if (m_canHaveScrollbars) | 292 if (m_canHaveScrollbars) |
302 setScrollbarModes(ScrollbarAuto, ScrollbarAuto); | 293 setScrollbarModes(ScrollbarAuto, ScrollbarAuto); |
303 else | 294 else |
304 setScrollbarModes(ScrollbarAlwaysOff, ScrollbarAlwaysOff); | 295 setScrollbarModes(ScrollbarAlwaysOff, ScrollbarAlwaysOff); |
305 setScrollbarsSuppressed(false); | 296 setScrollbarsSuppressed(false); |
306 } | 297 } |
307 | 298 |
308 void FrameView::init() | 299 void FrameView::init() |
309 { | 300 { |
310 reset(); | 301 reset(); |
311 | 302 |
312 m_margins = LayoutSize(-1, -1); // undefined | 303 m_margins = LayoutSize(-1, -1); // undefined |
313 m_size = LayoutSize(); | 304 m_size = LayoutSize(); |
314 | 305 |
315 // Propagate the marginwidth/height and scrolling modes to the view. | 306 // Propagate the marginwidth/height and scrolling modes to the view. |
316 Element* ownerElement = m_frame ? m_frame->ownerElement() : 0; | 307 Element* ownerElement = m_frame->ownerElement(); |
317 if (ownerElement && (ownerElement->hasTagName(frameTag) || ownerElement->has
TagName(iframeTag))) { | 308 if (ownerElement && (ownerElement->hasTagName(frameTag) || ownerElement->has
TagName(iframeTag))) { |
318 HTMLFrameElementBase* frameElt = toHTMLFrameElementBase(ownerElement); | 309 HTMLFrameElementBase* frameElt = toHTMLFrameElementBase(ownerElement); |
319 if (frameElt->scrollingMode() == ScrollbarAlwaysOff) | 310 if (frameElt->scrollingMode() == ScrollbarAlwaysOff) |
320 setCanHaveScrollbars(false); | 311 setCanHaveScrollbars(false); |
321 LayoutUnit marginWidth = frameElt->marginWidth(); | 312 LayoutUnit marginWidth = frameElt->marginWidth(); |
322 LayoutUnit marginHeight = frameElt->marginHeight(); | 313 LayoutUnit marginHeight = frameElt->marginHeight(); |
323 if (marginWidth != -1) | 314 if (marginWidth != -1) |
324 setMarginWidth(marginWidth); | 315 setMarginWidth(marginWidth); |
325 if (marginHeight != -1) | 316 if (marginHeight != -1) |
326 setMarginHeight(marginHeight); | 317 setMarginHeight(marginHeight); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 } | 392 } |
402 | 393 |
403 void FrameView::invalidateRect(const IntRect& rect) | 394 void FrameView::invalidateRect(const IntRect& rect) |
404 { | 395 { |
405 if (!parent()) { | 396 if (!parent()) { |
406 if (HostWindow* window = hostWindow()) | 397 if (HostWindow* window = hostWindow()) |
407 window->invalidateContentsAndRootView(rect); | 398 window->invalidateContentsAndRootView(rect); |
408 return; | 399 return; |
409 } | 400 } |
410 | 401 |
411 if (!m_frame) | |
412 return; | |
413 | |
414 RenderPart* renderer = m_frame->ownerRenderer(); | 402 RenderPart* renderer = m_frame->ownerRenderer(); |
415 if (!renderer) | 403 if (!renderer) |
416 return; | 404 return; |
417 | 405 |
418 IntRect repaintRect = rect; | 406 IntRect repaintRect = rect; |
419 repaintRect.move(renderer->borderLeft() + renderer->paddingLeft(), | 407 repaintRect.move(renderer->borderLeft() + renderer->paddingLeft(), |
420 renderer->borderTop() + renderer->paddingTop()); | 408 renderer->borderTop() + renderer->paddingTop()); |
421 renderer->repaintRectangle(repaintRect); | 409 renderer->repaintRectangle(repaintRect); |
422 } | 410 } |
423 | 411 |
424 void FrameView::setFrameRect(const IntRect& newRect) | 412 void FrameView::setFrameRect(const IntRect& newRect) |
425 { | 413 { |
426 IntRect oldRect = frameRect(); | 414 IntRect oldRect = frameRect(); |
427 if (newRect == oldRect) | 415 if (newRect == oldRect) |
428 return; | 416 return; |
429 | 417 |
430 // Autosized font sizes depend on the width of the viewing area. | 418 // Autosized font sizes depend on the width of the viewing area. |
431 if (newRect.width() != oldRect.width()) { | 419 if (newRect.width() != oldRect.width()) { |
432 Page* page = m_frame ? m_frame->page() : 0; | 420 Page* page = m_frame->page(); |
433 if (page && page->mainFrame() == m_frame && page->settings().textAutosiz
ingEnabled()) { | 421 if (page && page->mainFrame() == m_frame && page->settings().textAutosiz
ingEnabled()) { |
434 for (Frame* frame = page->mainFrame(); frame; frame = frame->tree()-
>traverseNext()) | 422 for (Frame* frame = page->mainFrame(); frame; frame = frame->tree()-
>traverseNext()) |
435 m_frame->document()->textAutosizer()->recalculateMultipliers(); | 423 m_frame->document()->textAutosizer()->recalculateMultipliers(); |
436 } | 424 } |
437 } | 425 } |
438 | 426 |
439 ScrollView::setFrameRect(newRect); | 427 ScrollView::setFrameRect(newRect); |
440 | 428 |
441 updateScrollableAreaSet(); | 429 updateScrollableAreaSet(); |
442 | 430 |
(...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1302 } | 1290 } |
1303 | 1291 |
1304 | 1292 |
1305 IntSize FrameView::scrollOffsetForFixedPosition() const | 1293 IntSize FrameView::scrollOffsetForFixedPosition() const |
1306 { | 1294 { |
1307 return toIntSize(clampScrollPosition(scrollPosition())); | 1295 return toIntSize(clampScrollPosition(scrollPosition())); |
1308 } | 1296 } |
1309 | 1297 |
1310 IntPoint FrameView::lastKnownMousePosition() const | 1298 IntPoint FrameView::lastKnownMousePosition() const |
1311 { | 1299 { |
1312 return m_frame ? m_frame->eventHandler()->lastKnownMousePosition() : IntPoin
t(); | 1300 return m_frame->eventHandler()->lastKnownMousePosition(); |
1313 } | 1301 } |
1314 | 1302 |
1315 bool FrameView::scrollContentsFastPath(const IntSize& scrollDelta, const IntRect
& rectToScroll, const IntRect& clipRect) | 1303 bool FrameView::scrollContentsFastPath(const IntSize& scrollDelta, const IntRect
& rectToScroll, const IntRect& clipRect) |
1316 { | 1304 { |
1317 if (!m_viewportConstrainedObjects || m_viewportConstrainedObjects->isEmpty()
) { | 1305 if (!m_viewportConstrainedObjects || m_viewportConstrainedObjects->isEmpty()
) { |
1318 hostWindow()->scroll(scrollDelta, rectToScroll, clipRect); | 1306 hostWindow()->scroll(scrollDelta, rectToScroll, clipRect); |
1319 return true; | 1307 return true; |
1320 } | 1308 } |
1321 | 1309 |
1322 const bool isCompositedContentLayer = contentsInCompositedLayer(); | 1310 const bool isCompositedContentLayer = contentsInCompositedLayer(); |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1934 bool FrameView::layoutPending() const | 1922 bool FrameView::layoutPending() const |
1935 { | 1923 { |
1936 return m_layoutTimer.isActive(); | 1924 return m_layoutTimer.isActive(); |
1937 } | 1925 } |
1938 | 1926 |
1939 bool FrameView::needsLayout() const | 1927 bool FrameView::needsLayout() const |
1940 { | 1928 { |
1941 // This can return true in cases where the document does not have a body yet
. | 1929 // This can return true in cases where the document does not have a body yet
. |
1942 // Document::shouldScheduleLayout takes care of preventing us from schedulin
g | 1930 // Document::shouldScheduleLayout takes care of preventing us from schedulin
g |
1943 // layout in that case. | 1931 // layout in that case. |
1944 if (!m_frame) | |
1945 return false; | |
1946 | 1932 |
1947 RenderView* renderView = this->renderView(); | 1933 RenderView* renderView = this->renderView(); |
1948 return layoutPending() | 1934 return layoutPending() |
1949 || (renderView && renderView->needsLayout()) | 1935 || (renderView && renderView->needsLayout()) |
1950 || m_layoutRoot | 1936 || m_layoutRoot |
1951 || (m_deferSetNeedsLayouts && m_setNeedsLayoutWasDeferred); | 1937 || (m_deferSetNeedsLayouts && m_setNeedsLayoutWasDeferred); |
1952 } | 1938 } |
1953 | 1939 |
1954 void FrameView::setNeedsLayout() | 1940 void FrameView::setNeedsLayout() |
1955 { | 1941 { |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2413 | 2399 |
2414 IntRect FrameView::windowClipRect(bool clipToContents) const | 2400 IntRect FrameView::windowClipRect(bool clipToContents) const |
2415 { | 2401 { |
2416 ASSERT(m_frame->view() == this); | 2402 ASSERT(m_frame->view() == this); |
2417 | 2403 |
2418 if (paintsEntireContents()) | 2404 if (paintsEntireContents()) |
2419 return IntRect(IntPoint(), contentsSize()); | 2405 return IntRect(IntPoint(), contentsSize()); |
2420 | 2406 |
2421 // Set our clip rect to be our contents. | 2407 // Set our clip rect to be our contents. |
2422 IntRect clipRect = contentsToWindow(visibleContentRect(clipToContents ? Excl
udeScrollbars : IncludeScrollbars)); | 2408 IntRect clipRect = contentsToWindow(visibleContentRect(clipToContents ? Excl
udeScrollbars : IncludeScrollbars)); |
2423 if (!m_frame || !m_frame->ownerElement()) | 2409 if (!m_frame->ownerElement()) |
2424 return clipRect; | 2410 return clipRect; |
2425 | 2411 |
2426 // Take our owner element and get its clip rect. | 2412 // Take our owner element and get its clip rect. |
2427 HTMLFrameOwnerElement* ownerElement = m_frame->ownerElement(); | 2413 HTMLFrameOwnerElement* ownerElement = m_frame->ownerElement(); |
2428 FrameView* parentView = ownerElement->document()->view(); | 2414 FrameView* parentView = ownerElement->document()->view(); |
2429 if (parentView) | 2415 if (parentView) |
2430 clipRect.intersect(parentView->windowClipRectForFrameOwner(ownerElement,
true)); | 2416 clipRect.intersect(parentView->windowClipRectForFrameOwner(ownerElement,
true)); |
2431 return clipRect; | 2417 return clipRect; |
2432 } | 2418 } |
2433 | 2419 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2493 { | 2479 { |
2494 if (m_visibleContentScaleFactor == visibleContentScaleFactor) | 2480 if (m_visibleContentScaleFactor == visibleContentScaleFactor) |
2495 return; | 2481 return; |
2496 | 2482 |
2497 m_visibleContentScaleFactor = visibleContentScaleFactor; | 2483 m_visibleContentScaleFactor = visibleContentScaleFactor; |
2498 updateScrollbars(scrollOffset()); | 2484 updateScrollbars(scrollOffset()); |
2499 } | 2485 } |
2500 | 2486 |
2501 bool FrameView::scrollbarsCanBeActive() const | 2487 bool FrameView::scrollbarsCanBeActive() const |
2502 { | 2488 { |
2503 if (!m_frame) | |
2504 return false; | |
2505 | |
2506 if (m_frame->view() != this) | 2489 if (m_frame->view() != this) |
2507 return false; | 2490 return false; |
2508 | 2491 |
2509 return !!m_frame->document(); | 2492 return !!m_frame->document(); |
2510 } | 2493 } |
2511 | 2494 |
2512 ScrollableArea* FrameView::enclosingScrollableArea() const | 2495 ScrollableArea* FrameView::enclosingScrollableArea() const |
2513 { | 2496 { |
2514 // FIXME: Walk up the frame tree and look for a scrollable parent frame or R
enderLayer. | 2497 // FIXME: Walk up the frame tree and look for a scrollable parent frame or R
enderLayer. |
2515 return 0; | 2498 return 0; |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2789 } | 2772 } |
2790 | 2773 |
2791 void FrameView::updateControlTints() | 2774 void FrameView::updateControlTints() |
2792 { | 2775 { |
2793 // This is called when control tints are changed from aqua/graphite to clear
and vice versa. | 2776 // This is called when control tints are changed from aqua/graphite to clear
and vice versa. |
2794 // We do a "fake" paint, and when the theme gets a paint call, it can then d
o an invalidate. | 2777 // We do a "fake" paint, and when the theme gets a paint call, it can then d
o an invalidate. |
2795 // This is only done if the theme supports control tinting. It's up to the t
heme and platform | 2778 // This is only done if the theme supports control tinting. It's up to the t
heme and platform |
2796 // to define when controls get the tint and to call this function when that
changes. | 2779 // to define when controls get the tint and to call this function when that
changes. |
2797 | 2780 |
2798 // Optimize the common case where we bring a window to the front while it's
still empty. | 2781 // Optimize the common case where we bring a window to the front while it's
still empty. |
2799 if (!m_frame || m_frame->document()->url().isEmpty()) | 2782 if (m_frame->document()->url().isEmpty()) |
2800 return; | 2783 return; |
2801 | 2784 |
2802 if (RenderTheme::theme().supportsControlTints() || hasCustomScrollbars()) | 2785 if (RenderTheme::theme().supportsControlTints() || hasCustomScrollbars()) |
2803 paintControlTints(); | 2786 paintControlTints(); |
2804 } | 2787 } |
2805 | 2788 |
2806 void FrameView::paintControlTints() | 2789 void FrameView::paintControlTints() |
2807 { | 2790 { |
2808 if (needsLayout()) | 2791 if (needsLayout()) |
2809 layout(); | 2792 layout(); |
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3359 } | 3342 } |
3360 | 3343 |
3361 AXObjectCache* FrameView::axObjectCache() const | 3344 AXObjectCache* FrameView::axObjectCache() const |
3362 { | 3345 { |
3363 if (frame() && frame()->document()) | 3346 if (frame() && frame()->document()) |
3364 return frame()->document()->existingAXObjectCache(); | 3347 return frame()->document()->existingAXObjectCache(); |
3365 return 0; | 3348 return 0; |
3366 } | 3349 } |
3367 | 3350 |
3368 } // namespace WebCore | 3351 } // namespace WebCore |
OLD | NEW |