OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 20 matching lines...) Loading... | |
31 #include "public/platform/WebColor.h" | 31 #include "public/platform/WebColor.h" |
32 #include "public/web/WebColorChooser.h" | 32 #include "public/web/WebColorChooser.h" |
33 #include "public/web/WebColorSuggestion.h" | 33 #include "public/web/WebColorSuggestion.h" |
34 #include "public/web/WebFrameClient.h" | 34 #include "public/web/WebFrameClient.h" |
35 #include "web/WebLocalFrameImpl.h" | 35 #include "web/WebLocalFrameImpl.h" |
36 | 36 |
37 namespace blink { | 37 namespace blink { |
38 | 38 |
39 | 39 |
40 ColorChooserUIController::ColorChooserUIController(LocalFrame* frame, ColorChoos erClient* client) | 40 ColorChooserUIController::ColorChooserUIController(LocalFrame* frame, ColorChoos erClient* client) |
41 : m_frame(frame) | 41 : m_client(client) |
42 , m_client(client) | 42 , m_frame(frame) |
43 { | 43 { |
44 } | 44 } |
45 | 45 |
46 ColorChooserUIController::~ColorChooserUIController() | 46 ColorChooserUIController::~ColorChooserUIController() |
47 { | 47 { |
48 // The client cannot be accessed when finalizing. | |
49 m_client = nullptr; | |
50 endChooser(); | |
51 } | |
52 | |
53 void ColorChooserUIController::trace(Visitor* visitor) | |
54 { | |
55 visitor->trace(m_frame); | |
56 visitor->trace(m_client); | |
57 ColorChooser::trace(visitor); | |
48 } | 58 } |
49 | 59 |
50 void ColorChooserUIController::openUI() | 60 void ColorChooserUIController::openUI() |
51 { | 61 { |
52 openColorChooser(); | 62 openColorChooser(); |
53 } | 63 } |
54 | 64 |
55 void ColorChooserUIController::setSelectedColor(const Color& color) | 65 void ColorChooserUIController::setSelectedColor(const Color& color) |
56 { | 66 { |
57 ASSERT(m_chooser); | 67 ASSERT(m_chooser); |
(...skipping 12 matching lines...) Loading... | |
70 } | 80 } |
71 | 81 |
72 void ColorChooserUIController::didChooseColor(const WebColor& color) | 82 void ColorChooserUIController::didChooseColor(const WebColor& color) |
73 { | 83 { |
74 ASSERT(m_client); | 84 ASSERT(m_client); |
75 m_client->didChooseColor(Color(static_cast<RGBA32>(color))); | 85 m_client->didChooseColor(Color(static_cast<RGBA32>(color))); |
76 } | 86 } |
77 | 87 |
78 void ColorChooserUIController::didEndChooser() | 88 void ColorChooserUIController::didEndChooser() |
79 { | 89 { |
80 ASSERT(m_client); | 90 ASSERT(m_client); |
haraken
2014/10/07 08:27:35
I think you need to remove this ASSERT.
sof
2014/10/08 10:26:34
Done.
| |
81 m_chooser = nullptr; | 91 m_chooser = nullptr; |
82 m_client->didEndChooser(); | 92 if (m_client) |
93 m_client->didEndChooser(); | |
83 } | 94 } |
84 | 95 |
85 void ColorChooserUIController::openColorChooser() | 96 void ColorChooserUIController::openColorChooser() |
86 { | 97 { |
87 ASSERT(!m_chooser); | 98 ASSERT(!m_chooser); |
88 WebLocalFrameImpl* frame = WebLocalFrameImpl::fromFrame(m_frame); | 99 WebLocalFrameImpl* frame = WebLocalFrameImpl::fromFrame(m_frame); |
89 WebFrameClient* webFrameClient = frame->client(); | 100 WebFrameClient* webFrameClient = frame->client(); |
90 if (!webFrameClient) | 101 if (!webFrameClient) |
91 return; | 102 return; |
92 m_chooser = adoptPtr(webFrameClient->createColorChooser( | 103 m_chooser = adoptPtr(webFrameClient->createColorChooser( |
93 this, static_cast<WebColor>(m_client->currentColor().rgb()), m_client->s uggestions())); | 104 this, static_cast<WebColor>(m_client->currentColor().rgb()), m_client->s uggestions())); |
94 } | 105 } |
95 | 106 |
96 } // namespace blink | 107 } // namespace blink |
OLD | NEW |