| 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) 2000 Dirk Mueller (mueller@kde.org) | 4 * (C) 2000 Dirk Mueller (mueller@kde.org) |
| 5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) | 5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) |
| 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv
ed. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv
ed. |
| 7 * Copyright (C) 2009 Google Inc. All rights reserved. | 7 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
| 9 * | 9 * |
| 10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
| 11 * modify it under the terms of the GNU Library General Public | 11 * modify it under the terms of the GNU Library General Public |
| 12 * License as published by the Free Software Foundation; either | 12 * License as published by the Free Software Foundation; either |
| 13 * version 2 of the License, or (at your option) any later version. | 13 * version 2 of the License, or (at your option) any later version. |
| 14 * | 14 * |
| 15 * This library is distributed in the hope that it will be useful, | 15 * This library is distributed in the hope that it will be useful, |
| 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 18 * Library General Public License for more details. | 18 * Library General Public License for more details. |
| 19 * | 19 * |
| 20 * You should have received a copy of the GNU Library General Public License | 20 * You should have received a copy of the GNU Library General Public License |
| 21 * along with this library; see the file COPYING.LIB. If not, write to | 21 * along with this library; see the file COPYING.LIB. If not, write to |
| 22 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 22 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 23 * Boston, MA 02110-1301, USA. | 23 * Boston, MA 02110-1301, USA. |
| 24 * | 24 * |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 #include "config.h" | 27 #include "config.h" |
| 28 #include "core/rendering/RenderObject.h" | 28 #include "core/layout/LayoutObject.h" |
| 29 | 29 |
| 30 #include "core/HTMLNames.h" | 30 #include "core/HTMLNames.h" |
| 31 #include "core/css/resolver/StyleResolver.h" | 31 #include "core/css/resolver/StyleResolver.h" |
| 32 #include "core/dom/AXObjectCache.h" | 32 #include "core/dom/AXObjectCache.h" |
| 33 #include "core/dom/ElementTraversal.h" | 33 #include "core/dom/ElementTraversal.h" |
| 34 #include "core/dom/StyleEngine.h" | 34 #include "core/dom/StyleEngine.h" |
| 35 #include "core/dom/shadow/ShadowRoot.h" | 35 #include "core/dom/shadow/ShadowRoot.h" |
| 36 #include "core/editing/EditingBoundary.h" | 36 #include "core/editing/EditingBoundary.h" |
| 37 #include "core/editing/FrameSelection.h" | 37 #include "core/editing/FrameSelection.h" |
| 38 #include "core/editing/htmlediting.h" | 38 #include "core/editing/htmlediting.h" |
| 39 #include "core/fetch/ResourceLoadPriorityOptimizer.h" | 39 #include "core/fetch/ResourceLoadPriorityOptimizer.h" |
| 40 #include "core/fetch/ResourceLoader.h" | 40 #include "core/fetch/ResourceLoader.h" |
| 41 #include "core/frame/EventHandlerRegistry.h" | 41 #include "core/frame/EventHandlerRegistry.h" |
| 42 #include "core/frame/FrameView.h" | 42 #include "core/frame/FrameView.h" |
| 43 #include "core/frame/LocalFrame.h" | 43 #include "core/frame/LocalFrame.h" |
| 44 #include "core/frame/Settings.h" | 44 #include "core/frame/Settings.h" |
| 45 #include "core/frame/UseCounter.h" | 45 #include "core/frame/UseCounter.h" |
| 46 #include "core/html/HTMLAnchorElement.h" | 46 #include "core/html/HTMLAnchorElement.h" |
| 47 #include "core/html/HTMLElement.h" | 47 #include "core/html/HTMLElement.h" |
| 48 #include "core/html/HTMLHtmlElement.h" | 48 #include "core/html/HTMLHtmlElement.h" |
| 49 #include "core/html/HTMLTableCellElement.h" | 49 #include "core/html/HTMLTableCellElement.h" |
| 50 #include "core/html/HTMLTableElement.h" | 50 #include "core/html/HTMLTableElement.h" |
| 51 #include "core/layout/HitTestResult.h" | 51 #include "core/layout/HitTestResult.h" |
| 52 #include "core/layout/Layer.h" | 52 #include "core/layout/Layer.h" |
| 53 #include "core/layout/LayoutCounter.h" | 53 #include "core/layout/LayoutCounter.h" |
| 54 #include "core/layout/LayoutObjectInlines.h" |
| 54 #include "core/layout/LayoutTableCaption.h" | 55 #include "core/layout/LayoutTableCaption.h" |
| 55 #include "core/layout/LayoutTableCell.h" | 56 #include "core/layout/LayoutTableCell.h" |
| 56 #include "core/layout/LayoutTableCol.h" | 57 #include "core/layout/LayoutTableCol.h" |
| 57 #include "core/layout/LayoutTableRow.h" | 58 #include "core/layout/LayoutTableRow.h" |
| 58 #include "core/layout/LayoutTheme.h" | 59 #include "core/layout/LayoutTheme.h" |
| 59 #include "core/layout/compositing/CompositedLayerMapping.h" | 60 #include "core/layout/compositing/CompositedLayerMapping.h" |
| 60 #include "core/layout/compositing/LayerCompositor.h" | 61 #include "core/layout/compositing/LayerCompositor.h" |
| 61 #include "core/page/AutoscrollController.h" | 62 #include "core/page/AutoscrollController.h" |
| 62 #include "core/page/EventHandler.h" | 63 #include "core/page/EventHandler.h" |
| 63 #include "core/page/Page.h" | 64 #include "core/page/Page.h" |
| 64 #include "core/paint/ObjectPainter.h" | 65 #include "core/paint/ObjectPainter.h" |
| 65 #include "core/rendering/RenderDeprecatedFlexibleBox.h" | 66 #include "core/rendering/RenderDeprecatedFlexibleBox.h" |
| 66 #include "core/rendering/RenderFlexibleBox.h" | 67 #include "core/rendering/RenderFlexibleBox.h" |
| 67 #include "core/rendering/RenderFlowThread.h" | 68 #include "core/rendering/RenderFlowThread.h" |
| 68 #include "core/rendering/RenderGeometryMap.h" | 69 #include "core/rendering/RenderGeometryMap.h" |
| 69 #include "core/rendering/RenderGrid.h" | 70 #include "core/rendering/RenderGrid.h" |
| 70 #include "core/rendering/RenderImage.h" | 71 #include "core/rendering/RenderImage.h" |
| 71 #include "core/rendering/RenderImageResourceStyleImage.h" | 72 #include "core/rendering/RenderImageResourceStyleImage.h" |
| 72 #include "core/rendering/RenderInline.h" | 73 #include "core/rendering/RenderInline.h" |
| 73 #include "core/rendering/RenderListItem.h" | 74 #include "core/rendering/RenderListItem.h" |
| 74 #include "core/rendering/RenderMultiColumnSpannerPlaceholder.h" | 75 #include "core/rendering/RenderMultiColumnSpannerPlaceholder.h" |
| 75 #include "core/rendering/RenderObjectInlines.h" | |
| 76 #include "core/rendering/RenderPart.h" | 76 #include "core/rendering/RenderPart.h" |
| 77 #include "core/rendering/RenderScrollbarPart.h" | 77 #include "core/rendering/RenderScrollbarPart.h" |
| 78 #include "core/rendering/RenderView.h" | 78 #include "core/rendering/RenderView.h" |
| 79 #include "core/rendering/style/ContentData.h" | 79 #include "core/rendering/style/ContentData.h" |
| 80 #include "core/rendering/style/ShadowList.h" | 80 #include "core/rendering/style/ShadowList.h" |
| 81 #include "platform/JSONValues.h" | 81 #include "platform/JSONValues.h" |
| 82 #include "platform/Partitions.h" | 82 #include "platform/Partitions.h" |
| 83 #include "platform/RuntimeEnabledFeatures.h" | 83 #include "platform/RuntimeEnabledFeatures.h" |
| 84 #include "platform/TraceEvent.h" | 84 #include "platform/TraceEvent.h" |
| 85 #include "platform/TracedValue.h" | 85 #include "platform/TracedValue.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 99 namespace { | 99 namespace { |
| 100 | 100 |
| 101 static bool gModifyRenderTreeStructureAnyState = false; | 101 static bool gModifyRenderTreeStructureAnyState = false; |
| 102 | 102 |
| 103 } // namespace | 103 } // namespace |
| 104 | 104 |
| 105 using namespace HTMLNames; | 105 using namespace HTMLNames; |
| 106 | 106 |
| 107 #if ENABLE(ASSERT) | 107 #if ENABLE(ASSERT) |
| 108 | 108 |
| 109 RenderObject::SetLayoutNeededForbiddenScope::SetLayoutNeededForbiddenScope(Rende
rObject& renderObject) | 109 LayoutObject::SetLayoutNeededForbiddenScope::SetLayoutNeededForbiddenScope(Layou
tObject& layoutObject) |
| 110 : m_renderObject(renderObject) | 110 : m_layoutObject(layoutObject) |
| 111 , m_preexistingForbidden(m_renderObject.isSetNeedsLayoutForbidden()) | 111 , m_preexistingForbidden(m_layoutObject.isSetNeedsLayoutForbidden()) |
| 112 { | 112 { |
| 113 m_renderObject.setNeedsLayoutIsForbidden(true); | 113 m_layoutObject.setNeedsLayoutIsForbidden(true); |
| 114 } | 114 } |
| 115 | 115 |
| 116 RenderObject::SetLayoutNeededForbiddenScope::~SetLayoutNeededForbiddenScope() | 116 LayoutObject::SetLayoutNeededForbiddenScope::~SetLayoutNeededForbiddenScope() |
| 117 { | 117 { |
| 118 m_renderObject.setNeedsLayoutIsForbidden(m_preexistingForbidden); | 118 m_layoutObject.setNeedsLayoutIsForbidden(m_preexistingForbidden); |
| 119 } | 119 } |
| 120 #endif | 120 #endif |
| 121 | 121 |
| 122 struct SameSizeAsRenderObject { | 122 struct SameSizeAsLayoutObject { |
| 123 virtual ~SameSizeAsRenderObject() { } // Allocate vtable pointer. | 123 virtual ~SameSizeAsLayoutObject() { } // Allocate vtable pointer. |
| 124 void* pointers[5]; | 124 void* pointers[5]; |
| 125 #if ENABLE(ASSERT) | 125 #if ENABLE(ASSERT) |
| 126 unsigned m_debugBitfields : 2; | 126 unsigned m_debugBitfields : 2; |
| 127 #endif | 127 #endif |
| 128 unsigned m_bitfields; | 128 unsigned m_bitfields; |
| 129 unsigned m_bitfields2; | 129 unsigned m_bitfields2; |
| 130 LayoutRect rect; // Stores the previous paint invalidation rect. | 130 LayoutRect rect; // Stores the previous paint invalidation rect. |
| 131 LayoutPoint position; // Stores the previous position from the paint invalid
ation container. | 131 LayoutPoint position; // Stores the previous position from the paint invalid
ation container. |
| 132 }; | 132 }; |
| 133 | 133 |
| 134 static_assert(sizeof(RenderObject) == sizeof(SameSizeAsRenderObject), "RenderObj
ect should stay small"); | 134 static_assert(sizeof(LayoutObject) == sizeof(SameSizeAsLayoutObject), "LayoutObj
ect should stay small"); |
| 135 | 135 |
| 136 bool RenderObject::s_affectsParentBlock = false; | 136 bool LayoutObject::s_affectsParentBlock = false; |
| 137 | 137 |
| 138 typedef HashMap<const RenderObject*, LayoutRect> SelectionPaintInvalidationMap; | 138 typedef HashMap<const LayoutObject*, LayoutRect> SelectionPaintInvalidationMap; |
| 139 static SelectionPaintInvalidationMap* selectionPaintInvalidationMap = 0; | 139 static SelectionPaintInvalidationMap* selectionPaintInvalidationMap = 0; |
| 140 | 140 |
| 141 void* RenderObject::operator new(size_t sz) | 141 void* LayoutObject::operator new(size_t sz) |
| 142 { | 142 { |
| 143 ASSERT(isMainThread()); | 143 ASSERT(isMainThread()); |
| 144 return partitionAlloc(Partitions::getRenderingPartition(), sz); | 144 return partitionAlloc(Partitions::getRenderingPartition(), sz); |
| 145 } | 145 } |
| 146 | 146 |
| 147 void RenderObject::operator delete(void* ptr) | 147 void LayoutObject::operator delete(void* ptr) |
| 148 { | 148 { |
| 149 ASSERT(isMainThread()); | 149 ASSERT(isMainThread()); |
| 150 partitionFree(ptr); | 150 partitionFree(ptr); |
| 151 } | 151 } |
| 152 | 152 |
| 153 RenderObject* RenderObject::createObject(Element* element, RenderStyle* style) | 153 LayoutObject* LayoutObject::createObject(Element* element, RenderStyle* style) |
| 154 { | 154 { |
| 155 ASSERT(isAllowedToModifyRenderTreeStructure(element->document())); | 155 ASSERT(isAllowedToModifyRenderTreeStructure(element->document())); |
| 156 | 156 |
| 157 // Minimal support for content properties replacing an entire element. | 157 // Minimal support for content properties replacing an entire element. |
| 158 // Works only if we have exactly one piece of content and it's a URL. | 158 // Works only if we have exactly one piece of content and it's a URL. |
| 159 // Otherwise acts as if we didn't support this feature. | 159 // Otherwise acts as if we didn't support this feature. |
| 160 const ContentData* contentData = style->contentData(); | 160 const ContentData* contentData = style->contentData(); |
| 161 if (contentData && !contentData->next() && contentData->isImage() && !elemen
t->isPseudoElement()) { | 161 if (contentData && !contentData->next() && contentData->isImage() && !elemen
t->isPseudoElement()) { |
| 162 RenderImage* image = new RenderImage(element); | 162 RenderImage* image = new RenderImage(element); |
| 163 // RenderImageResourceStyleImage requires a style being present on the i
mage but we don't want to | 163 // RenderImageResourceStyleImage requires a style being present on the i
mage but we don't want to |
| 164 // trigger a style change now as the node is not fully attached. Moving
this code to style change | 164 // trigger a style change now as the node is not fully attached. Moving
this code to style change |
| 165 // doesn't make sense as it should be run once at renderer creation. | 165 // doesn't make sense as it should be run once at renderer creation. |
| 166 image->setStyleInternal(style); | 166 image->setStyleInternal(style); |
| 167 if (const StyleImage* styleImage = toImageContentData(contentData)->imag
e()) { | 167 if (const StyleImage* styleImage = toImageContentData(contentData)->imag
e()) { |
| 168 image->setImageResource(RenderImageResourceStyleImage::create(const_
cast<StyleImage*>(styleImage))); | 168 image->setImageResource(RenderImageResourceStyleImage::create(const_
cast<StyleImage*>(styleImage))); |
| 169 image->setIsGeneratedContent(); | 169 image->setIsGeneratedContent(); |
| 170 } else | 170 } else { |
| 171 image->setImageResource(RenderImageResource::create()); | 171 image->setImageResource(RenderImageResource::create()); |
| 172 } |
| 172 image->setStyleInternal(nullptr); | 173 image->setStyleInternal(nullptr); |
| 173 return image; | 174 return image; |
| 174 } | 175 } |
| 175 | 176 |
| 176 switch (style->display()) { | 177 switch (style->display()) { |
| 177 case NONE: | 178 case NONE: |
| 178 return 0; | 179 return 0; |
| 179 case INLINE: | 180 case INLINE: |
| 180 return new RenderInline(element); | 181 return new RenderInline(element); |
| 181 case BLOCK: | 182 case BLOCK: |
| (...skipping 24 matching lines...) Expand all Loading... |
| 206 case INLINE_FLEX: | 207 case INLINE_FLEX: |
| 207 return new RenderFlexibleBox(element); | 208 return new RenderFlexibleBox(element); |
| 208 case GRID: | 209 case GRID: |
| 209 case INLINE_GRID: | 210 case INLINE_GRID: |
| 210 return new RenderGrid(element); | 211 return new RenderGrid(element); |
| 211 } | 212 } |
| 212 | 213 |
| 213 return 0; | 214 return 0; |
| 214 } | 215 } |
| 215 | 216 |
| 216 DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, renderObjectCounter, ("Rend
erObject")); | 217 DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, layoutObjectCounter, ("Layo
utObject")); |
| 217 unsigned RenderObject::s_instanceCount = 0; | 218 unsigned LayoutObject::s_instanceCount = 0; |
| 218 | 219 |
| 219 RenderObject::RenderObject(Node* node) | 220 LayoutObject::LayoutObject(Node* node) |
| 220 : ImageResourceClient() | 221 : ImageResourceClient() |
| 221 , m_style(nullptr) | 222 , m_style(nullptr) |
| 222 , m_node(node) | 223 , m_node(node) |
| 223 , m_parent(nullptr) | 224 , m_parent(nullptr) |
| 224 , m_previous(nullptr) | 225 , m_previous(nullptr) |
| 225 , m_next(nullptr) | 226 , m_next(nullptr) |
| 226 #if ENABLE(ASSERT) | 227 #if ENABLE(ASSERT) |
| 227 , m_hasAXObject(false) | 228 , m_hasAXObject(false) |
| 228 , m_setNeedsLayoutForbidden(false) | 229 , m_setNeedsLayoutForbidden(false) |
| 229 #endif | 230 #endif |
| 230 , m_bitfields(node) | 231 , m_bitfields(node) |
| 231 { | 232 { |
| 232 #ifndef NDEBUG | 233 #ifndef NDEBUG |
| 233 renderObjectCounter.increment(); | 234 layoutObjectCounter.increment(); |
| 234 #endif | 235 #endif |
| 235 ++s_instanceCount; | 236 ++s_instanceCount; |
| 236 } | 237 } |
| 237 | 238 |
| 238 RenderObject::~RenderObject() | 239 LayoutObject::~LayoutObject() |
| 239 { | 240 { |
| 240 ASSERT(!m_hasAXObject); | 241 ASSERT(!m_hasAXObject); |
| 241 #ifndef NDEBUG | 242 #ifndef NDEBUG |
| 242 renderObjectCounter.decrement(); | 243 layoutObjectCounter.decrement(); |
| 243 #endif | 244 #endif |
| 244 --s_instanceCount; | 245 --s_instanceCount; |
| 245 } | 246 } |
| 246 | 247 |
| 247 String RenderObject::debugName() const | 248 String LayoutObject::debugName() const |
| 248 { | 249 { |
| 249 StringBuilder name; | 250 StringBuilder name; |
| 250 name.append(renderName()); | 251 name.append(renderName()); |
| 251 | 252 |
| 252 if (Node* node = this->node()) { | 253 if (Node* node = this->node()) { |
| 253 name.append(' '); | 254 name.append(' '); |
| 254 name.append(node->debugName()); | 255 name.append(node->debugName()); |
| 255 } | 256 } |
| 256 | 257 |
| 257 return name.toString(); | 258 return name.toString(); |
| 258 } | 259 } |
| 259 | 260 |
| 260 bool RenderObject::isDescendantOf(const RenderObject* obj) const | 261 bool LayoutObject::isDescendantOf(const LayoutObject* obj) const |
| 261 { | 262 { |
| 262 for (const RenderObject* r = this; r; r = r->m_parent) { | 263 for (const LayoutObject* r = this; r; r = r->m_parent) { |
| 263 if (r == obj) | 264 if (r == obj) |
| 264 return true; | 265 return true; |
| 265 } | 266 } |
| 266 return false; | 267 return false; |
| 267 } | 268 } |
| 268 | 269 |
| 269 bool RenderObject::isHR() const | 270 bool LayoutObject::isHR() const |
| 270 { | 271 { |
| 271 return isHTMLHRElement(node()); | 272 return isHTMLHRElement(node()); |
| 272 } | 273 } |
| 273 | 274 |
| 274 bool RenderObject::isLegend() const | 275 bool LayoutObject::isLegend() const |
| 275 { | 276 { |
| 276 return isHTMLLegendElement(node()); | 277 return isHTMLLegendElement(node()); |
| 277 } | 278 } |
| 278 | 279 |
| 279 void RenderObject::setFlowThreadStateIncludingDescendants(FlowThreadState state) | 280 void LayoutObject::setFlowThreadStateIncludingDescendants(FlowThreadState state) |
| 280 { | 281 { |
| 281 for (RenderObject *object = this; object; object = object->nextInPreOrder(th
is)) { | 282 for (LayoutObject *object = this; object; object = object->nextInPreOrder(th
is)) { |
| 282 // If object is a fragmentation context it already updated the descendan
ts flag accordingly. | 283 // If object is a fragmentation context it already updated the descendan
ts flag accordingly. |
| 283 if (object->isRenderFlowThread()) | 284 if (object->isRenderFlowThread()) |
| 284 continue; | 285 continue; |
| 285 ASSERT(state != object->flowThreadState()); | 286 ASSERT(state != object->flowThreadState()); |
| 286 object->setFlowThreadState(state); | 287 object->setFlowThreadState(state); |
| 287 } | 288 } |
| 288 } | 289 } |
| 289 | 290 |
| 290 bool RenderObject::requiresAnonymousTableWrappers(const RenderObject* newChild)
const | 291 bool LayoutObject::requiresAnonymousTableWrappers(const LayoutObject* newChild)
const |
| 291 { | 292 { |
| 292 // Check should agree with: | 293 // Check should agree with: |
| 293 // CSS 2.1 Tables: 17.2.1 Anonymous table objects | 294 // CSS 2.1 Tables: 17.2.1 Anonymous table objects |
| 294 // http://www.w3.org/TR/CSS21/tables.html#anonymous-boxes | 295 // http://www.w3.org/TR/CSS21/tables.html#anonymous-boxes |
| 295 if (newChild->isLayoutTableCol()) { | 296 if (newChild->isLayoutTableCol()) { |
| 296 const LayoutTableCol* newTableColumn = toLayoutTableCol(newChild); | 297 const LayoutTableCol* newTableColumn = toLayoutTableCol(newChild); |
| 297 bool isColumnInColumnGroup = newTableColumn->isTableColumn() && isLayout
TableCol(); | 298 bool isColumnInColumnGroup = newTableColumn->isTableColumn() && isLayout
TableCol(); |
| 298 return !isTable() && !isColumnInColumnGroup; | 299 return !isTable() && !isColumnInColumnGroup; |
| 299 } | 300 } |
| 300 if (newChild->isTableCaption()) | 301 if (newChild->isTableCaption()) |
| 301 return !isTable(); | 302 return !isTable(); |
| 302 if (newChild->isTableSection()) | 303 if (newChild->isTableSection()) |
| 303 return !isTable(); | 304 return !isTable(); |
| 304 if (newChild->isTableRow()) | 305 if (newChild->isTableRow()) |
| 305 return !isTableSection(); | 306 return !isTableSection(); |
| 306 if (newChild->isTableCell()) | 307 if (newChild->isTableCell()) |
| 307 return !isTableRow(); | 308 return !isTableRow(); |
| 308 return false; | 309 return false; |
| 309 } | 310 } |
| 310 | 311 |
| 311 void RenderObject::addChild(RenderObject* newChild, RenderObject* beforeChild) | 312 void LayoutObject::addChild(LayoutObject* newChild, LayoutObject* beforeChild) |
| 312 { | 313 { |
| 313 ASSERT(isAllowedToModifyRenderTreeStructure(document())); | 314 ASSERT(isAllowedToModifyRenderTreeStructure(document())); |
| 314 | 315 |
| 315 RenderObjectChildList* children = virtualChildren(); | 316 LayoutObjectChildList* children = virtualChildren(); |
| 316 ASSERT(children); | 317 ASSERT(children); |
| 317 if (!children) | 318 if (!children) |
| 318 return; | 319 return; |
| 319 | 320 |
| 320 if (requiresAnonymousTableWrappers(newChild)) { | 321 if (requiresAnonymousTableWrappers(newChild)) { |
| 321 // Generate an anonymous table or reuse existing one from previous child | 322 // Generate an anonymous table or reuse existing one from previous child |
| 322 // Per: 17.2.1 Anonymous table objects 3. Generate missing parents | 323 // Per: 17.2.1 Anonymous table objects 3. Generate missing parents |
| 323 // http://www.w3.org/TR/CSS21/tables.html#anonymous-boxes | 324 // http://www.w3.org/TR/CSS21/tables.html#anonymous-boxes |
| 324 LayoutTable* table; | 325 LayoutTable* table; |
| 325 RenderObject* afterChild = beforeChild ? beforeChild->previousSibling()
: children->lastChild(); | 326 LayoutObject* afterChild = beforeChild ? beforeChild->previousSibling()
: children->lastChild(); |
| 326 if (afterChild && afterChild->isAnonymous() && afterChild->isTable() &&
!afterChild->isBeforeContent()) | 327 if (afterChild && afterChild->isAnonymous() && afterChild->isTable() &&
!afterChild->isBeforeContent()) { |
| 327 table = toLayoutTable(afterChild); | 328 table = toLayoutTable(afterChild); |
| 328 else { | 329 } else { |
| 329 table = LayoutTable::createAnonymousWithParentRenderer(this); | 330 table = LayoutTable::createAnonymousWithParentRenderer(this); |
| 330 addChild(table, beforeChild); | 331 addChild(table, beforeChild); |
| 331 } | 332 } |
| 332 table->addChild(newChild); | 333 table->addChild(newChild); |
| 333 } else | 334 } else { |
| 334 children->insertChildNode(this, newChild, beforeChild); | 335 children->insertChildNode(this, newChild, beforeChild); |
| 336 } |
| 335 | 337 |
| 336 if (newChild->isText() && newChild->style()->textTransform() == CAPITALIZE) | 338 if (newChild->isText() && newChild->style()->textTransform() == CAPITALIZE) |
| 337 toRenderText(newChild)->transformText(); | 339 toRenderText(newChild)->transformText(); |
| 338 | 340 |
| 339 // SVG creates renderers for <g display="none">, as SVG requires children of
hidden | 341 // SVG creates renderers for <g display="none">, as SVG requires children of
hidden |
| 340 // <g>s to have renderers - at least that's how our implementation works. Co
nsider: | 342 // <g>s to have renderers - at least that's how our implementation works. Co
nsider: |
| 341 // <g display="none"><foreignObject><body style="position: relative">FOO... | 343 // <g display="none"><foreignObject><body style="position: relative">FOO... |
| 342 // - layerTypeRequired() would return true for the <body>, creating a new La
yer | 344 // - layerTypeRequired() would return true for the <body>, creating a new La
yer |
| 343 // - when the document is painted, both layers are painted. The <body> layer
doesn't | 345 // - when the document is painted, both layers are painted. The <body> layer
doesn't |
| 344 // know that it's inside a "hidden SVG subtree", and thus paints, even if
it shouldn't. | 346 // know that it's inside a "hidden SVG subtree", and thus paints, even if
it shouldn't. |
| 345 // To avoid the problem alltogether, detect early if we're inside a hidden S
VG subtree | 347 // To avoid the problem alltogether, detect early if we're inside a hidden S
VG subtree |
| 346 // and stop creating layers at all for these cases - they're not used anyway
s. | 348 // and stop creating layers at all for these cases - they're not used anyway
s. |
| 347 if (newChild->hasLayer() && !layerCreationAllowedForSubtree()) | 349 if (newChild->hasLayer() && !layerCreationAllowedForSubtree()) |
| 348 toLayoutLayerModelObject(newChild)->layer()->removeOnlyThisLayer(); | 350 toLayoutLayerModelObject(newChild)->layer()->removeOnlyThisLayer(); |
| 349 } | 351 } |
| 350 | 352 |
| 351 void RenderObject::removeChild(RenderObject* oldChild) | 353 void LayoutObject::removeChild(LayoutObject* oldChild) |
| 352 { | 354 { |
| 353 ASSERT(isAllowedToModifyRenderTreeStructure(document())); | 355 ASSERT(isAllowedToModifyRenderTreeStructure(document())); |
| 354 | 356 |
| 355 RenderObjectChildList* children = virtualChildren(); | 357 LayoutObjectChildList* children = virtualChildren(); |
| 356 ASSERT(children); | 358 ASSERT(children); |
| 357 if (!children) | 359 if (!children) |
| 358 return; | 360 return; |
| 359 | 361 |
| 360 children->removeChildNode(this, oldChild); | 362 children->removeChildNode(this, oldChild); |
| 361 } | 363 } |
| 362 | 364 |
| 363 RenderObject* RenderObject::nextInPreOrder() const | 365 LayoutObject* LayoutObject::nextInPreOrder() const |
| 364 { | 366 { |
| 365 if (RenderObject* o = slowFirstChild()) | 367 if (LayoutObject* o = slowFirstChild()) |
| 366 return o; | 368 return o; |
| 367 | 369 |
| 368 return nextInPreOrderAfterChildren(); | 370 return nextInPreOrderAfterChildren(); |
| 369 } | 371 } |
| 370 | 372 |
| 371 RenderObject* RenderObject::nextInPreOrderAfterChildren() const | 373 LayoutObject* LayoutObject::nextInPreOrderAfterChildren() const |
| 372 { | 374 { |
| 373 RenderObject* o = nextSibling(); | 375 LayoutObject* o = nextSibling(); |
| 374 if (!o) { | 376 if (!o) { |
| 375 o = parent(); | 377 o = parent(); |
| 376 while (o && !o->nextSibling()) | 378 while (o && !o->nextSibling()) |
| 377 o = o->parent(); | 379 o = o->parent(); |
| 378 if (o) | 380 if (o) |
| 379 o = o->nextSibling(); | 381 o = o->nextSibling(); |
| 380 } | 382 } |
| 381 | 383 |
| 382 return o; | 384 return o; |
| 383 } | 385 } |
| 384 | 386 |
| 385 RenderObject* RenderObject::nextInPreOrder(const RenderObject* stayWithin) const | 387 LayoutObject* LayoutObject::nextInPreOrder(const LayoutObject* stayWithin) const |
| 386 { | 388 { |
| 387 if (RenderObject* o = slowFirstChild()) | 389 if (LayoutObject* o = slowFirstChild()) |
| 388 return o; | 390 return o; |
| 389 | 391 |
| 390 return nextInPreOrderAfterChildren(stayWithin); | 392 return nextInPreOrderAfterChildren(stayWithin); |
| 391 } | 393 } |
| 392 | 394 |
| 393 RenderObject* RenderObject::nextInPreOrderAfterChildren(const RenderObject* stay
Within) const | 395 LayoutObject* LayoutObject::nextInPreOrderAfterChildren(const LayoutObject* stay
Within) const |
| 394 { | 396 { |
| 395 if (this == stayWithin) | 397 if (this == stayWithin) |
| 396 return 0; | 398 return 0; |
| 397 | 399 |
| 398 const RenderObject* current = this; | 400 const LayoutObject* current = this; |
| 399 RenderObject* next = current->nextSibling(); | 401 LayoutObject* next = current->nextSibling(); |
| 400 for (; !next; next = current->nextSibling()) { | 402 for (; !next; next = current->nextSibling()) { |
| 401 current = current->parent(); | 403 current = current->parent(); |
| 402 if (!current || current == stayWithin) | 404 if (!current || current == stayWithin) |
| 403 return 0; | 405 return 0; |
| 404 } | 406 } |
| 405 return next; | 407 return next; |
| 406 } | 408 } |
| 407 | 409 |
| 408 RenderObject* RenderObject::previousInPreOrder() const | 410 LayoutObject* LayoutObject::previousInPreOrder() const |
| 409 { | 411 { |
| 410 if (RenderObject* o = previousSibling()) { | 412 if (LayoutObject* o = previousSibling()) { |
| 411 while (RenderObject* lastChild = o->slowLastChild()) | 413 while (LayoutObject* lastChild = o->slowLastChild()) |
| 412 o = lastChild; | 414 o = lastChild; |
| 413 return o; | 415 return o; |
| 414 } | 416 } |
| 415 | 417 |
| 416 return parent(); | 418 return parent(); |
| 417 } | 419 } |
| 418 | 420 |
| 419 RenderObject* RenderObject::previousInPreOrder(const RenderObject* stayWithin) c
onst | 421 LayoutObject* LayoutObject::previousInPreOrder(const LayoutObject* stayWithin) c
onst |
| 420 { | 422 { |
| 421 if (this == stayWithin) | 423 if (this == stayWithin) |
| 422 return 0; | 424 return 0; |
| 423 | 425 |
| 424 return previousInPreOrder(); | 426 return previousInPreOrder(); |
| 425 } | 427 } |
| 426 | 428 |
| 427 RenderObject* RenderObject::childAt(unsigned index) const | 429 LayoutObject* LayoutObject::childAt(unsigned index) const |
| 428 { | 430 { |
| 429 RenderObject* child = slowFirstChild(); | 431 LayoutObject* child = slowFirstChild(); |
| 430 for (unsigned i = 0; child && i < index; i++) | 432 for (unsigned i = 0; child && i < index; i++) |
| 431 child = child->nextSibling(); | 433 child = child->nextSibling(); |
| 432 return child; | 434 return child; |
| 433 } | 435 } |
| 434 | 436 |
| 435 RenderObject* RenderObject::lastLeafChild() const | 437 LayoutObject* LayoutObject::lastLeafChild() const |
| 436 { | 438 { |
| 437 RenderObject* r = slowLastChild(); | 439 LayoutObject* r = slowLastChild(); |
| 438 while (r) { | 440 while (r) { |
| 439 RenderObject* n = 0; | 441 LayoutObject* n = 0; |
| 440 n = r->slowLastChild(); | 442 n = r->slowLastChild(); |
| 441 if (!n) | 443 if (!n) |
| 442 break; | 444 break; |
| 443 r = n; | 445 r = n; |
| 444 } | 446 } |
| 445 return r; | 447 return r; |
| 446 } | 448 } |
| 447 | 449 |
| 448 static void addLayers(RenderObject* obj, Layer* parentLayer, RenderObject*& newO
bject, | 450 static void addLayers(LayoutObject* obj, Layer* parentLayer, LayoutObject*& newO
bject, |
| 449 Layer*& beforeChild) | 451 Layer*& beforeChild) |
| 450 { | 452 { |
| 451 if (obj->hasLayer()) { | 453 if (obj->hasLayer()) { |
| 452 if (!beforeChild && newObject) { | 454 if (!beforeChild && newObject) { |
| 453 // We need to figure out the layer that follows newObject. We only d
o | 455 // We need to figure out the layer that follows newObject. We only d
o |
| 454 // this the first time we find a child layer, and then we update the | 456 // this the first time we find a child layer, and then we update the |
| 455 // pointer values for newObject and beforeChild used by everyone els
e. | 457 // pointer values for newObject and beforeChild used by everyone els
e. |
| 456 beforeChild = newObject->parent()->findNextLayer(parentLayer, newObj
ect); | 458 beforeChild = newObject->parent()->findNextLayer(parentLayer, newObj
ect); |
| 457 newObject = 0; | 459 newObject = 0; |
| 458 } | 460 } |
| 459 parentLayer->addChild(toLayoutLayerModelObject(obj)->layer(), beforeChil
d); | 461 parentLayer->addChild(toLayoutLayerModelObject(obj)->layer(), beforeChil
d); |
| 460 return; | 462 return; |
| 461 } | 463 } |
| 462 | 464 |
| 463 for (RenderObject* curr = obj->slowFirstChild(); curr; curr = curr->nextSibl
ing()) | 465 for (LayoutObject* curr = obj->slowFirstChild(); curr; curr = curr->nextSibl
ing()) |
| 464 addLayers(curr, parentLayer, newObject, beforeChild); | 466 addLayers(curr, parentLayer, newObject, beforeChild); |
| 465 } | 467 } |
| 466 | 468 |
| 467 void RenderObject::addLayers(Layer* parentLayer) | 469 void LayoutObject::addLayers(Layer* parentLayer) |
| 468 { | 470 { |
| 469 if (!parentLayer) | 471 if (!parentLayer) |
| 470 return; | 472 return; |
| 471 | 473 |
| 472 RenderObject* object = this; | 474 LayoutObject* object = this; |
| 473 Layer* beforeChild = 0; | 475 Layer* beforeChild = 0; |
| 474 blink::addLayers(this, parentLayer, object, beforeChild); | 476 blink::addLayers(this, parentLayer, object, beforeChild); |
| 475 } | 477 } |
| 476 | 478 |
| 477 void RenderObject::removeLayers(Layer* parentLayer) | 479 void LayoutObject::removeLayers(Layer* parentLayer) |
| 478 { | 480 { |
| 479 if (!parentLayer) | 481 if (!parentLayer) |
| 480 return; | 482 return; |
| 481 | 483 |
| 482 if (hasLayer()) { | 484 if (hasLayer()) { |
| 483 parentLayer->removeChild(toLayoutLayerModelObject(this)->layer()); | 485 parentLayer->removeChild(toLayoutLayerModelObject(this)->layer()); |
| 484 return; | 486 return; |
| 485 } | 487 } |
| 486 | 488 |
| 487 for (RenderObject* curr = slowFirstChild(); curr; curr = curr->nextSibling()
) | 489 for (LayoutObject* curr = slowFirstChild(); curr; curr = curr->nextSibling()
) |
| 488 curr->removeLayers(parentLayer); | 490 curr->removeLayers(parentLayer); |
| 489 } | 491 } |
| 490 | 492 |
| 491 void RenderObject::moveLayers(Layer* oldParent, Layer* newParent) | 493 void LayoutObject::moveLayers(Layer* oldParent, Layer* newParent) |
| 492 { | 494 { |
| 493 if (!newParent) | 495 if (!newParent) |
| 494 return; | 496 return; |
| 495 | 497 |
| 496 if (hasLayer()) { | 498 if (hasLayer()) { |
| 497 Layer* layer = toLayoutLayerModelObject(this)->layer(); | 499 Layer* layer = toLayoutLayerModelObject(this)->layer(); |
| 498 ASSERT(oldParent == layer->parent()); | 500 ASSERT(oldParent == layer->parent()); |
| 499 if (oldParent) | 501 if (oldParent) |
| 500 oldParent->removeChild(layer); | 502 oldParent->removeChild(layer); |
| 501 newParent->addChild(layer); | 503 newParent->addChild(layer); |
| 502 return; | 504 return; |
| 503 } | 505 } |
| 504 | 506 |
| 505 for (RenderObject* curr = slowFirstChild(); curr; curr = curr->nextSibling()
) | 507 for (LayoutObject* curr = slowFirstChild(); curr; curr = curr->nextSibling()
) |
| 506 curr->moveLayers(oldParent, newParent); | 508 curr->moveLayers(oldParent, newParent); |
| 507 } | 509 } |
| 508 | 510 |
| 509 Layer* RenderObject::findNextLayer(Layer* parentLayer, RenderObject* startPoint, | 511 Layer* LayoutObject::findNextLayer(Layer* parentLayer, LayoutObject* startPoint,
bool checkParent) |
| 510 bool checkParent) | |
| 511 { | 512 { |
| 512 // Error check the parent layer passed in. If it's null, we can't find anyth
ing. | 513 // Error check the parent layer passed in. If it's null, we can't find anyth
ing. |
| 513 if (!parentLayer) | 514 if (!parentLayer) |
| 514 return 0; | 515 return 0; |
| 515 | 516 |
| 516 // Step 1: If our layer is a child of the desired parent, then return our la
yer. | 517 // Step 1: If our layer is a child of the desired parent, then return our la
yer. |
| 517 Layer* ourLayer = hasLayer() ? toLayoutLayerModelObject(this)->layer() : 0; | 518 Layer* ourLayer = hasLayer() ? toLayoutLayerModelObject(this)->layer() : 0; |
| 518 if (ourLayer && ourLayer->parent() == parentLayer) | 519 if (ourLayer && ourLayer->parent() == parentLayer) |
| 519 return ourLayer; | 520 return ourLayer; |
| 520 | 521 |
| 521 // Step 2: If we don't have a layer, or our layer is the desired parent, the
n descend | 522 // Step 2: If we don't have a layer, or our layer is the desired parent, the
n descend |
| 522 // into our siblings trying to find the next layer whose parent is the desir
ed parent. | 523 // into our siblings trying to find the next layer whose parent is the desir
ed parent. |
| 523 if (!ourLayer || ourLayer == parentLayer) { | 524 if (!ourLayer || ourLayer == parentLayer) { |
| 524 for (RenderObject* curr = startPoint ? startPoint->nextSibling() : slowF
irstChild(); | 525 for (LayoutObject* curr = startPoint ? startPoint->nextSibling() : slowF
irstChild(); |
| 525 curr; curr = curr->nextSibling()) { | 526 curr; curr = curr->nextSibling()) { |
| 526 Layer* nextLayer = curr->findNextLayer(parentLayer, 0, false); | 527 Layer* nextLayer = curr->findNextLayer(parentLayer, 0, false); |
| 527 if (nextLayer) | 528 if (nextLayer) |
| 528 return nextLayer; | 529 return nextLayer; |
| 529 } | 530 } |
| 530 } | 531 } |
| 531 | 532 |
| 532 // Step 3: If our layer is the desired parent layer, then we're finished. We
didn't | 533 // Step 3: If our layer is the desired parent layer, then we're finished. We
didn't |
| 533 // find anything. | 534 // find anything. |
| 534 if (parentLayer == ourLayer) | 535 if (parentLayer == ourLayer) |
| 535 return 0; | 536 return 0; |
| 536 | 537 |
| 537 // Step 4: If |checkParent| is set, climb up to our parent and check its sib
lings that | 538 // Step 4: If |checkParent| is set, climb up to our parent and check its sib
lings that |
| 538 // follow us to see if we can locate a layer. | 539 // follow us to see if we can locate a layer. |
| 539 if (checkParent && parent()) | 540 if (checkParent && parent()) |
| 540 return parent()->findNextLayer(parentLayer, this, true); | 541 return parent()->findNextLayer(parentLayer, this, true); |
| 541 | 542 |
| 542 return 0; | 543 return 0; |
| 543 } | 544 } |
| 544 | 545 |
| 545 Layer* RenderObject::enclosingLayer() const | 546 Layer* LayoutObject::enclosingLayer() const |
| 546 { | 547 { |
| 547 for (const RenderObject* current = this; current; current = current->parent(
)) { | 548 for (const LayoutObject* current = this; current; current = current->parent(
)) { |
| 548 if (current->hasLayer()) | 549 if (current->hasLayer()) |
| 549 return toLayoutLayerModelObject(current)->layer(); | 550 return toLayoutLayerModelObject(current)->layer(); |
| 550 } | 551 } |
| 551 // FIXME: we should get rid of detached render subtrees, at which point this
code should | 552 // FIXME: we should get rid of detached render subtrees, at which point this
code should |
| 552 // not be reached. crbug.com/411429 | 553 // not be reached. crbug.com/411429 |
| 553 return 0; | 554 return 0; |
| 554 } | 555 } |
| 555 | 556 |
| 556 bool RenderObject::scrollRectToVisible(const LayoutRect& rect, const ScrollAlign
ment& alignX, const ScrollAlignment& alignY) | 557 bool LayoutObject::scrollRectToVisible(const LayoutRect& rect, const ScrollAlign
ment& alignX, const ScrollAlignment& alignY) |
| 557 { | 558 { |
| 558 RenderBox* enclosingBox = this->enclosingBox(); | 559 RenderBox* enclosingBox = this->enclosingBox(); |
| 559 if (!enclosingBox) | 560 if (!enclosingBox) |
| 560 return false; | 561 return false; |
| 561 | 562 |
| 562 enclosingBox->scrollRectToVisible(rect, alignX, alignY); | 563 enclosingBox->scrollRectToVisible(rect, alignX, alignY); |
| 563 return true; | 564 return true; |
| 564 } | 565 } |
| 565 | 566 |
| 566 RenderBox* RenderObject::enclosingBox() const | 567 RenderBox* LayoutObject::enclosingBox() const |
| 567 { | 568 { |
| 568 RenderObject* curr = const_cast<RenderObject*>(this); | 569 LayoutObject* curr = const_cast<LayoutObject*>(this); |
| 569 while (curr) { | 570 while (curr) { |
| 570 if (curr->isBox()) | 571 if (curr->isBox()) |
| 571 return toRenderBox(curr); | 572 return toRenderBox(curr); |
| 572 curr = curr->parent(); | 573 curr = curr->parent(); |
| 573 } | 574 } |
| 574 | 575 |
| 575 ASSERT_NOT_REACHED(); | 576 ASSERT_NOT_REACHED(); |
| 576 return 0; | 577 return 0; |
| 577 } | 578 } |
| 578 | 579 |
| 579 RenderBoxModelObject* RenderObject::enclosingBoxModelObject() const | 580 RenderBoxModelObject* LayoutObject::enclosingBoxModelObject() const |
| 580 { | 581 { |
| 581 RenderObject* curr = const_cast<RenderObject*>(this); | 582 LayoutObject* curr = const_cast<LayoutObject*>(this); |
| 582 while (curr) { | 583 while (curr) { |
| 583 if (curr->isBoxModelObject()) | 584 if (curr->isBoxModelObject()) |
| 584 return toRenderBoxModelObject(curr); | 585 return toRenderBoxModelObject(curr); |
| 585 curr = curr->parent(); | 586 curr = curr->parent(); |
| 586 } | 587 } |
| 587 | 588 |
| 588 ASSERT_NOT_REACHED(); | 589 ASSERT_NOT_REACHED(); |
| 589 return 0; | 590 return 0; |
| 590 } | 591 } |
| 591 | 592 |
| 592 RenderBox* RenderObject::enclosingScrollableBox() const | 593 RenderBox* LayoutObject::enclosingScrollableBox() const |
| 593 { | 594 { |
| 594 for (RenderObject* ancestor = parent(); ancestor; ancestor = ancestor->paren
t()) { | 595 for (LayoutObject* ancestor = parent(); ancestor; ancestor = ancestor->paren
t()) { |
| 595 if (!ancestor->isBox()) | 596 if (!ancestor->isBox()) |
| 596 continue; | 597 continue; |
| 597 | 598 |
| 598 RenderBox* ancestorBox = toRenderBox(ancestor); | 599 RenderBox* ancestorBox = toRenderBox(ancestor); |
| 599 if (ancestorBox->canBeScrolledAndHasScrollableArea()) | 600 if (ancestorBox->canBeScrolledAndHasScrollableArea()) |
| 600 return ancestorBox; | 601 return ancestorBox; |
| 601 } | 602 } |
| 602 | 603 |
| 603 return 0; | 604 return 0; |
| 604 } | 605 } |
| 605 | 606 |
| 606 RenderFlowThread* RenderObject::locateFlowThreadContainingBlock() const | 607 RenderFlowThread* LayoutObject::locateFlowThreadContainingBlock() const |
| 607 { | 608 { |
| 608 ASSERT(flowThreadState() != NotInsideFlowThread); | 609 ASSERT(flowThreadState() != NotInsideFlowThread); |
| 609 | 610 |
| 610 // See if we have the thread cached because we're in the middle of layout. | 611 // See if we have the thread cached because we're in the middle of layout. |
| 611 if (LayoutState* layoutState = view()->layoutState()) { | 612 if (LayoutState* layoutState = view()->layoutState()) { |
| 612 if (RenderFlowThread* flowThread = layoutState->flowThread()) | 613 if (RenderFlowThread* flowThread = layoutState->flowThread()) |
| 613 return flowThread; | 614 return flowThread; |
| 614 } | 615 } |
| 615 | 616 |
| 616 // Not in the middle of layout so have to find the thread the slow way. | 617 // Not in the middle of layout so have to find the thread the slow way. |
| 617 RenderObject* curr = const_cast<RenderObject*>(this); | 618 LayoutObject* curr = const_cast<LayoutObject*>(this); |
| 618 while (curr) { | 619 while (curr) { |
| 619 if (curr->isRenderFlowThread()) | 620 if (curr->isRenderFlowThread()) |
| 620 return toRenderFlowThread(curr); | 621 return toRenderFlowThread(curr); |
| 621 curr = curr->containingBlock(); | 622 curr = curr->containingBlock(); |
| 622 } | 623 } |
| 623 return 0; | 624 return 0; |
| 624 } | 625 } |
| 625 | 626 |
| 626 bool RenderObject::skipInvalidationWhenLaidOutChildren() const | 627 bool LayoutObject::skipInvalidationWhenLaidOutChildren() const |
| 627 { | 628 { |
| 628 if (!neededLayoutBecauseOfChildren()) | 629 if (!neededLayoutBecauseOfChildren()) |
| 629 return false; | 630 return false; |
| 630 | 631 |
| 631 // SVG renderers need to be invalidated when their children are laid out. | 632 // SVG renderers need to be invalidated when their children are laid out. |
| 632 // RenderBlocks with line boxes are responsible to invalidate them so we can
't ignore them. | 633 // RenderBlocks with line boxes are responsible to invalidate them so we can
't ignore them. |
| 633 if (isSVG() || (isRenderBlockFlow() && toRenderBlockFlow(this)->firstLineBox
())) | 634 if (isSVG() || (isRenderBlockFlow() && toRenderBlockFlow(this)->firstLineBox
())) |
| 634 return false; | 635 return false; |
| 635 | 636 |
| 636 return rendererHasNoBoxEffect(); | 637 return rendererHasNoBoxEffect(); |
| 637 } | 638 } |
| 638 | 639 |
| 639 RenderBlock* RenderObject::firstLineBlock() const | 640 RenderBlock* LayoutObject::firstLineBlock() const |
| 640 { | 641 { |
| 641 return 0; | 642 return 0; |
| 642 } | 643 } |
| 643 | 644 |
| 644 static inline bool objectIsRelayoutBoundary(const RenderObject* object) | 645 static inline bool objectIsRelayoutBoundary(const LayoutObject* object) |
| 645 { | 646 { |
| 646 // FIXME: In future it may be possible to broaden these conditions in order
to improve performance. | 647 // FIXME: In future it may be possible to broaden these conditions in order
to improve performance. |
| 647 if (object->isTextControl()) | 648 if (object->isTextControl()) |
| 648 return true; | 649 return true; |
| 649 | 650 |
| 650 if (object->isSVGRoot()) | 651 if (object->isSVGRoot()) |
| 651 return true; | 652 return true; |
| 652 | 653 |
| 653 if (!object->hasOverflowClip()) | 654 if (!object->hasOverflowClip()) |
| 654 return false; | 655 return false; |
| 655 | 656 |
| 656 if (object->style()->width().isIntrinsicOrAuto() || object->style()->height(
).isIntrinsicOrAuto() || object->style()->height().isPercent()) | 657 if (object->style()->width().isIntrinsicOrAuto() || object->style()->height(
).isIntrinsicOrAuto() || object->style()->height().isPercent()) |
| 657 return false; | 658 return false; |
| 658 | 659 |
| 659 // Table parts can't be relayout roots since the table is responsible for la
youting all the parts. | 660 // Table parts can't be relayout roots since the table is responsible for la
youting all the parts. |
| 660 if (object->isTablePart()) | 661 if (object->isTablePart()) |
| 661 return false; | 662 return false; |
| 662 | 663 |
| 663 return true; | 664 return true; |
| 664 } | 665 } |
| 665 | 666 |
| 666 void RenderObject::markContainingBlocksForLayout(bool scheduleRelayout, RenderOb
ject* newRoot, SubtreeLayoutScope* layouter) | 667 void LayoutObject::markContainingBlocksForLayout(bool scheduleRelayout, LayoutOb
ject* newRoot, SubtreeLayoutScope* layouter) |
| 667 { | 668 { |
| 668 ASSERT(!scheduleRelayout || !newRoot); | 669 ASSERT(!scheduleRelayout || !newRoot); |
| 669 ASSERT(!isSetNeedsLayoutForbidden()); | 670 ASSERT(!isSetNeedsLayoutForbidden()); |
| 670 ASSERT(!layouter || this != layouter->root()); | 671 ASSERT(!layouter || this != layouter->root()); |
| 671 | 672 |
| 672 RenderObject* object = container(); | 673 LayoutObject* object = container(); |
| 673 RenderObject* last = this; | 674 LayoutObject* last = this; |
| 674 | 675 |
| 675 bool simplifiedNormalFlowLayout = needsSimplifiedNormalFlowLayout() && !self
NeedsLayout() && !normalChildNeedsLayout(); | 676 bool simplifiedNormalFlowLayout = needsSimplifiedNormalFlowLayout() && !self
NeedsLayout() && !normalChildNeedsLayout(); |
| 676 | 677 |
| 677 while (object) { | 678 while (object) { |
| 678 if (object->selfNeedsLayout()) | 679 if (object->selfNeedsLayout()) |
| 679 return; | 680 return; |
| 680 | 681 |
| 681 // Don't mark the outermost object of an unrooted subtree. That object w
ill be | 682 // Don't mark the outermost object of an unrooted subtree. That object w
ill be |
| 682 // marked when the subtree is added to the document. | 683 // marked when the subtree is added to the document. |
| 683 RenderObject* container = object->container(); | 684 LayoutObject* container = object->container(); |
| 684 if (!container && !object->isRenderView()) | 685 if (!container && !object->isRenderView()) |
| 685 return; | 686 return; |
| 686 if (!last->isText() && last->style()->hasOutOfFlowPosition()) { | 687 if (!last->isText() && last->style()->hasOutOfFlowPosition()) { |
| 687 bool willSkipRelativelyPositionedInlines = !object->isRenderBlock()
|| object->isAnonymousBlock(); | 688 bool willSkipRelativelyPositionedInlines = !object->isRenderBlock()
|| object->isAnonymousBlock(); |
| 688 // Skip relatively positioned inlines and anonymous blocks to get to
the enclosing RenderBlock. | 689 // Skip relatively positioned inlines and anonymous blocks to get to
the enclosing RenderBlock. |
| 689 while (object && (!object->isRenderBlock() || object->isAnonymousBlo
ck())) | 690 while (object && (!object->isRenderBlock() || object->isAnonymousBlo
ck())) |
| 690 object = object->container(); | 691 object = object->container(); |
| 691 if (!object || object->posChildNeedsLayout()) | 692 if (!object || object->posChildNeedsLayout()) |
| 692 return; | 693 return; |
| 693 if (willSkipRelativelyPositionedInlines) | 694 if (willSkipRelativelyPositionedInlines) |
| (...skipping 26 matching lines...) Expand all Loading... |
| 720 if (scheduleRelayout && objectIsRelayoutBoundary(last)) | 721 if (scheduleRelayout && objectIsRelayoutBoundary(last)) |
| 721 break; | 722 break; |
| 722 object = container; | 723 object = container; |
| 723 } | 724 } |
| 724 | 725 |
| 725 if (scheduleRelayout) | 726 if (scheduleRelayout) |
| 726 last->scheduleRelayout(); | 727 last->scheduleRelayout(); |
| 727 } | 728 } |
| 728 | 729 |
| 729 #if ENABLE(ASSERT) | 730 #if ENABLE(ASSERT) |
| 730 void RenderObject::checkBlockPositionedObjectsNeedLayout() | 731 void LayoutObject::checkBlockPositionedObjectsNeedLayout() |
| 731 { | 732 { |
| 732 ASSERT(!needsLayout()); | 733 ASSERT(!needsLayout()); |
| 733 | 734 |
| 734 if (isRenderBlock()) | 735 if (isRenderBlock()) |
| 735 toRenderBlock(this)->checkPositionedObjectsNeedLayout(); | 736 toRenderBlock(this)->checkPositionedObjectsNeedLayout(); |
| 736 } | 737 } |
| 737 #endif | 738 #endif |
| 738 | 739 |
| 739 void RenderObject::setPreferredLogicalWidthsDirty(MarkingBehavior markParents) | 740 void LayoutObject::setPreferredLogicalWidthsDirty(MarkingBehavior markParents) |
| 740 { | 741 { |
| 741 m_bitfields.setPreferredLogicalWidthsDirty(true); | 742 m_bitfields.setPreferredLogicalWidthsDirty(true); |
| 742 if (markParents == MarkContainingBlockChain && (isText() || !style()->hasOut
OfFlowPosition())) | 743 if (markParents == MarkContainingBlockChain && (isText() || !style()->hasOut
OfFlowPosition())) |
| 743 invalidateContainerPreferredLogicalWidths(); | 744 invalidateContainerPreferredLogicalWidths(); |
| 744 } | 745 } |
| 745 | 746 |
| 746 void RenderObject::clearPreferredLogicalWidthsDirty() | 747 void LayoutObject::clearPreferredLogicalWidthsDirty() |
| 747 { | 748 { |
| 748 m_bitfields.setPreferredLogicalWidthsDirty(false); | 749 m_bitfields.setPreferredLogicalWidthsDirty(false); |
| 749 } | 750 } |
| 750 | 751 |
| 751 void RenderObject::invalidateContainerPreferredLogicalWidths() | 752 void LayoutObject::invalidateContainerPreferredLogicalWidths() |
| 752 { | 753 { |
| 753 // In order to avoid pathological behavior when inlines are deeply nested, w
e do include them | 754 // In order to avoid pathological behavior when inlines are deeply nested, w
e do include them |
| 754 // in the chain that we mark dirty (even though they're kind of irrelevant). | 755 // in the chain that we mark dirty (even though they're kind of irrelevant). |
| 755 RenderObject* o = isTableCell() ? containingBlock() : container(); | 756 LayoutObject* o = isTableCell() ? containingBlock() : container(); |
| 756 while (o && !o->preferredLogicalWidthsDirty()) { | 757 while (o && !o->preferredLogicalWidthsDirty()) { |
| 757 // Don't invalidate the outermost object of an unrooted subtree. That ob
ject will be | 758 // Don't invalidate the outermost object of an unrooted subtree. That ob
ject will be |
| 758 // invalidated when the subtree is added to the document. | 759 // invalidated when the subtree is added to the document. |
| 759 RenderObject* container = o->isTableCell() ? o->containingBlock() : o->c
ontainer(); | 760 LayoutObject* container = o->isTableCell() ? o->containingBlock() : o->c
ontainer(); |
| 760 if (!container && !o->isRenderView()) | 761 if (!container && !o->isRenderView()) |
| 761 break; | 762 break; |
| 762 | 763 |
| 763 o->m_bitfields.setPreferredLogicalWidthsDirty(true); | 764 o->m_bitfields.setPreferredLogicalWidthsDirty(true); |
| 764 if (o->style()->hasOutOfFlowPosition()) | 765 if (o->style()->hasOutOfFlowPosition()) { |
| 765 // A positioned object has no effect on the min/max width of its con
taining block ever. | 766 // A positioned object has no effect on the min/max width of its con
taining block ever. |
| 766 // We can optimize this case and not go up any further. | 767 // We can optimize this case and not go up any further. |
| 767 break; | 768 break; |
| 769 } |
| 768 o = container; | 770 o = container; |
| 769 } | 771 } |
| 770 } | 772 } |
| 771 | 773 |
| 772 RenderBlock* RenderObject::containerForFixedPosition(const LayoutLayerModelObjec
t* paintInvalidationContainer, bool* paintInvalidationContainerSkipped) const | 774 RenderBlock* LayoutObject::containerForFixedPosition(const LayoutLayerModelObjec
t* paintInvalidationContainer, bool* paintInvalidationContainerSkipped) const |
| 773 { | 775 { |
| 774 ASSERT(!paintInvalidationContainerSkipped || !*paintInvalidationContainerSki
pped); | 776 ASSERT(!paintInvalidationContainerSkipped || !*paintInvalidationContainerSki
pped); |
| 775 ASSERT(!isText()); | 777 ASSERT(!isText()); |
| 776 ASSERT(style()->position() == FixedPosition); | 778 ASSERT(style()->position() == FixedPosition); |
| 777 | 779 |
| 778 RenderObject* ancestor = parent(); | 780 LayoutObject* ancestor = parent(); |
| 779 for (; ancestor && !ancestor->canContainFixedPositionObjects(); ancestor = a
ncestor->parent()) { | 781 for (; ancestor && !ancestor->canContainFixedPositionObjects(); ancestor = a
ncestor->parent()) { |
| 780 if (paintInvalidationContainerSkipped && ancestor == paintInvalidationCo
ntainer) | 782 if (paintInvalidationContainerSkipped && ancestor == paintInvalidationCo
ntainer) |
| 781 *paintInvalidationContainerSkipped = true; | 783 *paintInvalidationContainerSkipped = true; |
| 782 } | 784 } |
| 783 | 785 |
| 784 ASSERT(!ancestor || !ancestor->isAnonymousBlock()); | 786 ASSERT(!ancestor || !ancestor->isAnonymousBlock()); |
| 785 return toRenderBlock(ancestor); | 787 return toRenderBlock(ancestor); |
| 786 } | 788 } |
| 787 | 789 |
| 788 RenderBlock* RenderObject::containingBlock() const | 790 RenderBlock* LayoutObject::containingBlock() const |
| 789 { | 791 { |
| 790 RenderObject* o = parent(); | 792 LayoutObject* o = parent(); |
| 791 if (!o && isRenderScrollbarPart()) | 793 if (!o && isRenderScrollbarPart()) |
| 792 o = toRenderScrollbarPart(this)->rendererOwningScrollbar(); | 794 o = toRenderScrollbarPart(this)->rendererOwningScrollbar(); |
| 793 if (!isText() && m_style->position() == FixedPosition) { | 795 if (!isText() && m_style->position() == FixedPosition) |
| 794 return containerForFixedPosition(); | 796 return containerForFixedPosition(); |
| 795 } else if (!isText() && m_style->position() == AbsolutePosition) { | 797 if (!isText() && m_style->position() == AbsolutePosition) { |
| 796 while (o) { | 798 while (o) { |
| 797 // For relpositioned inlines, we return the nearest non-anonymous en
closing block. We don't try | 799 // For relpositioned inlines, we return the nearest non-anonymous en
closing block. We don't try |
| 798 // to return the inline itself. This allows us to avoid having a po
sitioned objects | 800 // to return the inline itself. This allows us to avoid having a po
sitioned objects |
| 799 // list in all RenderInlines and lets us return a strongly-typed Ren
derBlock* result | 801 // list in all RenderInlines and lets us return a strongly-typed Ren
derBlock* result |
| 800 // from this method. The container() method can actually be used to
obtain the | 802 // from this method. The container() method can actually be used to
obtain the |
| 801 // inline directly. | 803 // inline directly. |
| 802 if (o->style()->position() != StaticPosition && (!o->isInline() || o
->isReplaced())) | 804 if (o->style()->position() != StaticPosition && (!o->isInline() || o
->isReplaced())) |
| 803 break; | 805 break; |
| 804 | 806 |
| 805 if (o->canContainFixedPositionObjects()) | 807 if (o->canContainFixedPositionObjects()) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 824 while (o && ((o->isInline() && !o->isReplaced()) || !o->isRenderBlock())
) | 826 while (o && ((o->isInline() && !o->isReplaced()) || !o->isRenderBlock())
) |
| 825 o = o->parent(); | 827 o = o->parent(); |
| 826 } | 828 } |
| 827 | 829 |
| 828 if (!o || !o->isRenderBlock()) | 830 if (!o || !o->isRenderBlock()) |
| 829 return 0; // This can still happen in case of an orphaned tree | 831 return 0; // This can still happen in case of an orphaned tree |
| 830 | 832 |
| 831 return toRenderBlock(o); | 833 return toRenderBlock(o); |
| 832 } | 834 } |
| 833 | 835 |
| 834 bool RenderObject::canRenderBorderImage() const | 836 bool LayoutObject::canRenderBorderImage() const |
| 835 { | 837 { |
| 836 if (!style()->hasBorder()) | 838 if (!style()->hasBorder()) |
| 837 return false; | 839 return false; |
| 838 | 840 |
| 839 StyleImage* borderImage = style()->borderImage().image(); | 841 StyleImage* borderImage = style()->borderImage().image(); |
| 840 return borderImage && borderImage->canRender(*this, style()->effectiveZoom()
) && borderImage->isLoaded(); | 842 return borderImage && borderImage->canRender(*this, style()->effectiveZoom()
) && borderImage->isLoaded(); |
| 841 } | 843 } |
| 842 | 844 |
| 843 bool RenderObject::mustInvalidateFillLayersPaintOnWidthChange(const FillLayer& l
ayer) const | 845 bool LayoutObject::mustInvalidateFillLayersPaintOnWidthChange(const FillLayer& l
ayer) const |
| 844 { | 846 { |
| 845 // Nobody will use multiple layers without wanting fancy positioning. | 847 // Nobody will use multiple layers without wanting fancy positioning. |
| 846 if (layer.next()) | 848 if (layer.next()) |
| 847 return true; | 849 return true; |
| 848 | 850 |
| 849 // Make sure we have a valid image. | 851 // Make sure we have a valid image. |
| 850 StyleImage* img = layer.image(); | 852 StyleImage* img = layer.image(); |
| 851 if (!img || !img->canRender(*this, style()->effectiveZoom())) | 853 if (!img || !img->canRender(*this, style()->effectiveZoom())) |
| 852 return false; | 854 return false; |
| 853 | 855 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 870 return true; | 872 return true; |
| 871 if (img->isGeneratedImage() && layer.sizeLength().width().isAuto()) | 873 if (img->isGeneratedImage() && layer.sizeLength().width().isAuto()) |
| 872 return true; | 874 return true; |
| 873 } else if (img->usesImageContainerSize()) { | 875 } else if (img->usesImageContainerSize()) { |
| 874 return true; | 876 return true; |
| 875 } | 877 } |
| 876 | 878 |
| 877 return false; | 879 return false; |
| 878 } | 880 } |
| 879 | 881 |
| 880 bool RenderObject::mustInvalidateFillLayersPaintOnHeightChange(const FillLayer&
layer) const | 882 bool LayoutObject::mustInvalidateFillLayersPaintOnHeightChange(const FillLayer&
layer) const |
| 881 { | 883 { |
| 882 // Nobody will use multiple layers without wanting fancy positioning. | 884 // Nobody will use multiple layers without wanting fancy positioning. |
| 883 if (layer.next()) | 885 if (layer.next()) |
| 884 return true; | 886 return true; |
| 885 | 887 |
| 886 // Make sure we have a valid image. | 888 // Make sure we have a valid image. |
| 887 StyleImage* img = layer.image(); | 889 StyleImage* img = layer.image(); |
| 888 if (!img || !img->canRender(*this, style()->effectiveZoom())) | 890 if (!img || !img->canRender(*this, style()->effectiveZoom())) |
| 889 return false; | 891 return false; |
| 890 | 892 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 907 return true; | 909 return true; |
| 908 if (img->isGeneratedImage() && layer.sizeLength().height().isAuto()) | 910 if (img->isGeneratedImage() && layer.sizeLength().height().isAuto()) |
| 909 return true; | 911 return true; |
| 910 } else if (img->usesImageContainerSize()) { | 912 } else if (img->usesImageContainerSize()) { |
| 911 return true; | 913 return true; |
| 912 } | 914 } |
| 913 | 915 |
| 914 return false; | 916 return false; |
| 915 } | 917 } |
| 916 | 918 |
| 917 bool RenderObject::mustInvalidateBackgroundOrBorderPaintOnWidthChange() const | 919 bool LayoutObject::mustInvalidateBackgroundOrBorderPaintOnWidthChange() const |
| 918 { | 920 { |
| 919 if (hasMask() && mustInvalidateFillLayersPaintOnWidthChange(style()->maskLay
ers())) | 921 if (hasMask() && mustInvalidateFillLayersPaintOnWidthChange(style()->maskLay
ers())) |
| 920 return true; | 922 return true; |
| 921 | 923 |
| 922 // If we don't have a background/border/mask, then nothing to do. | 924 // If we don't have a background/border/mask, then nothing to do. |
| 923 if (!hasBoxDecorationBackground()) | 925 if (!hasBoxDecorationBackground()) |
| 924 return false; | 926 return false; |
| 925 | 927 |
| 926 if (mustInvalidateFillLayersPaintOnWidthChange(style()->backgroundLayers())) | 928 if (mustInvalidateFillLayersPaintOnWidthChange(style()->backgroundLayers())) |
| 927 return true; | 929 return true; |
| 928 | 930 |
| 929 // Our fill layers are ok. Let's check border. | 931 // Our fill layers are ok. Let's check border. |
| 930 if (style()->hasBorder() && canRenderBorderImage()) | 932 if (style()->hasBorder() && canRenderBorderImage()) |
| 931 return true; | 933 return true; |
| 932 | 934 |
| 933 return false; | 935 return false; |
| 934 } | 936 } |
| 935 | 937 |
| 936 bool RenderObject::mustInvalidateBackgroundOrBorderPaintOnHeightChange() const | 938 bool LayoutObject::mustInvalidateBackgroundOrBorderPaintOnHeightChange() const |
| 937 { | 939 { |
| 938 if (hasMask() && mustInvalidateFillLayersPaintOnHeightChange(style()->maskLa
yers())) | 940 if (hasMask() && mustInvalidateFillLayersPaintOnHeightChange(style()->maskLa
yers())) |
| 939 return true; | 941 return true; |
| 940 | 942 |
| 941 // If we don't have a background/border/mask, then nothing to do. | 943 // If we don't have a background/border/mask, then nothing to do. |
| 942 if (!hasBoxDecorationBackground()) | 944 if (!hasBoxDecorationBackground()) |
| 943 return false; | 945 return false; |
| 944 | 946 |
| 945 if (mustInvalidateFillLayersPaintOnHeightChange(style()->backgroundLayers())
) | 947 if (mustInvalidateFillLayersPaintOnHeightChange(style()->backgroundLayers())
) |
| 946 return true; | 948 return true; |
| 947 | 949 |
| 948 // Our fill layers are ok. Let's check border. | 950 // Our fill layers are ok. Let's check border. |
| 949 if (style()->hasBorder() && canRenderBorderImage()) | 951 if (style()->hasBorder() && canRenderBorderImage()) |
| 950 return true; | 952 return true; |
| 951 | 953 |
| 952 return false; | 954 return false; |
| 953 } | 955 } |
| 954 | 956 |
| 955 IntRect RenderObject::absoluteBoundingBoxRect() const | 957 IntRect LayoutObject::absoluteBoundingBoxRect() const |
| 956 { | 958 { |
| 957 Vector<FloatQuad> quads; | 959 Vector<FloatQuad> quads; |
| 958 absoluteQuads(quads); | 960 absoluteQuads(quads); |
| 959 | 961 |
| 960 size_t n = quads.size(); | 962 size_t n = quads.size(); |
| 961 if (!n) | 963 if (!n) |
| 962 return IntRect(); | 964 return IntRect(); |
| 963 | 965 |
| 964 IntRect result = quads[0].enclosingBoundingBox(); | 966 IntRect result = quads[0].enclosingBoundingBox(); |
| 965 for (size_t i = 1; i < n; ++i) | 967 for (size_t i = 1; i < n; ++i) |
| 966 result.unite(quads[i].enclosingBoundingBox()); | 968 result.unite(quads[i].enclosingBoundingBox()); |
| 967 return result; | 969 return result; |
| 968 } | 970 } |
| 969 | 971 |
| 970 IntRect RenderObject::absoluteBoundingBoxRectIgnoringTransforms() const | 972 IntRect LayoutObject::absoluteBoundingBoxRectIgnoringTransforms() const |
| 971 { | 973 { |
| 972 FloatPoint absPos = localToAbsolute(); | 974 FloatPoint absPos = localToAbsolute(); |
| 973 Vector<IntRect> rects; | 975 Vector<IntRect> rects; |
| 974 absoluteRects(rects, flooredLayoutPoint(absPos)); | 976 absoluteRects(rects, flooredLayoutPoint(absPos)); |
| 975 | 977 |
| 976 size_t n = rects.size(); | 978 size_t n = rects.size(); |
| 977 if (!n) | 979 if (!n) |
| 978 return IntRect(); | 980 return IntRect(); |
| 979 | 981 |
| 980 LayoutRect result = rects[0]; | 982 LayoutRect result = rects[0]; |
| 981 for (size_t i = 1; i < n; ++i) | 983 for (size_t i = 1; i < n; ++i) |
| 982 result.unite(rects[i]); | 984 result.unite(rects[i]); |
| 983 return pixelSnappedIntRect(result); | 985 return pixelSnappedIntRect(result); |
| 984 } | 986 } |
| 985 | 987 |
| 986 IntRect RenderObject::absoluteFocusRingBoundingBoxRect() const | 988 IntRect LayoutObject::absoluteFocusRingBoundingBoxRect() const |
| 987 { | 989 { |
| 988 Vector<LayoutRect> rects; | 990 Vector<LayoutRect> rects; |
| 989 const LayoutLayerModelObject* container = enclosingLayer()->renderer(); | 991 const LayoutLayerModelObject* container = enclosingLayer()->renderer(); |
| 990 addFocusRingRects(rects, LayoutPoint(localToContainerPoint(FloatPoint(), con
tainer))); | 992 addFocusRingRects(rects, LayoutPoint(localToContainerPoint(FloatPoint(), con
tainer))); |
| 991 return container->localToAbsoluteQuad(FloatQuad(unionRect(rects))).enclosing
BoundingBox(); | 993 return container->localToAbsoluteQuad(FloatQuad(unionRect(rects))).enclosing
BoundingBox(); |
| 992 } | 994 } |
| 993 | 995 |
| 994 FloatRect RenderObject::absoluteBoundingBoxRectForRange(const Range* range) | 996 FloatRect LayoutObject::absoluteBoundingBoxRectForRange(const Range* range) |
| 995 { | 997 { |
| 996 if (!range || !range->startContainer()) | 998 if (!range || !range->startContainer()) |
| 997 return FloatRect(); | 999 return FloatRect(); |
| 998 | 1000 |
| 999 range->ownerDocument().updateLayout(); | 1001 range->ownerDocument().updateLayout(); |
| 1000 | 1002 |
| 1001 Vector<FloatQuad> quads; | 1003 Vector<FloatQuad> quads; |
| 1002 range->textQuads(quads); | 1004 range->textQuads(quads); |
| 1003 | 1005 |
| 1004 FloatRect result; | 1006 FloatRect result; |
| 1005 for (size_t i = 0; i < quads.size(); ++i) | 1007 for (size_t i = 0; i < quads.size(); ++i) |
| 1006 result.unite(quads[i].boundingBox()); | 1008 result.unite(quads[i].boundingBox()); |
| 1007 | 1009 |
| 1008 return result; | 1010 return result; |
| 1009 } | 1011 } |
| 1010 | 1012 |
| 1011 void RenderObject::addAbsoluteRectForLayer(LayoutRect& result) | 1013 void LayoutObject::addAbsoluteRectForLayer(LayoutRect& result) |
| 1012 { | 1014 { |
| 1013 if (hasLayer()) | 1015 if (hasLayer()) |
| 1014 result.unite(absoluteBoundingBoxRect()); | 1016 result.unite(absoluteBoundingBoxRect()); |
| 1015 for (RenderObject* current = slowFirstChild(); current; current = current->n
extSibling()) | 1017 for (LayoutObject* current = slowFirstChild(); current; current = current->n
extSibling()) |
| 1016 current->addAbsoluteRectForLayer(result); | 1018 current->addAbsoluteRectForLayer(result); |
| 1017 } | 1019 } |
| 1018 | 1020 |
| 1019 LayoutRect RenderObject::paintingRootRect(LayoutRect& topLevelRect) | 1021 LayoutRect LayoutObject::paintingRootRect(LayoutRect& topLevelRect) |
| 1020 { | 1022 { |
| 1021 LayoutRect result = absoluteBoundingBoxRect(); | 1023 LayoutRect result = absoluteBoundingBoxRect(); |
| 1022 topLevelRect = result; | 1024 topLevelRect = result; |
| 1023 for (RenderObject* current = slowFirstChild(); current; current = current->n
extSibling()) | 1025 for (LayoutObject* current = slowFirstChild(); current; current = current->n
extSibling()) |
| 1024 current->addAbsoluteRectForLayer(result); | 1026 current->addAbsoluteRectForLayer(result); |
| 1025 return result; | 1027 return result; |
| 1026 } | 1028 } |
| 1027 | 1029 |
| 1028 void RenderObject::paint(const PaintInfo&, const LayoutPoint&) | 1030 void LayoutObject::paint(const PaintInfo&, const LayoutPoint&) |
| 1029 { | 1031 { |
| 1030 } | 1032 } |
| 1031 | 1033 |
| 1032 const LayoutLayerModelObject* RenderObject::containerForPaintInvalidation() cons
t | 1034 const LayoutLayerModelObject* LayoutObject::containerForPaintInvalidation() cons
t |
| 1033 { | 1035 { |
| 1034 RELEASE_ASSERT(isRooted()); | 1036 RELEASE_ASSERT(isRooted()); |
| 1035 return adjustCompositedContainerForSpecialAncestors(enclosingCompositedConta
iner()); | 1037 return adjustCompositedContainerForSpecialAncestors(enclosingCompositedConta
iner()); |
| 1036 } | 1038 } |
| 1037 | 1039 |
| 1038 const LayoutLayerModelObject* RenderObject::enclosingCompositedContainer() const | 1040 const LayoutLayerModelObject* LayoutObject::enclosingCompositedContainer() const |
| 1039 { | 1041 { |
| 1040 LayoutLayerModelObject* container = 0; | 1042 LayoutLayerModelObject* container = 0; |
| 1041 // FIXME: CompositingState is not necessarily up to date for many callers of
this function. | 1043 // FIXME: CompositingState is not necessarily up to date for many callers of
this function. |
| 1042 DisableCompositingQueryAsserts disabler; | 1044 DisableCompositingQueryAsserts disabler; |
| 1043 | 1045 |
| 1044 if (Layer* compositingLayer = enclosingLayer()->enclosingLayerForPaintInvali
dationCrossingFrameBoundaries()) | 1046 if (Layer* compositingLayer = enclosingLayer()->enclosingLayerForPaintInvali
dationCrossingFrameBoundaries()) |
| 1045 container = compositingLayer->renderer(); | 1047 container = compositingLayer->renderer(); |
| 1046 return container; | 1048 return container; |
| 1047 } | 1049 } |
| 1048 | 1050 |
| 1049 const LayoutLayerModelObject* RenderObject::adjustCompositedContainerForSpecialA
ncestors(const LayoutLayerModelObject* paintInvalidationContainer) const | 1051 const LayoutLayerModelObject* LayoutObject::adjustCompositedContainerForSpecialA
ncestors(const LayoutLayerModelObject* paintInvalidationContainer) const |
| 1050 { | 1052 { |
| 1051 if (paintInvalidationContainer) | 1053 if (paintInvalidationContainer) |
| 1052 return paintInvalidationContainer; | 1054 return paintInvalidationContainer; |
| 1053 | 1055 |
| 1054 RenderView* renderView = view(); | 1056 RenderView* renderView = view(); |
| 1055 while (renderView->frame()->ownerRenderer()) | 1057 while (renderView->frame()->ownerRenderer()) |
| 1056 renderView = renderView->frame()->ownerRenderer()->view(); | 1058 renderView = renderView->frame()->ownerRenderer()->view(); |
| 1057 return renderView; | 1059 return renderView; |
| 1058 } | 1060 } |
| 1059 | 1061 |
| 1060 bool RenderObject::isPaintInvalidationContainer() const | 1062 bool LayoutObject::isPaintInvalidationContainer() const |
| 1061 { | 1063 { |
| 1062 return hasLayer() && toLayoutLayerModelObject(this)->layer()->isPaintInvalid
ationContainer(); | 1064 return hasLayer() && toLayoutLayerModelObject(this)->layer()->isPaintInvalid
ationContainer(); |
| 1063 } | 1065 } |
| 1064 | 1066 |
| 1065 template <typename T> | 1067 template <typename T> |
| 1066 void addJsonObjectForRect(TracedValue* value, const char* name, const T& rect) | 1068 void addJsonObjectForRect(TracedValue* value, const char* name, const T& rect) |
| 1067 { | 1069 { |
| 1068 value->beginDictionary(name); | 1070 value->beginDictionary(name); |
| 1069 value->setDouble("x", rect.x()); | 1071 value->setDouble("x", rect.x()); |
| 1070 value->setDouble("y", rect.y()); | 1072 value->setDouble("y", rect.y()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1083 } | 1085 } |
| 1084 | 1086 |
| 1085 static PassRefPtr<TraceEvent::ConvertableToTraceFormat> jsonObjectForPaintInvali
dationInfo(const LayoutRect& rect, const String& invalidationReason) | 1087 static PassRefPtr<TraceEvent::ConvertableToTraceFormat> jsonObjectForPaintInvali
dationInfo(const LayoutRect& rect, const String& invalidationReason) |
| 1086 { | 1088 { |
| 1087 RefPtr<TracedValue> value = TracedValue::create(); | 1089 RefPtr<TracedValue> value = TracedValue::create(); |
| 1088 addJsonObjectForRect(value.get(), "rect", rect); | 1090 addJsonObjectForRect(value.get(), "rect", rect); |
| 1089 value->setString("invalidation_reason", invalidationReason); | 1091 value->setString("invalidation_reason", invalidationReason); |
| 1090 return value; | 1092 return value; |
| 1091 } | 1093 } |
| 1092 | 1094 |
| 1093 LayoutRect RenderObject::computePaintInvalidationRect(const LayoutLayerModelObje
ct* paintInvalidationContainer, const PaintInvalidationState* paintInvalidationS
tate) const | 1095 LayoutRect LayoutObject::computePaintInvalidationRect(const LayoutLayerModelObje
ct* paintInvalidationContainer, const PaintInvalidationState* paintInvalidationS
tate) const |
| 1094 { | 1096 { |
| 1095 return clippedOverflowRectForPaintInvalidation(paintInvalidationContainer, p
aintInvalidationState); | 1097 return clippedOverflowRectForPaintInvalidation(paintInvalidationContainer, p
aintInvalidationState); |
| 1096 } | 1098 } |
| 1097 | 1099 |
| 1098 void RenderObject::invalidatePaintUsingContainer(const LayoutLayerModelObject* p
aintInvalidationContainer, const LayoutRect& r, PaintInvalidationReason invalida
tionReason) const | 1100 void LayoutObject::invalidatePaintUsingContainer(const LayoutLayerModelObject* p
aintInvalidationContainer, const LayoutRect& r, PaintInvalidationReason invalida
tionReason) const |
| 1099 { | 1101 { |
| 1100 if (r.isEmpty()) | 1102 if (r.isEmpty()) |
| 1101 return; | 1103 return; |
| 1102 | 1104 |
| 1103 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) { | 1105 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) { |
| 1104 if (Layer* container = enclosingLayer()->enclosingLayerForPaintInvalidat
ionCrossingFrameBoundaries()) | 1106 if (Layer* container = enclosingLayer()->enclosingLayerForPaintInvalidat
ionCrossingFrameBoundaries()) |
| 1105 invalidateDisplayItemClients(container->graphicsLayerBacking()->disp
layItemList()); | 1107 invalidateDisplayItemClients(container->graphicsLayerBacking()->disp
layItemList()); |
| 1106 } | 1108 } |
| 1107 | 1109 |
| 1108 RELEASE_ASSERT(isRooted()); | 1110 RELEASE_ASSERT(isRooted()); |
| 1109 | 1111 |
| 1110 // FIXME: Unify "devtools.timeline.invalidationTracking" and "blink.invalida
tion". crbug.com/413527. | 1112 // FIXME: Unify "devtools.timeline.invalidationTracking" and "blink.invalida
tion". crbug.com/413527. |
| 1111 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.invalidati
onTracking"), | 1113 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.invalidati
onTracking"), |
| 1112 "PaintInvalidationTracking", | 1114 "PaintInvalidationTracking", |
| 1113 "data", InspectorPaintInvalidationTrackingEvent::data(this, paintInvalid
ationContainer)); | 1115 "data", InspectorPaintInvalidationTrackingEvent::data(this, paintInvalid
ationContainer)); |
| 1114 TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("blink.invalidation"), "RenderObject:
:invalidatePaintUsingContainer()", | 1116 TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("blink.invalidation"), "LayoutObject:
:invalidatePaintUsingContainer()", |
| 1115 "object", this->debugName().ascii(), | 1117 "object", this->debugName().ascii(), |
| 1116 "info", jsonObjectForPaintInvalidationInfo(r, paintInvalidationReasonToS
tring(invalidationReason))); | 1118 "info", jsonObjectForPaintInvalidationInfo(r, paintInvalidationReasonToS
tring(invalidationReason))); |
| 1117 | 1119 |
| 1118 if (paintInvalidationContainer->isRenderView()) { | 1120 if (paintInvalidationContainer->isRenderView()) { |
| 1119 toRenderView(paintInvalidationContainer)->invalidatePaintForRectangle(r,
invalidationReason); | 1121 toRenderView(paintInvalidationContainer)->invalidatePaintForRectangle(r,
invalidationReason); |
| 1120 return; | 1122 return; |
| 1121 } | 1123 } |
| 1122 | 1124 |
| 1123 if (paintInvalidationContainer->view()->usesCompositing()) { | 1125 if (paintInvalidationContainer->view()->usesCompositing()) { |
| 1124 ASSERT(paintInvalidationContainer->isPaintInvalidationContainer()); | 1126 ASSERT(paintInvalidationContainer->isPaintInvalidationContainer()); |
| 1125 paintInvalidationContainer->setBackingNeedsPaintInvalidationInRect(r, in
validationReason); | 1127 paintInvalidationContainer->setBackingNeedsPaintInvalidationInRect(r, in
validationReason); |
| 1126 } | 1128 } |
| 1127 } | 1129 } |
| 1128 | 1130 |
| 1129 void RenderObject::invalidateDisplayItemClients(DisplayItemList* displayItemList
) const | 1131 void LayoutObject::invalidateDisplayItemClients(DisplayItemList* displayItemList
) const |
| 1130 { | 1132 { |
| 1131 displayItemList->invalidate(displayItemClient()); | 1133 displayItemList->invalidate(displayItemClient()); |
| 1132 } | 1134 } |
| 1133 | 1135 |
| 1134 LayoutRect RenderObject::boundsRectForPaintInvalidation(const LayoutLayerModelOb
ject* paintInvalidationContainer, const PaintInvalidationState* paintInvalidatio
nState) const | 1136 LayoutRect LayoutObject::boundsRectForPaintInvalidation(const LayoutLayerModelOb
ject* paintInvalidationContainer, const PaintInvalidationState* paintInvalidatio
nState) const |
| 1135 { | 1137 { |
| 1136 if (!paintInvalidationContainer) | 1138 if (!paintInvalidationContainer) |
| 1137 return computePaintInvalidationRect(paintInvalidationContainer, paintInv
alidationState); | 1139 return computePaintInvalidationRect(paintInvalidationContainer, paintInv
alidationState); |
| 1138 return Layer::computePaintInvalidationRect(this, paintInvalidationContainer-
>layer(), paintInvalidationState); | 1140 return Layer::computePaintInvalidationRect(this, paintInvalidationContainer-
>layer(), paintInvalidationState); |
| 1139 } | 1141 } |
| 1140 | 1142 |
| 1141 void RenderObject::invalidatePaintRectangle(const LayoutRect& r) const | 1143 void LayoutObject::invalidatePaintRectangle(const LayoutRect& r) const |
| 1142 { | 1144 { |
| 1143 RELEASE_ASSERT(isRooted()); | 1145 RELEASE_ASSERT(isRooted()); |
| 1144 | 1146 |
| 1145 if (view()->document().printing()) | 1147 if (view()->document().printing()) |
| 1146 return; // Don't invalidate paints if we're printing. | 1148 return; // Don't invalidate paints if we're printing. |
| 1147 | 1149 |
| 1148 LayoutRect dirtyRect(r); | 1150 LayoutRect dirtyRect(r); |
| 1149 | 1151 |
| 1150 const LayoutLayerModelObject* paintInvalidationContainer = containerForPaint
Invalidation(); | 1152 const LayoutLayerModelObject* paintInvalidationContainer = containerForPaint
Invalidation(); |
| 1151 Layer::mapRectToPaintInvalidationBacking(this, paintInvalidationContainer, d
irtyRect); | 1153 Layer::mapRectToPaintInvalidationBacking(this, paintInvalidationContainer, d
irtyRect); |
| 1152 invalidatePaintUsingContainer(paintInvalidationContainer, dirtyRect, PaintIn
validationRectangle); | 1154 invalidatePaintUsingContainer(paintInvalidationContainer, dirtyRect, PaintIn
validationRectangle); |
| 1153 } | 1155 } |
| 1154 | 1156 |
| 1155 void RenderObject::invalidateTreeIfNeeded(const PaintInvalidationState& paintInv
alidationState) | 1157 void LayoutObject::invalidateTreeIfNeeded(const PaintInvalidationState& paintInv
alidationState) |
| 1156 { | 1158 { |
| 1157 ASSERT(!needsLayout()); | 1159 ASSERT(!needsLayout()); |
| 1158 | 1160 |
| 1159 // If we didn't need paint invalidation then our children don't need as well
. | 1161 // If we didn't need paint invalidation then our children don't need as well
. |
| 1160 // Skip walking down the tree as everything should be fine below us. | 1162 // Skip walking down the tree as everything should be fine below us. |
| 1161 if (!shouldCheckForPaintInvalidation(paintInvalidationState)) | 1163 if (!shouldCheckForPaintInvalidation(paintInvalidationState)) |
| 1162 return; | 1164 return; |
| 1163 | 1165 |
| 1164 invalidatePaintIfNeeded(paintInvalidationState, paintInvalidationState.paint
InvalidationContainer()); | 1166 invalidatePaintIfNeeded(paintInvalidationState, paintInvalidationState.paint
InvalidationContainer()); |
| 1165 clearPaintInvalidationState(paintInvalidationState); | 1167 clearPaintInvalidationState(paintInvalidationState); |
| 1166 invalidatePaintOfSubtreesIfNeeded(paintInvalidationState); | 1168 invalidatePaintOfSubtreesIfNeeded(paintInvalidationState); |
| 1167 } | 1169 } |
| 1168 | 1170 |
| 1169 void RenderObject::invalidatePaintOfSubtreesIfNeeded(const PaintInvalidationStat
e& childPaintInvalidationState) | 1171 void LayoutObject::invalidatePaintOfSubtreesIfNeeded(const PaintInvalidationStat
e& childPaintInvalidationState) |
| 1170 { | 1172 { |
| 1171 for (RenderObject* child = slowFirstChild(); child; child = child->nextSibli
ng()) { | 1173 for (LayoutObject* child = slowFirstChild(); child; child = child->nextSibli
ng()) { |
| 1172 if (!child->isOutOfFlowPositioned()) | 1174 if (!child->isOutOfFlowPositioned()) |
| 1173 child->invalidateTreeIfNeeded(childPaintInvalidationState); | 1175 child->invalidateTreeIfNeeded(childPaintInvalidationState); |
| 1174 } | 1176 } |
| 1175 } | 1177 } |
| 1176 | 1178 |
| 1177 static PassRefPtr<TraceEvent::ConvertableToTraceFormat> jsonObjectForOldAndNewRe
cts(const LayoutRect& oldRect, const LayoutPoint& oldLocation, const LayoutRect&
newRect, const LayoutPoint& newLocation) | 1179 static PassRefPtr<TraceEvent::ConvertableToTraceFormat> jsonObjectForOldAndNewRe
cts(const LayoutRect& oldRect, const LayoutPoint& oldLocation, const LayoutRect&
newRect, const LayoutPoint& newLocation) |
| 1178 { | 1180 { |
| 1179 RefPtr<TracedValue> value = TracedValue::create(); | 1181 RefPtr<TracedValue> value = TracedValue::create(); |
| 1180 addJsonObjectForRect(value.get(), "oldRect", oldRect); | 1182 addJsonObjectForRect(value.get(), "oldRect", oldRect); |
| 1181 addJsonObjectForPoint(value.get(), "oldLocation", oldLocation); | 1183 addJsonObjectForPoint(value.get(), "oldLocation", oldLocation); |
| 1182 addJsonObjectForRect(value.get(), "newRect", newRect); | 1184 addJsonObjectForRect(value.get(), "newRect", newRect); |
| 1183 addJsonObjectForPoint(value.get(), "newLocation", newLocation); | 1185 addJsonObjectForPoint(value.get(), "newLocation", newLocation); |
| 1184 return value; | 1186 return value; |
| 1185 } | 1187 } |
| 1186 | 1188 |
| 1187 LayoutRect RenderObject::previousSelectionRectForPaintInvalidation() const | 1189 LayoutRect LayoutObject::previousSelectionRectForPaintInvalidation() const |
| 1188 { | 1190 { |
| 1189 if (!selectionPaintInvalidationMap) | 1191 if (!selectionPaintInvalidationMap) |
| 1190 return LayoutRect(); | 1192 return LayoutRect(); |
| 1191 | 1193 |
| 1192 return selectionPaintInvalidationMap->get(this); | 1194 return selectionPaintInvalidationMap->get(this); |
| 1193 } | 1195 } |
| 1194 | 1196 |
| 1195 void RenderObject::setPreviousSelectionRectForPaintInvalidation(const LayoutRect
& selectionRect) | 1197 void LayoutObject::setPreviousSelectionRectForPaintInvalidation(const LayoutRect
& selectionRect) |
| 1196 { | 1198 { |
| 1197 if (!selectionPaintInvalidationMap) { | 1199 if (!selectionPaintInvalidationMap) { |
| 1198 if (selectionRect.isEmpty()) | 1200 if (selectionRect.isEmpty()) |
| 1199 return; | 1201 return; |
| 1200 selectionPaintInvalidationMap = new SelectionPaintInvalidationMap(); | 1202 selectionPaintInvalidationMap = new SelectionPaintInvalidationMap(); |
| 1201 } | 1203 } |
| 1202 | 1204 |
| 1203 if (selectionRect.isEmpty()) | 1205 if (selectionRect.isEmpty()) |
| 1204 selectionPaintInvalidationMap->remove(this); | 1206 selectionPaintInvalidationMap->remove(this); |
| 1205 else | 1207 else |
| 1206 selectionPaintInvalidationMap->set(this, selectionRect); | 1208 selectionPaintInvalidationMap->set(this, selectionRect); |
| 1207 } | 1209 } |
| 1208 | 1210 |
| 1209 void RenderObject::invalidateSelectionIfNeeded(const LayoutLayerModelObject& pai
ntInvalidationContainer, PaintInvalidationReason invalidationReason) | 1211 void LayoutObject::invalidateSelectionIfNeeded(const LayoutLayerModelObject& pai
ntInvalidationContainer, PaintInvalidationReason invalidationReason) |
| 1210 { | 1212 { |
| 1211 // Update selection rect when we are doing full invalidation (in case that t
he object is moved, composite status changed, etc.) | 1213 // Update selection rect when we are doing full invalidation (in case that t
he object is moved, composite status changed, etc.) |
| 1212 // or shouldInvalidationSelection is set (in case that the selection itself
changed). | 1214 // or shouldInvalidationSelection is set (in case that the selection itself
changed). |
| 1213 bool fullInvalidation = view()->doingFullPaintInvalidation() || isFullPaintI
nvalidationReason(invalidationReason); | 1215 bool fullInvalidation = view()->doingFullPaintInvalidation() || isFullPaintI
nvalidationReason(invalidationReason); |
| 1214 if (!fullInvalidation && !shouldInvalidateSelection()) | 1216 if (!fullInvalidation && !shouldInvalidateSelection()) |
| 1215 return; | 1217 return; |
| 1216 | 1218 |
| 1217 LayoutRect oldSelectionRect = previousSelectionRectForPaintInvalidation(); | 1219 LayoutRect oldSelectionRect = previousSelectionRectForPaintInvalidation(); |
| 1218 LayoutRect newSelectionRect = selectionRectForPaintInvalidation(&paintInvali
dationContainer); | 1220 LayoutRect newSelectionRect = selectionRectForPaintInvalidation(&paintInvali
dationContainer); |
| 1219 setPreviousSelectionRectForPaintInvalidation(newSelectionRect); | 1221 setPreviousSelectionRectForPaintInvalidation(newSelectionRect); |
| 1220 | 1222 |
| 1221 if (fullInvalidation) | 1223 if (fullInvalidation) |
| 1222 return; | 1224 return; |
| 1223 | 1225 |
| 1224 fullyInvalidatePaint(paintInvalidationContainer, PaintInvalidationSelection,
oldSelectionRect, newSelectionRect); | 1226 fullyInvalidatePaint(paintInvalidationContainer, PaintInvalidationSelection,
oldSelectionRect, newSelectionRect); |
| 1225 } | 1227 } |
| 1226 | 1228 |
| 1227 PaintInvalidationReason RenderObject::invalidatePaintIfNeeded(const PaintInvalid
ationState& paintInvalidationState, const LayoutLayerModelObject& paintInvalidat
ionContainer) | 1229 PaintInvalidationReason LayoutObject::invalidatePaintIfNeeded(const PaintInvalid
ationState& paintInvalidationState, const LayoutLayerModelObject& paintInvalidat
ionContainer) |
| 1228 { | 1230 { |
| 1229 RenderView* v = view(); | 1231 RenderView* v = view(); |
| 1230 if (v->document().printing()) | 1232 if (v->document().printing()) |
| 1231 return PaintInvalidationNone; // Don't invalidate paints if we're printi
ng. | 1233 return PaintInvalidationNone; // Don't invalidate paints if we're printi
ng. |
| 1232 | 1234 |
| 1233 const LayoutRect oldBounds = previousPaintInvalidationRect(); | 1235 const LayoutRect oldBounds = previousPaintInvalidationRect(); |
| 1234 const LayoutPoint oldLocation = previousPositionFromPaintInvalidationBacking
(); | 1236 const LayoutPoint oldLocation = previousPositionFromPaintInvalidationBacking
(); |
| 1235 const LayoutRect newBounds = boundsRectForPaintInvalidation(&paintInvalidati
onContainer, &paintInvalidationState); | 1237 const LayoutRect newBounds = boundsRectForPaintInvalidation(&paintInvalidati
onContainer, &paintInvalidationState); |
| 1236 const LayoutPoint newLocation = Layer::positionFromPaintInvalidationBacking(
this, &paintInvalidationContainer, &paintInvalidationState); | 1238 const LayoutPoint newLocation = Layer::positionFromPaintInvalidationBacking(
this, &paintInvalidationContainer, &paintInvalidationState); |
| 1237 setPreviousPaintInvalidationRect(newBounds); | 1239 setPreviousPaintInvalidationRect(newBounds); |
| 1238 setPreviousPositionFromPaintInvalidationBacking(newLocation); | 1240 setPreviousPositionFromPaintInvalidationBacking(newLocation); |
| 1239 | 1241 |
| 1240 PaintInvalidationReason invalidationReason = paintInvalidationReason(paintIn
validationContainer, oldBounds, oldLocation, newBounds, newLocation); | 1242 PaintInvalidationReason invalidationReason = paintInvalidationReason(paintIn
validationContainer, oldBounds, oldLocation, newBounds, newLocation); |
| 1241 | 1243 |
| 1242 // We need to invalidate the selection before checking for whether we are do
ing a full invalidation. | 1244 // We need to invalidate the selection before checking for whether we are do
ing a full invalidation. |
| 1243 // This is because we need to update the old rect regardless. | 1245 // This is because we need to update the old rect regardless. |
| 1244 invalidateSelectionIfNeeded(paintInvalidationContainer, invalidationReason); | 1246 invalidateSelectionIfNeeded(paintInvalidationContainer, invalidationReason); |
| 1245 | 1247 |
| 1246 // If we are set to do a full paint invalidation that means the RenderView w
ill issue | 1248 // If we are set to do a full paint invalidation that means the RenderView w
ill issue |
| 1247 // paint invalidations. We can then skip issuing of paint invalidations for
the child | 1249 // paint invalidations. We can then skip issuing of paint invalidations for
the child |
| 1248 // renderers as they'll be covered by the RenderView. | 1250 // renderers as they'll be covered by the RenderView. |
| 1249 if (view()->doingFullPaintInvalidation()) | 1251 if (view()->doingFullPaintInvalidation()) |
| 1250 return invalidationReason; | 1252 return invalidationReason; |
| 1251 | 1253 |
| 1252 TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("blink.invalidation"), "RenderObject:
:invalidatePaintIfNeeded()", | 1254 TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("blink.invalidation"), "LayoutObject:
:invalidatePaintIfNeeded()", |
| 1253 "object", this->debugName().ascii(), | 1255 "object", this->debugName().ascii(), |
| 1254 "info", jsonObjectForOldAndNewRects(oldBounds, oldLocation, newBounds, n
ewLocation)); | 1256 "info", jsonObjectForOldAndNewRects(oldBounds, oldLocation, newBounds, n
ewLocation)); |
| 1255 | 1257 |
| 1256 if (invalidationReason == PaintInvalidationNone) | 1258 if (invalidationReason == PaintInvalidationNone) |
| 1257 return invalidationReason; | 1259 return invalidationReason; |
| 1258 | 1260 |
| 1259 if (invalidationReason == PaintInvalidationIncremental) { | 1261 if (invalidationReason == PaintInvalidationIncremental) { |
| 1260 incrementallyInvalidatePaint(paintInvalidationContainer, oldBounds, newB
ounds, newLocation); | 1262 incrementallyInvalidatePaint(paintInvalidationContainer, oldBounds, newB
ounds, newLocation); |
| 1261 return invalidationReason; | 1263 return invalidationReason; |
| 1262 } | 1264 } |
| 1263 | 1265 |
| 1264 fullyInvalidatePaint(paintInvalidationContainer, invalidationReason, oldBoun
ds, newBounds); | 1266 fullyInvalidatePaint(paintInvalidationContainer, invalidationReason, oldBoun
ds, newBounds); |
| 1265 return invalidationReason; | 1267 return invalidationReason; |
| 1266 } | 1268 } |
| 1267 | 1269 |
| 1268 PaintInvalidationReason RenderObject::paintInvalidationReason(const LayoutLayerM
odelObject& paintInvalidationContainer, | 1270 PaintInvalidationReason LayoutObject::paintInvalidationReason(const LayoutLayerM
odelObject& paintInvalidationContainer, |
| 1269 const LayoutRect& oldBounds, const LayoutPoint& oldPositionFromPaintInvalida
tionBacking, | 1271 const LayoutRect& oldBounds, const LayoutPoint& oldPositionFromPaintInvalida
tionBacking, |
| 1270 const LayoutRect& newBounds, const LayoutPoint& newPositionFromPaintInvalida
tionBacking) const | 1272 const LayoutRect& newBounds, const LayoutPoint& newPositionFromPaintInvalida
tionBacking) const |
| 1271 { | 1273 { |
| 1272 // First check for InvalidationLocationChange to avoid it from being hidden
by other | 1274 // First check for InvalidationLocationChange to avoid it from being hidden
by other |
| 1273 // invalidation reasons because we'll need to force check for paint invalida
tion for | 1275 // invalidation reasons because we'll need to force check for paint invalida
tion for |
| 1274 // children when location of this object changed. | 1276 // children when location of this object changed. |
| 1275 if (newPositionFromPaintInvalidationBacking != oldPositionFromPaintInvalidat
ionBacking) | 1277 if (newPositionFromPaintInvalidationBacking != oldPositionFromPaintInvalidat
ionBacking) |
| 1276 return PaintInvalidationLocationChange; | 1278 return PaintInvalidationLocationChange; |
| 1277 | 1279 |
| 1278 if (shouldDoFullPaintInvalidation()) | 1280 if (shouldDoFullPaintInvalidation()) |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1301 // into the incremental invalidation we'll issue two invalidations instead | 1303 // into the incremental invalidation we'll issue two invalidations instead |
| 1302 // of one. | 1304 // of one. |
| 1303 if (oldBounds.isEmpty()) | 1305 if (oldBounds.isEmpty()) |
| 1304 return PaintInvalidationBecameVisible; | 1306 return PaintInvalidationBecameVisible; |
| 1305 if (newBounds.isEmpty()) | 1307 if (newBounds.isEmpty()) |
| 1306 return PaintInvalidationBecameInvisible; | 1308 return PaintInvalidationBecameInvisible; |
| 1307 | 1309 |
| 1308 return PaintInvalidationIncremental; | 1310 return PaintInvalidationIncremental; |
| 1309 } | 1311 } |
| 1310 | 1312 |
| 1311 void RenderObject::incrementallyInvalidatePaint(const LayoutLayerModelObject& pa
intInvalidationContainer, const LayoutRect& oldBounds, const LayoutRect& newBoun
ds, const LayoutPoint& positionFromPaintInvalidationBacking) | 1313 void LayoutObject::incrementallyInvalidatePaint(const LayoutLayerModelObject& pa
intInvalidationContainer, const LayoutRect& oldBounds, const LayoutRect& newBoun
ds, const LayoutPoint& positionFromPaintInvalidationBacking) |
| 1312 { | 1314 { |
| 1313 ASSERT(oldBounds.location() == newBounds.location()); | 1315 ASSERT(oldBounds.location() == newBounds.location()); |
| 1314 | 1316 |
| 1315 LayoutUnit deltaRight = newBounds.maxX() - oldBounds.maxX(); | 1317 LayoutUnit deltaRight = newBounds.maxX() - oldBounds.maxX(); |
| 1316 if (deltaRight > 0) | 1318 if (deltaRight > 0) |
| 1317 invalidatePaintUsingContainer(&paintInvalidationContainer, LayoutRect(ol
dBounds.maxX(), newBounds.y(), deltaRight, newBounds.height()), PaintInvalidatio
nIncremental); | 1319 invalidatePaintUsingContainer(&paintInvalidationContainer, LayoutRect(ol
dBounds.maxX(), newBounds.y(), deltaRight, newBounds.height()), PaintInvalidatio
nIncremental); |
| 1318 else if (deltaRight < 0) | 1320 else if (deltaRight < 0) |
| 1319 invalidatePaintUsingContainer(&paintInvalidationContainer, LayoutRect(ne
wBounds.maxX(), oldBounds.y(), -deltaRight, oldBounds.height()), PaintInvalidati
onIncremental); | 1321 invalidatePaintUsingContainer(&paintInvalidationContainer, LayoutRect(ne
wBounds.maxX(), oldBounds.y(), -deltaRight, oldBounds.height()), PaintInvalidati
onIncremental); |
| 1320 | 1322 |
| 1321 LayoutUnit deltaBottom = newBounds.maxY() - oldBounds.maxY(); | 1323 LayoutUnit deltaBottom = newBounds.maxY() - oldBounds.maxY(); |
| 1322 if (deltaBottom > 0) | 1324 if (deltaBottom > 0) |
| 1323 invalidatePaintUsingContainer(&paintInvalidationContainer, LayoutRect(ne
wBounds.x(), oldBounds.maxY(), newBounds.width(), deltaBottom), PaintInvalidatio
nIncremental); | 1325 invalidatePaintUsingContainer(&paintInvalidationContainer, LayoutRect(ne
wBounds.x(), oldBounds.maxY(), newBounds.width(), deltaBottom), PaintInvalidatio
nIncremental); |
| 1324 else if (deltaBottom < 0) | 1326 else if (deltaBottom < 0) |
| 1325 invalidatePaintUsingContainer(&paintInvalidationContainer, LayoutRect(ol
dBounds.x(), newBounds.maxY(), oldBounds.width(), -deltaBottom), PaintInvalidati
onIncremental); | 1327 invalidatePaintUsingContainer(&paintInvalidationContainer, LayoutRect(ol
dBounds.x(), newBounds.maxY(), oldBounds.width(), -deltaBottom), PaintInvalidati
onIncremental); |
| 1326 } | 1328 } |
| 1327 | 1329 |
| 1328 void RenderObject::fullyInvalidatePaint(const LayoutLayerModelObject& paintInval
idationContainer, PaintInvalidationReason invalidationReason, const LayoutRect&
oldBounds, const LayoutRect& newBounds) | 1330 void LayoutObject::fullyInvalidatePaint(const LayoutLayerModelObject& paintInval
idationContainer, PaintInvalidationReason invalidationReason, const LayoutRect&
oldBounds, const LayoutRect& newBounds) |
| 1329 { | 1331 { |
| 1330 // Otherwise do full paint invalidation. | 1332 // Otherwise do full paint invalidation. |
| 1331 invalidatePaintUsingContainer(&paintInvalidationContainer, oldBounds, invali
dationReason); | 1333 invalidatePaintUsingContainer(&paintInvalidationContainer, oldBounds, invali
dationReason); |
| 1332 if (newBounds != oldBounds) | 1334 if (newBounds != oldBounds) |
| 1333 invalidatePaintUsingContainer(&paintInvalidationContainer, newBounds, in
validationReason); | 1335 invalidatePaintUsingContainer(&paintInvalidationContainer, newBounds, in
validationReason); |
| 1334 } | 1336 } |
| 1335 | 1337 |
| 1336 void RenderObject::invalidatePaintForOverflow() | 1338 void LayoutObject::invalidatePaintForOverflow() |
| 1337 { | 1339 { |
| 1338 } | 1340 } |
| 1339 | 1341 |
| 1340 void RenderObject::invalidatePaintForOverflowIfNeeded() | 1342 void LayoutObject::invalidatePaintForOverflowIfNeeded() |
| 1341 { | 1343 { |
| 1342 if (shouldInvalidateOverflowForPaint()) | 1344 if (shouldInvalidateOverflowForPaint()) |
| 1343 invalidatePaintForOverflow(); | 1345 invalidatePaintForOverflow(); |
| 1344 } | 1346 } |
| 1345 | 1347 |
| 1346 LayoutRect RenderObject::rectWithOutlineForPaintInvalidation(const LayoutLayerMo
delObject* paintInvalidationContainer, LayoutUnit outlineWidth, const PaintInval
idationState* paintInvalidationState) const | 1348 LayoutRect LayoutObject::rectWithOutlineForPaintInvalidation(const LayoutLayerMo
delObject* paintInvalidationContainer, LayoutUnit outlineWidth, const PaintInval
idationState* paintInvalidationState) const |
| 1347 { | 1349 { |
| 1348 LayoutRect r(clippedOverflowRectForPaintInvalidation(paintInvalidationContai
ner, paintInvalidationState)); | 1350 LayoutRect r(clippedOverflowRectForPaintInvalidation(paintInvalidationContai
ner, paintInvalidationState)); |
| 1349 r.inflate(outlineWidth); | 1351 r.inflate(outlineWidth); |
| 1350 return r; | 1352 return r; |
| 1351 } | 1353 } |
| 1352 | 1354 |
| 1353 LayoutRect RenderObject::absoluteClippedOverflowRect() const | 1355 LayoutRect LayoutObject::absoluteClippedOverflowRect() const |
| 1354 { | 1356 { |
| 1355 return clippedOverflowRectForPaintInvalidation(view()); | 1357 return clippedOverflowRectForPaintInvalidation(view()); |
| 1356 } | 1358 } |
| 1357 | 1359 |
| 1358 LayoutRect RenderObject::clippedOverflowRectForPaintInvalidation(const LayoutLay
erModelObject*, const PaintInvalidationState*) const | 1360 LayoutRect LayoutObject::clippedOverflowRectForPaintInvalidation(const LayoutLay
erModelObject*, const PaintInvalidationState*) const |
| 1359 { | 1361 { |
| 1360 ASSERT_NOT_REACHED(); | 1362 ASSERT_NOT_REACHED(); |
| 1361 return LayoutRect(); | 1363 return LayoutRect(); |
| 1362 } | 1364 } |
| 1363 | 1365 |
| 1364 void RenderObject::mapRectToPaintInvalidationBacking(const LayoutLayerModelObjec
t* paintInvalidationContainer, LayoutRect& rect, const PaintInvalidationState* p
aintInvalidationState) const | 1366 void LayoutObject::mapRectToPaintInvalidationBacking(const LayoutLayerModelObjec
t* paintInvalidationContainer, LayoutRect& rect, const PaintInvalidationState* p
aintInvalidationState) const |
| 1365 { | 1367 { |
| 1366 if (paintInvalidationContainer == this) | 1368 if (paintInvalidationContainer == this) |
| 1367 return; | 1369 return; |
| 1368 | 1370 |
| 1369 if (paintInvalidationState && paintInvalidationState->canMapToContainer(pain
tInvalidationContainer)) { | 1371 if (paintInvalidationState && paintInvalidationState->canMapToContainer(pain
tInvalidationContainer)) { |
| 1370 rect.move(paintInvalidationState->paintOffset()); | 1372 rect.move(paintInvalidationState->paintOffset()); |
| 1371 if (paintInvalidationState->isClipped()) | 1373 if (paintInvalidationState->isClipped()) |
| 1372 rect.intersect(paintInvalidationState->clipRect()); | 1374 rect.intersect(paintInvalidationState->clipRect()); |
| 1373 return; | 1375 return; |
| 1374 } | 1376 } |
| 1375 | 1377 |
| 1376 if (RenderObject* o = parent()) { | 1378 if (LayoutObject* o = parent()) { |
| 1377 if (o->isRenderBlockFlow()) { | 1379 if (o->isRenderBlockFlow()) { |
| 1378 RenderBlock* cb = toRenderBlock(o); | 1380 RenderBlock* cb = toRenderBlock(o); |
| 1379 if (cb->hasColumns()) | 1381 if (cb->hasColumns()) |
| 1380 cb->adjustRectForColumns(rect); | 1382 cb->adjustRectForColumns(rect); |
| 1381 } | 1383 } |
| 1382 | 1384 |
| 1383 if (o->hasOverflowClip()) { | 1385 if (o->hasOverflowClip()) { |
| 1384 RenderBox* boxParent = toRenderBox(o); | 1386 RenderBox* boxParent = toRenderBox(o); |
| 1385 boxParent->applyCachedClipAndScrollOffsetForPaintInvalidation(rect); | 1387 boxParent->applyCachedClipAndScrollOffsetForPaintInvalidation(rect); |
| 1386 if (rect.isEmpty()) | 1388 if (rect.isEmpty()) |
| 1387 return; | 1389 return; |
| 1388 } | 1390 } |
| 1389 | 1391 |
| 1390 o->mapRectToPaintInvalidationBacking(paintInvalidationContainer, rect, p
aintInvalidationState); | 1392 o->mapRectToPaintInvalidationBacking(paintInvalidationContainer, rect, p
aintInvalidationState); |
| 1391 } | 1393 } |
| 1392 } | 1394 } |
| 1393 | 1395 |
| 1394 void RenderObject::dirtyLinesFromChangedChild(RenderObject*) | 1396 void LayoutObject::dirtyLinesFromChangedChild(LayoutObject*) |
| 1395 { | 1397 { |
| 1396 } | 1398 } |
| 1397 | 1399 |
| 1398 #ifndef NDEBUG | 1400 #ifndef NDEBUG |
| 1399 | 1401 |
| 1400 void RenderObject::showTreeForThis() const | 1402 void LayoutObject::showTreeForThis() const |
| 1401 { | 1403 { |
| 1402 if (node()) | 1404 if (node()) |
| 1403 node()->showTreeForThis(); | 1405 node()->showTreeForThis(); |
| 1404 } | 1406 } |
| 1405 | 1407 |
| 1406 void RenderObject::showRenderTreeForThis() const | 1408 void LayoutObject::showRenderTreeForThis() const |
| 1407 { | 1409 { |
| 1408 showRenderTree(this, 0); | 1410 showRenderTree(this, 0); |
| 1409 } | 1411 } |
| 1410 | 1412 |
| 1411 void RenderObject::showLineTreeForThis() const | 1413 void LayoutObject::showLineTreeForThis() const |
| 1412 { | 1414 { |
| 1413 if (containingBlock()) | 1415 if (containingBlock()) |
| 1414 containingBlock()->showLineTreeAndMark(0, 0, 0, 0, this); | 1416 containingBlock()->showLineTreeAndMark(0, 0, 0, 0, this); |
| 1415 } | 1417 } |
| 1416 | 1418 |
| 1417 void RenderObject::showRenderObject() const | 1419 void LayoutObject::showLayoutObject() const |
| 1418 { | 1420 { |
| 1419 showRenderObject(0); | 1421 showLayoutObject(0); |
| 1420 } | 1422 } |
| 1421 | 1423 |
| 1422 void RenderObject::showRenderObject(int printedCharacters) const | 1424 void LayoutObject::showLayoutObject(int printedCharacters) const |
| 1423 { | 1425 { |
| 1424 printedCharacters += fprintf(stderr, "%s %p", renderName(), this); | 1426 printedCharacters += fprintf(stderr, "%s %p", renderName(), this); |
| 1425 | 1427 |
| 1426 if (isText() && toRenderText(this)->isTextFragment()) | 1428 if (isText() && toRenderText(this)->isTextFragment()) |
| 1427 printedCharacters += fprintf(stderr, " \"%s\" ", toRenderText(this)->tex
t().ascii().data()); | 1429 printedCharacters += fprintf(stderr, " \"%s\" ", toRenderText(this)->tex
t().ascii().data()); |
| 1428 | 1430 |
| 1429 if (node()) { | 1431 if (node()) { |
| 1430 if (printedCharacters) | 1432 if (printedCharacters) |
| 1431 for (; printedCharacters < showTreeCharacterOffset; printedCharacter
s++) | 1433 for (; printedCharacters < showTreeCharacterOffset; printedCharacter
s++) |
| 1432 fputc(' ', stderr); | 1434 fputc(' ', stderr); |
| 1433 fputc('\t', stderr); | 1435 fputc('\t', stderr); |
| 1434 node()->showNode(); | 1436 node()->showNode(); |
| 1435 } else | 1437 } else { |
| 1436 fputc('\n', stderr); | 1438 fputc('\n', stderr); |
| 1439 } |
| 1437 } | 1440 } |
| 1438 | 1441 |
| 1439 void RenderObject::showRenderTreeAndMark(const RenderObject* markedObject1, cons
t char* markedLabel1, const RenderObject* markedObject2, const char* markedLabel
2, int depth) const | 1442 void LayoutObject::showRenderTreeAndMark(const LayoutObject* markedObject1, cons
t char* markedLabel1, const LayoutObject* markedObject2, const char* markedLabel
2, int depth) const |
| 1440 { | 1443 { |
| 1441 int printedCharacters = 0; | 1444 int printedCharacters = 0; |
| 1442 if (markedObject1 == this && markedLabel1) | 1445 if (markedObject1 == this && markedLabel1) |
| 1443 printedCharacters += fprintf(stderr, "%s", markedLabel1); | 1446 printedCharacters += fprintf(stderr, "%s", markedLabel1); |
| 1444 if (markedObject2 == this && markedLabel2) | 1447 if (markedObject2 == this && markedLabel2) |
| 1445 printedCharacters += fprintf(stderr, "%s", markedLabel2); | 1448 printedCharacters += fprintf(stderr, "%s", markedLabel2); |
| 1446 for (; printedCharacters < depth * 2; printedCharacters++) | 1449 for (; printedCharacters < depth * 2; printedCharacters++) |
| 1447 fputc(' ', stderr); | 1450 fputc(' ', stderr); |
| 1448 | 1451 |
| 1449 showRenderObject(printedCharacters); | 1452 showLayoutObject(printedCharacters); |
| 1450 | 1453 |
| 1451 for (const RenderObject* child = slowFirstChild(); child; child = child->nex
tSibling()) | 1454 for (const LayoutObject* child = slowFirstChild(); child; child = child->nex
tSibling()) |
| 1452 child->showRenderTreeAndMark(markedObject1, markedLabel1, markedObject2,
markedLabel2, depth + 1); | 1455 child->showRenderTreeAndMark(markedObject1, markedLabel1, markedObject2,
markedLabel2, depth + 1); |
| 1453 } | 1456 } |
| 1454 | 1457 |
| 1455 #endif // NDEBUG | 1458 #endif // NDEBUG |
| 1456 | 1459 |
| 1457 bool RenderObject::isSelectable() const | 1460 bool LayoutObject::isSelectable() const |
| 1458 { | 1461 { |
| 1459 return !isInert() && !(style()->userSelect() == SELECT_NONE && style()->user
Modify() == READ_ONLY); | 1462 return !isInert() && !(style()->userSelect() == SELECT_NONE && style()->user
Modify() == READ_ONLY); |
| 1460 } | 1463 } |
| 1461 | 1464 |
| 1462 Color RenderObject::selectionBackgroundColor() const | 1465 Color LayoutObject::selectionBackgroundColor() const |
| 1463 { | 1466 { |
| 1464 if (!isSelectable()) | 1467 if (!isSelectable()) |
| 1465 return Color::transparent; | 1468 return Color::transparent; |
| 1466 | 1469 |
| 1467 if (RefPtr<RenderStyle> pseudoStyle = getUncachedPseudoStyleFromParentOrShad
owHost()) | 1470 if (RefPtr<RenderStyle> pseudoStyle = getUncachedPseudoStyleFromParentOrShad
owHost()) |
| 1468 return resolveColor(*pseudoStyle, CSSPropertyBackgroundColor).blendWithW
hite(); | 1471 return resolveColor(*pseudoStyle, CSSPropertyBackgroundColor).blendWithW
hite(); |
| 1469 return frame()->selection().isFocusedAndActive() ? | 1472 return frame()->selection().isFocusedAndActive() ? |
| 1470 LayoutTheme::theme().activeSelectionBackgroundColor() : | 1473 LayoutTheme::theme().activeSelectionBackgroundColor() : |
| 1471 LayoutTheme::theme().inactiveSelectionBackgroundColor(); | 1474 LayoutTheme::theme().inactiveSelectionBackgroundColor(); |
| 1472 } | 1475 } |
| 1473 | 1476 |
| 1474 Color RenderObject::selectionColor(int colorProperty) const | 1477 Color LayoutObject::selectionColor(int colorProperty) const |
| 1475 { | 1478 { |
| 1476 // If the element is unselectable, or we are only painting the selection, | 1479 // If the element is unselectable, or we are only painting the selection, |
| 1477 // don't override the foreground color with the selection foreground color. | 1480 // don't override the foreground color with the selection foreground color. |
| 1478 if (!isSelectable() || (frame()->view()->paintBehavior() & PaintBehaviorSele
ctionOnly)) | 1481 if (!isSelectable() || (frame()->view()->paintBehavior() & PaintBehaviorSele
ctionOnly)) |
| 1479 return resolveColor(colorProperty); | 1482 return resolveColor(colorProperty); |
| 1480 | 1483 |
| 1481 if (RefPtr<RenderStyle> pseudoStyle = getUncachedPseudoStyleFromParentOrShad
owHost()) | 1484 if (RefPtr<RenderStyle> pseudoStyle = getUncachedPseudoStyleFromParentOrShad
owHost()) |
| 1482 return resolveColor(*pseudoStyle, colorProperty); | 1485 return resolveColor(*pseudoStyle, colorProperty); |
| 1483 if (!LayoutTheme::theme().supportsSelectionForegroundColors()) | 1486 if (!LayoutTheme::theme().supportsSelectionForegroundColors()) |
| 1484 return resolveColor(colorProperty); | 1487 return resolveColor(colorProperty); |
| 1485 return frame()->selection().isFocusedAndActive() ? | 1488 return frame()->selection().isFocusedAndActive() ? |
| 1486 LayoutTheme::theme().activeSelectionForegroundColor() : | 1489 LayoutTheme::theme().activeSelectionForegroundColor() : |
| 1487 LayoutTheme::theme().inactiveSelectionForegroundColor(); | 1490 LayoutTheme::theme().inactiveSelectionForegroundColor(); |
| 1488 } | 1491 } |
| 1489 | 1492 |
| 1490 Color RenderObject::selectionForegroundColor() const | 1493 Color LayoutObject::selectionForegroundColor() const |
| 1491 { | 1494 { |
| 1492 return selectionColor(CSSPropertyWebkitTextFillColor); | 1495 return selectionColor(CSSPropertyWebkitTextFillColor); |
| 1493 } | 1496 } |
| 1494 | 1497 |
| 1495 Color RenderObject::selectionEmphasisMarkColor() const | 1498 Color LayoutObject::selectionEmphasisMarkColor() const |
| 1496 { | 1499 { |
| 1497 return selectionColor(CSSPropertyWebkitTextEmphasisColor); | 1500 return selectionColor(CSSPropertyWebkitTextEmphasisColor); |
| 1498 } | 1501 } |
| 1499 | 1502 |
| 1500 void RenderObject::selectionStartEnd(int& spos, int& epos) const | 1503 void LayoutObject::selectionStartEnd(int& spos, int& epos) const |
| 1501 { | 1504 { |
| 1502 view()->selectionStartEnd(spos, epos); | 1505 view()->selectionStartEnd(spos, epos); |
| 1503 } | 1506 } |
| 1504 | 1507 |
| 1505 void RenderObject::handleDynamicFloatPositionChange() | 1508 void LayoutObject::handleDynamicFloatPositionChange() |
| 1506 { | 1509 { |
| 1507 // We have gone from not affecting the inline status of the parent flow to s
uddenly | 1510 // We have gone from not affecting the inline status of the parent flow to s
uddenly |
| 1508 // having an impact. See if there is a mismatch between the parent flow's | 1511 // having an impact. See if there is a mismatch between the parent flow's |
| 1509 // childrenInline() state and our state. | 1512 // childrenInline() state and our state. |
| 1510 setInline(style()->isDisplayInlineType()); | 1513 setInline(style()->isDisplayInlineType()); |
| 1511 if (isInline() != parent()->childrenInline()) { | 1514 if (isInline() != parent()->childrenInline()) { |
| 1512 if (!isInline()) | 1515 if (!isInline()) { |
| 1513 toRenderBoxModelObject(parent())->childBecameNonInline(this); | 1516 toRenderBoxModelObject(parent())->childBecameNonInline(this); |
| 1514 else { | 1517 } else { |
| 1515 // An anonymous block must be made to wrap this inline. | 1518 // An anonymous block must be made to wrap this inline. |
| 1516 RenderBlock* block = toRenderBlock(parent())->createAnonymousBlock()
; | 1519 RenderBlock* block = toRenderBlock(parent())->createAnonymousBlock()
; |
| 1517 RenderObjectChildList* childlist = parent()->virtualChildren(); | 1520 LayoutObjectChildList* childlist = parent()->virtualChildren(); |
| 1518 childlist->insertChildNode(parent(), block, this); | 1521 childlist->insertChildNode(parent(), block, this); |
| 1519 block->children()->appendChildNode(block, childlist->removeChildNode
(parent(), this)); | 1522 block->children()->appendChildNode(block, childlist->removeChildNode
(parent(), this)); |
| 1520 } | 1523 } |
| 1521 } | 1524 } |
| 1522 } | 1525 } |
| 1523 | 1526 |
| 1524 StyleDifference RenderObject::adjustStyleDifference(StyleDifference diff) const | 1527 StyleDifference LayoutObject::adjustStyleDifference(StyleDifference diff) const |
| 1525 { | 1528 { |
| 1526 if (diff.transformChanged() && isSVG()) | 1529 if (diff.transformChanged() && isSVG()) |
| 1527 diff.setNeedsFullLayout(); | 1530 diff.setNeedsFullLayout(); |
| 1528 | 1531 |
| 1529 // If transform changed, and the layer does not paint into its own separate
backing, then we need to invalidate paints. | 1532 // If transform changed, and the layer does not paint into its own separate
backing, then we need to invalidate paints. |
| 1530 if (diff.transformChanged()) { | 1533 if (diff.transformChanged()) { |
| 1531 // Text nodes share style with their parents but transforms don't apply
to them, | 1534 // Text nodes share style with their parents but transforms don't apply
to them, |
| 1532 // hence the !isText() check. | 1535 // hence the !isText() check. |
| 1533 if (!isText() && (!hasLayer() || !toLayoutLayerModelObject(this)->layer(
)->hasStyleDeterminedDirectCompositingReasons())) | 1536 if (!isText() && (!hasLayer() || !toLayoutLayerModelObject(this)->layer(
)->hasStyleDeterminedDirectCompositingReasons())) |
| 1534 diff.setNeedsPaintInvalidationLayer(); | 1537 diff.setNeedsPaintInvalidationLayer(); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1565 | 1568 |
| 1566 // If we have no layer(), just treat a PaintInvalidationLayer hint as a norm
al paint invalidation. | 1569 // If we have no layer(), just treat a PaintInvalidationLayer hint as a norm
al paint invalidation. |
| 1567 if (diff.needsPaintInvalidationLayer() && !hasLayer()) { | 1570 if (diff.needsPaintInvalidationLayer() && !hasLayer()) { |
| 1568 diff.clearNeedsPaintInvalidation(); | 1571 diff.clearNeedsPaintInvalidation(); |
| 1569 diff.setNeedsPaintInvalidationObject(); | 1572 diff.setNeedsPaintInvalidationObject(); |
| 1570 } | 1573 } |
| 1571 | 1574 |
| 1572 return diff; | 1575 return diff; |
| 1573 } | 1576 } |
| 1574 | 1577 |
| 1575 void RenderObject::setPseudoStyle(PassRefPtr<RenderStyle> pseudoStyle) | 1578 void LayoutObject::setPseudoStyle(PassRefPtr<RenderStyle> pseudoStyle) |
| 1576 { | 1579 { |
| 1577 ASSERT(pseudoStyle->styleType() == BEFORE || pseudoStyle->styleType() == AFT
ER || pseudoStyle->styleType() == FIRST_LETTER); | 1580 ASSERT(pseudoStyle->styleType() == BEFORE || pseudoStyle->styleType() == AFT
ER || pseudoStyle->styleType() == FIRST_LETTER); |
| 1578 | 1581 |
| 1579 // FIXME: We should consider just making all pseudo items use an inherited s
tyle. | 1582 // FIXME: We should consider just making all pseudo items use an inherited s
tyle. |
| 1580 | 1583 |
| 1581 // Images are special and must inherit the pseudoStyle so the width and heig
ht of | 1584 // Images are special and must inherit the pseudoStyle so the width and heig
ht of |
| 1582 // the pseudo element doesn't change the size of the image. In all other cas
es we | 1585 // the pseudo element doesn't change the size of the image. In all other cas
es we |
| 1583 // can just share the style. | 1586 // can just share the style. |
| 1584 // | 1587 // |
| 1585 // Quotes are also RenderInline, so we need to create an inherited style to
avoid | 1588 // Quotes are also RenderInline, so we need to create an inherited style to
avoid |
| 1586 // getting an inline with positioning or an invalid display. | 1589 // getting an inline with positioning or an invalid display. |
| 1587 // | 1590 // |
| 1588 if (isImage() || isQuote()) { | 1591 if (isImage() || isQuote()) { |
| 1589 RefPtr<RenderStyle> style = RenderStyle::create(); | 1592 RefPtr<RenderStyle> style = RenderStyle::create(); |
| 1590 style->inheritFrom(pseudoStyle.get()); | 1593 style->inheritFrom(pseudoStyle.get()); |
| 1591 setStyle(style.release()); | 1594 setStyle(style.release()); |
| 1592 return; | 1595 return; |
| 1593 } | 1596 } |
| 1594 | 1597 |
| 1595 setStyle(pseudoStyle); | 1598 setStyle(pseudoStyle); |
| 1596 } | 1599 } |
| 1597 | 1600 |
| 1598 void RenderObject::markContainingBlocksForOverflowRecalc() | 1601 void LayoutObject::markContainingBlocksForOverflowRecalc() |
| 1599 { | 1602 { |
| 1600 for (RenderBlock* container = containingBlock(); container && !container->ch
ildNeedsOverflowRecalcAfterStyleChange(); container = container->containingBlock
()) | 1603 for (RenderBlock* container = containingBlock(); container && !container->ch
ildNeedsOverflowRecalcAfterStyleChange(); container = container->containingBlock
()) |
| 1601 container->setChildNeedsOverflowRecalcAfterStyleChange(true); | 1604 container->setChildNeedsOverflowRecalcAfterStyleChange(true); |
| 1602 } | 1605 } |
| 1603 | 1606 |
| 1604 void RenderObject::setNeedsOverflowRecalcAfterStyleChange() | 1607 void LayoutObject::setNeedsOverflowRecalcAfterStyleChange() |
| 1605 { | 1608 { |
| 1606 bool neededRecalc = needsOverflowRecalcAfterStyleChange(); | 1609 bool neededRecalc = needsOverflowRecalcAfterStyleChange(); |
| 1607 setSelfNeedsOverflowRecalcAfterStyleChange(true); | 1610 setSelfNeedsOverflowRecalcAfterStyleChange(true); |
| 1608 if (!neededRecalc) | 1611 if (!neededRecalc) |
| 1609 markContainingBlocksForOverflowRecalc(); | 1612 markContainingBlocksForOverflowRecalc(); |
| 1610 } | 1613 } |
| 1611 | 1614 |
| 1612 void RenderObject::setStyle(PassRefPtr<RenderStyle> style) | 1615 void LayoutObject::setStyle(PassRefPtr<RenderStyle> style) |
| 1613 { | 1616 { |
| 1614 ASSERT(style); | 1617 ASSERT(style); |
| 1615 | 1618 |
| 1616 if (m_style == style) { | 1619 if (m_style == style) { |
| 1617 // We need to run through adjustStyleDifference() for iframes, plugins,
and canvas so | 1620 // We need to run through adjustStyleDifference() for iframes, plugins,
and canvas so |
| 1618 // style sharing is disabled for them. That should ensure that we never
hit this code path. | 1621 // style sharing is disabled for them. That should ensure that we never
hit this code path. |
| 1619 ASSERT(!isRenderIFrame() && !isEmbeddedObject() && !isCanvas()); | 1622 ASSERT(!isRenderIFrame() && !isEmbeddedObject() && !isCanvas()); |
| 1620 return; | 1623 return; |
| 1621 } | 1624 } |
| 1622 | 1625 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1665 if (RenderBlock* container = containingBlock()) | 1668 if (RenderBlock* container = containingBlock()) |
| 1666 container->setNeedsOverflowRecalcAfterStyleChange(); | 1669 container->setNeedsOverflowRecalcAfterStyleChange(); |
| 1667 } | 1670 } |
| 1668 | 1671 |
| 1669 if (updatedDiff.needsPaintInvalidationLayer()) | 1672 if (updatedDiff.needsPaintInvalidationLayer()) |
| 1670 toLayoutLayerModelObject(this)->layer()->setShouldDoFullPaintInvalidatio
nIncludingNonCompositingDescendants(); | 1673 toLayoutLayerModelObject(this)->layer()->setShouldDoFullPaintInvalidatio
nIncludingNonCompositingDescendants(); |
| 1671 else if (diff.needsPaintInvalidationObject() || updatedDiff.needsPaintInvali
dationObject()) | 1674 else if (diff.needsPaintInvalidationObject() || updatedDiff.needsPaintInvali
dationObject()) |
| 1672 setShouldDoFullPaintInvalidation(); | 1675 setShouldDoFullPaintInvalidation(); |
| 1673 } | 1676 } |
| 1674 | 1677 |
| 1675 static inline bool rendererHasBackground(const RenderObject* renderer) | 1678 static inline bool rendererHasBackground(const LayoutObject* renderer) |
| 1676 { | 1679 { |
| 1677 return renderer && renderer->hasBackground(); | 1680 return renderer && renderer->hasBackground(); |
| 1678 } | 1681 } |
| 1679 | 1682 |
| 1680 void RenderObject::styleWillChange(StyleDifference diff, const RenderStyle& newS
tyle) | 1683 void LayoutObject::styleWillChange(StyleDifference diff, const RenderStyle& newS
tyle) |
| 1681 { | 1684 { |
| 1682 if (m_style) { | 1685 if (m_style) { |
| 1683 // If our z-index changes value or our visibility changes, | 1686 // If our z-index changes value or our visibility changes, |
| 1684 // we need to dirty our stacking context's z-order list. | 1687 // we need to dirty our stacking context's z-order list. |
| 1685 bool visibilityChanged = m_style->visibility() != newStyle.visibility() | 1688 bool visibilityChanged = m_style->visibility() != newStyle.visibility() |
| 1686 || m_style->zIndex() != newStyle.zIndex() | 1689 || m_style->zIndex() != newStyle.zIndex() |
| 1687 || m_style->hasAutoZIndex() != newStyle.hasAutoZIndex(); | 1690 || m_style->hasAutoZIndex() != newStyle.hasAutoZIndex(); |
| 1688 if (visibilityChanged) { | 1691 if (visibilityChanged) { |
| 1689 document().setAnnotatedRegionsDirty(true); | 1692 document().setAnnotatedRegionsDirty(true); |
| 1690 if (AXObjectCache* cache = document().existingAXObjectCache()) | 1693 if (AXObjectCache* cache = document().existingAXObjectCache()) |
| 1691 cache->childrenChanged(parent()); | 1694 cache->childrenChanged(parent()); |
| 1692 } | 1695 } |
| 1693 | 1696 |
| 1694 // Keep layer hierarchy visibility bits up to date if visibility changes
. | 1697 // Keep layer hierarchy visibility bits up to date if visibility changes
. |
| 1695 if (m_style->visibility() != newStyle.visibility()) { | 1698 if (m_style->visibility() != newStyle.visibility()) { |
| 1696 // We might not have an enclosing layer yet because we might not be
in the tree. | 1699 // We might not have an enclosing layer yet because we might not be
in the tree. |
| 1697 if (Layer* layer = enclosingLayer()) | 1700 if (Layer* layer = enclosingLayer()) |
| 1698 layer->potentiallyDirtyVisibleContentStatus(newStyle.visibility(
)); | 1701 layer->potentiallyDirtyVisibleContentStatus(newStyle.visibility(
)); |
| 1699 } | 1702 } |
| 1700 | 1703 |
| 1701 if (isFloating() && (m_style->floating() != newStyle.floating())) | 1704 if (isFloating() && (m_style->floating() != newStyle.floating())) { |
| 1702 // For changes in float styles, we need to conceivably remove oursel
ves | 1705 // For changes in float styles, we need to conceivably remove oursel
ves |
| 1703 // from the floating objects list. | 1706 // from the floating objects list. |
| 1704 toRenderBox(this)->removeFloatingOrPositionedChildFromBlockLists(); | 1707 toRenderBox(this)->removeFloatingOrPositionedChildFromBlockLists(); |
| 1705 else if (isOutOfFlowPositioned() && (m_style->position() != newStyle.pos
ition())) | 1708 } else if (isOutOfFlowPositioned() && (m_style->position() != newStyle.p
osition())) { |
| 1706 // For changes in positioning styles, we need to conceivably remove
ourselves | 1709 // For changes in positioning styles, we need to conceivably remove
ourselves |
| 1707 // from the positioned objects list. | 1710 // from the positioned objects list. |
| 1708 toRenderBox(this)->removeFloatingOrPositionedChildFromBlockLists(); | 1711 toRenderBox(this)->removeFloatingOrPositionedChildFromBlockLists(); |
| 1712 } |
| 1709 | 1713 |
| 1710 s_affectsParentBlock = isFloatingOrOutOfFlowPositioned() | 1714 s_affectsParentBlock = isFloatingOrOutOfFlowPositioned() |
| 1711 && (!newStyle.isFloating() && !newStyle.hasOutOfFlowPosition()) | 1715 && (!newStyle.isFloating() && !newStyle.hasOutOfFlowPosition()) |
| 1712 && parent() && (parent()->isRenderBlockFlow() || parent()->isRenderI
nline()); | 1716 && parent() && (parent()->isRenderBlockFlow() || parent()->isRenderI
nline()); |
| 1713 | 1717 |
| 1714 // Clearing these bits is required to avoid leaving stale renderers. | 1718 // Clearing these bits is required to avoid leaving stale renderers. |
| 1715 // FIXME: We shouldn't need that hack if our logic was totally correct. | 1719 // FIXME: We shouldn't need that hack if our logic was totally correct. |
| 1716 if (diff.needsLayout()) { | 1720 if (diff.needsLayout()) { |
| 1717 setFloating(false); | 1721 setFloating(false); |
| 1718 clearPositionedState(); | 1722 clearPositionedState(); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1772 { | 1776 { |
| 1773 ASSERT(a->cursors() != b->cursors()); | 1777 ASSERT(a->cursors() != b->cursors()); |
| 1774 return a->cursors() && b->cursors() && *a->cursors() == *b->cursors(); | 1778 return a->cursors() && b->cursors() && *a->cursors() == *b->cursors(); |
| 1775 } | 1779 } |
| 1776 | 1780 |
| 1777 static inline bool areCursorsEqual(const RenderStyle* a, const RenderStyle* b) | 1781 static inline bool areCursorsEqual(const RenderStyle* a, const RenderStyle* b) |
| 1778 { | 1782 { |
| 1779 return a->cursor() == b->cursor() && (a->cursors() == b->cursors() || areNon
IdenticalCursorListsEqual(a, b)); | 1783 return a->cursor() == b->cursor() && (a->cursors() == b->cursors() || areNon
IdenticalCursorListsEqual(a, b)); |
| 1780 } | 1784 } |
| 1781 | 1785 |
| 1782 void RenderObject::styleDidChange(StyleDifference diff, const RenderStyle* oldSt
yle) | 1786 void LayoutObject::styleDidChange(StyleDifference diff, const RenderStyle* oldSt
yle) |
| 1783 { | 1787 { |
| 1784 if (s_affectsParentBlock) | 1788 if (s_affectsParentBlock) |
| 1785 handleDynamicFloatPositionChange(); | 1789 handleDynamicFloatPositionChange(); |
| 1786 | 1790 |
| 1787 if (!m_parent) | 1791 if (!m_parent) |
| 1788 return; | 1792 return; |
| 1789 | 1793 |
| 1790 if (diff.needsFullLayout()) { | 1794 if (diff.needsFullLayout()) { |
| 1791 LayoutCounter::rendererStyleChanged(*this, oldStyle, m_style.get()); | 1795 LayoutCounter::rendererStyleChanged(*this, oldStyle, m_style.get()); |
| 1792 | 1796 |
| 1793 // If the object already needs layout, then setNeedsLayout won't do | 1797 // If the object already needs layout, then setNeedsLayout won't do |
| 1794 // any work. But if the containing block has changed, then we may need | 1798 // any work. But if the containing block has changed, then we may need |
| 1795 // to mark the new containing blocks for layout. The change that can | 1799 // to mark the new containing blocks for layout. The change that can |
| 1796 // directly affect the containing block of this object is a change to | 1800 // directly affect the containing block of this object is a change to |
| 1797 // the position style. | 1801 // the position style. |
| 1798 if (needsLayout() && oldStyle->position() != m_style->position()) | 1802 if (needsLayout() && oldStyle->position() != m_style->position()) |
| 1799 markContainingBlocksForLayout(); | 1803 markContainingBlocksForLayout(); |
| 1800 | 1804 |
| 1801 // Ditto. | 1805 // Ditto. |
| 1802 if (needsOverflowRecalcAfterStyleChange() && oldStyle->position() != m_s
tyle->position()) | 1806 if (needsOverflowRecalcAfterStyleChange() && oldStyle->position() != m_s
tyle->position()) |
| 1803 markContainingBlocksForOverflowRecalc(); | 1807 markContainingBlocksForOverflowRecalc(); |
| 1804 | 1808 |
| 1805 if (diff.needsFullLayout()) | 1809 if (diff.needsFullLayout()) |
| 1806 setNeedsLayoutAndPrefWidthsRecalc(); | 1810 setNeedsLayoutAndPrefWidthsRecalc(); |
| 1807 } else if (diff.needsPositionedMovementLayout()) | 1811 } else if (diff.needsPositionedMovementLayout()) { |
| 1808 setNeedsPositionedMovementLayout(); | 1812 setNeedsPositionedMovementLayout(); |
| 1813 } |
| 1809 | 1814 |
| 1810 // Don't check for paint invalidation here; we need to wait until the layer
has been | 1815 // Don't check for paint invalidation here; we need to wait until the layer
has been |
| 1811 // updated by subclasses before we know if we have to invalidate paints (in
setStyle()). | 1816 // updated by subclasses before we know if we have to invalidate paints (in
setStyle()). |
| 1812 | 1817 |
| 1813 if (oldStyle && !areCursorsEqual(oldStyle, style())) { | 1818 if (oldStyle && !areCursorsEqual(oldStyle, style())) { |
| 1814 if (LocalFrame* frame = this->frame()) | 1819 if (LocalFrame* frame = this->frame()) |
| 1815 frame->eventHandler().scheduleCursorUpdate(); | 1820 frame->eventHandler().scheduleCursorUpdate(); |
| 1816 } | 1821 } |
| 1817 } | 1822 } |
| 1818 | 1823 |
| 1819 void RenderObject::propagateStyleToAnonymousChildren(bool blockChildrenOnly) | 1824 void LayoutObject::propagateStyleToAnonymousChildren(bool blockChildrenOnly) |
| 1820 { | 1825 { |
| 1821 // FIXME: We could save this call when the change only affected non-inherite
d properties. | 1826 // FIXME: We could save this call when the change only affected non-inherite
d properties. |
| 1822 for (RenderObject* child = slowFirstChild(); child; child = child->nextSibli
ng()) { | 1827 for (LayoutObject* child = slowFirstChild(); child; child = child->nextSibli
ng()) { |
| 1823 if (!child->isAnonymous() || child->style()->styleType() != NOPSEUDO) | 1828 if (!child->isAnonymous() || child->style()->styleType() != NOPSEUDO) |
| 1824 continue; | 1829 continue; |
| 1825 | 1830 |
| 1826 if (blockChildrenOnly && !child->isRenderBlock()) | 1831 if (blockChildrenOnly && !child->isRenderBlock()) |
| 1827 continue; | 1832 continue; |
| 1828 | 1833 |
| 1829 if (child->isRenderFullScreen() || child->isRenderFullScreenPlaceholder(
)) | 1834 if (child->isRenderFullScreen() || child->isRenderFullScreenPlaceholder(
)) |
| 1830 continue; | 1835 continue; |
| 1831 | 1836 |
| 1832 RefPtr<RenderStyle> newStyle = RenderStyle::createAnonymousStyleWithDisp
lay(style(), child->style()->display()); | 1837 RefPtr<RenderStyle> newStyle = RenderStyle::createAnonymousStyleWithDisp
lay(style(), child->style()->display()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1843 // they contain block descendants of relative positioned inlines. | 1848 // they contain block descendants of relative positioned inlines. |
| 1844 if (child->isRelPositioned() && toRenderBlock(child)->isAnonymousBlockCo
ntinuation()) | 1849 if (child->isRelPositioned() && toRenderBlock(child)->isAnonymousBlockCo
ntinuation()) |
| 1845 newStyle->setPosition(child->style()->position()); | 1850 newStyle->setPosition(child->style()->position()); |
| 1846 | 1851 |
| 1847 updateAnonymousChildStyle(child, newStyle.get()); | 1852 updateAnonymousChildStyle(child, newStyle.get()); |
| 1848 | 1853 |
| 1849 child->setStyle(newStyle.release()); | 1854 child->setStyle(newStyle.release()); |
| 1850 } | 1855 } |
| 1851 } | 1856 } |
| 1852 | 1857 |
| 1853 void RenderObject::updateFillImages(const FillLayer* oldLayers, const FillLayer&
newLayers) | 1858 void LayoutObject::updateFillImages(const FillLayer* oldLayers, const FillLayer&
newLayers) |
| 1854 { | 1859 { |
| 1855 // Optimize the common case | 1860 // Optimize the common case |
| 1856 if (oldLayers && !oldLayers->next() && !newLayers.next() && (oldLayers->imag
e() == newLayers.image())) | 1861 if (oldLayers && !oldLayers->next() && !newLayers.next() && (oldLayers->imag
e() == newLayers.image())) |
| 1857 return; | 1862 return; |
| 1858 | 1863 |
| 1859 // Go through the new layers and addClients first, to avoid removing all cli
ents of an image. | 1864 // Go through the new layers and addClients first, to avoid removing all cli
ents of an image. |
| 1860 for (const FillLayer* currNew = &newLayers; currNew; currNew = currNew->next
()) { | 1865 for (const FillLayer* currNew = &newLayers; currNew; currNew = currNew->next
()) { |
| 1861 if (currNew->image()) | 1866 if (currNew->image()) |
| 1862 currNew->image()->addClient(this); | 1867 currNew->image()->addClient(this); |
| 1863 } | 1868 } |
| 1864 | 1869 |
| 1865 for (const FillLayer* currOld = oldLayers; currOld; currOld = currOld->next(
)) { | 1870 for (const FillLayer* currOld = oldLayers; currOld; currOld = currOld->next(
)) { |
| 1866 if (currOld->image()) | 1871 if (currOld->image()) |
| 1867 currOld->image()->removeClient(this); | 1872 currOld->image()->removeClient(this); |
| 1868 } | 1873 } |
| 1869 } | 1874 } |
| 1870 | 1875 |
| 1871 void RenderObject::updateImage(StyleImage* oldImage, StyleImage* newImage) | 1876 void LayoutObject::updateImage(StyleImage* oldImage, StyleImage* newImage) |
| 1872 { | 1877 { |
| 1873 if (oldImage != newImage) { | 1878 if (oldImage != newImage) { |
| 1874 if (oldImage) | 1879 if (oldImage) |
| 1875 oldImage->removeClient(this); | 1880 oldImage->removeClient(this); |
| 1876 if (newImage) | 1881 if (newImage) |
| 1877 newImage->addClient(this); | 1882 newImage->addClient(this); |
| 1878 } | 1883 } |
| 1879 } | 1884 } |
| 1880 | 1885 |
| 1881 void RenderObject::updateShapeImage(const ShapeValue* oldShapeValue, const Shape
Value* newShapeValue) | 1886 void LayoutObject::updateShapeImage(const ShapeValue* oldShapeValue, const Shape
Value* newShapeValue) |
| 1882 { | 1887 { |
| 1883 if (oldShapeValue || newShapeValue) | 1888 if (oldShapeValue || newShapeValue) |
| 1884 updateImage(oldShapeValue ? oldShapeValue->image() : 0, newShapeValue ?
newShapeValue->image() : 0); | 1889 updateImage(oldShapeValue ? oldShapeValue->image() : 0, newShapeValue ?
newShapeValue->image() : 0); |
| 1885 } | 1890 } |
| 1886 | 1891 |
| 1887 LayoutRect RenderObject::viewRect() const | 1892 LayoutRect LayoutObject::viewRect() const |
| 1888 { | 1893 { |
| 1889 return view()->viewRect(); | 1894 return view()->viewRect(); |
| 1890 } | 1895 } |
| 1891 | 1896 |
| 1892 FloatPoint RenderObject::localToAbsolute(const FloatPoint& localPoint, MapCoordi
natesFlags mode) const | 1897 FloatPoint LayoutObject::localToAbsolute(const FloatPoint& localPoint, MapCoordi
natesFlags mode) const |
| 1893 { | 1898 { |
| 1894 TransformState transformState(TransformState::ApplyTransformDirection, local
Point); | 1899 TransformState transformState(TransformState::ApplyTransformDirection, local
Point); |
| 1895 mapLocalToContainer(0, transformState, mode | ApplyContainerFlip); | 1900 mapLocalToContainer(0, transformState, mode | ApplyContainerFlip); |
| 1896 transformState.flatten(); | 1901 transformState.flatten(); |
| 1897 | 1902 |
| 1898 return transformState.lastPlanarPoint(); | 1903 return transformState.lastPlanarPoint(); |
| 1899 } | 1904 } |
| 1900 | 1905 |
| 1901 FloatPoint RenderObject::absoluteToLocal(const FloatPoint& containerPoint, MapCo
ordinatesFlags mode) const | 1906 FloatPoint LayoutObject::absoluteToLocal(const FloatPoint& containerPoint, MapCo
ordinatesFlags mode) const |
| 1902 { | 1907 { |
| 1903 TransformState transformState(TransformState::UnapplyInverseTransformDirecti
on, containerPoint); | 1908 TransformState transformState(TransformState::UnapplyInverseTransformDirecti
on, containerPoint); |
| 1904 mapAbsoluteToLocalPoint(mode, transformState); | 1909 mapAbsoluteToLocalPoint(mode, transformState); |
| 1905 transformState.flatten(); | 1910 transformState.flatten(); |
| 1906 | 1911 |
| 1907 return transformState.lastPlanarPoint(); | 1912 return transformState.lastPlanarPoint(); |
| 1908 } | 1913 } |
| 1909 | 1914 |
| 1910 FloatQuad RenderObject::absoluteToLocalQuad(const FloatQuad& quad, MapCoordinate
sFlags mode) const | 1915 FloatQuad LayoutObject::absoluteToLocalQuad(const FloatQuad& quad, MapCoordinate
sFlags mode) const |
| 1911 { | 1916 { |
| 1912 TransformState transformState(TransformState::UnapplyInverseTransformDirecti
on, quad.boundingBox().center(), quad); | 1917 TransformState transformState(TransformState::UnapplyInverseTransformDirecti
on, quad.boundingBox().center(), quad); |
| 1913 mapAbsoluteToLocalPoint(mode, transformState); | 1918 mapAbsoluteToLocalPoint(mode, transformState); |
| 1914 transformState.flatten(); | 1919 transformState.flatten(); |
| 1915 return transformState.lastPlanarQuad(); | 1920 return transformState.lastPlanarQuad(); |
| 1916 } | 1921 } |
| 1917 | 1922 |
| 1918 void RenderObject::mapLocalToContainer(const LayoutLayerModelObject* paintInvali
dationContainer, TransformState& transformState, MapCoordinatesFlags mode, bool*
wasFixed, const PaintInvalidationState* paintInvalidationState) const | 1923 void LayoutObject::mapLocalToContainer(const LayoutLayerModelObject* paintInvali
dationContainer, TransformState& transformState, MapCoordinatesFlags mode, bool*
wasFixed, const PaintInvalidationState* paintInvalidationState) const |
| 1919 { | 1924 { |
| 1920 if (paintInvalidationContainer == this) | 1925 if (paintInvalidationContainer == this) |
| 1921 return; | 1926 return; |
| 1922 | 1927 |
| 1923 RenderObject* o = parent(); | 1928 LayoutObject* o = parent(); |
| 1924 if (!o) | 1929 if (!o) |
| 1925 return; | 1930 return; |
| 1926 | 1931 |
| 1927 // FIXME: this should call offsetFromContainer to share code, but I'm not su
re it's ever called. | 1932 // FIXME: this should call offsetFromContainer to share code, but I'm not su
re it's ever called. |
| 1928 LayoutPoint centerPoint = roundedLayoutPoint(transformState.mappedPoint()); | 1933 LayoutPoint centerPoint = roundedLayoutPoint(transformState.mappedPoint()); |
| 1929 if (mode & ApplyContainerFlip && o->isBox()) { | 1934 if (mode & ApplyContainerFlip && o->isBox()) { |
| 1930 if (o->style()->isFlippedBlocksWritingMode()) | 1935 if (o->style()->isFlippedBlocksWritingMode()) |
| 1931 transformState.move(toRenderBox(o)->flipForWritingModeIncludingColum
ns(roundedLayoutPoint(transformState.mappedPoint())) - centerPoint); | 1936 transformState.move(toRenderBox(o)->flipForWritingModeIncludingColum
ns(roundedLayoutPoint(transformState.mappedPoint())) - centerPoint); |
| 1932 mode &= ~ApplyContainerFlip; | 1937 mode &= ~ApplyContainerFlip; |
| 1933 } | 1938 } |
| 1934 | 1939 |
| 1935 transformState.move(o->columnOffset(roundedLayoutPoint(transformState.mapped
Point()))); | 1940 transformState.move(o->columnOffset(roundedLayoutPoint(transformState.mapped
Point()))); |
| 1936 | 1941 |
| 1937 if (o->hasOverflowClip()) | 1942 if (o->hasOverflowClip()) |
| 1938 transformState.move(-toRenderBox(o)->scrolledContentOffset()); | 1943 transformState.move(-toRenderBox(o)->scrolledContentOffset()); |
| 1939 | 1944 |
| 1940 o->mapLocalToContainer(paintInvalidationContainer, transformState, mode, was
Fixed, paintInvalidationState); | 1945 o->mapLocalToContainer(paintInvalidationContainer, transformState, mode, was
Fixed, paintInvalidationState); |
| 1941 } | 1946 } |
| 1942 | 1947 |
| 1943 const RenderObject* RenderObject::pushMappingToContainer(const LayoutLayerModelO
bject* ancestorToStopAt, RenderGeometryMap& geometryMap) const | 1948 const LayoutObject* LayoutObject::pushMappingToContainer(const LayoutLayerModelO
bject* ancestorToStopAt, RenderGeometryMap& geometryMap) const |
| 1944 { | 1949 { |
| 1945 ASSERT_UNUSED(ancestorToStopAt, ancestorToStopAt != this); | 1950 ASSERT_UNUSED(ancestorToStopAt, ancestorToStopAt != this); |
| 1946 | 1951 |
| 1947 RenderObject* container = parent(); | 1952 LayoutObject* container = parent(); |
| 1948 if (!container) | 1953 if (!container) |
| 1949 return 0; | 1954 return 0; |
| 1950 | 1955 |
| 1951 // FIXME: this should call offsetFromContainer to share code, but I'm not su
re it's ever called. | 1956 // FIXME: this should call offsetFromContainer to share code, but I'm not su
re it's ever called. |
| 1952 LayoutSize offset; | 1957 LayoutSize offset; |
| 1953 if (container->hasOverflowClip()) | 1958 if (container->hasOverflowClip()) |
| 1954 offset = -LayoutSize(toRenderBox(container)->scrolledContentOffset()); | 1959 offset = -LayoutSize(toRenderBox(container)->scrolledContentOffset()); |
| 1955 | 1960 |
| 1956 geometryMap.push(this, offset, hasColumns()); | 1961 geometryMap.push(this, offset, hasColumns()); |
| 1957 | 1962 |
| 1958 return container; | 1963 return container; |
| 1959 } | 1964 } |
| 1960 | 1965 |
| 1961 void RenderObject::mapAbsoluteToLocalPoint(MapCoordinatesFlags mode, TransformSt
ate& transformState) const | 1966 void LayoutObject::mapAbsoluteToLocalPoint(MapCoordinatesFlags mode, TransformSt
ate& transformState) const |
| 1962 { | 1967 { |
| 1963 RenderObject* o = parent(); | 1968 LayoutObject* o = parent(); |
| 1964 if (o) { | 1969 if (o) { |
| 1965 o->mapAbsoluteToLocalPoint(mode, transformState); | 1970 o->mapAbsoluteToLocalPoint(mode, transformState); |
| 1966 if (o->hasOverflowClip()) | 1971 if (o->hasOverflowClip()) |
| 1967 transformState.move(toRenderBox(o)->scrolledContentOffset()); | 1972 transformState.move(toRenderBox(o)->scrolledContentOffset()); |
| 1968 } | 1973 } |
| 1969 } | 1974 } |
| 1970 | 1975 |
| 1971 bool RenderObject::shouldUseTransformFromContainer(const RenderObject* container
Object) const | 1976 bool LayoutObject::shouldUseTransformFromContainer(const LayoutObject* container
Object) const |
| 1972 { | 1977 { |
| 1973 // hasTransform() indicates whether the object has transform, transform-styl
e or perspective. We just care about transform, | 1978 // hasTransform() indicates whether the object has transform, transform-styl
e or perspective. We just care about transform, |
| 1974 // so check the layer's transform directly. | 1979 // so check the layer's transform directly. |
| 1975 return (hasLayer() && toLayoutLayerModelObject(this)->layer()->transform())
|| (containerObject && containerObject->style()->hasPerspective()); | 1980 return (hasLayer() && toLayoutLayerModelObject(this)->layer()->transform())
|| (containerObject && containerObject->style()->hasPerspective()); |
| 1976 } | 1981 } |
| 1977 | 1982 |
| 1978 void RenderObject::getTransformFromContainer(const RenderObject* containerObject
, const LayoutSize& offsetInContainer, TransformationMatrix& transform) const | 1983 void LayoutObject::getTransformFromContainer(const LayoutObject* containerObject
, const LayoutSize& offsetInContainer, TransformationMatrix& transform) const |
| 1979 { | 1984 { |
| 1980 transform.makeIdentity(); | 1985 transform.makeIdentity(); |
| 1981 transform.translate(offsetInContainer.width().toFloat(), offsetInContainer.h
eight().toFloat()); | 1986 transform.translate(offsetInContainer.width().toFloat(), offsetInContainer.h
eight().toFloat()); |
| 1982 Layer* layer = hasLayer() ? toLayoutLayerModelObject(this)->layer() : 0; | 1987 Layer* layer = hasLayer() ? toLayoutLayerModelObject(this)->layer() : 0; |
| 1983 if (layer && layer->transform()) | 1988 if (layer && layer->transform()) |
| 1984 transform.multiply(layer->currentTransform()); | 1989 transform.multiply(layer->currentTransform()); |
| 1985 | 1990 |
| 1986 if (containerObject && containerObject->hasLayer() && containerObject->style
()->hasPerspective()) { | 1991 if (containerObject && containerObject->hasLayer() && containerObject->style
()->hasPerspective()) { |
| 1987 // Perpsective on the container affects us, so we have to factor it in h
ere. | 1992 // Perpsective on the container affects us, so we have to factor it in h
ere. |
| 1988 ASSERT(containerObject->hasLayer()); | 1993 ASSERT(containerObject->hasLayer()); |
| 1989 FloatPoint perspectiveOrigin = toLayoutLayerModelObject(containerObject)
->layer()->perspectiveOrigin(); | 1994 FloatPoint perspectiveOrigin = toLayoutLayerModelObject(containerObject)
->layer()->perspectiveOrigin(); |
| 1990 | 1995 |
| 1991 TransformationMatrix perspectiveMatrix; | 1996 TransformationMatrix perspectiveMatrix; |
| 1992 perspectiveMatrix.applyPerspective(containerObject->style()->perspective
()); | 1997 perspectiveMatrix.applyPerspective(containerObject->style()->perspective
()); |
| 1993 | 1998 |
| 1994 transform.translateRight3d(-perspectiveOrigin.x(), -perspectiveOrigin.y(
), 0); | 1999 transform.translateRight3d(-perspectiveOrigin.x(), -perspectiveOrigin.y(
), 0); |
| 1995 transform = perspectiveMatrix * transform; | 2000 transform = perspectiveMatrix * transform; |
| 1996 transform.translateRight3d(perspectiveOrigin.x(), perspectiveOrigin.y(),
0); | 2001 transform.translateRight3d(perspectiveOrigin.x(), perspectiveOrigin.y(),
0); |
| 1997 } | 2002 } |
| 1998 } | 2003 } |
| 1999 | 2004 |
| 2000 FloatQuad RenderObject::localToContainerQuad(const FloatQuad& localQuad, const L
ayoutLayerModelObject* paintInvalidationContainer, MapCoordinatesFlags mode, boo
l* wasFixed) const | 2005 FloatQuad LayoutObject::localToContainerQuad(const FloatQuad& localQuad, const L
ayoutLayerModelObject* paintInvalidationContainer, MapCoordinatesFlags mode, boo
l* wasFixed) const |
| 2001 { | 2006 { |
| 2002 // Track the point at the center of the quad's bounding box. As mapLocalToCo
ntainer() calls offsetFromContainer(), | 2007 // Track the point at the center of the quad's bounding box. As mapLocalToCo
ntainer() calls offsetFromContainer(), |
| 2003 // it will use that point as the reference point to decide which column's tr
ansform to apply in multiple-column blocks. | 2008 // it will use that point as the reference point to decide which column's tr
ansform to apply in multiple-column blocks. |
| 2004 TransformState transformState(TransformState::ApplyTransformDirection, local
Quad.boundingBox().center(), localQuad); | 2009 TransformState transformState(TransformState::ApplyTransformDirection, local
Quad.boundingBox().center(), localQuad); |
| 2005 mapLocalToContainer(paintInvalidationContainer, transformState, mode | Apply
ContainerFlip | UseTransforms, wasFixed); | 2010 mapLocalToContainer(paintInvalidationContainer, transformState, mode | Apply
ContainerFlip | UseTransforms, wasFixed); |
| 2006 transformState.flatten(); | 2011 transformState.flatten(); |
| 2007 | 2012 |
| 2008 return transformState.lastPlanarQuad(); | 2013 return transformState.lastPlanarQuad(); |
| 2009 } | 2014 } |
| 2010 | 2015 |
| 2011 FloatPoint RenderObject::localToContainerPoint(const FloatPoint& localPoint, con
st LayoutLayerModelObject* paintInvalidationContainer, MapCoordinatesFlags mode,
bool* wasFixed, const PaintInvalidationState* paintInvalidationState) const | 2016 FloatPoint LayoutObject::localToContainerPoint(const FloatPoint& localPoint, con
st LayoutLayerModelObject* paintInvalidationContainer, MapCoordinatesFlags mode,
bool* wasFixed, const PaintInvalidationState* paintInvalidationState) const |
| 2012 { | 2017 { |
| 2013 TransformState transformState(TransformState::ApplyTransformDirection, local
Point); | 2018 TransformState transformState(TransformState::ApplyTransformDirection, local
Point); |
| 2014 mapLocalToContainer(paintInvalidationContainer, transformState, mode | Apply
ContainerFlip | UseTransforms, wasFixed, paintInvalidationState); | 2019 mapLocalToContainer(paintInvalidationContainer, transformState, mode | Apply
ContainerFlip | UseTransforms, wasFixed, paintInvalidationState); |
| 2015 transformState.flatten(); | 2020 transformState.flatten(); |
| 2016 | 2021 |
| 2017 return transformState.lastPlanarPoint(); | 2022 return transformState.lastPlanarPoint(); |
| 2018 } | 2023 } |
| 2019 | 2024 |
| 2020 FloatPoint RenderObject::localToInvalidationBackingPoint(const LayoutPoint& loca
lPoint, Layer** backingLayer) | 2025 FloatPoint LayoutObject::localToInvalidationBackingPoint(const LayoutPoint& loca
lPoint, Layer** backingLayer) |
| 2021 { | 2026 { |
| 2022 const LayoutLayerModelObject* paintInvalidationContainer = containerForPaint
Invalidation(); | 2027 const LayoutLayerModelObject* paintInvalidationContainer = containerForPaint
Invalidation(); |
| 2023 ASSERT(paintInvalidationContainer); | 2028 ASSERT(paintInvalidationContainer); |
| 2024 ASSERT(paintInvalidationContainer->layer()); | 2029 ASSERT(paintInvalidationContainer->layer()); |
| 2025 | 2030 |
| 2026 if (backingLayer) | 2031 if (backingLayer) |
| 2027 *backingLayer = paintInvalidationContainer->layer(); | 2032 *backingLayer = paintInvalidationContainer->layer(); |
| 2028 FloatPoint containerPoint = localToContainerPoint(FloatPoint(localPoint), pa
intInvalidationContainer, TraverseDocumentBoundaries); | 2033 FloatPoint containerPoint = localToContainerPoint(FloatPoint(localPoint), pa
intInvalidationContainer, TraverseDocumentBoundaries); |
| 2029 | 2034 |
| 2030 // A renderer can have no invalidation backing if it is from a detached fram
e, | 2035 // A renderer can have no invalidation backing if it is from a detached fram
e, |
| 2031 // or when forced compositing is disabled. | 2036 // or when forced compositing is disabled. |
| 2032 if (paintInvalidationContainer->layer()->compositingState() == NotComposited
) | 2037 if (paintInvalidationContainer->layer()->compositingState() == NotComposited
) |
| 2033 return containerPoint; | 2038 return containerPoint; |
| 2034 | 2039 |
| 2035 Layer::mapPointToPaintBackingCoordinates(paintInvalidationContainer, contain
erPoint); | 2040 Layer::mapPointToPaintBackingCoordinates(paintInvalidationContainer, contain
erPoint); |
| 2036 return containerPoint; | 2041 return containerPoint; |
| 2037 } | 2042 } |
| 2038 | 2043 |
| 2039 LayoutSize RenderObject::offsetFromContainer(const RenderObject* o, const Layout
Point& point, bool* offsetDependsOnPoint) const | 2044 LayoutSize LayoutObject::offsetFromContainer(const LayoutObject* o, const Layout
Point& point, bool* offsetDependsOnPoint) const |
| 2040 { | 2045 { |
| 2041 ASSERT(o == container()); | 2046 ASSERT(o == container()); |
| 2042 | 2047 |
| 2043 LayoutSize offset = o->columnOffset(point); | 2048 LayoutSize offset = o->columnOffset(point); |
| 2044 | 2049 |
| 2045 if (o->hasOverflowClip()) | 2050 if (o->hasOverflowClip()) |
| 2046 offset -= toRenderBox(o)->scrolledContentOffset(); | 2051 offset -= toRenderBox(o)->scrolledContentOffset(); |
| 2047 | 2052 |
| 2048 if (offsetDependsOnPoint) | 2053 if (offsetDependsOnPoint) |
| 2049 *offsetDependsOnPoint = hasColumns() || o->isRenderFlowThread(); | 2054 *offsetDependsOnPoint = hasColumns() || o->isRenderFlowThread(); |
| 2050 | 2055 |
| 2051 return offset; | 2056 return offset; |
| 2052 } | 2057 } |
| 2053 | 2058 |
| 2054 LayoutSize RenderObject::offsetFromAncestorContainer(const RenderObject* contain
er) const | 2059 LayoutSize LayoutObject::offsetFromAncestorContainer(const LayoutObject* contain
er) const |
| 2055 { | 2060 { |
| 2056 if (container == this) | 2061 if (container == this) |
| 2057 return LayoutSize(); | 2062 return LayoutSize(); |
| 2058 | 2063 |
| 2059 LayoutSize offset; | 2064 LayoutSize offset; |
| 2060 LayoutPoint referencePoint; | 2065 LayoutPoint referencePoint; |
| 2061 const RenderObject* currContainer = this; | 2066 const LayoutObject* currContainer = this; |
| 2062 do { | 2067 do { |
| 2063 const RenderObject* nextContainer = currContainer->container(); | 2068 const LayoutObject* nextContainer = currContainer->container(); |
| 2064 ASSERT(nextContainer); // This means we reached the top without finding
container. | 2069 ASSERT(nextContainer); // This means we reached the top without finding
container. |
| 2065 if (!nextContainer) | 2070 if (!nextContainer) |
| 2066 break; | 2071 break; |
| 2067 ASSERT(!currContainer->hasTransformRelatedProperty()); | 2072 ASSERT(!currContainer->hasTransformRelatedProperty()); |
| 2068 LayoutSize currentOffset = currContainer->offsetFromContainer(nextContai
ner, referencePoint); | 2073 LayoutSize currentOffset = currContainer->offsetFromContainer(nextContai
ner, referencePoint); |
| 2069 offset += currentOffset; | 2074 offset += currentOffset; |
| 2070 referencePoint.move(currentOffset); | 2075 referencePoint.move(currentOffset); |
| 2071 currContainer = nextContainer; | 2076 currContainer = nextContainer; |
| 2072 } while (currContainer != container); | 2077 } while (currContainer != container); |
| 2073 | 2078 |
| 2074 return offset; | 2079 return offset; |
| 2075 } | 2080 } |
| 2076 | 2081 |
| 2077 LayoutRect RenderObject::localCaretRect(InlineBox*, int, LayoutUnit* extraWidthT
oEndOfLine) | 2082 LayoutRect LayoutObject::localCaretRect(InlineBox*, int, LayoutUnit* extraWidthT
oEndOfLine) |
| 2078 { | 2083 { |
| 2079 if (extraWidthToEndOfLine) | 2084 if (extraWidthToEndOfLine) |
| 2080 *extraWidthToEndOfLine = 0; | 2085 *extraWidthToEndOfLine = 0; |
| 2081 | 2086 |
| 2082 return LayoutRect(); | 2087 return LayoutRect(); |
| 2083 } | 2088 } |
| 2084 | 2089 |
| 2085 void RenderObject::computeLayerHitTestRects(LayerHitTestRects& layerRects) const | 2090 void LayoutObject::computeLayerHitTestRects(LayerHitTestRects& layerRects) const |
| 2086 { | 2091 { |
| 2087 // Figure out what layer our container is in. Any offset (or new layer) for
this | 2092 // Figure out what layer our container is in. Any offset (or new layer) for
this |
| 2088 // renderer within it's container will be applied in addLayerHitTestRects. | 2093 // renderer within it's container will be applied in addLayerHitTestRects. |
| 2089 LayoutPoint layerOffset; | 2094 LayoutPoint layerOffset; |
| 2090 const Layer* currentLayer = 0; | 2095 const Layer* currentLayer = 0; |
| 2091 | 2096 |
| 2092 if (!hasLayer()) { | 2097 if (!hasLayer()) { |
| 2093 RenderObject* container = this->container(); | 2098 LayoutObject* container = this->container(); |
| 2094 currentLayer = container->enclosingLayer(); | 2099 currentLayer = container->enclosingLayer(); |
| 2095 if (container && currentLayer->renderer() != container) { | 2100 if (container && currentLayer->renderer() != container) { |
| 2096 layerOffset.move(container->offsetFromAncestorContainer(currentLayer
->renderer())); | 2101 layerOffset.move(container->offsetFromAncestorContainer(currentLayer
->renderer())); |
| 2097 // If the layer itself is scrolled, we have to undo the subtraction
of its scroll | 2102 // If the layer itself is scrolled, we have to undo the subtraction
of its scroll |
| 2098 // offset since we want the offset relative to the scrolling content
, not the | 2103 // offset since we want the offset relative to the scrolling content
, not the |
| 2099 // element itself. | 2104 // element itself. |
| 2100 if (currentLayer->renderer()->hasOverflowClip()) | 2105 if (currentLayer->renderer()->hasOverflowClip()) |
| 2101 layerOffset.move(currentLayer->renderBox()->scrolledContentOffse
t()); | 2106 layerOffset.move(currentLayer->renderBox()->scrolledContentOffse
t()); |
| 2102 } | 2107 } |
| 2103 } | 2108 } |
| 2104 | 2109 |
| 2105 this->addLayerHitTestRects(layerRects, currentLayer, layerOffset, LayoutRect
()); | 2110 this->addLayerHitTestRects(layerRects, currentLayer, layerOffset, LayoutRect
()); |
| 2106 } | 2111 } |
| 2107 | 2112 |
| 2108 void RenderObject::addLayerHitTestRects(LayerHitTestRects& layerRects, const Lay
er* currentLayer, const LayoutPoint& layerOffset, const LayoutRect& containerRec
t) const | 2113 void LayoutObject::addLayerHitTestRects(LayerHitTestRects& layerRects, const Lay
er* currentLayer, const LayoutPoint& layerOffset, const LayoutRect& containerRec
t) const |
| 2109 { | 2114 { |
| 2110 ASSERT(currentLayer); | 2115 ASSERT(currentLayer); |
| 2111 ASSERT(currentLayer == this->enclosingLayer()); | 2116 ASSERT(currentLayer == this->enclosingLayer()); |
| 2112 | 2117 |
| 2113 // Compute the rects for this renderer only and add them to the results. | 2118 // Compute the rects for this renderer only and add them to the results. |
| 2114 // Note that we could avoid passing the offset and instead adjust each resul
t, but this | 2119 // Note that we could avoid passing the offset and instead adjust each resul
t, but this |
| 2115 // seems slightly simpler. | 2120 // seems slightly simpler. |
| 2116 Vector<LayoutRect> ownRects; | 2121 Vector<LayoutRect> ownRects; |
| 2117 LayoutRect newContainerRect; | 2122 LayoutRect newContainerRect; |
| 2118 computeSelfHitTestRects(ownRects, layerOffset); | 2123 computeSelfHitTestRects(ownRects, layerOffset); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 2147 newContainerRect = containerRect; | 2152 newContainerRect = containerRect; |
| 2148 | 2153 |
| 2149 // If it's possible for children to have rects outside our bounds, then we n
eed to descend into | 2154 // If it's possible for children to have rects outside our bounds, then we n
eed to descend into |
| 2150 // the children and compute them. | 2155 // the children and compute them. |
| 2151 // Ideally there would be other cases where we could detect that children co
uldn't have rects | 2156 // Ideally there would be other cases where we could detect that children co
uldn't have rects |
| 2152 // outside our bounds and prune the tree walk. | 2157 // outside our bounds and prune the tree walk. |
| 2153 // Note that we don't use Region here because Union is O(N) - better to just
keep a list of | 2158 // Note that we don't use Region here because Union is O(N) - better to just
keep a list of |
| 2154 // partially redundant rectangles. If we find examples where this is expensi
ve, then we could | 2159 // partially redundant rectangles. If we find examples where this is expensi
ve, then we could |
| 2155 // rewrite Region to be more efficient. See https://bugs.webkit.org/show_bug
.cgi?id=100814. | 2160 // rewrite Region to be more efficient. See https://bugs.webkit.org/show_bug
.cgi?id=100814. |
| 2156 if (!isRenderView()) { | 2161 if (!isRenderView()) { |
| 2157 for (RenderObject* curr = slowFirstChild(); curr; curr = curr->nextSibli
ng()) { | 2162 for (LayoutObject* curr = slowFirstChild(); curr; curr = curr->nextSibli
ng()) { |
| 2158 curr->addLayerHitTestRects(layerRects, currentLayer, layerOffset, n
ewContainerRect); | 2163 curr->addLayerHitTestRects(layerRects, currentLayer, layerOffset, n
ewContainerRect); |
| 2159 } | 2164 } |
| 2160 } | 2165 } |
| 2161 } | 2166 } |
| 2162 | 2167 |
| 2163 bool RenderObject::isRooted() const | 2168 bool LayoutObject::isRooted() const |
| 2164 { | 2169 { |
| 2165 const RenderObject* object = this; | 2170 const LayoutObject* object = this; |
| 2166 while (object->parent() && !object->hasLayer()) | 2171 while (object->parent() && !object->hasLayer()) |
| 2167 object = object->parent(); | 2172 object = object->parent(); |
| 2168 if (object->hasLayer()) | 2173 if (object->hasLayer()) |
| 2169 return toLayoutLayerModelObject(object)->layer()->root()->isRootLayer(); | 2174 return toLayoutLayerModelObject(object)->layer()->root()->isRootLayer(); |
| 2170 return false; | 2175 return false; |
| 2171 } | 2176 } |
| 2172 | 2177 |
| 2173 RenderObject* RenderObject::rendererForRootBackground() | 2178 LayoutObject* LayoutObject::rendererForRootBackground() |
| 2174 { | 2179 { |
| 2175 ASSERT(isDocumentElement()); | 2180 ASSERT(isDocumentElement()); |
| 2176 if (!hasBackground() && isHTMLHtmlElement(node())) { | 2181 if (!hasBackground() && isHTMLHtmlElement(node())) { |
| 2177 // Locate the <body> element using the DOM. This is easier than trying | 2182 // Locate the <body> element using the DOM. This is easier than trying |
| 2178 // to crawl around a render tree with potential :before/:after content a
nd | 2183 // to crawl around a render tree with potential :before/:after content a
nd |
| 2179 // anonymous blocks created by inline <body> tags etc. We can locate the
<body> | 2184 // anonymous blocks created by inline <body> tags etc. We can locate the
<body> |
| 2180 // render object very easily via the DOM. | 2185 // render object very easily via the DOM. |
| 2181 HTMLElement* body = document().body(); | 2186 HTMLElement* body = document().body(); |
| 2182 RenderObject* bodyObject = isHTMLBodyElement(body) ? body->renderer() :
0; | 2187 LayoutObject* bodyObject = isHTMLBodyElement(body) ? body->renderer() :
0; |
| 2183 if (bodyObject) | 2188 if (bodyObject) |
| 2184 return bodyObject; | 2189 return bodyObject; |
| 2185 } | 2190 } |
| 2186 | 2191 |
| 2187 return this; | 2192 return this; |
| 2188 } | 2193 } |
| 2189 | 2194 |
| 2190 RespectImageOrientationEnum RenderObject::shouldRespectImageOrientation() const | 2195 RespectImageOrientationEnum LayoutObject::shouldRespectImageOrientation() const |
| 2191 { | 2196 { |
| 2192 // Respect the image's orientation if it's being used as a full-page image o
r it's | 2197 // Respect the image's orientation if it's being used as a full-page image o
r it's |
| 2193 // an <img> and the setting to respect it everywhere is set. | 2198 // an <img> and the setting to respect it everywhere is set. |
| 2194 return document().isImageDocument() | 2199 return document().isImageDocument() |
| 2195 || (document().settings() && document().settings()->shouldRespectImageOr
ientation() && isHTMLImageElement(node())) ? RespectImageOrientation : DoNotResp
ectImageOrientation; | 2200 || (document().settings() && document().settings()->shouldRespectImageOr
ientation() && isHTMLImageElement(node())) ? RespectImageOrientation : DoNotResp
ectImageOrientation; |
| 2196 } | 2201 } |
| 2197 | 2202 |
| 2198 bool RenderObject::hasEntirelyFixedBackground() const | 2203 bool LayoutObject::hasEntirelyFixedBackground() const |
| 2199 { | 2204 { |
| 2200 return m_style->hasEntirelyFixedBackground(); | 2205 return m_style->hasEntirelyFixedBackground(); |
| 2201 } | 2206 } |
| 2202 | 2207 |
| 2203 RenderObject* RenderObject::container(const LayoutLayerModelObject* paintInvalid
ationContainer, bool* paintInvalidationContainerSkipped) const | 2208 LayoutObject* LayoutObject::container(const LayoutLayerModelObject* paintInvalid
ationContainer, bool* paintInvalidationContainerSkipped) const |
| 2204 { | 2209 { |
| 2205 if (paintInvalidationContainerSkipped) | 2210 if (paintInvalidationContainerSkipped) |
| 2206 *paintInvalidationContainerSkipped = false; | 2211 *paintInvalidationContainerSkipped = false; |
| 2207 | 2212 |
| 2208 // This method is extremely similar to containingBlock(), but with a few not
able | 2213 // This method is extremely similar to containingBlock(), but with a few not
able |
| 2209 // exceptions. | 2214 // exceptions. |
| 2210 // (1) It can be used on orphaned subtrees, i.e., it can be called safely ev
en when | 2215 // (1) It can be used on orphaned subtrees, i.e., it can be called safely ev
en when |
| 2211 // the object is not part of the primary document subtree yet. | 2216 // the object is not part of the primary document subtree yet. |
| 2212 // (2) For normal flow elements, it just returns the parent. | 2217 // (2) For normal flow elements, it just returns the parent. |
| 2213 // (3) For absolute positioned elements, it will return a relative positione
d inline. | 2218 // (3) For absolute positioned elements, it will return a relative positione
d inline. |
| 2214 // containingBlock() simply skips relpositioned inlines and lets an enclosin
g block handle | 2219 // containingBlock() simply skips relpositioned inlines and lets an enclosin
g block handle |
| 2215 // the layout of the positioned object. This does mean that computePosition
edLogicalWidth and | 2220 // the layout of the positioned object. This does mean that computePosition
edLogicalWidth and |
| 2216 // computePositionedLogicalHeight have to use container(). | 2221 // computePositionedLogicalHeight have to use container(). |
| 2217 RenderObject* o = parent(); | 2222 LayoutObject* o = parent(); |
| 2218 | 2223 |
| 2219 if (isText()) | 2224 if (isText()) |
| 2220 return o; | 2225 return o; |
| 2221 | 2226 |
| 2222 EPosition pos = m_style->position(); | 2227 EPosition pos = m_style->position(); |
| 2223 if (pos == FixedPosition) { | 2228 if (pos == FixedPosition) |
| 2224 return containerForFixedPosition(paintInvalidationContainer, paintInvali
dationContainerSkipped); | 2229 return containerForFixedPosition(paintInvalidationContainer, paintInvali
dationContainerSkipped); |
| 2225 } else if (pos == AbsolutePosition) { | 2230 |
| 2231 if (pos == AbsolutePosition) { |
| 2226 // We technically just want our containing block, but | 2232 // We technically just want our containing block, but |
| 2227 // we may not have one if we're part of an uninstalled | 2233 // we may not have one if we're part of an uninstalled |
| 2228 // subtree. We'll climb as high as we can though. | 2234 // subtree. We'll climb as high as we can though. |
| 2229 while (o) { | 2235 while (o) { |
| 2230 if (o->style()->position() != StaticPosition) | 2236 if (o->style()->position() != StaticPosition) |
| 2231 break; | 2237 break; |
| 2232 | 2238 |
| 2233 if (o->canContainFixedPositionObjects()) | 2239 if (o->canContainFixedPositionObjects()) |
| 2234 break; | 2240 break; |
| 2235 | 2241 |
| 2236 if (paintInvalidationContainerSkipped && o == paintInvalidationConta
iner) | 2242 if (paintInvalidationContainerSkipped && o == paintInvalidationConta
iner) |
| 2237 *paintInvalidationContainerSkipped = true; | 2243 *paintInvalidationContainerSkipped = true; |
| 2238 | 2244 |
| 2239 o = o->parent(); | 2245 o = o->parent(); |
| 2240 } | 2246 } |
| 2241 } else if (isColumnSpanAll()) { | 2247 } else if (isColumnSpanAll()) { |
| 2242 RenderObject* multicolContainer = spannerPlaceholder()->container(); | 2248 LayoutObject* multicolContainer = spannerPlaceholder()->container(); |
| 2243 if (paintInvalidationContainerSkipped && paintInvalidationContainer) { | 2249 if (paintInvalidationContainerSkipped && paintInvalidationContainer) { |
| 2244 // We jumped directly from the spanner to the multicol container. Ne
ed to check if | 2250 // We jumped directly from the spanner to the multicol container. Ne
ed to check if |
| 2245 // we skipped |paintInvalidationContainer| on the way. | 2251 // we skipped |paintInvalidationContainer| on the way. |
| 2246 for (RenderObject* walker = parent(); walker && walker != multicolCo
ntainer; walker = walker->parent()) { | 2252 for (LayoutObject* walker = parent(); walker && walker != multicolCo
ntainer; walker = walker->parent()) { |
| 2247 if (walker == paintInvalidationContainer) { | 2253 if (walker == paintInvalidationContainer) { |
| 2248 *paintInvalidationContainerSkipped = true; | 2254 *paintInvalidationContainerSkipped = true; |
| 2249 break; | 2255 break; |
| 2250 } | 2256 } |
| 2251 } | 2257 } |
| 2252 } | 2258 } |
| 2253 return multicolContainer; | 2259 return multicolContainer; |
| 2254 } | 2260 } |
| 2255 | 2261 |
| 2256 return o; | 2262 return o; |
| 2257 } | 2263 } |
| 2258 | 2264 |
| 2259 bool RenderObject::isSelectionBorder() const | 2265 bool LayoutObject::isSelectionBorder() const |
| 2260 { | 2266 { |
| 2261 SelectionState st = selectionState(); | 2267 SelectionState st = selectionState(); |
| 2262 return st == SelectionStart || st == SelectionEnd || st == SelectionBoth; | 2268 return st == SelectionStart || st == SelectionEnd || st == SelectionBoth; |
| 2263 } | 2269 } |
| 2264 | 2270 |
| 2265 inline void RenderObject::clearLayoutRootIfNeeded() const | 2271 inline void LayoutObject::clearLayoutRootIfNeeded() const |
| 2266 { | 2272 { |
| 2267 if (frame()) { | 2273 if (frame()) { |
| 2268 if (FrameView* view = frame()->view()) { | 2274 if (FrameView* view = frame()->view()) { |
| 2269 if (view->layoutRoot() == this) { | 2275 if (view->layoutRoot() == this) { |
| 2270 if (!documentBeingDestroyed()) | 2276 if (!documentBeingDestroyed()) |
| 2271 ASSERT_NOT_REACHED(); | 2277 ASSERT_NOT_REACHED(); |
| 2272 // This indicates a failure to layout the child, which is why | 2278 // This indicates a failure to layout the child, which is why |
| 2273 // the layout root is still set to |this|. Make sure to clear it | 2279 // the layout root is still set to |this|. Make sure to clear it |
| 2274 // since we are getting destroyed. | 2280 // since we are getting destroyed. |
| 2275 view->clearLayoutSubtreeRoot(); | 2281 view->clearLayoutSubtreeRoot(); |
| 2276 } | 2282 } |
| 2277 } | 2283 } |
| 2278 } | 2284 } |
| 2279 } | 2285 } |
| 2280 | 2286 |
| 2281 void RenderObject::willBeDestroyed() | 2287 void LayoutObject::willBeDestroyed() |
| 2282 { | 2288 { |
| 2283 // Destroy any leftover anonymous children. | 2289 // Destroy any leftover anonymous children. |
| 2284 RenderObjectChildList* children = virtualChildren(); | 2290 LayoutObjectChildList* children = virtualChildren(); |
| 2285 if (children) | 2291 if (children) |
| 2286 children->destroyLeftoverChildren(); | 2292 children->destroyLeftoverChildren(); |
| 2287 | 2293 |
| 2288 // If this renderer is being autoscrolled, stop the autoscrolling. | 2294 // If this renderer is being autoscrolled, stop the autoscrolling. |
| 2289 if (LocalFrame* frame = this->frame()) { | 2295 if (LocalFrame* frame = this->frame()) { |
| 2290 if (frame->page()) | 2296 if (frame->page()) |
| 2291 frame->page()->autoscrollController().stopAutoscrollIfNeeded(this); | 2297 frame->page()->autoscrollController().stopAutoscrollIfNeeded(this); |
| 2292 } | 2298 } |
| 2293 | 2299 |
| 2294 // For accessibility management, notify the parent of the imminent change to
its child set. | 2300 // For accessibility management, notify the parent of the imminent change to
its child set. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 2322 } | 2328 } |
| 2323 | 2329 |
| 2324 setAncestorLineBoxDirty(false); | 2330 setAncestorLineBoxDirty(false); |
| 2325 | 2331 |
| 2326 if (selectionPaintInvalidationMap) | 2332 if (selectionPaintInvalidationMap) |
| 2327 selectionPaintInvalidationMap->remove(this); | 2333 selectionPaintInvalidationMap->remove(this); |
| 2328 | 2334 |
| 2329 clearLayoutRootIfNeeded(); | 2335 clearLayoutRootIfNeeded(); |
| 2330 } | 2336 } |
| 2331 | 2337 |
| 2332 void RenderObject::insertedIntoTree() | 2338 void LayoutObject::insertedIntoTree() |
| 2333 { | 2339 { |
| 2334 // FIXME: We should ASSERT(isRooted()) here but generated content makes some
out-of-order insertion. | 2340 // FIXME: We should ASSERT(isRooted()) here but generated content makes some
out-of-order insertion. |
| 2335 | 2341 |
| 2336 // Keep our layer hierarchy updated. Optimize for the common case where we d
on't have any children | 2342 // Keep our layer hierarchy updated. Optimize for the common case where we d
on't have any children |
| 2337 // and don't have a layer attached to ourselves. | 2343 // and don't have a layer attached to ourselves. |
| 2338 Layer* layer = 0; | 2344 Layer* layer = 0; |
| 2339 if (slowFirstChild() || hasLayer()) { | 2345 if (slowFirstChild() || hasLayer()) { |
| 2340 layer = parent()->enclosingLayer(); | 2346 layer = parent()->enclosingLayer(); |
| 2341 addLayers(layer); | 2347 addLayers(layer); |
| 2342 } | 2348 } |
| 2343 | 2349 |
| 2344 // If |this| is visible but this object was not, tell the layer it has some
visible content | 2350 // If |this| is visible but this object was not, tell the layer it has some
visible content |
| 2345 // that needs to be drawn and layer visibility optimization can't be used | 2351 // that needs to be drawn and layer visibility optimization can't be used |
| 2346 if (parent()->style()->visibility() != VISIBLE && style()->visibility() == V
ISIBLE && !hasLayer()) { | 2352 if (parent()->style()->visibility() != VISIBLE && style()->visibility() == V
ISIBLE && !hasLayer()) { |
| 2347 if (!layer) | 2353 if (!layer) |
| 2348 layer = parent()->enclosingLayer(); | 2354 layer = parent()->enclosingLayer(); |
| 2349 if (layer) | 2355 if (layer) |
| 2350 layer->dirtyVisibleContentStatus(); | 2356 layer->dirtyVisibleContentStatus(); |
| 2351 } | 2357 } |
| 2352 | 2358 |
| 2353 if (!isFloating() && parent()->childrenInline()) | 2359 if (!isFloating() && parent()->childrenInline()) |
| 2354 parent()->dirtyLinesFromChangedChild(this); | 2360 parent()->dirtyLinesFromChangedChild(this); |
| 2355 | 2361 |
| 2356 if (RenderFlowThread* flowThread = parent()->flowThreadContainingBlock()) | 2362 if (RenderFlowThread* flowThread = parent()->flowThreadContainingBlock()) |
| 2357 flowThread->flowThreadDescendantWasInserted(this); | 2363 flowThread->flowThreadDescendantWasInserted(this); |
| 2358 } | 2364 } |
| 2359 | 2365 |
| 2360 void RenderObject::willBeRemovedFromTree() | 2366 void LayoutObject::willBeRemovedFromTree() |
| 2361 { | 2367 { |
| 2362 // FIXME: We should ASSERT(isRooted()) but we have some out-of-order removal
s which would need to be fixed first. | 2368 // FIXME: We should ASSERT(isRooted()) but we have some out-of-order removal
s which would need to be fixed first. |
| 2363 | 2369 |
| 2364 // If we remove a visible child from an invisible parent, we don't know the
layer visibility any more. | 2370 // If we remove a visible child from an invisible parent, we don't know the
layer visibility any more. |
| 2365 Layer* layer = 0; | 2371 Layer* layer = 0; |
| 2366 if (parent()->style()->visibility() != VISIBLE && style()->visibility() == V
ISIBLE && !hasLayer()) { | 2372 if (parent()->style()->visibility() != VISIBLE && style()->visibility() == V
ISIBLE && !hasLayer()) { |
| 2367 layer = parent()->enclosingLayer(); | 2373 layer = parent()->enclosingLayer(); |
| 2368 if (layer) | 2374 if (layer) |
| 2369 layer->dirtyVisibleContentStatus(); | 2375 layer->dirtyVisibleContentStatus(); |
| 2370 } | 2376 } |
| 2371 | 2377 |
| 2372 // Keep our layer hierarchy updated. | 2378 // Keep our layer hierarchy updated. |
| 2373 if (slowFirstChild() || hasLayer()) { | 2379 if (slowFirstChild() || hasLayer()) { |
| 2374 if (!layer) | 2380 if (!layer) |
| 2375 layer = parent()->enclosingLayer(); | 2381 layer = parent()->enclosingLayer(); |
| 2376 removeLayers(layer); | 2382 removeLayers(layer); |
| 2377 } | 2383 } |
| 2378 | 2384 |
| 2379 if (isOutOfFlowPositioned() && parent()->childrenInline()) | 2385 if (isOutOfFlowPositioned() && parent()->childrenInline()) |
| 2380 parent()->dirtyLinesFromChangedChild(this); | 2386 parent()->dirtyLinesFromChangedChild(this); |
| 2381 | 2387 |
| 2382 removeFromRenderFlowThread(); | 2388 removeFromRenderFlowThread(); |
| 2383 | 2389 |
| 2384 // Update cached boundaries in SVG renderers if a child is removed. | 2390 // Update cached boundaries in SVG renderers if a child is removed. |
| 2385 if (parent()->isSVG()) | 2391 if (parent()->isSVG()) |
| 2386 parent()->setNeedsBoundariesUpdate(); | 2392 parent()->setNeedsBoundariesUpdate(); |
| 2387 } | 2393 } |
| 2388 | 2394 |
| 2389 void RenderObject::removeFromRenderFlowThread() | 2395 void LayoutObject::removeFromRenderFlowThread() |
| 2390 { | 2396 { |
| 2391 if (flowThreadState() == NotInsideFlowThread) | 2397 if (flowThreadState() == NotInsideFlowThread) |
| 2392 return; | 2398 return; |
| 2393 | 2399 |
| 2394 // Sometimes we remove the element from the flow, but it's not destroyed at
that time. | 2400 // Sometimes we remove the element from the flow, but it's not destroyed at
that time. |
| 2395 // It's only until later when we actually destroy it and remove all the chil
dren from it. | 2401 // It's only until later when we actually destroy it and remove all the chil
dren from it. |
| 2396 // Currently, that happens for firstLetter elements and list markers. | 2402 // Currently, that happens for firstLetter elements and list markers. |
| 2397 // Pass in the flow thread so that we don't have to look it up for all the c
hildren. | 2403 // Pass in the flow thread so that we don't have to look it up for all the c
hildren. |
| 2398 // If we're a column spanner, we need to use our parent to find the flow thr
ead, since a spanner | 2404 // If we're a column spanner, we need to use our parent to find the flow thr
ead, since a spanner |
| 2399 // doesn't have the flow thread in its containing block chain. We still need
to notify the flow | 2405 // doesn't have the flow thread in its containing block chain. We still need
to notify the flow |
| 2400 // thread when the renderer removed happens to be a spanner, so that we get
rid of the spanner | 2406 // thread when the renderer removed happens to be a spanner, so that we get
rid of the spanner |
| 2401 // placeholder, and column sets around the placeholder get merged. | 2407 // placeholder, and column sets around the placeholder get merged. |
| 2402 RenderFlowThread* flowThread = isColumnSpanAll() ? parent()->flowThreadConta
iningBlock() : flowThreadContainingBlock(); | 2408 RenderFlowThread* flowThread = isColumnSpanAll() ? parent()->flowThreadConta
iningBlock() : flowThreadContainingBlock(); |
| 2403 removeFromRenderFlowThreadRecursive(flowThread); | 2409 removeFromRenderFlowThreadRecursive(flowThread); |
| 2404 } | 2410 } |
| 2405 | 2411 |
| 2406 void RenderObject::removeFromRenderFlowThreadRecursive(RenderFlowThread* renderF
lowThread) | 2412 void LayoutObject::removeFromRenderFlowThreadRecursive(RenderFlowThread* renderF
lowThread) |
| 2407 { | 2413 { |
| 2408 if (const RenderObjectChildList* children = virtualChildren()) { | 2414 if (const LayoutObjectChildList* children = virtualChildren()) { |
| 2409 for (RenderObject* child = children->firstChild(); child; child = child-
>nextSibling()) | 2415 for (LayoutObject* child = children->firstChild(); child; child = child-
>nextSibling()) |
| 2410 child->removeFromRenderFlowThreadRecursive(renderFlowThread); | 2416 child->removeFromRenderFlowThreadRecursive(renderFlowThread); |
| 2411 } | 2417 } |
| 2412 | 2418 |
| 2413 if (renderFlowThread && renderFlowThread != this) | 2419 if (renderFlowThread && renderFlowThread != this) |
| 2414 renderFlowThread->flowThreadDescendantWillBeRemoved(this); | 2420 renderFlowThread->flowThreadDescendantWillBeRemoved(this); |
| 2415 setFlowThreadState(NotInsideFlowThread); | 2421 setFlowThreadState(NotInsideFlowThread); |
| 2416 RELEASE_ASSERT(!spannerPlaceholder()); | 2422 RELEASE_ASSERT(!spannerPlaceholder()); |
| 2417 } | 2423 } |
| 2418 | 2424 |
| 2419 void RenderObject::destroyAndCleanupAnonymousWrappers() | 2425 void LayoutObject::destroyAndCleanupAnonymousWrappers() |
| 2420 { | 2426 { |
| 2421 // If the tree is destroyed, there is no need for a clean-up phase. | 2427 // If the tree is destroyed, there is no need for a clean-up phase. |
| 2422 if (documentBeingDestroyed()) { | 2428 if (documentBeingDestroyed()) { |
| 2423 destroy(); | 2429 destroy(); |
| 2424 return; | 2430 return; |
| 2425 } | 2431 } |
| 2426 | 2432 |
| 2427 RenderObject* destroyRoot = this; | 2433 LayoutObject* destroyRoot = this; |
| 2428 for (RenderObject* destroyRootParent = destroyRoot->parent(); destroyRootPar
ent && destroyRootParent->isAnonymous(); destroyRoot = destroyRootParent, destro
yRootParent = destroyRootParent->parent()) { | 2434 for (LayoutObject* destroyRootParent = destroyRoot->parent(); destroyRootPar
ent && destroyRootParent->isAnonymous(); destroyRoot = destroyRootParent, destro
yRootParent = destroyRootParent->parent()) { |
| 2429 // Anonymous block continuations are tracked and destroyed elsewhere (se
e the bottom of RenderBlock::removeChild) | 2435 // Anonymous block continuations are tracked and destroyed elsewhere (se
e the bottom of RenderBlock::removeChild) |
| 2430 if (destroyRootParent->isRenderBlock() && toRenderBlock(destroyRootParen
t)->isAnonymousBlockContinuation()) | 2436 if (destroyRootParent->isRenderBlock() && toRenderBlock(destroyRootParen
t)->isAnonymousBlockContinuation()) |
| 2431 break; | 2437 break; |
| 2432 // A flow thread is tracked by its containing block. Whether its childre
n are removed or not is irrelevant. | 2438 // A flow thread is tracked by its containing block. Whether its childre
n are removed or not is irrelevant. |
| 2433 if (destroyRootParent->isRenderFlowThread()) | 2439 if (destroyRootParent->isRenderFlowThread()) |
| 2434 break; | 2440 break; |
| 2435 // Column spans are tracked elsewhere. | 2441 // Column spans are tracked elsewhere. |
| 2436 if (destroyRootParent->isAnonymousColumnSpanBlock()) | 2442 if (destroyRootParent->isAnonymousColumnSpanBlock()) |
| 2437 break; | 2443 break; |
| 2438 | 2444 |
| 2439 if (destroyRootParent->slowFirstChild() != destroyRoot || destroyRootPar
ent->slowLastChild() != destroyRoot) | 2445 if (destroyRootParent->slowFirstChild() != destroyRoot || destroyRootPar
ent->slowLastChild() != destroyRoot) |
| 2440 break; // Need to keep the anonymous parent, since it won't become e
mpty by the removal of this renderer. | 2446 break; // Need to keep the anonymous parent, since it won't become e
mpty by the removal of this renderer. |
| 2441 } | 2447 } |
| 2442 | 2448 |
| 2443 destroyRoot->destroy(); | 2449 destroyRoot->destroy(); |
| 2444 | 2450 |
| 2445 // WARNING: |this| is deleted here. | 2451 // WARNING: |this| is deleted here. |
| 2446 } | 2452 } |
| 2447 | 2453 |
| 2448 void RenderObject::destroy() | 2454 void LayoutObject::destroy() |
| 2449 { | 2455 { |
| 2450 willBeDestroyed(); | 2456 willBeDestroyed(); |
| 2451 postDestroy(); | 2457 postDestroy(); |
| 2452 } | 2458 } |
| 2453 | 2459 |
| 2454 void RenderObject::removeShapeImageClient(ShapeValue* shapeValue) | 2460 void LayoutObject::removeShapeImageClient(ShapeValue* shapeValue) |
| 2455 { | 2461 { |
| 2456 if (!shapeValue) | 2462 if (!shapeValue) |
| 2457 return; | 2463 return; |
| 2458 if (StyleImage* shapeImage = shapeValue->image()) | 2464 if (StyleImage* shapeImage = shapeValue->image()) |
| 2459 shapeImage->removeClient(this); | 2465 shapeImage->removeClient(this); |
| 2460 } | 2466 } |
| 2461 | 2467 |
| 2462 void RenderObject::postDestroy() | 2468 void LayoutObject::postDestroy() |
| 2463 { | 2469 { |
| 2464 // It seems ugly that this is not in willBeDestroyed(). | 2470 // It seems ugly that this is not in willBeDestroyed(). |
| 2465 if (m_style) { | 2471 if (m_style) { |
| 2466 for (const FillLayer* bgLayer = &m_style->backgroundLayers(); bgLayer; b
gLayer = bgLayer->next()) { | 2472 for (const FillLayer* bgLayer = &m_style->backgroundLayers(); bgLayer; b
gLayer = bgLayer->next()) { |
| 2467 if (StyleImage* backgroundImage = bgLayer->image()) | 2473 if (StyleImage* backgroundImage = bgLayer->image()) |
| 2468 backgroundImage->removeClient(this); | 2474 backgroundImage->removeClient(this); |
| 2469 } | 2475 } |
| 2470 | 2476 |
| 2471 for (const FillLayer* maskLayer = &m_style->maskLayers(); maskLayer; mas
kLayer = maskLayer->next()) { | 2477 for (const FillLayer* maskLayer = &m_style->maskLayers(); maskLayer; mas
kLayer = maskLayer->next()) { |
| 2472 if (StyleImage* maskImage = maskLayer->image()) | 2478 if (StyleImage* maskImage = maskLayer->image()) |
| 2473 maskImage->removeClient(this); | 2479 maskImage->removeClient(this); |
| 2474 } | 2480 } |
| 2475 | 2481 |
| 2476 if (StyleImage* borderImage = m_style->borderImage().image()) | 2482 if (StyleImage* borderImage = m_style->borderImage().image()) |
| 2477 borderImage->removeClient(this); | 2483 borderImage->removeClient(this); |
| 2478 | 2484 |
| 2479 if (StyleImage* maskBoxImage = m_style->maskBoxImage().image()) | 2485 if (StyleImage* maskBoxImage = m_style->maskBoxImage().image()) |
| 2480 maskBoxImage->removeClient(this); | 2486 maskBoxImage->removeClient(this); |
| 2481 | 2487 |
| 2482 removeShapeImageClient(m_style->shapeOutside()); | 2488 removeShapeImageClient(m_style->shapeOutside()); |
| 2483 } | 2489 } |
| 2484 ResourceLoadPriorityOptimizer::resourceLoadPriorityOptimizer()->removeRender
Object(this); | 2490 ResourceLoadPriorityOptimizer::resourceLoadPriorityOptimizer()->removeLayout
Object(this); |
| 2485 delete this; | 2491 delete this; |
| 2486 } | 2492 } |
| 2487 | 2493 |
| 2488 PositionWithAffinity RenderObject::positionForPoint(const LayoutPoint&) | 2494 PositionWithAffinity LayoutObject::positionForPoint(const LayoutPoint&) |
| 2489 { | 2495 { |
| 2490 return createPositionWithAffinity(caretMinOffset(), DOWNSTREAM); | 2496 return createPositionWithAffinity(caretMinOffset(), DOWNSTREAM); |
| 2491 } | 2497 } |
| 2492 | 2498 |
| 2493 void RenderObject::updateDragState(bool dragOn) | 2499 void LayoutObject::updateDragState(bool dragOn) |
| 2494 { | 2500 { |
| 2495 bool valueChanged = (dragOn != isDragging()); | 2501 bool valueChanged = (dragOn != isDragging()); |
| 2496 setIsDragging(dragOn); | 2502 setIsDragging(dragOn); |
| 2497 if (valueChanged && node()) { | 2503 if (valueChanged && node()) { |
| 2498 if (node()->isElementNode() && toElement(node())->childrenOrSiblingsAffe
ctedByDrag()) | 2504 if (node()->isElementNode() && toElement(node())->childrenOrSiblingsAffe
ctedByDrag()) |
| 2499 node()->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonFor
Tracing::create(StyleChangeReason::Drag)); | 2505 node()->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonFor
Tracing::create(StyleChangeReason::Drag)); |
| 2500 else if (style()->affectedByDrag()) | 2506 else if (style()->affectedByDrag()) |
| 2501 node()->setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTr
acing::create(StyleChangeReason::Drag)); | 2507 node()->setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTr
acing::create(StyleChangeReason::Drag)); |
| 2502 } | 2508 } |
| 2503 for (RenderObject* curr = slowFirstChild(); curr; curr = curr->nextSibling()
) | 2509 for (LayoutObject* curr = slowFirstChild(); curr; curr = curr->nextSibling()
) |
| 2504 curr->updateDragState(dragOn); | 2510 curr->updateDragState(dragOn); |
| 2505 } | 2511 } |
| 2506 | 2512 |
| 2507 CompositingState RenderObject::compositingState() const | 2513 CompositingState LayoutObject::compositingState() const |
| 2508 { | 2514 { |
| 2509 return hasLayer() ? toLayoutLayerModelObject(this)->layer()->compositingStat
e() : NotComposited; | 2515 return hasLayer() ? toLayoutLayerModelObject(this)->layer()->compositingStat
e() : NotComposited; |
| 2510 } | 2516 } |
| 2511 | 2517 |
| 2512 CompositingReasons RenderObject::additionalCompositingReasons() const | 2518 CompositingReasons LayoutObject::additionalCompositingReasons() const |
| 2513 { | 2519 { |
| 2514 return CompositingReasonNone; | 2520 return CompositingReasonNone; |
| 2515 } | 2521 } |
| 2516 | 2522 |
| 2517 bool RenderObject::hitTest(const HitTestRequest& request, HitTestResult& result,
const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffse
t, HitTestFilter hitTestFilter) | 2523 bool LayoutObject::hitTest(const HitTestRequest& request, HitTestResult& result,
const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffse
t, HitTestFilter hitTestFilter) |
| 2518 { | 2524 { |
| 2519 bool inside = false; | 2525 bool inside = false; |
| 2520 if (hitTestFilter != HitTestSelf) { | 2526 if (hitTestFilter != HitTestSelf) { |
| 2521 // First test the foreground layer (lines and inlines). | 2527 // First test the foreground layer (lines and inlines). |
| 2522 inside = nodeAtPoint(request, result, locationInContainer, accumulatedOf
fset, HitTestForeground); | 2528 inside = nodeAtPoint(request, result, locationInContainer, accumulatedOf
fset, HitTestForeground); |
| 2523 | 2529 |
| 2524 // Test floats next. | 2530 // Test floats next. |
| 2525 if (!inside) | 2531 if (!inside) |
| 2526 inside = nodeAtPoint(request, result, locationInContainer, accumulat
edOffset, HitTestFloat); | 2532 inside = nodeAtPoint(request, result, locationInContainer, accumulat
edOffset, HitTestFloat); |
| 2527 | 2533 |
| 2528 // Finally test to see if the mouse is in the background (within a child
block's background). | 2534 // Finally test to see if the mouse is in the background (within a child
block's background). |
| 2529 if (!inside) | 2535 if (!inside) |
| 2530 inside = nodeAtPoint(request, result, locationInContainer, accumulat
edOffset, HitTestChildBlockBackgrounds); | 2536 inside = nodeAtPoint(request, result, locationInContainer, accumulat
edOffset, HitTestChildBlockBackgrounds); |
| 2531 } | 2537 } |
| 2532 | 2538 |
| 2533 // See if the mouse is inside us but not any of our descendants | 2539 // See if the mouse is inside us but not any of our descendants |
| 2534 if (hitTestFilter != HitTestDescendants && !inside) | 2540 if (hitTestFilter != HitTestDescendants && !inside) |
| 2535 inside = nodeAtPoint(request, result, locationInContainer, accumulatedOf
fset, HitTestBlockBackground); | 2541 inside = nodeAtPoint(request, result, locationInContainer, accumulatedOf
fset, HitTestBlockBackground); |
| 2536 | 2542 |
| 2537 return inside; | 2543 return inside; |
| 2538 } | 2544 } |
| 2539 | 2545 |
| 2540 void RenderObject::updateHitTestResult(HitTestResult& result, const LayoutPoint&
point) | 2546 void LayoutObject::updateHitTestResult(HitTestResult& result, const LayoutPoint&
point) |
| 2541 { | 2547 { |
| 2542 if (result.innerNode()) | 2548 if (result.innerNode()) |
| 2543 return; | 2549 return; |
| 2544 | 2550 |
| 2545 Node* node = this->node(); | 2551 Node* node = this->node(); |
| 2546 | 2552 |
| 2547 // If we hit the anonymous renderers inside generated content we should | 2553 // If we hit the anonymous renderers inside generated content we should |
| 2548 // actually hit the generated content so walk up to the PseudoElement. | 2554 // actually hit the generated content so walk up to the PseudoElement. |
| 2549 if (!node && parent() && parent()->isBeforeOrAfterContent()) { | 2555 if (!node && parent() && parent()->isBeforeOrAfterContent()) { |
| 2550 for (RenderObject* renderer = parent(); renderer && !node; renderer = re
nderer->parent()) | 2556 for (LayoutObject* renderer = parent(); renderer && !node; renderer = re
nderer->parent()) |
| 2551 node = renderer->node(); | 2557 node = renderer->node(); |
| 2552 } | 2558 } |
| 2553 | 2559 |
| 2554 if (node) { | 2560 if (node) { |
| 2555 result.setInnerNode(node); | 2561 result.setInnerNode(node); |
| 2556 if (!result.innerNonSharedNode()) | 2562 if (!result.innerNonSharedNode()) |
| 2557 result.setInnerNonSharedNode(node); | 2563 result.setInnerNonSharedNode(node); |
| 2558 result.setLocalPoint(point); | 2564 result.setLocalPoint(point); |
| 2559 } | 2565 } |
| 2560 } | 2566 } |
| 2561 | 2567 |
| 2562 bool RenderObject::nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitT
estLocation& /*locationInContainer*/, const LayoutPoint& /*accumulatedOffset*/,
HitTestAction) | 2568 bool LayoutObject::nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitT
estLocation& /*locationInContainer*/, const LayoutPoint& /*accumulatedOffset*/,
HitTestAction) |
| 2563 { | 2569 { |
| 2564 return false; | 2570 return false; |
| 2565 } | 2571 } |
| 2566 | 2572 |
| 2567 void RenderObject::scheduleRelayout() | 2573 void LayoutObject::scheduleRelayout() |
| 2568 { | 2574 { |
| 2569 if (isRenderView()) { | 2575 if (isRenderView()) { |
| 2570 FrameView* view = toRenderView(this)->frameView(); | 2576 FrameView* view = toRenderView(this)->frameView(); |
| 2571 if (view) | 2577 if (view) |
| 2572 view->scheduleRelayout(); | 2578 view->scheduleRelayout(); |
| 2573 } else { | 2579 } else { |
| 2574 if (isRooted()) { | 2580 if (isRooted()) { |
| 2575 if (RenderView* renderView = view()) { | 2581 if (RenderView* renderView = view()) { |
| 2576 if (FrameView* frameView = renderView->frameView()) | 2582 if (FrameView* frameView = renderView->frameView()) |
| 2577 frameView->scheduleRelayoutOfSubtree(this); | 2583 frameView->scheduleRelayoutOfSubtree(this); |
| 2578 } | 2584 } |
| 2579 } | 2585 } |
| 2580 } | 2586 } |
| 2581 } | 2587 } |
| 2582 | 2588 |
| 2583 void RenderObject::forceLayout() | 2589 void LayoutObject::forceLayout() |
| 2584 { | 2590 { |
| 2585 setSelfNeedsLayout(true); | 2591 setSelfNeedsLayout(true); |
| 2586 setShouldDoFullPaintInvalidation(); | 2592 setShouldDoFullPaintInvalidation(); |
| 2587 layout(); | 2593 layout(); |
| 2588 } | 2594 } |
| 2589 | 2595 |
| 2590 // FIXME: Does this do anything different than forceLayout given that we don't w
alk | 2596 // FIXME: Does this do anything different than forceLayout given that we don't w
alk |
| 2591 // the containing block chain. If not, we should change all callers to use force
Layout. | 2597 // the containing block chain. If not, we should change all callers to use force
Layout. |
| 2592 void RenderObject::forceChildLayout() | 2598 void LayoutObject::forceChildLayout() |
| 2593 { | 2599 { |
| 2594 setNormalChildNeedsLayout(true); | 2600 setNormalChildNeedsLayout(true); |
| 2595 layout(); | 2601 layout(); |
| 2596 } | 2602 } |
| 2597 | 2603 |
| 2598 enum StyleCacheState { | 2604 enum StyleCacheState { |
| 2599 Cached, | 2605 Cached, |
| 2600 Uncached | 2606 Uncached |
| 2601 }; | 2607 }; |
| 2602 | 2608 |
| 2603 static PassRefPtr<RenderStyle> firstLineStyleForCachedUncachedType(StyleCacheSta
te type, const RenderObject* renderer, RenderStyle* style) | 2609 static PassRefPtr<RenderStyle> firstLineStyleForCachedUncachedType(StyleCacheSta
te type, const LayoutObject* renderer, RenderStyle* style) |
| 2604 { | 2610 { |
| 2605 const RenderObject* rendererForFirstLineStyle = renderer; | 2611 const LayoutObject* rendererForFirstLineStyle = renderer; |
| 2606 if (renderer->isBeforeOrAfterContent()) | 2612 if (renderer->isBeforeOrAfterContent()) |
| 2607 rendererForFirstLineStyle = renderer->parent(); | 2613 rendererForFirstLineStyle = renderer->parent(); |
| 2608 | 2614 |
| 2609 if (rendererForFirstLineStyle->isRenderBlockFlow() || rendererForFirstLineSt
yle->isRenderButton()) { | 2615 if (rendererForFirstLineStyle->isRenderBlockFlow() || rendererForFirstLineSt
yle->isRenderButton()) { |
| 2610 if (RenderBlock* firstLineBlock = rendererForFirstLineStyle->firstLineBl
ock()) { | 2616 if (RenderBlock* firstLineBlock = rendererForFirstLineStyle->firstLineBl
ock()) { |
| 2611 if (type == Cached) | 2617 if (type == Cached) |
| 2612 return firstLineBlock->getCachedPseudoStyle(FIRST_LINE, style); | 2618 return firstLineBlock->getCachedPseudoStyle(FIRST_LINE, style); |
| 2613 return firstLineBlock->getUncachedPseudoStyle(PseudoStyleRequest(FIR
ST_LINE), style, firstLineBlock == renderer ? style : 0); | 2619 return firstLineBlock->getUncachedPseudoStyle(PseudoStyleRequest(FIR
ST_LINE), style, firstLineBlock == renderer ? style : 0); |
| 2614 } | 2620 } |
| 2615 } else if (!rendererForFirstLineStyle->isAnonymous() && rendererForFirstLine
Style->isRenderInline() | 2621 } else if (!rendererForFirstLineStyle->isAnonymous() && rendererForFirstLine
Style->isRenderInline() |
| 2616 && !rendererForFirstLineStyle->node()->isFirstLetterPseudoElement()) { | 2622 && !rendererForFirstLineStyle->node()->isFirstLetterPseudoElement()) { |
| 2617 RenderStyle* parentStyle = rendererForFirstLineStyle->parent()->firstLin
eStyle(); | 2623 RenderStyle* parentStyle = rendererForFirstLineStyle->parent()->firstLin
eStyle(); |
| 2618 if (parentStyle != rendererForFirstLineStyle->parent()->style()) { | 2624 if (parentStyle != rendererForFirstLineStyle->parent()->style()) { |
| 2619 if (type == Cached) { | 2625 if (type == Cached) { |
| 2620 // A first-line style is in effect. Cache a first-line style for
ourselves. | 2626 // A first-line style is in effect. Cache a first-line style for
ourselves. |
| 2621 rendererForFirstLineStyle->style()->setHasPseudoStyle(FIRST_LINE
_INHERITED); | 2627 rendererForFirstLineStyle->style()->setHasPseudoStyle(FIRST_LINE
_INHERITED); |
| 2622 return rendererForFirstLineStyle->getCachedPseudoStyle(FIRST_LIN
E_INHERITED, parentStyle); | 2628 return rendererForFirstLineStyle->getCachedPseudoStyle(FIRST_LIN
E_INHERITED, parentStyle); |
| 2623 } | 2629 } |
| 2624 return rendererForFirstLineStyle->getUncachedPseudoStyle(PseudoStyle
Request(FIRST_LINE_INHERITED), parentStyle, style); | 2630 return rendererForFirstLineStyle->getUncachedPseudoStyle(PseudoStyle
Request(FIRST_LINE_INHERITED), parentStyle, style); |
| 2625 } | 2631 } |
| 2626 } | 2632 } |
| 2627 return nullptr; | 2633 return nullptr; |
| 2628 } | 2634 } |
| 2629 | 2635 |
| 2630 PassRefPtr<RenderStyle> RenderObject::uncachedFirstLineStyle(RenderStyle* style)
const | 2636 PassRefPtr<RenderStyle> LayoutObject::uncachedFirstLineStyle(RenderStyle* style)
const |
| 2631 { | 2637 { |
| 2632 if (!document().styleEngine()->usesFirstLineRules()) | 2638 if (!document().styleEngine()->usesFirstLineRules()) |
| 2633 return nullptr; | 2639 return nullptr; |
| 2634 | 2640 |
| 2635 ASSERT(!isText()); | 2641 ASSERT(!isText()); |
| 2636 | 2642 |
| 2637 return firstLineStyleForCachedUncachedType(Uncached, this, style); | 2643 return firstLineStyleForCachedUncachedType(Uncached, this, style); |
| 2638 } | 2644 } |
| 2639 | 2645 |
| 2640 RenderStyle* RenderObject::cachedFirstLineStyle() const | 2646 RenderStyle* LayoutObject::cachedFirstLineStyle() const |
| 2641 { | 2647 { |
| 2642 ASSERT(document().styleEngine()->usesFirstLineRules()); | 2648 ASSERT(document().styleEngine()->usesFirstLineRules()); |
| 2643 | 2649 |
| 2644 if (RefPtr<RenderStyle> style = firstLineStyleForCachedUncachedType(Cached,
isText() ? parent() : this, m_style.get())) | 2650 if (RefPtr<RenderStyle> style = firstLineStyleForCachedUncachedType(Cached,
isText() ? parent() : this, m_style.get())) |
| 2645 return style.get(); | 2651 return style.get(); |
| 2646 | 2652 |
| 2647 return m_style.get(); | 2653 return m_style.get(); |
| 2648 } | 2654 } |
| 2649 | 2655 |
| 2650 RenderStyle* RenderObject::getCachedPseudoStyle(PseudoId pseudo, RenderStyle* pa
rentStyle) const | 2656 RenderStyle* LayoutObject::getCachedPseudoStyle(PseudoId pseudo, RenderStyle* pa
rentStyle) const |
| 2651 { | 2657 { |
| 2652 if (pseudo < FIRST_INTERNAL_PSEUDOID && !style()->hasPseudoStyle(pseudo)) | 2658 if (pseudo < FIRST_INTERNAL_PSEUDOID && !style()->hasPseudoStyle(pseudo)) |
| 2653 return 0; | 2659 return 0; |
| 2654 | 2660 |
| 2655 RenderStyle* cachedStyle = style()->getCachedPseudoStyle(pseudo); | 2661 RenderStyle* cachedStyle = style()->getCachedPseudoStyle(pseudo); |
| 2656 if (cachedStyle) | 2662 if (cachedStyle) |
| 2657 return cachedStyle; | 2663 return cachedStyle; |
| 2658 | 2664 |
| 2659 RefPtr<RenderStyle> result = getUncachedPseudoStyle(PseudoStyleRequest(pseud
o), parentStyle); | 2665 RefPtr<RenderStyle> result = getUncachedPseudoStyle(PseudoStyleRequest(pseud
o), parentStyle); |
| 2660 if (result) | 2666 if (result) |
| 2661 return style()->addCachedPseudoStyle(result.release()); | 2667 return style()->addCachedPseudoStyle(result.release()); |
| 2662 return 0; | 2668 return 0; |
| 2663 } | 2669 } |
| 2664 | 2670 |
| 2665 PassRefPtr<RenderStyle> RenderObject::getUncachedPseudoStyle(const PseudoStyleRe
quest& pseudoStyleRequest, RenderStyle* parentStyle, RenderStyle* ownStyle) cons
t | 2671 PassRefPtr<RenderStyle> LayoutObject::getUncachedPseudoStyle(const PseudoStyleRe
quest& pseudoStyleRequest, RenderStyle* parentStyle, RenderStyle* ownStyle) cons
t |
| 2666 { | 2672 { |
| 2667 if (pseudoStyleRequest.pseudoId < FIRST_INTERNAL_PSEUDOID && !ownStyle && !s
tyle()->hasPseudoStyle(pseudoStyleRequest.pseudoId)) | 2673 if (pseudoStyleRequest.pseudoId < FIRST_INTERNAL_PSEUDOID && !ownStyle && !s
tyle()->hasPseudoStyle(pseudoStyleRequest.pseudoId)) |
| 2668 return nullptr; | 2674 return nullptr; |
| 2669 | 2675 |
| 2670 if (!parentStyle) { | 2676 if (!parentStyle) { |
| 2671 ASSERT(!ownStyle); | 2677 ASSERT(!ownStyle); |
| 2672 parentStyle = style(); | 2678 parentStyle = style(); |
| 2673 } | 2679 } |
| 2674 | 2680 |
| 2675 if (!node()) | 2681 if (!node()) |
| 2676 return nullptr; | 2682 return nullptr; |
| 2677 | 2683 |
| 2678 Element* element = Traversal<Element>::firstAncestorOrSelf(*node()); | 2684 Element* element = Traversal<Element>::firstAncestorOrSelf(*node()); |
| 2679 if (!element) | 2685 if (!element) |
| 2680 return nullptr; | 2686 return nullptr; |
| 2681 | 2687 |
| 2682 if (pseudoStyleRequest.pseudoId == FIRST_LINE_INHERITED) { | 2688 if (pseudoStyleRequest.pseudoId == FIRST_LINE_INHERITED) { |
| 2683 RefPtr<RenderStyle> result = document().ensureStyleResolver().styleForEl
ement(element, parentStyle, DisallowStyleSharing); | 2689 RefPtr<RenderStyle> result = document().ensureStyleResolver().styleForEl
ement(element, parentStyle, DisallowStyleSharing); |
| 2684 result->setStyleType(FIRST_LINE_INHERITED); | 2690 result->setStyleType(FIRST_LINE_INHERITED); |
| 2685 return result.release(); | 2691 return result.release(); |
| 2686 } | 2692 } |
| 2687 | 2693 |
| 2688 return document().ensureStyleResolver().pseudoStyleForElement(element, pseud
oStyleRequest, parentStyle); | 2694 return document().ensureStyleResolver().pseudoStyleForElement(element, pseud
oStyleRequest, parentStyle); |
| 2689 } | 2695 } |
| 2690 | 2696 |
| 2691 PassRefPtr<RenderStyle> RenderObject::getUncachedPseudoStyleFromParentOrShadowHo
st() const | 2697 PassRefPtr<RenderStyle> LayoutObject::getUncachedPseudoStyleFromParentOrShadowHo
st() const |
| 2692 { | 2698 { |
| 2693 if (!node()) | 2699 if (!node()) |
| 2694 return nullptr; | 2700 return nullptr; |
| 2695 | 2701 |
| 2696 if (ShadowRoot* root = node()->containingShadowRoot()) { | 2702 if (ShadowRoot* root = node()->containingShadowRoot()) { |
| 2697 if (root->type() == ShadowRoot::UserAgentShadowRoot) { | 2703 if (root->type() == ShadowRoot::UserAgentShadowRoot) { |
| 2698 if (Element* shadowHost = node()->shadowHost()) { | 2704 if (Element* shadowHost = node()->shadowHost()) { |
| 2699 return shadowHost->renderer()->getUncachedPseudoStyle(PseudoStyl
eRequest(SELECTION)); | 2705 return shadowHost->renderer()->getUncachedPseudoStyle(PseudoStyl
eRequest(SELECTION)); |
| 2700 } | 2706 } |
| 2701 } | 2707 } |
| 2702 } | 2708 } |
| 2703 | 2709 |
| 2704 return getUncachedPseudoStyle(PseudoStyleRequest(SELECTION)); | 2710 return getUncachedPseudoStyle(PseudoStyleRequest(SELECTION)); |
| 2705 } | 2711 } |
| 2706 | 2712 |
| 2707 void RenderObject::getTextDecorations(unsigned decorations, AppliedTextDecoratio
n& underline, AppliedTextDecoration& overline, AppliedTextDecoration& linethroug
h, bool quirksMode, bool firstlineStyle) | 2713 void LayoutObject::getTextDecorations(unsigned decorations, AppliedTextDecoratio
n& underline, AppliedTextDecoration& overline, AppliedTextDecoration& linethroug
h, bool quirksMode, bool firstlineStyle) |
| 2708 { | 2714 { |
| 2709 RenderObject* curr = this; | 2715 LayoutObject* curr = this; |
| 2710 RenderStyle* styleToUse = 0; | 2716 RenderStyle* styleToUse = 0; |
| 2711 unsigned currDecs = TextDecorationNone; | 2717 unsigned currDecs = TextDecorationNone; |
| 2712 Color resultColor; | 2718 Color resultColor; |
| 2713 TextDecorationStyle resultStyle; | 2719 TextDecorationStyle resultStyle; |
| 2714 do { | 2720 do { |
| 2715 styleToUse = curr->style(firstlineStyle); | 2721 styleToUse = curr->style(firstlineStyle); |
| 2716 currDecs = styleToUse->textDecoration(); | 2722 currDecs = styleToUse->textDecoration(); |
| 2717 currDecs &= decorations; | 2723 currDecs &= decorations; |
| 2718 resultColor = styleToUse->visitedDependentColor(CSSPropertyTextDecoratio
nColor); | 2724 resultColor = styleToUse->visitedDependentColor(CSSPropertyTextDecoratio
nColor); |
| 2719 resultStyle = styleToUse->textDecorationStyle(); | 2725 resultStyle = styleToUse->textDecorationStyle(); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2754 overline.color = resultColor; | 2760 overline.color = resultColor; |
| 2755 overline.style = resultStyle; | 2761 overline.style = resultStyle; |
| 2756 } | 2762 } |
| 2757 if (decorations & TextDecorationLineThrough) { | 2763 if (decorations & TextDecorationLineThrough) { |
| 2758 linethrough.color = resultColor; | 2764 linethrough.color = resultColor; |
| 2759 linethrough.style = resultStyle; | 2765 linethrough.style = resultStyle; |
| 2760 } | 2766 } |
| 2761 } | 2767 } |
| 2762 } | 2768 } |
| 2763 | 2769 |
| 2764 void RenderObject::addAnnotatedRegions(Vector<AnnotatedRegionValue>& regions) | 2770 void LayoutObject::addAnnotatedRegions(Vector<AnnotatedRegionValue>& regions) |
| 2765 { | 2771 { |
| 2766 // Convert the style regions to absolute coordinates. | 2772 // Convert the style regions to absolute coordinates. |
| 2767 if (style()->visibility() != VISIBLE || !isBox()) | 2773 if (style()->visibility() != VISIBLE || !isBox()) |
| 2768 return; | 2774 return; |
| 2769 | 2775 |
| 2770 if (style()->getDraggableRegionMode() == DraggableRegionNone) | 2776 if (style()->getDraggableRegionMode() == DraggableRegionNone) |
| 2771 return; | 2777 return; |
| 2772 | 2778 |
| 2773 RenderBox* box = toRenderBox(this); | 2779 RenderBox* box = toRenderBox(this); |
| 2774 FloatRect localBounds(FloatPoint(), FloatSize(box->size())); | 2780 FloatRect localBounds(FloatPoint(), FloatSize(box->size())); |
| 2775 FloatRect absBounds = localToAbsoluteQuad(localBounds).boundingBox(); | 2781 FloatRect absBounds = localToAbsoluteQuad(localBounds).boundingBox(); |
| 2776 | 2782 |
| 2777 AnnotatedRegionValue region; | 2783 AnnotatedRegionValue region; |
| 2778 region.draggable = style()->getDraggableRegionMode() == DraggableRegionDrag; | 2784 region.draggable = style()->getDraggableRegionMode() == DraggableRegionDrag; |
| 2779 region.bounds = LayoutRect(absBounds); | 2785 region.bounds = LayoutRect(absBounds); |
| 2780 regions.append(region); | 2786 regions.append(region); |
| 2781 } | 2787 } |
| 2782 | 2788 |
| 2783 void RenderObject::collectAnnotatedRegions(Vector<AnnotatedRegionValue>& regions
) | 2789 void LayoutObject::collectAnnotatedRegions(Vector<AnnotatedRegionValue>& regions
) |
| 2784 { | 2790 { |
| 2785 // RenderTexts don't have their own style, they just use their parent's styl
e, | 2791 // RenderTexts don't have their own style, they just use their parent's styl
e, |
| 2786 // so we don't want to include them. | 2792 // so we don't want to include them. |
| 2787 if (isText()) | 2793 if (isText()) |
| 2788 return; | 2794 return; |
| 2789 | 2795 |
| 2790 addAnnotatedRegions(regions); | 2796 addAnnotatedRegions(regions); |
| 2791 for (RenderObject* curr = slowFirstChild(); curr; curr = curr->nextSibling()
) | 2797 for (LayoutObject* curr = slowFirstChild(); curr; curr = curr->nextSibling()
) |
| 2792 curr->collectAnnotatedRegions(regions); | 2798 curr->collectAnnotatedRegions(regions); |
| 2793 } | 2799 } |
| 2794 | 2800 |
| 2795 bool RenderObject::willRenderImage(ImageResource*) | 2801 bool LayoutObject::willRenderImage(ImageResource*) |
| 2796 { | 2802 { |
| 2797 // Without visibility we won't render (and therefore don't care about animat
ion). | 2803 // Without visibility we won't render (and therefore don't care about animat
ion). |
| 2798 if (style()->visibility() != VISIBLE) | 2804 if (style()->visibility() != VISIBLE) |
| 2799 return false; | 2805 return false; |
| 2800 | 2806 |
| 2801 // We will not render a new image when Active DOM is suspended | 2807 // We will not render a new image when Active DOM is suspended |
| 2802 if (document().activeDOMObjectsAreSuspended()) | 2808 if (document().activeDOMObjectsAreSuspended()) |
| 2803 return false; | 2809 return false; |
| 2804 | 2810 |
| 2805 // If we're not in a window (i.e., we're dormant from being in a background
tab) | 2811 // If we're not in a window (i.e., we're dormant from being in a background
tab) |
| 2806 // then we don't want to render either. | 2812 // then we don't want to render either. |
| 2807 return document().view()->isVisible(); | 2813 return document().view()->isVisible(); |
| 2808 } | 2814 } |
| 2809 | 2815 |
| 2810 bool RenderObject::getImageAnimationPolicy(ImageResource*, ImageAnimationPolicy&
policy) | 2816 bool LayoutObject::getImageAnimationPolicy(ImageResource*, ImageAnimationPolicy&
policy) |
| 2811 { | 2817 { |
| 2812 if (!document().settings()) | 2818 if (!document().settings()) |
| 2813 return false; | 2819 return false; |
| 2814 | 2820 |
| 2815 policy = document().settings()->imageAnimationPolicy(); | 2821 policy = document().settings()->imageAnimationPolicy(); |
| 2816 return true; | 2822 return true; |
| 2817 } | 2823 } |
| 2818 | 2824 |
| 2819 int RenderObject::caretMinOffset() const | 2825 int LayoutObject::caretMinOffset() const |
| 2820 { | 2826 { |
| 2821 return 0; | 2827 return 0; |
| 2822 } | 2828 } |
| 2823 | 2829 |
| 2824 int RenderObject::caretMaxOffset() const | 2830 int LayoutObject::caretMaxOffset() const |
| 2825 { | 2831 { |
| 2826 if (isReplaced()) | 2832 if (isReplaced()) |
| 2827 return node() ? std::max(1U, node()->countChildren()) : 1; | 2833 return node() ? std::max(1U, node()->countChildren()) : 1; |
| 2828 if (isHR()) | 2834 if (isHR()) |
| 2829 return 1; | 2835 return 1; |
| 2830 return 0; | 2836 return 0; |
| 2831 } | 2837 } |
| 2832 | 2838 |
| 2833 int RenderObject::previousOffset(int current) const | 2839 int LayoutObject::previousOffset(int current) const |
| 2834 { | 2840 { |
| 2835 return current - 1; | 2841 return current - 1; |
| 2836 } | 2842 } |
| 2837 | 2843 |
| 2838 int RenderObject::previousOffsetForBackwardDeletion(int current) const | 2844 int LayoutObject::previousOffsetForBackwardDeletion(int current) const |
| 2839 { | 2845 { |
| 2840 return current - 1; | 2846 return current - 1; |
| 2841 } | 2847 } |
| 2842 | 2848 |
| 2843 int RenderObject::nextOffset(int current) const | 2849 int LayoutObject::nextOffset(int current) const |
| 2844 { | 2850 { |
| 2845 return current + 1; | 2851 return current + 1; |
| 2846 } | 2852 } |
| 2847 | 2853 |
| 2848 bool RenderObject::isInert() const | 2854 bool LayoutObject::isInert() const |
| 2849 { | 2855 { |
| 2850 const RenderObject* renderer = this; | 2856 const LayoutObject* renderer = this; |
| 2851 while (!renderer->node()) | 2857 while (!renderer->node()) |
| 2852 renderer = renderer->parent(); | 2858 renderer = renderer->parent(); |
| 2853 return renderer->node()->isInert(); | 2859 return renderer->node()->isInert(); |
| 2854 } | 2860 } |
| 2855 | 2861 |
| 2856 // touch-action applies to all elements with both width AND height properties. | 2862 // touch-action applies to all elements with both width AND height properties. |
| 2857 // According to the CSS Box Model Spec (http://dev.w3.org/csswg/css-box/#the-wid
th-and-height-properties) | 2863 // According to the CSS Box Model Spec (http://dev.w3.org/csswg/css-box/#the-wid
th-and-height-properties) |
| 2858 // width applies to all elements but non-replaced inline elements, table rows, a
nd row groups and | 2864 // width applies to all elements but non-replaced inline elements, table rows, a
nd row groups and |
| 2859 // height applies to all elements but non-replaced inline elements, table column
s, and column groups. | 2865 // height applies to all elements but non-replaced inline elements, table column
s, and column groups. |
| 2860 bool RenderObject::supportsTouchAction() const | 2866 bool LayoutObject::supportsTouchAction() const |
| 2861 { | 2867 { |
| 2862 if (isInline() && !isReplaced()) | 2868 if (isInline() && !isReplaced()) |
| 2863 return false; | 2869 return false; |
| 2864 if (isTableRow() || isLayoutTableCol()) | 2870 if (isTableRow() || isLayoutTableCol()) |
| 2865 return false; | 2871 return false; |
| 2866 | 2872 |
| 2867 return true; | 2873 return true; |
| 2868 } | 2874 } |
| 2869 | 2875 |
| 2870 void RenderObject::imageChanged(ImageResource* image, const IntRect* rect) | 2876 void LayoutObject::imageChanged(ImageResource* image, const IntRect* rect) |
| 2871 { | 2877 { |
| 2872 imageChanged(static_cast<WrappedImagePtr>(image), rect); | 2878 imageChanged(static_cast<WrappedImagePtr>(image), rect); |
| 2873 } | 2879 } |
| 2874 | 2880 |
| 2875 Element* RenderObject::offsetParent() const | 2881 Element* LayoutObject::offsetParent() const |
| 2876 { | 2882 { |
| 2877 if (isDocumentElement() || isBody()) | 2883 if (isDocumentElement() || isBody()) |
| 2878 return 0; | 2884 return 0; |
| 2879 | 2885 |
| 2880 if (isOutOfFlowPositioned() && style()->position() == FixedPosition) | 2886 if (isOutOfFlowPositioned() && style()->position() == FixedPosition) |
| 2881 return 0; | 2887 return 0; |
| 2882 | 2888 |
| 2883 float effectiveZoom = style()->effectiveZoom(); | 2889 float effectiveZoom = style()->effectiveZoom(); |
| 2884 Node* node = 0; | 2890 Node* node = 0; |
| 2885 for (RenderObject* ancestor = parent(); ancestor; ancestor = ancestor->paren
t()) { | 2891 for (LayoutObject* ancestor = parent(); ancestor; ancestor = ancestor->paren
t()) { |
| 2886 // Spec: http://www.w3.org/TR/cssom-view/#offset-attributes | 2892 // Spec: http://www.w3.org/TR/cssom-view/#offset-attributes |
| 2887 | 2893 |
| 2888 node = ancestor->node(); | 2894 node = ancestor->node(); |
| 2889 | 2895 |
| 2890 if (!node) | 2896 if (!node) |
| 2891 continue; | 2897 continue; |
| 2892 | 2898 |
| 2893 if (ancestor->isPositioned()) | 2899 if (ancestor->isPositioned()) |
| 2894 break; | 2900 break; |
| 2895 | 2901 |
| 2896 if (isHTMLBodyElement(*node)) | 2902 if (isHTMLBodyElement(*node)) |
| 2897 break; | 2903 break; |
| 2898 | 2904 |
| 2899 if (!isPositioned() && (isHTMLTableElement(*node) || isHTMLTableCellElem
ent(*node))) | 2905 if (!isPositioned() && (isHTMLTableElement(*node) || isHTMLTableCellElem
ent(*node))) |
| 2900 break; | 2906 break; |
| 2901 | 2907 |
| 2902 // Webkit specific extension where offsetParent stops at zoom level chan
ges. | 2908 // Webkit specific extension where offsetParent stops at zoom level chan
ges. |
| 2903 if (effectiveZoom != ancestor->style()->effectiveZoom()) | 2909 if (effectiveZoom != ancestor->style()->effectiveZoom()) |
| 2904 break; | 2910 break; |
| 2905 } | 2911 } |
| 2906 | 2912 |
| 2907 return node && node->isElementNode() ? toElement(node) : 0; | 2913 return node && node->isElementNode() ? toElement(node) : 0; |
| 2908 } | 2914 } |
| 2909 | 2915 |
| 2910 PositionWithAffinity RenderObject::createPositionWithAffinity(int offset, EAffin
ity affinity) | 2916 PositionWithAffinity LayoutObject::createPositionWithAffinity(int offset, EAffin
ity affinity) |
| 2911 { | 2917 { |
| 2912 // If this is a non-anonymous renderer in an editable area, then it's simple
. | 2918 // If this is a non-anonymous renderer in an editable area, then it's simple
. |
| 2913 if (Node* node = nonPseudoNode()) { | 2919 if (Node* node = nonPseudoNode()) { |
| 2914 if (!node->hasEditableStyle()) { | 2920 if (!node->hasEditableStyle()) { |
| 2915 // If it can be found, we prefer a visually equivalent position that
is editable. | 2921 // If it can be found, we prefer a visually equivalent position that
is editable. |
| 2916 Position position = createLegacyEditingPosition(node, offset); | 2922 Position position = createLegacyEditingPosition(node, offset); |
| 2917 Position candidate = position.downstream(CanCrossEditingBoundary); | 2923 Position candidate = position.downstream(CanCrossEditingBoundary); |
| 2918 if (candidate.deprecatedNode()->hasEditableStyle()) | 2924 if (candidate.deprecatedNode()->hasEditableStyle()) |
| 2919 return PositionWithAffinity(candidate, affinity); | 2925 return PositionWithAffinity(candidate, affinity); |
| 2920 candidate = position.upstream(CanCrossEditingBoundary); | 2926 candidate = position.upstream(CanCrossEditingBoundary); |
| 2921 if (candidate.deprecatedNode()->hasEditableStyle()) | 2927 if (candidate.deprecatedNode()->hasEditableStyle()) |
| 2922 return PositionWithAffinity(candidate, affinity); | 2928 return PositionWithAffinity(candidate, affinity); |
| 2923 } | 2929 } |
| 2924 // FIXME: Eliminate legacy editing positions | 2930 // FIXME: Eliminate legacy editing positions |
| 2925 return PositionWithAffinity(createLegacyEditingPosition(node, offset), a
ffinity); | 2931 return PositionWithAffinity(createLegacyEditingPosition(node, offset), a
ffinity); |
| 2926 } | 2932 } |
| 2927 | 2933 |
| 2928 // We don't want to cross the boundary between editable and non-editable | 2934 // We don't want to cross the boundary between editable and non-editable |
| 2929 // regions of the document, but that is either impossible or at least | 2935 // regions of the document, but that is either impossible or at least |
| 2930 // extremely unlikely in any normal case because we stop as soon as we | 2936 // extremely unlikely in any normal case because we stop as soon as we |
| 2931 // find a single non-anonymous renderer. | 2937 // find a single non-anonymous renderer. |
| 2932 | 2938 |
| 2933 // Find a nearby non-anonymous renderer. | 2939 // Find a nearby non-anonymous renderer. |
| 2934 RenderObject* child = this; | 2940 LayoutObject* child = this; |
| 2935 while (RenderObject* parent = child->parent()) { | 2941 while (LayoutObject* parent = child->parent()) { |
| 2936 // Find non-anonymous content after. | 2942 // Find non-anonymous content after. |
| 2937 for (RenderObject* renderer = child->nextInPreOrder(parent); renderer; r
enderer = renderer->nextInPreOrder(parent)) { | 2943 for (LayoutObject* renderer = child->nextInPreOrder(parent); renderer; r
enderer = renderer->nextInPreOrder(parent)) { |
| 2938 if (Node* node = renderer->nonPseudoNode()) | 2944 if (Node* node = renderer->nonPseudoNode()) |
| 2939 return PositionWithAffinity(firstPositionInOrBeforeNode(node), D
OWNSTREAM); | 2945 return PositionWithAffinity(firstPositionInOrBeforeNode(node), D
OWNSTREAM); |
| 2940 } | 2946 } |
| 2941 | 2947 |
| 2942 // Find non-anonymous content before. | 2948 // Find non-anonymous content before. |
| 2943 for (RenderObject* renderer = child->previousInPreOrder(); renderer; ren
derer = renderer->previousInPreOrder()) { | 2949 for (LayoutObject* renderer = child->previousInPreOrder(); renderer; ren
derer = renderer->previousInPreOrder()) { |
| 2944 if (renderer == parent) | 2950 if (renderer == parent) |
| 2945 break; | 2951 break; |
| 2946 if (Node* node = renderer->nonPseudoNode()) | 2952 if (Node* node = renderer->nonPseudoNode()) |
| 2947 return PositionWithAffinity(lastPositionInOrAfterNode(node), DOW
NSTREAM); | 2953 return PositionWithAffinity(lastPositionInOrAfterNode(node), DOW
NSTREAM); |
| 2948 } | 2954 } |
| 2949 | 2955 |
| 2950 // Use the parent itself unless it too is anonymous. | 2956 // Use the parent itself unless it too is anonymous. |
| 2951 if (Node* node = parent->nonPseudoNode()) | 2957 if (Node* node = parent->nonPseudoNode()) |
| 2952 return PositionWithAffinity(firstPositionInOrBeforeNode(node), DOWNS
TREAM); | 2958 return PositionWithAffinity(firstPositionInOrBeforeNode(node), DOWNS
TREAM); |
| 2953 | 2959 |
| 2954 // Repeat at the next level up. | 2960 // Repeat at the next level up. |
| 2955 child = parent; | 2961 child = parent; |
| 2956 } | 2962 } |
| 2957 | 2963 |
| 2958 // Everything was anonymous. Give up. | 2964 // Everything was anonymous. Give up. |
| 2959 return PositionWithAffinity(); | 2965 return PositionWithAffinity(); |
| 2960 } | 2966 } |
| 2961 | 2967 |
| 2962 PositionWithAffinity RenderObject::createPositionWithAffinity(const Position& po
sition) | 2968 PositionWithAffinity LayoutObject::createPositionWithAffinity(const Position& po
sition) |
| 2963 { | 2969 { |
| 2964 if (position.isNotNull()) | 2970 if (position.isNotNull()) |
| 2965 return PositionWithAffinity(position); | 2971 return PositionWithAffinity(position); |
| 2966 | 2972 |
| 2967 ASSERT(!node()); | 2973 ASSERT(!node()); |
| 2968 return createPositionWithAffinity(0, DOWNSTREAM); | 2974 return createPositionWithAffinity(0, DOWNSTREAM); |
| 2969 } | 2975 } |
| 2970 | 2976 |
| 2971 CursorDirective RenderObject::getCursor(const LayoutPoint&, Cursor&) const | 2977 CursorDirective LayoutObject::getCursor(const LayoutPoint&, Cursor&) const |
| 2972 { | 2978 { |
| 2973 return SetCursorBasedOnStyle; | 2979 return SetCursorBasedOnStyle; |
| 2974 } | 2980 } |
| 2975 | 2981 |
| 2976 bool RenderObject::canUpdateSelectionOnRootLineBoxes() const | 2982 bool LayoutObject::canUpdateSelectionOnRootLineBoxes() const |
| 2977 { | 2983 { |
| 2978 if (needsLayout()) | 2984 if (needsLayout()) |
| 2979 return false; | 2985 return false; |
| 2980 | 2986 |
| 2981 const RenderBlock* containingBlock = this->containingBlock(); | 2987 const RenderBlock* containingBlock = this->containingBlock(); |
| 2982 return containingBlock ? !containingBlock->needsLayout() : false; | 2988 return containingBlock ? !containingBlock->needsLayout() : false; |
| 2983 } | 2989 } |
| 2984 | 2990 |
| 2985 // We only create "generated" child renderers like one for first-letter if: | 2991 // We only create "generated" child renderers like one for first-letter if: |
| 2986 // - the firstLetterBlock can have children in the DOM and | 2992 // - the firstLetterBlock can have children in the DOM and |
| 2987 // - the block doesn't have any special assumption on its text children. | 2993 // - the block doesn't have any special assumption on its text children. |
| 2988 // This correctly prevents form controls from having such renderers. | 2994 // This correctly prevents form controls from having such renderers. |
| 2989 bool RenderObject::canHaveGeneratedChildren() const | 2995 bool LayoutObject::canHaveGeneratedChildren() const |
| 2990 { | 2996 { |
| 2991 return canHaveChildren(); | 2997 return canHaveChildren(); |
| 2992 } | 2998 } |
| 2993 | 2999 |
| 2994 void RenderObject::setNeedsBoundariesUpdate() | 3000 void LayoutObject::setNeedsBoundariesUpdate() |
| 2995 { | 3001 { |
| 2996 if (RenderObject* renderer = parent()) | 3002 if (LayoutObject* renderer = parent()) |
| 2997 renderer->setNeedsBoundariesUpdate(); | 3003 renderer->setNeedsBoundariesUpdate(); |
| 2998 } | 3004 } |
| 2999 | 3005 |
| 3000 FloatRect RenderObject::objectBoundingBox() const | 3006 FloatRect LayoutObject::objectBoundingBox() const |
| 3001 { | 3007 { |
| 3002 ASSERT_NOT_REACHED(); | 3008 ASSERT_NOT_REACHED(); |
| 3003 return FloatRect(); | 3009 return FloatRect(); |
| 3004 } | 3010 } |
| 3005 | 3011 |
| 3006 FloatRect RenderObject::strokeBoundingBox() const | 3012 FloatRect LayoutObject::strokeBoundingBox() const |
| 3007 { | 3013 { |
| 3008 ASSERT_NOT_REACHED(); | 3014 ASSERT_NOT_REACHED(); |
| 3009 return FloatRect(); | 3015 return FloatRect(); |
| 3010 } | 3016 } |
| 3011 | 3017 |
| 3012 // Returns the smallest rectangle enclosing all of the painted content | 3018 // Returns the smallest rectangle enclosing all of the painted content |
| 3013 // respecting clipping, masking, filters, opacity, stroke-width and markers | 3019 // respecting clipping, masking, filters, opacity, stroke-width and markers |
| 3014 FloatRect RenderObject::paintInvalidationRectInLocalCoordinates() const | 3020 FloatRect LayoutObject::paintInvalidationRectInLocalCoordinates() const |
| 3015 { | 3021 { |
| 3016 ASSERT_NOT_REACHED(); | 3022 ASSERT_NOT_REACHED(); |
| 3017 return FloatRect(); | 3023 return FloatRect(); |
| 3018 } | 3024 } |
| 3019 | 3025 |
| 3020 AffineTransform RenderObject::localTransform() const | 3026 AffineTransform LayoutObject::localTransform() const |
| 3021 { | 3027 { |
| 3022 static const AffineTransform identity; | 3028 static const AffineTransform identity; |
| 3023 return identity; | 3029 return identity; |
| 3024 } | 3030 } |
| 3025 | 3031 |
| 3026 const AffineTransform& RenderObject::localToParentTransform() const | 3032 const AffineTransform& LayoutObject::localToParentTransform() const |
| 3027 { | 3033 { |
| 3028 static const AffineTransform identity; | 3034 static const AffineTransform identity; |
| 3029 return identity; | 3035 return identity; |
| 3030 } | 3036 } |
| 3031 | 3037 |
| 3032 bool RenderObject::nodeAtFloatPoint(const HitTestRequest&, HitTestResult&, const
FloatPoint&, HitTestAction) | 3038 bool LayoutObject::nodeAtFloatPoint(const HitTestRequest&, HitTestResult&, const
FloatPoint&, HitTestAction) |
| 3033 { | 3039 { |
| 3034 ASSERT_NOT_REACHED(); | 3040 ASSERT_NOT_REACHED(); |
| 3035 return false; | 3041 return false; |
| 3036 } | 3042 } |
| 3037 | 3043 |
| 3038 bool RenderObject::isRelayoutBoundaryForInspector() const | 3044 bool LayoutObject::isRelayoutBoundaryForInspector() const |
| 3039 { | 3045 { |
| 3040 return objectIsRelayoutBoundary(this); | 3046 return objectIsRelayoutBoundary(this); |
| 3041 } | 3047 } |
| 3042 | 3048 |
| 3043 static PaintInvalidationReason documentLifecycleBasedPaintInvalidationReason(con
st DocumentLifecycle& documentLifecycle) | 3049 static PaintInvalidationReason documentLifecycleBasedPaintInvalidationReason(con
st DocumentLifecycle& documentLifecycle) |
| 3044 { | 3050 { |
| 3045 switch (documentLifecycle.state()) { | 3051 switch (documentLifecycle.state()) { |
| 3046 case DocumentLifecycle::InStyleRecalc: | 3052 case DocumentLifecycle::InStyleRecalc: |
| 3047 return PaintInvalidationStyleChange; | 3053 return PaintInvalidationStyleChange; |
| 3048 case DocumentLifecycle::InPreLayout: | 3054 case DocumentLifecycle::InPreLayout: |
| 3049 case DocumentLifecycle::InPerformLayout: | 3055 case DocumentLifecycle::InPerformLayout: |
| 3050 case DocumentLifecycle::AfterPerformLayout: | 3056 case DocumentLifecycle::AfterPerformLayout: |
| 3051 return PaintInvalidationForcedByLayout; | 3057 return PaintInvalidationForcedByLayout; |
| 3052 case DocumentLifecycle::InCompositingUpdate: | 3058 case DocumentLifecycle::InCompositingUpdate: |
| 3053 return PaintInvalidationCompositingUpdate; | 3059 return PaintInvalidationCompositingUpdate; |
| 3054 default: | 3060 default: |
| 3055 return PaintInvalidationFull; | 3061 return PaintInvalidationFull; |
| 3056 } | 3062 } |
| 3057 } | 3063 } |
| 3058 | 3064 |
| 3059 void RenderObject::setShouldDoFullPaintInvalidation(PaintInvalidationReason reas
on) | 3065 void LayoutObject::setShouldDoFullPaintInvalidation(PaintInvalidationReason reas
on) |
| 3060 { | 3066 { |
| 3061 // Only full invalidation reasons are allowed. | 3067 // Only full invalidation reasons are allowed. |
| 3062 ASSERT(isFullPaintInvalidationReason(reason)); | 3068 ASSERT(isFullPaintInvalidationReason(reason)); |
| 3063 | 3069 |
| 3064 if (m_bitfields.fullPaintInvalidationReason() == PaintInvalidationNone) { | 3070 if (m_bitfields.fullPaintInvalidationReason() == PaintInvalidationNone) { |
| 3065 if (reason == PaintInvalidationFull) | 3071 if (reason == PaintInvalidationFull) |
| 3066 reason = documentLifecycleBasedPaintInvalidationReason(document().li
fecycle()); | 3072 reason = documentLifecycleBasedPaintInvalidationReason(document().li
fecycle()); |
| 3067 m_bitfields.setFullPaintInvalidationReason(reason); | 3073 m_bitfields.setFullPaintInvalidationReason(reason); |
| 3068 } | 3074 } |
| 3069 | 3075 |
| 3070 ASSERT(document().lifecycle().state() != DocumentLifecycle::InPaintInvalidat
ion); | 3076 ASSERT(document().lifecycle().state() != DocumentLifecycle::InPaintInvalidat
ion); |
| 3071 frame()->page()->animator().scheduleVisualUpdate(); // In case that this is
called outside of FrameView::updateLayoutAndStyleForPainting(). | 3077 frame()->page()->animator().scheduleVisualUpdate(); // In case that this is
called outside of FrameView::updateLayoutAndStyleForPainting(). |
| 3072 markContainingBlockChainForPaintInvalidation(); | 3078 markContainingBlockChainForPaintInvalidation(); |
| 3073 } | 3079 } |
| 3074 | 3080 |
| 3075 void RenderObject::setMayNeedPaintInvalidation() | 3081 void LayoutObject::setMayNeedPaintInvalidation() |
| 3076 { | 3082 { |
| 3077 if (mayNeedPaintInvalidation()) | 3083 if (mayNeedPaintInvalidation()) |
| 3078 return; | 3084 return; |
| 3079 m_bitfields.setMayNeedPaintInvalidation(true); | 3085 m_bitfields.setMayNeedPaintInvalidation(true); |
| 3080 // Make sure our parent is marked as needing invalidation. | 3086 // Make sure our parent is marked as needing invalidation. |
| 3081 markContainingBlockChainForPaintInvalidation(); | 3087 markContainingBlockChainForPaintInvalidation(); |
| 3082 frame()->page()->animator().scheduleVisualUpdate(); // In case that this is
called outside of FrameView::updateLayoutAndStyleForPainting(). | 3088 frame()->page()->animator().scheduleVisualUpdate(); // In case that this is
called outside of FrameView::updateLayoutAndStyleForPainting(). |
| 3083 } | 3089 } |
| 3084 | 3090 |
| 3085 void RenderObject::clearMayNeedPaintInvalidation() | 3091 void LayoutObject::clearMayNeedPaintInvalidation() |
| 3086 { | 3092 { |
| 3087 m_bitfields.setMayNeedPaintInvalidation(false); | 3093 m_bitfields.setMayNeedPaintInvalidation(false); |
| 3088 } | 3094 } |
| 3089 | 3095 |
| 3090 void RenderObject::setSelfMayNeedPaintInvalidation() | 3096 void LayoutObject::setSelfMayNeedPaintInvalidation() |
| 3091 { | 3097 { |
| 3092 m_bitfields.setMayNeedPaintInvalidation(true); | 3098 m_bitfields.setMayNeedPaintInvalidation(true); |
| 3093 } | 3099 } |
| 3094 | 3100 |
| 3095 void RenderObject::markContainingBlockChainForPaintInvalidation() | 3101 void LayoutObject::markContainingBlockChainForPaintInvalidation() |
| 3096 { | 3102 { |
| 3097 for (RenderObject* container = this->container(); container && !container->s
houldCheckForPaintInvalidationRegardlessOfPaintInvalidationState(); container =
container->container()) | 3103 for (LayoutObject* container = this->container(); container && !container->s
houldCheckForPaintInvalidationRegardlessOfPaintInvalidationState(); container =
container->container()) |
| 3098 container->setSelfMayNeedPaintInvalidation(); | 3104 container->setSelfMayNeedPaintInvalidation(); |
| 3099 } | 3105 } |
| 3100 | 3106 |
| 3101 void RenderObject::clearPaintInvalidationState(const PaintInvalidationState& pai
ntInvalidationState) | 3107 void LayoutObject::clearPaintInvalidationState(const PaintInvalidationState& pai
ntInvalidationState) |
| 3102 { | 3108 { |
| 3103 // paintInvalidationStateIsDirty should be kept in sync with the | 3109 // paintInvalidationStateIsDirty should be kept in sync with the |
| 3104 // booleans that are cleared below. | 3110 // booleans that are cleared below. |
| 3105 ASSERT(paintInvalidationState.forceCheckForPaintInvalidation() || paintInval
idationStateIsDirty()); | 3111 ASSERT(paintInvalidationState.forceCheckForPaintInvalidation() || paintInval
idationStateIsDirty()); |
| 3106 clearShouldDoFullPaintInvalidation(); | 3112 clearShouldDoFullPaintInvalidation(); |
| 3107 setNeededLayoutBecauseOfChildren(false); | 3113 setNeededLayoutBecauseOfChildren(false); |
| 3108 setShouldInvalidateOverflowForPaint(false); | 3114 setShouldInvalidateOverflowForPaint(false); |
| 3109 clearLayoutDidGetCalledSinceLastFrame(); | 3115 clearLayoutDidGetCalledSinceLastFrame(); |
| 3110 clearMayNeedPaintInvalidation(); | 3116 clearMayNeedPaintInvalidation(); |
| 3111 clearShouldInvalidateSelection(); | 3117 clearShouldInvalidateSelection(); |
| 3112 } | 3118 } |
| 3113 | 3119 |
| 3114 bool RenderObject::isAllowedToModifyRenderTreeStructure(Document& document) | 3120 bool LayoutObject::isAllowedToModifyRenderTreeStructure(Document& document) |
| 3115 { | 3121 { |
| 3116 return DeprecatedDisableModifyRenderTreeStructureAsserts::canModifyRenderTre
eStateInAnyState() | 3122 return DeprecatedDisableModifyRenderTreeStructureAsserts::canModifyRenderTre
eStateInAnyState() |
| 3117 || document.lifecycle().stateAllowsRenderTreeMutations(); | 3123 || document.lifecycle().stateAllowsRenderTreeMutations(); |
| 3118 } | 3124 } |
| 3119 | 3125 |
| 3120 DeprecatedDisableModifyRenderTreeStructureAsserts::DeprecatedDisableModifyRender
TreeStructureAsserts() | 3126 DeprecatedDisableModifyRenderTreeStructureAsserts::DeprecatedDisableModifyRender
TreeStructureAsserts() |
| 3121 : m_disabler(gModifyRenderTreeStructureAnyState, true) | 3127 : m_disabler(gModifyRenderTreeStructureAnyState, true) |
| 3122 { | 3128 { |
| 3123 } | 3129 } |
| 3124 | 3130 |
| 3125 bool DeprecatedDisableModifyRenderTreeStructureAsserts::canModifyRenderTreeState
InAnyState() | 3131 bool DeprecatedDisableModifyRenderTreeStructureAsserts::canModifyRenderTreeState
InAnyState() |
| 3126 { | 3132 { |
| 3127 return gModifyRenderTreeStructureAnyState; | 3133 return gModifyRenderTreeStructureAnyState; |
| 3128 } | 3134 } |
| 3129 | 3135 |
| 3130 // Since we're only painting non-composited layers, we know that they all share
the same paintInvalidationContainer. | 3136 // Since we're only painting non-composited layers, we know that they all share
the same paintInvalidationContainer. |
| 3131 void RenderObject::invalidatePaintIncludingNonCompositingDescendants() | 3137 void LayoutObject::invalidatePaintIncludingNonCompositingDescendants() |
| 3132 { | 3138 { |
| 3133 invalidatePaintIncludingNonCompositingDescendantsInternal(containerForPaintI
nvalidation()); | 3139 invalidatePaintIncludingNonCompositingDescendantsInternal(containerForPaintI
nvalidation()); |
| 3134 } | 3140 } |
| 3135 | 3141 |
| 3136 void RenderObject::invalidatePaintIncludingNonCompositingDescendantsInternal(con
st LayoutLayerModelObject* paintInvalidationContainer) | 3142 void LayoutObject::invalidatePaintIncludingNonCompositingDescendantsInternal(con
st LayoutLayerModelObject* paintInvalidationContainer) |
| 3137 { | 3143 { |
| 3138 invalidatePaintUsingContainer(paintInvalidationContainer, previousPaintInval
idationRect(), PaintInvalidationLayer); | 3144 invalidatePaintUsingContainer(paintInvalidationContainer, previousPaintInval
idationRect(), PaintInvalidationLayer); |
| 3139 | 3145 |
| 3140 for (RenderObject* child = slowFirstChild(); child; child = child->nextSibli
ng()) { | 3146 for (LayoutObject* child = slowFirstChild(); child; child = child->nextSibli
ng()) { |
| 3141 if (!child->isPaintInvalidationContainer()) | 3147 if (!child->isPaintInvalidationContainer()) |
| 3142 child->invalidatePaintIncludingNonCompositingDescendantsInternal(pai
ntInvalidationContainer); | 3148 child->invalidatePaintIncludingNonCompositingDescendantsInternal(pai
ntInvalidationContainer); |
| 3143 } | 3149 } |
| 3144 } | 3150 } |
| 3145 | 3151 |
| 3146 | 3152 |
| 3147 } // namespace blink | 3153 } // namespace blink |
| 3148 | 3154 |
| 3149 #ifndef NDEBUG | 3155 #ifndef NDEBUG |
| 3150 | 3156 |
| 3151 void showTree(const blink::RenderObject* object) | 3157 void showTree(const blink::LayoutObject* object) |
| 3152 { | 3158 { |
| 3153 if (object) | 3159 if (object) |
| 3154 object->showTreeForThis(); | 3160 object->showTreeForThis(); |
| 3155 } | 3161 } |
| 3156 | 3162 |
| 3157 void showLineTree(const blink::RenderObject* object) | 3163 void showLineTree(const blink::LayoutObject* object) |
| 3158 { | 3164 { |
| 3159 if (object) | 3165 if (object) |
| 3160 object->showLineTreeForThis(); | 3166 object->showLineTreeForThis(); |
| 3161 } | 3167 } |
| 3162 | 3168 |
| 3163 void showRenderTree(const blink::RenderObject* object1) | 3169 void showRenderTree(const blink::LayoutObject* object1) |
| 3164 { | 3170 { |
| 3165 showRenderTree(object1, 0); | 3171 showRenderTree(object1, 0); |
| 3166 } | 3172 } |
| 3167 | 3173 |
| 3168 void showRenderTree(const blink::RenderObject* object1, const blink::RenderObjec
t* object2) | 3174 void showRenderTree(const blink::LayoutObject* object1, const blink::LayoutObjec
t* object2) |
| 3169 { | 3175 { |
| 3170 if (object1) { | 3176 if (object1) { |
| 3171 const blink::RenderObject* root = object1; | 3177 const blink::LayoutObject* root = object1; |
| 3172 while (root->parent()) | 3178 while (root->parent()) |
| 3173 root = root->parent(); | 3179 root = root->parent(); |
| 3174 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); | 3180 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); |
| 3175 } | 3181 } |
| 3176 } | 3182 } |
| 3177 | 3183 |
| 3178 #endif | 3184 #endif |
| OLD | NEW |