| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). | 2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
| 3 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 3 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 4 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 4 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 5 * (C) 2001 Dirk Mueller (mueller@kde.org) | 5 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 6 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2011 Apple Inc. All rights | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2011 Apple Inc. All rights |
| 7 * reserved. | 7 * reserved. |
| 8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) | 8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) |
| 9 * Copyright (C) 2010 Google Inc. All rights reserved. | 9 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 10 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. | 10 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 #include "bindings/core/v8/HTMLElementOrLong.h" | 35 #include "bindings/core/v8/HTMLElementOrLong.h" |
| 36 #include "bindings/core/v8/HTMLOptionElementOrHTMLOptGroupElement.h" | 36 #include "bindings/core/v8/HTMLOptionElementOrHTMLOptGroupElement.h" |
| 37 #include "core/HTMLNames.h" | 37 #include "core/HTMLNames.h" |
| 38 #include "core/dom/AXObjectCache.h" | 38 #include "core/dom/AXObjectCache.h" |
| 39 #include "core/dom/Attribute.h" | 39 #include "core/dom/Attribute.h" |
| 40 #include "core/dom/ElementTraversal.h" | 40 #include "core/dom/ElementTraversal.h" |
| 41 #include "core/dom/ExecutionContextTask.h" | 41 #include "core/dom/ExecutionContextTask.h" |
| 42 #include "core/dom/MutationCallback.h" | 42 #include "core/dom/MutationCallback.h" |
| 43 #include "core/dom/MutationObserver.h" | 43 #include "core/dom/MutationObserver.h" |
| 44 #include "core/dom/MutationObserverInit.h" | 44 #include "core/dom/MutationObserverInit.h" |
| 45 #include "core/dom/MutationRecord.h" |
| 45 #include "core/dom/NodeComputedStyle.h" | 46 #include "core/dom/NodeComputedStyle.h" |
| 46 #include "core/dom/NodeListsNodeData.h" | 47 #include "core/dom/NodeListsNodeData.h" |
| 47 #include "core/dom/NodeTraversal.h" | 48 #include "core/dom/NodeTraversal.h" |
| 48 #include "core/events/GestureEvent.h" | 49 #include "core/events/GestureEvent.h" |
| 49 #include "core/events/KeyboardEvent.h" | 50 #include "core/events/KeyboardEvent.h" |
| 50 #include "core/events/MouseEvent.h" | 51 #include "core/events/MouseEvent.h" |
| 51 #include "core/events/ScopedEventQueue.h" | 52 #include "core/events/ScopedEventQueue.h" |
| 52 #include "core/frame/FrameHost.h" | 53 #include "core/frame/FrameHost.h" |
| 53 #include "core/frame/FrameView.h" | 54 #include "core/frame/FrameView.h" |
| 54 #include "core/frame/LocalFrame.h" | 55 #include "core/frame/LocalFrame.h" |
| (...skipping 1905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1960 // PopupUpdater notifies updates of the specified SELECT element subtree to | 1961 // PopupUpdater notifies updates of the specified SELECT element subtree to |
| 1961 // a PopupMenu object. | 1962 // a PopupMenu object. |
| 1962 class HTMLSelectElement::PopupUpdater : public MutationCallback { | 1963 class HTMLSelectElement::PopupUpdater : public MutationCallback { |
| 1963 public: | 1964 public: |
| 1964 explicit PopupUpdater(HTMLSelectElement&); | 1965 explicit PopupUpdater(HTMLSelectElement&); |
| 1965 DECLARE_VIRTUAL_TRACE(); | 1966 DECLARE_VIRTUAL_TRACE(); |
| 1966 | 1967 |
| 1967 void dispose() { m_observer->disconnect(); } | 1968 void dispose() { m_observer->disconnect(); } |
| 1968 | 1969 |
| 1969 private: | 1970 private: |
| 1970 void call(const HeapVector<Member<MutationRecord>>&, | 1971 void call(const HeapVector<Member<MutationRecord>>& records, |
| 1971 MutationObserver*) override { | 1972 MutationObserver*) override { |
| 1972 // We disconnect the MutationObserver when a popuup is closed. However | 1973 // We disconnect the MutationObserver when a popuup is closed. However |
| 1973 // MutationObserver can call back after disconnection. | 1974 // MutationObserver can call back after disconnection. |
| 1974 if (!m_select->popupIsVisible()) | 1975 if (!m_select->popupIsVisible()) |
| 1975 return; | 1976 return; |
| 1976 m_select->didMutateSubtree(); | 1977 for (const auto& record : records) { |
| 1978 if (record->type() == "attributes") { |
| 1979 const Element& element = *toElement(record->target()); |
| 1980 if (record->oldValue() == element.getAttribute(record->attributeName())) |
| 1981 continue; |
| 1982 } else if (record->type() == "characterData") { |
| 1983 if (record->oldValue() == record->target()->nodeValue()) |
| 1984 continue; |
| 1985 } |
| 1986 m_select->didMutateSubtree(); |
| 1987 return; |
| 1988 } |
| 1977 } | 1989 } |
| 1978 | 1990 |
| 1979 ExecutionContext* getExecutionContext() const override { | 1991 ExecutionContext* getExecutionContext() const override { |
| 1980 return &m_select->document(); | 1992 return &m_select->document(); |
| 1981 } | 1993 } |
| 1982 | 1994 |
| 1983 Member<HTMLSelectElement> m_select; | 1995 Member<HTMLSelectElement> m_select; |
| 1984 Member<MutationObserver> m_observer; | 1996 Member<MutationObserver> m_observer; |
| 1985 }; | 1997 }; |
| 1986 | 1998 |
| 1987 HTMLSelectElement::PopupUpdater::PopupUpdater(HTMLSelectElement& select) | 1999 HTMLSelectElement::PopupUpdater::PopupUpdater(HTMLSelectElement& select) |
| 1988 : m_select(select) { | 2000 : m_select(select) { |
| 1989 m_observer = MutationObserver::create(this); | 2001 m_observer = MutationObserver::create(this); |
| 1990 Vector<String> filter; | 2002 Vector<String> filter; |
| 1991 filter.reserveCapacity(4); | 2003 filter.reserveCapacity(4); |
| 1992 // Observe only attributes which affect popup content. | 2004 // Observe only attributes which affect popup content. |
| 1993 filter.append(String("disabled")); | 2005 filter.append(String("disabled")); |
| 1994 filter.append(String("label")); | 2006 filter.append(String("label")); |
| 1995 filter.append(String("selected")); | 2007 filter.append(String("selected")); |
| 1996 filter.append(String("value")); | 2008 filter.append(String("value")); |
| 1997 MutationObserverInit init; | 2009 MutationObserverInit init; |
| 2010 init.setAttributeOldValue(true); |
| 1998 init.setAttributes(true); | 2011 init.setAttributes(true); |
| 1999 init.setAttributeFilter(filter); | 2012 init.setAttributeFilter(filter); |
| 2000 init.setCharacterData(true); | 2013 init.setCharacterData(true); |
| 2014 init.setCharacterDataOldValue(true); |
| 2001 init.setChildList(true); | 2015 init.setChildList(true); |
| 2002 init.setSubtree(true); | 2016 init.setSubtree(true); |
| 2003 m_observer->observe(&select, init, ASSERT_NO_EXCEPTION); | 2017 m_observer->observe(&select, init, ASSERT_NO_EXCEPTION); |
| 2004 } | 2018 } |
| 2005 | 2019 |
| 2006 DEFINE_TRACE(HTMLSelectElement::PopupUpdater) { | 2020 DEFINE_TRACE(HTMLSelectElement::PopupUpdater) { |
| 2007 visitor->trace(m_select); | 2021 visitor->trace(m_select); |
| 2008 visitor->trace(m_observer); | 2022 visitor->trace(m_observer); |
| 2009 MutationCallback::trace(visitor); | 2023 MutationCallback::trace(visitor); |
| 2010 } | 2024 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2021 m_popupUpdater = nullptr; | 2035 m_popupUpdater = nullptr; |
| 2022 } | 2036 } |
| 2023 | 2037 |
| 2024 void HTMLSelectElement::didMutateSubtree() { | 2038 void HTMLSelectElement::didMutateSubtree() { |
| 2025 DCHECK(popupIsVisible()); | 2039 DCHECK(popupIsVisible()); |
| 2026 DCHECK(m_popup); | 2040 DCHECK(m_popup); |
| 2027 m_popup->updateFromElement(PopupMenu::ByDOMChange); | 2041 m_popup->updateFromElement(PopupMenu::ByDOMChange); |
| 2028 } | 2042 } |
| 2029 | 2043 |
| 2030 } // namespace blink | 2044 } // namespace blink |
| OLD | NEW |