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

Side by Side Diff: Source/core/rendering/RenderBoxModelObject.cpp

Issue 103213002: position:sticky should stick for the enclosing overflow ancestor (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add back changes in RenderBoxModelObject.cpp eaten by rebase. Created 6 years, 11 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
« no previous file with comments | « Source/core/rendering/RenderBoxModelObject.h ('k') | Source/core/rendering/RenderLayer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com)
6 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
7 * Copyright (C) 2010 Google Inc. All rights reserved. 7 * Copyright (C) 2010 Google Inc. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 if (current->isRenderNamedFlowThread()) 312 if (current->isRenderNamedFlowThread())
313 referencePoint = toRenderNamedFlowThread(current)->adjustedPosit ionRelativeToOffsetParent(*this, referencePoint); 313 referencePoint = toRenderNamedFlowThread(current)->adjustedPosit ionRelativeToOffsetParent(*this, referencePoint);
314 else if (offsetParent->isBox() && offsetParent->isBody() && !offsetP arent->isPositioned()) 314 else if (offsetParent->isBox() && offsetParent->isBody() && !offsetP arent->isPositioned())
315 referencePoint.moveBy(toRenderBox(offsetParent)->topLeftLocation ()); 315 referencePoint.moveBy(toRenderBox(offsetParent)->topLeftLocation ());
316 } 316 }
317 } 317 }
318 318
319 return referencePoint; 319 return referencePoint;
320 } 320 }
321 321
322 void RenderBoxModelObject::computeStickyPositionConstraints(StickyPositionViewpo rtConstraints& constraints, const FloatRect& viewportRect) const 322 void RenderBoxModelObject::computeStickyPositionConstraints(StickyPositionViewpo rtConstraints& constraints, const FloatRect& constrainingRect) const
323 { 323 {
324 RenderBlock* containingBlock = this->containingBlock(); 324 RenderBlock* containingBlock = this->containingBlock();
325 325
326 LayoutRect containerContentRect = containingBlock->contentBoxRect(); 326 LayoutRect containerContentRect = containingBlock->contentBoxRect();
327 LayoutUnit maxWidth = containingBlock->availableLogicalWidth(); 327 LayoutUnit maxWidth = containingBlock->availableLogicalWidth();
328 328
329 // Sticky positioned element ignore any override logical width on the contai ning block (as they don't call 329 // Sticky positioned element ignore any override logical width on the contai ning block (as they don't call
330 // containingBlockLogicalWidthForContent). It's unclear whether this is tota lly fine. 330 // containingBlockLogicalWidthForContent). It's unclear whether this is tota lly fine.
331 LayoutBoxExtent minMargin(minimumValueForLength(style()->marginTop(), maxWid th), 331 LayoutBoxExtent minMargin(minimumValueForLength(style()->marginTop(), maxWid th),
332 minimumValueForLength(style()->marginRight(), maxWidth), 332 minimumValueForLength(style()->marginRight(), maxWidth),
333 minimumValueForLength(style()->marginBottom(), maxWidth), 333 minimumValueForLength(style()->marginBottom(), maxWidth),
334 minimumValueForLength(style()->marginLeft(), maxWidth)); 334 minimumValueForLength(style()->marginLeft(), maxWidth));
335 335
336 // Compute the container-relative area within which the sticky element is al lowed to move. 336 // Compute the container-relative area within which the sticky element is al lowed to move.
337 containerContentRect.contract(minMargin); 337 containerContentRect.contract(minMargin);
338 // Map to the view to avoid including page scale factor. 338 // Map to the view to avoid including page scale factor.
339 constraints.setAbsoluteContainingBlockRect(containingBlock->localToContainer Quad(FloatRect(containerContentRect), view()).boundingBox()); 339 constraints.setAbsoluteContainingBlockRect(containingBlock->localToContainer Quad(FloatRect(containerContentRect), view()).boundingBox());
340 340
341 LayoutRect stickyBoxRect = frameRectForStickyPositioning(); 341 LayoutRect stickyBoxRect = frameRectForStickyPositioning();
342 LayoutRect flippedStickyBoxRect = stickyBoxRect; 342 LayoutRect flippedStickyBoxRect = stickyBoxRect;
343 containingBlock->flipForWritingMode(flippedStickyBoxRect); 343 containingBlock->flipForWritingMode(flippedStickyBoxRect);
344 LayoutPoint stickyLocation = flippedStickyBoxRect.location(); 344 LayoutPoint stickyLocation = flippedStickyBoxRect.location();
345 345
346 // FIXME: sucks to call localToAbsolute again, but we can't just offset from the previously computed rect if there are transforms. 346 // FIXME: sucks to call localToAbsolute again, but we can't just offset from the previously computed rect if there are transforms.
347 // Map to the view to avoid including page scale factor. 347 // Map to the view to avoid including page scale factor.
348 FloatRect absContainerFrame = containingBlock->localToContainerQuad(FloatRec t(FloatPoint(), containingBlock->size()), view()).boundingBox(); 348 FloatRect absContainerFrame = containingBlock->localToContainerQuad(FloatRec t(FloatPoint(), containingBlock->size()), view()).boundingBox();
349 349
350 if (containingBlock->hasOverflowClip()) {
351 IntSize scrollOffset = containingBlock->layer()->scrollableArea()->adjus tedScrollOffset();
352 stickyLocation -= scrollOffset;
353 }
354
350 // We can't call localToAbsolute on |this| because that will recur. FIXME: F or now, assume that |this| is not transformed. 355 // We can't call localToAbsolute on |this| because that will recur. FIXME: F or now, assume that |this| is not transformed.
351 FloatRect absoluteStickyBoxRect(absContainerFrame.location() + stickyLocatio n, flippedStickyBoxRect.size()); 356 FloatRect absoluteStickyBoxRect(absContainerFrame.location() + stickyLocatio n, flippedStickyBoxRect.size());
352 constraints.setAbsoluteStickyBoxRect(absoluteStickyBoxRect); 357 constraints.setAbsoluteStickyBoxRect(absoluteStickyBoxRect);
353 358
354 if (!style()->left().isAuto()) { 359 if (!style()->left().isAuto()) {
355 constraints.setLeftOffset(valueForLength(style()->left(), viewportRect.w idth())); 360 constraints.setLeftOffset(valueForLength(style()->left(), constrainingRe ct.width()));
356 constraints.addAnchorEdge(ViewportConstraints::AnchorEdgeLeft); 361 constraints.addAnchorEdge(ViewportConstraints::AnchorEdgeLeft);
357 } 362 }
358 363
359 if (!style()->right().isAuto()) { 364 if (!style()->right().isAuto()) {
360 constraints.setRightOffset(valueForLength(style()->right(), viewportRect .width())); 365 constraints.setRightOffset(valueForLength(style()->right(), constraining Rect.width()));
361 constraints.addAnchorEdge(ViewportConstraints::AnchorEdgeRight); 366 constraints.addAnchorEdge(ViewportConstraints::AnchorEdgeRight);
362 } 367 }
363 368
364 if (!style()->top().isAuto()) { 369 if (!style()->top().isAuto()) {
365 constraints.setTopOffset(valueForLength(style()->top(), viewportRect.hei ght())); 370 constraints.setTopOffset(valueForLength(style()->top(), constrainingRect .height()));
366 constraints.addAnchorEdge(ViewportConstraints::AnchorEdgeTop); 371 constraints.addAnchorEdge(ViewportConstraints::AnchorEdgeTop);
367 } 372 }
368 373
369 if (!style()->bottom().isAuto()) { 374 if (!style()->bottom().isAuto()) {
370 constraints.setBottomOffset(valueForLength(style()->bottom(), viewportRe ct.height())); 375 constraints.setBottomOffset(valueForLength(style()->bottom(), constraini ngRect.height() ));
371 constraints.addAnchorEdge(ViewportConstraints::AnchorEdgeBottom); 376 constraints.addAnchorEdge(ViewportConstraints::AnchorEdgeBottom);
372 } 377 }
373 } 378 }
374 379
375 LayoutSize RenderBoxModelObject::stickyPositionOffset() const 380 LayoutSize RenderBoxModelObject::stickyPositionOffset() const
376 { 381 {
377 LayoutRect viewportRect = view()->frameView()->viewportConstrainedVisibleCon tentRect(); 382 FloatRect constrainingRect;
383
384 ASSERT(hasLayer());
385 RenderLayer* enclosingClippingLayer = layer()->enclosingOverflowClipLayer(Ex cludeSelf);
386 if (enclosingClippingLayer) {
387 RenderBox* enclosingClippingBox = toRenderBox(enclosingClippingLayer->re nderer());
388 LayoutRect clipRect = enclosingClippingBox->overflowClipRect(LayoutPoint (), 0); // FIXME: make this work in regions.
389 constrainingRect = enclosingClippingBox->localToContainerQuad(FloatRect( clipRect), view()).boundingBox();
390 } else {
391 LayoutRect viewportRect = view()->frameView()->viewportConstrainedVisibl eContentRect();
392 constrainingRect = viewportRect;
393 }
378 394
379 StickyPositionViewportConstraints constraints; 395 StickyPositionViewportConstraints constraints;
380 computeStickyPositionConstraints(constraints, viewportRect); 396 computeStickyPositionConstraints(constraints, constrainingRect);
381 397
382 // The sticky offset is physical, so we can just return the delta computed i n absolute coords (though it may be wrong with transforms). 398 // The sticky offset is physical, so we can just return the delta computed i n absolute coords (though it may be wrong with transforms).
383 return LayoutSize(constraints.computeStickyOffset(viewportRect)); 399 return LayoutSize(constraints.computeStickyOffset(constrainingRect));
384 } 400 }
385 401
386 LayoutSize RenderBoxModelObject::offsetForInFlowPosition() const 402 LayoutSize RenderBoxModelObject::offsetForInFlowPosition() const
387 { 403 {
388 if (isRelPositioned()) 404 if (isRelPositioned())
389 return relativePositionOffset(); 405 return relativePositionOffset();
390 406
391 if (isStickyPositioned()) 407 if (isStickyPositioned())
392 return stickyPositionOffset(); 408 return stickyPositionOffset();
393 409
(...skipping 2420 matching lines...) Expand 10 before | Expand all | Expand 10 after
2814 ASSERT(!beforeChild || toBoxModelObject == beforeChild->parent()); 2830 ASSERT(!beforeChild || toBoxModelObject == beforeChild->parent());
2815 for (RenderObject* child = startChild; child && child != endChild; ) { 2831 for (RenderObject* child = startChild; child && child != endChild; ) {
2816 // Save our next sibling as moveChildTo will clear it. 2832 // Save our next sibling as moveChildTo will clear it.
2817 RenderObject* nextSibling = child->nextSibling(); 2833 RenderObject* nextSibling = child->nextSibling();
2818 moveChildTo(toBoxModelObject, child, beforeChild, fullRemoveInsert); 2834 moveChildTo(toBoxModelObject, child, beforeChild, fullRemoveInsert);
2819 child = nextSibling; 2835 child = nextSibling;
2820 } 2836 }
2821 } 2837 }
2822 2838
2823 } // namespace WebCore 2839 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderBoxModelObject.h ('k') | Source/core/rendering/RenderLayer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698