Chromium Code Reviews| 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) 2001 Peter Kelly (pmk@post.com) | 4 * (C) 2001 Peter Kelly (pmk@post.com) |
| 5 * (C) 2001 Dirk Mueller (mueller@kde.org) | 5 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 6 * (C) 2007 David Smith (catfish.man@gmail.com) | 6 * (C) 2007 David Smith (catfish.man@gmail.com) |
| 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved. | 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved. |
| 8 * (C) 2007 Eric Seidel (eric@webkit.org) | 8 * (C) 2007 Eric Seidel (eric@webkit.org) |
| 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 |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 198 } | 198 } |
| 199 #endif | 199 #endif |
| 200 | 200 |
| 201 if (PropertySetCSSStyleDeclaration* cssomWrapper = inlineStyleCSSOMWrapper() ) | 201 if (PropertySetCSSStyleDeclaration* cssomWrapper = inlineStyleCSSOMWrapper() ) |
| 202 cssomWrapper->clearParentElement(); | 202 cssomWrapper->clearParentElement(); |
| 203 | 203 |
| 204 if (hasRareData()) { | 204 if (hasRareData()) { |
| 205 ElementRareData* data = elementRareData(); | 205 ElementRareData* data = elementRareData(); |
| 206 data->setPseudoElement(BEFORE, 0); | 206 data->setPseudoElement(BEFORE, 0); |
| 207 data->setPseudoElement(AFTER, 0); | 207 data->setPseudoElement(AFTER, 0); |
| 208 | |
| 209 if (Element* backdrop = data->pseudoElement(BACKDROP)) | |
| 210 document()->removeFromTopLayer(backdrop); | |
|
esprehn
2013/07/04 08:34:07
Lets just do this inside releasePseudoElement(). I
falken
2013/07/04 12:18:01
Done.
| |
| 211 data->setPseudoElement(BACKDROP, 0); | |
| 212 | |
| 208 data->clearShadow(); | 213 data->clearShadow(); |
| 209 } | 214 } |
| 210 | 215 |
| 211 if (isCustomElement() && document() && document()->registry()) { | 216 if (isCustomElement() && document() && document()->registry()) { |
| 212 document()->registry()->customElementWasDestroyed(this); | 217 document()->registry()->customElementWasDestroyed(this); |
| 213 } | 218 } |
| 214 | 219 |
| 215 if (hasSyntheticAttrChildNodes()) | 220 if (hasSyntheticAttrChildNodes()) |
| 216 detachAllAttrNodesFromElement(); | 221 detachAllAttrNodesFromElement(); |
| 217 | 222 |
| (...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1285 void Element::removedFrom(ContainerNode* insertionPoint) | 1290 void Element::removedFrom(ContainerNode* insertionPoint) |
| 1286 { | 1291 { |
| 1287 bool wasInDocument = insertionPoint->document(); | 1292 bool wasInDocument = insertionPoint->document(); |
| 1288 | 1293 |
| 1289 if (Element* before = pseudoElement(BEFORE)) | 1294 if (Element* before = pseudoElement(BEFORE)) |
| 1290 before->removedFrom(insertionPoint); | 1295 before->removedFrom(insertionPoint); |
| 1291 | 1296 |
| 1292 if (Element* after = pseudoElement(AFTER)) | 1297 if (Element* after = pseudoElement(AFTER)) |
| 1293 after->removedFrom(insertionPoint); | 1298 after->removedFrom(insertionPoint); |
| 1294 | 1299 |
| 1300 if (Element* backdrop = pseudoElement(BACKDROP)) | |
| 1301 backdrop->removedFrom(insertionPoint); | |
| 1295 document()->removeFromTopLayer(this); | 1302 document()->removeFromTopLayer(this); |
| 1303 | |
| 1296 if (containsFullScreenElement()) | 1304 if (containsFullScreenElement()) |
| 1297 setContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(false); | 1305 setContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(false); |
| 1298 | 1306 |
| 1299 if (document()->page()) | 1307 if (document()->page()) |
| 1300 document()->page()->pointerLockController()->elementRemoved(this); | 1308 document()->page()->pointerLockController()->elementRemoved(this); |
| 1301 | 1309 |
| 1302 setSavedLayerScrollOffset(IntSize()); | 1310 setSavedLayerScrollOffset(IntSize()); |
| 1303 | 1311 |
| 1304 if (insertionPoint->isInTreeScope() && treeScope() == document()) { | 1312 if (insertionPoint->isInTreeScope() && treeScope() == document()) { |
| 1305 const AtomicString& idValue = getIdAttribute(); | 1313 const AtomicString& idValue = getIdAttribute(); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1343 // When a shadow root exists, it does the work of attaching the children. | 1351 // When a shadow root exists, it does the work of attaching the children. |
| 1344 if (ElementShadow* shadow = this->shadow()) { | 1352 if (ElementShadow* shadow = this->shadow()) { |
| 1345 parentPusher.push(); | 1353 parentPusher.push(); |
| 1346 shadow->attach(context); | 1354 shadow->attach(context); |
| 1347 } else if (firstChild()) | 1355 } else if (firstChild()) |
| 1348 parentPusher.push(); | 1356 parentPusher.push(); |
| 1349 | 1357 |
| 1350 ContainerNode::attach(context); | 1358 ContainerNode::attach(context); |
| 1351 | 1359 |
| 1352 createPseudoElementIfNeeded(AFTER); | 1360 createPseudoElementIfNeeded(AFTER); |
| 1361 createPseudoElementIfNeeded(BACKDROP); | |
| 1353 | 1362 |
| 1354 if (hasRareData()) { | 1363 if (hasRareData()) { |
| 1355 ElementRareData* data = elementRareData(); | 1364 ElementRareData* data = elementRareData(); |
| 1356 if (data->needsFocusAppearanceUpdateSoonAfterAttach()) { | 1365 if (data->needsFocusAppearanceUpdateSoonAfterAttach()) { |
| 1357 if (isFocusable() && document()->focusedNode() == this) | 1366 if (isFocusable() && document()->focusedNode() == this) |
| 1358 document()->updateFocusAppearanceSoon(false /* don't restore sel ection */); | 1367 document()->updateFocusAppearanceSoon(false /* don't restore sel ection */); |
| 1359 data->setNeedsFocusAppearanceUpdateSoonAfterAttach(false); | 1368 data->setNeedsFocusAppearanceUpdateSoonAfterAttach(false); |
| 1360 } | 1369 } |
| 1361 } | 1370 } |
| 1362 | 1371 |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 1375 | 1384 |
| 1376 void Element::detach(const AttachContext& context) | 1385 void Element::detach(const AttachContext& context) |
| 1377 { | 1386 { |
| 1378 WidgetHierarchyUpdatesSuspensionScope suspendWidgetHierarchyUpdates; | 1387 WidgetHierarchyUpdatesSuspensionScope suspendWidgetHierarchyUpdates; |
| 1379 unregisterNamedFlowContentNode(); | 1388 unregisterNamedFlowContentNode(); |
| 1380 cancelFocusAppearanceUpdate(); | 1389 cancelFocusAppearanceUpdate(); |
| 1381 if (hasRareData()) { | 1390 if (hasRareData()) { |
| 1382 ElementRareData* data = elementRareData(); | 1391 ElementRareData* data = elementRareData(); |
| 1383 data->setPseudoElement(BEFORE, 0); | 1392 data->setPseudoElement(BEFORE, 0); |
| 1384 data->setPseudoElement(AFTER, 0); | 1393 data->setPseudoElement(AFTER, 0); |
| 1394 | |
| 1395 if (Element* backdrop = data->pseudoElement(BACKDROP)) | |
| 1396 document()->removeFromTopLayer(backdrop); | |
|
esprehn
2013/07/04 08:34:07
Yeah lets do this in releasePseudoElement, then yo
falken
2013/07/04 12:18:01
Done.
| |
| 1397 data->setPseudoElement(BACKDROP, 0); | |
| 1398 | |
| 1385 data->setIsInCanvasSubtree(false); | 1399 data->setIsInCanvasSubtree(false); |
| 1386 data->resetComputedStyle(); | 1400 data->resetComputedStyle(); |
| 1387 data->resetDynamicRestyleObservations(); | 1401 data->resetDynamicRestyleObservations(); |
| 1388 data->setIsInsideRegion(false); | 1402 data->setIsInsideRegion(false); |
| 1389 } | 1403 } |
| 1390 if (ElementShadow* shadow = this->shadow()) | 1404 if (ElementShadow* shadow = this->shadow()) |
| 1391 shadow->detach(context); | 1405 shadow->detach(context); |
| 1392 ContainerNode::detach(context); | 1406 ContainerNode::detach(context); |
| 1393 } | 1407 } |
| 1394 | 1408 |
| (...skipping 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2408 PseudoElement* element = pseudoElement(pseudoId); | 2422 PseudoElement* element = pseudoElement(pseudoId); |
| 2409 if (element && (needsStyleRecalc() || shouldRecalcStyle(change, element))) { | 2423 if (element && (needsStyleRecalc() || shouldRecalcStyle(change, element))) { |
| 2410 // PseudoElement styles hang off their parent element's style so if we n eeded | 2424 // PseudoElement styles hang off their parent element's style so if we n eeded |
| 2411 // a style recalc we should Force one on the pseudo. | 2425 // a style recalc we should Force one on the pseudo. |
| 2412 element->recalcStyle(needsStyleRecalc() ? Force : change); | 2426 element->recalcStyle(needsStyleRecalc() ? Force : change); |
| 2413 | 2427 |
| 2414 // Wait until our parent is not displayed or pseudoElementRendererIsNeed ed | 2428 // Wait until our parent is not displayed or pseudoElementRendererIsNeed ed |
| 2415 // is false, otherwise we could continously create and destroy PseudoEle ments | 2429 // is false, otherwise we could continously create and destroy PseudoEle ments |
| 2416 // when RenderObject::isChildAllowed on our parent returns false for the | 2430 // when RenderObject::isChildAllowed on our parent returns false for the |
| 2417 // PseudoElement's renderer for each style recalc. | 2431 // PseudoElement's renderer for each style recalc. |
| 2418 if (!renderer() || !pseudoElementRendererIsNeeded(renderer()->getCachedP seudoStyle(pseudoId))) | 2432 if (!renderer() || !pseudoElementRendererIsNeeded(renderer()->getCachedP seudoStyle(pseudoId))) { |
| 2433 if (pseudoId == BACKDROP) | |
| 2434 document()->removeFromTopLayer(element); | |
|
esprehn
2013/07/04 08:34:07
Remove.
falken
2013/07/04 12:18:01
Done.
| |
| 2419 elementRareData()->setPseudoElement(pseudoId, 0); | 2435 elementRareData()->setPseudoElement(pseudoId, 0); |
| 2436 } | |
| 2420 } else if (change >= Inherit || needsStyleRecalc()) | 2437 } else if (change >= Inherit || needsStyleRecalc()) |
| 2421 createPseudoElementIfNeeded(pseudoId); | 2438 createPseudoElementIfNeeded(pseudoId); |
| 2422 } | 2439 } |
| 2423 | 2440 |
| 2424 void Element::createPseudoElementIfNeeded(PseudoId pseudoId) | 2441 void Element::createPseudoElementIfNeeded(PseudoId pseudoId) |
| 2425 { | 2442 { |
| 2426 if (!document()->styleSheetCollection()->usesBeforeAfterRules()) | 2443 if ((pseudoId == BEFORE || pseudoId == AFTER) && !document()->styleSheetColl ection()->usesBeforeAfterRules()) |
| 2444 return; | |
| 2445 | |
| 2446 if (pseudoId == BACKDROP && !isInTopLayer()) | |
| 2427 return; | 2447 return; |
| 2428 | 2448 |
| 2429 if (!renderer() || !pseudoElementRendererIsNeeded(renderer()->getCachedPseud oStyle(pseudoId))) | 2449 if (!renderer() || !pseudoElementRendererIsNeeded(renderer()->getCachedPseud oStyle(pseudoId))) |
| 2430 return; | 2450 return; |
| 2431 | 2451 |
| 2432 if (!renderer()->canHaveGeneratedChildren()) | 2452 if (!renderer()->canHaveGeneratedChildren()) |
| 2433 return; | 2453 return; |
| 2434 | 2454 |
| 2435 ASSERT(!isPseudoElement()); | 2455 ASSERT(!isPseudoElement()); |
| 2436 RefPtr<PseudoElement> element = PseudoElement::create(this, pseudoId); | 2456 RefPtr<PseudoElement> element = PseudoElement::create(this, pseudoId); |
| 2437 element->attach(); | 2457 element->attach(); |
| 2438 ensureElementRareData()->setPseudoElement(pseudoId, element.release()); | 2458 ensureElementRareData()->setPseudoElement(pseudoId, element.release()); |
| 2459 | |
| 2460 if (pseudoId == BACKDROP) | |
| 2461 document()->addToTopLayer(pseudoElement(BACKDROP), this); | |
| 2439 } | 2462 } |
| 2440 | 2463 |
| 2441 PseudoElement* Element::pseudoElement(PseudoId pseudoId) const | 2464 PseudoElement* Element::pseudoElement(PseudoId pseudoId) const |
| 2442 { | 2465 { |
| 2443 return hasRareData() ? elementRareData()->pseudoElement(pseudoId) : 0; | 2466 return hasRareData() ? elementRareData()->pseudoElement(pseudoId) : 0; |
| 2444 } | 2467 } |
| 2445 | 2468 |
| 2446 RenderObject* Element::pseudoElementRenderer(PseudoId pseudoId) const | 2469 RenderObject* Element::pseudoElementRenderer(PseudoId pseudoId) const |
| 2447 { | 2470 { |
| 2448 if (PseudoElement* element = pseudoElement(pseudoId)) | 2471 if (PseudoElement* element = pseudoElement(pseudoId)) |
| (...skipping 1149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3598 return 0; | 3621 return 0; |
| 3599 } | 3622 } |
| 3600 | 3623 |
| 3601 Attribute* UniqueElementData::attributeItem(unsigned index) | 3624 Attribute* UniqueElementData::attributeItem(unsigned index) |
| 3602 { | 3625 { |
| 3603 ASSERT_WITH_SECURITY_IMPLICATION(index < length()); | 3626 ASSERT_WITH_SECURITY_IMPLICATION(index < length()); |
| 3604 return &m_attributeVector.at(index); | 3627 return &m_attributeVector.at(index); |
| 3605 } | 3628 } |
| 3606 | 3629 |
| 3607 } // namespace WebCore | 3630 } // namespace WebCore |
| OLD | NEW |