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

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

Issue 143323014: *** DO NOT LAND *** Attempt to understand Regions complexity Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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 | Annotate | Revision Log
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 19 matching lines...) Expand all
30 #include "core/frame/Settings.h" 30 #include "core/frame/Settings.h"
31 #include "core/html/HTMLFrameOwnerElement.h" 31 #include "core/html/HTMLFrameOwnerElement.h"
32 #include "core/page/scrolling/ScrollingConstraints.h" 32 #include "core/page/scrolling/ScrollingConstraints.h"
33 #include "core/rendering/CompositedLayerMapping.h" 33 #include "core/rendering/CompositedLayerMapping.h"
34 #include "core/rendering/ImageQualityController.h" 34 #include "core/rendering/ImageQualityController.h"
35 #include "core/rendering/RenderBlock.h" 35 #include "core/rendering/RenderBlock.h"
36 #include "core/rendering/RenderGeometryMap.h" 36 #include "core/rendering/RenderGeometryMap.h"
37 #include "core/rendering/RenderInline.h" 37 #include "core/rendering/RenderInline.h"
38 #include "core/rendering/RenderLayer.h" 38 #include "core/rendering/RenderLayer.h"
39 #include "core/rendering/RenderLayerCompositor.h" 39 #include "core/rendering/RenderLayerCompositor.h"
40 #include "core/rendering/RenderNamedFlowThread.h"
41 #include "core/rendering/RenderRegion.h"
42 #include "core/rendering/RenderView.h" 40 #include "core/rendering/RenderView.h"
43 #include "core/rendering/style/ShadowList.h" 41 #include "core/rendering/style/ShadowList.h"
44 #include "platform/geometry/TransformState.h" 42 #include "platform/geometry/TransformState.h"
45 #include "platform/graphics/DrawLooper.h" 43 #include "platform/graphics/DrawLooper.h"
46 #include "platform/graphics/GraphicsContextStateSaver.h" 44 #include "platform/graphics/GraphicsContextStateSaver.h"
47 #include "platform/graphics/Path.h" 45 #include "platform/graphics/Path.h"
48 #include "wtf/CurrentTime.h" 46 #include "wtf/CurrentTime.h"
49 47
50 using namespace std; 48 using namespace std;
51 49
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 // If the offsetParent of the element is null, or is the HTML body element, 279 // If the offsetParent of the element is null, or is the HTML body element,
282 // return the distance between the canvas origin and the left border edge 280 // return the distance between the canvas origin and the left border edge
283 // of the element and stop this algorithm. 281 // of the element and stop this algorithm.
284 Element* element = offsetParent(); 282 Element* element = offsetParent();
285 if (!element) 283 if (!element)
286 return referencePoint; 284 return referencePoint;
287 285
288 if (const RenderBoxModelObject* offsetParent = element->renderBoxModelObject ()) { 286 if (const RenderBoxModelObject* offsetParent = element->renderBoxModelObject ()) {
289 if (offsetParent->isBox() && !offsetParent->isBody()) 287 if (offsetParent->isBox() && !offsetParent->isBody())
290 referencePoint.move(-toRenderBox(offsetParent)->borderLeft(), -toRen derBox(offsetParent)->borderTop()); 288 referencePoint.move(-toRenderBox(offsetParent)->borderLeft(), -toRen derBox(offsetParent)->borderTop());
291 if (!isOutOfFlowPositioned() || flowThreadContainingBlock()) { 289 if (!isOutOfFlowPositioned()) {
292 if (isRelPositioned()) 290 if (isRelPositioned())
293 referencePoint.move(relativePositionOffset()); 291 referencePoint.move(relativePositionOffset());
294 else if (isStickyPositioned()) 292 else if (isStickyPositioned())
295 referencePoint.move(stickyPositionOffset()); 293 referencePoint.move(stickyPositionOffset());
296 294
297 // CSS regions specification says that region flows should return th e body element as their offsetParent.
298 // Since we will bypass the body’s renderer anyway, just end the loo p if we encounter a region flow (named flow thread).
299 // See http://dev.w3.org/csswg/css-regions/#cssomview-offset-attribu tes
300 RenderObject* current; 295 RenderObject* current;
301 for (current = parent(); current != offsetParent && !current->isRend erNamedFlowThread() && current->parent(); current = current->parent()) { 296 for (current = parent(); current != offsetParent && current->parent( ); current = current->parent()) {
302 // FIXME: What are we supposed to do inside SVG content? 297 // FIXME: What are we supposed to do inside SVG content?
303 if (!isOutOfFlowPositioned()) { 298 if (!isOutOfFlowPositioned()) {
304 if (current->isBox() && !current->isTableRow()) 299 if (current->isBox() && !current->isTableRow())
305 referencePoint.moveBy(toRenderBox(current)->topLeftLocat ion()); 300 referencePoint.moveBy(toRenderBox(current)->topLeftLocat ion());
306 referencePoint.move(current->parent()->offsetForColumns(refe rencePoint)); 301 referencePoint.move(current->parent()->offsetForColumns(refe rencePoint));
307 } 302 }
308 } 303 }
309 304
310 // Compute the offset position for elements inside named flow thread s for which the offsetParent was the body. 305 if (offsetParent->isBox() && offsetParent->isBody() && !offsetParent ->isPositioned())
311 // See https://code.google.com/p/chromium/issues/detail?id=242168
312 if (current->isRenderNamedFlowThread())
313 referencePoint = toRenderNamedFlowThread(current)->adjustedPosit ionRelativeToOffsetParent(*this, referencePoint);
314 else if (offsetParent->isBox() && offsetParent->isBody() && !offsetP arent->isPositioned())
315 referencePoint.moveBy(toRenderBox(offsetParent)->topLeftLocation ()); 306 referencePoint.moveBy(toRenderBox(offsetParent)->topLeftLocation ());
316 } 307 }
317 } 308 }
318 309
319 return referencePoint; 310 return referencePoint;
320 } 311 }
321 312
322 void RenderBoxModelObject::computeStickyPositionConstraints(StickyPositionViewpo rtConstraints& constraints, const FloatRect& constrainingRect) const 313 void RenderBoxModelObject::computeStickyPositionConstraints(StickyPositionViewpo rtConstraints& constraints, const FloatRect& constrainingRect) const
323 { 314 {
324 RenderBlock* containingBlock = this->containingBlock(); 315 RenderBlock* containingBlock = this->containingBlock();
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 } 369 }
379 370
380 LayoutSize RenderBoxModelObject::stickyPositionOffset() const 371 LayoutSize RenderBoxModelObject::stickyPositionOffset() const
381 { 372 {
382 FloatRect constrainingRect; 373 FloatRect constrainingRect;
383 374
384 ASSERT(hasLayer()); 375 ASSERT(hasLayer());
385 RenderLayer* enclosingClippingLayer = layer()->enclosingOverflowClipLayer(Ex cludeSelf); 376 RenderLayer* enclosingClippingLayer = layer()->enclosingOverflowClipLayer(Ex cludeSelf);
386 if (enclosingClippingLayer) { 377 if (enclosingClippingLayer) {
387 RenderBox* enclosingClippingBox = toRenderBox(enclosingClippingLayer->re nderer()); 378 RenderBox* enclosingClippingBox = toRenderBox(enclosingClippingLayer->re nderer());
388 LayoutRect clipRect = enclosingClippingBox->overflowClipRect(LayoutPoint (), 0); // FIXME: make this work in regions. 379 LayoutRect clipRect = enclosingClippingBox->overflowClipRect(LayoutPoint ());
389 constrainingRect = enclosingClippingBox->localToContainerQuad(FloatRect( clipRect), view()).boundingBox(); 380 constrainingRect = enclosingClippingBox->localToContainerQuad(FloatRect( clipRect), view()).boundingBox();
390 } else { 381 } else {
391 LayoutRect viewportRect = view()->frameView()->viewportConstrainedVisibl eContentRect(); 382 LayoutRect viewportRect = view()->frameView()->viewportConstrainedVisibl eContentRect();
392 constrainingRect = viewportRect; 383 constrainingRect = viewportRect;
393 } 384 }
394 385
395 StickyPositionViewportConstraints constraints; 386 StickyPositionViewportConstraints constraints;
396 computeStickyPositionConstraints(constraints, constrainingRect); 387 computeStickyPositionConstraints(constraints, constrainingRect);
397 388
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). 389 // The sticky offset is physical, so we can just return the delta computed i n absolute coords (though it may be wrong with transforms).
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 int bLeft = includeLeftEdge ? borderLeft() : 0; 610 int bLeft = includeLeftEdge ? borderLeft() : 0;
620 int bRight = includeRightEdge ? borderRight() : 0; 611 int bRight = includeRightEdge ? borderRight() : 0;
621 LayoutUnit pLeft = includeLeftEdge ? paddingLeft() : LayoutUnit(); 612 LayoutUnit pLeft = includeLeftEdge ? paddingLeft() : LayoutUnit();
622 LayoutUnit pRight = includeRightEdge ? paddingRight() : LayoutUnit(); 613 LayoutUnit pRight = includeRightEdge ? paddingRight() : LayoutUnit();
623 614
624 GraphicsContextStateSaver clipWithScrollingStateSaver(*context, clippedWithL ocalScrolling); 615 GraphicsContextStateSaver clipWithScrollingStateSaver(*context, clippedWithL ocalScrolling);
625 LayoutRect scrolledPaintRect = rect; 616 LayoutRect scrolledPaintRect = rect;
626 if (clippedWithLocalScrolling) { 617 if (clippedWithLocalScrolling) {
627 // Clip to the overflow area. 618 // Clip to the overflow area.
628 RenderBox* thisBox = toRenderBox(this); 619 RenderBox* thisBox = toRenderBox(this);
629 context->clip(thisBox->overflowClipRect(rect.location(), paintInfo.rende rRegion)); 620 context->clip(thisBox->overflowClipRect(rect.location()));
630 621
631 // Adjust the paint rect to reflect a scrolled content box with borders at the ends. 622 // Adjust the paint rect to reflect a scrolled content box with borders at the ends.
632 IntSize offset = thisBox->scrolledContentOffset(); 623 IntSize offset = thisBox->scrolledContentOffset();
633 scrolledPaintRect.move(-offset); 624 scrolledPaintRect.move(-offset);
634 scrolledPaintRect.setWidth(bLeft + thisBox->scrollWidth() + bRight); 625 scrolledPaintRect.setWidth(bLeft + thisBox->scrollWidth() + bRight);
635 scrolledPaintRect.setHeight(borderTop() + thisBox->scrollHeight() + bord erBottom()); 626 scrolledPaintRect.setHeight(borderTop() + thisBox->scrollHeight() + bord erBottom());
636 } 627 }
637 628
638 GraphicsContextStateSaver backgroundClipStateSaver(*context, false); 629 GraphicsContextStateSaver backgroundClipStateSaver(*context, false);
639 IntRect maskRect; 630 IntRect maskRect;
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 if (bgLayer->clip() == TextFillBox) { 750 if (bgLayer->clip() == TextFillBox) {
760 // Create the text mask layer. 751 // Create the text mask layer.
761 context->setCompositeOperation(CompositeDestinationIn); 752 context->setCompositeOperation(CompositeDestinationIn);
762 context->beginTransparencyLayer(1); 753 context->beginTransparencyLayer(1);
763 754
764 // FIXME: Workaround for https://code.google.com/p/skia/issues/detail?id =1291. 755 // FIXME: Workaround for https://code.google.com/p/skia/issues/detail?id =1291.
765 context->clearRect(maskRect); 756 context->clearRect(maskRect);
766 757
767 // Now draw the text into the mask. We do this by painting using a speci al paint phase that signals to 758 // Now draw the text into the mask. We do this by painting using a speci al paint phase that signals to
768 // InlineTextBoxes that they should just add their contents to the clip. 759 // InlineTextBoxes that they should just add their contents to the clip.
769 PaintInfo info(context, maskRect, PaintPhaseTextClip, PaintBehaviorForce BlackText, 0, paintInfo.renderRegion); 760 PaintInfo info(context, maskRect, PaintPhaseTextClip, PaintBehaviorForce BlackText, 0);
770 context->setCompositeOperation(CompositeSourceOver); 761 context->setCompositeOperation(CompositeSourceOver);
771 if (box) { 762 if (box) {
772 RootInlineBox* root = box->root(); 763 RootInlineBox* root = box->root();
773 box->paint(info, LayoutPoint(scrolledPaintRect.x() - box->x(), scrol ledPaintRect.y() - box->y()), root->lineTop(), root->lineBottom()); 764 box->paint(info, LayoutPoint(scrolledPaintRect.x() - box->x(), scrol ledPaintRect.y() - box->y()), root->lineTop(), root->lineBottom());
774 } else { 765 } else {
775 LayoutSize localOffset = isBox() ? toRenderBox(this)->locationOffset () : LayoutSize(); 766 LayoutSize localOffset = isBox() ? toRenderBox(this)->locationOffset () : LayoutSize();
776 paint(info, scrolledPaintRect.location() - localOffset); 767 paint(info, scrolledPaintRect.location() - localOffset);
777 } 768 }
778 769
779 context->endLayer(); 770 context->endLayer();
(...skipping 1950 matching lines...) Expand 10 before | Expand all | Expand 10 after
2730 2721
2731 void RenderBoxModelObject::mapAbsoluteToLocalPoint(MapCoordinatesFlags mode, Tra nsformState& transformState) const 2722 void RenderBoxModelObject::mapAbsoluteToLocalPoint(MapCoordinatesFlags mode, Tra nsformState& transformState) const
2732 { 2723 {
2733 // We don't expect to be called during layout. 2724 // We don't expect to be called during layout.
2734 ASSERT(!view() || !view()->layoutStateEnabled()); 2725 ASSERT(!view() || !view()->layoutStateEnabled());
2735 2726
2736 RenderObject* o = container(); 2727 RenderObject* o = container();
2737 if (!o) 2728 if (!o)
2738 return; 2729 return;
2739 2730
2740 // The point inside a box that's inside a region has its coordinates relativ e to the region,
2741 // not the FlowThread that is its container in the RenderObject tree.
2742 if (o->isRenderFlowThread() && isRenderBlock()) {
2743 // FIXME: switch to Box instead of Block when we'll have range informati on for boxes as well, not just for blocks.
2744 RenderRegion* startRegion;
2745 RenderRegion* ignoredEndRegion;
2746 toRenderFlowThread(o)->getRegionRangeForBox(toRenderBlock(this), startRe gion, ignoredEndRegion);
2747 // If there is no region to use the FlowThread, then there's no region r ange for the content in that FlowThread.
2748 // An API like elementFromPoint might crash without this check.
2749 if (startRegion)
2750 o = startRegion;
2751 }
2752
2753 o->mapAbsoluteToLocalPoint(mode, transformState); 2731 o->mapAbsoluteToLocalPoint(mode, transformState);
2754 2732
2755 LayoutSize containerOffset = offsetFromContainer(o, LayoutPoint()); 2733 LayoutSize containerOffset = offsetFromContainer(o, LayoutPoint());
2756 2734
2757 if (!style()->hasOutOfFlowPosition() && o->hasColumns()) { 2735 if (!style()->hasOutOfFlowPosition() && o->hasColumns()) {
2758 RenderBlock* block = toRenderBlock(o); 2736 RenderBlock* block = toRenderBlock(o);
2759 LayoutPoint point(roundedLayoutPoint(transformState.mappedPoint())); 2737 LayoutPoint point(roundedLayoutPoint(transformState.mappedPoint()));
2760 point -= containerOffset; 2738 point -= containerOffset;
2761 block->adjustForColumnRect(containerOffset, point); 2739 block->adjustForColumnRect(containerOffset, point);
2762 } 2740 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
2838 ASSERT(!beforeChild || toBoxModelObject == beforeChild->parent()); 2816 ASSERT(!beforeChild || toBoxModelObject == beforeChild->parent());
2839 for (RenderObject* child = startChild; child && child != endChild; ) { 2817 for (RenderObject* child = startChild; child && child != endChild; ) {
2840 // Save our next sibling as moveChildTo will clear it. 2818 // Save our next sibling as moveChildTo will clear it.
2841 RenderObject* nextSibling = child->nextSibling(); 2819 RenderObject* nextSibling = child->nextSibling();
2842 moveChildTo(toBoxModelObject, child, beforeChild, fullRemoveInsert); 2820 moveChildTo(toBoxModelObject, child, beforeChild, fullRemoveInsert);
2843 child = nextSibling; 2821 child = nextSibling;
2844 } 2822 }
2845 } 2823 }
2846 2824
2847 } // namespace WebCore 2825 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderBoxModelObject.h ('k') | Source/core/rendering/RenderBoxRegionInfo.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698