Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(260)

Side by Side Diff: third_party/WebKit/WebCore/rendering/RenderLayer.cpp

Issue 21165: Revert the merge. Mac build is mysteriously broken. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
3 * 3 *
4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation.
5 * 5 *
6 * Other contributors: 6 * Other contributors:
7 * Robert O'Callahan <roc+@cs.cmu.edu> 7 * Robert O'Callahan <roc+@cs.cmu.edu>
8 * David Baron <dbaron@fas.harvard.edu> 8 * David Baron <dbaron@fas.harvard.edu>
9 * Christian Biesinger <cbiesinger@web.de> 9 * Christian Biesinger <cbiesinger@web.de>
10 * Randall Jesup <rjesup@wgate.com> 10 * Randall Jesup <rjesup@wgate.com>
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 } 119 }
120 120
121 void ClipRects::destroy(RenderArena* renderArena) 121 void ClipRects::destroy(RenderArena* renderArena)
122 { 122 {
123 delete this; 123 delete this;
124 124
125 // Recover the size left there for us by operator delete and free the memory . 125 // Recover the size left there for us by operator delete and free the memory .
126 renderArena->free(*(size_t *)this, this); 126 renderArena->free(*(size_t *)this, this);
127 } 127 }
128 128
129 RenderLayer::RenderLayer(RenderBoxModelObject* renderer) 129 RenderLayer::RenderLayer(RenderBox* renderer)
130 : m_renderer(renderer) 130 : m_renderer(renderer)
131 , m_parent(0) 131 , m_parent(0)
132 , m_previous(0) 132 , m_previous(0)
133 , m_next(0) 133 , m_next(0)
134 , m_first(0) 134 , m_first(0)
135 , m_last(0) 135 , m_last(0)
136 , m_relX(0) 136 , m_relX(0)
137 , m_relY(0) 137 , m_relY(0)
138 , m_x(0) 138 , m_x(0)
139 , m_y(0) 139 , m_y(0)
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 } 221 }
222 222
223 #if USE(ACCELERATED_COMPOSITING) 223 #if USE(ACCELERATED_COMPOSITING)
224 RenderLayerCompositor* RenderLayer::compositor() const 224 RenderLayerCompositor* RenderLayer::compositor() const
225 { 225 {
226 ASSERT(renderer()->view()); 226 ASSERT(renderer()->view());
227 return renderer()->view()->compositor(); 227 return renderer()->view()->compositor();
228 } 228 }
229 #endif // USE(ACCELERATED_COMPOSITING) 229 #endif // USE(ACCELERATED_COMPOSITING)
230 230
231 void RenderLayer::setStaticY(int staticY)
232 {
233 if (m_staticY == staticY)
234 return;
235 m_staticY = staticY;
236 renderer()->setChildNeedsLayout(true, false);
237 }
238
239 void RenderLayer::updateLayerPositions(bool doFullRepaint, bool checkForRepaint) 231 void RenderLayer::updateLayerPositions(bool doFullRepaint, bool checkForRepaint)
240 { 232 {
241 if (doFullRepaint) { 233 if (doFullRepaint) {
242 renderer()->repaint(); 234 renderer()->repaint();
243 #if USE(ACCELERATED_COMPOSITING) 235 #if USE(ACCELERATED_COMPOSITING)
244 checkForRepaint = false; 236 checkForRepaint = false;
245 // We need the full repaint to propagate to child layers if we are hardw are compositing. 237 // We need the full repaint to propagate to child layers if we are hardw are compositing.
246 if (!compositor()->inCompositingMode()) 238 if (!compositor()->inCompositingMode())
247 doFullRepaint = false; 239 doFullRepaint = false;
248 #else 240 #else
(...skipping 14 matching lines...) Expand all
263 255
264 updateTransform(); 256 updateTransform();
265 257
266 if (m_hasVisibleContent) { 258 if (m_hasVisibleContent) {
267 RenderView* view = renderer()->view(); 259 RenderView* view = renderer()->view();
268 ASSERT(view); 260 ASSERT(view);
269 // FIXME: Optimize using LayoutState and remove the disableLayoutState() call 261 // FIXME: Optimize using LayoutState and remove the disableLayoutState() call
270 // from updateScrollInfoAfterLayout(). 262 // from updateScrollInfoAfterLayout().
271 ASSERT(!view->layoutStateEnabled()); 263 ASSERT(!view->layoutStateEnabled());
272 264
273 RenderBoxModelObject* repaintContainer = renderer()->containerForRepaint (); 265 RenderBox* repaintContainer = renderer()->containerForRepaint();
274 IntRect newRect = renderer()->clippedOverflowRectForRepaint(repaintConta iner); 266 IntRect newRect = renderer()->clippedOverflowRectForRepaint(repaintConta iner);
275 IntRect newOutlineBox = renderer()->outlineBoundsForRepaint(repaintConta iner); 267 IntRect newOutlineBox = renderer()->outlineBoundsForRepaint(repaintConta iner);
276 if (checkForRepaint) { 268 if (checkForRepaint) {
277 if (view && !view->printing()) { 269 if (view && !view->printing()) {
278 if (m_needsFullRepaint) { 270 if (m_needsFullRepaint) {
279 renderer()->repaintUsingContainer(repaintContainer, m_repain tRect); 271 renderer()->repaintUsingContainer(repaintContainer, m_repain tRect);
280 if (newRect != m_repaintRect) 272 if (newRect != m_repaintRect)
281 renderer()->repaintUsingContainer(repaintContainer, newR ect); 273 renderer()->repaintUsingContainer(repaintContainer, newR ect);
282 } else 274 } else
283 renderer()->repaintAfterLayoutIfNeeded(repaintContainer, m_r epaintRect, m_outlineBox); 275 renderer()->repaintAfterLayoutIfNeeded(repaintContainer, m_r epaintRect, m_outlineBox);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 bool hasTransform = renderer()->hasTransform(); 309 bool hasTransform = renderer()->hasTransform();
318 bool hadTransform = m_transform; 310 bool hadTransform = m_transform;
319 if (hasTransform != hadTransform) { 311 if (hasTransform != hadTransform) {
320 if (hasTransform) 312 if (hasTransform)
321 m_transform.set(new TransformationMatrix); 313 m_transform.set(new TransformationMatrix);
322 else 314 else
323 m_transform.clear(); 315 m_transform.clear();
324 } 316 }
325 317
326 if (hasTransform) { 318 if (hasTransform) {
327 RenderBox* box = renderBox();
328 ASSERT(box);
329 m_transform->reset(); 319 m_transform->reset();
330 box->style()->applyTransform(*m_transform, box->borderBoxRect().size()); 320 renderer()->style()->applyTransform(*m_transform, renderer()->borderBoxR ect().size());
331 } 321 }
332 } 322 }
333 323
334 void RenderLayer::setHasVisibleContent(bool b) 324 void RenderLayer::setHasVisibleContent(bool b)
335 { 325 {
336 if (m_hasVisibleContent == b && !m_visibleContentStatusDirty) 326 if (m_hasVisibleContent == b && !m_visibleContentStatusDirty)
337 return; 327 return;
338 m_visibleContentStatusDirty = false; 328 m_visibleContentStatusDirty = false;
339 m_hasVisibleContent = b; 329 m_hasVisibleContent = b;
340 if (m_hasVisibleContent) { 330 if (m_hasVisibleContent) {
341 RenderBoxModelObject* repaintContainer = renderer()->containerForRepaint (); 331 RenderBox* repaintContainer = renderer()->containerForRepaint();
342 m_repaintRect = renderer()->clippedOverflowRectForRepaint(repaintContain er); 332 m_repaintRect = renderer()->clippedOverflowRectForRepaint(repaintContain er);
343 m_outlineBox = renderer()->outlineBoundsForRepaint(repaintContainer); 333 m_outlineBox = renderer()->outlineBoundsForRepaint(repaintContainer);
344 if (!isOverflowOnly()) 334 if (!isOverflowOnly())
345 dirtyStackingContextZOrderLists(); 335 dirtyStackingContextZOrderLists();
346 } 336 }
347 if (parent()) 337 if (parent())
348 parent()->childVisibilityChanged(m_hasVisibleContent); 338 parent()->childVisibilityChanged(m_hasVisibleContent);
349 } 339 }
350 340
351 void RenderLayer::dirtyVisibleContentStatus() 341 void RenderLayer::dirtyVisibleContentStatus()
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 } 411 }
422 m_visibleContentStatusDirty = false; 412 m_visibleContentStatusDirty = false;
423 } 413 }
424 } 414 }
425 415
426 void RenderLayer::updateLayerPosition() 416 void RenderLayer::updateLayerPosition()
427 { 417 {
428 // Clear our cached clip rect information. 418 // Clear our cached clip rect information.
429 clearClipRects(); 419 clearClipRects();
430 420
431 RenderBox* rendererBox = renderBox(); 421 int x = renderer()->x();
432 422 int y = renderer()->y();
433 int x = rendererBox ? rendererBox->x() : 0;
434 int y = rendererBox ? rendererBox->y() : 0;
435 423
436 if (!renderer()->isPositioned() && renderer()->parent()) { 424 if (!renderer()->isPositioned() && renderer()->parent()) {
437 // We must adjust our position by walking up the render tree looking for the 425 // We must adjust our position by walking up the render tree looking for the
438 // nearest enclosing object with a layer. 426 // nearest enclosing object with a layer.
439 RenderObject* curr = renderer()->parent(); 427 RenderBox* curr = renderer()->parentBox();
440 while (curr && !curr->hasLayer()) { 428 while (curr && !curr->hasLayer()) {
441 if (curr->isBox() && !curr->isTableRow()) { 429 if (!curr->isTableRow()) {
442 // Rows and cells share the same coordinate space (that of the s ection). 430 // Rows and cells share the same coordinate space (that of the s ection).
443 // Omit them when computing our xpos/ypos. 431 // Omit them when computing our xpos/ypos.
444 RenderBox* currBox = toRenderBox(curr); 432 x += curr->x();
445 x += currBox->x(); 433 y += curr->y();
446 y += currBox->y();
447 } 434 }
448 curr = curr->parent(); 435 curr = curr->parentBox();
449 } 436 }
450 if (curr->isBox() && curr->isTableRow()) { 437 if (curr->isTableRow()) {
451 // Put ourselves into the row coordinate space. 438 // Put ourselves into the row coordinate space.
452 RenderBox* currBox = toRenderBox(curr); 439 x -= curr->x();
453 x -= currBox->x(); 440 y -= curr->y();
454 y -= currBox->y();
455 } 441 }
456 } 442 }
457 443
458 m_relX = m_relY = 0; 444 m_relX = m_relY = 0;
459 if (renderer()->isRelPositioned()) { 445 if (renderer()->isRelPositioned()) {
460 m_relX = renderer()->relativePositionOffsetX(); 446 m_relX = renderer()->relativePositionOffsetX();
461 m_relY = renderer()->relativePositionOffsetY(); 447 m_relY = renderer()->relativePositionOffsetY();
462 x += m_relX; y += m_relY; 448 x += m_relX; y += m_relY;
463 } 449 }
464 450
465 // Subtract our parent's scroll offset. 451 // Subtract our parent's scroll offset.
466 if (renderer()->isPositioned() && enclosingPositionedAncestor()) { 452 if (renderer()->isPositioned() && enclosingPositionedAncestor()) {
467 RenderLayer* positionedParent = enclosingPositionedAncestor(); 453 RenderLayer* positionedParent = enclosingPositionedAncestor();
468 454
469 // For positioned layers, we subtract out the enclosing positioned layer 's scroll offset. 455 // For positioned layers, we subtract out the enclosing positioned layer 's scroll offset.
470 positionedParent->subtractScrolledContentOffset(x, y); 456 positionedParent->subtractScrolledContentOffset(x, y);
471 457
472 if (renderer()->isPositioned() && positionedParent->renderer()->isRelPos itioned() && positionedParent->renderer()->isRenderInline()) { 458 if (renderer()->isPositioned() && positionedParent->renderer()->isRelPos itioned() && positionedParent->renderer()->isRenderInline()) {
473 IntSize offset = toRenderInline(positionedParent->renderer())->relat ivePositionedInlineOffset(toRenderBox(renderer())); 459 IntSize offset = toRenderInline(positionedParent->renderer())->relat ivePositionedInlineOffset(renderer());
474 x += offset.width(); 460 x += offset.width();
475 y += offset.height(); 461 y += offset.height();
476 } 462 }
477 } else if (parent()) 463 } else if (parent())
478 parent()->subtractScrolledContentOffset(x, y); 464 parent()->subtractScrolledContentOffset(x, y);
479 465
480 // FIXME: We'd really like to just get rid of the concept of a layer rectang le and rely on the renderers. 466 // FIXME: We'd really like to just get rid of the concept of a layer rectang le and rely on the renderers.
481 467
482 setPos(x, y); 468 setPos(x, y);
483 469
484 if (renderer()->isRenderInline()) { 470 if (renderer()->isRenderInline()) {
485 RenderInline* inlineFlow = toRenderInline(renderer()); 471 RenderInline* inlineFlow = toRenderInline(renderer());
486 IntRect lineBox = inlineFlow->linesBoundingBox(); 472 IntRect lineBox = inlineFlow->linesBoundingBox();
487 setWidth(lineBox.width()); 473 setWidth(lineBox.width());
488 setHeight(lineBox.height()); 474 setHeight(lineBox.height());
489 } else if (RenderBox* box = renderBox()) { 475 } else {
490 setWidth(box->width()); 476 setWidth(renderer()->width());
491 setHeight(box->height()); 477 setHeight(renderer()->height());
492 478
493 if (!box->hasOverflowClip()) { 479 if (!renderer()->hasOverflowClip()) {
494 if (box->overflowWidth() > box->width()) 480 if (renderer()->overflowWidth() > renderer()->width())
495 setWidth(box->overflowWidth()); 481 setWidth(renderer()->overflowWidth());
496 if (box->overflowHeight() > box->height()) 482 if (renderer()->overflowHeight() > renderer()->height())
497 setHeight(box->overflowHeight()); 483 setHeight(renderer()->overflowHeight());
498 } 484 }
499 } 485 }
500 } 486 }
501 487
502 RenderLayer *RenderLayer::stackingContext() const 488 RenderLayer *RenderLayer::stackingContext() const
503 { 489 {
504 RenderLayer* curr = parent(); 490 RenderLayer* curr = parent();
505 for ( ; curr && !curr->renderer()->isRenderView() && !curr->renderer()->isRo ot() && 491 for ( ; curr && !curr->renderer()->isRenderView() && !curr->renderer()->isRo ot() &&
506 curr->renderer()->style()->hasAutoZIndex(); 492 curr->renderer()->style()->hasAutoZIndex();
507 curr = curr->parent()) { } 493 curr = curr->parent()) { }
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
871 857
872 void 858 void
873 RenderLayer::subtractScrolledContentOffset(int& x, int& y) const 859 RenderLayer::subtractScrolledContentOffset(int& x, int& y) const
874 { 860 {
875 x -= scrollXOffset() + m_scrollLeftOverflow; 861 x -= scrollXOffset() + m_scrollLeftOverflow;
876 y -= scrollYOffset(); 862 y -= scrollYOffset();
877 } 863 }
878 864
879 void RenderLayer::scrollToOffset(int x, int y, bool updateScrollbars, bool repai nt) 865 void RenderLayer::scrollToOffset(int x, int y, bool updateScrollbars, bool repai nt)
880 { 866 {
881 RenderBox* box = renderBox(); 867 if (renderer()->style()->overflowX() != OMARQUEE) {
882 if (!box)
883 return;
884
885 if (box->style()->overflowX() != OMARQUEE) {
886 if (x < 0) x = 0; 868 if (x < 0) x = 0;
887 if (y < 0) y = 0; 869 if (y < 0) y = 0;
888 870
889 // Call the scrollWidth/Height functions so that the dimensions will be computed if they need 871 // Call the scrollWidth/Height functions so that the dimensions will be computed if they need
890 // to be (for overflow:hidden blocks). 872 // to be (for overflow:hidden blocks).
891 int maxX = scrollWidth() - box->clientWidth(); 873 int maxX = scrollWidth() - renderer()->clientWidth();
892 int maxY = scrollHeight() - box->clientHeight(); 874 int maxY = scrollHeight() - renderer()->clientHeight();
893 875
894 if (x > maxX) x = maxX; 876 if (x > maxX) x = maxX;
895 if (y > maxY) y = maxY; 877 if (y > maxY) y = maxY;
896 } 878 }
897 879
898 // FIXME: Eventually, we will want to perform a blit. For now never 880 // FIXME: Eventually, we will want to perform a blit. For now never
899 // blit, since the check for blitting is going to be very 881 // blit, since the check for blitting is going to be very
900 // complicated (since it will involve testing whether our layer 882 // complicated (since it will involve testing whether our layer
901 // is either occluded by another layer or clipped by an enclosing 883 // is either occluded by another layer or clipped by an enclosing
902 // layer or contains fixed backgrounds, etc.). 884 // layer or contains fixed backgrounds, etc.).
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
941 if (updateScrollbars) { 923 if (updateScrollbars) {
942 if (m_hBar) 924 if (m_hBar)
943 m_hBar->setValue(scrollXOffset()); 925 m_hBar->setValue(scrollXOffset());
944 if (m_vBar) 926 if (m_vBar)
945 m_vBar->setValue(m_scrollY); 927 m_vBar->setValue(m_scrollY);
946 } 928 }
947 929
948 // Schedule the scroll DOM event. 930 // Schedule the scroll DOM event.
949 if (view) { 931 if (view) {
950 if (FrameView* frameView = view->frameView()) 932 if (FrameView* frameView = view->frameView())
951 frameView->scheduleEvent(Event::create(eventNames().scrollEvent, fal se, false), renderer()->element()); 933 frameView->scheduleEvent(Event::create(eventNames().scrollEvent, fal se, false), EventTargetNodeCast(renderer()->element()));
952 } 934 }
953 } 935 }
954 936
955 void RenderLayer::scrollRectToVisible(const IntRect &rect, bool scrollToAnchor, const ScrollAlignment& alignX, const ScrollAlignment& alignY) 937 void RenderLayer::scrollRectToVisible(const IntRect &rect, bool scrollToAnchor, const ScrollAlignment& alignX, const ScrollAlignment& alignY)
956 { 938 {
957 RenderLayer* parentLayer = 0; 939 RenderLayer* parentLayer = 0;
958 IntRect newRect = rect; 940 IntRect newRect = rect;
959 int xOffset = 0, yOffset = 0; 941 int xOffset = 0, yOffset = 0;
960 942
961 // We may end up propagating a scroll event. It is important that we suspend events until 943 // We may end up propagating a scroll event. It is important that we suspend events until
962 // the end of the function since they could delete the layer or the layer's renderer(). 944 // the end of the function since they could delete the layer or the layer's renderer().
963 FrameView* frameView = renderer()->document()->view(); 945 FrameView* frameView = renderer()->document()->view();
964 if (frameView) 946 if (frameView)
965 frameView->pauseScheduledEvents(); 947 frameView->pauseScheduledEvents();
966 948
967 bool restrictedByLineClamp = false; 949 bool restrictedByLineClamp = false;
968 if (renderer()->parent()) { 950 if (renderer()->parent()) {
969 parentLayer = renderer()->parent()->enclosingLayer(); 951 parentLayer = renderer()->parent()->enclosingLayer();
970 restrictedByLineClamp = renderer()->parent()->style()->lineClamp() >= 0; 952 restrictedByLineClamp = renderer()->parent()->style()->lineClamp() >= 0;
971 } 953 }
972 954
973 if (renderer()->hasOverflowClip() && !restrictedByLineClamp) { 955 if (renderer()->hasOverflowClip() && !restrictedByLineClamp) {
974 // Don't scroll to reveal an overflow layer that is restricted by the -w ebkit-line-clamp property. 956 // Don't scroll to reveal an overflow layer that is restricted by the -w ebkit-line-clamp property.
975 // This will prevent us from revealing text hidden by the slider in Safa ri RSS. 957 // This will prevent us from revealing text hidden by the slider in Safa ri RSS.
976 RenderBox* box = renderBox(); 958 FloatPoint absPos = renderer()->localToAbsolute();
977 ASSERT(box); 959 absPos.move(renderer()->borderLeft(), renderer()->borderTop());
978 FloatPoint absPos = box->localToAbsolute();
979 absPos.move(box->borderLeft(), box->borderTop());
980 960
981 IntRect layerBounds = IntRect(absPos.x() + scrollXOffset(), absPos.y() + scrollYOffset(), box->clientWidth(), box->clientHeight()); 961 IntRect layerBounds = IntRect(absPos.x() + scrollXOffset(), absPos.y() + scrollYOffset(), renderer()->clientWidth(), renderer()->clientHeight());
982 IntRect exposeRect = IntRect(rect.x() + scrollXOffset(), rect.y() + scro llYOffset(), rect.width(), rect.height()); 962 IntRect exposeRect = IntRect(rect.x() + scrollXOffset(), rect.y() + scro llYOffset(), rect.width(), rect.height());
983 IntRect r = getRectToExpose(layerBounds, exposeRect, alignX, alignY); 963 IntRect r = getRectToExpose(layerBounds, exposeRect, alignX, alignY);
984 964
985 xOffset = r.x() - absPos.x(); 965 xOffset = r.x() - absPos.x();
986 yOffset = r.y() - absPos.y(); 966 yOffset = r.y() - absPos.y();
987 // Adjust offsets if they're outside of the allowable range. 967 // Adjust offsets if they're outside of the allowable range.
988 xOffset = max(0, min(scrollWidth() - layerBounds.width(), xOffset)); 968 xOffset = max(0, min(scrollWidth() - layerBounds.width(), xOffset));
989 yOffset = max(0, min(scrollHeight() - layerBounds.height(), yOffset)); 969 yOffset = max(0, min(scrollHeight() - layerBounds.height(), yOffset));
990 970
991 if (xOffset != scrollXOffset() || yOffset != scrollYOffset()) { 971 if (xOffset != scrollXOffset() || yOffset != scrollYOffset()) {
992 int diffX = scrollXOffset(); 972 int diffX = scrollXOffset();
993 int diffY = scrollYOffset(); 973 int diffY = scrollYOffset();
994 scrollToOffset(xOffset, yOffset); 974 scrollToOffset(xOffset, yOffset);
995 diffX = scrollXOffset() - diffX; 975 diffX = scrollXOffset() - diffX;
996 diffY = scrollYOffset() - diffY; 976 diffY = scrollYOffset() - diffY;
997 newRect.setX(rect.x() - diffX); 977 newRect.setX(rect.x() - diffX);
998 newRect.setY(rect.y() - diffY); 978 newRect.setY(rect.y() - diffY);
999 } 979 }
1000 } else if (!parentLayer && renderer()->isBox() && renderBox()->canBePrograma ticallyScrolled(scrollToAnchor)) { 980 } else if (!parentLayer && renderer()->canBeProgramaticallyScrolled(scrollTo Anchor)) {
1001 if (frameView) { 981 if (frameView) {
1002 if (renderer()->document() && renderer()->document()->ownerElement() && renderer()->document()->ownerElement()->renderer()) { 982 if (renderer()->document() && renderer()->document()->ownerElement() && renderer()->document()->ownerElement()->renderer()) {
1003 IntRect viewRect = frameView->visibleContentRect(); 983 IntRect viewRect = frameView->visibleContentRect();
1004 IntRect r = getRectToExpose(viewRect, rect, alignX, alignY); 984 IntRect r = getRectToExpose(viewRect, rect, alignX, alignY);
1005 985
1006 xOffset = r.x(); 986 xOffset = r.x();
1007 yOffset = r.y(); 987 yOffset = r.y();
1008 // Adjust offsets if they're outside of the allowable range. 988 // Adjust offsets if they're outside of the allowable range.
1009 xOffset = max(0, min(frameView->contentsWidth(), xOffset)); 989 xOffset = max(0, min(frameView->contentsWidth(), xOffset));
1010 yOffset = max(0, min(frameView->contentsHeight(), yOffset)); 990 yOffset = max(0, min(frameView->contentsHeight(), yOffset));
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
1250 bool hasHorizontalBar = layer->horizontalScrollbar(); 1230 bool hasHorizontalBar = layer->horizontalScrollbar();
1251 bool hasVerticalBar = layer->verticalScrollbar(); 1231 bool hasVerticalBar = layer->verticalScrollbar();
1252 bool hasResizer = layer->renderer()->style()->resize() != RESIZE_NONE; 1232 bool hasResizer = layer->renderer()->style()->resize() != RESIZE_NONE;
1253 if ((hasHorizontalBar && hasVerticalBar) || (hasResizer && (hasHorizontalBar || hasVerticalBar))) 1233 if ((hasHorizontalBar && hasVerticalBar) || (hasResizer && (hasHorizontalBar || hasVerticalBar)))
1254 return cornerRect(layer, bounds); 1234 return cornerRect(layer, bounds);
1255 return IntRect(); 1235 return IntRect();
1256 } 1236 }
1257 1237
1258 static IntRect resizerCornerRect(const RenderLayer* layer, const IntRect& bounds ) 1238 static IntRect resizerCornerRect(const RenderLayer* layer, const IntRect& bounds )
1259 { 1239 {
1260 ASSERT(layer->renderer()->isBox());
1261 if (layer->renderer()->style()->resize() == RESIZE_NONE) 1240 if (layer->renderer()->style()->resize() == RESIZE_NONE)
1262 return IntRect(); 1241 return IntRect();
1263 return cornerRect(layer, bounds); 1242 return cornerRect(layer, bounds);
1264 } 1243 }
1265 1244
1266 bool RenderLayer::scrollbarCornerPresent() const 1245 bool RenderLayer::scrollbarCornerPresent() const
1267 { 1246 {
1268 ASSERT(renderer()->isBox()); 1247 return !scrollCornerRect(this, renderer()->borderBoxRect()).isEmpty();
1269 return !scrollCornerRect(this, renderBox()->borderBoxRect()).isEmpty();
1270 } 1248 }
1271 1249
1272 void RenderLayer::invalidateScrollbarRect(Scrollbar* scrollbar, const IntRect& r ect) 1250 void RenderLayer::invalidateScrollbarRect(Scrollbar* scrollbar, const IntRect& r ect)
1273 { 1251 {
1274 IntRect scrollRect = rect; 1252 IntRect scrollRect = rect;
1275 RenderBox* box = renderBox();
1276 ASSERT(box);
1277 if (scrollbar == m_vBar.get()) 1253 if (scrollbar == m_vBar.get())
1278 scrollRect.move(box->width() - box->borderRight() - box->width(), box->b orderTop()); 1254 scrollRect.move(renderer()->width() - renderer()->borderRight() - scroll bar->width(), renderer()->borderTop());
1279 else 1255 else
1280 scrollRect.move(box->borderLeft(), box->height() - box->borderBottom() - scrollbar->height()); 1256 scrollRect.move(renderer()->borderLeft(), renderer()->height() - rendere r()->borderBottom() - scrollbar->height());
1281 renderer()->repaintRectangle(scrollRect); 1257 renderer()->repaintRectangle(scrollRect);
1282 } 1258 }
1283 1259
1284 PassRefPtr<Scrollbar> RenderLayer::createScrollbar(ScrollbarOrientation orientat ion) 1260 PassRefPtr<Scrollbar> RenderLayer::createScrollbar(ScrollbarOrientation orientat ion)
1285 { 1261 {
1286 RefPtr<Scrollbar> widget; 1262 RefPtr<Scrollbar> widget;
1287 bool hasCustomScrollbarStyle = renderer()->node()->shadowAncestorNode()->ren derer()->style()->hasPseudoStyle(SCROLLBAR); 1263 bool hasCustomScrollbarStyle = renderer()->node()->shadowAncestorNode()->ren derer()->style()->hasPseudoStyle(SCROLLBAR);
1288 if (hasCustomScrollbarStyle) 1264 if (hasCustomScrollbarStyle)
1289 widget = RenderScrollbar::createCustomScrollbar(this, orientation, rende rer()->node()->shadowAncestorNode()->renderBox()); 1265 widget = RenderScrollbar::createCustomScrollbar(this, orientation, rende rer()->node()->shadowAncestorNode()->renderBox());
1290 else 1266 else
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1369 IntPoint bottomRight(width(), height()); 1345 IntPoint bottomRight(width(), height());
1370 IntPoint localPoint = absoluteToContents(absolutePoint); 1346 IntPoint localPoint = absoluteToContents(absolutePoint);
1371 return localPoint - bottomRight; 1347 return localPoint - bottomRight;
1372 } 1348 }
1373 1349
1374 void RenderLayer::positionOverflowControls(int tx, int ty) 1350 void RenderLayer::positionOverflowControls(int tx, int ty)
1375 { 1351 {
1376 if (!m_hBar && !m_vBar && (!renderer()->hasOverflowClip() || renderer()->sty le()->resize() == RESIZE_NONE)) 1352 if (!m_hBar && !m_vBar && (!renderer()->hasOverflowClip() || renderer()->sty le()->resize() == RESIZE_NONE))
1377 return; 1353 return;
1378 1354
1379 RenderBox* box = renderBox(); 1355 IntRect borderBox = renderer()->borderBoxRect();
1380 if (!box)
1381 return;
1382
1383 IntRect borderBox = box->borderBoxRect();
1384 IntRect scrollCorner(scrollCornerRect(this, borderBox)); 1356 IntRect scrollCorner(scrollCornerRect(this, borderBox));
1385 IntRect absBounds(borderBox.x() + tx, borderBox.y() + ty, borderBox.width(), borderBox.height()); 1357 IntRect absBounds(borderBox.x() + tx, borderBox.y() + ty, borderBox.width(), borderBox.height());
1386 if (m_vBar) 1358 if (m_vBar)
1387 m_vBar->setFrameRect(IntRect(absBounds.right() - box->borderRight() - m_ vBar->width(), 1359 m_vBar->setFrameRect(IntRect(absBounds.right() - renderer()->borderRight () - m_vBar->width(),
1388 absBounds.y() + box->borderTop(), 1360 absBounds.y() + renderer()->borderTop(),
1389 m_vBar->width(), 1361 m_vBar->width(),
1390 absBounds.height() - (box->borderTop() + bo x->borderBottom()) - scrollCorner.height())); 1362 absBounds.height() - (renderer()->borderTop () + renderer()->borderBottom()) - scrollCorner.height()));
1391 1363
1392 if (m_hBar) 1364 if (m_hBar)
1393 m_hBar->setFrameRect(IntRect(absBounds.x() + box->borderLeft(), 1365 m_hBar->setFrameRect(IntRect(absBounds.x() + renderer()->borderLeft(),
1394 absBounds.bottom() - box->borderBottom() - m_hBar->height(), 1366 absBounds.bottom() - renderer()->borderBott om() - m_hBar->height(),
1395 absBounds.width() - (box->borderLeft() + bo x->borderRight()) - scrollCorner.width(), 1367 absBounds.width() - (renderer()->borderLeft () + renderer()->borderRight()) - scrollCorner.width(),
1396 m_hBar->height())); 1368 m_hBar->height()));
1397 1369
1398 if (m_scrollCorner) 1370 if (m_scrollCorner)
1399 m_scrollCorner->setFrameRect(scrollCorner); 1371 m_scrollCorner->setFrameRect(scrollCorner);
1400 if (m_resizer) 1372 if (m_resizer)
1401 m_resizer->setFrameRect(resizerCornerRect(this, borderBox)); 1373 m_resizer->setFrameRect(resizerCornerRect(this, borderBox));
1402 } 1374 }
1403 1375
1404 int RenderLayer::scrollWidth() 1376 int RenderLayer::scrollWidth()
1405 { 1377 {
1406 if (m_scrollDimensionsDirty) 1378 if (m_scrollDimensionsDirty)
1407 computeScrollDimensions(); 1379 computeScrollDimensions();
1408 return m_scrollWidth; 1380 return m_scrollWidth;
1409 } 1381 }
1410 1382
1411 int RenderLayer::scrollHeight() 1383 int RenderLayer::scrollHeight()
1412 { 1384 {
1413 if (m_scrollDimensionsDirty) 1385 if (m_scrollDimensionsDirty)
1414 computeScrollDimensions(); 1386 computeScrollDimensions();
1415 return m_scrollHeight; 1387 return m_scrollHeight;
1416 } 1388 }
1417 1389
1418 void RenderLayer::computeScrollDimensions(bool* needHBar, bool* needVBar) 1390 void RenderLayer::computeScrollDimensions(bool* needHBar, bool* needVBar)
1419 { 1391 {
1420 RenderBox* box = renderBox();
1421 ASSERT(box);
1422
1423 m_scrollDimensionsDirty = false; 1392 m_scrollDimensionsDirty = false;
1424 1393
1425 bool ltr = renderer()->style()->direction() == LTR; 1394 bool ltr = renderer()->style()->direction() == LTR;
1426 1395
1427 int clientWidth = box->clientWidth(); 1396 int clientWidth = renderer()->clientWidth();
1428 int clientHeight = box->clientHeight(); 1397 int clientHeight = renderer()->clientHeight();
1429 1398
1430 m_scrollLeftOverflow = ltr ? 0 : min(0, box->leftmostPosition(true, false) - box->borderLeft()); 1399 m_scrollLeftOverflow = ltr ? 0 : min(0, renderer()->leftmostPosition(true, f alse) - renderer()->borderLeft());
1431 1400
1432 int rightPos = ltr ? 1401 int rightPos = ltr ?
1433 box->rightmostPosition(true, false) - box->borderLeft() : 1402 renderer()->rightmostPosition(true, false) - renderer()->bor derLeft() :
1434 clientWidth - m_scrollLeftOverflow; 1403 clientWidth - m_scrollLeftOverflow;
1435 int bottomPos = renderer()->lowestPosition(true, false) - box->borderTop(); 1404 int bottomPos = renderer()->lowestPosition(true, false) - renderer()->border Top();
1436 1405
1437 m_scrollWidth = max(rightPos, clientWidth); 1406 m_scrollWidth = max(rightPos, clientWidth);
1438 m_scrollHeight = max(bottomPos, clientHeight); 1407 m_scrollHeight = max(bottomPos, clientHeight);
1439 1408
1440 m_scrollOriginX = ltr ? 0 : m_scrollWidth - clientWidth; 1409 m_scrollOriginX = ltr ? 0 : m_scrollWidth - clientWidth;
1441 1410
1442 if (needHBar) 1411 if (needHBar)
1443 *needHBar = rightPos > clientWidth; 1412 *needHBar = rightPos > clientWidth;
1444 if (needVBar) 1413 if (needVBar)
1445 *needVBar = bottomPos > clientHeight; 1414 *needVBar = bottomPos > clientHeight;
(...skipping 11 matching lines...) Expand all
1457 1426
1458 bool horizontalOverflowChanged = (m_horizontalOverflow != horizontalOverflow ); 1427 bool horizontalOverflowChanged = (m_horizontalOverflow != horizontalOverflow );
1459 bool verticalOverflowChanged = (m_verticalOverflow != verticalOverflow); 1428 bool verticalOverflowChanged = (m_verticalOverflow != verticalOverflow);
1460 1429
1461 if (horizontalOverflowChanged || verticalOverflowChanged) { 1430 if (horizontalOverflowChanged || verticalOverflowChanged) {
1462 m_horizontalOverflow = horizontalOverflow; 1431 m_horizontalOverflow = horizontalOverflow;
1463 m_verticalOverflow = verticalOverflow; 1432 m_verticalOverflow = verticalOverflow;
1464 1433
1465 if (FrameView* frameView = renderer()->document()->view()) { 1434 if (FrameView* frameView = renderer()->document()->view()) {
1466 frameView->scheduleEvent(OverflowEvent::create(horizontalOverflowCha nged, horizontalOverflow, verticalOverflowChanged, verticalOverflow), 1435 frameView->scheduleEvent(OverflowEvent::create(horizontalOverflowCha nged, horizontalOverflow, verticalOverflowChanged, verticalOverflow),
1467 renderer()->element()); 1436 EventTargetNodeCast(renderer()->element()));
1468 } 1437 }
1469 } 1438 }
1470 } 1439 }
1471 1440
1472 void 1441 void
1473 RenderLayer::updateScrollInfoAfterLayout() 1442 RenderLayer::updateScrollInfoAfterLayout()
1474 { 1443 {
1475 RenderBox* box = renderBox();
1476 if (!box)
1477 return;
1478
1479 m_scrollDimensionsDirty = true; 1444 m_scrollDimensionsDirty = true;
1480 1445
1481 bool horizontalOverflow, verticalOverflow; 1446 bool horizontalOverflow, verticalOverflow;
1482 computeScrollDimensions(&horizontalOverflow, &verticalOverflow); 1447 computeScrollDimensions(&horizontalOverflow, &verticalOverflow);
1483 1448
1484 if (box->style()->overflowX() != OMARQUEE) { 1449 if (renderer()->style()->overflowX() != OMARQUEE) {
1485 // Layout may cause us to be in an invalid scroll position. In this cas e we need 1450 // Layout may cause us to be in an invalid scroll position. In this cas e we need
1486 // to pull our scroll offsets back to the max (or push them up to the mi n). 1451 // to pull our scroll offsets back to the max (or push them up to the mi n).
1487 int newX = max(0, min(scrollXOffset(), scrollWidth() - box->clientWidth( ))); 1452 int newX = max(0, min(scrollXOffset(), scrollWidth() - renderer()->clien tWidth()));
1488 int newY = max(0, min(m_scrollY, scrollHeight() - box->clientHeight())); 1453 int newY = max(0, min(m_scrollY, scrollHeight() - renderer()->clientHeig ht()));
1489 if (newX != scrollXOffset() || newY != m_scrollY) { 1454 if (newX != scrollXOffset() || newY != m_scrollY) {
1490 RenderView* view = renderer()->view(); 1455 RenderView* view = renderer()->view();
1491 ASSERT(view); 1456 ASSERT(view);
1492 // scrollToOffset() may call updateLayerPositions(), which doesn't w ork 1457 // scrollToOffset() may call updateLayerPositions(), which doesn't w ork
1493 // with LayoutState. 1458 // with LayoutState.
1494 // FIXME: Remove the disableLayoutState/enableLayoutState if the abo ve changes. 1459 // FIXME: Remove the disableLayoutState/enableLayoutState if the abo ve changes.
1495 if (view) 1460 if (view)
1496 view->disableLayoutState(); 1461 view->disableLayoutState();
1497 scrollToOffset(newX, newY); 1462 scrollToOffset(newX, newY);
1498 if (view) 1463 if (view)
(...skipping 11 matching lines...) Expand all
1510 m_vBar->setEnabled(verticalOverflow); 1475 m_vBar->setEnabled(verticalOverflow);
1511 1476
1512 // A dynamic change from a scrolling overflow to overflow:hidden means we ne ed to get rid of any 1477 // A dynamic change from a scrolling overflow to overflow:hidden means we ne ed to get rid of any
1513 // scrollbars that may be present. 1478 // scrollbars that may be present.
1514 if (renderer()->style()->overflowX() == OHIDDEN && haveHorizontalBar) 1479 if (renderer()->style()->overflowX() == OHIDDEN && haveHorizontalBar)
1515 setHasHorizontalScrollbar(false); 1480 setHasHorizontalScrollbar(false);
1516 if (renderer()->style()->overflowY() == OHIDDEN && haveVerticalBar) 1481 if (renderer()->style()->overflowY() == OHIDDEN && haveVerticalBar)
1517 setHasVerticalScrollbar(false); 1482 setHasVerticalScrollbar(false);
1518 1483
1519 // overflow:auto may need to lay out again if scrollbars got added/removed. 1484 // overflow:auto may need to lay out again if scrollbars got added/removed.
1520 bool scrollbarsChanged = (box->hasAutoHorizontalScrollbar() && haveHorizonta lBar != horizontalOverflow) || 1485 bool scrollbarsChanged = (renderer()->hasAutoHorizontalScrollbar() && haveHo rizontalBar != horizontalOverflow) ||
1521 (box->hasAutoVerticalScrollbar() && haveVerticalBar != verticalOverflow); 1486 (renderer()->hasAutoVerticalScrollbar() && haveVert icalBar != verticalOverflow);
1522 if (scrollbarsChanged) { 1487 if (scrollbarsChanged) {
1523 if (box->hasAutoHorizontalScrollbar()) 1488 if (renderer()->hasAutoHorizontalScrollbar())
1524 setHasHorizontalScrollbar(horizontalOverflow); 1489 setHasHorizontalScrollbar(horizontalOverflow);
1525 if (box->hasAutoVerticalScrollbar()) 1490 if (renderer()->hasAutoVerticalScrollbar())
1526 setHasVerticalScrollbar(verticalOverflow); 1491 setHasVerticalScrollbar(verticalOverflow);
1527 1492
1528 #if ENABLE(DASHBOARD_SUPPORT) 1493 #if ENABLE(DASHBOARD_SUPPORT)
1529 // Force an update since we know the scrollbars have changed things. 1494 // Force an update since we know the scrollbars have changed things.
1530 if (renderer()->document()->hasDashboardRegions()) 1495 if (renderer()->document()->hasDashboardRegions())
1531 renderer()->document()->setDashboardRegionsDirty(true); 1496 renderer()->document()->setDashboardRegionsDirty(true);
1532 #endif 1497 #endif
1533 1498
1534 renderer()->repaint(); 1499 renderer()->repaint();
1535 1500
1536 if (renderer()->style()->overflowX() == OAUTO || renderer()->style()->ov erflowY() == OAUTO) { 1501 if (renderer()->style()->overflowX() == OAUTO || renderer()->style()->ov erflowY() == OAUTO) {
1537 if (!m_inOverflowRelayout) { 1502 if (!m_inOverflowRelayout) {
1538 // Our proprietary overflow: overlay value doesn't trigger a lay out. 1503 // Our proprietary overflow: overlay value doesn't trigger a lay out.
1539 m_inOverflowRelayout = true; 1504 m_inOverflowRelayout = true;
1540 renderer()->setNeedsLayout(true, false); 1505 renderer()->setNeedsLayout(true, false);
1541 if (renderer()->isRenderBlock()) 1506 if (renderer()->isRenderBlock())
1542 toRenderBlock(renderer())->layoutBlock(true); 1507 toRenderBlock(renderer())->layoutBlock(true);
1543 else 1508 else
1544 renderer()->layout(); 1509 renderer()->layout();
1545 m_inOverflowRelayout = false; 1510 m_inOverflowRelayout = false;
1546 } 1511 }
1547 } 1512 }
1548 } 1513 }
1549 1514
1550 // If overflow:scroll is turned into overflow:auto a bar might still be disa bled (Bug 11985). 1515 // If overflow:scroll is turned into overflow:auto a bar might still be disa bled (Bug 11985).
1551 if (m_hBar && box->hasAutoHorizontalScrollbar()) 1516 if (m_hBar && renderer()->hasAutoHorizontalScrollbar())
1552 m_hBar->setEnabled(true); 1517 m_hBar->setEnabled(true);
1553 if (m_vBar && box->hasAutoVerticalScrollbar()) 1518 if (m_vBar && renderer()->hasAutoVerticalScrollbar())
1554 m_vBar->setEnabled(true); 1519 m_vBar->setEnabled(true);
1555 1520
1556 // Set up the range (and page step/line step). 1521 // Set up the range (and page step/line step).
1557 if (m_hBar) { 1522 if (m_hBar) {
1558 int clientWidth = box->clientWidth(); 1523 int clientWidth = renderer()->clientWidth();
1559 int pageStep = (clientWidth - cAmountToKeepWhenPaging); 1524 int pageStep = (clientWidth - cAmountToKeepWhenPaging);
1560 if (pageStep < 0) pageStep = clientWidth; 1525 if (pageStep < 0) pageStep = clientWidth;
1561 m_hBar->setSteps(cScrollbarPixelsPerLineStep, pageStep); 1526 m_hBar->setSteps(cScrollbarPixelsPerLineStep, pageStep);
1562 m_hBar->setProportion(clientWidth, m_scrollWidth); 1527 m_hBar->setProportion(clientWidth, m_scrollWidth);
1563 m_hBar->setValue(scrollXOffset()); 1528 m_hBar->setValue(scrollXOffset());
1564 } 1529 }
1565 if (m_vBar) { 1530 if (m_vBar) {
1566 int clientHeight = box->clientHeight(); 1531 int clientHeight = renderer()->clientHeight();
1567 int pageStep = (clientHeight - cAmountToKeepWhenPaging); 1532 int pageStep = (clientHeight - cAmountToKeepWhenPaging);
1568 if (pageStep < 0) pageStep = clientHeight; 1533 if (pageStep < 0) pageStep = clientHeight;
1569 m_vBar->setSteps(cScrollbarPixelsPerLineStep, pageStep); 1534 m_vBar->setSteps(cScrollbarPixelsPerLineStep, pageStep);
1570 m_vBar->setProportion(clientHeight, m_scrollHeight); 1535 m_vBar->setProportion(clientHeight, m_scrollHeight);
1571 } 1536 }
1572 1537
1573 if (renderer()->element() && renderer()->document()->hasListenerType(Documen t::OVERFLOWCHANGED_LISTENER)) 1538 if (renderer()->element() && renderer()->document()->hasListenerType(Documen t::OVERFLOWCHANGED_LISTENER))
1574 updateOverflowStatus(horizontalOverflow, verticalOverflow); 1539 updateOverflowStatus(horizontalOverflow, verticalOverflow);
1575 } 1540 }
1576 1541
(...skipping 17 matching lines...) Expand all
1594 // We fill our scroll corner with white if we have a scrollbar that doesn't run all the way up to the 1559 // We fill our scroll corner with white if we have a scrollbar that doesn't run all the way up to the
1595 // edge of the box. 1560 // edge of the box.
1596 paintScrollCorner(context, tx, ty, damageRect); 1561 paintScrollCorner(context, tx, ty, damageRect);
1597 1562
1598 // Paint our resizer last, since it sits on top of the scroll corner. 1563 // Paint our resizer last, since it sits on top of the scroll corner.
1599 paintResizer(context, tx, ty, damageRect); 1564 paintResizer(context, tx, ty, damageRect);
1600 } 1565 }
1601 1566
1602 void RenderLayer::paintScrollCorner(GraphicsContext* context, int tx, int ty, co nst IntRect& damageRect) 1567 void RenderLayer::paintScrollCorner(GraphicsContext* context, int tx, int ty, co nst IntRect& damageRect)
1603 { 1568 {
1604 RenderBox* box = renderBox(); 1569 IntRect cornerRect = scrollCornerRect(this, renderer()->borderBoxRect());
1605 ASSERT(box);
1606
1607 IntRect cornerRect = scrollCornerRect(this, box->borderBoxRect());
1608 IntRect absRect = IntRect(cornerRect.x() + tx, cornerRect.y() + ty, cornerRe ct.width(), cornerRect.height()); 1570 IntRect absRect = IntRect(cornerRect.x() + tx, cornerRect.y() + ty, cornerRe ct.width(), cornerRect.height());
1609 if (!absRect.intersects(damageRect)) 1571 if (!absRect.intersects(damageRect))
1610 return; 1572 return;
1611 1573
1612 if (context->updatingControlTints()) { 1574 if (context->updatingControlTints()) {
1613 updateScrollCornerStyle(); 1575 updateScrollCornerStyle();
1614 return; 1576 return;
1615 } 1577 }
1616 1578
1617 if (m_scrollCorner) { 1579 if (m_scrollCorner) {
1618 m_scrollCorner->paintIntoRect(context, tx, ty, absRect); 1580 m_scrollCorner->paintIntoRect(context, tx, ty, absRect);
1619 return; 1581 return;
1620 } 1582 }
1621 1583
1622 context->fillRect(absRect, Color::white); 1584 context->fillRect(absRect, Color::white);
1623 } 1585 }
1624 1586
1625 void RenderLayer::paintResizer(GraphicsContext* context, int tx, int ty, const I ntRect& damageRect) 1587 void RenderLayer::paintResizer(GraphicsContext* context, int tx, int ty, const I ntRect& damageRect)
1626 { 1588 {
1627 if (renderer()->style()->resize() == RESIZE_NONE) 1589 if (renderer()->style()->resize() == RESIZE_NONE)
1628 return; 1590 return;
1629 1591
1630 RenderBox* box = renderBox(); 1592 IntRect cornerRect = resizerCornerRect(this, renderer()->borderBoxRect());
1631 ASSERT(box);
1632
1633 IntRect cornerRect = resizerCornerRect(this, box->borderBoxRect());
1634 IntRect absRect = IntRect(cornerRect.x() + tx, cornerRect.y() + ty, cornerRe ct.width(), cornerRect.height()); 1593 IntRect absRect = IntRect(cornerRect.x() + tx, cornerRect.y() + ty, cornerRe ct.width(), cornerRect.height());
1635 if (!absRect.intersects(damageRect)) 1594 if (!absRect.intersects(damageRect))
1636 return; 1595 return;
1637 1596
1638 if (context->updatingControlTints()) { 1597 if (context->updatingControlTints()) {
1639 updateResizerStyle(); 1598 updateResizerStyle();
1640 return; 1599 return;
1641 } 1600 }
1642 1601
1643 if (m_resizer) { 1602 if (m_resizer) {
(...skipping 18 matching lines...) Expand all
1662 context->drawRect(largerCorner); 1621 context->drawRect(largerCorner);
1663 context->restore(); 1622 context->restore();
1664 } 1623 }
1665 } 1624 }
1666 1625
1667 bool RenderLayer::isPointInResizeControl(const IntPoint& absolutePoint) const 1626 bool RenderLayer::isPointInResizeControl(const IntPoint& absolutePoint) const
1668 { 1627 {
1669 if (!renderer()->hasOverflowClip() || renderer()->style()->resize() == RESIZ E_NONE) 1628 if (!renderer()->hasOverflowClip() || renderer()->style()->resize() == RESIZ E_NONE)
1670 return false; 1629 return false;
1671 1630
1672 RenderBox* box = renderBox();
1673 ASSERT(box);
1674
1675 IntPoint localPoint = absoluteToContents(absolutePoint); 1631 IntPoint localPoint = absoluteToContents(absolutePoint);
1676 1632
1677 IntRect localBounds(0, 0, box->width(), box->height()); 1633 IntRect localBounds(0, 0, renderer()->width(), renderer()->height());
1678 return resizerCornerRect(this, localBounds).contains(localPoint); 1634 return resizerCornerRect(this, localBounds).contains(localPoint);
1679 } 1635 }
1680 1636
1681 bool RenderLayer::hitTestOverflowControls(HitTestResult& result) 1637 bool RenderLayer::hitTestOverflowControls(HitTestResult& result)
1682 { 1638 {
1683 if (!m_hBar && !m_vBar && (!renderer()->hasOverflowClip() || renderer()->sty le()->resize() == RESIZE_NONE)) 1639 if (!m_hBar && !m_vBar && (!renderer()->hasOverflowClip() || renderer()->sty le()->resize() == RESIZE_NONE))
1684 return false; 1640 return false;
1685 1641
1686 RenderBox* box = renderBox();
1687 ASSERT(box);
1688
1689 int x = 0; 1642 int x = 0;
1690 int y = 0; 1643 int y = 0;
1691 convertToLayerCoords(root(), x, y); 1644 convertToLayerCoords(root(), x, y);
1692 IntRect absBounds(x, y, box->width(), box->height()); 1645 IntRect absBounds(x, y, renderer()->width(), renderer()->height());
1693 1646
1694 IntRect resizeControlRect; 1647 IntRect resizeControlRect;
1695 if (renderer()->style()->resize() != RESIZE_NONE) { 1648 if (renderer()->style()->resize() != RESIZE_NONE) {
1696 resizeControlRect = resizerCornerRect(this, absBounds); 1649 resizeControlRect = resizerCornerRect(this, absBounds);
1697 if (resizeControlRect.contains(result.point())) 1650 if (resizeControlRect.contains(result.point()))
1698 return true; 1651 return true;
1699 } 1652 }
1700 1653
1701 int resizeControlSize = max(resizeControlRect.height(), 0); 1654 int resizeControlSize = max(resizeControlRect.height(), 0);
1702 1655
1703 if (m_vBar) { 1656 if (m_vBar) {
1704 IntRect vBarRect(absBounds.right() - box->borderRight() - m_vBar->width( ), 1657 IntRect vBarRect(absBounds.right() - renderer()->borderRight() - m_vBar- >width(), absBounds.y() + renderer()->borderTop(), m_vBar->width(), absBounds.he ight() - (renderer()->borderTop() + renderer()->borderBottom()) - (m_hBar ? m_hB ar->height() : resizeControlSize));
1705 absBounds.y() + box->borderTop(),
1706 m_vBar->width(),
1707 absBounds.height() - (box->borderTop() + box->borderBot tom()) - (m_hBar ? m_hBar->height() : resizeControlSize));
1708 if (vBarRect.contains(result.point())) { 1658 if (vBarRect.contains(result.point())) {
1709 result.setScrollbar(m_vBar.get()); 1659 result.setScrollbar(m_vBar.get());
1710 return true; 1660 return true;
1711 } 1661 }
1712 } 1662 }
1713 1663
1714 resizeControlSize = max(resizeControlRect.width(), 0); 1664 resizeControlSize = max(resizeControlRect.width(), 0);
1715 if (m_hBar) { 1665 if (m_hBar) {
1716 IntRect hBarRect(absBounds.x() + box->borderLeft(), 1666 IntRect hBarRect(absBounds.x() + renderer()->borderLeft(), absBounds.bot tom() - renderer()->borderBottom() - m_hBar->height(), absBounds.width() - (rend erer()->borderLeft() + renderer()->borderRight()) - (m_vBar ? m_vBar->width() : resizeControlSize), m_hBar->height());
1717 absBounds.bottom() - box->borderBottom() - m_hBar->heig ht(),
1718 absBounds.width() - (box->borderLeft() + box->borderRig ht()) - (m_vBar ? m_vBar->width() : resizeControlSize),
1719 m_hBar->height());
1720 if (hBarRect.contains(result.point())) { 1667 if (hBarRect.contains(result.point())) {
1721 result.setScrollbar(m_hBar.get()); 1668 result.setScrollbar(m_hBar.get());
1722 return true; 1669 return true;
1723 } 1670 }
1724 } 1671 }
1725 1672
1726 return false; 1673 return false;
1727 } 1674 }
1728 1675
1729 bool RenderLayer::scroll(ScrollDirection direction, ScrollGranularity granularit y, float multiplier) 1676 bool RenderLayer::scroll(ScrollDirection direction, ScrollGranularity granularit y, float multiplier)
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1849 m_paintingInsideReflection = true; 1796 m_paintingInsideReflection = true;
1850 reflectionLayer()->paintLayer(rootLayer, p, paintDirtyRect, haveTranspar ency, paintRestriction, paintingRoot, false, temporaryClipRects); 1797 reflectionLayer()->paintLayer(rootLayer, p, paintDirtyRect, haveTranspar ency, paintRestriction, paintingRoot, false, temporaryClipRects);
1851 m_paintingInsideReflection = false; 1798 m_paintingInsideReflection = false;
1852 } 1799 }
1853 1800
1854 // Calculate the clip rects we should use. 1801 // Calculate the clip rects we should use.
1855 IntRect layerBounds, damageRect, clipRectToApply, outlineRect; 1802 IntRect layerBounds, damageRect, clipRectToApply, outlineRect;
1856 calculateRects(rootLayer, paintDirtyRect, layerBounds, damageRect, clipRectT oApply, outlineRect, temporaryClipRects); 1803 calculateRects(rootLayer, paintDirtyRect, layerBounds, damageRect, clipRectT oApply, outlineRect, temporaryClipRects);
1857 int x = layerBounds.x(); 1804 int x = layerBounds.x();
1858 int y = layerBounds.y(); 1805 int y = layerBounds.y();
1859 int tx = x - renderBoxX(); 1806 int tx = x - renderer()->x();
1860 int ty = y - renderBoxY(); 1807 int ty = y - renderer()->y();
1861 1808
1862 // Ensure our lists are up-to-date. 1809 // Ensure our lists are up-to-date.
1863 updateLayerListsIfNeeded(); 1810 updateLayerListsIfNeeded();
1864 1811
1865 bool selectionOnly = paintRestriction == PaintRestrictionSelectionOnly || pa intRestriction == PaintRestrictionSelectionOnlyBlackText; 1812 bool selectionOnly = paintRestriction == PaintRestrictionSelectionOnly || pa intRestriction == PaintRestrictionSelectionOnlyBlackText;
1866 bool forceBlackText = paintRestriction == PaintRestrictionSelectionOnlyBlack Text; 1813 bool forceBlackText = paintRestriction == PaintRestrictionSelectionOnlyBlack Text;
1867 1814
1868 // If this layer's renderer is a child of the paintingRoot, we render uncond itionally, which 1815 // If this layer's renderer is a child of the paintingRoot, we render uncond itionally, which
1869 // is done by passing a nil paintingRoot down to our renderer (as if no pain tingRoot was ever set). 1816 // is done by passing a nil paintingRoot down to our renderer (as if no pain tingRoot was ever set).
1870 // Else, our renderer tree may or may not contain the painting root, so we p ass that root along 1817 // Else, our renderer tree may or may not contain the painting root, so we p ass that root along
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
2072 for (int i = m_overflowList->size() - 1; i >= 0; --i) { 2019 for (int i = m_overflowList->size() - 1; i >= 0; --i) {
2073 insideLayer = m_overflowList->at(i)->hitTestLayer(rootLayer, request , result, hitTestRect, hitTestPoint); 2020 insideLayer = m_overflowList->at(i)->hitTestLayer(rootLayer, request , result, hitTestRect, hitTestPoint);
2074 if (insideLayer) 2021 if (insideLayer)
2075 return insideLayer; 2022 return insideLayer;
2076 } 2023 }
2077 } 2024 }
2078 2025
2079 // Next we want to see if the mouse pos is inside the child RenderObjects of the layer. 2026 // Next we want to see if the mouse pos is inside the child RenderObjects of the layer.
2080 if (fgRect.contains(hitTestPoint) && 2027 if (fgRect.contains(hitTestPoint) &&
2081 renderer()->hitTest(request, result, hitTestPoint, 2028 renderer()->hitTest(request, result, hitTestPoint,
2082 layerBounds.x() - renderBoxX(), 2029 layerBounds.x() - renderer()->x(),
2083 layerBounds.y() - renderBoxY(), 2030 layerBounds.y() - renderer()->y(),
2084 HitTestDescendants)) { 2031 HitTestDescendants)) {
2085 // For positioned generated content, we might still not have a 2032 // For positioned generated content, we might still not have a
2086 // node by the time we get to the layer level, since none of 2033 // node by the time we get to the layer level, since none of
2087 // the content in the layer has an element. So just walk up 2034 // the content in the layer has an element. So just walk up
2088 // the tree. 2035 // the tree.
2089 if (!result.innerNode() || !result.innerNonSharedNode()) { 2036 if (!result.innerNode() || !result.innerNonSharedNode()) {
2090 Node* e = enclosingElement(); 2037 Node* e = enclosingElement();
2091 if (!result.innerNode()) 2038 if (!result.innerNode())
2092 result.setInnerNode(e); 2039 result.setInnerNode(e);
2093 if (!result.innerNonSharedNode()) 2040 if (!result.innerNonSharedNode())
2094 result.setInnerNonSharedNode(e); 2041 result.setInnerNonSharedNode(e);
2095 } 2042 }
2096 2043
2097 return this; 2044 return this;
2098 } 2045 }
2099 2046
2100 // Now check our negative z-index children. 2047 // Now check our negative z-index children.
2101 if (m_negZOrderList) { 2048 if (m_negZOrderList) {
2102 for (int i = m_negZOrderList->size() - 1; i >= 0; --i) { 2049 for (int i = m_negZOrderList->size() - 1; i >= 0; --i) {
2103 insideLayer = m_negZOrderList->at(i)->hitTestLayer(rootLayer, reques t, result, hitTestRect, hitTestPoint); 2050 insideLayer = m_negZOrderList->at(i)->hitTestLayer(rootLayer, reques t, result, hitTestRect, hitTestPoint);
2104 if (insideLayer) 2051 if (insideLayer)
2105 return insideLayer; 2052 return insideLayer;
2106 } 2053 }
2107 } 2054 }
2108 2055
2109 // Next we want to see if the mouse is inside this layer but not any of its children. 2056 // Next we want to see if the mouse is inside this layer but not any of its children.
2110 if (bgRect.contains(hitTestPoint) && 2057 if (bgRect.contains(hitTestPoint) &&
2111 renderer()->hitTest(request, result, hitTestPoint, 2058 renderer()->hitTest(request, result, hitTestPoint,
2112 layerBounds.x() - renderBoxX(), 2059 layerBounds.x() - renderer()->x(),
2113 layerBounds.y() - renderBoxY(), 2060 layerBounds.y() - renderer()->y(),
2114 HitTestSelf)) { 2061 HitTestSelf)) {
2115 if (!result.innerNode() || !result.innerNonSharedNode()) { 2062 if (!result.innerNode() || !result.innerNonSharedNode()) {
2116 Node* e = enclosingElement(); 2063 Node* e = enclosingElement();
2117 if (!result.innerNode()) 2064 if (!result.innerNode())
2118 result.setInnerNode(e); 2065 result.setInnerNode(e);
2119 if (!result.innerNonSharedNode()) 2066 if (!result.innerNonSharedNode())
2120 result.setInnerNonSharedNode(e); 2067 result.setInnerNonSharedNode(e);
2121 } 2068 }
2122 2069
2123 return this; 2070 return this;
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
2341 // Go from our first line box to our last line box. 2288 // Go from our first line box to our last line box.
2342 RenderInline* inlineFlow = toRenderInline(renderer()); 2289 RenderInline* inlineFlow = toRenderInline(renderer());
2343 InlineFlowBox* firstBox = inlineFlow->firstLineBox(); 2290 InlineFlowBox* firstBox = inlineFlow->firstLineBox();
2344 if (!firstBox) 2291 if (!firstBox)
2345 return result; 2292 return result;
2346 int top = firstBox->root()->topOverflow(); 2293 int top = firstBox->root()->topOverflow();
2347 int bottom = inlineFlow->lastLineBox()->root()->bottomOverflow(); 2294 int bottom = inlineFlow->lastLineBox()->root()->bottomOverflow();
2348 int left = firstBox->xPos(); 2295 int left = firstBox->xPos();
2349 for (InlineRunBox* curr = firstBox->nextLineBox(); curr; curr = curr->ne xtLineBox()) 2296 for (InlineRunBox* curr = firstBox->nextLineBox(); curr; curr = curr->ne xtLineBox())
2350 left = min(left, curr->xPos()); 2297 left = min(left, curr->xPos());
2351 result = IntRect(left, top, width(), bottom - top); 2298 result = IntRect(left, (top - renderer()->y()), width(), bottom - top);
2352 } else if (renderer()->isTableRow()) { 2299 } else if (renderer()->isTableRow()) {
2353 // Our bounding box is just the union of all of our cells' border/overfl ow rects. 2300 // Our bounding box is just the union of all of our cells' border/overfl ow rects.
2354 for (RenderObject* child = renderer()->firstChild(); child; child = chil d->nextSibling()) { 2301 for (RenderObject* child = renderer()->firstChild(); child; child = chil d->nextSibling()) {
2355 if (child->isTableCell()) { 2302 if (child->isTableCell()) {
2356 IntRect bbox = toRenderBox(child)->borderBoxRect(); 2303 IntRect bbox = toRenderBox(child)->borderBoxRect();
2357 result.unite(bbox); 2304 result.unite(bbox);
2358 IntRect overflowRect = renderBox()->overflowRect(false); 2305 IntRect overflowRect = renderer()->overflowRect(false);
2359 if (bbox != overflowRect) 2306 if (bbox != overflowRect)
2360 result.unite(overflowRect); 2307 result.unite(overflowRect);
2361 } 2308 }
2362 } 2309 }
2363 } else { 2310 } else {
2364 RenderBox* box = renderBox(); 2311 if (renderer()->hasMask())
2365 ASSERT(box); 2312 result = renderer()->maskClipRect();
2366 if (box->hasMask())
2367 result = box->maskClipRect();
2368 else { 2313 else {
2369 IntRect bbox = box->borderBoxRect(); 2314 IntRect bbox = renderer()->borderBoxRect();
2370 result = bbox; 2315 result = bbox;
2371 IntRect overflowRect = box->overflowRect(false); 2316 IntRect overflowRect = renderer()->overflowRect(false);
2372 if (bbox != overflowRect) 2317 if (bbox != overflowRect)
2373 result.unite(overflowRect); 2318 result.unite(overflowRect);
2374 } 2319 }
2375 } 2320 }
2376 2321
2377 RenderView* view = renderer()->view(); 2322 RenderView* view = renderer()->view();
2378 ASSERT(view); 2323 ASSERT(view);
2379 if (view) 2324 if (view)
2380 result.inflate(view->maximalOutlineSize()); // Used to apply a fudge fac tor to dirty-rect checks on blocks/tables. 2325 result.inflate(view->maximalOutlineSize()); // Used to apply a fudge fac tor to dirty-rect checks on blocks/tables.
2381 2326
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
2834 if (m_marquee) 2779 if (m_marquee)
2835 m_marquee->suspend(); 2780 m_marquee->suspend();
2836 2781
2837 for (RenderLayer* curr = firstChild(); curr; curr = curr->nextSibling()) 2782 for (RenderLayer* curr = firstChild(); curr; curr = curr->nextSibling())
2838 curr->suspendMarquees(); 2783 curr->suspendMarquees();
2839 } 2784 }
2840 2785
2841 } // namespace WebCore 2786 } // namespace WebCore
2842 2787
2843 2788
OLDNEW
« no previous file with comments | « third_party/WebKit/WebCore/rendering/RenderLayer.h ('k') | third_party/WebKit/WebCore/rendering/RenderLayerBacking.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698