| 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 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 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/EditingUtilities.h" | 33 #include "core/editing/EditingUtilities.h" |
| 34 #include "core/editing/Editor.h" | 34 #include "core/editing/Editor.h" |
| 35 #include "core/editing/FrameSelection.h" | 35 #include "core/editing/FrameSelection.h" |
| 36 #include "core/fetch/ResourceLoadPriorityOptimizer.h" | |
| 37 #include "core/frame/FrameView.h" | 36 #include "core/frame/FrameView.h" |
| 38 #include "core/frame/LocalFrame.h" | 37 #include "core/frame/LocalFrame.h" |
| 39 #include "core/frame/Settings.h" | 38 #include "core/frame/Settings.h" |
| 40 #include "core/html/HTMLMarqueeElement.h" | 39 #include "core/html/HTMLMarqueeElement.h" |
| 41 #include "core/layout/HitTestLocation.h" | 40 #include "core/layout/HitTestLocation.h" |
| 42 #include "core/layout/HitTestResult.h" | 41 #include "core/layout/HitTestResult.h" |
| 43 #include "core/layout/LayoutAnalyzer.h" | 42 #include "core/layout/LayoutAnalyzer.h" |
| 44 #include "core/layout/LayoutDeprecatedFlexibleBox.h" | 43 #include "core/layout/LayoutDeprecatedFlexibleBox.h" |
| 45 #include "core/layout/LayoutFlexibleBox.h" | 44 #include "core/layout/LayoutFlexibleBox.h" |
| 46 #include "core/layout/LayoutFlowThread.h" | 45 #include "core/layout/LayoutFlowThread.h" |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 continue; | 149 continue; |
| 151 HashSet<LayoutBlock*>* containerSet = it->value.get(); | 150 HashSet<LayoutBlock*>* containerSet = it->value.get(); |
| 152 ASSERT(containerSet->contains(block)); | 151 ASSERT(containerSet->contains(block)); |
| 153 containerSet->remove(block); | 152 containerSet->remove(block); |
| 154 if (containerSet->isEmpty()) | 153 if (containerSet->isEmpty()) |
| 155 containerMap->remove(it); | 154 containerMap->remove(it); |
| 156 } | 155 } |
| 157 } | 156 } |
| 158 } | 157 } |
| 159 | 158 |
| 160 static void appendImageIfNotNull(Vector<ImageResource*>& imageResources, const S
tyleImage* styleImage) | |
| 161 { | |
| 162 if (styleImage && styleImage->cachedImage()) { | |
| 163 ImageResource* imageResource = styleImage->cachedImage(); | |
| 164 if (imageResource && !imageResource->isLoaded()) | |
| 165 imageResources.append(styleImage->cachedImage()); | |
| 166 } | |
| 167 } | |
| 168 | |
| 169 static void appendLayers(Vector<ImageResource*>& images, const FillLayer& styleL
ayer) | |
| 170 { | |
| 171 for (const FillLayer* layer = &styleLayer; layer; layer = layer->next()) | |
| 172 appendImageIfNotNull(images, layer->image()); | |
| 173 } | |
| 174 | |
| 175 static void appendImagesFromStyle(Vector<ImageResource*>& images, const Computed
Style& blockStyle) | |
| 176 { | |
| 177 appendLayers(images, blockStyle.backgroundLayers()); | |
| 178 appendLayers(images, blockStyle.maskLayers()); | |
| 179 | |
| 180 const ContentData* contentData = blockStyle.contentData(); | |
| 181 if (contentData && contentData->isImage()) | |
| 182 appendImageIfNotNull(images, toImageContentData(contentData)->image()); | |
| 183 if (blockStyle.boxReflect()) | |
| 184 appendImageIfNotNull(images, blockStyle.boxReflect()->mask().image()); | |
| 185 appendImageIfNotNull(images, blockStyle.listStyleImage()); | |
| 186 appendImageIfNotNull(images, blockStyle.borderImageSource()); | |
| 187 appendImageIfNotNull(images, blockStyle.maskBoxImageSource()); | |
| 188 if (blockStyle.shapeOutside()) | |
| 189 appendImageIfNotNull(images, blockStyle.shapeOutside()->image()); | |
| 190 } | |
| 191 | |
| 192 void LayoutBlock::removeFromGlobalMaps() | 159 void LayoutBlock::removeFromGlobalMaps() |
| 193 { | 160 { |
| 194 if (gPercentHeightDescendantsMap) | 161 if (gPercentHeightDescendantsMap) |
| 195 removeBlockFromDescendantAndContainerMaps(this, gPercentHeightDescendant
sMap, gPercentHeightContainerMap); | 162 removeBlockFromDescendantAndContainerMaps(this, gPercentHeightDescendant
sMap, gPercentHeightContainerMap); |
| 196 if (gPositionedDescendantsMap) | 163 if (gPositionedDescendantsMap) |
| 197 removeBlockFromDescendantAndContainerMaps(this, gPositionedDescendantsMa
p, gPositionedContainerMap); | 164 removeBlockFromDescendantAndContainerMaps(this, gPositionedDescendantsMa
p, gPositionedContainerMap); |
| 198 } | 165 } |
| 199 | 166 |
| 200 LayoutBlock::~LayoutBlock() | 167 LayoutBlock::~LayoutBlock() |
| 201 { | 168 { |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 } | 282 } |
| 316 | 283 |
| 317 if (TextAutosizer* textAutosizer = document().textAutosizer()) | 284 if (TextAutosizer* textAutosizer = document().textAutosizer()) |
| 318 textAutosizer->record(this); | 285 textAutosizer->record(this); |
| 319 | 286 |
| 320 propagateStyleToAnonymousChildren(true); | 287 propagateStyleToAnonymousChildren(true); |
| 321 | 288 |
| 322 // It's possible for our border/padding to change, but for the overall logic
al width of the block to | 289 // It's possible for our border/padding to change, but for the overall logic
al width of the block to |
| 323 // end up being the same. We keep track of this change so in layoutBlock, we
can know to set relayoutChildren=true. | 290 // end up being the same. We keep track of this change so in layoutBlock, we
can know to set relayoutChildren=true. |
| 324 m_widthAvailableToChildrenChanged |= oldStyle && diff.needsFullLayout() && n
eedsLayout() && borderOrPaddingLogicalWidthChanged(*oldStyle, newStyle); | 291 m_widthAvailableToChildrenChanged |= oldStyle && diff.needsFullLayout() && n
eedsLayout() && borderOrPaddingLogicalWidthChanged(*oldStyle, newStyle); |
| 325 | |
| 326 // If the style has unloaded images, want to notify the ResourceLoadPriority
Optimizer so that | |
| 327 // network priorities can be set. | |
| 328 Vector<ImageResource*> images; | |
| 329 appendImagesFromStyle(images, newStyle); | |
| 330 if (images.isEmpty()) | |
| 331 ResourceLoadPriorityOptimizer::resourceLoadPriorityOptimizer()->removeLa
youtObject(this); | |
| 332 else | |
| 333 ResourceLoadPriorityOptimizer::resourceLoadPriorityOptimizer()->addLayou
tObject(this); | |
| 334 } | 292 } |
| 335 | 293 |
| 336 void LayoutBlock::invalidatePaintOfSubtreesIfNeeded(PaintInvalidationState& chil
dPaintInvalidationState) | 294 void LayoutBlock::invalidatePaintOfSubtreesIfNeeded(PaintInvalidationState& chil
dPaintInvalidationState) |
| 337 { | 295 { |
| 338 LayoutBox::invalidatePaintOfSubtreesIfNeeded(childPaintInvalidationState); | 296 LayoutBox::invalidatePaintOfSubtreesIfNeeded(childPaintInvalidationState); |
| 339 | 297 |
| 340 // Take care of positioned objects. This is required as PaintInvalidationSta
te keeps a single clip rect. | 298 // Take care of positioned objects. This is required as PaintInvalidationSta
te keeps a single clip rect. |
| 341 if (TrackedLayoutBoxListHashSet* positionedObjects = this->positionedObjects
()) { | 299 if (TrackedLayoutBoxListHashSet* positionedObjects = this->positionedObjects
()) { |
| 342 for (auto* box : *positionedObjects) { | 300 for (auto* box : *positionedObjects) { |
| 343 | 301 |
| (...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 907 layoutBlock(false); | 865 layoutBlock(false); |
| 908 | 866 |
| 909 // It's safe to check for control clip here, since controls can never be tab
le cells. | 867 // It's safe to check for control clip here, since controls can never be tab
le cells. |
| 910 // If we have a lightweight clip, there can never be any overflow from child
ren. | 868 // If we have a lightweight clip, there can never be any overflow from child
ren. |
| 911 if (hasControlClip() && m_overflow) | 869 if (hasControlClip() && m_overflow) |
| 912 clearLayoutOverflow(); | 870 clearLayoutOverflow(); |
| 913 | 871 |
| 914 invalidateBackgroundObscurationStatus(); | 872 invalidateBackgroundObscurationStatus(); |
| 915 } | 873 } |
| 916 | 874 |
| 917 bool LayoutBlock::updateImageLoadingPriorities() | |
| 918 { | |
| 919 Vector<ImageResource*> images; | |
| 920 appendImagesFromStyle(images, styleRef()); | |
| 921 | |
| 922 if (images.isEmpty()) | |
| 923 return false; | |
| 924 | |
| 925 LayoutRect viewBounds = viewRect(); | |
| 926 LayoutRect objectBounds(absoluteContentBox()); | |
| 927 // The object bounds might be empty right now, so intersects will fail since
it doesn't deal | |
| 928 // with empty rects. Use LayoutRect::contains in that case. | |
| 929 bool isVisible; | |
| 930 if (!objectBounds.isEmpty()) | |
| 931 isVisible = viewBounds.intersects(objectBounds); | |
| 932 else | |
| 933 isVisible = viewBounds.contains(objectBounds); | |
| 934 | |
| 935 ResourceLoadPriorityOptimizer::VisibilityStatus status = isVisible ? | |
| 936 ResourceLoadPriorityOptimizer::Visible : ResourceLoadPriorityOptimizer::
NotVisible; | |
| 937 | |
| 938 LayoutRect screenArea; | |
| 939 if (!objectBounds.isEmpty()) { | |
| 940 screenArea = viewBounds; | |
| 941 screenArea.intersect(objectBounds); | |
| 942 } | |
| 943 | |
| 944 for (auto* imageResource : images) | |
| 945 ResourceLoadPriorityOptimizer::resourceLoadPriorityOptimizer()->notifyIm
ageResourceVisibility(imageResource, status, screenArea); | |
| 946 | |
| 947 return true; | |
| 948 } | |
| 949 | |
| 950 bool LayoutBlock::widthAvailableToChildrenHasChanged() | 875 bool LayoutBlock::widthAvailableToChildrenHasChanged() |
| 951 { | 876 { |
| 952 bool widthAvailableToChildrenHasChanged = m_widthAvailableToChildrenChanged; | 877 bool widthAvailableToChildrenHasChanged = m_widthAvailableToChildrenChanged; |
| 953 m_widthAvailableToChildrenChanged = false; | 878 m_widthAvailableToChildrenChanged = false; |
| 954 | 879 |
| 955 // 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 | 880 // 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 |
| 956 // though our own width has remained the same. | 881 // though our own width has remained the same. |
| 957 widthAvailableToChildrenHasChanged |= style()->boxSizing() == BORDER_BOX &&
needsPreferredWidthsRecalculation() && view()->layoutState()->containingBlockLog
icalWidthChanged(); | 882 widthAvailableToChildrenHasChanged |= style()->boxSizing() == BORDER_BOX &&
needsPreferredWidthsRecalculation() && view()->layoutState()->containingBlockLog
icalWidthChanged(); |
| 958 | 883 |
| 959 return widthAvailableToChildrenHasChanged; | 884 return widthAvailableToChildrenHasChanged; |
| (...skipping 1948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2908 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m
arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout
Object* obj) const | 2833 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m
arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout
Object* obj) const |
| 2909 { | 2834 { |
| 2910 showLayoutObject(); | 2835 showLayoutObject(); |
| 2911 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot
Box()) | 2836 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot
Box()) |
| 2912 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa
bel2, obj, 1); | 2837 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa
bel2, obj, 1); |
| 2913 } | 2838 } |
| 2914 | 2839 |
| 2915 #endif | 2840 #endif |
| 2916 | 2841 |
| 2917 } // namespace blink | 2842 } // namespace blink |
| OLD | NEW |