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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 #include "wtf/text/CString.h" | 97 #include "wtf/text/CString.h" |
98 #include "wtf/text/TextPosition.h" | 98 #include "wtf/text/TextPosition.h" |
99 | 99 |
100 namespace WebCore { | 100 namespace WebCore { |
101 | 101 |
102 using namespace HTMLNames; | 102 using namespace HTMLNames; |
103 using namespace XMLNames; | 103 using namespace XMLNames; |
104 | 104 |
105 static inline bool shouldIgnoreAttributeCase(const Element* e) | 105 static inline bool shouldIgnoreAttributeCase(const Element* e) |
106 { | 106 { |
107 return e && e->document()->isHTMLDocument() && e->isHTMLElement(); | 107 return e && e->document().isHTMLDocument() && e->isHTMLElement(); |
108 } | 108 } |
109 | 109 |
110 class StyleResolverParentPusher { | 110 class StyleResolverParentPusher { |
111 public: | 111 public: |
112 StyleResolverParentPusher(Element* parent) | 112 StyleResolverParentPusher(Element* parent) |
113 : m_parent(parent) | 113 : m_parent(parent) |
114 , m_pushedStyleResolver(0) | 114 , m_pushedStyleResolver(0) |
115 { | 115 { |
116 } | 116 } |
117 void push() | 117 void push() |
118 { | 118 { |
119 if (m_pushedStyleResolver) | 119 if (m_pushedStyleResolver) |
120 return; | 120 return; |
121 m_pushedStyleResolver = m_parent->document()->styleResolver(); | 121 m_pushedStyleResolver = m_parent->document().styleResolver(); |
122 m_pushedStyleResolver->pushParentElement(m_parent); | 122 m_pushedStyleResolver->pushParentElement(m_parent); |
123 } | 123 } |
124 ~StyleResolverParentPusher() | 124 ~StyleResolverParentPusher() |
125 { | 125 { |
126 | 126 |
127 if (!m_pushedStyleResolver) | 127 if (!m_pushedStyleResolver) |
128 return; | 128 return; |
129 | 129 |
130 // This tells us that our pushed style selector is in a bad state, | 130 // This tells us that our pushed style selector is in a bad state, |
131 // so we should just bail out in that scenario. | 131 // so we should just bail out in that scenario. |
132 ASSERT(m_pushedStyleResolver == m_parent->document()->styleResolver()); | 132 ASSERT(m_pushedStyleResolver == m_parent->document().styleResolver()); |
133 if (m_pushedStyleResolver != m_parent->document()->styleResolver()) | 133 if (m_pushedStyleResolver != m_parent->document().styleResolver()) |
134 return; | 134 return; |
135 | 135 |
136 m_pushedStyleResolver->popParentElement(m_parent); | 136 m_pushedStyleResolver->popParentElement(m_parent); |
137 } | 137 } |
138 | 138 |
139 private: | 139 private: |
140 Element* m_parent; | 140 Element* m_parent; |
141 StyleResolver* m_pushedStyleResolver; | 141 StyleResolver* m_pushedStyleResolver; |
142 }; | 142 }; |
143 | 143 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 } | 188 } |
189 | 189 |
190 PassRefPtr<Element> Element::create(const QualifiedName& tagName, Document* docu
ment) | 190 PassRefPtr<Element> Element::create(const QualifiedName& tagName, Document* docu
ment) |
191 { | 191 { |
192 return adoptRef(new Element(tagName, document, CreateElement)); | 192 return adoptRef(new Element(tagName, document, CreateElement)); |
193 } | 193 } |
194 | 194 |
195 Element::~Element() | 195 Element::~Element() |
196 { | 196 { |
197 #ifndef NDEBUG | 197 #ifndef NDEBUG |
198 if (document()->renderer()) { | 198 if (document().renderer()) { |
199 // When the document is not destroyed, an element that was part of a nam
ed flow | 199 // When the document is not destroyed, an element that was part of a nam
ed flow |
200 // content nodes should have been removed from the content nodes collect
ion | 200 // content nodes should have been removed from the content nodes collect
ion |
201 // and the inNamedFlow flag reset. | 201 // and the inNamedFlow flag reset. |
202 ASSERT(!inNamedFlow()); | 202 ASSERT(!inNamedFlow()); |
203 } | 203 } |
204 #endif | 204 #endif |
205 | 205 |
206 if (PropertySetCSSStyleDeclaration* cssomWrapper = inlineStyleCSSOMWrapper()
) | 206 if (PropertySetCSSStyleDeclaration* cssomWrapper = inlineStyleCSSOMWrapper()
) |
207 cssomWrapper->clearParentElement(); | 207 cssomWrapper->clearParentElement(); |
208 | 208 |
(...skipping 10 matching lines...) Expand all Loading... |
219 } | 219 } |
220 } | 220 } |
221 | 221 |
222 if (isCustomElement()) | 222 if (isCustomElement()) |
223 CustomElement::wasDestroyed(this); | 223 CustomElement::wasDestroyed(this); |
224 | 224 |
225 if (hasSyntheticAttrChildNodes()) | 225 if (hasSyntheticAttrChildNodes()) |
226 detachAllAttrNodesFromElement(); | 226 detachAllAttrNodesFromElement(); |
227 | 227 |
228 if (hasPendingResources()) { | 228 if (hasPendingResources()) { |
229 document()->accessSVGExtensions()->removeElementFromPendingResources(thi
s); | 229 document().accessSVGExtensions()->removeElementFromPendingResources(this
); |
230 ASSERT(!hasPendingResources()); | 230 ASSERT(!hasPendingResources()); |
231 } | 231 } |
232 } | 232 } |
233 | 233 |
234 inline ElementRareData* Element::elementRareData() const | 234 inline ElementRareData* Element::elementRareData() const |
235 { | 235 { |
236 ASSERT(hasRareData()); | 236 ASSERT(hasRareData()); |
237 return static_cast<ElementRareData*>(rareData()); | 237 return static_cast<ElementRareData*>(rareData()); |
238 } | 238 } |
239 | 239 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 | 277 |
278 // FIXME: These asserts should be in Node::isFocusable, but there are some | 278 // FIXME: These asserts should be in Node::isFocusable, but there are some |
279 // callsites like Document::setFocusedElement that would currently fail on | 279 // callsites like Document::setFocusedElement that would currently fail on |
280 // them. See crbug.com/251163 | 280 // them. See crbug.com/251163 |
281 if (renderer()) { | 281 if (renderer()) { |
282 ASSERT(!renderer()->needsLayout()); | 282 ASSERT(!renderer()->needsLayout()); |
283 } else { | 283 } else { |
284 // We can't just use needsStyleRecalc() because if the node is in a | 284 // We can't just use needsStyleRecalc() because if the node is in a |
285 // display:none tree it might say it needs style recalc but the whole | 285 // display:none tree it might say it needs style recalc but the whole |
286 // document is actually up to date. | 286 // document is actually up to date. |
287 ASSERT(!document()->childNeedsStyleRecalc()); | 287 ASSERT(!document().childNeedsStyleRecalc()); |
288 } | 288 } |
289 | 289 |
290 // FIXME: Even if we are not visible, we might have a child that is visible. | 290 // FIXME: Even if we are not visible, we might have a child that is visible. |
291 // Hyatt wants to fix that some day with a "has visible content" flag or the
like. | 291 // Hyatt wants to fix that some day with a "has visible content" flag or the
like. |
292 if (!renderer() || renderer()->style()->visibility() != VISIBLE) | 292 if (!renderer() || renderer()->style()->visibility() != VISIBLE) |
293 return false; | 293 return false; |
294 | 294 |
295 return true; | 295 return true; |
296 } | 296 } |
297 | 297 |
(...skipping 20 matching lines...) Expand all Loading... |
318 // This will catch HTML elements in the wrong namespace that are not correct
ly copied. | 318 // This will catch HTML elements in the wrong namespace that are not correct
ly copied. |
319 // This is a sanity check as HTML overloads some of the DOM methods. | 319 // This is a sanity check as HTML overloads some of the DOM methods. |
320 ASSERT(isHTMLElement() == clone->isHTMLElement()); | 320 ASSERT(isHTMLElement() == clone->isHTMLElement()); |
321 | 321 |
322 clone->cloneDataFromElement(*this); | 322 clone->cloneDataFromElement(*this); |
323 return clone.release(); | 323 return clone.release(); |
324 } | 324 } |
325 | 325 |
326 PassRefPtr<Element> Element::cloneElementWithoutAttributesAndChildren() | 326 PassRefPtr<Element> Element::cloneElementWithoutAttributesAndChildren() |
327 { | 327 { |
328 return document()->createElement(tagQName(), false); | 328 return document().createElement(tagQName(), false); |
329 } | 329 } |
330 | 330 |
331 PassRefPtr<Attr> Element::detachAttribute(size_t index) | 331 PassRefPtr<Attr> Element::detachAttribute(size_t index) |
332 { | 332 { |
333 ASSERT(elementData()); | 333 ASSERT(elementData()); |
334 const Attribute* attribute = elementData()->attributeItem(index); | 334 const Attribute* attribute = elementData()->attributeItem(index); |
335 RefPtr<Attr> attrNode = attrIfExists(attribute->name()); | 335 RefPtr<Attr> attrNode = attrIfExists(attribute->name()); |
336 if (attrNode) | 336 if (attrNode) |
337 detachAttrNodeAtIndex(attrNode.get(), index); | 337 detachAttrNodeAtIndex(attrNode.get(), index); |
338 else { | 338 else { |
339 attrNode = Attr::create(document(), attribute->name(), attribute->value(
)); | 339 attrNode = Attr::create(&document(), attribute->name(), attribute->value
()); |
340 removeAttributeInternal(index, NotInSynchronizationOfLazyAttribute); | 340 removeAttributeInternal(index, NotInSynchronizationOfLazyAttribute); |
341 } | 341 } |
342 return attrNode.release(); | 342 return attrNode.release(); |
343 } | 343 } |
344 | 344 |
345 void Element::detachAttrNodeAtIndex(Attr* attr, size_t index) | 345 void Element::detachAttrNodeAtIndex(Attr* attr, size_t index) |
346 { | 346 { |
347 ASSERT(attr); | 347 ASSERT(attr); |
348 ASSERT(elementData()); | 348 ASSERT(elementData()); |
349 | 349 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 if (!elementData()) | 473 if (!elementData()) |
474 return nullAtom; | 474 return nullAtom; |
475 synchronizeAttribute(name); | 475 synchronizeAttribute(name); |
476 if (const Attribute* attribute = getAttributeItem(name)) | 476 if (const Attribute* attribute = getAttributeItem(name)) |
477 return attribute->value(); | 477 return attribute->value(); |
478 return nullAtom; | 478 return nullAtom; |
479 } | 479 } |
480 | 480 |
481 void Element::scrollIntoView(bool alignToTop) | 481 void Element::scrollIntoView(bool alignToTop) |
482 { | 482 { |
483 document()->updateLayoutIgnorePendingStylesheets(); | 483 document().updateLayoutIgnorePendingStylesheets(); |
484 | 484 |
485 if (!renderer()) | 485 if (!renderer()) |
486 return; | 486 return; |
487 | 487 |
488 LayoutRect bounds = boundingBox(); | 488 LayoutRect bounds = boundingBox(); |
489 // Align to the top / bottom and to the closest edge. | 489 // Align to the top / bottom and to the closest edge. |
490 if (alignToTop) | 490 if (alignToTop) |
491 renderer()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdgeIfNe
eded, ScrollAlignment::alignTopAlways); | 491 renderer()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdgeIfNe
eded, ScrollAlignment::alignTopAlways); |
492 else | 492 else |
493 renderer()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdgeIfNe
eded, ScrollAlignment::alignBottomAlways); | 493 renderer()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdgeIfNe
eded, ScrollAlignment::alignBottomAlways); |
494 } | 494 } |
495 | 495 |
496 void Element::scrollIntoViewIfNeeded(bool centerIfNeeded) | 496 void Element::scrollIntoViewIfNeeded(bool centerIfNeeded) |
497 { | 497 { |
498 document()->updateLayoutIgnorePendingStylesheets(); | 498 document().updateLayoutIgnorePendingStylesheets(); |
499 | 499 |
500 if (!renderer()) | 500 if (!renderer()) |
501 return; | 501 return; |
502 | 502 |
503 LayoutRect bounds = boundingBox(); | 503 LayoutRect bounds = boundingBox(); |
504 if (centerIfNeeded) | 504 if (centerIfNeeded) |
505 renderer()->scrollRectToVisible(bounds, ScrollAlignment::alignCenterIfNe
eded, ScrollAlignment::alignCenterIfNeeded); | 505 renderer()->scrollRectToVisible(bounds, ScrollAlignment::alignCenterIfNe
eded, ScrollAlignment::alignCenterIfNeeded); |
506 else | 506 else |
507 renderer()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdgeIfNe
eded, ScrollAlignment::alignToEdgeIfNeeded); | 507 renderer()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdgeIfNe
eded, ScrollAlignment::alignToEdgeIfNeeded); |
508 } | 508 } |
509 | 509 |
510 void Element::scrollByUnits(int units, ScrollGranularity granularity) | 510 void Element::scrollByUnits(int units, ScrollGranularity granularity) |
511 { | 511 { |
512 document()->updateLayoutIgnorePendingStylesheets(); | 512 document().updateLayoutIgnorePendingStylesheets(); |
513 | 513 |
514 if (!renderer()) | 514 if (!renderer()) |
515 return; | 515 return; |
516 | 516 |
517 if (!renderer()->hasOverflowClip()) | 517 if (!renderer()->hasOverflowClip()) |
518 return; | 518 return; |
519 | 519 |
520 ScrollDirection direction = ScrollDown; | 520 ScrollDirection direction = ScrollDown; |
521 if (units < 0) { | 521 if (units < 0) { |
522 direction = ScrollUp; | 522 direction = ScrollUp; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 static int adjustForLocalZoom(LayoutUnit value, RenderObject* renderer) | 562 static int adjustForLocalZoom(LayoutUnit value, RenderObject* renderer) |
563 { | 563 { |
564 float zoomFactor = localZoomForRenderer(renderer); | 564 float zoomFactor = localZoomForRenderer(renderer); |
565 if (zoomFactor == 1) | 565 if (zoomFactor == 1) |
566 return value; | 566 return value; |
567 return lroundf(value / zoomFactor); | 567 return lroundf(value / zoomFactor); |
568 } | 568 } |
569 | 569 |
570 int Element::offsetLeft() | 570 int Element::offsetLeft() |
571 { | 571 { |
572 document()->updateLayoutIgnorePendingStylesheets(); | 572 document().updateLayoutIgnorePendingStylesheets(); |
573 if (RenderBoxModelObject* renderer = renderBoxModelObject()) | 573 if (RenderBoxModelObject* renderer = renderBoxModelObject()) |
574 return adjustForLocalZoom(renderer->pixelSnappedOffsetLeft(), renderer); | 574 return adjustForLocalZoom(renderer->pixelSnappedOffsetLeft(), renderer); |
575 return 0; | 575 return 0; |
576 } | 576 } |
577 | 577 |
578 int Element::offsetTop() | 578 int Element::offsetTop() |
579 { | 579 { |
580 document()->updateLayoutIgnorePendingStylesheets(); | 580 document().updateLayoutIgnorePendingStylesheets(); |
581 if (RenderBoxModelObject* renderer = renderBoxModelObject()) | 581 if (RenderBoxModelObject* renderer = renderBoxModelObject()) |
582 return adjustForLocalZoom(renderer->pixelSnappedOffsetTop(), renderer); | 582 return adjustForLocalZoom(renderer->pixelSnappedOffsetTop(), renderer); |
583 return 0; | 583 return 0; |
584 } | 584 } |
585 | 585 |
586 int Element::offsetWidth() | 586 int Element::offsetWidth() |
587 { | 587 { |
588 document()->updateStyleForNodeIfNeeded(this); | 588 document().updateStyleForNodeIfNeeded(this); |
589 | 589 |
590 if (RenderBox* renderer = renderBox()) { | 590 if (RenderBox* renderer = renderBox()) { |
591 if (!renderer->requiresLayoutToDetermineWidth()) | 591 if (!renderer->requiresLayoutToDetermineWidth()) |
592 return adjustLayoutUnitForAbsoluteZoom(renderer->fixedOffsetWidth(),
renderer).round(); | 592 return adjustLayoutUnitForAbsoluteZoom(renderer->fixedOffsetWidth(),
renderer).round(); |
593 } | 593 } |
594 | 594 |
595 document()->updateLayoutIgnorePendingStylesheets(); | 595 document().updateLayoutIgnorePendingStylesheets(); |
596 if (RenderBoxModelObject* renderer = renderBoxModelObject()) | 596 if (RenderBoxModelObject* renderer = renderBoxModelObject()) |
597 return adjustLayoutUnitForAbsoluteZoom(renderer->pixelSnappedOffsetWidth
(), renderer).round(); | 597 return adjustLayoutUnitForAbsoluteZoom(renderer->pixelSnappedOffsetWidth
(), renderer).round(); |
598 return 0; | 598 return 0; |
599 } | 599 } |
600 | 600 |
601 int Element::offsetHeight() | 601 int Element::offsetHeight() |
602 { | 602 { |
603 document()->updateLayoutIgnorePendingStylesheets(); | 603 document().updateLayoutIgnorePendingStylesheets(); |
604 if (RenderBoxModelObject* renderer = renderBoxModelObject()) | 604 if (RenderBoxModelObject* renderer = renderBoxModelObject()) |
605 return adjustLayoutUnitForAbsoluteZoom(renderer->pixelSnappedOffsetHeigh
t(), renderer).round(); | 605 return adjustLayoutUnitForAbsoluteZoom(renderer->pixelSnappedOffsetHeigh
t(), renderer).round(); |
606 return 0; | 606 return 0; |
607 } | 607 } |
608 | 608 |
609 Element* Element::bindingsOffsetParent() | 609 Element* Element::bindingsOffsetParent() |
610 { | 610 { |
611 Element* element = offsetParent(); | 611 Element* element = offsetParent(); |
612 if (!element || !element->isInShadowTree()) | 612 if (!element || !element->isInShadowTree()) |
613 return element; | 613 return element; |
614 return element->containingShadowRoot()->shouldExposeToBindings() ? element :
0; | 614 return element->containingShadowRoot()->shouldExposeToBindings() ? element :
0; |
615 } | 615 } |
616 | 616 |
617 Element* Element::offsetParent() | 617 Element* Element::offsetParent() |
618 { | 618 { |
619 document()->updateLayoutIgnorePendingStylesheets(); | 619 document().updateLayoutIgnorePendingStylesheets(); |
620 if (RenderObject* renderer = this->renderer()) | 620 if (RenderObject* renderer = this->renderer()) |
621 return renderer->offsetParent(); | 621 return renderer->offsetParent(); |
622 return 0; | 622 return 0; |
623 } | 623 } |
624 | 624 |
625 int Element::clientLeft() | 625 int Element::clientLeft() |
626 { | 626 { |
627 document()->updateLayoutIgnorePendingStylesheets(); | 627 document().updateLayoutIgnorePendingStylesheets(); |
628 | 628 |
629 if (RenderBox* renderer = renderBox()) | 629 if (RenderBox* renderer = renderBox()) |
630 return adjustForAbsoluteZoom(roundToInt(renderer->clientLeft()), rendere
r); | 630 return adjustForAbsoluteZoom(roundToInt(renderer->clientLeft()), rendere
r); |
631 return 0; | 631 return 0; |
632 } | 632 } |
633 | 633 |
634 int Element::clientTop() | 634 int Element::clientTop() |
635 { | 635 { |
636 document()->updateLayoutIgnorePendingStylesheets(); | 636 document().updateLayoutIgnorePendingStylesheets(); |
637 | 637 |
638 if (RenderBox* renderer = renderBox()) | 638 if (RenderBox* renderer = renderBox()) |
639 return adjustForAbsoluteZoom(roundToInt(renderer->clientTop()), renderer
); | 639 return adjustForAbsoluteZoom(roundToInt(renderer->clientTop()), renderer
); |
640 return 0; | 640 return 0; |
641 } | 641 } |
642 | 642 |
643 int Element::clientWidth() | 643 int Element::clientWidth() |
644 { | 644 { |
645 document()->updateLayoutIgnorePendingStylesheets(); | 645 document().updateLayoutIgnorePendingStylesheets(); |
646 | 646 |
647 // When in strict mode, clientWidth for the document element should return t
he width of the containing frame. | 647 // When in strict mode, clientWidth for the document element should return t
he width of the containing frame. |
648 // When in quirks mode, clientWidth for the body element should return the w
idth of the containing frame. | 648 // When in quirks mode, clientWidth for the body element should return the w
idth of the containing frame. |
649 bool inQuirksMode = document()->inQuirksMode(); | 649 bool inQuirksMode = document().inQuirksMode(); |
650 if ((!inQuirksMode && document()->documentElement() == this) || | 650 if ((!inQuirksMode && document().documentElement() == this) |
651 (inQuirksMode && isHTMLElement() && document()->body() == this)) { | 651 || (inQuirksMode && isHTMLElement() && document().body() == this)) { |
652 if (FrameView* view = document()->view()) { | 652 if (FrameView* view = document().view()) { |
653 if (RenderView* renderView = document()->renderView()) | 653 if (RenderView* renderView = document().renderView()) |
654 return adjustForAbsoluteZoom(view->layoutWidth(), renderView); | 654 return adjustForAbsoluteZoom(view->layoutWidth(), renderView); |
655 } | 655 } |
656 } | 656 } |
657 | 657 |
658 if (RenderBox* renderer = renderBox()) | 658 if (RenderBox* renderer = renderBox()) |
659 return adjustLayoutUnitForAbsoluteZoom(renderer->pixelSnappedClientWidth
(), renderer).round(); | 659 return adjustLayoutUnitForAbsoluteZoom(renderer->pixelSnappedClientWidth
(), renderer).round(); |
660 return 0; | 660 return 0; |
661 } | 661 } |
662 | 662 |
663 int Element::clientHeight() | 663 int Element::clientHeight() |
664 { | 664 { |
665 document()->updateLayoutIgnorePendingStylesheets(); | 665 document().updateLayoutIgnorePendingStylesheets(); |
666 | 666 |
667 // When in strict mode, clientHeight for the document element should return
the height of the containing frame. | 667 // When in strict mode, clientHeight for the document element should return
the height of the containing frame. |
668 // When in quirks mode, clientHeight for the body element should return the
height of the containing frame. | 668 // When in quirks mode, clientHeight for the body element should return the
height of the containing frame. |
669 bool inQuirksMode = document()->inQuirksMode(); | 669 bool inQuirksMode = document().inQuirksMode(); |
670 | 670 |
671 if ((!inQuirksMode && document()->documentElement() == this) || | 671 if ((!inQuirksMode && document().documentElement() == this) |
672 (inQuirksMode && isHTMLElement() && document()->body() == this)) { | 672 || (inQuirksMode && isHTMLElement() && document().body() == this)) { |
673 if (FrameView* view = document()->view()) { | 673 if (FrameView* view = document().view()) { |
674 if (RenderView* renderView = document()->renderView()) | 674 if (RenderView* renderView = document().renderView()) |
675 return adjustForAbsoluteZoom(view->layoutHeight(), renderView); | 675 return adjustForAbsoluteZoom(view->layoutHeight(), renderView); |
676 } | 676 } |
677 } | 677 } |
678 | 678 |
679 if (RenderBox* renderer = renderBox()) | 679 if (RenderBox* renderer = renderBox()) |
680 return adjustLayoutUnitForAbsoluteZoom(renderer->pixelSnappedClientHeigh
t(), renderer).round(); | 680 return adjustLayoutUnitForAbsoluteZoom(renderer->pixelSnappedClientHeigh
t(), renderer).round(); |
681 return 0; | 681 return 0; |
682 } | 682 } |
683 | 683 |
684 int Element::scrollLeft() | 684 int Element::scrollLeft() |
685 { | 685 { |
686 document()->updateLayoutIgnorePendingStylesheets(); | 686 document().updateLayoutIgnorePendingStylesheets(); |
687 if (RenderBox* rend = renderBox()) | 687 if (RenderBox* rend = renderBox()) |
688 return adjustForAbsoluteZoom(rend->scrollLeft(), rend); | 688 return adjustForAbsoluteZoom(rend->scrollLeft(), rend); |
689 return 0; | 689 return 0; |
690 } | 690 } |
691 | 691 |
692 int Element::scrollTop() | 692 int Element::scrollTop() |
693 { | 693 { |
694 document()->updateLayoutIgnorePendingStylesheets(); | 694 document().updateLayoutIgnorePendingStylesheets(); |
695 if (RenderBox* rend = renderBox()) | 695 if (RenderBox* rend = renderBox()) |
696 return adjustForAbsoluteZoom(rend->scrollTop(), rend); | 696 return adjustForAbsoluteZoom(rend->scrollTop(), rend); |
697 return 0; | 697 return 0; |
698 } | 698 } |
699 | 699 |
700 void Element::setScrollLeft(int newLeft) | 700 void Element::setScrollLeft(int newLeft) |
701 { | 701 { |
702 document()->updateLayoutIgnorePendingStylesheets(); | 702 document().updateLayoutIgnorePendingStylesheets(); |
703 if (RenderBox* rend = renderBox()) | 703 if (RenderBox* rend = renderBox()) |
704 rend->setScrollLeft(static_cast<int>(newLeft * rend->style()->effectiveZ
oom())); | 704 rend->setScrollLeft(static_cast<int>(newLeft * rend->style()->effectiveZ
oom())); |
705 } | 705 } |
706 | 706 |
707 void Element::setScrollTop(int newTop) | 707 void Element::setScrollTop(int newTop) |
708 { | 708 { |
709 document()->updateLayoutIgnorePendingStylesheets(); | 709 document().updateLayoutIgnorePendingStylesheets(); |
710 if (RenderBox* rend = renderBox()) | 710 if (RenderBox* rend = renderBox()) |
711 rend->setScrollTop(static_cast<int>(newTop * rend->style()->effectiveZoo
m())); | 711 rend->setScrollTop(static_cast<int>(newTop * rend->style()->effectiveZoo
m())); |
712 } | 712 } |
713 | 713 |
714 int Element::scrollWidth() | 714 int Element::scrollWidth() |
715 { | 715 { |
716 document()->updateLayoutIgnorePendingStylesheets(); | 716 document().updateLayoutIgnorePendingStylesheets(); |
717 if (RenderBox* rend = renderBox()) | 717 if (RenderBox* rend = renderBox()) |
718 return adjustForAbsoluteZoom(rend->scrollWidth(), rend); | 718 return adjustForAbsoluteZoom(rend->scrollWidth(), rend); |
719 return 0; | 719 return 0; |
720 } | 720 } |
721 | 721 |
722 int Element::scrollHeight() | 722 int Element::scrollHeight() |
723 { | 723 { |
724 document()->updateLayoutIgnorePendingStylesheets(); | 724 document().updateLayoutIgnorePendingStylesheets(); |
725 if (RenderBox* rend = renderBox()) | 725 if (RenderBox* rend = renderBox()) |
726 return adjustForAbsoluteZoom(rend->scrollHeight(), rend); | 726 return adjustForAbsoluteZoom(rend->scrollHeight(), rend); |
727 return 0; | 727 return 0; |
728 } | 728 } |
729 | 729 |
730 IntRect Element::boundsInRootViewSpace() | 730 IntRect Element::boundsInRootViewSpace() |
731 { | 731 { |
732 document()->updateLayoutIgnorePendingStylesheets(); | 732 document().updateLayoutIgnorePendingStylesheets(); |
733 | 733 |
734 FrameView* view = document()->view(); | 734 FrameView* view = document().view(); |
735 if (!view) | 735 if (!view) |
736 return IntRect(); | 736 return IntRect(); |
737 | 737 |
738 Vector<FloatQuad> quads; | 738 Vector<FloatQuad> quads; |
739 if (isSVGElement() && renderer()) { | 739 if (isSVGElement() && renderer()) { |
740 // Get the bounding rectangle from the SVG model. | 740 // Get the bounding rectangle from the SVG model. |
741 SVGElement* svgElement = toSVGElement(this); | 741 SVGElement* svgElement = toSVGElement(this); |
742 FloatRect localRect; | 742 FloatRect localRect; |
743 if (svgElement->getBoundingBox(localRect)) | 743 if (svgElement->getBoundingBox(localRect)) |
744 quads.append(renderer()->localToAbsoluteQuad(localRect)); | 744 quads.append(renderer()->localToAbsoluteQuad(localRect)); |
745 } else { | 745 } else { |
746 // Get the bounding rectangle from the box model. | 746 // Get the bounding rectangle from the box model. |
747 if (renderBoxModelObject()) | 747 if (renderBoxModelObject()) |
748 renderBoxModelObject()->absoluteQuads(quads); | 748 renderBoxModelObject()->absoluteQuads(quads); |
749 } | 749 } |
750 | 750 |
751 if (quads.isEmpty()) | 751 if (quads.isEmpty()) |
752 return IntRect(); | 752 return IntRect(); |
753 | 753 |
754 IntRect result = quads[0].enclosingBoundingBox(); | 754 IntRect result = quads[0].enclosingBoundingBox(); |
755 for (size_t i = 1; i < quads.size(); ++i) | 755 for (size_t i = 1; i < quads.size(); ++i) |
756 result.unite(quads[i].enclosingBoundingBox()); | 756 result.unite(quads[i].enclosingBoundingBox()); |
757 | 757 |
758 result = view->contentsToRootView(result); | 758 result = view->contentsToRootView(result); |
759 return result; | 759 return result; |
760 } | 760 } |
761 | 761 |
762 PassRefPtr<ClientRectList> Element::getClientRects() | 762 PassRefPtr<ClientRectList> Element::getClientRects() |
763 { | 763 { |
764 document()->updateLayoutIgnorePendingStylesheets(); | 764 document().updateLayoutIgnorePendingStylesheets(); |
765 | 765 |
766 RenderBoxModelObject* renderBoxModelObject = this->renderBoxModelObject(); | 766 RenderBoxModelObject* renderBoxModelObject = this->renderBoxModelObject(); |
767 if (!renderBoxModelObject) | 767 if (!renderBoxModelObject) |
768 return ClientRectList::create(); | 768 return ClientRectList::create(); |
769 | 769 |
770 // FIXME: Handle SVG elements. | 770 // FIXME: Handle SVG elements. |
771 // FIXME: Handle table/inline-table with a caption. | 771 // FIXME: Handle table/inline-table with a caption. |
772 | 772 |
773 Vector<FloatQuad> quads; | 773 Vector<FloatQuad> quads; |
774 renderBoxModelObject->absoluteQuads(quads); | 774 renderBoxModelObject->absoluteQuads(quads); |
775 document()->adjustFloatQuadsForScrollAndAbsoluteZoom(quads, renderBoxModelOb
ject); | 775 document().adjustFloatQuadsForScrollAndAbsoluteZoom(quads, renderBoxModelObj
ect); |
776 return ClientRectList::create(quads); | 776 return ClientRectList::create(quads); |
777 } | 777 } |
778 | 778 |
779 PassRefPtr<ClientRect> Element::getBoundingClientRect() | 779 PassRefPtr<ClientRect> Element::getBoundingClientRect() |
780 { | 780 { |
781 document()->updateLayoutIgnorePendingStylesheets(); | 781 document().updateLayoutIgnorePendingStylesheets(); |
782 | 782 |
783 Vector<FloatQuad> quads; | 783 Vector<FloatQuad> quads; |
784 if (isSVGElement() && renderer() && !renderer()->isSVGRoot()) { | 784 if (isSVGElement() && renderer() && !renderer()->isSVGRoot()) { |
785 // Get the bounding rectangle from the SVG model. | 785 // Get the bounding rectangle from the SVG model. |
786 SVGElement* svgElement = toSVGElement(this); | 786 SVGElement* svgElement = toSVGElement(this); |
787 FloatRect localRect; | 787 FloatRect localRect; |
788 if (svgElement->getBoundingBox(localRect)) | 788 if (svgElement->getBoundingBox(localRect)) |
789 quads.append(renderer()->localToAbsoluteQuad(localRect)); | 789 quads.append(renderer()->localToAbsoluteQuad(localRect)); |
790 } else { | 790 } else { |
791 // Get the bounding rectangle from the box model. | 791 // Get the bounding rectangle from the box model. |
792 if (renderBoxModelObject()) | 792 if (renderBoxModelObject()) |
793 renderBoxModelObject()->absoluteQuads(quads); | 793 renderBoxModelObject()->absoluteQuads(quads); |
794 } | 794 } |
795 | 795 |
796 if (quads.isEmpty()) | 796 if (quads.isEmpty()) |
797 return ClientRect::create(); | 797 return ClientRect::create(); |
798 | 798 |
799 FloatRect result = quads[0].boundingBox(); | 799 FloatRect result = quads[0].boundingBox(); |
800 for (size_t i = 1; i < quads.size(); ++i) | 800 for (size_t i = 1; i < quads.size(); ++i) |
801 result.unite(quads[i].boundingBox()); | 801 result.unite(quads[i].boundingBox()); |
802 | 802 |
803 document()->adjustFloatRectForScrollAndAbsoluteZoom(result, renderer()); | 803 document().adjustFloatRectForScrollAndAbsoluteZoom(result, renderer()); |
804 return ClientRect::create(result); | 804 return ClientRect::create(result); |
805 } | 805 } |
806 | 806 |
807 IntRect Element::screenRect() const | 807 IntRect Element::screenRect() const |
808 { | 808 { |
809 if (!renderer()) | 809 if (!renderer()) |
810 return IntRect(); | 810 return IntRect(); |
811 // FIXME: this should probably respect transforms | 811 // FIXME: this should probably respect transforms |
812 return document()->view()->contentsToScreen(renderer()->absoluteBoundingBoxR
ectIgnoringTransforms()); | 812 return document().view()->contentsToScreen(renderer()->absoluteBoundingBoxRe
ctIgnoringTransforms()); |
813 } | 813 } |
814 | 814 |
815 const AtomicString& Element::getAttribute(const AtomicString& localName) const | 815 const AtomicString& Element::getAttribute(const AtomicString& localName) const |
816 { | 816 { |
817 if (!elementData()) | 817 if (!elementData()) |
818 return nullAtom; | 818 return nullAtom; |
819 synchronizeAttribute(localName); | 819 synchronizeAttribute(localName); |
820 if (const Attribute* attribute = elementData()->getAttributeItem(localName,
shouldIgnoreAttributeCase(this))) | 820 if (const Attribute* attribute = elementData()->getAttributeItem(localName,
shouldIgnoreAttributeCase(this))) |
821 return attribute->value(); | 821 return attribute->value(); |
822 return nullAtom; | 822 return nullAtom; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
906 | 906 |
907 void Element::attributeChanged(const QualifiedName& name, const AtomicString& ne
wValue, AttributeModificationReason reason) | 907 void Element::attributeChanged(const QualifiedName& name, const AtomicString& ne
wValue, AttributeModificationReason reason) |
908 { | 908 { |
909 if (ElementShadow* parentElementShadow = shadowOfParentForDistribution(this)
) { | 909 if (ElementShadow* parentElementShadow = shadowOfParentForDistribution(this)
) { |
910 if (shouldInvalidateDistributionWhenAttributeChanged(parentElementShadow
, name, newValue)) | 910 if (shouldInvalidateDistributionWhenAttributeChanged(parentElementShadow
, name, newValue)) |
911 parentElementShadow->setNeedsDistributionRecalc(); | 911 parentElementShadow->setNeedsDistributionRecalc(); |
912 } | 912 } |
913 | 913 |
914 parseAttribute(name, newValue); | 914 parseAttribute(name, newValue); |
915 | 915 |
916 document()->incDOMTreeVersion(); | 916 document().incDOMTreeVersion(); |
917 | 917 |
918 StyleResolver* styleResolver = document()->styleResolverIfExists(); | 918 StyleResolver* styleResolver = document().styleResolverIfExists(); |
919 bool testShouldInvalidateStyle = attached() && styleResolver && styleChangeT
ype() < SubtreeStyleChange; | 919 bool testShouldInvalidateStyle = attached() && styleResolver && styleChangeT
ype() < SubtreeStyleChange; |
920 bool shouldInvalidateStyle = false; | 920 bool shouldInvalidateStyle = false; |
921 | 921 |
922 if (isStyledElement() && name == styleAttr) { | 922 if (isStyledElement() && name == styleAttr) { |
923 styleAttributeChanged(newValue, reason); | 923 styleAttributeChanged(newValue, reason); |
924 } else if (isStyledElement() && isPresentationAttribute(name)) { | 924 } else if (isStyledElement() && isPresentationAttribute(name)) { |
925 elementData()->m_presentationAttributeStyleIsDirty = true; | 925 elementData()->m_presentationAttributeStyleIsDirty = true; |
926 setNeedsStyleRecalc(LocalStyleChange); | 926 setNeedsStyleRecalc(LocalStyleChange); |
927 } | 927 } |
928 | 928 |
929 if (isIdAttributeName(name)) { | 929 if (isIdAttributeName(name)) { |
930 AtomicString oldId = elementData()->idForStyleResolution(); | 930 AtomicString oldId = elementData()->idForStyleResolution(); |
931 AtomicString newId = makeIdForStyleResolution(newValue, document()->inQu
irksMode()); | 931 AtomicString newId = makeIdForStyleResolution(newValue, document().inQui
rksMode()); |
932 if (newId != oldId) { | 932 if (newId != oldId) { |
933 elementData()->setIdForStyleResolution(newId); | 933 elementData()->setIdForStyleResolution(newId); |
934 shouldInvalidateStyle = testShouldInvalidateStyle && checkNeedsStyle
InvalidationForIdChange(oldId, newId, styleResolver->ruleFeatureSet()); | 934 shouldInvalidateStyle = testShouldInvalidateStyle && checkNeedsStyle
InvalidationForIdChange(oldId, newId, styleResolver->ruleFeatureSet()); |
935 } | 935 } |
936 } else if (name == classAttr) { | 936 } else if (name == classAttr) { |
937 classAttributeChanged(newValue); | 937 classAttributeChanged(newValue); |
938 } else if (name == HTMLNames::nameAttr) { | 938 } else if (name == HTMLNames::nameAttr) { |
939 setHasName(!newValue.isNull()); | 939 setHasName(!newValue.isNull()); |
940 } else if (name == HTMLNames::pseudoAttr) { | 940 } else if (name == HTMLNames::pseudoAttr) { |
941 shouldInvalidateStyle |= testShouldInvalidateStyle && isInShadowTree(); | 941 shouldInvalidateStyle |= testShouldInvalidateStyle && isInShadowTree(); |
942 } | 942 } |
943 | 943 |
944 invalidateNodeListCachesInAncestors(&name, this); | 944 invalidateNodeListCachesInAncestors(&name, this); |
945 | 945 |
946 // If there is currently no StyleResolver, we can't be sure that this attrib
ute change won't affect style. | 946 // If there is currently no StyleResolver, we can't be sure that this attrib
ute change won't affect style. |
947 shouldInvalidateStyle |= !styleResolver; | 947 shouldInvalidateStyle |= !styleResolver; |
948 | 948 |
949 if (shouldInvalidateStyle) | 949 if (shouldInvalidateStyle) |
950 setNeedsStyleRecalc(); | 950 setNeedsStyleRecalc(); |
951 | 951 |
952 if (AXObjectCache* cache = document()->existingAXObjectCache()) | 952 if (AXObjectCache* cache = document().existingAXObjectCache()) |
953 cache->handleAttributeChanged(name, this); | 953 cache->handleAttributeChanged(name, this); |
954 } | 954 } |
955 | 955 |
956 inline void Element::attributeChangedFromParserOrByCloning(const QualifiedName&
name, const AtomicString& newValue, AttributeModificationReason reason) | 956 inline void Element::attributeChangedFromParserOrByCloning(const QualifiedName&
name, const AtomicString& newValue, AttributeModificationReason reason) |
957 { | 957 { |
958 if (name == isAttr) | 958 if (name == isAttr) |
959 CustomElementRegistrationContext::setTypeExtension(this, newValue, reaso
n == ModifiedDirectly ? CustomElementRegistrationContext::CreatedByParser : Cust
omElementRegistrationContext::NotCreatedByParser); | 959 CustomElementRegistrationContext::setTypeExtension(this, newValue, reaso
n == ModifiedDirectly ? CustomElementRegistrationContext::CreatedByParser : Cust
omElementRegistrationContext::NotCreatedByParser); |
960 attributeChanged(name, newValue, reason); | 960 attributeChanged(name, newValue, reason); |
961 } | 961 } |
962 | 962 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1023 if (remainingClassBits.quickGet(i)) | 1023 if (remainingClassBits.quickGet(i)) |
1024 continue; | 1024 continue; |
1025 if (checker.hasSelectorForClass(oldClasses[i])) | 1025 if (checker.hasSelectorForClass(oldClasses[i])) |
1026 return true; | 1026 return true; |
1027 } | 1027 } |
1028 return false; | 1028 return false; |
1029 } | 1029 } |
1030 | 1030 |
1031 void Element::classAttributeChanged(const AtomicString& newClassString) | 1031 void Element::classAttributeChanged(const AtomicString& newClassString) |
1032 { | 1032 { |
1033 StyleResolver* styleResolver = document()->styleResolverIfExists(); | 1033 StyleResolver* styleResolver = document().styleResolverIfExists(); |
1034 bool testShouldInvalidateStyle = attached() && styleResolver && styleChangeT
ype() < SubtreeStyleChange; | 1034 bool testShouldInvalidateStyle = attached() && styleResolver && styleChangeT
ype() < SubtreeStyleChange; |
1035 bool shouldInvalidateStyle = false; | 1035 bool shouldInvalidateStyle = false; |
1036 | 1036 |
1037 if (classStringHasClassName(newClassString)) { | 1037 if (classStringHasClassName(newClassString)) { |
1038 const bool shouldFoldCase = document()->inQuirksMode(); | 1038 const bool shouldFoldCase = document().inQuirksMode(); |
1039 const SpaceSplitString oldClasses = elementData()->classNames(); | 1039 const SpaceSplitString oldClasses = elementData()->classNames(); |
1040 elementData()->setClass(newClassString, shouldFoldCase); | 1040 elementData()->setClass(newClassString, shouldFoldCase); |
1041 const SpaceSplitString& newClasses = elementData()->classNames(); | 1041 const SpaceSplitString& newClasses = elementData()->classNames(); |
1042 shouldInvalidateStyle = testShouldInvalidateStyle && checkSelectorForCla
ssChange(oldClasses, newClasses, styleResolver->ruleFeatureSet()); | 1042 shouldInvalidateStyle = testShouldInvalidateStyle && checkSelectorForCla
ssChange(oldClasses, newClasses, styleResolver->ruleFeatureSet()); |
1043 } else { | 1043 } else { |
1044 const SpaceSplitString& oldClasses = elementData()->classNames(); | 1044 const SpaceSplitString& oldClasses = elementData()->classNames(); |
1045 shouldInvalidateStyle = testShouldInvalidateStyle && checkSelectorForCla
ssChange(oldClasses, styleResolver->ruleFeatureSet()); | 1045 shouldInvalidateStyle = testShouldInvalidateStyle && checkSelectorForCla
ssChange(oldClasses, styleResolver->ruleFeatureSet()); |
1046 elementData()->clearClass(); | 1046 elementData()->clearClass(); |
1047 } | 1047 } |
1048 | 1048 |
1049 if (hasRareData()) | 1049 if (hasRareData()) |
1050 elementRareData()->clearClassListValueForQuirksMode(); | 1050 elementRareData()->clearClassListValueForQuirksMode(); |
1051 | 1051 |
1052 if (shouldInvalidateStyle) | 1052 if (shouldInvalidateStyle) |
1053 setNeedsStyleRecalc(); | 1053 setNeedsStyleRecalc(); |
1054 } | 1054 } |
1055 | 1055 |
1056 bool Element::shouldInvalidateDistributionWhenAttributeChanged(ElementShadow* el
ementShadow, const QualifiedName& name, const AtomicString& newValue) | 1056 bool Element::shouldInvalidateDistributionWhenAttributeChanged(ElementShadow* el
ementShadow, const QualifiedName& name, const AtomicString& newValue) |
1057 { | 1057 { |
1058 ASSERT(elementShadow); | 1058 ASSERT(elementShadow); |
1059 const SelectRuleFeatureSet& featureSet = elementShadow->ensureSelectFeatureS
et(); | 1059 const SelectRuleFeatureSet& featureSet = elementShadow->ensureSelectFeatureS
et(); |
1060 | 1060 |
1061 if (isIdAttributeName(name)) { | 1061 if (isIdAttributeName(name)) { |
1062 AtomicString oldId = elementData()->idForStyleResolution(); | 1062 AtomicString oldId = elementData()->idForStyleResolution(); |
1063 AtomicString newId = makeIdForStyleResolution(newValue, document()->inQu
irksMode()); | 1063 AtomicString newId = makeIdForStyleResolution(newValue, document().inQui
rksMode()); |
1064 if (newId != oldId) { | 1064 if (newId != oldId) { |
1065 if (!oldId.isEmpty() && featureSet.hasSelectorForId(oldId)) | 1065 if (!oldId.isEmpty() && featureSet.hasSelectorForId(oldId)) |
1066 return true; | 1066 return true; |
1067 if (!newId.isEmpty() && featureSet.hasSelectorForId(newId)) | 1067 if (!newId.isEmpty() && featureSet.hasSelectorForId(newId)) |
1068 return true; | 1068 return true; |
1069 } | 1069 } |
1070 } | 1070 } |
1071 | 1071 |
1072 if (name == HTMLNames::classAttr) { | 1072 if (name == HTMLNames::classAttr) { |
1073 const AtomicString& newClassString = newValue; | 1073 const AtomicString& newClassString = newValue; |
1074 if (classStringHasClassName(newClassString)) { | 1074 if (classStringHasClassName(newClassString)) { |
1075 const bool shouldFoldCase = document()->inQuirksMode(); | 1075 const bool shouldFoldCase = document().inQuirksMode(); |
1076 const SpaceSplitString& oldClasses = elementData()->classNames(); | 1076 const SpaceSplitString& oldClasses = elementData()->classNames(); |
1077 const SpaceSplitString newClasses(newClassString, shouldFoldCase); | 1077 const SpaceSplitString newClasses(newClassString, shouldFoldCase); |
1078 if (checkSelectorForClassChange(oldClasses, newClasses, featureSet)) | 1078 if (checkSelectorForClassChange(oldClasses, newClasses, featureSet)) |
1079 return true; | 1079 return true; |
1080 } else { | 1080 } else { |
1081 const SpaceSplitString& oldClasses = elementData()->classNames(); | 1081 const SpaceSplitString& oldClasses = elementData()->classNames(); |
1082 if (checkSelectorForClassChange(oldClasses, featureSet)) | 1082 if (checkSelectorForClassChange(oldClasses, featureSet)) |
1083 return true; | 1083 return true; |
1084 } | 1084 } |
1085 } | 1085 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1121 | 1121 |
1122 void Element::parserSetAttributes(const Vector<Attribute>& attributeVector) | 1122 void Element::parserSetAttributes(const Vector<Attribute>& attributeVector) |
1123 { | 1123 { |
1124 ASSERT(!inDocument()); | 1124 ASSERT(!inDocument()); |
1125 ASSERT(!parentNode()); | 1125 ASSERT(!parentNode()); |
1126 ASSERT(!m_elementData); | 1126 ASSERT(!m_elementData); |
1127 | 1127 |
1128 if (attributeVector.isEmpty()) | 1128 if (attributeVector.isEmpty()) |
1129 return; | 1129 return; |
1130 | 1130 |
1131 if (document()->sharedObjectPool()) | 1131 if (document().sharedObjectPool()) |
1132 m_elementData = document()->sharedObjectPool()->cachedShareableElementDa
taWithAttributes(attributeVector); | 1132 m_elementData = document().sharedObjectPool()->cachedShareableElementDat
aWithAttributes(attributeVector); |
1133 else | 1133 else |
1134 m_elementData = ShareableElementData::createWithAttributes(attributeVect
or); | 1134 m_elementData = ShareableElementData::createWithAttributes(attributeVect
or); |
1135 | 1135 |
1136 // Use attributeVector instead of m_elementData because attributeChanged mig
ht modify m_elementData. | 1136 // Use attributeVector instead of m_elementData because attributeChanged mig
ht modify m_elementData. |
1137 for (unsigned i = 0; i < attributeVector.size(); ++i) | 1137 for (unsigned i = 0; i < attributeVector.size(); ++i) |
1138 attributeChangedFromParserOrByCloning(attributeVector[i].name(), attribu
teVector[i].value(), ModifiedDirectly); | 1138 attributeChangedFromParserOrByCloning(attributeVector[i].name(), attribu
teVector[i].value(), ModifiedDirectly); |
1139 } | 1139 } |
1140 | 1140 |
1141 bool Element::hasAttributes() const | 1141 bool Element::hasAttributes() const |
1142 { | 1142 { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1227 if (Element* backdrop = pseudoElement(BACKDROP)) | 1227 if (Element* backdrop = pseudoElement(BACKDROP)) |
1228 backdrop->insertedInto(insertionPoint); | 1228 backdrop->insertedInto(insertionPoint); |
1229 | 1229 |
1230 if (!insertionPoint->isInTreeScope()) | 1230 if (!insertionPoint->isInTreeScope()) |
1231 return InsertionDone; | 1231 return InsertionDone; |
1232 | 1232 |
1233 if (hasRareData()) | 1233 if (hasRareData()) |
1234 elementRareData()->clearClassListValueForQuirksMode(); | 1234 elementRareData()->clearClassListValueForQuirksMode(); |
1235 | 1235 |
1236 if (isUpgradedCustomElement() && inDocument()) | 1236 if (isUpgradedCustomElement() && inDocument()) |
1237 CustomElement::didEnterDocument(this, document()); | 1237 CustomElement::didEnterDocument(this, &document()); |
1238 | 1238 |
1239 TreeScope* scope = insertionPoint->treeScope(); | 1239 TreeScope* scope = insertionPoint->treeScope(); |
1240 if (scope != treeScope()) | 1240 if (scope != treeScope()) |
1241 return InsertionDone; | 1241 return InsertionDone; |
1242 | 1242 |
1243 const AtomicString& idValue = getIdAttribute(); | 1243 const AtomicString& idValue = getIdAttribute(); |
1244 if (!idValue.isNull()) | 1244 if (!idValue.isNull()) |
1245 updateId(scope, nullAtom, idValue); | 1245 updateId(scope, nullAtom, idValue); |
1246 | 1246 |
1247 const AtomicString& nameValue = getNameAttribute(); | 1247 const AtomicString& nameValue = getNameAttribute(); |
(...skipping 16 matching lines...) Expand all Loading... |
1264 bool wasInDocument = insertionPoint->inDocument(); | 1264 bool wasInDocument = insertionPoint->inDocument(); |
1265 | 1265 |
1266 if (Element* before = pseudoElement(BEFORE)) | 1266 if (Element* before = pseudoElement(BEFORE)) |
1267 before->removedFrom(insertionPoint); | 1267 before->removedFrom(insertionPoint); |
1268 | 1268 |
1269 if (Element* after = pseudoElement(AFTER)) | 1269 if (Element* after = pseudoElement(AFTER)) |
1270 after->removedFrom(insertionPoint); | 1270 after->removedFrom(insertionPoint); |
1271 | 1271 |
1272 if (Element* backdrop = pseudoElement(BACKDROP)) | 1272 if (Element* backdrop = pseudoElement(BACKDROP)) |
1273 backdrop->removedFrom(insertionPoint); | 1273 backdrop->removedFrom(insertionPoint); |
1274 document()->removeFromTopLayer(this); | 1274 document().removeFromTopLayer(this); |
1275 | 1275 |
1276 if (containsFullScreenElement()) | 1276 if (containsFullScreenElement()) |
1277 setContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(false); | 1277 setContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(false); |
1278 | 1278 |
1279 if (document()->page()) | 1279 if (document().page()) |
1280 document()->page()->pointerLockController().elementRemoved(this); | 1280 document().page()->pointerLockController().elementRemoved(this); |
1281 | 1281 |
1282 setSavedLayerScrollOffset(IntSize()); | 1282 setSavedLayerScrollOffset(IntSize()); |
1283 | 1283 |
1284 if (insertionPoint->isInTreeScope() && treeScope() == document()) { | 1284 if (insertionPoint->isInTreeScope() && treeScope() == &document()) { |
1285 const AtomicString& idValue = getIdAttribute(); | 1285 const AtomicString& idValue = getIdAttribute(); |
1286 if (!idValue.isNull()) | 1286 if (!idValue.isNull()) |
1287 updateId(insertionPoint->treeScope(), idValue, nullAtom); | 1287 updateId(insertionPoint->treeScope(), idValue, nullAtom); |
1288 | 1288 |
1289 const AtomicString& nameValue = getNameAttribute(); | 1289 const AtomicString& nameValue = getNameAttribute(); |
1290 if (!nameValue.isNull()) | 1290 if (!nameValue.isNull()) |
1291 updateName(nameValue, nullAtom); | 1291 updateName(nameValue, nullAtom); |
1292 | 1292 |
1293 if (hasTagName(labelTag)) { | 1293 if (hasTagName(labelTag)) { |
1294 TreeScope* treeScope = insertionPoint->treeScope(); | 1294 TreeScope* treeScope = insertionPoint->treeScope(); |
1295 if (treeScope->shouldCacheLabelsByForAttribute()) | 1295 if (treeScope->shouldCacheLabelsByForAttribute()) |
1296 updateLabel(treeScope, fastGetAttribute(forAttr), nullAtom); | 1296 updateLabel(treeScope, fastGetAttribute(forAttr), nullAtom); |
1297 } | 1297 } |
1298 } | 1298 } |
1299 | 1299 |
1300 ContainerNode::removedFrom(insertionPoint); | 1300 ContainerNode::removedFrom(insertionPoint); |
1301 if (wasInDocument) { | 1301 if (wasInDocument) { |
1302 if (hasPendingResources()) | 1302 if (hasPendingResources()) |
1303 document()->accessSVGExtensions()->removeElementFromPendingResources
(this); | 1303 document().accessSVGExtensions()->removeElementFromPendingResources(
this); |
1304 | 1304 |
1305 if (isUpgradedCustomElement()) | 1305 if (isUpgradedCustomElement()) |
1306 CustomElement::didLeaveDocument(this, insertionPoint->document()); | 1306 CustomElement::didLeaveDocument(this, &insertionPoint->document()); |
1307 } | 1307 } |
1308 | 1308 |
1309 if (hasRareData()) | 1309 if (hasRareData()) |
1310 elementRareData()->setIsInCanvasSubtree(false); | 1310 elementRareData()->setIsInCanvasSubtree(false); |
1311 } | 1311 } |
1312 | 1312 |
1313 void Element::attach(const AttachContext& context) | 1313 void Element::attach(const AttachContext& context) |
1314 { | 1314 { |
1315 PostAttachCallbackDisabler callbackDisabler(this); | 1315 PostAttachCallbackDisabler callbackDisabler(this); |
1316 StyleResolverParentPusher parentPusher(this); | 1316 StyleResolverParentPusher parentPusher(this); |
(...skipping 21 matching lines...) Expand all Loading... |
1338 parentPusher.push(); | 1338 parentPusher.push(); |
1339 | 1339 |
1340 ContainerNode::attach(context); | 1340 ContainerNode::attach(context); |
1341 | 1341 |
1342 createPseudoElementIfNeeded(AFTER); | 1342 createPseudoElementIfNeeded(AFTER); |
1343 createPseudoElementIfNeeded(BACKDROP); | 1343 createPseudoElementIfNeeded(BACKDROP); |
1344 | 1344 |
1345 if (hasRareData()) { | 1345 if (hasRareData()) { |
1346 ElementRareData* data = elementRareData(); | 1346 ElementRareData* data = elementRareData(); |
1347 if (data->needsFocusAppearanceUpdateSoonAfterAttach()) { | 1347 if (data->needsFocusAppearanceUpdateSoonAfterAttach()) { |
1348 if (isFocusable() && document()->focusedElement() == this) | 1348 if (isFocusable() && document().focusedElement() == this) |
1349 document()->updateFocusAppearanceSoon(false /* don't restore sel
ection */); | 1349 document().updateFocusAppearanceSoon(false /* don't restore sele
ction */); |
1350 data->setNeedsFocusAppearanceUpdateSoonAfterAttach(false); | 1350 data->setNeedsFocusAppearanceUpdateSoonAfterAttach(false); |
1351 } | 1351 } |
1352 } | 1352 } |
1353 | 1353 |
1354 // FIXME: It doesn't appear safe to call didRecalculateStyleForElement when | 1354 // FIXME: It doesn't appear safe to call didRecalculateStyleForElement when |
1355 // not in a Document::recalcStyle. Since we're hopefully going to always | 1355 // not in a Document::recalcStyle. Since we're hopefully going to always |
1356 // lazyAttach in the future that problem should go away. | 1356 // lazyAttach in the future that problem should go away. |
1357 if (document()->inStyleRecalc()) | 1357 if (document().inStyleRecalc()) |
1358 InspectorInstrumentation::didRecalculateStyleForElement(this); | 1358 InspectorInstrumentation::didRecalculateStyleForElement(this); |
1359 } | 1359 } |
1360 | 1360 |
1361 void Element::unregisterNamedFlowContentNode() | 1361 void Element::unregisterNamedFlowContentNode() |
1362 { | 1362 { |
1363 if (RuntimeEnabledFeatures::cssRegionsEnabled() && inNamedFlow() && document
()->renderView()) | 1363 if (RuntimeEnabledFeatures::cssRegionsEnabled() && inNamedFlow() && document
().renderView()) |
1364 document()->renderView()->flowThreadController()->unregisterNamedFlowCon
tentNode(this); | 1364 document().renderView()->flowThreadController()->unregisterNamedFlowCont
entNode(this); |
1365 } | 1365 } |
1366 | 1366 |
1367 void Element::detach(const AttachContext& context) | 1367 void Element::detach(const AttachContext& context) |
1368 { | 1368 { |
1369 WidgetHierarchyUpdatesSuspensionScope suspendWidgetHierarchyUpdates; | 1369 WidgetHierarchyUpdatesSuspensionScope suspendWidgetHierarchyUpdates; |
1370 unregisterNamedFlowContentNode(); | 1370 unregisterNamedFlowContentNode(); |
1371 cancelFocusAppearanceUpdate(); | 1371 cancelFocusAppearanceUpdate(); |
1372 if (hasRareData()) { | 1372 if (hasRareData()) { |
1373 ElementRareData* data = elementRareData(); | 1373 ElementRareData* data = elementRareData(); |
1374 data->setPseudoElement(BEFORE, 0); | 1374 data->setPseudoElement(BEFORE, 0); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1435 if (hasCustomStyleCallbacks()) { | 1435 if (hasCustomStyleCallbacks()) { |
1436 if (RefPtr<RenderStyle> style = customStyleForRenderer()) | 1436 if (RefPtr<RenderStyle> style = customStyleForRenderer()) |
1437 return style.release(); | 1437 return style.release(); |
1438 } | 1438 } |
1439 | 1439 |
1440 return originalStyleForRenderer(); | 1440 return originalStyleForRenderer(); |
1441 } | 1441 } |
1442 | 1442 |
1443 PassRefPtr<RenderStyle> Element::originalStyleForRenderer() | 1443 PassRefPtr<RenderStyle> Element::originalStyleForRenderer() |
1444 { | 1444 { |
1445 return document()->styleResolver()->styleForElement(this); | 1445 return document().styleResolver()->styleForElement(this); |
1446 } | 1446 } |
1447 | 1447 |
1448 bool Element::recalcStyle(StyleChange change) | 1448 bool Element::recalcStyle(StyleChange change) |
1449 { | 1449 { |
1450 ASSERT(document()->inStyleRecalc()); | 1450 ASSERT(document().inStyleRecalc()); |
1451 | 1451 |
1452 if (hasCustomStyleCallbacks()) | 1452 if (hasCustomStyleCallbacks()) |
1453 willRecalcStyle(change); | 1453 willRecalcStyle(change); |
1454 | 1454 |
1455 if (hasRareData() && (change > NoChange || needsStyleRecalc())) { | 1455 if (hasRareData() && (change > NoChange || needsStyleRecalc())) { |
1456 ElementRareData* data = elementRareData(); | 1456 ElementRareData* data = elementRareData(); |
1457 data->resetStyleState(); | 1457 data->resetStyleState(); |
1458 data->clearComputedStyle(); | 1458 data->clearComputedStyle(); |
1459 } | 1459 } |
1460 | 1460 |
1461 // Active InsertionPoints have no renderers so they never need to go through
a recalc. | 1461 // Active InsertionPoints have no renderers so they never need to go through
a recalc. |
1462 if ((change >= Inherit || needsStyleRecalc()) && parentRenderStyle() && !isA
ctiveInsertionPoint(this)) | 1462 if ((change >= Inherit || needsStyleRecalc()) && parentRenderStyle() && !isA
ctiveInsertionPoint(this)) |
1463 change = recalcOwnStyle(change); | 1463 change = recalcOwnStyle(change); |
1464 | 1464 |
1465 // If we reattached we don't need to recalc the style of our descendants any
more. | 1465 // If we reattached we don't need to recalc the style of our descendants any
more. |
1466 if (change < Reattach) | 1466 if (change < Reattach) |
1467 recalcChildStyle(change); | 1467 recalcChildStyle(change); |
1468 | 1468 |
1469 clearNeedsStyleRecalc(); | 1469 clearNeedsStyleRecalc(); |
1470 clearChildNeedsStyleRecalc(); | 1470 clearChildNeedsStyleRecalc(); |
1471 | 1471 |
1472 if (hasCustomStyleCallbacks()) | 1472 if (hasCustomStyleCallbacks()) |
1473 didRecalcStyle(change); | 1473 didRecalcStyle(change); |
1474 | 1474 |
1475 return change == Reattach; | 1475 return change == Reattach; |
1476 } | 1476 } |
1477 | 1477 |
1478 Node::StyleChange Element::recalcOwnStyle(StyleChange change) | 1478 Node::StyleChange Element::recalcOwnStyle(StyleChange change) |
1479 { | 1479 { |
1480 ASSERT(document()->inStyleRecalc()); | 1480 ASSERT(document().inStyleRecalc()); |
1481 | 1481 |
1482 CSSAnimationUpdateScope cssAnimationUpdateScope(this); | 1482 CSSAnimationUpdateScope cssAnimationUpdateScope(this); |
1483 RefPtr<RenderStyle> oldStyle = renderStyle(); | 1483 RefPtr<RenderStyle> oldStyle = renderStyle(); |
1484 RefPtr<RenderStyle> newStyle = styleForRenderer(); | 1484 RefPtr<RenderStyle> newStyle = styleForRenderer(); |
1485 StyleChange localChange = oldStyle ? Node::diff(oldStyle.get(), newStyle.get
(), document()) : Reattach; | 1485 StyleChange localChange = oldStyle ? Node::diff(oldStyle.get(), newStyle.get
(), &document()) : Reattach; |
1486 | 1486 |
1487 if (localChange == Reattach) { | 1487 if (localChange == Reattach) { |
1488 AttachContext reattachContext; | 1488 AttachContext reattachContext; |
1489 reattachContext.resolvedStyle = newStyle.get(); | 1489 reattachContext.resolvedStyle = newStyle.get(); |
1490 reattach(reattachContext); | 1490 reattach(reattachContext); |
1491 return Reattach; | 1491 return Reattach; |
1492 } | 1492 } |
1493 | 1493 |
1494 InspectorInstrumentation::didRecalculateStyleForElement(this); | 1494 InspectorInstrumentation::didRecalculateStyleForElement(this); |
1495 | 1495 |
1496 if (RenderObject* renderer = this->renderer()) { | 1496 if (RenderObject* renderer = this->renderer()) { |
1497 if (localChange != NoChange || pseudoStyleCacheIsInvalid(oldStyle.get(),
newStyle.get()) || (change == Force && renderer->requiresForcedStyleRecalcPropa
gation()) || shouldNotifyRendererWithIdenticalStyles()) { | 1497 if (localChange != NoChange || pseudoStyleCacheIsInvalid(oldStyle.get(),
newStyle.get()) || (change == Force && renderer->requiresForcedStyleRecalcPropa
gation()) || shouldNotifyRendererWithIdenticalStyles()) { |
1498 renderer->setAnimatableStyle(newStyle.get()); | 1498 renderer->setAnimatableStyle(newStyle.get()); |
1499 } else if (needsStyleRecalc()) { | 1499 } else if (needsStyleRecalc()) { |
1500 // Although no change occurred, we use the new style so that the cou
sin style sharing code won't get | 1500 // Although no change occurred, we use the new style so that the cou
sin style sharing code won't get |
1501 // fooled into believing this style is the same. | 1501 // fooled into believing this style is the same. |
1502 renderer->setStyleInternal(newStyle.get()); | 1502 renderer->setStyleInternal(newStyle.get()); |
1503 } | 1503 } |
1504 } | 1504 } |
1505 | 1505 |
1506 // If "rem" units are used anywhere in the document, and if the document ele
ment's font size changes, then go ahead and force font updating | 1506 // If "rem" units are used anywhere in the document, and if the document ele
ment's font size changes, then go ahead and force font updating |
1507 // all the way down the tree. This is simpler than having to maintain a cach
e of objects (and such font size changes should be rare anyway). | 1507 // all the way down the tree. This is simpler than having to maintain a cach
e of objects (and such font size changes should be rare anyway). |
1508 if (document()->styleSheetCollections()->usesRemUnits() && document()->docum
entElement() == this && oldStyle && newStyle && oldStyle->fontSize() != newStyle
->fontSize()) { | 1508 if (document().styleSheetCollections()->usesRemUnits() && document().documen
tElement() == this && oldStyle && newStyle && oldStyle->fontSize() != newStyle->
fontSize()) { |
1509 // Cached RenderStyles may depend on the re units. | 1509 // Cached RenderStyles may depend on the re units. |
1510 document()->styleResolver()->invalidateMatchedPropertiesCache(); | 1510 document().styleResolver()->invalidateMatchedPropertiesCache(); |
1511 return Force; | 1511 return Force; |
1512 } | 1512 } |
1513 | 1513 |
1514 if (styleChangeType() >= SubtreeStyleChange) | 1514 if (styleChangeType() >= SubtreeStyleChange) |
1515 return Force; | 1515 return Force; |
1516 | 1516 |
1517 return max(localChange, change); | 1517 return max(localChange, change); |
1518 } | 1518 } |
1519 | 1519 |
1520 void Element::recalcChildStyle(StyleChange change) | 1520 void Element::recalcChildStyle(StyleChange change) |
1521 { | 1521 { |
1522 ASSERT(document()->inStyleRecalc()); | 1522 ASSERT(document().inStyleRecalc()); |
1523 | 1523 |
1524 StyleResolverParentPusher parentPusher(this); | 1524 StyleResolverParentPusher parentPusher(this); |
1525 | 1525 |
1526 for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadow
Root()) { | 1526 for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadow
Root()) { |
1527 if (shouldRecalcStyle(change, root)) { | 1527 if (shouldRecalcStyle(change, root)) { |
1528 parentPusher.push(); | 1528 parentPusher.push(); |
1529 root->recalcStyle(change); | 1529 root->recalcStyle(change); |
1530 } | 1530 } |
1531 } | 1531 } |
1532 | 1532 |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1665 if (!style && !element->styleAffectedByEmpty()) | 1665 if (!style && !element->styleAffectedByEmpty()) |
1666 return; | 1666 return; |
1667 | 1667 |
1668 if (!style || (element->styleAffectedByEmpty() && (!style->emptyState() || e
lement->hasChildNodes()))) | 1668 if (!style || (element->styleAffectedByEmpty() && (!style->emptyState() || e
lement->hasChildNodes()))) |
1669 element->setNeedsStyleRecalc(); | 1669 element->setNeedsStyleRecalc(); |
1670 } | 1670 } |
1671 | 1671 |
1672 static void checkForSiblingStyleChanges(Element* e, RenderStyle* style, bool fin
ishedParsingCallback, | 1672 static void checkForSiblingStyleChanges(Element* e, RenderStyle* style, bool fin
ishedParsingCallback, |
1673 Node* beforeChange, Node* afterChange, i
nt childCountDelta) | 1673 Node* beforeChange, Node* afterChange, i
nt childCountDelta) |
1674 { | 1674 { |
1675 if (!e->attached() || e->document()->hasPendingForcedStyleRecalc() || e->sty
leChangeType() >= SubtreeStyleChange) | 1675 if (!e->attached() || e->document().hasPendingForcedStyleRecalc() || e->styl
eChangeType() >= SubtreeStyleChange) |
1676 return; | 1676 return; |
1677 | 1677 |
1678 // :empty selector. | 1678 // :empty selector. |
1679 checkForEmptyStyleChange(e, style); | 1679 checkForEmptyStyleChange(e, style); |
1680 | 1680 |
1681 if (!style || (e->needsStyleRecalc() && e->childrenAffectedByPositionalRules
())) | 1681 if (!style || (e->needsStyleRecalc() && e->childrenAffectedByPositionalRules
())) |
1682 return; | 1682 return; |
1683 | 1683 |
1684 // Forward positional selectors include the ~ selector, nth-child, nth-of-ty
pe, first-of-type and only-of-type. | 1684 // Forward positional selectors include the ~ selector, nth-child, nth-of-ty
pe, first-of-type and only-of-type. |
1685 // Backward positional selectors include nth-last-child, nth-last-of-type, l
ast-of-type and only-of-type. | 1685 // Backward positional selectors include nth-last-child, nth-last-of-type, l
ast-of-type and only-of-type. |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1757 void Element::removeAllEventListeners() | 1757 void Element::removeAllEventListeners() |
1758 { | 1758 { |
1759 ContainerNode::removeAllEventListeners(); | 1759 ContainerNode::removeAllEventListeners(); |
1760 if (ElementShadow* shadow = this->shadow()) | 1760 if (ElementShadow* shadow = this->shadow()) |
1761 shadow->removeAllEventListeners(); | 1761 shadow->removeAllEventListeners(); |
1762 } | 1762 } |
1763 | 1763 |
1764 void Element::beginParsingChildren() | 1764 void Element::beginParsingChildren() |
1765 { | 1765 { |
1766 clearIsParsingChildrenFinished(); | 1766 clearIsParsingChildrenFinished(); |
1767 StyleResolver* styleResolver = document()->styleResolverIfExists(); | 1767 StyleResolver* styleResolver = document().styleResolverIfExists(); |
1768 if (styleResolver && attached()) | 1768 if (styleResolver && attached()) |
1769 styleResolver->pushParentElement(this); | 1769 styleResolver->pushParentElement(this); |
1770 } | 1770 } |
1771 | 1771 |
1772 void Element::finishParsingChildren() | 1772 void Element::finishParsingChildren() |
1773 { | 1773 { |
1774 ContainerNode::finishParsingChildren(); | 1774 ContainerNode::finishParsingChildren(); |
1775 setIsParsingChildrenFinished(); | 1775 setIsParsingChildrenFinished(); |
1776 checkForSiblingStyleChanges(this, renderStyle(), true, lastChild(), 0, 0); | 1776 checkForSiblingStyleChanges(this, renderStyle(), true, lastChild(), 0, 0); |
1777 if (StyleResolver* styleResolver = document()->styleResolverIfExists()) | 1777 if (StyleResolver* styleResolver = document().styleResolverIfExists()) |
1778 styleResolver->popParentElement(this); | 1778 styleResolver->popParentElement(this); |
1779 if (isCustomElement()) | 1779 if (isCustomElement()) |
1780 CustomElement::didFinishParsingChildren(this); | 1780 CustomElement::didFinishParsingChildren(this); |
1781 } | 1781 } |
1782 | 1782 |
1783 #ifndef NDEBUG | 1783 #ifndef NDEBUG |
1784 void Element::formatForDebugger(char* buffer, unsigned length) const | 1784 void Element::formatForDebugger(char* buffer, unsigned length) const |
1785 { | 1785 { |
1786 StringBuilder result; | 1786 StringBuilder result; |
1787 String s; | 1787 String s; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1833 } | 1833 } |
1834 | 1834 |
1835 synchronizeAllAttributes(); | 1835 synchronizeAllAttributes(); |
1836 UniqueElementData* elementData = ensureUniqueElementData(); | 1836 UniqueElementData* elementData = ensureUniqueElementData(); |
1837 | 1837 |
1838 size_t index = elementData->getAttributeItemIndex(attrNode->qualifiedName(),
shouldIgnoreAttributeCase(this)); | 1838 size_t index = elementData->getAttributeItemIndex(attrNode->qualifiedName(),
shouldIgnoreAttributeCase(this)); |
1839 if (index != notFound) { | 1839 if (index != notFound) { |
1840 if (oldAttrNode) | 1840 if (oldAttrNode) |
1841 detachAttrNodeFromElementWithValue(oldAttrNode.get(), elementData->a
ttributeItem(index)->value()); | 1841 detachAttrNodeFromElementWithValue(oldAttrNode.get(), elementData->a
ttributeItem(index)->value()); |
1842 else | 1842 else |
1843 oldAttrNode = Attr::create(document(), attrNode->qualifiedName(), el
ementData->attributeItem(index)->value()); | 1843 oldAttrNode = Attr::create(&document(), attrNode->qualifiedName(), e
lementData->attributeItem(index)->value()); |
1844 } | 1844 } |
1845 | 1845 |
1846 setAttributeInternal(index, attrNode->qualifiedName(), attrNode->value(), No
tInSynchronizationOfLazyAttribute); | 1846 setAttributeInternal(index, attrNode->qualifiedName(), attrNode->value(), No
tInSynchronizationOfLazyAttribute); |
1847 | 1847 |
1848 attrNode->attachToElement(this); | 1848 attrNode->attachToElement(this); |
1849 treeScope()->adoptIfNeeded(attrNode); | 1849 treeScope()->adoptIfNeeded(attrNode); |
1850 ensureAttrNodeListForElement(this)->append(attrNode); | 1850 ensureAttrNodeListForElement(this)->append(attrNode); |
1851 | 1851 |
1852 return oldAttrNode.release(); | 1852 return oldAttrNode.release(); |
1853 } | 1853 } |
1854 | 1854 |
1855 PassRefPtr<Attr> Element::setAttributeNodeNS(Attr* attr, ExceptionState& es) | 1855 PassRefPtr<Attr> Element::setAttributeNodeNS(Attr* attr, ExceptionState& es) |
1856 { | 1856 { |
1857 return setAttributeNode(attr, es); | 1857 return setAttributeNode(attr, es); |
1858 } | 1858 } |
1859 | 1859 |
1860 PassRefPtr<Attr> Element::removeAttributeNode(Attr* attr, ExceptionState& es) | 1860 PassRefPtr<Attr> Element::removeAttributeNode(Attr* attr, ExceptionState& es) |
1861 { | 1861 { |
1862 if (!attr) { | 1862 if (!attr) { |
1863 es.throwDOMException(TypeMismatchError); | 1863 es.throwDOMException(TypeMismatchError); |
1864 return 0; | 1864 return 0; |
1865 } | 1865 } |
1866 if (attr->ownerElement() != this) { | 1866 if (attr->ownerElement() != this) { |
1867 es.throwDOMException(NotFoundError); | 1867 es.throwDOMException(NotFoundError); |
1868 return 0; | 1868 return 0; |
1869 } | 1869 } |
1870 | 1870 |
1871 ASSERT(document() == attr->document()); | 1871 ASSERT(&document() == &attr->document()); |
1872 | 1872 |
1873 synchronizeAttribute(attr->qualifiedName()); | 1873 synchronizeAttribute(attr->qualifiedName()); |
1874 | 1874 |
1875 size_t index = elementData()->getAttrIndex(attr); | 1875 size_t index = elementData()->getAttrIndex(attr); |
1876 if (index == notFound) { | 1876 if (index == notFound) { |
1877 es.throwDOMException(NotFoundError); | 1877 es.throwDOMException(NotFoundError); |
1878 return 0; | 1878 return 0; |
1879 } | 1879 } |
1880 | 1880 |
1881 RefPtr<Attr> guard(attr); | 1881 RefPtr<Attr> guard(attr); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2000 QualifiedName qName(nullAtom, localName, namespaceURI); | 2000 QualifiedName qName(nullAtom, localName, namespaceURI); |
2001 synchronizeAttribute(qName); | 2001 synchronizeAttribute(qName); |
2002 return elementData()->getAttributeItem(qName); | 2002 return elementData()->getAttributeItem(qName); |
2003 } | 2003 } |
2004 | 2004 |
2005 void Element::focus(bool restorePreviousSelection, FocusDirection direction) | 2005 void Element::focus(bool restorePreviousSelection, FocusDirection direction) |
2006 { | 2006 { |
2007 if (!inDocument()) | 2007 if (!inDocument()) |
2008 return; | 2008 return; |
2009 | 2009 |
2010 Document* doc = document(); | 2010 Document& doc = document(); |
2011 if (doc->focusedElement() == this) | 2011 if (doc.focusedElement() == this) |
2012 return; | 2012 return; |
2013 | 2013 |
2014 // If the stylesheets have already been loaded we can reliably check isFocus
able. | 2014 // If the stylesheets have already been loaded we can reliably check isFocus
able. |
2015 // If not, we continue and set the focused node on the focus controller belo
w so | 2015 // If not, we continue and set the focused node on the focus controller belo
w so |
2016 // that it can be updated soon after attach. | 2016 // that it can be updated soon after attach. |
2017 if (doc->haveStylesheetsLoaded()) { | 2017 if (doc.haveStylesheetsLoaded()) { |
2018 doc->updateLayoutIgnorePendingStylesheets(); | 2018 doc.updateLayoutIgnorePendingStylesheets(); |
2019 if (!isFocusable()) | 2019 if (!isFocusable()) |
2020 return; | 2020 return; |
2021 } | 2021 } |
2022 | 2022 |
2023 if (!supportsFocus()) | 2023 if (!supportsFocus()) |
2024 return; | 2024 return; |
2025 | 2025 |
2026 RefPtr<Node> protect; | 2026 RefPtr<Node> protect; |
2027 if (Page* page = doc->page()) { | 2027 if (Page* page = doc.page()) { |
2028 // Focus and change event handlers can cause us to lose our last ref. | 2028 // Focus and change event handlers can cause us to lose our last ref. |
2029 // If a focus event handler changes the focus to a different node it | 2029 // If a focus event handler changes the focus to a different node it |
2030 // does not make sense to continue and update appearence. | 2030 // does not make sense to continue and update appearence. |
2031 protect = this; | 2031 protect = this; |
2032 if (!page->focusController().setFocusedElement(this, doc->frame(), direc
tion)) | 2032 if (!page->focusController().setFocusedElement(this, doc.frame(), direct
ion)) |
2033 return; | 2033 return; |
2034 } | 2034 } |
2035 | 2035 |
2036 // Setting the focused node above might have invalidated the layout due to s
cripts. | 2036 // Setting the focused node above might have invalidated the layout due to s
cripts. |
2037 doc->updateLayoutIgnorePendingStylesheets(); | 2037 doc.updateLayoutIgnorePendingStylesheets(); |
2038 | 2038 |
2039 if (!isFocusable()) { | 2039 if (!isFocusable()) { |
2040 ensureElementRareData()->setNeedsFocusAppearanceUpdateSoonAfterAttach(tr
ue); | 2040 ensureElementRareData()->setNeedsFocusAppearanceUpdateSoonAfterAttach(tr
ue); |
2041 return; | 2041 return; |
2042 } | 2042 } |
2043 | 2043 |
2044 cancelFocusAppearanceUpdate(); | 2044 cancelFocusAppearanceUpdate(); |
2045 updateFocusAppearance(restorePreviousSelection); | 2045 updateFocusAppearance(restorePreviousSelection); |
2046 } | 2046 } |
2047 | 2047 |
2048 void Element::updateFocusAppearance(bool /*restorePreviousSelection*/) | 2048 void Element::updateFocusAppearance(bool /*restorePreviousSelection*/) |
2049 { | 2049 { |
2050 if (isRootEditableElement()) { | 2050 if (isRootEditableElement()) { |
2051 Frame* frame = document()->frame(); | 2051 Frame* frame = document().frame(); |
2052 if (!frame) | 2052 if (!frame) |
2053 return; | 2053 return; |
2054 | 2054 |
2055 // When focusing an editable element in an iframe, don't reset the selec
tion if it already contains a selection. | 2055 // When focusing an editable element in an iframe, don't reset the selec
tion if it already contains a selection. |
2056 if (this == frame->selection()->rootEditableElement()) | 2056 if (this == frame->selection()->rootEditableElement()) |
2057 return; | 2057 return; |
2058 | 2058 |
2059 // FIXME: We should restore the previous selection if there is one. | 2059 // FIXME: We should restore the previous selection if there is one. |
2060 VisibleSelection newSelection = VisibleSelection(firstPositionInOrBefore
Node(this), DOWNSTREAM); | 2060 VisibleSelection newSelection = VisibleSelection(firstPositionInOrBefore
Node(this), DOWNSTREAM); |
2061 | 2061 |
2062 if (frame->selection()->shouldChangeSelection(newSelection)) { | 2062 if (frame->selection()->shouldChangeSelection(newSelection)) { |
2063 frame->selection()->setSelection(newSelection); | 2063 frame->selection()->setSelection(newSelection); |
2064 frame->selection()->revealSelection(); | 2064 frame->selection()->revealSelection(); |
2065 } | 2065 } |
2066 } else if (renderer() && !renderer()->isWidget()) | 2066 } else if (renderer() && !renderer()->isWidget()) |
2067 renderer()->scrollRectToVisible(boundingBox()); | 2067 renderer()->scrollRectToVisible(boundingBox()); |
2068 } | 2068 } |
2069 | 2069 |
2070 void Element::blur() | 2070 void Element::blur() |
2071 { | 2071 { |
2072 cancelFocusAppearanceUpdate(); | 2072 cancelFocusAppearanceUpdate(); |
2073 if (treeScope()->adjustedFocusedElement() == this) { | 2073 if (treeScope()->adjustedFocusedElement() == this) { |
2074 Document* doc = document(); | 2074 Document& doc = document(); |
2075 if (doc->page()) | 2075 if (doc.page()) |
2076 doc->page()->focusController().setFocusedElement(0, doc->frame()); | 2076 doc.page()->focusController().setFocusedElement(0, doc.frame()); |
2077 else | 2077 else |
2078 doc->setFocusedElement(0); | 2078 doc.setFocusedElement(0); |
2079 } | 2079 } |
2080 } | 2080 } |
2081 | 2081 |
2082 bool Element::isFocusable() const | 2082 bool Element::isFocusable() const |
2083 { | 2083 { |
2084 return inDocument() && supportsFocus() && !isInert() && rendererIsFocusable(
); | 2084 return inDocument() && supportsFocus() && !isInert() && rendererIsFocusable(
); |
2085 } | 2085 } |
2086 | 2086 |
2087 bool Element::isKeyboardFocusable() const | 2087 bool Element::isKeyboardFocusable() const |
2088 { | 2088 { |
2089 return isFocusable() && tabIndex() >= 0; | 2089 return isFocusable() && tabIndex() >= 0; |
2090 } | 2090 } |
2091 | 2091 |
2092 bool Element::isMouseFocusable() const | 2092 bool Element::isMouseFocusable() const |
2093 { | 2093 { |
2094 return isFocusable(); | 2094 return isFocusable(); |
2095 } | 2095 } |
2096 | 2096 |
2097 void Element::dispatchFocusEvent(Element* oldFocusedElement, FocusDirection) | 2097 void Element::dispatchFocusEvent(Element* oldFocusedElement, FocusDirection) |
2098 { | 2098 { |
2099 RefPtr<FocusEvent> event = FocusEvent::create(eventNames().focusEvent, false
, false, document()->defaultView(), 0, oldFocusedElement); | 2099 RefPtr<FocusEvent> event = FocusEvent::create(eventNames().focusEvent, false
, false, document().defaultView(), 0, oldFocusedElement); |
2100 EventDispatcher::dispatchEvent(this, FocusEventDispatchMediator::create(even
t.release())); | 2100 EventDispatcher::dispatchEvent(this, FocusEventDispatchMediator::create(even
t.release())); |
2101 } | 2101 } |
2102 | 2102 |
2103 void Element::dispatchBlurEvent(Element* newFocusedElement) | 2103 void Element::dispatchBlurEvent(Element* newFocusedElement) |
2104 { | 2104 { |
2105 RefPtr<FocusEvent> event = FocusEvent::create(eventNames().blurEvent, false,
false, document()->defaultView(), 0, newFocusedElement); | 2105 RefPtr<FocusEvent> event = FocusEvent::create(eventNames().blurEvent, false,
false, document().defaultView(), 0, newFocusedElement); |
2106 EventDispatcher::dispatchEvent(this, BlurEventDispatchMediator::create(event
.release())); | 2106 EventDispatcher::dispatchEvent(this, BlurEventDispatchMediator::create(event
.release())); |
2107 } | 2107 } |
2108 | 2108 |
2109 void Element::dispatchFocusInEvent(const AtomicString& eventType, Element* oldFo
cusedElement) | 2109 void Element::dispatchFocusInEvent(const AtomicString& eventType, Element* oldFo
cusedElement) |
2110 { | 2110 { |
2111 ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden()); | 2111 ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden()); |
2112 ASSERT(eventType == eventNames().focusinEvent || eventType == eventNames().D
OMFocusInEvent); | 2112 ASSERT(eventType == eventNames().focusinEvent || eventType == eventNames().D
OMFocusInEvent); |
2113 dispatchScopedEventDispatchMediator(FocusInEventDispatchMediator::create(Foc
usEvent::create(eventType, true, false, document()->defaultView(), 0, oldFocused
Element))); | 2113 dispatchScopedEventDispatchMediator(FocusInEventDispatchMediator::create(Foc
usEvent::create(eventType, true, false, document().defaultView(), 0, oldFocusedE
lement))); |
2114 } | 2114 } |
2115 | 2115 |
2116 void Element::dispatchFocusOutEvent(const AtomicString& eventType, Element* newF
ocusedElement) | 2116 void Element::dispatchFocusOutEvent(const AtomicString& eventType, Element* newF
ocusedElement) |
2117 { | 2117 { |
2118 ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden()); | 2118 ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden()); |
2119 ASSERT(eventType == eventNames().focusoutEvent || eventType == eventNames().
DOMFocusOutEvent); | 2119 ASSERT(eventType == eventNames().focusoutEvent || eventType == eventNames().
DOMFocusOutEvent); |
2120 dispatchScopedEventDispatchMediator(FocusOutEventDispatchMediator::create(Fo
cusEvent::create(eventType, true, false, document()->defaultView(), 0, newFocuse
dElement))); | 2120 dispatchScopedEventDispatchMediator(FocusOutEventDispatchMediator::create(Fo
cusEvent::create(eventType, true, false, document().defaultView(), 0, newFocused
Element))); |
2121 } | 2121 } |
2122 | 2122 |
2123 String Element::innerText() | 2123 String Element::innerText() |
2124 { | 2124 { |
2125 // We need to update layout, since plainText uses line boxes in the render t
ree. | 2125 // We need to update layout, since plainText uses line boxes in the render t
ree. |
2126 document()->updateLayoutIgnorePendingStylesheets(); | 2126 document().updateLayoutIgnorePendingStylesheets(); |
2127 | 2127 |
2128 if (!renderer()) | 2128 if (!renderer()) |
2129 return textContent(true); | 2129 return textContent(true); |
2130 | 2130 |
2131 return plainText(rangeOfContents(const_cast<Element*>(this)).get()); | 2131 return plainText(rangeOfContents(const_cast<Element*>(this)).get()); |
2132 } | 2132 } |
2133 | 2133 |
2134 String Element::outerText() | 2134 String Element::outerText() |
2135 { | 2135 { |
2136 // Getting outerText is the same as getting innerText, only | 2136 // Getting outerText is the same as getting innerText, only |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2225 return usedStyle; | 2225 return usedStyle; |
2226 } | 2226 } |
2227 | 2227 |
2228 if (!attached()) | 2228 if (!attached()) |
2229 // FIXME: Try to do better than this. Ensure that styleForElement() work
s for elements that are not in the | 2229 // FIXME: Try to do better than this. Ensure that styleForElement() work
s for elements that are not in the |
2230 // document tree and figure out when to destroy the computed style for s
uch elements. | 2230 // document tree and figure out when to destroy the computed style for s
uch elements. |
2231 return 0; | 2231 return 0; |
2232 | 2232 |
2233 ElementRareData* data = ensureElementRareData(); | 2233 ElementRareData* data = ensureElementRareData(); |
2234 if (!data->computedStyle()) | 2234 if (!data->computedStyle()) |
2235 data->setComputedStyle(document()->styleForElementIgnoringPendingStylesh
eets(this)); | 2235 data->setComputedStyle(document().styleForElementIgnoringPendingStyleshe
ets(this)); |
2236 return pseudoElementSpecifier ? data->computedStyle()->getCachedPseudoStyle(
pseudoElementSpecifier) : data->computedStyle(); | 2236 return pseudoElementSpecifier ? data->computedStyle()->getCachedPseudoStyle(
pseudoElementSpecifier) : data->computedStyle(); |
2237 } | 2237 } |
2238 | 2238 |
2239 void Element::setStyleAffectedByEmpty() | 2239 void Element::setStyleAffectedByEmpty() |
2240 { | 2240 { |
2241 ensureElementRareData()->setStyleAffectedByEmpty(true); | 2241 ensureElementRareData()->setStyleAffectedByEmpty(true); |
2242 } | 2242 } |
2243 | 2243 |
2244 void Element::setChildrenAffectedByHover(bool value) | 2244 void Element::setChildrenAffectedByHover(bool value) |
2245 { | 2245 { |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2419 } | 2419 } |
2420 | 2420 |
2421 n = n->parentNode(); | 2421 n = n->parentNode(); |
2422 } while (n && value.isNull()); | 2422 } while (n && value.isNull()); |
2423 | 2423 |
2424 return value; | 2424 return value; |
2425 } | 2425 } |
2426 | 2426 |
2427 Locale& Element::locale() const | 2427 Locale& Element::locale() const |
2428 { | 2428 { |
2429 return document()->getCachedLocale(computeInheritedLanguage()); | 2429 return document().getCachedLocale(computeInheritedLanguage()); |
2430 } | 2430 } |
2431 | 2431 |
2432 void Element::cancelFocusAppearanceUpdate() | 2432 void Element::cancelFocusAppearanceUpdate() |
2433 { | 2433 { |
2434 if (hasRareData()) | 2434 if (hasRareData()) |
2435 elementRareData()->setNeedsFocusAppearanceUpdateSoonAfterAttach(false); | 2435 elementRareData()->setNeedsFocusAppearanceUpdateSoonAfterAttach(false); |
2436 if (document()->focusedElement() == this) | 2436 if (document().focusedElement() == this) |
2437 document()->cancelFocusAppearanceUpdate(); | 2437 document().cancelFocusAppearanceUpdate(); |
2438 } | 2438 } |
2439 | 2439 |
2440 void Element::normalizeAttributes() | 2440 void Element::normalizeAttributes() |
2441 { | 2441 { |
2442 if (!hasAttributes()) | 2442 if (!hasAttributes()) |
2443 return; | 2443 return; |
2444 for (unsigned i = 0; i < attributeCount(); ++i) { | 2444 for (unsigned i = 0; i < attributeCount(); ++i) { |
2445 if (RefPtr<Attr> attr = attrIfExists(attributeItem(i)->name())) | 2445 if (RefPtr<Attr> attr = attrIfExists(attributeItem(i)->name())) |
2446 attr->normalize(); | 2446 attr->normalize(); |
2447 } | 2447 } |
(...skipping 24 matching lines...) Expand all Loading... |
2472 | 2472 |
2473 if (!renderer() || !pseudoElementRendererIsNeeded(renderer()->getCachedPseud
oStyle(pseudoId))) | 2473 if (!renderer() || !pseudoElementRendererIsNeeded(renderer()->getCachedPseud
oStyle(pseudoId))) |
2474 return; | 2474 return; |
2475 | 2475 |
2476 if (!renderer()->canHaveGeneratedChildren()) | 2476 if (!renderer()->canHaveGeneratedChildren()) |
2477 return; | 2477 return; |
2478 | 2478 |
2479 ASSERT(!isPseudoElement()); | 2479 ASSERT(!isPseudoElement()); |
2480 RefPtr<PseudoElement> element = PseudoElement::create(this, pseudoId); | 2480 RefPtr<PseudoElement> element = PseudoElement::create(this, pseudoId); |
2481 if (pseudoId == BACKDROP) | 2481 if (pseudoId == BACKDROP) |
2482 document()->addToTopLayer(element.get(), this); | 2482 document().addToTopLayer(element.get(), this); |
2483 element->attach(); | 2483 element->attach(); |
2484 | 2484 |
2485 ensureElementRareData()->setPseudoElement(pseudoId, element.release()); | 2485 ensureElementRareData()->setPseudoElement(pseudoId, element.release()); |
2486 } | 2486 } |
2487 | 2487 |
2488 PseudoElement* Element::pseudoElement(PseudoId pseudoId) const | 2488 PseudoElement* Element::pseudoElement(PseudoId pseudoId) const |
2489 { | 2489 { |
2490 return hasRareData() ? elementRareData()->pseudoElement(pseudoId) : 0; | 2490 return hasRareData() ? elementRareData()->pseudoElement(pseudoId) : 0; |
2491 } | 2491 } |
2492 | 2492 |
2493 RenderObject* Element::pseudoElementRenderer(PseudoId pseudoId) const | 2493 RenderObject* Element::pseudoElementRenderer(PseudoId pseudoId) const |
2494 { | 2494 { |
2495 if (PseudoElement* element = pseudoElement(pseudoId)) | 2495 if (PseudoElement* element = pseudoElement(pseudoId)) |
2496 return element->renderer(); | 2496 return element->renderer(); |
2497 return 0; | 2497 return 0; |
2498 } | 2498 } |
2499 | 2499 |
2500 bool Element::webkitMatchesSelector(const String& selector, ExceptionState& es) | 2500 bool Element::webkitMatchesSelector(const String& selector, ExceptionState& es) |
2501 { | 2501 { |
2502 if (selector.isEmpty()) { | 2502 if (selector.isEmpty()) { |
2503 es.throwDOMException(SyntaxError); | 2503 es.throwDOMException(SyntaxError); |
2504 return false; | 2504 return false; |
2505 } | 2505 } |
2506 | 2506 |
2507 SelectorQuery* selectorQuery = document()->selectorQueryCache()->add(selecto
r, document(), es); | 2507 SelectorQuery* selectorQuery = document().selectorQueryCache()->add(selector
, &document(), es); |
2508 if (!selectorQuery) | 2508 if (!selectorQuery) |
2509 return false; | 2509 return false; |
2510 return selectorQuery->matches(this); | 2510 return selectorQuery->matches(this); |
2511 } | 2511 } |
2512 | 2512 |
2513 DOMTokenList* Element::classList() | 2513 DOMTokenList* Element::classList() |
2514 { | 2514 { |
2515 ElementRareData* data = ensureElementRareData(); | 2515 ElementRareData* data = ensureElementRareData(); |
2516 if (!data->classList()) | 2516 if (!data->classList()) |
2517 data->setClassList(ClassList::create(this)); | 2517 data->setClassList(ClassList::create(this)); |
2518 return data->classList(); | 2518 return data->classList(); |
2519 } | 2519 } |
2520 | 2520 |
2521 DOMStringMap* Element::dataset() | 2521 DOMStringMap* Element::dataset() |
2522 { | 2522 { |
2523 ElementRareData* data = ensureElementRareData(); | 2523 ElementRareData* data = ensureElementRareData(); |
2524 if (!data->dataset()) | 2524 if (!data->dataset()) |
2525 data->setDataset(DatasetDOMStringMap::create(this)); | 2525 data->setDataset(DatasetDOMStringMap::create(this)); |
2526 return data->dataset(); | 2526 return data->dataset(); |
2527 } | 2527 } |
2528 | 2528 |
2529 KURL Element::getURLAttribute(const QualifiedName& name) const | 2529 KURL Element::getURLAttribute(const QualifiedName& name) const |
2530 { | 2530 { |
2531 #if !ASSERT_DISABLED | 2531 #if !ASSERT_DISABLED |
2532 if (elementData()) { | 2532 if (elementData()) { |
2533 if (const Attribute* attribute = getAttributeItem(name)) | 2533 if (const Attribute* attribute = getAttributeItem(name)) |
2534 ASSERT(isURLAttribute(*attribute)); | 2534 ASSERT(isURLAttribute(*attribute)); |
2535 } | 2535 } |
2536 #endif | 2536 #endif |
2537 return document()->completeURL(stripLeadingAndTrailingHTMLSpaces(getAttribut
e(name))); | 2537 return document().completeURL(stripLeadingAndTrailingHTMLSpaces(getAttribute
(name))); |
2538 } | 2538 } |
2539 | 2539 |
2540 KURL Element::getNonEmptyURLAttribute(const QualifiedName& name) const | 2540 KURL Element::getNonEmptyURLAttribute(const QualifiedName& name) const |
2541 { | 2541 { |
2542 #if !ASSERT_DISABLED | 2542 #if !ASSERT_DISABLED |
2543 if (elementData()) { | 2543 if (elementData()) { |
2544 if (const Attribute* attribute = getAttributeItem(name)) | 2544 if (const Attribute* attribute = getAttributeItem(name)) |
2545 ASSERT(isURLAttribute(*attribute)); | 2545 ASSERT(isURLAttribute(*attribute)); |
2546 } | 2546 } |
2547 #endif | 2547 #endif |
2548 String value = stripLeadingAndTrailingHTMLSpaces(getAttribute(name)); | 2548 String value = stripLeadingAndTrailingHTMLSpaces(getAttribute(name)); |
2549 if (value.isEmpty()) | 2549 if (value.isEmpty()) |
2550 return KURL(); | 2550 return KURL(); |
2551 return document()->completeURL(value); | 2551 return document().completeURL(value); |
2552 } | 2552 } |
2553 | 2553 |
2554 int Element::getIntegralAttribute(const QualifiedName& attributeName) const | 2554 int Element::getIntegralAttribute(const QualifiedName& attributeName) const |
2555 { | 2555 { |
2556 return getAttribute(attributeName).string().toInt(); | 2556 return getAttribute(attributeName).string().toInt(); |
2557 } | 2557 } |
2558 | 2558 |
2559 void Element::setIntegralAttribute(const QualifiedName& attributeName, int value
) | 2559 void Element::setIntegralAttribute(const QualifiedName& attributeName, int value
) |
2560 { | 2560 { |
2561 // FIXME: Need an AtomicString version of String::number. | 2561 // FIXME: Need an AtomicString version of String::number. |
(...skipping 15 matching lines...) Expand all Loading... |
2577 { | 2577 { |
2578 // Only create renderers for SVG elements whose parents are SVG elements, or
for proper <svg xmlns="svgNS"> subdocuments. | 2578 // Only create renderers for SVG elements whose parents are SVG elements, or
for proper <svg xmlns="svgNS"> subdocuments. |
2579 if (childContext.node()->isSVGElement()) | 2579 if (childContext.node()->isSVGElement()) |
2580 return childContext.node()->hasTagName(SVGNames::svgTag) || isSVGElement
(); | 2580 return childContext.node()->hasTagName(SVGNames::svgTag) || isSVGElement
(); |
2581 | 2581 |
2582 return ContainerNode::childShouldCreateRenderer(childContext); | 2582 return ContainerNode::childShouldCreateRenderer(childContext); |
2583 } | 2583 } |
2584 | 2584 |
2585 void Element::webkitRequestFullscreen() | 2585 void Element::webkitRequestFullscreen() |
2586 { | 2586 { |
2587 FullscreenElementStack::from(document())->requestFullScreenForElement(this,
ALLOW_KEYBOARD_INPUT, FullscreenElementStack::EnforceIFrameAllowFullScreenRequir
ement); | 2587 FullscreenElementStack::from(&document())->requestFullScreenForElement(this,
ALLOW_KEYBOARD_INPUT, FullscreenElementStack::EnforceIFrameAllowFullScreenRequi
rement); |
2588 } | 2588 } |
2589 | 2589 |
2590 void Element::webkitRequestFullScreen(unsigned short flags) | 2590 void Element::webkitRequestFullScreen(unsigned short flags) |
2591 { | 2591 { |
2592 FullscreenElementStack::from(document())->requestFullScreenForElement(this,
(flags | LEGACY_MOZILLA_REQUEST), FullscreenElementStack::EnforceIFrameAllowFull
ScreenRequirement); | 2592 FullscreenElementStack::from(&document())->requestFullScreenForElement(this,
(flags | LEGACY_MOZILLA_REQUEST), FullscreenElementStack::EnforceIFrameAllowFul
lScreenRequirement); |
2593 } | 2593 } |
2594 | 2594 |
2595 bool Element::containsFullScreenElement() const | 2595 bool Element::containsFullScreenElement() const |
2596 { | 2596 { |
2597 return hasRareData() && elementRareData()->containsFullScreenElement(); | 2597 return hasRareData() && elementRareData()->containsFullScreenElement(); |
2598 } | 2598 } |
2599 | 2599 |
2600 void Element::setContainsFullScreenElement(bool flag) | 2600 void Element::setContainsFullScreenElement(bool flag) |
2601 { | 2601 { |
2602 ensureElementRareData()->setContainsFullScreenElement(flag); | 2602 ensureElementRareData()->setContainsFullScreenElement(flag); |
2603 setNeedsStyleRecalc(SubtreeStyleChange); | 2603 setNeedsStyleRecalc(SubtreeStyleChange); |
2604 } | 2604 } |
2605 | 2605 |
2606 static Element* parentCrossingFrameBoundaries(Element* element) | 2606 static Element* parentCrossingFrameBoundaries(Element* element) |
2607 { | 2607 { |
2608 ASSERT(element); | 2608 ASSERT(element); |
2609 return element->parentElement() ? element->parentElement() : element->docume
nt()->ownerElement(); | 2609 return element->parentElement() ? element->parentElement() : element->docume
nt().ownerElement(); |
2610 } | 2610 } |
2611 | 2611 |
2612 void Element::setContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(boo
l flag) | 2612 void Element::setContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(boo
l flag) |
2613 { | 2613 { |
2614 Element* element = this; | 2614 Element* element = this; |
2615 while ((element = parentCrossingFrameBoundaries(element))) | 2615 while ((element = parentCrossingFrameBoundaries(element))) |
2616 element->setContainsFullScreenElement(flag); | 2616 element->setContainsFullScreenElement(flag); |
2617 } | 2617 } |
2618 | 2618 |
2619 bool Element::isInTopLayer() const | 2619 bool Element::isInTopLayer() const |
2620 { | 2620 { |
2621 return hasRareData() && elementRareData()->isInTopLayer(); | 2621 return hasRareData() && elementRareData()->isInTopLayer(); |
2622 } | 2622 } |
2623 | 2623 |
2624 void Element::setIsInTopLayer(bool inTopLayer) | 2624 void Element::setIsInTopLayer(bool inTopLayer) |
2625 { | 2625 { |
2626 if (isInTopLayer() == inTopLayer) | 2626 if (isInTopLayer() == inTopLayer) |
2627 return; | 2627 return; |
2628 ensureElementRareData()->setIsInTopLayer(inTopLayer); | 2628 ensureElementRareData()->setIsInTopLayer(inTopLayer); |
2629 | 2629 |
2630 // We must ensure a reattach occurs so the renderer is inserted in the corre
ct sibling order under RenderView according to its | 2630 // We must ensure a reattach occurs so the renderer is inserted in the corre
ct sibling order under RenderView according to its |
2631 // top layer position, or in its usual place if not in the top layer. | 2631 // top layer position, or in its usual place if not in the top layer. |
2632 lazyReattachIfAttached(); | 2632 lazyReattachIfAttached(); |
2633 } | 2633 } |
2634 | 2634 |
2635 void Element::webkitRequestPointerLock() | 2635 void Element::webkitRequestPointerLock() |
2636 { | 2636 { |
2637 if (document()->page()) | 2637 if (document().page()) |
2638 document()->page()->pointerLockController().requestPointerLock(this); | 2638 document().page()->pointerLockController().requestPointerLock(this); |
2639 } | 2639 } |
2640 | 2640 |
2641 SpellcheckAttributeState Element::spellcheckAttributeState() const | 2641 SpellcheckAttributeState Element::spellcheckAttributeState() const |
2642 { | 2642 { |
2643 const AtomicString& value = getAttribute(HTMLNames::spellcheckAttr); | 2643 const AtomicString& value = getAttribute(HTMLNames::spellcheckAttr); |
2644 if (value == nullAtom) | 2644 if (value == nullAtom) |
2645 return SpellcheckAttributeDefault; | 2645 return SpellcheckAttributeDefault; |
2646 if (equalIgnoringCase(value, "true") || equalIgnoringCase(value, "")) | 2646 if (equalIgnoringCase(value, "true") || equalIgnoringCase(value, "")) |
2647 return SpellcheckAttributeTrue; | 2647 return SpellcheckAttributeTrue; |
2648 if (equalIgnoringCase(value, "false")) | 2648 if (equalIgnoringCase(value, "false")) |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2686 return false; | 2686 return false; |
2687 | 2687 |
2688 if (styleToUse->flowThread().isEmpty()) | 2688 if (styleToUse->flowThread().isEmpty()) |
2689 return false; | 2689 return false; |
2690 | 2690 |
2691 return !isRegisteredWithNamedFlow(); | 2691 return !isRegisteredWithNamedFlow(); |
2692 } | 2692 } |
2693 | 2693 |
2694 const AtomicString& Element::webkitRegionOverset() const | 2694 const AtomicString& Element::webkitRegionOverset() const |
2695 { | 2695 { |
2696 document()->updateLayoutIgnorePendingStylesheets(); | 2696 document().updateLayoutIgnorePendingStylesheets(); |
2697 | 2697 |
2698 DEFINE_STATIC_LOCAL(AtomicString, undefinedState, ("undefined", AtomicString
::ConstructFromLiteral)); | 2698 DEFINE_STATIC_LOCAL(AtomicString, undefinedState, ("undefined", AtomicString
::ConstructFromLiteral)); |
2699 if (!RuntimeEnabledFeatures::cssRegionsEnabled() || !renderRegion()) | 2699 if (!RuntimeEnabledFeatures::cssRegionsEnabled() || !renderRegion()) |
2700 return undefinedState; | 2700 return undefinedState; |
2701 | 2701 |
2702 switch (renderRegion()->regionOversetState()) { | 2702 switch (renderRegion()->regionOversetState()) { |
2703 case RegionFit: { | 2703 case RegionFit: { |
2704 DEFINE_STATIC_LOCAL(AtomicString, fitState, ("fit", AtomicString::Constr
uctFromLiteral)); | 2704 DEFINE_STATIC_LOCAL(AtomicString, fitState, ("fit", AtomicString::Constr
uctFromLiteral)); |
2705 return fitState; | 2705 return fitState; |
2706 } | 2706 } |
2707 case RegionEmpty: { | 2707 case RegionEmpty: { |
2708 DEFINE_STATIC_LOCAL(AtomicString, emptyState, ("empty", AtomicString::Co
nstructFromLiteral)); | 2708 DEFINE_STATIC_LOCAL(AtomicString, emptyState, ("empty", AtomicString::Co
nstructFromLiteral)); |
2709 return emptyState; | 2709 return emptyState; |
2710 } | 2710 } |
2711 case RegionOverset: { | 2711 case RegionOverset: { |
2712 DEFINE_STATIC_LOCAL(AtomicString, overflowState, ("overset", AtomicStrin
g::ConstructFromLiteral)); | 2712 DEFINE_STATIC_LOCAL(AtomicString, overflowState, ("overset", AtomicStrin
g::ConstructFromLiteral)); |
2713 return overflowState; | 2713 return overflowState; |
2714 } | 2714 } |
2715 case RegionUndefined: | 2715 case RegionUndefined: |
2716 return undefinedState; | 2716 return undefinedState; |
2717 } | 2717 } |
2718 | 2718 |
2719 ASSERT_NOT_REACHED(); | 2719 ASSERT_NOT_REACHED(); |
2720 return undefinedState; | 2720 return undefinedState; |
2721 } | 2721 } |
2722 | 2722 |
2723 Vector<RefPtr<Range> > Element::webkitGetRegionFlowRanges() const | 2723 Vector<RefPtr<Range> > Element::webkitGetRegionFlowRanges() const |
2724 { | 2724 { |
2725 document()->updateLayoutIgnorePendingStylesheets(); | 2725 document().updateLayoutIgnorePendingStylesheets(); |
2726 | 2726 |
2727 Vector<RefPtr<Range> > rangeObjects; | 2727 Vector<RefPtr<Range> > rangeObjects; |
2728 if (RuntimeEnabledFeatures::cssRegionsEnabled() && renderer() && renderer()-
>isRenderRegion()) { | 2728 if (RuntimeEnabledFeatures::cssRegionsEnabled() && renderer() && renderer()-
>isRenderRegion()) { |
2729 RenderRegion* region = toRenderRegion(renderer()); | 2729 RenderRegion* region = toRenderRegion(renderer()); |
2730 if (region->isValid()) | 2730 if (region->isValid()) |
2731 region->getRanges(rangeObjects); | 2731 region->getRanges(rangeObjects); |
2732 } | 2732 } |
2733 | 2733 |
2734 return rangeObjects; | 2734 return rangeObjects; |
2735 } | 2735 } |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2818 updateId(oldValue, newValue); | 2818 updateId(oldValue, newValue); |
2819 else if (name == HTMLNames::nameAttr) | 2819 else if (name == HTMLNames::nameAttr) |
2820 updateName(oldValue, newValue); | 2820 updateName(oldValue, newValue); |
2821 else if (name == HTMLNames::forAttr && hasTagName(labelTag)) { | 2821 else if (name == HTMLNames::forAttr && hasTagName(labelTag)) { |
2822 TreeScope* scope = treeScope(); | 2822 TreeScope* scope = treeScope(); |
2823 if (scope->shouldCacheLabelsByForAttribute()) | 2823 if (scope->shouldCacheLabelsByForAttribute()) |
2824 updateLabel(scope, oldValue, newValue); | 2824 updateLabel(scope, oldValue, newValue); |
2825 } | 2825 } |
2826 | 2826 |
2827 if (oldValue != newValue) { | 2827 if (oldValue != newValue) { |
2828 if (attached() && hasSelectorForAttribute(document(), name.localName())) | 2828 if (attached() && hasSelectorForAttribute(&document(), name.localName())
) |
2829 setNeedsStyleRecalc(); | 2829 setNeedsStyleRecalc(); |
2830 | 2830 |
2831 if (isUpgradedCustomElement()) | 2831 if (isUpgradedCustomElement()) |
2832 CustomElement::attributeDidChange(this, name.localName(), oldValue,
newValue); | 2832 CustomElement::attributeDidChange(this, name.localName(), oldValue,
newValue); |
2833 } | 2833 } |
2834 | 2834 |
2835 if (OwnPtr<MutationObserverInterestGroup> recipients = MutationObserverInter
estGroup::createForAttributesMutation(this, name)) | 2835 if (OwnPtr<MutationObserverInterestGroup> recipients = MutationObserverInter
estGroup::createForAttributesMutation(this, name)) |
2836 recipients->enqueueMutationRecord(MutationRecord::createAttributes(this,
name, oldValue)); | 2836 recipients->enqueueMutationRecord(MutationRecord::createAttributes(this,
name, oldValue)); |
2837 | 2837 |
2838 InspectorInstrumentation::willModifyDOMAttr(document(), this, oldValue, newV
alue); | 2838 InspectorInstrumentation::willModifyDOMAttr(&document(), this, oldValue, new
Value); |
2839 } | 2839 } |
2840 | 2840 |
2841 void Element::didAddAttribute(const QualifiedName& name, const AtomicString& val
ue) | 2841 void Element::didAddAttribute(const QualifiedName& name, const AtomicString& val
ue) |
2842 { | 2842 { |
2843 attributeChanged(name, value); | 2843 attributeChanged(name, value); |
2844 InspectorInstrumentation::didModifyDOMAttr(document(), this, name.localName(
), value); | 2844 InspectorInstrumentation::didModifyDOMAttr(&document(), this, name.localName
(), value); |
2845 dispatchSubtreeModifiedEvent(); | 2845 dispatchSubtreeModifiedEvent(); |
2846 } | 2846 } |
2847 | 2847 |
2848 void Element::didModifyAttribute(const QualifiedName& name, const AtomicString&
value) | 2848 void Element::didModifyAttribute(const QualifiedName& name, const AtomicString&
value) |
2849 { | 2849 { |
2850 attributeChanged(name, value); | 2850 attributeChanged(name, value); |
2851 InspectorInstrumentation::didModifyDOMAttr(document(), this, name.localName(
), value); | 2851 InspectorInstrumentation::didModifyDOMAttr(&document(), this, name.localName
(), value); |
2852 // Do not dispatch a DOMSubtreeModified event here; see bug 81141. | 2852 // Do not dispatch a DOMSubtreeModified event here; see bug 81141. |
2853 } | 2853 } |
2854 | 2854 |
2855 void Element::didRemoveAttribute(const QualifiedName& name) | 2855 void Element::didRemoveAttribute(const QualifiedName& name) |
2856 { | 2856 { |
2857 attributeChanged(name, nullAtom); | 2857 attributeChanged(name, nullAtom); |
2858 InspectorInstrumentation::didRemoveDOMAttr(document(), this, name.localName(
)); | 2858 InspectorInstrumentation::didRemoveDOMAttr(&document(), this, name.localName
()); |
2859 dispatchSubtreeModifiedEvent(); | 2859 dispatchSubtreeModifiedEvent(); |
2860 } | 2860 } |
2861 | 2861 |
2862 void Element::didMoveToNewDocument(Document* oldDocument) | 2862 void Element::didMoveToNewDocument(Document* oldDocument) |
2863 { | 2863 { |
2864 Node::didMoveToNewDocument(oldDocument); | 2864 Node::didMoveToNewDocument(oldDocument); |
2865 | 2865 |
2866 // If the documents differ by quirks mode then they differ by case sensitivi
ty | 2866 // If the documents differ by quirks mode then they differ by case sensitivi
ty |
2867 // for class and id names so we need to go through the attribute change logi
c | 2867 // for class and id names so we need to go through the attribute change logi
c |
2868 // to pick up the new casing in the ElementData. | 2868 // to pick up the new casing in the ElementData. |
2869 if (oldDocument->inQuirksMode() != document()->inQuirksMode()) { | 2869 if (oldDocument->inQuirksMode() != document().inQuirksMode()) { |
2870 if (hasID()) | 2870 if (hasID()) |
2871 setIdAttribute(getIdAttribute()); | 2871 setIdAttribute(getIdAttribute()); |
2872 if (hasClass()) | 2872 if (hasClass()) |
2873 setAttribute(HTMLNames::classAttr, getClassAttribute()); | 2873 setAttribute(HTMLNames::classAttr, getClassAttribute()); |
2874 } | 2874 } |
2875 } | 2875 } |
2876 | 2876 |
2877 void Element::updateNamedItemRegistration(const AtomicString& oldName, const Ato
micString& newName) | 2877 void Element::updateNamedItemRegistration(const AtomicString& oldName, const Ato
micString& newName) |
2878 { | 2878 { |
2879 if (!document()->isHTMLDocument()) | 2879 if (!document().isHTMLDocument()) |
2880 return; | 2880 return; |
2881 | 2881 |
2882 if (!oldName.isEmpty()) | 2882 if (!oldName.isEmpty()) |
2883 toHTMLDocument(document())->removeNamedItem(oldName); | 2883 toHTMLDocument(&document())->removeNamedItem(oldName); |
2884 | 2884 |
2885 if (!newName.isEmpty()) | 2885 if (!newName.isEmpty()) |
2886 toHTMLDocument(document())->addNamedItem(newName); | 2886 toHTMLDocument(&document())->addNamedItem(newName); |
2887 } | 2887 } |
2888 | 2888 |
2889 void Element::updateExtraNamedItemRegistration(const AtomicString& oldId, const
AtomicString& newId) | 2889 void Element::updateExtraNamedItemRegistration(const AtomicString& oldId, const
AtomicString& newId) |
2890 { | 2890 { |
2891 if (!document()->isHTMLDocument()) | 2891 if (!document().isHTMLDocument()) |
2892 return; | 2892 return; |
2893 | 2893 |
2894 if (!oldId.isEmpty()) | 2894 if (!oldId.isEmpty()) |
2895 toHTMLDocument(document())->removeExtraNamedItem(oldId); | 2895 toHTMLDocument(&document())->removeExtraNamedItem(oldId); |
2896 | 2896 |
2897 if (!newId.isEmpty()) | 2897 if (!newId.isEmpty()) |
2898 toHTMLDocument(document())->addExtraNamedItem(newId); | 2898 toHTMLDocument(&document())->addExtraNamedItem(newId); |
2899 } | 2899 } |
2900 | 2900 |
2901 PassRefPtr<HTMLCollection> Element::ensureCachedHTMLCollection(CollectionType ty
pe) | 2901 PassRefPtr<HTMLCollection> Element::ensureCachedHTMLCollection(CollectionType ty
pe) |
2902 { | 2902 { |
2903 if (HTMLCollection* collection = cachedHTMLCollection(type)) | 2903 if (HTMLCollection* collection = cachedHTMLCollection(type)) |
2904 return collection; | 2904 return collection; |
2905 | 2905 |
2906 RefPtr<HTMLCollection> collection; | 2906 RefPtr<HTMLCollection> collection; |
2907 if (type == TableRows) { | 2907 if (type == TableRows) { |
2908 ASSERT(hasTagName(tableTag)); | 2908 ASSERT(hasTagName(tableTag)); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3036 const AtomicString& oldName = getNameAttribute(); | 3036 const AtomicString& oldName = getNameAttribute(); |
3037 const AtomicString& newName = other.getNameAttribute(); | 3037 const AtomicString& newName = other.getNameAttribute(); |
3038 | 3038 |
3039 if (!oldName.isNull() || !newName.isNull()) | 3039 if (!oldName.isNull() || !newName.isNull()) |
3040 updateName(oldName, newName); | 3040 updateName(oldName, newName); |
3041 | 3041 |
3042 // Quirks mode makes class and id not case sensitive. We can't share the Ele
mentData | 3042 // Quirks mode makes class and id not case sensitive. We can't share the Ele
mentData |
3043 // if the idForStyleResolution and the className need different casing. | 3043 // if the idForStyleResolution and the className need different casing. |
3044 bool ownerDocumentsHaveDifferentCaseSensitivity = false; | 3044 bool ownerDocumentsHaveDifferentCaseSensitivity = false; |
3045 if (other.hasClass() || other.hasID()) | 3045 if (other.hasClass() || other.hasID()) |
3046 ownerDocumentsHaveDifferentCaseSensitivity = other.document()->inQuirksM
ode() != document()->inQuirksMode(); | 3046 ownerDocumentsHaveDifferentCaseSensitivity = other.document().inQuirksMo
de() != document().inQuirksMode(); |
3047 | 3047 |
3048 // If 'other' has a mutable ElementData, convert it to an immutable one so w
e can share it between both elements. | 3048 // If 'other' has a mutable ElementData, convert it to an immutable one so w
e can share it between both elements. |
3049 // We can only do this if there is no CSSOM wrapper for other's inline style
, and there are no presentation attributes, | 3049 // We can only do this if there is no CSSOM wrapper for other's inline style
, and there are no presentation attributes, |
3050 // and sharing the data won't result in different case sensitivity of class
or id. | 3050 // and sharing the data won't result in different case sensitivity of class
or id. |
3051 if (other.m_elementData->isUnique() | 3051 if (other.m_elementData->isUnique() |
3052 && !ownerDocumentsHaveDifferentCaseSensitivity | 3052 && !ownerDocumentsHaveDifferentCaseSensitivity |
3053 && !other.m_elementData->presentationAttributeStyle() | 3053 && !other.m_elementData->presentationAttributeStyle() |
3054 && (!other.m_elementData->inlineStyle() || !other.m_elementData->inlineS
tyle()->hasCSSOMWrapper())) | 3054 && (!other.m_elementData->inlineStyle() || !other.m_elementData->inlineS
tyle()->hasCSSOMWrapper())) |
3055 const_cast<Element&>(other).m_elementData = static_cast<const UniqueElem
entData*>(other.m_elementData.get())->makeShareableCopy(); | 3055 const_cast<Element&>(other).m_elementData = static_cast<const UniqueElem
entData*>(other.m_elementData.get())->makeShareableCopy(); |
3056 | 3056 |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3190 if (!isStyledElement()) | 3190 if (!isStyledElement()) |
3191 return 0; | 3191 return 0; |
3192 return ensureMutableInlineStyle()->ensureInlineCSSStyleDeclaration(this); | 3192 return ensureMutableInlineStyle()->ensureInlineCSSStyleDeclaration(this); |
3193 } | 3193 } |
3194 | 3194 |
3195 MutableStylePropertySet* Element::ensureMutableInlineStyle() | 3195 MutableStylePropertySet* Element::ensureMutableInlineStyle() |
3196 { | 3196 { |
3197 ASSERT(isStyledElement()); | 3197 ASSERT(isStyledElement()); |
3198 RefPtr<StylePropertySet>& inlineStyle = ensureUniqueElementData()->m_inlineS
tyle; | 3198 RefPtr<StylePropertySet>& inlineStyle = ensureUniqueElementData()->m_inlineS
tyle; |
3199 if (!inlineStyle) | 3199 if (!inlineStyle) |
3200 inlineStyle = MutableStylePropertySet::create(strictToCSSParserMode(isHT
MLElement() && !document()->inQuirksMode())); | 3200 inlineStyle = MutableStylePropertySet::create(strictToCSSParserMode(isHT
MLElement() && !document().inQuirksMode())); |
3201 else if (!inlineStyle->isMutable()) | 3201 else if (!inlineStyle->isMutable()) |
3202 inlineStyle = inlineStyle->mutableCopy(); | 3202 inlineStyle = inlineStyle->mutableCopy(); |
3203 ASSERT(inlineStyle->isMutable()); | 3203 ASSERT(inlineStyle->isMutable()); |
3204 return static_cast<MutableStylePropertySet*>(inlineStyle.get()); | 3204 return static_cast<MutableStylePropertySet*>(inlineStyle.get()); |
3205 } | 3205 } |
3206 | 3206 |
3207 PropertySetCSSStyleDeclaration* Element::inlineStyleCSSOMWrapper() | 3207 PropertySetCSSStyleDeclaration* Element::inlineStyleCSSOMWrapper() |
3208 { | 3208 { |
3209 if (!inlineStyle() || !inlineStyle()->hasCSSOMWrapper()) | 3209 if (!inlineStyle() || !inlineStyle()->hasCSSOMWrapper()) |
3210 return 0; | 3210 return 0; |
(...skipping 13 matching lines...) Expand all Loading... |
3224 | 3224 |
3225 // We reconstruct the property set instead of mutating if there is no CSSOM
wrapper. | 3225 // We reconstruct the property set instead of mutating if there is no CSSOM
wrapper. |
3226 // This makes wrapperless property sets immutable and so cacheable. | 3226 // This makes wrapperless property sets immutable and so cacheable. |
3227 if (inlineStyle && !inlineStyle->isMutable()) | 3227 if (inlineStyle && !inlineStyle->isMutable()) |
3228 inlineStyle.clear(); | 3228 inlineStyle.clear(); |
3229 | 3229 |
3230 if (!inlineStyle) { | 3230 if (!inlineStyle) { |
3231 inlineStyle = CSSParser::parseInlineStyleDeclaration(newStyleString, thi
s); | 3231 inlineStyle = CSSParser::parseInlineStyleDeclaration(newStyleString, thi
s); |
3232 } else { | 3232 } else { |
3233 ASSERT(inlineStyle->isMutable()); | 3233 ASSERT(inlineStyle->isMutable()); |
3234 static_pointer_cast<MutableStylePropertySet>(inlineStyle)->parseDeclarat
ion(newStyleString, document()->elementSheet()->contents()); | 3234 static_pointer_cast<MutableStylePropertySet>(inlineStyle)->parseDeclarat
ion(newStyleString, document().elementSheet()->contents()); |
3235 } | 3235 } |
3236 } | 3236 } |
3237 | 3237 |
3238 void Element::styleAttributeChanged(const AtomicString& newStyleString, Attribut
eModificationReason modificationReason) | 3238 void Element::styleAttributeChanged(const AtomicString& newStyleString, Attribut
eModificationReason modificationReason) |
3239 { | 3239 { |
3240 ASSERT(isStyledElement()); | 3240 ASSERT(isStyledElement()); |
3241 WTF::OrdinalNumber startLineNumber = WTF::OrdinalNumber::beforeFirst(); | 3241 WTF::OrdinalNumber startLineNumber = WTF::OrdinalNumber::beforeFirst(); |
3242 if (document()->scriptableDocumentParser() && !document()->isInDocumentWrite
()) | 3242 if (document().scriptableDocumentParser() && !document().isInDocumentWrite()
) |
3243 startLineNumber = document()->scriptableDocumentParser()->lineNumber(); | 3243 startLineNumber = document().scriptableDocumentParser()->lineNumber(); |
3244 | 3244 |
3245 if (newStyleString.isNull()) { | 3245 if (newStyleString.isNull()) { |
3246 if (PropertySetCSSStyleDeclaration* cssomWrapper = inlineStyleCSSOMWrapp
er()) | 3246 if (PropertySetCSSStyleDeclaration* cssomWrapper = inlineStyleCSSOMWrapp
er()) |
3247 cssomWrapper->clearParentElement(); | 3247 cssomWrapper->clearParentElement(); |
3248 ensureUniqueElementData()->m_inlineStyle.clear(); | 3248 ensureUniqueElementData()->m_inlineStyle.clear(); |
3249 } else if (modificationReason == ModifiedByCloning || document()->contentSec
urityPolicy()->allowInlineStyle(document()->url(), startLineNumber)) { | 3249 } else if (modificationReason == ModifiedByCloning || document().contentSecu
rityPolicy()->allowInlineStyle(document().url(), startLineNumber)) { |
3250 setInlineStyleFromString(newStyleString); | 3250 setInlineStyleFromString(newStyleString); |
3251 } | 3251 } |
3252 | 3252 |
3253 elementData()->m_styleAttributeIsDirty = false; | 3253 elementData()->m_styleAttributeIsDirty = false; |
3254 | 3254 |
3255 setNeedsStyleRecalc(LocalStyleChange); | 3255 setNeedsStyleRecalc(LocalStyleChange); |
3256 InspectorInstrumentation::didInvalidateStyleAttr(document(), this); | 3256 InspectorInstrumentation::didInvalidateStyleAttr(&document(), this); |
3257 } | 3257 } |
3258 | 3258 |
3259 void Element::inlineStyleChanged() | 3259 void Element::inlineStyleChanged() |
3260 { | 3260 { |
3261 ASSERT(isStyledElement()); | 3261 ASSERT(isStyledElement()); |
3262 setNeedsStyleRecalc(LocalStyleChange); | 3262 setNeedsStyleRecalc(LocalStyleChange); |
3263 ASSERT(elementData()); | 3263 ASSERT(elementData()); |
3264 elementData()->m_styleAttributeIsDirty = true; | 3264 elementData()->m_styleAttributeIsDirty = true; |
3265 InspectorInstrumentation::didInvalidateStyleAttr(document(), this); | 3265 InspectorInstrumentation::didInvalidateStyleAttr(&document(), this); |
3266 } | 3266 } |
3267 | 3267 |
3268 bool Element::setInlineStyleProperty(CSSPropertyID propertyID, CSSValueID identi
fier, bool important) | 3268 bool Element::setInlineStyleProperty(CSSPropertyID propertyID, CSSValueID identi
fier, bool important) |
3269 { | 3269 { |
3270 ASSERT(isStyledElement()); | 3270 ASSERT(isStyledElement()); |
3271 ensureMutableInlineStyle()->setProperty(propertyID, cssValuePool().createIde
ntifierValue(identifier), important); | 3271 ensureMutableInlineStyle()->setProperty(propertyID, cssValuePool().createIde
ntifierValue(identifier), important); |
3272 inlineStyleChanged(); | 3272 inlineStyleChanged(); |
3273 return true; | 3273 return true; |
3274 } | 3274 } |
3275 | 3275 |
3276 bool Element::setInlineStyleProperty(CSSPropertyID propertyID, CSSPropertyID ide
ntifier, bool important) | 3276 bool Element::setInlineStyleProperty(CSSPropertyID propertyID, CSSPropertyID ide
ntifier, bool important) |
3277 { | 3277 { |
3278 ASSERT(isStyledElement()); | 3278 ASSERT(isStyledElement()); |
3279 ensureMutableInlineStyle()->setProperty(propertyID, cssValuePool().createIde
ntifierValue(identifier), important); | 3279 ensureMutableInlineStyle()->setProperty(propertyID, cssValuePool().createIde
ntifierValue(identifier), important); |
3280 inlineStyleChanged(); | 3280 inlineStyleChanged(); |
3281 return true; | 3281 return true; |
3282 } | 3282 } |
3283 | 3283 |
3284 bool Element::setInlineStyleProperty(CSSPropertyID propertyID, double value, CSS
PrimitiveValue::UnitTypes unit, bool important) | 3284 bool Element::setInlineStyleProperty(CSSPropertyID propertyID, double value, CSS
PrimitiveValue::UnitTypes unit, bool important) |
3285 { | 3285 { |
3286 ASSERT(isStyledElement()); | 3286 ASSERT(isStyledElement()); |
3287 ensureMutableInlineStyle()->setProperty(propertyID, cssValuePool().createVal
ue(value, unit), important); | 3287 ensureMutableInlineStyle()->setProperty(propertyID, cssValuePool().createVal
ue(value, unit), important); |
3288 inlineStyleChanged(); | 3288 inlineStyleChanged(); |
3289 return true; | 3289 return true; |
3290 } | 3290 } |
3291 | 3291 |
3292 bool Element::setInlineStyleProperty(CSSPropertyID propertyID, const String& val
ue, bool important) | 3292 bool Element::setInlineStyleProperty(CSSPropertyID propertyID, const String& val
ue, bool important) |
3293 { | 3293 { |
3294 ASSERT(isStyledElement()); | 3294 ASSERT(isStyledElement()); |
3295 bool changes = ensureMutableInlineStyle()->setProperty(propertyID, value, im
portant, document()->elementSheet()->contents()); | 3295 bool changes = ensureMutableInlineStyle()->setProperty(propertyID, value, im
portant, document().elementSheet()->contents()); |
3296 if (changes) | 3296 if (changes) |
3297 inlineStyleChanged(); | 3297 inlineStyleChanged(); |
3298 return changes; | 3298 return changes; |
3299 } | 3299 } |
3300 | 3300 |
3301 bool Element::removeInlineStyleProperty(CSSPropertyID propertyID) | 3301 bool Element::removeInlineStyleProperty(CSSPropertyID propertyID) |
3302 { | 3302 { |
3303 ASSERT(isStyledElement()); | 3303 ASSERT(isStyledElement()); |
3304 if (!inlineStyle()) | 3304 if (!inlineStyle()) |
3305 return false; | 3305 return false; |
3306 bool changes = ensureMutableInlineStyle()->removeProperty(propertyID); | 3306 bool changes = ensureMutableInlineStyle()->removeProperty(propertyID); |
3307 if (changes) | 3307 if (changes) |
3308 inlineStyleChanged(); | 3308 inlineStyleChanged(); |
3309 return changes; | 3309 return changes; |
3310 } | 3310 } |
3311 | 3311 |
3312 void Element::removeAllInlineStyleProperties() | 3312 void Element::removeAllInlineStyleProperties() |
3313 { | 3313 { |
3314 ASSERT(isStyledElement()); | 3314 ASSERT(isStyledElement()); |
3315 if (!inlineStyle() || inlineStyle()->isEmpty()) | 3315 if (!inlineStyle() || inlineStyle()->isEmpty()) |
3316 return; | 3316 return; |
3317 ensureMutableInlineStyle()->clear(); | 3317 ensureMutableInlineStyle()->clear(); |
3318 inlineStyleChanged(); | 3318 inlineStyleChanged(); |
3319 } | 3319 } |
3320 | 3320 |
3321 void Element::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const | 3321 void Element::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const |
3322 { | 3322 { |
3323 ASSERT(isStyledElement()); | 3323 ASSERT(isStyledElement()); |
3324 if (const StylePropertySet* inlineStyle = elementData() ? elementData()->inl
ineStyle() : 0) | 3324 if (const StylePropertySet* inlineStyle = elementData() ? elementData()->inl
ineStyle() : 0) |
3325 inlineStyle->addSubresourceStyleURLs(urls, document()->elementSheet()->c
ontents()); | 3325 inlineStyle->addSubresourceStyleURLs(urls, document().elementSheet()->co
ntents()); |
3326 } | 3326 } |
3327 | 3327 |
3328 static inline bool attributeNameSort(const pair<StringImpl*, AtomicString>& p1,
const pair<StringImpl*, AtomicString>& p2) | 3328 static inline bool attributeNameSort(const pair<StringImpl*, AtomicString>& p1,
const pair<StringImpl*, AtomicString>& p2) |
3329 { | 3329 { |
3330 // Sort based on the attribute name pointers. It doesn't matter what the ord
er is as long as it is always the same. | 3330 // Sort based on the attribute name pointers. It doesn't matter what the ord
er is as long as it is always the same. |
3331 return p1.first < p2.first; | 3331 return p1.first < p2.first; |
3332 } | 3332 } |
3333 | 3333 |
3334 void Element::makePresentationAttributeCacheKey(PresentationAttributeCacheKey& r
esult) const | 3334 void Element::makePresentationAttributeCacheKey(PresentationAttributeCacheKey& r
esult) const |
3335 { | 3335 { |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3430 | 3430 |
3431 void Element::addPropertyToPresentationAttributeStyle(MutableStylePropertySet* s
tyle, CSSPropertyID propertyID, double value, CSSPrimitiveValue::UnitTypes unit) | 3431 void Element::addPropertyToPresentationAttributeStyle(MutableStylePropertySet* s
tyle, CSSPropertyID propertyID, double value, CSSPrimitiveValue::UnitTypes unit) |
3432 { | 3432 { |
3433 ASSERT(isStyledElement()); | 3433 ASSERT(isStyledElement()); |
3434 style->setProperty(propertyID, cssValuePool().createValue(value, unit)); | 3434 style->setProperty(propertyID, cssValuePool().createValue(value, unit)); |
3435 } | 3435 } |
3436 | 3436 |
3437 void Element::addPropertyToPresentationAttributeStyle(MutableStylePropertySet* s
tyle, CSSPropertyID propertyID, const String& value) | 3437 void Element::addPropertyToPresentationAttributeStyle(MutableStylePropertySet* s
tyle, CSSPropertyID propertyID, const String& value) |
3438 { | 3438 { |
3439 ASSERT(isStyledElement()); | 3439 ASSERT(isStyledElement()); |
3440 style->setProperty(propertyID, value, false, document()->elementSheet()->con
tents()); | 3440 style->setProperty(propertyID, value, false, document().elementSheet()->cont
ents()); |
3441 } | 3441 } |
3442 | 3442 |
3443 void ElementData::deref() | 3443 void ElementData::deref() |
3444 { | 3444 { |
3445 if (!derefBase()) | 3445 if (!derefBase()) |
3446 return; | 3446 return; |
3447 | 3447 |
3448 if (m_isUnique) | 3448 if (m_isUnique) |
3449 delete static_cast<UniqueElementData*>(this); | 3449 delete static_cast<UniqueElementData*>(this); |
3450 else | 3450 else |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3636 return 0; | 3636 return 0; |
3637 } | 3637 } |
3638 | 3638 |
3639 Attribute* UniqueElementData::attributeItem(unsigned index) | 3639 Attribute* UniqueElementData::attributeItem(unsigned index) |
3640 { | 3640 { |
3641 ASSERT_WITH_SECURITY_IMPLICATION(index < length()); | 3641 ASSERT_WITH_SECURITY_IMPLICATION(index < length()); |
3642 return &m_attributeVector.at(index); | 3642 return &m_attributeVector.at(index); |
3643 } | 3643 } |
3644 | 3644 |
3645 } // namespace WebCore | 3645 } // namespace WebCore |
OLD | NEW |