Commit 55c13aa9 authored by shrike's avatar shrike Committed by Commit bot

[Mac] Prevent omnibox text bg from drawing over decoration, focus ring.

The AutocompleteTextFieldEditor draws a background, apparently even when
you call setDrawsBackground:NO (at least during editing). Because of the
1pt spacing set by UX between the security decoration border and the
start of omnibox text, this background started drawing into the
decoration's hover rect. On the right edge it drew into the edge of the
focus ring.

This cl	prevents the AutocompleteTetFieldEditor	from drawing a
background, relying instead on the background drawn by the textfield's
cell. It also changes decorations to be drawn after the cell's interior,
to prevent the background overlap when not editing.

R=avi@chromium.org
BUG=669870,672518

Review-Url: https://codereview.chromium.org/2562863002
Cr-Commit-Position: refs/heads/master@{#437596}
parent 1a656aba
...@@ -375,6 +375,10 @@ size_t CalculatePositionsInFrame( ...@@ -375,6 +375,10 @@ size_t CalculatePositionsInFrame(
} }
- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView*)controlView { - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView*)controlView {
ui::ScopedCGContextSmoothFonts fontSmoothing;
[super drawInteriorWithFrame:cellFrame inView:controlView];
// NOTE: This method must closely match the logic in |-textFrameForFrame:|.
std::vector<LocationBarDecoration*> decorations; std::vector<LocationBarDecoration*> decorations;
std::vector<NSRect> decorationFrames; std::vector<NSRect> decorationFrames;
NSRect workingFrame; NSRect workingFrame;
...@@ -382,20 +386,15 @@ size_t CalculatePositionsInFrame( ...@@ -382,20 +386,15 @@ size_t CalculatePositionsInFrame(
CalculatePositionsInFrame(cellFrame, leftDecorations_, rightDecorations_, CalculatePositionsInFrame(cellFrame, leftDecorations_, rightDecorations_,
&decorations, &decorationFrames, &workingFrame); &decorations, &decorationFrames, &workingFrame);
// Draw the decorations. // Draw the decorations. Do this after drawing the interior because the
// field editor's background rect overlaps the right edge of the security
// decoration's hover rounded rect.
for (size_t i = 0; i < decorations.size(); ++i) { for (size_t i = 0; i < decorations.size(); ++i) {
if (decorations[i]) { if (decorations[i]) {
decorations[i]->DrawWithBackgroundInFrame(decorationFrames[i], decorations[i]->DrawWithBackgroundInFrame(decorationFrames[i],
controlView); controlView);
} }
} }
// NOTE: This function must closely match the logic in
// |-textFrameForFrame:|.
// Superclass draws text portion WRT original |cellFrame|.
ui::ScopedCGContextSmoothFonts fontSmoothing;
[super drawInteriorWithFrame:cellFrame inView:controlView];
} }
- (BOOL)canDropAtLocationInWindow:(NSPoint)location - (BOOL)canDropAtLocationInWindow:(NSPoint)location
......
...@@ -598,6 +598,20 @@ NSMenuItem* PasteAndGoMenuItemForObserver( ...@@ -598,6 +598,20 @@ NSMenuItem* PasteAndGoMenuItemForObserver(
[[FindPasteboard sharedInstance] setFindText:[selection string]]; [[FindPasteboard sharedInstance] setFindText:[selection string]];
} }
- (BOOL)isOpaque {
// Even if you call -setDrawsBackground:NO, the background still gets drawn
// when editing. This is a problem because the left edge of the background
// overlaps the security decoration's hover rect. Return that the textview
// is transparent, and follow up below by disabling any background drawing.
// This will cause background drawing to fall through to the cell. See
// https://crbug.com/669870 .
return NO;
}
- (void)drawViewBackgroundInRect:(NSRect)aRect {
// See the comment in -isOpaque.
}
- (void)drawRect:(NSRect)rect { - (void)drawRect:(NSRect)rect {
AutocompleteTextFieldObserver* observer = [self observer]; AutocompleteTextFieldObserver* observer = [self observer];
if (observer) if (observer)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment