| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 #include "core/html/HTMLLabelElement.h" | 83 #include "core/html/HTMLLabelElement.h" |
| 84 #include "core/html/HTMLOptionsCollection.h" | 84 #include "core/html/HTMLOptionsCollection.h" |
| 85 #include "core/html/HTMLTableRowsCollection.h" | 85 #include "core/html/HTMLTableRowsCollection.h" |
| 86 #include "core/html/HTMLTemplateElement.h" | 86 #include "core/html/HTMLTemplateElement.h" |
| 87 #include "core/html/parser/HTMLParserIdioms.h" | 87 #include "core/html/parser/HTMLParserIdioms.h" |
| 88 #include "core/inspector/InspectorInstrumentation.h" | 88 #include "core/inspector/InspectorInstrumentation.h" |
| 89 #include "core/page/FocusController.h" | 89 #include "core/page/FocusController.h" |
| 90 #include "core/page/Page.h" | 90 #include "core/page/Page.h" |
| 91 #include "core/page/PointerLockController.h" | 91 #include "core/page/PointerLockController.h" |
| 92 #include "core/rendering/FlowThreadController.h" | 92 #include "core/rendering/FlowThreadController.h" |
| 93 #include "core/rendering/RenderNamedFlowFragment.h" | |
| 94 #include "core/rendering/RenderView.h" | 93 #include "core/rendering/RenderView.h" |
| 95 #include "core/rendering/RenderWidget.h" | 94 #include "core/rendering/RenderWidget.h" |
| 96 #include "core/svg/SVGDocumentExtensions.h" | 95 #include "core/svg/SVGDocumentExtensions.h" |
| 97 #include "core/svg/SVGElement.h" | 96 #include "core/svg/SVGElement.h" |
| 98 #include "wtf/BitVector.h" | 97 #include "wtf/BitVector.h" |
| 99 #include "wtf/HashFunctions.h" | 98 #include "wtf/HashFunctions.h" |
| 100 #include "wtf/text/CString.h" | 99 #include "wtf/text/CString.h" |
| 101 #include "wtf/text/StringBuilder.h" | 100 #include "wtf/text/StringBuilder.h" |
| 102 #include "wtf/text/TextPosition.h" | 101 #include "wtf/text/TextPosition.h" |
| 103 | 102 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 return 0; | 186 return 0; |
| 188 } | 187 } |
| 189 | 188 |
| 190 PassRefPtr<Element> Element::create(const QualifiedName& tagName, Document* docu
ment) | 189 PassRefPtr<Element> Element::create(const QualifiedName& tagName, Document* docu
ment) |
| 191 { | 190 { |
| 192 return adoptRef(new Element(tagName, document, CreateElement)); | 191 return adoptRef(new Element(tagName, document, CreateElement)); |
| 193 } | 192 } |
| 194 | 193 |
| 195 Element::~Element() | 194 Element::~Element() |
| 196 { | 195 { |
| 197 // When the document is not destroyed, an element that was part of a named f
low | |
| 198 // content nodes should have been removed from the content nodes collection | |
| 199 // and the inNamedFlow flag reset. | |
| 200 ASSERT(!document().renderView() || !inNamedFlow()); | |
| 201 ASSERT(needsAttach()); | 196 ASSERT(needsAttach()); |
| 202 | 197 |
| 203 if (hasRareData()) | 198 if (hasRareData()) |
| 204 elementRareData()->clearShadow(); | 199 elementRareData()->clearShadow(); |
| 205 | 200 |
| 206 if (isCustomElement()) | 201 if (isCustomElement()) |
| 207 CustomElement::wasDestroyed(this); | 202 CustomElement::wasDestroyed(this); |
| 208 | 203 |
| 209 if (hasSyntheticAttrChildNodes()) | 204 if (hasSyntheticAttrChildNodes()) |
| 210 detachAllAttrNodesFromElement(); | 205 detachAllAttrNodesFromElement(); |
| (...skipping 1237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1448 if (ActiveAnimations* activeAnimations = data->activeAnimations()) { | 1443 if (ActiveAnimations* activeAnimations = data->activeAnimations()) { |
| 1449 activeAnimations->cssAnimations().cancel(); | 1444 activeAnimations->cssAnimations().cancel(); |
| 1450 activeAnimations->setAnimationStyleChange(false); | 1445 activeAnimations->setAnimationStyleChange(false); |
| 1451 } | 1446 } |
| 1452 } | 1447 } |
| 1453 } | 1448 } |
| 1454 | 1449 |
| 1455 InspectorInstrumentation::didRecalculateStyleForElement(this); | 1450 InspectorInstrumentation::didRecalculateStyleForElement(this); |
| 1456 } | 1451 } |
| 1457 | 1452 |
| 1458 void Element::unregisterNamedFlowContentNode() | |
| 1459 { | |
| 1460 if (RuntimeEnabledFeatures::cssRegionsEnabled() && inNamedFlow() && document
().renderView()) | |
| 1461 document().renderView()->flowThreadController()->unregisterNamedFlowCont
entNode(this); | |
| 1462 } | |
| 1463 | |
| 1464 void Element::detach(const AttachContext& context) | 1453 void Element::detach(const AttachContext& context) |
| 1465 { | 1454 { |
| 1466 RenderWidget::UpdateSuspendScope suspendWidgetHierarchyUpdates; | 1455 RenderWidget::UpdateSuspendScope suspendWidgetHierarchyUpdates; |
| 1467 unregisterNamedFlowContentNode(); | |
| 1468 cancelFocusAppearanceUpdate(); | 1456 cancelFocusAppearanceUpdate(); |
| 1469 removeCallbackSelectors(); | 1457 removeCallbackSelectors(); |
| 1470 if (hasRareData()) { | 1458 if (hasRareData()) { |
| 1471 ElementRareData* data = elementRareData(); | 1459 ElementRareData* data = elementRareData(); |
| 1472 data->clearPseudoElements(); | 1460 data->clearPseudoElements(); |
| 1473 data->setIsInsideRegion(false); | |
| 1474 | 1461 |
| 1475 // attach() will perform the below steps for us when inside recalcStyle. | 1462 // attach() will perform the below steps for us when inside recalcStyle. |
| 1476 if (!document().inStyleRecalc()) { | 1463 if (!document().inStyleRecalc()) { |
| 1477 data->resetStyleState(); | 1464 data->resetStyleState(); |
| 1478 data->clearComputedStyle(); | 1465 data->clearComputedStyle(); |
| 1479 data->resetDynamicRestyleObservations(); | 1466 data->resetDynamicRestyleObservations(); |
| 1480 } | 1467 } |
| 1481 | 1468 |
| 1482 if (RuntimeEnabledFeatures::webAnimationsCSSEnabled()) { | 1469 if (RuntimeEnabledFeatures::webAnimationsCSSEnabled()) { |
| 1483 if (ActiveAnimations* activeAnimations = data->activeAnimations()) { | 1470 if (ActiveAnimations* activeAnimations = data->activeAnimations()) { |
| (...skipping 1199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2683 void Element::setIsInCanvasSubtree(bool isInCanvasSubtree) | 2670 void Element::setIsInCanvasSubtree(bool isInCanvasSubtree) |
| 2684 { | 2671 { |
| 2685 ensureElementRareData().setIsInCanvasSubtree(isInCanvasSubtree); | 2672 ensureElementRareData().setIsInCanvasSubtree(isInCanvasSubtree); |
| 2686 } | 2673 } |
| 2687 | 2674 |
| 2688 bool Element::isInCanvasSubtree() const | 2675 bool Element::isInCanvasSubtree() const |
| 2689 { | 2676 { |
| 2690 return hasRareData() && elementRareData()->isInCanvasSubtree(); | 2677 return hasRareData() && elementRareData()->isInCanvasSubtree(); |
| 2691 } | 2678 } |
| 2692 | 2679 |
| 2693 void Element::setIsInsideRegion(bool value) | |
| 2694 { | |
| 2695 if (value == isInsideRegion()) | |
| 2696 return; | |
| 2697 | |
| 2698 ensureElementRareData().setIsInsideRegion(value); | |
| 2699 } | |
| 2700 | |
| 2701 bool Element::isInsideRegion() const | |
| 2702 { | |
| 2703 return hasRareData() ? elementRareData()->isInsideRegion() : false; | |
| 2704 } | |
| 2705 | |
| 2706 void Element::setRegionOversetState(RegionOversetState state) | |
| 2707 { | |
| 2708 ensureElementRareData().setRegionOversetState(state); | |
| 2709 } | |
| 2710 | |
| 2711 RegionOversetState Element::regionOversetState() const | |
| 2712 { | |
| 2713 return hasRareData() ? elementRareData()->regionOversetState() : RegionUndef
ined; | |
| 2714 } | |
| 2715 | |
| 2716 AtomicString Element::computeInheritedLanguage() const | 2680 AtomicString Element::computeInheritedLanguage() const |
| 2717 { | 2681 { |
| 2718 const Node* n = this; | 2682 const Node* n = this; |
| 2719 AtomicString value; | 2683 AtomicString value; |
| 2720 // The language property is inherited, so we iterate over the parents to fin
d the first language. | 2684 // The language property is inherited, so we iterate over the parents to fin
d the first language. |
| 2721 do { | 2685 do { |
| 2722 if (n->isElementNode()) { | 2686 if (n->isElementNode()) { |
| 2723 if (const ElementData* elementData = toElement(n)->elementData()) { | 2687 if (const ElementData* elementData = toElement(n)->elementData()) { |
| 2724 // Spec: xml:lang takes precedence -- http://www.w3.org/TR/xhtml
1/#C_7 | 2688 // Spec: xml:lang takes precedence -- http://www.w3.org/TR/xhtml
1/#C_7 |
| 2725 if (const Attribute* attribute = elementData->getAttributeItem(X
MLNames::langAttr)) | 2689 if (const Attribute* attribute = elementData->getAttributeItem(X
MLNames::langAttr)) |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2981 case SpellcheckAttributeFalse: | 2945 case SpellcheckAttributeFalse: |
| 2982 return false; | 2946 return false; |
| 2983 case SpellcheckAttributeDefault: | 2947 case SpellcheckAttributeDefault: |
| 2984 break; | 2948 break; |
| 2985 } | 2949 } |
| 2986 } | 2950 } |
| 2987 | 2951 |
| 2988 return true; | 2952 return true; |
| 2989 } | 2953 } |
| 2990 | 2954 |
| 2991 RenderRegion* Element::renderRegion() const | |
| 2992 { | |
| 2993 if (renderer() && renderer()->isRenderNamedFlowFragmentContainer()) | |
| 2994 return toRenderBlockFlow(renderer())->renderNamedFlowFragment(); | |
| 2995 | |
| 2996 return 0; | |
| 2997 } | |
| 2998 | |
| 2999 const AtomicString& Element::webkitRegionOverset() const | |
| 3000 { | |
| 3001 DEFINE_STATIC_LOCAL(AtomicString, undefinedState, ("undefined", AtomicString
::ConstructFromLiteral)); | |
| 3002 if (!RuntimeEnabledFeatures::cssRegionsEnabled()) | |
| 3003 return undefinedState; | |
| 3004 | |
| 3005 document().updateLayoutIgnorePendingStylesheets(); | |
| 3006 | |
| 3007 if (!renderRegion()) | |
| 3008 return undefinedState; | |
| 3009 | |
| 3010 switch (renderRegion()->regionOversetState()) { | |
| 3011 case RegionFit: { | |
| 3012 DEFINE_STATIC_LOCAL(AtomicString, fitState, ("fit", AtomicString::Constr
uctFromLiteral)); | |
| 3013 return fitState; | |
| 3014 } | |
| 3015 case RegionEmpty: { | |
| 3016 DEFINE_STATIC_LOCAL(AtomicString, emptyState, ("empty", AtomicString::Co
nstructFromLiteral)); | |
| 3017 return emptyState; | |
| 3018 } | |
| 3019 case RegionOverset: { | |
| 3020 DEFINE_STATIC_LOCAL(AtomicString, overflowState, ("overset", AtomicStrin
g::ConstructFromLiteral)); | |
| 3021 return overflowState; | |
| 3022 } | |
| 3023 case RegionUndefined: | |
| 3024 return undefinedState; | |
| 3025 } | |
| 3026 | |
| 3027 ASSERT_NOT_REACHED(); | |
| 3028 return undefinedState; | |
| 3029 } | |
| 3030 | |
| 3031 Vector<RefPtr<Range> > Element::webkitGetRegionFlowRanges() const | |
| 3032 { | |
| 3033 Vector<RefPtr<Range> > rangeObjects; | |
| 3034 if (!RuntimeEnabledFeatures::cssRegionsEnabled()) | |
| 3035 return rangeObjects; | |
| 3036 | |
| 3037 document().updateLayoutIgnorePendingStylesheets(); | |
| 3038 | |
| 3039 if (renderer() && renderer()->isRenderNamedFlowFragmentContainer()) { | |
| 3040 RenderNamedFlowFragment* region = toRenderBlockFlow(renderer())->renderN
amedFlowFragment(); | |
| 3041 if (region->isValid()) | |
| 3042 region->getRanges(rangeObjects); | |
| 3043 } | |
| 3044 | |
| 3045 return rangeObjects; | |
| 3046 } | |
| 3047 | |
| 3048 #ifndef NDEBUG | 2955 #ifndef NDEBUG |
| 3049 bool Element::fastAttributeLookupAllowed(const QualifiedName& name) const | 2956 bool Element::fastAttributeLookupAllowed(const QualifiedName& name) const |
| 3050 { | 2957 { |
| 3051 if (name == HTMLNames::styleAttr) | 2958 if (name == HTMLNames::styleAttr) |
| 3052 return false; | 2959 return false; |
| 3053 | 2960 |
| 3054 if (isSVGElement()) | 2961 if (isSVGElement()) |
| 3055 return !toSVGElement(this)->isAnimatableAttribute(name); | 2962 return !toSVGElement(this)->isAnimatableAttribute(name); |
| 3056 | 2963 |
| 3057 return true; | 2964 return true; |
| (...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3626 // Before doing so, we need to resolve issues in HTMLSelectElement::recalcLi
stItems | 3533 // Before doing so, we need to resolve issues in HTMLSelectElement::recalcLi
stItems |
| 3627 // and RenderMenuList::setText. See also https://bugs.webkit.org/show_bug.cg
i?id=88405 | 3534 // and RenderMenuList::setText. See also https://bugs.webkit.org/show_bug.cg
i?id=88405 |
| 3628 if (hasTagName(optionTag) || hasTagName(optgroupTag)) | 3535 if (hasTagName(optionTag) || hasTagName(optgroupTag)) |
| 3629 return false; | 3536 return false; |
| 3630 if (FullscreenElementStack::isActiveFullScreenElement(this)) | 3537 if (FullscreenElementStack::isActiveFullScreenElement(this)) |
| 3631 return false; | 3538 return false; |
| 3632 return true; | 3539 return true; |
| 3633 } | 3540 } |
| 3634 | 3541 |
| 3635 } // namespace WebCore | 3542 } // namespace WebCore |
| OLD | NEW |