Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 2027 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2038 if (!hasOverhangingFloats()) | 2038 if (!hasOverhangingFloats()) |
| 2039 return; | 2039 return; |
| 2040 | 2040 |
| 2041 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); | 2041 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); |
| 2042 FloatingObjectSetIterator end = floatingObjectSet.end(); | 2042 FloatingObjectSetIterator end = floatingObjectSet.end(); |
| 2043 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++ it) { | 2043 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++ it) { |
| 2044 const FloatingObject& floatingObject = *it->get(); | 2044 const FloatingObject& floatingObject = *it->get(); |
| 2045 // Only issue paint invaldiations for the object if it is overhanging, i s not in its own layer, and | 2045 // Only issue paint invaldiations for the object if it is overhanging, i s not in its own layer, and |
| 2046 // is our responsibility to paint (m_shouldPaint is set). When paintAllD escendants is true, the latter | 2046 // is our responsibility to paint (m_shouldPaint is set). When paintAllD escendants is true, the latter |
| 2047 // condition is replaced with being a descendant of us. | 2047 // condition is replaced with being a descendant of us. |
| 2048 if (logicalBottomForFloat(floatingObject) > logicalHeight() | 2048 if (isOverhangingFloat(floatingObject) |
| 2049 && !floatingObject.layoutObject()->hasSelfPaintingLayer() | 2049 && !floatingObject.layoutObject()->hasSelfPaintingLayer() |
| 2050 && (floatingObject.shouldPaint() || (paintAllDescendants && floating Object.layoutObject()->isDescendantOf(this)))) { | 2050 && (floatingObject.shouldPaint() || (paintAllDescendants && floating Object.layoutObject()->isDescendantOf(this)))) { |
| 2051 | 2051 |
| 2052 LayoutBox* floatingLayoutBox = floatingObject.layoutObject(); | 2052 LayoutBox* floatingLayoutBox = floatingObject.layoutObject(); |
| 2053 floatingLayoutBox->setShouldDoFullPaintInvalidation(); | 2053 floatingLayoutBox->setShouldDoFullPaintInvalidation(); |
| 2054 floatingLayoutBox->invalidatePaintForOverhangingFloats(false); | 2054 floatingLayoutBox->invalidatePaintForOverhangingFloats(false); |
| 2055 } | 2055 } |
| 2056 } | 2056 } |
| 2057 } | 2057 } |
| 2058 | 2058 |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2454 bool LayoutBlockFlow::hasOverhangingFloat(LayoutBox* layoutBox) | 2454 bool LayoutBlockFlow::hasOverhangingFloat(LayoutBox* layoutBox) |
| 2455 { | 2455 { |
| 2456 if (!m_floatingObjects || !parent()) | 2456 if (!m_floatingObjects || !parent()) |
| 2457 return false; | 2457 return false; |
| 2458 | 2458 |
| 2459 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); | 2459 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); |
| 2460 FloatingObjectSetIterator it = floatingObjectSet.find<FloatingObjectHashTran slator>(layoutBox); | 2460 FloatingObjectSetIterator it = floatingObjectSet.find<FloatingObjectHashTran slator>(layoutBox); |
| 2461 if (it == floatingObjectSet.end()) | 2461 if (it == floatingObjectSet.end()) |
| 2462 return false; | 2462 return false; |
| 2463 | 2463 |
| 2464 return logicalBottomForFloat(*it->get()) > logicalHeight(); | 2464 return isOverhangingFloat(**it); |
| 2465 } | 2465 } |
| 2466 | 2466 |
| 2467 void LayoutBlockFlow::addIntrudingFloats(LayoutBlockFlow* prev, LayoutUnit logic alLeftOffset, LayoutUnit logicalTopOffset) | 2467 void LayoutBlockFlow::addIntrudingFloats(LayoutBlockFlow* prev, LayoutUnit logic alLeftOffset, LayoutUnit logicalTopOffset) |
| 2468 { | 2468 { |
| 2469 ASSERT(!avoidsFloats()); | 2469 ASSERT(!avoidsFloats()); |
| 2470 | 2470 |
| 2471 // If we create our own block formatting context then our contents don't int eract with floats outside it, even those from our parent. | 2471 // If we create our own block formatting context then our contents don't int eract with floats outside it, even those from our parent. |
| 2472 if (createsNewFormattingContext()) | 2472 if (createsNewFormattingContext()) |
| 2473 return; | 2473 return; |
| 2474 | 2474 |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2621 } | 2621 } |
| 2622 | 2622 |
| 2623 LayoutUnit LayoutBlockFlow::logicalRightFloatOffsetForLine(LayoutUnit logicalTop , LayoutUnit fixedOffset, LayoutUnit logicalHeight) const | 2623 LayoutUnit LayoutBlockFlow::logicalRightFloatOffsetForLine(LayoutUnit logicalTop , LayoutUnit fixedOffset, LayoutUnit logicalHeight) const |
| 2624 { | 2624 { |
| 2625 if (m_floatingObjects && m_floatingObjects->hasRightObjects()) | 2625 if (m_floatingObjects && m_floatingObjects->hasRightObjects()) |
| 2626 return m_floatingObjects->logicalRightOffset(fixedOffset, logicalTop, lo gicalHeight); | 2626 return m_floatingObjects->logicalRightOffset(fixedOffset, logicalTop, lo gicalHeight); |
| 2627 | 2627 |
| 2628 return fixedOffset; | 2628 return fixedOffset; |
| 2629 } | 2629 } |
| 2630 | 2630 |
| 2631 void LayoutBlockFlow::setAncestorShouldPaintFloatingObject(const LayoutBox& floa tBox, bool shouldPaint) | |
| 2632 { | |
| 2633 ASSERT(floatBox.isFloating()); | |
| 2634 ASSERT(!floatBox.hasSelfPaintingLayer()); | |
| 2635 for (LayoutObject* ancestor = floatBox.parent(); ancestor && ancestor->isLay outBlockFlow(); ancestor = ancestor->parent()) { | |
| 2636 LayoutBlockFlow* ancestorBlock = toLayoutBlockFlow(ancestor); | |
| 2637 FloatingObjects* ancestorFloatingObjects = ancestorBlock->m_floatingObje cts.get(); | |
| 2638 if (!ancestorFloatingObjects) | |
| 2639 break; | |
| 2640 FloatingObjectSet::iterator it = ancestorFloatingObjects->set().find<Flo atingObjectHashTranslator>(const_cast<LayoutBox*>(&floatBox)); | |
| 2641 if (it == ancestorFloatingObjects->set().end()) | |
| 2642 break; | |
| 2643 | |
| 2644 FloatingObject& floatingObject = **it; | |
| 2645 if (shouldPaint) { | |
| 2646 ASSERT(!floatingObject.shouldPaint()); | |
| 2647 if (ancestorBlock->hasSelfPaintingLayer() || !ancestorBlock->isOverh angingFloat(floatingObject)) { | |
|
chrishtr
2016/02/02 20:49:40
Please paste your explanatory comment here:
The r
Xianzhu
2016/02/02 22:47:12
Done.
| |
| 2648 floatingObject.setShouldPaint(true); | |
| 2649 return; | |
| 2650 } | |
| 2651 } else if (floatingObject.shouldPaint()) { | |
| 2652 floatingObject.setShouldPaint(false); | |
| 2653 return; | |
| 2654 } | |
| 2655 } | |
| 2656 // We should have found the ancestor to update shouldPaint flag. | |
| 2657 ASSERT_NOT_REACHED(); | |
| 2658 } | |
| 2659 | |
| 2631 IntRect alignSelectionRectToDevicePixels(LayoutRect& rect) | 2660 IntRect alignSelectionRectToDevicePixels(LayoutRect& rect) |
| 2632 { | 2661 { |
| 2633 LayoutUnit roundedX = LayoutUnit(rect.x().round()); | 2662 LayoutUnit roundedX = LayoutUnit(rect.x().round()); |
| 2634 return IntRect(roundedX, rect.y().round(), | 2663 return IntRect(roundedX, rect.y().round(), |
| 2635 (rect.maxX() - roundedX).round(), | 2664 (rect.maxX() - roundedX).round(), |
| 2636 snapSizeToPixel(rect.height(), rect.y())); | 2665 snapSizeToPixel(rect.height(), rect.y())); |
| 2637 } | 2666 } |
| 2638 | 2667 |
| 2639 bool LayoutBlockFlow::allowsPaginationStrut() const | 2668 bool LayoutBlockFlow::allowsPaginationStrut() const |
| 2640 { | 2669 { |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2835 FrameView* frameView = document().view(); | 2864 FrameView* frameView = document().view(); |
| 2836 LayoutUnit top = LayoutUnit((style()->position() == FixedPosition) ? 0 : fra meView->scrollOffset().height()); | 2865 LayoutUnit top = LayoutUnit((style()->position() == FixedPosition) ? 0 : fra meView->scrollOffset().height()); |
| 2837 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height( ); | 2866 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height( ); |
| 2838 if (size().height() < visibleHeight) | 2867 if (size().height() < visibleHeight) |
| 2839 top += (visibleHeight - size().height()) / 2; | 2868 top += (visibleHeight - size().height()) / 2; |
| 2840 setY(top); | 2869 setY(top); |
| 2841 dialog->setCentered(top); | 2870 dialog->setCentered(top); |
| 2842 } | 2871 } |
| 2843 | 2872 |
| 2844 } // namespace blink | 2873 } // namespace blink |
| OLD | NEW |