Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Neither the name of Google Inc. nor the names of its | 10 * * Neither the name of Google Inc. nor the names of its |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 #include "bindings/core/v8/ExceptionState.h" | 29 #include "bindings/core/v8/ExceptionState.h" |
| 30 #include "core/css/StyleSheetList.h" | 30 #include "core/css/StyleSheetList.h" |
| 31 #include "core/css/resolver/StyleResolver.h" | 31 #include "core/css/resolver/StyleResolver.h" |
| 32 #include "core/css/resolver/StyleSharingDepthScope.h" | 32 #include "core/css/resolver/StyleSharingDepthScope.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/Text.h" | 35 #include "core/dom/Text.h" |
| 36 #include "core/dom/shadow/ElementShadow.h" | 36 #include "core/dom/shadow/ElementShadow.h" |
| 37 #include "core/dom/shadow/InsertionPoint.h" | 37 #include "core/dom/shadow/InsertionPoint.h" |
| 38 #include "core/dom/shadow/ShadowRootRareData.h" | 38 #include "core/dom/shadow/ShadowRootRareData.h" |
| 39 #include "core/dom/shadow/ShadowRootRareDataV0.h" | |
| 39 #include "core/editing/serializers/Serialization.h" | 40 #include "core/editing/serializers/Serialization.h" |
| 40 #include "core/html/HTMLShadowElement.h" | 41 #include "core/html/HTMLShadowElement.h" |
| 41 #include "public/platform/Platform.h" | 42 #include "public/platform/Platform.h" |
| 42 | 43 |
| 43 namespace blink { | 44 namespace blink { |
| 44 | 45 |
| 45 struct SameSizeAsShadowRoot : public DocumentFragment, public TreeScope, public DoublyLinkedListNode<ShadowRoot> { | 46 struct SameSizeAsShadowRoot : public DocumentFragment, public TreeScope, public DoublyLinkedListNode<ShadowRoot> { |
| 46 char emptyClassFieldsDueToGCMixinMarker[1]; | 47 char emptyClassFieldsDueToGCMixinMarker[1]; |
| 47 Member<void*> willbeMember[4]; | 48 Member<void*> willbeMember[5]; |
| 48 unsigned countersAndFlags[1]; | 49 unsigned countersAndFlags[1]; |
| 49 }; | 50 }; |
| 50 | 51 |
| 51 static_assert(sizeof(ShadowRoot) == sizeof(SameSizeAsShadowRoot), "ShadowRoot sh ould stay small"); | 52 static_assert(sizeof(ShadowRoot) == sizeof(SameSizeAsShadowRoot), "ShadowRoot sh ould stay small"); |
| 52 | 53 |
| 53 ShadowRoot::ShadowRoot(Document& document, ShadowRootType type) | 54 ShadowRoot::ShadowRoot(Document& document, ShadowRootType type) |
| 54 : DocumentFragment(0, CreateShadowRoot) | 55 : DocumentFragment(0, CreateShadowRoot) |
| 55 , TreeScope(*this, document) | 56 , TreeScope(*this, document) |
| 56 , m_prev(nullptr) | 57 , m_prev(nullptr) |
| 57 , m_next(nullptr) | 58 , m_next(nullptr) |
| 59 , m_shadowRootRareData(nullptr) | |
|
tkent
2016/04/21 05:46:01
You don't need to initialize Member<T> with nullpt
hayato
2016/04/21 06:33:27
Done
| |
| 60 , m_shadowRootRareDataV0(nullptr) | |
| 58 , m_slotAssignment(nullptr) | 61 , m_slotAssignment(nullptr) |
| 59 , m_numberOfStyles(0) | 62 , m_numberOfStyles(0) |
| 60 , m_type(static_cast<unsigned>(type)) | 63 , m_type(static_cast<unsigned>(type)) |
| 61 , m_registeredWithParentShadowRoot(false) | 64 , m_registeredWithParentShadowRoot(false) |
| 62 , m_descendantInsertionPointsIsValid(false) | 65 , m_descendantInsertionPointsIsValid(false) |
| 63 , m_delegatesFocus(false) | 66 , m_delegatesFocus(false) |
| 64 , m_descendantSlotsIsValid(false) | 67 , m_descendantSlotsIsValid(false) |
| 65 { | 68 { |
| 66 } | 69 } |
| 67 | 70 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 187 | 190 |
| 188 ShadowRootRareData* ShadowRoot::ensureShadowRootRareData() | 191 ShadowRootRareData* ShadowRoot::ensureShadowRootRareData() |
| 189 { | 192 { |
| 190 if (m_shadowRootRareData) | 193 if (m_shadowRootRareData) |
| 191 return m_shadowRootRareData.get(); | 194 return m_shadowRootRareData.get(); |
| 192 | 195 |
| 193 m_shadowRootRareData = new ShadowRootRareData; | 196 m_shadowRootRareData = new ShadowRootRareData; |
| 194 return m_shadowRootRareData.get(); | 197 return m_shadowRootRareData.get(); |
| 195 } | 198 } |
| 196 | 199 |
| 200 ShadowRootRareDataV0* ShadowRoot::ensureShadowRootRareDataV0() | |
| 201 { | |
| 202 if (m_shadowRootRareDataV0) | |
| 203 return m_shadowRootRareDataV0.get(); | |
| 204 | |
| 205 m_shadowRootRareDataV0 = new ShadowRootRareDataV0; | |
| 206 return m_shadowRootRareDataV0.get(); | |
| 207 } | |
| 208 | |
| 197 bool ShadowRoot::containsShadowElements() const | 209 bool ShadowRoot::containsShadowElements() const |
| 198 { | 210 { |
| 199 return m_shadowRootRareData ? m_shadowRootRareData->containsShadowElements() : 0; | 211 return m_shadowRootRareDataV0 ? m_shadowRootRareDataV0->containsShadowElemen ts() : 0; |
|
tkent
2016/04/21 05:46:01
0 -> false?
hayato
2016/04/21 06:33:27
Done
| |
| 200 } | 212 } |
| 201 | 213 |
| 202 bool ShadowRoot::containsContentElements() const | 214 bool ShadowRoot::containsContentElements() const |
| 203 { | 215 { |
| 204 return m_shadowRootRareData ? m_shadowRootRareData->containsContentElements( ) : 0; | 216 return m_shadowRootRareDataV0 ? m_shadowRootRareDataV0->containsContentEleme nts() : 0; |
|
tkent
2016/04/21 05:46:01
0 -> false?
hayato
2016/04/21 06:33:27
Done
| |
| 205 } | 217 } |
| 206 | 218 |
| 207 bool ShadowRoot::containsShadowRoots() const | 219 bool ShadowRoot::containsShadowRoots() const |
| 208 { | 220 { |
| 209 return m_shadowRootRareData ? m_shadowRootRareData->containsShadowRoots() : 0; | 221 return m_shadowRootRareData ? m_shadowRootRareData->containsShadowRoots() : 0; |
| 210 } | 222 } |
| 211 | 223 |
| 212 unsigned ShadowRoot::descendantShadowElementCount() const | 224 unsigned ShadowRoot::descendantShadowElementCount() const |
| 213 { | 225 { |
| 214 return m_shadowRootRareData ? m_shadowRootRareData->descendantShadowElementC ount() : 0; | 226 return m_shadowRootRareDataV0 ? m_shadowRootRareDataV0->descendantShadowElem entCount() : 0; |
| 215 } | 227 } |
| 216 | 228 |
| 217 HTMLShadowElement* ShadowRoot::shadowInsertionPointOfYoungerShadowRoot() const | 229 HTMLShadowElement* ShadowRoot::shadowInsertionPointOfYoungerShadowRoot() const |
| 218 { | 230 { |
| 219 return m_shadowRootRareData ? m_shadowRootRareData->shadowInsertionPointOfYo ungerShadowRoot() : 0; | 231 return m_shadowRootRareDataV0 ? m_shadowRootRareDataV0->shadowInsertionPoint OfYoungerShadowRoot() : 0; |
|
tkent
2016/04/21 05:46:00
0 -> nullptr?
hayato
2016/04/21 06:33:27
Done
| |
| 220 } | 232 } |
| 221 | 233 |
| 222 void ShadowRoot::setShadowInsertionPointOfYoungerShadowRoot(HTMLShadowElement* s hadowInsertionPoint) | 234 void ShadowRoot::setShadowInsertionPointOfYoungerShadowRoot(HTMLShadowElement* s hadowInsertionPoint) |
| 223 { | 235 { |
| 224 if (!m_shadowRootRareData && !shadowInsertionPoint) | 236 if (!m_shadowRootRareDataV0 && !shadowInsertionPoint) |
| 225 return; | 237 return; |
| 226 ensureShadowRootRareData()->setShadowInsertionPointOfYoungerShadowRoot(shado wInsertionPoint); | 238 ensureShadowRootRareDataV0()->setShadowInsertionPointOfYoungerShadowRoot(sha dowInsertionPoint); |
| 227 } | 239 } |
| 228 | 240 |
| 229 void ShadowRoot::didAddInsertionPoint(InsertionPoint* insertionPoint) | 241 void ShadowRoot::didAddInsertionPoint(InsertionPoint* insertionPoint) |
| 230 { | 242 { |
| 231 ensureShadowRootRareData()->didAddInsertionPoint(insertionPoint); | 243 ensureShadowRootRareDataV0()->didAddInsertionPoint(insertionPoint); |
| 232 invalidateDescendantInsertionPoints(); | 244 invalidateDescendantInsertionPoints(); |
| 233 } | 245 } |
| 234 | 246 |
| 235 void ShadowRoot::didRemoveInsertionPoint(InsertionPoint* insertionPoint) | 247 void ShadowRoot::didRemoveInsertionPoint(InsertionPoint* insertionPoint) |
| 236 { | 248 { |
| 237 m_shadowRootRareData->didRemoveInsertionPoint(insertionPoint); | 249 m_shadowRootRareDataV0->didRemoveInsertionPoint(insertionPoint); |
| 238 invalidateDescendantInsertionPoints(); | 250 invalidateDescendantInsertionPoints(); |
| 239 } | 251 } |
| 240 | 252 |
| 241 void ShadowRoot::addChildShadowRoot() | 253 void ShadowRoot::addChildShadowRoot() |
| 242 { | 254 { |
| 243 ensureShadowRootRareData()->didAddChildShadowRoot(); | 255 ensureShadowRootRareData()->didAddChildShadowRoot(); |
| 244 } | 256 } |
| 245 | 257 |
| 246 void ShadowRoot::removeChildShadowRoot() | 258 void ShadowRoot::removeChildShadowRoot() |
| 247 { | 259 { |
| 248 // FIXME: Why isn't this an ASSERT? | 260 // FIXME: Why isn't this an ASSERT? |
| 249 if (!m_shadowRootRareData) | 261 if (!m_shadowRootRareData) |
| 250 return; | 262 return; |
| 251 m_shadowRootRareData->didRemoveChildShadowRoot(); | 263 m_shadowRootRareData->didRemoveChildShadowRoot(); |
| 252 } | 264 } |
| 253 | 265 |
| 254 unsigned ShadowRoot::childShadowRootCount() const | 266 unsigned ShadowRoot::childShadowRootCount() const |
| 255 { | 267 { |
| 256 return m_shadowRootRareData ? m_shadowRootRareData->childShadowRootCount() : 0; | 268 return m_shadowRootRareData ? m_shadowRootRareData->childShadowRootCount() : 0; |
| 257 } | 269 } |
| 258 | 270 |
| 259 void ShadowRoot::invalidateDescendantInsertionPoints() | 271 void ShadowRoot::invalidateDescendantInsertionPoints() |
| 260 { | 272 { |
| 261 m_descendantInsertionPointsIsValid = false; | 273 m_descendantInsertionPointsIsValid = false; |
| 262 m_shadowRootRareData->clearDescendantInsertionPoints(); | 274 m_shadowRootRareDataV0->clearDescendantInsertionPoints(); |
| 263 } | 275 } |
| 264 | 276 |
| 265 const HeapVector<Member<InsertionPoint>>& ShadowRoot::descendantInsertionPoints( ) | 277 const HeapVector<Member<InsertionPoint>>& ShadowRoot::descendantInsertionPoints( ) |
| 266 { | 278 { |
| 267 DEFINE_STATIC_LOCAL(HeapVector<Member<InsertionPoint>>, emptyList, (new Heap Vector<Member<InsertionPoint>>)); | 279 DEFINE_STATIC_LOCAL(HeapVector<Member<InsertionPoint>>, emptyList, (new Heap Vector<Member<InsertionPoint>>)); |
| 268 if (m_shadowRootRareData && m_descendantInsertionPointsIsValid) | 280 if (m_shadowRootRareDataV0 && m_descendantInsertionPointsIsValid) |
| 269 return m_shadowRootRareData->descendantInsertionPoints(); | 281 return m_shadowRootRareDataV0->descendantInsertionPoints(); |
| 270 | 282 |
| 271 m_descendantInsertionPointsIsValid = true; | 283 m_descendantInsertionPointsIsValid = true; |
| 272 | 284 |
| 273 if (!containsInsertionPoints()) | 285 if (!containsInsertionPoints()) |
| 274 return emptyList; | 286 return emptyList; |
| 275 | 287 |
| 276 HeapVector<Member<InsertionPoint>> insertionPoints; | 288 HeapVector<Member<InsertionPoint>> insertionPoints; |
| 277 for (InsertionPoint& insertionPoint : Traversal<InsertionPoint>::descendants Of(*this)) | 289 for (InsertionPoint& insertionPoint : Traversal<InsertionPoint>::descendants Of(*this)) |
| 278 insertionPoints.append(&insertionPoint); | 290 insertionPoints.append(&insertionPoint); |
| 279 | 291 |
| 280 ensureShadowRootRareData()->setDescendantInsertionPoints(insertionPoints); | 292 ensureShadowRootRareDataV0()->setDescendantInsertionPoints(insertionPoints); |
| 281 | 293 |
| 282 return m_shadowRootRareData->descendantInsertionPoints(); | 294 return m_shadowRootRareDataV0->descendantInsertionPoints(); |
| 283 } | 295 } |
| 284 | 296 |
| 285 StyleSheetList* ShadowRoot::styleSheets() | 297 StyleSheetList* ShadowRoot::styleSheets() |
| 286 { | 298 { |
| 287 if (!ensureShadowRootRareData()->styleSheets()) | 299 if (!ensureShadowRootRareData()->styleSheets()) |
| 288 m_shadowRootRareData->setStyleSheets(StyleSheetList::create(this)); | 300 m_shadowRootRareData->setStyleSheets(StyleSheetList::create(this)); |
| 289 | 301 |
| 290 return m_shadowRootRareData->styleSheets(); | 302 return m_shadowRootRareData->styleSheets(); |
| 291 } | 303 } |
| 292 | 304 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 339 if (!m_slotAssignment) | 351 if (!m_slotAssignment) |
| 340 m_slotAssignment = SlotAssignment::create(); | 352 m_slotAssignment = SlotAssignment::create(); |
| 341 m_slotAssignment->resolveAssignment(*this); | 353 m_slotAssignment->resolveAssignment(*this); |
| 342 } | 354 } |
| 343 | 355 |
| 344 DEFINE_TRACE(ShadowRoot) | 356 DEFINE_TRACE(ShadowRoot) |
| 345 { | 357 { |
| 346 visitor->trace(m_prev); | 358 visitor->trace(m_prev); |
| 347 visitor->trace(m_next); | 359 visitor->trace(m_next); |
| 348 visitor->trace(m_shadowRootRareData); | 360 visitor->trace(m_shadowRootRareData); |
| 361 visitor->trace(m_shadowRootRareDataV0); | |
| 349 visitor->trace(m_slotAssignment); | 362 visitor->trace(m_slotAssignment); |
| 350 TreeScope::trace(visitor); | 363 TreeScope::trace(visitor); |
| 351 DocumentFragment::trace(visitor); | 364 DocumentFragment::trace(visitor); |
| 352 } | 365 } |
| 353 | 366 |
| 354 } // namespace blink | 367 } // namespace blink |
| OLD | NEW |