Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Side by Side Diff: Source/core/dom/Element.cpp

Issue 159863002: Remove CSS regions support, keeping a bare minimum to support "region-based" multicol. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 #include "core/html/HTMLLabelElement.h" 84 #include "core/html/HTMLLabelElement.h"
85 #include "core/html/HTMLOptionsCollection.h" 85 #include "core/html/HTMLOptionsCollection.h"
86 #include "core/html/HTMLTableRowsCollection.h" 86 #include "core/html/HTMLTableRowsCollection.h"
87 #include "core/html/HTMLTemplateElement.h" 87 #include "core/html/HTMLTemplateElement.h"
88 #include "core/html/parser/HTMLParserIdioms.h" 88 #include "core/html/parser/HTMLParserIdioms.h"
89 #include "core/inspector/InspectorInstrumentation.h" 89 #include "core/inspector/InspectorInstrumentation.h"
90 #include "core/page/FocusController.h" 90 #include "core/page/FocusController.h"
91 #include "core/page/Page.h" 91 #include "core/page/Page.h"
92 #include "core/page/PointerLockController.h" 92 #include "core/page/PointerLockController.h"
93 #include "core/rendering/FlowThreadController.h" 93 #include "core/rendering/FlowThreadController.h"
94 #include "core/rendering/RenderNamedFlowFragment.h"
95 #include "core/rendering/RenderView.h" 94 #include "core/rendering/RenderView.h"
96 #include "core/rendering/RenderWidget.h" 95 #include "core/rendering/RenderWidget.h"
97 #include "core/svg/SVGDocumentExtensions.h" 96 #include "core/svg/SVGDocumentExtensions.h"
98 #include "core/svg/SVGElement.h" 97 #include "core/svg/SVGElement.h"
99 #include "platform/scroll/ScrollableArea.h" 98 #include "platform/scroll/ScrollableArea.h"
100 #include "wtf/BitVector.h" 99 #include "wtf/BitVector.h"
101 #include "wtf/HashFunctions.h" 100 #include "wtf/HashFunctions.h"
102 #include "wtf/text/CString.h" 101 #include "wtf/text/CString.h"
103 #include "wtf/text/StringBuilder.h" 102 #include "wtf/text/StringBuilder.h"
104 #include "wtf/text/TextPosition.h" 103 #include "wtf/text/TextPosition.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 return 0; 188 return 0;
190 } 189 }
191 190
192 PassRefPtr<Element> Element::create(const QualifiedName& tagName, Document* docu ment) 191 PassRefPtr<Element> Element::create(const QualifiedName& tagName, Document* docu ment)
193 { 192 {
194 return adoptRef(new Element(tagName, document, CreateElement)); 193 return adoptRef(new Element(tagName, document, CreateElement));
195 } 194 }
196 195
197 Element::~Element() 196 Element::~Element()
198 { 197 {
199 // When the document is not destroyed, an element that was part of a named f low
200 // content nodes should have been removed from the content nodes collection
201 // and the inNamedFlow flag reset.
202 ASSERT(!document().renderView() || !inNamedFlow());
203 ASSERT(needsAttach()); 198 ASSERT(needsAttach());
204 199
205 if (hasRareData()) 200 if (hasRareData())
206 elementRareData()->clearShadow(); 201 elementRareData()->clearShadow();
207 202
208 if (isCustomElement()) 203 if (isCustomElement())
209 CustomElement::wasDestroyed(this); 204 CustomElement::wasDestroyed(this);
210 205
211 if (hasSyntheticAttrChildNodes()) 206 if (hasSyntheticAttrChildNodes())
212 detachAllAttrNodesFromElement(); 207 detachAllAttrNodesFromElement();
(...skipping 1222 matching lines...) Expand 10 before | Expand all | Expand 10 after
1435 if (ActiveAnimations* activeAnimations = data->activeAnimations()) { 1430 if (ActiveAnimations* activeAnimations = data->activeAnimations()) {
1436 activeAnimations->cssAnimations().cancel(); 1431 activeAnimations->cssAnimations().cancel();
1437 activeAnimations->setAnimationStyleChange(false); 1432 activeAnimations->setAnimationStyleChange(false);
1438 } 1433 }
1439 } 1434 }
1440 } 1435 }
1441 1436
1442 InspectorInstrumentation::didRecalculateStyleForElement(this); 1437 InspectorInstrumentation::didRecalculateStyleForElement(this);
1443 } 1438 }
1444 1439
1445 void Element::unregisterNamedFlowContentNode()
1446 {
1447 if (RuntimeEnabledFeatures::cssRegionsEnabled() && inNamedFlow() && document ().renderView())
1448 document().renderView()->flowThreadController()->unregisterNamedFlowCont entNode(this);
1449 }
1450
1451 void Element::detach(const AttachContext& context) 1440 void Element::detach(const AttachContext& context)
1452 { 1441 {
1453 RenderWidget::UpdateSuspendScope suspendWidgetHierarchyUpdates; 1442 RenderWidget::UpdateSuspendScope suspendWidgetHierarchyUpdates;
1454 unregisterNamedFlowContentNode();
1455 cancelFocusAppearanceUpdate(); 1443 cancelFocusAppearanceUpdate();
1456 removeCallbackSelectors(); 1444 removeCallbackSelectors();
1457 if (hasRareData()) { 1445 if (hasRareData()) {
1458 ElementRareData* data = elementRareData(); 1446 ElementRareData* data = elementRareData();
1459 data->clearPseudoElements(); 1447 data->clearPseudoElements();
1460 data->setIsInsideRegion(false);
1461 1448
1462 // attach() will perform the below steps for us when inside recalcStyle. 1449 // attach() will perform the below steps for us when inside recalcStyle.
1463 if (!document().inStyleRecalc()) { 1450 if (!document().inStyleRecalc()) {
1464 data->resetStyleState(); 1451 data->resetStyleState();
1465 data->clearComputedStyle(); 1452 data->clearComputedStyle();
1466 data->resetDynamicRestyleObservations(); 1453 data->resetDynamicRestyleObservations();
1467 } 1454 }
1468 1455
1469 if (RuntimeEnabledFeatures::webAnimationsCSSEnabled()) { 1456 if (RuntimeEnabledFeatures::webAnimationsCSSEnabled()) {
1470 if (ActiveAnimations* activeAnimations = data->activeAnimations()) { 1457 if (ActiveAnimations* activeAnimations = data->activeAnimations()) {
(...skipping 1212 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
3625 // Before doing so, we need to resolve issues in HTMLSelectElement::recalcLi stItems 3532 // Before doing so, we need to resolve issues in HTMLSelectElement::recalcLi stItems
3626 // and RenderMenuList::setText. See also https://bugs.webkit.org/show_bug.cg i?id=88405 3533 // and RenderMenuList::setText. See also https://bugs.webkit.org/show_bug.cg i?id=88405
3627 if (hasTagName(optionTag) || hasTagName(optgroupTag)) 3534 if (hasTagName(optionTag) || hasTagName(optgroupTag))
3628 return false; 3535 return false;
3629 if (FullscreenElementStack::isActiveFullScreenElement(this)) 3536 if (FullscreenElementStack::isActiveFullScreenElement(this))
3630 return false; 3537 return false;
3631 return true; 3538 return true;
3632 } 3539 }
3633 3540
3634 } // namespace WebCore 3541 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698