|
|
Chromium Code Reviews|
Created:
3 years, 7 months ago by xdai1 Modified:
3 years, 7 months ago Reviewers:
michaelpg CC:
chromium-reviews, michaelpg+watch-md-settings_chromium.org, michaelpg+watch-md-ui_chromium.org, dbeam+watch-settings_chromium.org, stevenjb+watch-md-settings_chromium.org, arv+watch_chromium.org Target Ref:
refs/heads/master Project:
chromium Visibility:
Public. |
Description[CUPS] Fix the issue the default queue value not being persisted with each new printer setup.
BUG=710661
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation
Review-Url: https://codereview.chromium.org/2860883004
Cr-Commit-Position: refs/heads/master@{#469825}
Committed: https://chromium.googlesource.com/chromium/src/+/504e47cd10aa741e9315fdd02d8092cb5101dbff
Patch Set 1 #
Total comments: 1
Patch Set 2 : 2. #
Total comments: 4
Patch Set 3 : Address michaelpg@'s comment. #
Messages
Total messages: 16 (7 generated)
Description was changed from ========== [CUPS] Fix the issue the default queue value not being persisted with each new printer setup. BUG=710661 ========== to ========== [CUPS] Fix the issue the default queue value not being persisted with each new printer setup. BUG=710661 CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation ==========
xdai@chromium.org changed reviewers: + michaelpg@chromium.org
michaelpg@, could you help review this CL please? Thanks! https://codereview.chromium.org/2860883004/diff/1/chrome/browser/resources/se... File chrome/browser/resources/settings/printing_page/cups_add_printer_dialog.html (right): https://codereview.chromium.org/2860883004/diff/1/chrome/browser/resources/se... chrome/browser/resources/settings/printing_page/cups_add_printer_dialog.html:195: label="ipp/print" the label text was hard-coded since it doesn't require translation.
The CQ bit was checked by xdai@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
https://codereview.chromium.org/2860883004/diff/20001/chrome/browser/resource... File chrome/browser/resources/settings/printing_page/cups_add_printer_dialog.js (right): https://codereview.chromium.org/2860883004/diff/20001/chrome/browser/resource... chrome/browser/resources/settings/printing_page/cups_add_printer_dialog.js:160: this.newPrinter.printerQueue = "ipp/print"; here and elsewhere, why does this work? Normally Polymer would need to be notified of the change for data binding to update. Since this is setting a subproperty directly instead of with this.set(), I'd expect the UI to not get updated with the new value. Maybe it's okay here because we're closing the dialog, but what about in onProtocolChange_ below?
michaelpg@, I've addressed your comment. Please take another look, thanks! https://codereview.chromium.org/2860883004/diff/20001/chrome/browser/resource... File chrome/browser/resources/settings/printing_page/cups_add_printer_dialog.js (right): https://codereview.chromium.org/2860883004/diff/20001/chrome/browser/resource... chrome/browser/resources/settings/printing_page/cups_add_printer_dialog.js:160: this.newPrinter.printerQueue = "ipp/print"; On 2017/05/04 22:30:10, michaelpg wrote: > here and elsewhere, why does this work? Normally Polymer would need to be > notified of the change for data binding to update. Since this is setting a > subproperty directly instead of with this.set(), I'd expect the UI to not get > updated with the new value. > > Maybe it's okay here because we're closing the dialog, but what about in > onProtocolChange_ below? I think the root reason is it means I don't fully understand how Polymer data binding works... But for this specific case, I think the reason it works here and in onProtocolChange_() is there is no need of UI update for printerQueue and printerProtocol. I modified all the places that modify a subproperty to this.set(...).
lgtm https://codereview.chromium.org/2860883004/diff/20001/chrome/browser/resource... File chrome/browser/resources/settings/printing_page/cups_add_printer_dialog.js (right): https://codereview.chromium.org/2860883004/diff/20001/chrome/browser/resource... chrome/browser/resources/settings/printing_page/cups_add_printer_dialog.js:160: this.newPrinter.printerQueue = "ipp/print"; On 2017/05/05 00:45:37, xdai1 wrote: > On 2017/05/04 22:30:10, michaelpg wrote: > > here and elsewhere, why does this work? Normally Polymer would need to be > > notified of the change for data binding to update. Since this is setting a > > subproperty directly instead of with this.set(), I'd expect the UI to not get > > updated with the new value. > > > > Maybe it's okay here because we're closing the dialog, but what about in > > onProtocolChange_ below? > > I think the root reason is it means I don't fully understand how Polymer data > binding works... It's black magic, none of us do :-) But generally, Polymer automatically notices and propagates a change *only* if the property being set is a top-level Polymer property, *or* if you call this.set/this.notifyPath. https://www.polymer-project.org/1.0/docs/devguide/model-data#set-path Polymer properties, like this.newPrinter, are setters/getters. When you "set" this.newPrinter = foo, you actually call a Polymer method, which takes care of updating the backing "newPrinter" value *and* notifies observers and bindings that the value of this.newPrinter is changed. When you update a sub-property, like this.newPrinter.bar = foo, Polymer doesn't know. this.newPrinter is just a getter, so it returns the real "newPrinter" object. Setting a property of that object doesn't trigger any magic because it's just a plain old JavaScript object. > But for this specific case, I think the reason it works here > and in onProtocolChange_() is there is no need of UI update for printerQueue and > printerProtocol. > > I modified all the places that modify a subproperty to this.set(...).
On 2017/05/05 19:10:46, michaelpg wrote: > lgtm > > https://codereview.chromium.org/2860883004/diff/20001/chrome/browser/resource... > File chrome/browser/resources/settings/printing_page/cups_add_printer_dialog.js > (right): > > https://codereview.chromium.org/2860883004/diff/20001/chrome/browser/resource... > chrome/browser/resources/settings/printing_page/cups_add_printer_dialog.js:160: > this.newPrinter.printerQueue = "ipp/print"; > On 2017/05/05 00:45:37, xdai1 wrote: > > On 2017/05/04 22:30:10, michaelpg wrote: > > > here and elsewhere, why does this work? Normally Polymer would need to be > > > notified of the change for data binding to update. Since this is setting a > > > subproperty directly instead of with this.set(), I'd expect the UI to not > get > > > updated with the new value. > > > > > > Maybe it's okay here because we're closing the dialog, but what about in > > > onProtocolChange_ below? > > > > I think the root reason is it means I don't fully understand how Polymer data > > binding works... > > It's black magic, none of us do :-) > > But generally, Polymer automatically notices and propagates a change *only* if > the property being set is a top-level Polymer property, *or* if you call > this.set/this.notifyPath. > https://www.polymer-project.org/1.0/docs/devguide/model-data#set-path > > Polymer properties, like this.newPrinter, are setters/getters. When you "set" > this.newPrinter = foo, you actually call a Polymer method, which takes care of > updating the backing "newPrinter" value *and* notifies observers and bindings > that the value of this.newPrinter is changed. > > When you update a sub-property, like this.newPrinter.bar = foo, Polymer doesn't > know. this.newPrinter is just a getter, so it returns the real "newPrinter" > object. Setting a property of that object doesn't trigger any magic because it's > just a plain old JavaScript object. Thank you very much for so detailed explanation!! Updating a sub-property using this.newPrinter.bar = foo only updates the backing "newPrinter" value but doesn't notify observers. But this.set(..) does both. So whenever possible, we should use this.set(..) to update a sub-property. right? > > > But for this specific case, I think the reason it works here > > and in onProtocolChange_() is there is no need of UI update for printerQueue > and > > printerProtocol. > > > > I modified all the places that modify a subproperty to this.set(...).
https://codereview.chromium.org/2860883004/diff/20001/chrome/browser/resource... File chrome/browser/resources/settings/printing_page/cups_add_printer_dialog.js (right): https://codereview.chromium.org/2860883004/diff/20001/chrome/browser/resource... chrome/browser/resources/settings/printing_page/cups_add_printer_dialog.js:160: this.newPrinter.printerQueue = "ipp/print"; On 2017/05/05 19:10:46, michaelpg wrote: > On 2017/05/05 00:45:37, xdai1 wrote: > > On 2017/05/04 22:30:10, michaelpg wrote: > > > here and elsewhere, why does this work? Normally Polymer would need to be > > > notified of the change for data binding to update. Since this is setting a > > > subproperty directly instead of with this.set(), I'd expect the UI to not > get > > > updated with the new value. > > > > > > Maybe it's okay here because we're closing the dialog, but what about in > > > onProtocolChange_ below? > > > > I think the root reason is it means I don't fully understand how Polymer data > > binding works... > > It's black magic, none of us do :-) > > But generally, Polymer automatically notices and propagates a change *only* if > the property being set is a top-level Polymer property, *or* if you call > this.set/this.notifyPath. > https://www.polymer-project.org/1.0/docs/devguide/model-data#set-path > > Polymer properties, like this.newPrinter, are setters/getters. When you "set" > this.newPrinter = foo, you actually call a Polymer method, which takes care of > updating the backing "newPrinter" value *and* notifies observers and bindings > that the value of this.newPrinter is changed. > > When you update a sub-property, like this.newPrinter.bar = foo, Polymer doesn't > know. this.newPrinter is just a getter, so it returns the real "newPrinter" > object. Setting a property of that object doesn't trigger any magic because it's > just a plain old JavaScript object. > > > But for this specific case, I think the reason it works here > > and in onProtocolChange_() is there is no need of UI update for printerQueue > and > > printerProtocol. > > > > I modified all the places that modify a subproperty to this.set(...). > Replying to your message: > Thank you very much for so detailed explanation!! Updating a sub-property using > this.newPrinter.bar = foo only updates the backing "newPrinter" value but > doesn't notify observers. But this.set(..) does both. So whenever possible, we > should use this.set(..) to update a sub-property. right? Basically, yes. Unless you can guarantee that it won't affect the UI, like if you're always setting this.newPrinter to a completely new object. You can still update a sub-property with normal data binding too: <paper-input value="{{newPrinter.foo}}">
On 2017/05/05 20:45:50, michaelpg wrote: > https://codereview.chromium.org/2860883004/diff/20001/chrome/browser/resource... > File chrome/browser/resources/settings/printing_page/cups_add_printer_dialog.js > (right): > > https://codereview.chromium.org/2860883004/diff/20001/chrome/browser/resource... > chrome/browser/resources/settings/printing_page/cups_add_printer_dialog.js:160: > this.newPrinter.printerQueue = "ipp/print"; > On 2017/05/05 19:10:46, michaelpg wrote: > > On 2017/05/05 00:45:37, xdai1 wrote: > > > On 2017/05/04 22:30:10, michaelpg wrote: > > > > here and elsewhere, why does this work? Normally Polymer would need to be > > > > notified of the change for data binding to update. Since this is setting a > > > > subproperty directly instead of with this.set(), I'd expect the UI to not > > get > > > > updated with the new value. > > > > > > > > Maybe it's okay here because we're closing the dialog, but what about in > > > > onProtocolChange_ below? > > > > > > I think the root reason is it means I don't fully understand how Polymer > data > > > binding works... > > > > It's black magic, none of us do :-) > > > > But generally, Polymer automatically notices and propagates a change *only* if > > the property being set is a top-level Polymer property, *or* if you call > > this.set/this.notifyPath. > > https://www.polymer-project.org/1.0/docs/devguide/model-data#set-path > > > > Polymer properties, like this.newPrinter, are setters/getters. When you "set" > > this.newPrinter = foo, you actually call a Polymer method, which takes care of > > updating the backing "newPrinter" value *and* notifies observers and bindings > > that the value of this.newPrinter is changed. > > > > When you update a sub-property, like this.newPrinter.bar = foo, Polymer > doesn't > > know. this.newPrinter is just a getter, so it returns the real "newPrinter" > > object. Setting a property of that object doesn't trigger any magic because > it's > > just a plain old JavaScript object. > > > > > But for this specific case, I think the reason it works here > > > and in onProtocolChange_() is there is no need of UI update for printerQueue > > and > > > printerProtocol. > > > > > > I modified all the places that modify a subproperty to this.set(...). > > > > > Replying to your message: > > > Thank you very much for so detailed explanation!! Updating a sub-property > using > > this.newPrinter.bar = foo only updates the backing "newPrinter" value but > > doesn't notify observers. But this.set(..) does both. So whenever possible, we > > should use this.set(..) to update a sub-property. right? > > Basically, yes. Unless you can guarantee that it won't affect the UI, like if > you're always setting this.newPrinter to a completely new object. > > You can still update a sub-property with normal data binding too: > <paper-input value="{{newPrinter.foo}}"> Got it. Thank you very much!
The CQ bit was checked by xdai@chromium.org
CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
CQ is committing da patch.
Bot data: {"patchset_id": 40001, "attempt_start_ts": 1494022774002530,
"parent_rev": "c8faec73855c122f94f00c54549ee6542da59e9b", "commit_rev":
"504e47cd10aa741e9315fdd02d8092cb5101dbff"}
Message was sent while issue was closed.
Description was changed from ========== [CUPS] Fix the issue the default queue value not being persisted with each new printer setup. BUG=710661 CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation ========== to ========== [CUPS] Fix the issue the default queue value not being persisted with each new printer setup. BUG=710661 CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation Review-Url: https://codereview.chromium.org/2860883004 Cr-Commit-Position: refs/heads/master@{#469825} Committed: https://chromium.googlesource.com/chromium/src/+/504e47cd10aa741e9315fdd02d80... ==========
Message was sent while issue was closed.
Committed patchset #3 (id:40001) as https://chromium.googlesource.com/chromium/src/+/504e47cd10aa741e9315fdd02d80... |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
