| OLD | NEW |
| 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) 2007 David Smith (catfish.man@gmail.com) | 4 * (C) 2007 David Smith (catfish.man@gmail.com) |
| 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
All rights reserved. | 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
All rights reserved. |
| 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
| 7 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #include "core/HTMLNames.h" | 27 #include "core/HTMLNames.h" |
| 28 #include "core/dom/AXObjectCache.h" | 28 #include "core/dom/AXObjectCache.h" |
| 29 #include "core/dom/Document.h" | 29 #include "core/dom/Document.h" |
| 30 #include "core/dom/Element.h" | 30 #include "core/dom/Element.h" |
| 31 #include "core/dom/StyleEngine.h" | 31 #include "core/dom/StyleEngine.h" |
| 32 #include "core/dom/shadow/ShadowRoot.h" | 32 #include "core/dom/shadow/ShadowRoot.h" |
| 33 #include "core/editing/DragCaretController.h" | 33 #include "core/editing/DragCaretController.h" |
| 34 #include "core/editing/EditingUtilities.h" | 34 #include "core/editing/EditingUtilities.h" |
| 35 #include "core/editing/Editor.h" | 35 #include "core/editing/Editor.h" |
| 36 #include "core/editing/FrameSelection.h" | 36 #include "core/editing/FrameSelection.h" |
| 37 #include "core/fetch/ResourceLoadPriorityOptimizer.h" | |
| 38 #include "core/frame/FrameView.h" | 37 #include "core/frame/FrameView.h" |
| 39 #include "core/frame/LocalFrame.h" | 38 #include "core/frame/LocalFrame.h" |
| 40 #include "core/frame/Settings.h" | 39 #include "core/frame/Settings.h" |
| 41 #include "core/html/HTMLMarqueeElement.h" | 40 #include "core/html/HTMLMarqueeElement.h" |
| 42 #include "core/layout/HitTestLocation.h" | 41 #include "core/layout/HitTestLocation.h" |
| 43 #include "core/layout/HitTestResult.h" | 42 #include "core/layout/HitTestResult.h" |
| 44 #include "core/layout/LayoutAnalyzer.h" | 43 #include "core/layout/LayoutAnalyzer.h" |
| 45 #include "core/layout/LayoutDeprecatedFlexibleBox.h" | 44 #include "core/layout/LayoutDeprecatedFlexibleBox.h" |
| 46 #include "core/layout/LayoutFlexibleBox.h" | 45 #include "core/layout/LayoutFlexibleBox.h" |
| 47 #include "core/layout/LayoutFlowThread.h" | 46 #include "core/layout/LayoutFlowThread.h" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 continue; | 151 continue; |
| 153 HashSet<LayoutBlock*>* containerSet = it->value.get(); | 152 HashSet<LayoutBlock*>* containerSet = it->value.get(); |
| 154 ASSERT(containerSet->contains(block)); | 153 ASSERT(containerSet->contains(block)); |
| 155 containerSet->remove(block); | 154 containerSet->remove(block); |
| 156 if (containerSet->isEmpty()) | 155 if (containerSet->isEmpty()) |
| 157 containerMap->remove(it); | 156 containerMap->remove(it); |
| 158 } | 157 } |
| 159 } | 158 } |
| 160 } | 159 } |
| 161 | 160 |
| 162 static void appendImageIfNotNull(WillBeHeapVector<RawPtrWillBeMember<ImageResour
ce>>& imageResources, const StyleImage* styleImage) | |
| 163 { | |
| 164 if (styleImage && styleImage->cachedImage()) { | |
| 165 ImageResource* imageResource = styleImage->cachedImage(); | |
| 166 if (imageResource && !imageResource->isLoaded()) | |
| 167 imageResources.append(styleImage->cachedImage()); | |
| 168 } | |
| 169 } | |
| 170 | |
| 171 static void appendLayers(WillBeHeapVector<RawPtrWillBeMember<ImageResource>>& im
ages, const FillLayer& styleLayer) | |
| 172 { | |
| 173 for (const FillLayer* layer = &styleLayer; layer; layer = layer->next()) | |
| 174 appendImageIfNotNull(images, layer->image()); | |
| 175 } | |
| 176 | |
| 177 static void appendImagesFromStyle(WillBeHeapVector<RawPtrWillBeMember<ImageResou
rce>>& images, const ComputedStyle& blockStyle) | |
| 178 { | |
| 179 appendLayers(images, blockStyle.backgroundLayers()); | |
| 180 appendLayers(images, blockStyle.maskLayers()); | |
| 181 | |
| 182 const ContentData* contentData = blockStyle.contentData(); | |
| 183 if (contentData && contentData->isImage()) | |
| 184 appendImageIfNotNull(images, toImageContentData(contentData)->image()); | |
| 185 if (blockStyle.boxReflect()) | |
| 186 appendImageIfNotNull(images, blockStyle.boxReflect()->mask().image()); | |
| 187 appendImageIfNotNull(images, blockStyle.listStyleImage()); | |
| 188 appendImageIfNotNull(images, blockStyle.borderImageSource()); | |
| 189 appendImageIfNotNull(images, blockStyle.maskBoxImageSource()); | |
| 190 if (blockStyle.shapeOutside()) | |
| 191 appendImageIfNotNull(images, blockStyle.shapeOutside()->image()); | |
| 192 } | |
| 193 | |
| 194 void LayoutBlock::removeFromGlobalMaps() | 161 void LayoutBlock::removeFromGlobalMaps() |
| 195 { | 162 { |
| 196 if (gPercentHeightDescendantsMap) | 163 if (gPercentHeightDescendantsMap) |
| 197 removeBlockFromDescendantAndContainerMaps(this, gPercentHeightDescendant
sMap, gPercentHeightContainerMap); | 164 removeBlockFromDescendantAndContainerMaps(this, gPercentHeightDescendant
sMap, gPercentHeightContainerMap); |
| 198 if (gPositionedDescendantsMap) | 165 if (gPositionedDescendantsMap) |
| 199 removeBlockFromDescendantAndContainerMaps(this, gPositionedDescendantsMa
p, gPositionedContainerMap); | 166 removeBlockFromDescendantAndContainerMaps(this, gPositionedDescendantsMa
p, gPositionedContainerMap); |
| 200 } | 167 } |
| 201 | 168 |
| 202 LayoutBlock::~LayoutBlock() | 169 LayoutBlock::~LayoutBlock() |
| 203 { | 170 { |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 } | 290 } |
| 324 | 291 |
| 325 if (TextAutosizer* textAutosizer = document().textAutosizer()) | 292 if (TextAutosizer* textAutosizer = document().textAutosizer()) |
| 326 textAutosizer->record(this); | 293 textAutosizer->record(this); |
| 327 | 294 |
| 328 propagateStyleToAnonymousChildren(true); | 295 propagateStyleToAnonymousChildren(true); |
| 329 | 296 |
| 330 // It's possible for our border/padding to change, but for the overall logic
al width of the block to | 297 // It's possible for our border/padding to change, but for the overall logic
al width of the block to |
| 331 // end up being the same. We keep track of this change so in layoutBlock, we
can know to set relayoutChildren=true. | 298 // end up being the same. We keep track of this change so in layoutBlock, we
can know to set relayoutChildren=true. |
| 332 m_widthAvailableToChildrenChanged |= oldStyle && diff.needsFullLayout() && n
eedsLayout() && borderOrPaddingLogicalWidthChanged(*oldStyle, newStyle); | 299 m_widthAvailableToChildrenChanged |= oldStyle && diff.needsFullLayout() && n
eedsLayout() && borderOrPaddingLogicalWidthChanged(*oldStyle, newStyle); |
| 333 | |
| 334 // If the style has unloaded images, want to notify the ResourceLoadPriority
Optimizer so that | |
| 335 // network priorities can be set. | |
| 336 WillBeHeapVector<RawPtrWillBeMember<ImageResource>> images; | |
| 337 appendImagesFromStyle(images, newStyle); | |
| 338 if (images.isEmpty()) | |
| 339 ResourceLoadPriorityOptimizer::resourceLoadPriorityOptimizer()->removeLa
youtObject(this); | |
| 340 else | |
| 341 ResourceLoadPriorityOptimizer::resourceLoadPriorityOptimizer()->addLayou
tObject(this); | |
| 342 } | 300 } |
| 343 | 301 |
| 344 void LayoutBlock::invalidatePaintOfSubtreesIfNeeded(PaintInvalidationState& chil
dPaintInvalidationState) | 302 void LayoutBlock::invalidatePaintOfSubtreesIfNeeded(PaintInvalidationState& chil
dPaintInvalidationState) |
| 345 { | 303 { |
| 346 LayoutBox::invalidatePaintOfSubtreesIfNeeded(childPaintInvalidationState); | 304 LayoutBox::invalidatePaintOfSubtreesIfNeeded(childPaintInvalidationState); |
| 347 | 305 |
| 348 // Take care of positioned objects. This is required as PaintInvalidationSta
te keeps a single clip rect. | 306 // Take care of positioned objects. This is required as PaintInvalidationSta
te keeps a single clip rect. |
| 349 if (TrackedLayoutBoxListHashSet* positionedObjects = this->positionedObjects
()) { | 307 if (TrackedLayoutBoxListHashSet* positionedObjects = this->positionedObjects
()) { |
| 350 for (auto* box : *positionedObjects) { | 308 for (auto* box : *positionedObjects) { |
| 351 | 309 |
| (...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 940 layoutBlock(false); | 898 layoutBlock(false); |
| 941 | 899 |
| 942 // It's safe to check for control clip here, since controls can never be tab
le cells. | 900 // It's safe to check for control clip here, since controls can never be tab
le cells. |
| 943 // If we have a lightweight clip, there can never be any overflow from child
ren. | 901 // If we have a lightweight clip, there can never be any overflow from child
ren. |
| 944 if (hasControlClip() && m_overflow) | 902 if (hasControlClip() && m_overflow) |
| 945 clearLayoutOverflow(); | 903 clearLayoutOverflow(); |
| 946 | 904 |
| 947 invalidateBackgroundObscurationStatus(); | 905 invalidateBackgroundObscurationStatus(); |
| 948 } | 906 } |
| 949 | 907 |
| 950 bool LayoutBlock::updateImageLoadingPriorities() | |
| 951 { | |
| 952 WillBeHeapVector<RawPtrWillBeMember<ImageResource>> images; | |
| 953 appendImagesFromStyle(images, styleRef()); | |
| 954 | |
| 955 if (images.isEmpty()) | |
| 956 return false; | |
| 957 | |
| 958 LayoutRect viewBounds = viewRect(); | |
| 959 LayoutRect objectBounds(absoluteContentBox()); | |
| 960 // The object bounds might be empty right now, so intersects will fail since
it doesn't deal | |
| 961 // with empty rects. Use LayoutRect::contains in that case. | |
| 962 bool isVisible; | |
| 963 if (!objectBounds.isEmpty()) | |
| 964 isVisible = viewBounds.intersects(objectBounds); | |
| 965 else | |
| 966 isVisible = viewBounds.contains(objectBounds); | |
| 967 | |
| 968 ResourceLoadPriorityOptimizer::VisibilityStatus status = isVisible ? | |
| 969 ResourceLoadPriorityOptimizer::Visible : ResourceLoadPriorityOptimizer::
NotVisible; | |
| 970 | |
| 971 LayoutRect screenArea; | |
| 972 if (!objectBounds.isEmpty()) { | |
| 973 screenArea = viewBounds; | |
| 974 screenArea.intersect(objectBounds); | |
| 975 } | |
| 976 | |
| 977 for (auto imageResource : images) | |
| 978 ResourceLoadPriorityOptimizer::resourceLoadPriorityOptimizer()->notifyIm
ageResourceVisibility(imageResource, status, screenArea); | |
| 979 | |
| 980 return true; | |
| 981 } | |
| 982 | |
| 983 bool LayoutBlock::widthAvailableToChildrenHasChanged() | 908 bool LayoutBlock::widthAvailableToChildrenHasChanged() |
| 984 { | 909 { |
| 985 bool widthAvailableToChildrenHasChanged = m_widthAvailableToChildrenChanged; | 910 bool widthAvailableToChildrenHasChanged = m_widthAvailableToChildrenChanged; |
| 986 m_widthAvailableToChildrenChanged = false; | 911 m_widthAvailableToChildrenChanged = false; |
| 987 | 912 |
| 988 // If we use border-box sizing, have percentage padding, and our parent has
changed width then the width available to our children has changed even | 913 // If we use border-box sizing, have percentage padding, and our parent has
changed width then the width available to our children has changed even |
| 989 // though our own width has remained the same. | 914 // though our own width has remained the same. |
| 990 widthAvailableToChildrenHasChanged |= style()->boxSizing() == BORDER_BOX &&
needsPreferredWidthsRecalculation() && view()->layoutState()->containingBlockLog
icalWidthChanged(); | 915 widthAvailableToChildrenHasChanged |= style()->boxSizing() == BORDER_BOX &&
needsPreferredWidthsRecalculation() && view()->layoutState()->containingBlockLog
icalWidthChanged(); |
| 991 | 916 |
| 992 return widthAvailableToChildrenHasChanged; | 917 return widthAvailableToChildrenHasChanged; |
| (...skipping 1949 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2942 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m
arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout
Object* obj) const | 2867 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m
arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout
Object* obj) const |
| 2943 { | 2868 { |
| 2944 showLayoutObject(); | 2869 showLayoutObject(); |
| 2945 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot
Box()) | 2870 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot
Box()) |
| 2946 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa
bel2, obj, 1); | 2871 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa
bel2, obj, 1); |
| 2947 } | 2872 } |
| 2948 | 2873 |
| 2949 #endif | 2874 #endif |
| 2950 | 2875 |
| 2951 } // namespace blink | 2876 } // namespace blink |
| OLD | NEW |